Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2178892ybh; Sun, 4 Aug 2019 19:40:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQjNQi6zrarNvkoCX7rIWilwjPyFr7xFzk+OKmyzxiKbwb3Hv3jWSd3aMMN9GOIiGg9cWr X-Received: by 2002:a17:90a:9a95:: with SMTP id e21mr15516264pjp.98.1564972828915; Sun, 04 Aug 2019 19:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564972828; cv=none; d=google.com; s=arc-20160816; b=lcl1Lo0ic5SsJiAA8jQrqsTPshTi3haS/+D8YUmPWxebP44v5PaHoc2t4K2JCZ2LRc Yb/l3YaN1fQPrKTxEFAnVtmcznsiJbaoCSynINOc0O98f5VHJYGrmJCkea2nM+hqvRM3 lqFgDQ0LmD8SE/x221Jvcc2RJLRkIu4zFcDjQMw83qG+Xmwa/g5zrC92ai6iNIx9xn92 zd06hNK0rtX0ovN1LIWc0QQdNLOO9IFH6rsgySG//O9nTzdjtgU/JTGGaEZdtidLorJJ 1Nen9i/bxCjBzY8jeHDJ7WeYD6zmhVXB0wNGRAg0mbAAku5RPwKKRjy883uzo0cffF2r lspw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=6Emjj1lmLZcaj48Nz6SW9zfX16DHGw5ByS9TCsfhuto=; b=rgAUL+H1FY4j04w/E88Zpw/DgVCcxHS6zEuQvKVF0KeApg98xBnJOERYpO/6+vWrla VDtduRvsFMgPPEq7y7xfHt8bQQ4WDch3cLW9N6A3JskijMr4t2RBfQdm8PQVeEK4oFdV V3g85HPii4qo4yxEohIJlI4y97JB0OdzDOslzf2XEKWRBj9ve6ElosmLmt7bu+2UbHLE SJL6mU4qGR/aOK+VEnnvPYiHRjV5khEvzSjdmMJjNIsfRFgj+KcjVirXNY8pNe9WA+47 lfdwkziGqvgL3OXdR1+TDv1kPrj8Mu4FZiQcNBot9xtrXx1gaeOg2fCyyK7fVXEVeq9y 60Dg== 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 a64si45067709pfb.60.2019.08.04.19.40.13; Sun, 04 Aug 2019 19:40:28 -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 S1727017AbfHECi7 (ORCPT + 99 others); Sun, 4 Aug 2019 22:38:59 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:17597 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726767AbfHECi6 (ORCPT ); Sun, 4 Aug 2019 22:38:58 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=chge@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0TYeMK0t_1564972735; Received: from IT-C02YD3Q7JG5H.local(mailfrom:chge@linux.alibaba.com fp:SMTPD_---0TYeMK0t_1564972735) by smtp.aliyun-inc.com(127.0.0.1); Mon, 05 Aug 2019 10:38:56 +0800 Subject: Re: [Ocfs2-devel] [PATCH 2/3] fs: ocfs2: Fix a possible null-pointer dereference in ocfs2_write_end_nolock() To: Joseph Qi , Jia-Ju Bai , mark@fasheh.com, jlbec@evilplan.org Cc: linux-kernel@vger.kernel.org, ocfs2-devel@oss.oracle.com, Andrew Morton References: <20190726033705.32307-1-baijiaju1990@gmail.com> From: Changwei Ge Message-ID: <20d02767-6e14-c04f-4fcf-11ed2cbd63a2@linux.alibaba.com> Date: Mon, 5 Aug 2019 10:38:55 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jia-ju, Could you please point out how ->w_handle can be NULL if we are changing disk inode? I just checked the ocfs2 code but can't find any clue ... In my opinion, it's impossible to change disk inode without an existed journal transaction. If truly so, it's a another problem. Thanks, Changwei On 2019/7/26 5:38 下午, Joseph Qi wrote: > > 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); >> > _______________________________________________ > Ocfs2-devel mailing list > Ocfs2-devel@oss.oracle.com > https://oss.oracle.com/mailman/listinfo/ocfs2-devel