All cars you mentioned: Mazda CX-5, CX-9 and Jeep Cherokee have almost the same front headroom and legroom.
Mazda CX-5:
Front Head Room: 39.3 inches
Front Leg Room: 41 inches
Mazda CX-9:
Front Head Room: 40.1 inches
Front Leg Room: 41 inches
Jeep Cherokee:
Front Head Room: 39.4 inches
Front Leg Room: 41.1 inches
These vehicles under $40,000 have plenty of space.
Nissan Pathfinder: From $33,880
Front Head Room (inches): 42.3
Front Leg Room (inches): 44.3
Hyundai Palisade: From $34,595
Front Head Room (inches): 40.7
Front Leg Room (inches) 44.1
Ford Explorer: From $33,745
Front Head Room (inches): 40.7
Front Leg Room (inches): 43
What I would recommend is go to different car dealers and sit in different vehicles. That's the only way to be sure.