From nobody Fri May 17 11:28:45 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=1607629372; cv=none; d=zohomail.com; s=zohoarc; b=azLmCCsWfNiv+SicykxU9VwCGcsiVFvtFbczXjC0uAumnl2fvD2GrFGDVCEo1v2cybGLgM6rA5VVoBsv/l5rPo1z8PHGc6TVgPZR7y9RmfbGMToPiY5z2FembrGN93jEDTwU9Th3ZBSbc2uQBSrEtn4FCCmqLPnOHQefxemzCCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607629372; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=dL08mbrWUnIaSGHA/v8kNkE46bMV2Cj3ehsdUQyr5HA=; b=SvMRVcLvVy9L7/SwZdIqA1in1CIIv4RJuuOv7/ETEYZh7VUd+Hdfi1AyAiYpxTIQx+DdvZ2oTWL9oiR3QTrfCU3/iqgpLKxjbm/BtzvugEh8Ffgrmvryc61GDVSrcYxNtoXarRPWaSzb/VOhIWwKuvnenc8ju3dLZc3lBlLzb3s= 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 16076293726346.492156619784396; Thu, 10 Dec 2020 11:42:52 -0800 (PST) Received: from localhost ([::1]:43378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knNtZ-0005KW-BI for importer@patchew.org; Thu, 10 Dec 2020 10:30:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knNrk-0004aT-K5; Thu, 10 Dec 2020 10:28:24 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2168) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knNrh-0002qu-Uc; Thu, 10 Dec 2020 10:28:24 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CsHpb6GqJz7Bxg; Thu, 10 Dec 2020 23:27:19 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Thu, 10 Dec 2020 23:27:43 +0800 From: Alex Chen To: , Subject: [PATCH] virtiofsd: Fix potential NULL pointer dereference in virtio_send_msg() Date: Thu, 10 Dec 2020 15:14:26 +0000 Message-ID: <20201210151426.89244-1-alex.chen@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.124.27] 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=alex.chen@huawei.com; helo=szxga07-in.huawei.com 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: alex.chen@huawei.com, qemu-trivial@nongnu.org, qemu-devel@nongnu.org, zhang.zhanghailiang@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The 'ch' will be NULL in the following stack: send_notify_iov()->fuse_send_msg()->virtio_send_msg(), so we should check 'ch' is valid before dereferencing it Reported-by: Euler Robot Signed-off-by: Alex Chen --- tools/virtiofsd/fuse_virtio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 623812c432..31b2187a15 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -205,6 +205,8 @@ static void copy_iov(struct iovec *src_iov, int src_cou= nt, int virtio_send_msg(struct fuse_session *se, struct fuse_chan *ch, struct iovec *iov, int count) { + assert(ch); + FVRequest *req =3D container_of(ch, FVRequest, ch); struct fv_QueueInfo *qi =3D ch->qi; VuDev *dev =3D &se->virtio_dev->dev; --=20 2.19.1