Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4482661ybx; Mon, 4 Nov 2019 14:10:14 -0800 (PST) X-Google-Smtp-Source: APXvYqwq2wUZuxtZiTpDilvQGeC64FRUzPJDHnVgUDBgb0KXZtBYnD/K/Zg9KxM7W/cnepI4Qt1D X-Received: by 2002:a17:906:5786:: with SMTP id k6mr26350645ejq.294.1572905414509; Mon, 04 Nov 2019 14:10:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905414; cv=none; d=google.com; s=arc-20160816; b=fOG3xBrNkDsva0FzTV6z8TVIXhf2E4vejOaaxzxFijLsCuLljbrQvg/BUar4uFPRPh ZFvTHn8paxci7RpSXf4XrgISNeon9JTsgI7DuhaeCVvUna1qgSmuJ0qFepOprmfvQc9t ZreUwAy7kqGvoBpv6KMso0fGWde+nTuw2QFr0VSsVNaBPTHP1rP8NBauvxw9UhI4+o5c B78hBLUF2LEUUGPnZi+VzqHV0gXMblL6lox32/Cd3UqD5s2cD+m+E2Z5BBtczVWy8WmW 2nHeSfw1kk7DXyNc/PoqN4LfMMG/Mjm82ZOsPL+GyK6tzKdgXSsAX/SEKsWmZXuB/sRB ZGwA== 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=D2i+CzrklA4QQxim1E2IkpyaHt5zfQ42WqT/1SEzbPs=; b=0J8F2rHKzfFf02lwJhzI96kO7wga8XgB7jbVkWA0ndu/CwYU0M3GMtiGRiNwL5zFOe SObhoKm5GATuhQz4Lsk0gB7wJ8Nwb1HEmYw2HNUOdzT+f0rk1khlx0THLtnZCUh9BnRc 3gwwVWqgOX00PhXLs01s/eK1PaHnsCV26C6akuqxuTbBgT8UMQYK0qrKIMoO4Rqiq8us 82efDNPBFTqNByYBgE7YCjuK+bkE5qZBq8QJn5joPZElKKUsuOT09GyNEYiKwOzLFrpy rRsklTakzZ39ct+EnmOtqKA4rt7L/3qbxAooVXhnFZLG0gCT9ouicRsJHflxlrr69ZL0 PCYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e0tpWy91; 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 w23si12395078ejb.156.2019.11.04.14.09.50; Mon, 04 Nov 2019 14:10:14 -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=e0tpWy91; 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 S2389985AbfKDWGi (ORCPT + 99 others); Mon, 4 Nov 2019 17:06:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:38434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389044AbfKDWGd (ORCPT ); Mon, 4 Nov 2019 17:06:33 -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 AA93221744; Mon, 4 Nov 2019 22:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905192; bh=l4ufX9DFTWVEsodenjVNjo/1QN5IcvrZe4Qls64Ta0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e0tpWy91MziLzKuyO4d2YYC+Et6nug1/3RxGKOGBowt8tL2ZhX1sYbVGvYXNolGvP 80trMnp2Ho4NG2GNYiMPiidcUfSkWxww0jvTgrWj4ZvAHrGpBY8RFpgS4BijYxT/Sk DovGPHpVeS0TqlWXJPaVBbDp7jHoAByBtOdfCjkY= 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 5.3 061/163] fs: ocfs2: fix a possible null-pointer dereference in ocfs2_info_scan_inode_alloc() Date: Mon, 4 Nov 2019 22:44:11 +0100 Message-Id: <20191104212144.472508122@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@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 d6f7b299eb236..efeea208fdebd 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); -- 2.20.1