From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: "Vitaly Chikunov" <vt@altlinux.org>, "Greg Kurz" <groug@kaod.org>,
qemu-stable@nongnu.org, "Dmitry V . Levin" <ldv@altlinux.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [PATCH v4] 9pfs: Fix segfault in do_readdir_many caused by struct dirent overread
Date: Wed, 09 Feb 2022 13:34:08 +0100 [thread overview]
Message-ID: <2508467.LGuOOJKFuP@silver> (raw)
In-Reply-To: <20220206013419.849161-1-vt@altlinux.org>
On Sonntag, 6. Februar 2022 02:34:19 CET Vitaly Chikunov wrote:
> `struct dirent' returned from readdir(3) could be shorter (or longer)
> than `sizeof(struct dirent)', thus memcpy of sizeof length will overread
> into unallocated page causing SIGSEGV. Example stack trace:
>
> #0 0x00005555559ebeed v9fs_co_readdir_many (/usr/bin/qemu-system-x86_64 +
> 0x497eed) #1 0x00005555559ec2e9 v9fs_readdir (/usr/bin/qemu-system-x86_64
> + 0x4982e9) #2 0x0000555555eb7983 coroutine_trampoline
> (/usr/bin/qemu-system-x86_64 + 0x963983) #3 0x00007ffff73e0be0 n/a (n/a +
> 0x0)
>
> While fixing, provide a helper for any future `struct dirent' cloning.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/841
> Cc: qemu-stable@nongnu.org
> Co-authored-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
> Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
> Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
> ---
> Tested on x68-64 Linux with btrfs-progs tests and slow qos-test.
> Changes since v3:
> - Update commentary on qemu_dirent_dup logic.
> - Use g_memdup as suggested by Greg Kurz.
>
> hw/9pfs/codir.c | 3 +--
> include/qemu/osdep.h | 13 +++++++++++++
> util/osdep.c | 21 +++++++++++++++++++++
> 3 files changed, 35 insertions(+), 2 deletions(-)
Queued on 9p.next:
https://github.com/cschoenebeck/qemu/commits/9p.next
Thanks!
I plan to send a PR with my current queue to Peter tomorrow.
Best regards,
Christian Schoenebeck
prev parent reply other threads:[~2022-02-09 12:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-06 1:34 [PATCH v4] 9pfs: Fix segfault in do_readdir_many caused by struct dirent overread Vitaly Chikunov
2022-02-07 7:56 ` Greg Kurz
2022-02-07 16:29 ` Christian Schoenebeck
2022-02-09 12:34 ` Christian Schoenebeck [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=2508467.LGuOOJKFuP@silver \
--to=qemu_oss@crudebyte.com \
--cc=f4bug@amsat.org \
--cc=groug@kaod.org \
--cc=ldv@altlinux.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=vt@altlinux.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).