Blame 0105-9pfs-use-g_malloc0-to-allocate-space-for-xattr.patch

59eb7a
From: Prasad J Pandit <pjp@fedoraproject.org>
59eb7a
Date: Mon, 16 Oct 2017 14:21:59 +0200
59eb7a
Subject: [PATCH] 9pfs: use g_malloc0 to allocate space for xattr
59eb7a
59eb7a
9p back-end first queries the size of an extended attribute,
59eb7a
allocates space for it via g_malloc() and then retrieves its
59eb7a
value into allocated buffer. Race between querying attribute
59eb7a
size and retrieving its could lead to memory bytes disclosure.
59eb7a
Use g_malloc0() to avoid it.
59eb7a
59eb7a
Reported-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
59eb7a
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
59eb7a
Signed-off-by: Greg Kurz <groug@kaod.org>
59eb7a
(cherry picked from commit 7bd92756303f2158a68d5166264dc30139b813b6)
59eb7a
---
59eb7a
 hw/9pfs/9p.c | 4 ++--
59eb7a
 1 file changed, 2 insertions(+), 2 deletions(-)
59eb7a
59eb7a
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
59eb7a
index 8e9490c5f5..c41c0eb106 100644
59eb7a
--- a/hw/9pfs/9p.c
59eb7a
+++ b/hw/9pfs/9p.c
59eb7a
@@ -3236,7 +3236,7 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque)
59eb7a
         xattr_fidp->fid_type = P9_FID_XATTR;
59eb7a
         xattr_fidp->fs.xattr.xattrwalk_fid = true;
59eb7a
         if (size) {
59eb7a
-            xattr_fidp->fs.xattr.value = g_malloc(size);
59eb7a
+            xattr_fidp->fs.xattr.value = g_malloc0(size);
59eb7a
             err = v9fs_co_llistxattr(pdu, &xattr_fidp->path,
59eb7a
                                      xattr_fidp->fs.xattr.value,
59eb7a
                                      xattr_fidp->fs.xattr.len);
59eb7a
@@ -3269,7 +3269,7 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque)
59eb7a
         xattr_fidp->fid_type = P9_FID_XATTR;
59eb7a
         xattr_fidp->fs.xattr.xattrwalk_fid = true;
59eb7a
         if (size) {
59eb7a
-            xattr_fidp->fs.xattr.value = g_malloc(size);
59eb7a
+            xattr_fidp->fs.xattr.value = g_malloc0(size);
59eb7a
             err = v9fs_co_lgetxattr(pdu, &xattr_fidp->path,
59eb7a
                                     &name, xattr_fidp->fs.xattr.value,
59eb7a
                                     xattr_fidp->fs.xattr.len);