From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8BC2C2D0A3 for ; Thu, 5 Nov 2020 01:33:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 648EB208C7 for ; Thu, 5 Nov 2020 01:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732857AbgKEBdq (ORCPT ); Wed, 4 Nov 2020 20:33:46 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:7591 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731131AbgKEBdq (ORCPT ); Wed, 4 Nov 2020 20:33:46 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CRQyp4Cb7zLpG5; Thu, 5 Nov 2020 09:33:38 +0800 (CST) Received: from [127.0.0.1] (10.174.176.238) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Thu, 5 Nov 2020 09:33:34 +0800 Subject: Re: [PATCH] fuse: check whether fuse_request_alloc returns NULL in fuse_simple_request From: Zhiqiang Liu To: , , Miklos Szeredi CC: , , linfeilong , lihaotian References: Message-ID: Date: Thu, 5 Nov 2020 09:33:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.238] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ping ... On 2020/10/22 21:13, Zhiqiang Liu wrote: > > In fuse_simple_request func, we will call fuse_request_alloc func to alloc > one request from fuse_req_cachep when args->force is true. However, the > return value of fuse_request_alloc func is not checked whether it is NULL. > If allocating request fails, access-NULL-pointer problem will occur. > > Here, we check the return value of fuse_request_alloc func. > > Fixes: 7213394c4e18 ("fuse: simplify request allocation") > Signed-off-by: Zhiqiang Liu > Signed-off-by: Haotian Li > --- > fs/fuse/dev.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c > index 02b3c36b3676..f7dd33ae8e31 100644 > --- a/fs/fuse/dev.c > +++ b/fs/fuse/dev.c > @@ -481,6 +481,8 @@ ssize_t fuse_simple_request(struct fuse_conn *fc, struct fuse_args *args) > if (args->force) { > atomic_inc(&fc->num_waiting); > req = fuse_request_alloc(GFP_KERNEL | __GFP_NOFAIL); > + if (!req) > + return -ENOMEM; > > if (!args->nocreds) > fuse_force_creds(fc, req); >