Yes the AOS can be filed. It should be done asap before his stay under his visa expires. He wants to have the I 791 receipt notice for the I485 in hand before the end of visit date comes. Note that he cannot leave the US until he has his GCard or travel permit ( if he applied for one.) If he. leaves before this is processed he will be deemed as abandoning the AOS process. He cannot work until he has his GC or work authorisation if he applies for one. He is unlikely to be able to get any health coverage other than catastrophic /short term visitors cover which will not cover dr visits , medication etc. He will need certain documents which may be difficult to obtain from outside his home country. As desirable as it may seem now for him to stay rather than return home, it can be a very lengthy process and many find it way more restrictive than they expect. So yes it is legal and possible but not without challenges.