NASA can deny movies using their logo and name.
This general permission does not extend to use of the NASA insignia logo (the blue "meatball" insignia), the retired NASA logotype (the red "worm" logo) and the NASA seal. These images may not be used by persons who are not NASA employees or on products (including Web pages) that are not NASA-sponsored.
- NASA Guidelines
Usually they want to give script approval before they allow movies to use their name and logo. In the case of Farscape, they did not allow their logo to be used, so the movie had to make the necessary changes:
Crichton was going to be a NASA astronaut, but NASA requested script approval for the use of their logos, so "NASA" became the "IASA". ("Cool Farscape Facts" - Starburst Edition DVD v1.1)
- Farscape Wiki
NASA's excitement and fondness of the movie The Martian is well documented and reported. As such, it is very likely they gave script approval (especially because there was no drama and close to reality... in a movie kind of way).