Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11970250ybi; Fri, 26 Jul 2019 02:39:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRki5NmpSb/ZmV+HZBRyQk9sbmouAJS8SPZYVOkjJ3vd0QcUk8AAkAYok3T7t8ZXHsr6OZ X-Received: by 2002:a62:303:: with SMTP id 3mr21200719pfd.118.1564133948746; Fri, 26 Jul 2019 02:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564133948; cv=none; d=google.com; s=arc-20160816; b=e7ry4f9J+foAKfWnqGXJCfGRPJ2YE7WiJY/KFReLb/3ggRuUt3bio0Q6Tle1lGJq1C zolnTQTmUSGPjRodHZrKMhHphSU2sAHKm9hXWc8TrobE9T6pU6Z3cWPX9Cw4gMpyOWK4 d2nLY+sH9J7fHPkdc6qIKNRZHpGih1WE+cCMTMwGHqRVT6gg+WswMuDOxFBjLQCc+hKU OJ1xapN14WTBERFgS47aznzQpXtYwDiH488Z06nBVNqX3fIrVPJQ7p+1xcZKZPW7wA2I 9M+WBvttx3p3F0WqrrjUFSfdiGlyDZ8ciuZO8BZbxj2CeUfVyJ09Pk1LZ3p6Y11JTrfL Gdog== 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=a3cCOMJT9yC2tBU3FxjThJbxsb1z/jikEJ0/eec3514=; b=zV1YOVuwOWBObJU6mvxNaiKuzWmkPpRsg6IaMYJnp9rOuY5ys7eZM3GgV3/AU23xPp 8DoT3VQiueCS2qV2wanPxPdDjJ8uMFefJHKjbBfRJtsXeD9gLwiWNJq63OQA3B4UUSO9 jg0igVjpSh/KYBbGlEkJgZxm8F92U1tIxUXXUy0krm3FOmfq1iW/zqwSEQcQbuLdzoFh 9q+xERT1ICU8pQg43hGHbq78Ijjj9Em418khIYvZm2EvYwsF7jQxo6u/dXz/ywFwSWFo sZsKZsh63GuEcL5WRNLcwkR7WxEc0xZSW8uNo75+I3ujC/u3/4ehLtSXiRDOCZJhmscx YTww== 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 f2si21740870pgl.74.2019.07.26.02.38.53; Fri, 26 Jul 2019 02:39:08 -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 S1726332AbfGZJiN (ORCPT + 99 others); Fri, 26 Jul 2019 05:38:13 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:48939 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbfGZJiN (ORCPT ); Fri, 26 Jul 2019 05:38:13 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0TXq4TFt_1564133890; Received: from JosephdeMacBook-Pro.local(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0TXq4TFt_1564133890) by smtp.aliyun-inc.com(127.0.0.1); Fri, 26 Jul 2019 17:38:11 +0800 Subject: Re: [PATCH 2/3] fs: ocfs2: Fix a possible null-pointer dereference in ocfs2_write_end_nolock() To: Jia-Ju Bai , mark@fasheh.com, jlbec@evilplan.org Cc: ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org References: <20190726033705.32307-1-baijiaju1990@gmail.com> From: Joseph Qi Message-ID: Date: Fri, 26 Jul 2019 17:38:10 +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: <20190726033705.32307-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_write_end_nolock(), there are an if statement on lines 1976, > 2047 and 2058, to check whether handle is NULL: > if (handle) > > When handle is NULL, it is used on line 2045: > ocfs2_update_inode_fsync_trans(handle, inode, 1); > oi->i_sync_tid = handle->h_transaction->t_tid; > > Thus, a possible null-pointer dereference may occur. > > To fix this bug, handle is checked before calling > ocfs2_update_inode_fsync_trans(). > > 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/aops.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c > index a4c905d6b575..5473bd99043e 100644 > --- a/fs/ocfs2/aops.c > +++ b/fs/ocfs2/aops.c > @@ -2042,7 +2042,8 @@ int ocfs2_write_end_nolock(struct address_space *mapping, > inode->i_mtime = inode->i_ctime = current_time(inode); > di->i_mtime = di->i_ctime = cpu_to_le64(inode->i_mtime.tv_sec); > di->i_mtime_nsec = di->i_ctime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); > - ocfs2_update_inode_fsync_trans(handle, inode, 1); > + if (handle) > + ocfs2_update_inode_fsync_trans(handle, inode, 1); > } > if (handle) > ocfs2_journal_dirty(handle, wc->w_di_bh); >