From nobody Sun May 5 15:54:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604970776; cv=none; d=zohomail.com; s=zohoarc; b=jpIUWuumPfxqdEBfMEgs+cTMEY2A3jh2Oaeg8y5ro2iV5+4lYTxMDDac3K+7P746FBtd7d9ODmxTfNDHxNuEhTJeqO1ESvHxn7Yofszf2d3mwsu+mrY+eYiWKsuYQCrdUhHqxRvtbf1B+zgA6uRg2YevsA7ocSCwZ09pVJ2TpFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604970776; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HMlDR7O+j7CL5XWGvkvcr3bAddnMjcmXF7stmL8qQb8=; b=Dx2/iV+9llXK7DZ8km+WGlmuIeBy+9N0X7bfRY0BllYi+aA3pdjyUv783R10qgi8RhYwgfFKfqIJmNPZ+2WLbE9pcPjp/IGMJT7qB5UxjpTlVOjI/0AW6zMVpHra78rKVTg7GxBCFV5wZslH42lSR4U/Z86YiytpmmgOEPG1N/g= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604970776750874.626992840197; Mon, 9 Nov 2020 17:12:56 -0800 (PST) Received: from localhost ([::1]:42708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcIDO-0008A8-IL for importer@patchew.org; Mon, 09 Nov 2020 20:12:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcIBA-0007QM-H8 for qemu-devel@nongnu.org; Mon, 09 Nov 2020 20:10:36 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2512) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcIB8-0006yt-8k for qemu-devel@nongnu.org; Mon, 09 Nov 2020 20:10:36 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CVVCf3VSVzhjtg; Tue, 10 Nov 2020 09:10:22 +0800 (CST) Received: from [10.174.178.136] (10.174.178.136) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Tue, 10 Nov 2020 09:10:23 +0800 Subject: [PATCH 1/2] tools/virtiofsd/buffer.c: check whether buf is NULL in fuse_bufvec_advance func From: Haotian Li To: , References: Message-ID: <743d931f-8d19-3368-9170-084f0f11b28e@huawei.com> Date: Tue, 10 Nov 2020 09:10:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.1.0 MIME-Version: 1.0 In-Reply-To: Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.178.136] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.191; envelope-from=lihaotian9@huawei.com; helo=szxga05-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/09 20:10:31 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linfeilong@huawei.com, liuzhiqiang26@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In fuse_bufvec_advance func, calling fuse_bufvec_current func may return NULL, so we should check whether buf is NULL before using it. Signed-off-by: Haotian Li Signed-off-by: Zhiqiang Liu --- tools/virtiofsd/buffer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/virtiofsd/buffer.c b/tools/virtiofsd/buffer.c index 27c1377f22..c94993b936 100644 --- a/tools/virtiofsd/buffer.c +++ b/tools/virtiofsd/buffer.c @@ -246,6 +246,9 @@ static int fuse_bufvec_advance(struct fuse_bufvec *bufv= , size_t len) { const struct fuse_buf *buf =3D fuse_bufvec_current(bufv); + if (!buf) + return 0; + bufv->off +=3D len; assert(bufv->off <=3D buf->size); if (bufv->off =3D=3D buf->size) { --=20 From nobody Sun May 5 15:54:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604970831; cv=none; d=zohomail.com; s=zohoarc; b=ZbmWanF1TRmBnLXrzgXvP7LyOgmBCRl3LFE65hSxHB8wlK7cnkVeDQe/5Sx5XaVs3Xhy2p4NaGgVjJhdto/BhbSH1ldGOu9PQsV66H+2AayPmyNj3cS5h1++FD50S3xRF8dmjOvBEqvI8nDSNUpHcaRmrO09lCzyLSugCnNw5IM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604970831; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3pL3rOeluxE7nv4kUBFoKWpmTM0xvxQzh4SDal0RZSw=; b=FAbjQysSxAyqzdN4odq8djJ+2AF7495PzJvCUaFEgtzHxhKwu+A1dK0yOjVAORPvU2SdpV0C+Z1r1uUF5yTK4ddr8Crxe+mED3J+1w5tJsBseJu4dZFWyouHzYqmjp4PeHJ+WYgKM6vJ6aFlaiyqc35Fz6iuS1YURti38JjnVE8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604970831234209.84724807873658; Mon, 9 Nov 2020 17:13:51 -0800 (PST) Received: from localhost ([::1]:44096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcIEI-0000KP-8G for importer@patchew.org; Mon, 09 Nov 2020 20:13:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcICP-0007t4-GS for qemu-devel@nongnu.org; Mon, 09 Nov 2020 20:11:53 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:2086) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcICN-0007Bs-HX for qemu-devel@nongnu.org; Mon, 09 Nov 2020 20:11:53 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4CVVF519dgzhhW9; Tue, 10 Nov 2020 09:11:37 +0800 (CST) Received: from [10.174.178.136] (10.174.178.136) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Tue, 10 Nov 2020 09:11:32 +0800 Subject: [PATCH 2/2] virtiofsd: check whether lo_map_reserve returns NULL in main func From: Haotian Li To: , References: Message-ID: <98f164b6-2c73-6d79-30c5-9cc12393822c@huawei.com> Date: Tue, 10 Nov 2020 09:11:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.1.0 MIME-Version: 1.0 In-Reply-To: Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.178.136] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.32; envelope-from=lihaotian9@huawei.com; helo=szxga06-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/09 20:11:42 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linfeilong@huawei.com, liuzhiqiang26@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In main func, func lo_map_reserve is called without NULL check. If reallocing new_elems fails in func lo_map_grow, the func lo_map_reserve may return NULL. We should check whether lo_map_reserve returns NULL before using it. Signed-off-by: Haotian Li Signed-off-by: Zhiqiang Liu --- tools/virtiofsd/passthrough_ll.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index ec1008bceb..147c5381e9 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -3433,6 +3433,7 @@ int main(int argc, char *argv[]) .proc_self_fd =3D -1, }; struct lo_map_elem *root_elem; + struct lo_map_elem *reserve_elem; int ret =3D -1; /* Don't mask creation mode, kernel already did that */ @@ -3452,8 +3453,13 @@ int main(int argc, char *argv[]) * [1] Root inode */ lo_map_init(&lo.ino_map); - lo_map_reserve(&lo.ino_map, 0)->in_use =3D false; + reserve_elem =3D lo_map_reserve(&lo.ino_map, 0); + if (!reserve_elem) + goto err_out1; + reserve_elem->in_use =3D false; root_elem =3D lo_map_reserve(&lo.ino_map, lo.root.fuse_ino); + if (!root_elem) + goto err_out1; root_elem->inode =3D &lo.root; lo_map_init(&lo.dirp_map); --=20