From nobody Fri May 3 07:17:15 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508167013268743.8662125357657; Mon, 16 Oct 2017 08:16:53 -0700 (PDT) Received: from localhost ([::1]:33503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e478H-0001kc-JA for importer@patchew.org; Mon, 16 Oct 2017 11:16:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e475i-0000Qx-Gc for qemu-devel@nongnu.org; Mon, 16 Oct 2017 11:14:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e475c-0001Ki-AW for qemu-devel@nongnu.org; Mon, 16 Oct 2017 11:14:06 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58070 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e475c-0001K7-4K for qemu-devel@nongnu.org; Mon, 16 Oct 2017 11:14:00 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9GFAJsr117232 for ; Mon, 16 Oct 2017 11:13:58 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 2dmvgdhahn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 16 Oct 2017 11:13:57 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Oct 2017 16:13:56 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 16 Oct 2017 16:13:54 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9GFDrok24641728; Mon, 16 Oct 2017 15:13:53 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 24918AE051; Mon, 16 Oct 2017 16:08:04 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 126EFAE04D; Mon, 16 Oct 2017 16:08:04 +0100 (BST) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 16 Oct 2017 16:08:04 +0100 (BST) Received: from bahia.lan (icon-9-164-131-216.megacenter.de.ibm.com [9.164.131.216]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id F0B75220089; Mon, 16 Oct 2017 17:13:52 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 17:13:37 +0200 X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016151337.4121-1-groug@kaod.org> References: <20171016151337.4121-1-groug@kaod.org> X-TM-AS-GCONF: 00 x-cbid: 17101615-0040-0000-0000-000003E34F50 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101615-0041-0000-0000-000025E583D3 Message-Id: <20171016151337.4121-2-groug@kaod.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-16_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710160214 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 1/1] 9pfs: use g_malloc0 to allocate space for xattr X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Greg Kurz , Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit 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. Reported-by: Tuomas Tynkkynen Signed-off-by: Prasad J Pandit Signed-off-by: Greg Kurz --- 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 23ac7bb532f0..f8bbac251dc9 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 =3D P9_FID_XATTR; xattr_fidp->fs.xattr.xattrwalk_fid =3D true; if (size) { - xattr_fidp->fs.xattr.value =3D g_malloc(size); + xattr_fidp->fs.xattr.value =3D g_malloc0(size); err =3D 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 =3D P9_FID_XATTR; xattr_fidp->fs.xattr.xattrwalk_fid =3D true; if (size) { - xattr_fidp->fs.xattr.value =3D g_malloc(size); + xattr_fidp->fs.xattr.value =3D g_malloc0(size); err =3D v9fs_co_lgetxattr(pdu, &xattr_fidp->path, &name, xattr_fidp->fs.xattr.value, xattr_fidp->fs.xattr.len); --=20 2.13.6