mount.cifs: fix crash when mount point does not exist
Subsystems (2)
PATCH 1/1 mount.cifs: fix crash when mount point does not exist
@mountpointp is initially set to a statically allocated string in main(), and if we fail to update it in acquire_mountpoint(), make sure to set it to NULL and avoid freeing it at mount_exit.
This fixes the following crash
$ mount.cifs //srv/share /mnt/foo/bar -o ... Couldn't chdir to /mnt/foo/bar: No such file or directory munmap_chunk(): invalid pointer Aborted
--- mount.cifs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
mount.cifs.c +8 -5
@@ -1996,9 +1996,9 @@ acquire_mountpoint(char **mountpointp)*/ realuid =getuid ();if (realuid ==0 ) { - dacrc =toggle_dac_capability (0 ,1 ); -if (dacrc) -return dacrc; + rc =toggle_dac_capability (0 ,1 ); +if (rc) + goto out; }else { oldfsuid =setfsuid (realuid); oldfsgid =setfsgid (getgid ());
@@ -2019,7 +2019,6 @@ acquire_mountpoint(char **mountpointp) rc =EX_SYSERR ; } - *mountpointp = mountpoint; restore_privs:if (realuid ==0 ) { dacrc =toggle_dac_capability (0 ,0 );
@@ -2030,9 +2029,13 @@ restore_privs:gid_t __attribute__((unused)) gignore =setfsgid (oldfsgid); } -if (rc) +out: +if (rc) {free (mountpoint); + mountpoint =NULL ; + } + *mountpointp = mountpoint;return rc; }
Signature · 1 line
2.31.1
Quoted 10 lines · Paulo Alcantara
@mountpointp is initially set to a statically allocated string in
main(), and if we fail to update it inacquire_mountpoint(), make sure to set it to NULL and avoid freeing it atmount_exit.This fixes the following crash
$ mount.cifs //srv/share /mnt/foo/bar -o ... Couldn't chdir to /mnt/foo/bar: No such file or directory munmap_chunk(): invalid pointer Aborted
LGTM
Cheers,
Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
пт, 7 мая 2021 г. в 03:42, Aurélien Aptel <[email protected]>:
Quoted 15 lines
Quoted 10 lines · Paulo Alcantara
@mountpointp is initially set to a statically allocated string in
main(), and if we fail to update it inacquire_mountpoint(), make sure to set it to NULL and avoid freeing it atmount_exit.This fixes the following crash
$ mount.cifs //srv/share /mnt/foo/bar -o ... Couldn't chdir to /mnt/foo/bar: No such file or directory munmap_chunk(): invalid pointer AbortedLGTM
Quoted 9 lines
Reviewed-by Aurelien Aptel <[email protected]>Cheers,
--
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
Merged. Thanks!
--
Best regards,
Pavel Shilovsky