Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4501082ybx; Mon, 4 Nov 2019 14:26:45 -0800 (PST) X-Google-Smtp-Source: APXvYqzFUtSxdOASweRVqFGRfzu2watu6XGp0uJQrRKDjIcsDlH+ZXrRrMtsQDFCxKpbBF1j7U6O X-Received: by 2002:a50:959a:: with SMTP id w26mr32041360eda.214.1572906405691; Mon, 04 Nov 2019 14:26:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572906405; cv=none; d=google.com; s=arc-20160816; b=lM0BOoZVYCceVMnWcZAvtGjGqeob9y0fTz7gw/N8QqWjDYVHEf8/5f9ApmqtE6B/jU 8oq+BXDS5TQRE0lSCElDyvORuL+QDg3cVf/f5INkLrVGEl6RyEFKt8fh863wKP3gDtPK kyZPszlh56y1PygkfRVnaTdat8QBkbha4TtqvClJOkaDR5JqeXx7hrwv6PFf2iCSMZ2W 2e92ow+byVmXHiTlKtfR02wqpgfeAUICzHPsvkwAP8DXbH+S7FMxec35lAWD+D5xMIDq X5saDMPQGilyxK+xFAxQyovSSZY1pfd4q90raviTLqsxCKoJ/8c3TRSKSjeiUNpOGmmm ySaA== 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=xq3JIg8svN+E4nY2vOj4L6X6ecCjyoa8mqVWn6143mk=; b=R8nu0lQ9c6Bjw2bNX+gMpS4nZV9FBaLUcvQB1AZ1k/MwHoCfBgPc0pcxN6vB+y2Tvh 2x0+FknZoQ9bgw+Tiamb4737s4b0UsWTl6Mtc5so0oOF9MLxJyNaTQbTRwJjf5fRyRzm HrG4XG6K6U1kCSCipmimyoOkomf4pQZny2rjfacnSp2wUU53FnQd4FF7I6k1dpNOQ5UF 1esE/dwjfOkZ4MGhojgL9rBc3zdvt1+VxCvAxaXzbvZ9K74WEEOFNtbjfZqiEa0fqJyS rBYbqfxCwJYn2WkSlxZTAa93DBQ6MOYHnK9ZfmBnqWpwqIwLFknY/Tt87n/Ceq19HDpv U/OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Fp0fgOUH; 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 s39si8427756edm.338.2019.11.04.14.26.23; Mon, 04 Nov 2019 14:26:45 -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=Fp0fgOUH; 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 S1730701AbfKDVwO (ORCPT + 99 others); Mon, 4 Nov 2019 16:52:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:45392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730675AbfKDVwH (ORCPT ); Mon, 4 Nov 2019 16:52:07 -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 860DB21E6F; Mon, 4 Nov 2019 21:52:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904327; bh=LtgV19MgtfFX69rc+LOivsTvlCGFkpIRKuEDQjfkHRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fp0fgOUHP7k62LPhFqmxXIVvJO89biLRItFf8jD/uGyrhKj6lRFEMHTe/3ltH3xtH qNMngdCADD2dCHABqx9GqJLqOU47+AoWH8pakKfDKHgmZ020O1jNOBnQJ2YQ+vJyE3 kKQSE+FM9G20HbBO17zDLqt6wBQW1CYKJB+oyCK4= 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.9 26/62] fs: ocfs2: fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc() Date: Mon, 4 Nov 2019 22:44:48 +0100 Message-Id: <20191104211925.266199704@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104211901.387893698@linuxfoundation.org> References: <20191104211901.387893698@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 4506ec5ec2ea6..bfc44644301ca 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) 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); -- 2.20.1