From: Greg Kurz <groug@kaod.org>
To: P J P <ppandit@redhat.com>
Cc: Qemu Developers <qemu-devel@nongnu.org>,
Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>,
Prasad J Pandit <pjp@fedoraproject.org>
Subject: Re: [Qemu-devel] [PATCH] 9pfs: use g_malloc0 to allocate space for xattr
Date: Wed, 4 Oct 2017 14:26:34 +0200 [thread overview]
Message-ID: <20171004142634.3fb6f4ed@bahia.lan> (raw)
In-Reply-To: <20171004113652.29620-1-ppandit@redhat.com>
On Wed, 4 Oct 2017 17:06:52 +0530
P J P <ppandit@redhat.com> wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> 9p back-end first queries the size of an extended attribute,
> allocates space for it via g_malloc() and then retrieves its
> value into allocated buffer. Race between querying attribute
> size and retrieving its could lead to memory bytes disclosure.
> Use g_malloc0() to avoid it.
>
Applied to 9p-next.
Thanks.
> Reported-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
> hw/9pfs/9p.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index 23ac7bb532..f8bbac251d 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -3234,7 +3234,7 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque)
> xattr_fidp->fid_type = P9_FID_XATTR;
> xattr_fidp->fs.xattr.xattrwalk_fid = true;
> if (size) {
> - xattr_fidp->fs.xattr.value = g_malloc(size);
> + xattr_fidp->fs.xattr.value = g_malloc0(size);
> err = v9fs_co_llistxattr(pdu, &xattr_fidp->path,
> xattr_fidp->fs.xattr.value,
> xattr_fidp->fs.xattr.len);
> @@ -3267,7 +3267,7 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque)
> xattr_fidp->fid_type = P9_FID_XATTR;
> xattr_fidp->fs.xattr.xattrwalk_fid = true;
> if (size) {
> - xattr_fidp->fs.xattr.value = g_malloc(size);
> + xattr_fidp->fs.xattr.value = g_malloc0(size);
> err = v9fs_co_lgetxattr(pdu, &xattr_fidp->path,
> &name, xattr_fidp->fs.xattr.value,
> xattr_fidp->fs.xattr.len);
prev parent reply other threads:[~2017-10-04 12:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 11:36 [Qemu-devel] [PATCH] 9pfs: use g_malloc0 to allocate space for xattr P J P
2017-10-04 12:26 ` Greg Kurz [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=20171004142634.3fb6f4ed@bahia.lan \
--to=groug@kaod.org \
--cc=pjp@fedoraproject.org \
--cc=ppandit@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=tuomas.tynkkynen@iki.fi \
/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).