From nobody Fri Oct 24 09:58:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519123925305783.5749825823614; Tue, 20 Feb 2018 02:52:05 -0800 (PST) Received: from localhost ([::1]:54566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eo5Wi-00024k-Hz for importer@patchew.org; Tue, 20 Feb 2018 05:52:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eo5Ur-000150-A8 for qemu-devel@nongnu.org; Tue, 20 Feb 2018 05:50:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eo5Um-0000ws-BZ for qemu-devel@nongnu.org; Tue, 20 Feb 2018 05:50:05 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46306) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eo5Um-0000qC-2k for qemu-devel@nongnu.org; Tue, 20 Feb 2018 05:50:00 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1KAmu4Y112268 for ; Tue, 20 Feb 2018 05:49:52 -0500 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g8hmshkk9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 20 Feb 2018 05:49:51 -0500 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Feb 2018 10:49:49 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 20 Feb 2018 10:49:46 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1KAnkt529229134; Tue, 20 Feb 2018 10:49:46 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 793FFAE051; Tue, 20 Feb 2018 10:40:41 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64C4CAE045; Tue, 20 Feb 2018 10:40:41 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Feb 2018 10:40:41 +0000 (GMT) Received: from bahia.lan (icon-9-164-168-60.megacenter.de.ibm.com [9.164.168.60]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 3F969220411; Tue, 20 Feb 2018 11:49:45 +0100 (CET) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 20 Feb 2018 11:49:41 +0100 X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180220104942.14531-1-groug@kaod.org> References: <20180220104942.14531-1-groug@kaod.org> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18022010-0016-0000-0000-000005278E08 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022010-0017-0000-0000-000028639D3E Message-Id: <20180220104942.14531-2-groug@kaod.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-20_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=13 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802200139 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id w1KAmu4Y112268 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 1/2] 9p: v9fs_path_copy() readability 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 , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau lhs/rhs doesn't tell much about how argument are handled, dst/src is and const arguments is clearer in my mind. Use g_memdup() while at it. Signed-off-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Greg Kurz --- hw/9pfs/9p.c | 9 ++++----- hw/9pfs/9p.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 85a1ed8171a4..48fa48e72074 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -190,12 +190,11 @@ v9fs_path_sprintf(V9fsPath *path, const char *fmt, ..= .) va_end(ap); } =20 -void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs) +void v9fs_path_copy(V9fsPath *dst, const V9fsPath *src) { - v9fs_path_free(lhs); - lhs->data =3D g_malloc(rhs->size); - memcpy(lhs->data, rhs->data, rhs->size); - lhs->size =3D rhs->size; + v9fs_path_free(dst); + dst->size =3D src->size; + dst->data =3D g_memdup(src->data, src->size); } =20 int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath, diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 5ced427d861b..bad8ee719c4b 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -343,7 +343,7 @@ void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu); void v9fs_path_init(V9fsPath *path); void v9fs_path_free(V9fsPath *path); void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...); -void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs); +void v9fs_path_copy(V9fsPath *dst, const V9fsPath *src); int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath, const char *name, V9fsPath *path); int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t, --=20 2.13.6 From nobody Fri Oct 24 09:58:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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 1519123925136985.4052461413636; Tue, 20 Feb 2018 02:52:05 -0800 (PST) Received: from localhost ([::1]:54564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eo5Wd-00020Y-Vc for importer@patchew.org; Tue, 20 Feb 2018 05:51:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eo5Uo-00013m-Cg for qemu-devel@nongnu.org; Tue, 20 Feb 2018 05:50:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eo5Ul-0000un-A1 for qemu-devel@nongnu.org; Tue, 20 Feb 2018 05:50:02 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35642) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eo5Ul-0000pq-01 for qemu-devel@nongnu.org; Tue, 20 Feb 2018 05:49:59 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1KAmuGW049571 for ; Tue, 20 Feb 2018 05:49:51 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g8j3kgd7n-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 20 Feb 2018 05:49:51 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Feb 2018 10:49:48 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 20 Feb 2018 10:49:47 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1KAnkWq43253942; Tue, 20 Feb 2018 10:49:46 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E50F52041; Tue, 20 Feb 2018 09:41:41 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 5BCCB5203F; Tue, 20 Feb 2018 09:41:41 +0000 (GMT) Received: from bahia.lan (icon-9-164-168-60.megacenter.de.ibm.com [9.164.168.60]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id CFC2C2203C6; Tue, 20 Feb 2018 11:49:45 +0100 (CET) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 20 Feb 2018 11:49:42 +0100 X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180220104942.14531-1-groug@kaod.org> References: <20180220104942.14531-1-groug@kaod.org> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18022010-0020-0000-0000-000003F990E6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022010-0021-0000-0000-0000428D9D4B Message-Id: <20180220104942.14531-3-groug@kaod.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-20_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=13 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802200139 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id w1KAmuGW049571 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 2/2] 9p: fix leak in synth_name_to_path() 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 , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Leak found thanks to ASAN: Direct leak of 8 byte(s) in 1 object(s) allocated from: #0 0x55995789ac90 in __interceptor_malloc (/home/elmarco/src/qemu/build= /x86_64-softmmu/qemu-system-x86_64+0x1510c90) #1 0x7f0a91190f0c in g_malloc /home/elmarco/src/gnome/glib/builddir/../= glib/gmem.c:94 #2 0x5599580a281c in v9fs_path_copy /home/elmarco/src/qemu/hw/9pfs/9p.c= :196:17 #3 0x559958f9ec5d in coroutine_trampoline /home/elmarco/src/qemu/util/c= oroutine-ucontext.c:116:9 #4 0x7f0a8766ebbf (/lib64/libc.so.6+0x50bbf) Signed-off-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Greg Kurz --- hw/9pfs/9p-synth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 18082dffe865..54239c9bbf32 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -495,6 +495,7 @@ static int synth_name_to_path(FsContext *ctx, V9fsPath = *dir_path, } out: /* Copy the node pointer to fid */ + g_free(target->data); target->data =3D g_memdup(&node, sizeof(void *)); target->size =3D sizeof(void *); return 0; --=20 2.13.6