Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4508686ybx; Mon, 4 Nov 2019 14:33:33 -0800 (PST) X-Google-Smtp-Source: APXvYqwkkRnyrqZJifYNlWF/5Jt6SJ9UvaHroIosgZbaNK4fIZLSQsaZKyWPb5khAPHF/aL7T+Kk X-Received: by 2002:aa7:c987:: with SMTP id c7mr17050908edt.232.1572906813250; Mon, 04 Nov 2019 14:33:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572906813; cv=none; d=google.com; s=arc-20160816; b=eVc8rFrI1/8IiyyUnDUJ0oHElOfjB+zGdYqxIrVExAVJouoP51OkfH1LrN2JcTEw3O +KokuLIYfrAh7hN3E89qCTccNT7nhFhEcvbC1w7A4ga0YjP0RTBtlC/4DSx1oJ7KbQQu 90mxeXabC0P9zk/ZIhh0oBqRQZUExYGKewr4bPgvVqetUzPhKQ5SPPa6KOCKUXA4LSy/ FjcGoJIhphYt8KWC/Qy19hISN19tl3jqwfh2pHxVRf+yxw4V1NMvw+IV8Qr93OUKRwbS P3NI0h5SjCvLpn81Lqos7aMjeJUJN5nHBlfXnhKhhWr1E9obmTnvOwOdkKVKS9TTf1av 1yqg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G+V8ry0ewQGgq2ok0LHOnpqA+t7sDX+aS1SED/vWlK0=; b=ufXXj25hdiZvbfWsrYEdEd2kUvbv+cHoj9fUmwHRVHNylRMnIuFQ6m4b71ZVhd6zi1 X/jJDx/qJ0Z+lNEX1yk7skHqL/LInD9b5SadRZOMhaAFxXIOB6m+///j1NXFL6e8wbF4 Kyeq0vHmR2020Cc4yGTEVMmpIOdDdCwFb9JmD7TXe01XVQGiiDCt3iY/622uHYFcywox oD1xsuXdKefv4n/N9Pk0UiVFxWKqWTlgOmgseY33QmrSe60na/Wa4RfP5nFAyt5JZfSY 9ch/GyP2tmh0VUU0jI5d3L6XDLRu+ZNgMPBz1F83ndgdRcNpBxKWmtsjGf5De+LOI/VR +TiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DRaLP6Z5; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a24si8447072eda.446.2019.11.04.14.33.08; Mon, 04 Nov 2019 14:33:33 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=DRaLP6Z5; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389147AbfKDW3H (ORCPT + 99 others); Mon, 4 Nov 2019 17:29:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:38140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729899AbfKDVsJ (ORCPT ); Mon, 4 Nov 2019 16:48:09 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B347B21850; Mon, 4 Nov 2019 21:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904089; bh=1FToogkIY8Hsa4SVq/KUItZyuhUtpk68aHUfQPLdhjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DRaLP6Z5wV4Ddo0yxax2Ib3PlmP6+sy7TyqLD1YPP8afeiWSDLmWU2SywUiYr53b5 evyExS05SU8jO9VTJYCNN6HKASq3xnJfhMMLCmcdYkfH1pZmCtBWiAEDOdqVYHaETA h/jSYR4Tg9lN/SFCGvJpdBTs2dUn8jTlNzJ5o6Kw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Gang He , Jun Piao , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.4 18/46] fs: ocfs2: fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc() Date: Mon, 4 Nov 2019 22:44:49 +0100 Message-Id: <20191104211848.170365924@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104211830.912265604@linuxfoundation.org> References: <20191104211830.912265604@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit 2abb7d3b12d007c30193f48bebed781009bebdd2 ] 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. Link: http://lkml.kernel.org/r/20190726033717.32359-1-baijiaju1990@gmail.com Signed-off-by: Jia-Ju Bai Reviewed-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Gang He Cc: Jun Piao Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- 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 3cb097ccce607..79232296b7d2b 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c @@ -289,7 +289,7 @@ static int ocfs2_info_scan_inode_alloc(struct ocfs2_super *osb, if (inode_alloc) mutex_lock(&inode_alloc->i_mutex); - 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); -- 2.20.1