Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11971760ybi; Fri, 26 Jul 2019 02:40:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKVZBOiNRe/SZZ9cb8oQPsDvbmc+8njX4ljCLglBMAIOFyM3rv0rPvVjGN9d9mIfV5ZUXi X-Received: by 2002:aa7:9a92:: with SMTP id w18mr21322648pfi.167.1564134040099; Fri, 26 Jul 2019 02:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564134040; cv=none; d=google.com; s=arc-20160816; b=CncIl5bYVyowdOlaY9ES+djzU+he4dSi6HF6AwThkfob1ordbCC0Nsen2KYSqlqIHI wu2/dMinA75/MXIpRiGtVcNyd6jHIkFW5IqygY5Q5JoRJxbpKkGX4jZWy9QGag8cLMtF 5AOmY8ND+RSgJ36N8gRoofKnvCCEmSc3QhfP9PWhlZr493e68u76l+Q+hxePvA2h4UvB 7V5/6jeiI4KQDm/dXBlFiFLjLzyfujhPOfdAyZgX5n7aN9OO+7H3i2zd8ShCkd2sw67I 0ix4JsXNhN7DqhC1R/WRZmlst0J4sIbW1/3rRhlM/Odjr4eBde2vUVRk90qSuCtJgbxn /sTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=AedrIBupUuvfQZb48A0Mk4yEPzcf8qgVQ87DoSD9TCk=; b=akk73oAz4PQ46K4cPdD1fOb3UD7VHTZ8ph5GZlaIKVHsCVIn9CKWZpgrpnPuydhsXR o5QVZDM972+2XdB8aPiVSBdikwhMbxEnmOhO/nUKnuHs6QXjSXZXKw6JD4Mucj6U/WjN GY2JJ6w9xmVc28lW6a4aADQLBsF/c8LAmXRnBXOE59oGeVq0hHGJaSyfrM9fxcuwW4/0 zWMd+4N13n7Q+26IA2Ekj2qJ2xnfy2f2plGZajtSboThFNKSrNNfT17oDC3tbBBlOtwk T87P7hti9wecAhziYEYoCMV2Tp6jMkiZTU1vP3+y/rtGOfoD4HfEqAHugChCJ6ywp4tT ddxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17si22021664plq.138.2019.07.26.02.40.25; Fri, 26 Jul 2019 02:40:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726139AbfGZJjl (ORCPT + 99 others); Fri, 26 Jul 2019 05:39:41 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:42905 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725903AbfGZJjl (ORCPT ); Fri, 26 Jul 2019 05:39:41 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R841e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07486;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0TXq-pnk_1564133977; Received: from JosephdeMacBook-Pro.local(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0TXq-pnk_1564133977) by smtp.aliyun-inc.com(127.0.0.1); Fri, 26 Jul 2019 17:39:38 +0800 Subject: Re: [PATCH 3/3] fs: ocfs2: Fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc() To: Jia-Ju Bai , mark@fasheh.com, jlbec@evilplan.org Cc: ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org References: <20190726033717.32359-1-baijiaju1990@gmail.com> From: Joseph Qi Message-ID: <3db34626-a87f-9de8-6f9c-e4a35f863cd6@linux.alibaba.com> Date: Fri, 26 Jul 2019 17:39:37 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190726033717.32359-1-baijiaju1990@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/7/26 11:37, Jia-Ju Bai wrote: > In ocfs2_info_scan_inode_alloc(), there is an if statement on line 283 > to check whether inode_alloc is NULL: > if (inode_alloc) > > When inode_alloc is NULL, it is used on line 287: > ocfs2_inode_lock(inode_alloc, &bh, 0); > ocfs2_inode_lock_full_nested(inode, ...) > struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); > > Thus, a possible null-pointer dereference may occur. > > To fix this bug, inode_alloc is checked on line 286. > > This bug is found by a static analysis tool STCheck written by us. > > Signed-off-by: Jia-Ju Bai Looks good. Reviewed-by: Joseph Qi > --- > fs/ocfs2/ioctl.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c > index d6f7b299eb23..efeea208fdeb 100644 > --- a/fs/ocfs2/ioctl.c > +++ b/fs/ocfs2/ioctl.c > @@ -283,7 +283,7 @@ static int ocfs2_info_scan_inode_alloc(struct ocfs2_super *osb, > if (inode_alloc) > inode_lock(inode_alloc); > > - if (o2info_coherent(&fi->ifi_req)) { > + if (inode_alloc && o2info_coherent(&fi->ifi_req)) { > status = ocfs2_inode_lock(inode_alloc, &bh, 0); > if (status < 0) { > mlog_errno(status); >