I'm not a MD resident and I'm not a lawyer. I have had to go to MD frequently and have several friends that live there.
I've read most of MD statutes from the Criminal Law Article §4–101 thru §4–503 and have yet to find anything that prohibits possession of a rifle. §4–203 only pertains to handguns; The Public Safety Article, §5, seems to only pertain to the sale and transfer of regulated firearms ( and possession of regulated firearms by prohibited persons).
I believe the M4 carbine, though not explicitly specified, could be construed to be a regulated firearm as per §5-101 of the Public Safety Article, however I don't see how that would prevent you from possessing it in Maryland; unless, of course, you're a prohibited person as per §5–133.
I'd think you're good to go, but you should read the code yourself first.
Lastly, the only code I found related to high-cap magazines was one about more than 20 rounds during the commission of a crime ( I forget the code section); and
§4–305. (a)This section does not apply to a .22 caliber rifle with a tubular magazine.(b)A person may not manufacture, sell, offer for sale, purchase, receive, or transfer a detachable magazine that has a capacity of more than 20 rounds of ammunition for a firearm.