From: Pavel Shilovsky <piastryyy@gmail.com>
To: "Aurélien Aptel" <aaptel@suse.com>
Cc: "Paulo Alcantara (SUSE)" <paulo@paulo.ac>,
samba-technical <samba-technical@lists.samba.org>,
linux-cifs <linux-cifs@vger.kernel.org>
Subject: Re: [PATCH] mount.cifs: Fix double-free issue when mounting with setuid root
Date: Thu, 3 Oct 2019 17:22:27 -0700 [thread overview]
Message-ID: <CAKywueQZSHj6autWPkyjhnfpEttFbr=81Y6a7_tWSQVnr-PmJw@mail.gmail.com> (raw)
In-Reply-To: <87k1ahiqmd.fsf@suse.com>
пн, 9 сент. 2019 г. в 05:46, Aurélien Aptel <aaptel@suse.com>:
>
> " Paulo Alcantara (SUSE) " <paulo@paulo.ac> writes:
> > It can be easily reproduced with the following:
> >
> > # chmod +s `which mount.cifs`
> > # echo "//localhost/share /mnt cifs \
> > users,username=foo,password=XXXX" >> /etc/fstab
> > # su - foo
> > $ mount /mnt
> > free(): double free detected in tcache 2
> > Child process terminated abnormally.
> >
> > The problem was that check_fstab() already freed orgoptions pointer
> > and then we freed it again in main() function.
> >
> > Fixes: bf7f48f4c7dc ("mount.cifs.c: fix memory leaks in main func")
> > Signed-off-by: Paulo Alcantara (SUSE) <paulo@paulo.ac>
>
> Reviewed-by: Aurelien Aptel <aaptel@suse.com>
>
> I've compiled next branch with ASAN and can confirm the double-free and
> the fix works
>
> Compiling with ASAN
> -------------------
>
> $ CFLAGS=-fsanitize=address \
> LDFLAGS=-fsanitize=address \
> ac_cv_func_malloc_0_nonnull=yes \
> ./configure
> $ make clean && make -j4
>
> Next branch
> -----------
>
> $ mount /mnt; echo $?
> =================================================================
> ==29883==ERROR: AddressSanitizer: attempting double-free on 0x607000000020 in thread T0:
> #0 0x7f69d480a1b8 in __interceptor_free (/usr/lib64/libasan.so.4+0xdc1b8)
> #1 0x559381795f33 in main (/sbin/mount.cifs+0xef33)
> #2 0x7f69d4394f89 in __libc_start_main (/lib64/libc.so.6+0x20f89)
> #3 0x55938178e079 in _start (/sbin/mount.cifs+0x7079)
>
> 0x607000000020 is located 0 bytes inside of 68-byte region [0x607000000020,0x607000000064)
> freed by thread T0 here:
> #0 0x7f69d480a1b8 in __interceptor_free (/usr/lib64/libasan.so.4+0xdc1b8)
> #1 0x55938178e372 in check_fstab (/sbin/mount.cifs+0x7372)
> #2 0x559381794661 in assemble_mountinfo (/sbin/mount.cifs+0xd661)
> #3 0x559381795eef in main (/sbin/mount.cifs+0xeeef)
> #4 0x7f69d4394f89 in __libc_start_main (/lib64/libc.so.6+0x20f89)
>
> previously allocated by thread T0 here:
> #0 0x7f69d480a510 in malloc (/usr/lib64/libasan.so.4+0xdc510)
> #1 0x7f69d43fc2a9 in __GI___strndup (/lib64/libc.so.6+0x882a9)
>
> SUMMARY: AddressSanitizer: double-free (/usr/lib64/libasan.so.4+0xdc1b8) in __interceptor_free
> ==29883==ABORTING
> 1
>
> With fix
> --------
>
> $ mount /mnt; echo $?
> 0
>
> 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
prev parent reply other threads:[~2019-10-04 0:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-05 18:49 [PATCH] mount.cifs: Fix double-free issue when mounting with setuid root Paulo Alcantara (SUSE)
2019-09-09 12:46 ` Aurélien Aptel
2019-10-04 0:22 ` Pavel Shilovsky [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKywueQZSHj6autWPkyjhnfpEttFbr=81Y6a7_tWSQVnr-PmJw@mail.gmail.com' \
--to=piastryyy@gmail.com \
--cc=aaptel@suse.com \
--cc=linux-cifs@vger.kernel.org \
--cc=paulo@paulo.ac \
--cc=samba-technical@lists.samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).