From nobody Sat May 18 15:38:15 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=1605056842; cv=none; d=zohomail.com; s=zohoarc; b=AkdXjhrBYUXeJ10aUXh8OEYWfSvtiM4MiJjLj7bqVg+OhgFRMlNZoqcRJmiRcL7mnxOXQO0trHb+5D+ZHXZsLfwjNsWvYcls8udQw+dW3/AMALkQACMnPTUmtdaDXML2mTTPlcdNRXyBpu+Ah/mYinKJdGMcCn1XA7WLnIX08Qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605056842; 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=9zQfjdbaXwm9QxPLuxa89rV9JfcvYtRv2M0iTZ6m29Y=; b=HzsrtXmSAoksy3MVTiGmuX0OjpKf7bLkuCUYGd4wKpn3facFRVDQzT94Qna43AHwQFt2hqdOrvBtr7sdRVLVTdRzlWn5aHjOH7REY58bs+Nfe0y+MMRae/3potkUJVwGCjUOmiURKNkEwrjUXJe6IMqsz8uvY3skXP1a0KUtOHQ= 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 1605056842299265.2205473693216; Tue, 10 Nov 2020 17:07:22 -0800 (PST) Received: from localhost ([::1]:36854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcebZ-0008F9-Aa for importer@patchew.org; Tue, 10 Nov 2020 20:07:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kceaU-0007hp-3T for qemu-devel@nongnu.org; Tue, 10 Nov 2020 20:06:14 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kceaS-0007Pd-2n for qemu-devel@nongnu.org; Tue, 10 Nov 2020 20:06:13 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CW6472CxXzhkCg; Wed, 11 Nov 2020 09:05:59 +0800 (CST) Received: from [10.174.178.136] (10.174.178.136) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Wed, 11 Nov 2020 09:05:57 +0800 Subject: [PATCH 1/3] tools/virtiofsd/buffer.c: check whether buf is NULL in fuse_bufvec_advance func From: Haotian Li To: , References: <3477d902-ace9-1aa1-531a-9d20d6e93a05@huawei.com> Message-ID: <29fc87c2-b87c-4c34-40d4-75381f228849@huawei.com> Date: Wed, 11 Nov 2020 09:05:56 +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: <3477d902-ace9-1aa1-531a-9d20d6e93a05@huawei.com> 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/10 20:06:08 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 Reviewed-by: Dr. David Alan Gilbert --- tools/virtiofsd/buffer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/virtiofsd/buffer.c b/tools/virtiofsd/buffer.c index 27c1377f22..bdc608c221 100644 --- a/tools/virtiofsd/buffer.c +++ b/tools/virtiofsd/buffer.c @@ -246,6 +246,10 @@ static int fuse_bufvec_advance(struct fuse_bufvec *buf= v, 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 Sat May 18 15:38:15 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=1605057034; cv=none; d=zohomail.com; s=zohoarc; b=j1JAFY0QUGShX/9irUVz9xvqDtreOSqPenCQu2SD+mQJ1J2C9JmlErbeMNL73/gsRd43OhTrt4PSQELml3XzS+4Q/tWufztorWKTqtadu5N8RU+F03sSmNUAFl+MO20R2o5lVB4HI9mFE/jnIU0uUXIEJA1RTvNqbKlt3ESal1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605057034; 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=JSj84J8UD4Qd5XXAnuuRi3Ta8fQqf7BQBkk8pUcinlc=; b=Cr09qvCkrLCFT9gqGG2z0Y2Udzj//mJ9HZVAuaGmWhmW/znR0m37zvEwS3fx/M1bVmVsJE5dfBaaGrwatHnXZx9OtnOWPbvOkgfJVsAo585xiy+ZJEo7g/qZMM/OEOXik2q0AJmfSuC+u8VR8/TUuTICuQg2UtbX/y1mF5mCZ3I= 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 1605057034143655.0267833414633; Tue, 10 Nov 2020 17:10:34 -0800 (PST) Received: from localhost ([::1]:39720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kceee-0001Jj-LP for importer@patchew.org; Tue, 10 Nov 2020 20:10:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcedc-0000hR-Fz for qemu-devel@nongnu.org; Tue, 10 Nov 2020 20:09:28 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2449) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kceda-0007tb-LJ for qemu-devel@nongnu.org; Tue, 10 Nov 2020 20:09:28 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CW67q5HLszLwrn; Wed, 11 Nov 2020 09:09:11 +0800 (CST) Received: from [10.174.178.136] (10.174.178.136) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Wed, 11 Nov 2020 09:09:13 +0800 Subject: [PATCH 2/3] virtiofsd: check whether lo_map_reserve returns NULL in, main func From: Haotian Li To: , References: <3477d902-ace9-1aa1-531a-9d20d6e93a05@huawei.com> Message-ID: <48887813-1c95-048c-6d10-48e3dd2bac71@huawei.com> Date: Wed, 11 Nov 2020 09:09:12 +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: <3477d902-ace9-1aa1-531a-9d20d6e93a05@huawei.com> 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/10 20:06:08 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 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 Reviewed-by: Dr. David Alan Gilbert --- tools/virtiofsd/passthrough_ll.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index ec1008bceb..3e9bbc7a04 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,17 @@ 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) { + fuse_log(FUSE_LOG_ERR, "failed to alloc reserve_elem.\n"); + 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) { + fuse_log(FUSE_LOG_ERR, "failed to alloc root_elem.\n"); + goto err_out1; + } root_elem->inode =3D &lo.root; lo_map_init(&lo.dirp_map); --=20 From nobody Sat May 18 15:38:15 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=1605057123; cv=none; d=zohomail.com; s=zohoarc; b=Lh/1E+5968I0Q64hoBIrFoLAPt44IZm33QuhWq/RXyOm4BllgHE9yMDm/E5iG39f+ugEiXxS7vl1ck/6Y9h1AIqBTaJCbFHuh58x3HWNS56V08KxiEIqMSi4p9rRd3yd9aqIxysEbQ2PqA9xJlBwd17dpuHIMmgq+nmw8n+buu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605057123; 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=5enML2bGK7HvN+gFzeCfT+CVkbsjbd3IXGL7XDfsrb4=; b=JdHfKzPI7GTg99YpE4IbJldWi/PSrXeWK1/mSDD3QukyUiGDAQ7bdWBLlKGxnBpjh4LnLS0+FIfIcjTu0m+nQ51y2QJUE8Rmks9TXHqeme2hsX0e4ze6jmF135YG5O7OU75630pJ2iXh+jSwnGbE+Ao/luL+j8533Rrqhl6+2+4= 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 160505712378627.60193856927242; Tue, 10 Nov 2020 17:12:03 -0800 (PST) Received: from localhost ([::1]:42730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kceg6-0002he-OX for importer@patchew.org; Tue, 10 Nov 2020 20:12:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcef6-0001rK-0s for qemu-devel@nongnu.org; Tue, 10 Nov 2020 20:11:00 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2138) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcef4-0008DP-5Y for qemu-devel@nongnu.org; Tue, 10 Nov 2020 20:10:59 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CW69V4ZHqz74nC; Wed, 11 Nov 2020 09:10:38 +0800 (CST) Received: from [10.174.178.136] (10.174.178.136) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Wed, 11 Nov 2020 09:10:39 +0800 Subject: [PATCH 3/3] virtiofsd: check whether strdup lo.source return NULL in main func From: Haotian Li To: , References: <3477d902-ace9-1aa1-531a-9d20d6e93a05@huawei.com> Message-ID: Date: Wed, 11 Nov 2020 09:10:38 +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: <3477d902-ace9-1aa1-531a-9d20d6e93a05@huawei.com> 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.35; envelope-from=lihaotian9@huawei.com; helo=szxga07-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 20:10:47 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, strdup lo.source may fail. So check whether strdup lo.source return NULL before using it. Signed-off-by: Haotian Li Signed-off-by: Zhiqiang Liu Reviewed-by: Dr. David Alan Gilbert --- tools/virtiofsd/passthrough_ll.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index 3e9bbc7a04..0c11134fb5 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -3525,6 +3525,10 @@ int main(int argc, char *argv[]) } } else { lo.source =3D strdup("/"); + if (!lo.source) { + fuse_log(FUSE_LOG_ERR, "failed to strdup source\n"); + goto err_out1; + } } if (lo.xattrmap) { --=20