Yes, a lender can charge all these fees as closing costs depending on the type of loan.
For example on VA loans the lender is prohibited from charging a loan processing fee and/or an underwriting fee and certain other fees if the veteran is paying an origination fee. On VA purchase transactions the seller typically pays these fees. On refinances or if the seller is not paying these fees in a purchase transaction the lender takes into account that they will not receive that income when they set the interest rate on VA loans.
FHA and conventional loans do not have any restrictions on charging a processing and underwriting fee in addition to an origination fee. Even though lenders are prohibited from charging a tax service fee on FHA loans.
An interesting historical note on the origin of the underwriting fee. Before lenders were delegated by FHA and VA to underwrite FHA and VA loans, these loans were sent to FHA and VA to be underwritten by government paid employees. Lenders did not have the expense of hiring underwriters to underwrite the loans. When the responsibility for underwriting was transferred to lenders they instituted an underwriting fee to offset the additional costs incurred to hire and train underwriters to underwrite the loans. While this increased the cost to consumers it also streamlined the lending process and took weeks off of the time it took to process a loan from application to closing. Transactions with FHA and VA loans that took 60 to 90 days at a minimum when the loans were sent to Federal employees to underwrite can now be done in less than 30 days in many instances when the underwriting is done in house by the lender.