Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2009109imu; Fri, 14 Dec 2018 04:26:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vl3wnKfhk7Dk+lx7BOW9yFkvXSfsbTFGbXQGyydEQOu2Rz8UPPxBYccmWoR4DC5hi3VDHh X-Received: by 2002:a17:902:bb05:: with SMTP id l5mr2763588pls.230.1544790400169; Fri, 14 Dec 2018 04:26:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790400; cv=none; d=google.com; s=arc-20160816; b=Pl+SHO/3b6QUnqgslGGRmoCFu5U4neY9M6citFA0o04LqE0mUPjGijtjmKBPJFDBWa fh3jsKTLYO2G1CrE1ts7ceB3/IwCJUp8Ve19fB7mlCI4mGSylo9tXSSXk52bF1aMrhI+ 9qXXX99TnK+g3F1VZmwxmOWyhY4e5DppwbNghRkHpl2facsbGmHUi0HeEYSIR/ou3azQ OEozusQS1PZdxl4uOapO/nR5jEl1uAiqmMyfkupHqz85Qvoq4jjP8u307LfKGsWSbJc0 Ov/FDTpL7qJjjHLnLOunpksU4hTTOmKDd2h7aNIio4b7osEMyQXvwOSwQLW4aaKLId2Y VTgQ== 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=lrrtlVylzOtYFtpC/XbiBnDDQk7PJCSHfZp0yGn0sT8=; b=XUXNax5rfPvnl3ksSxun9jejv9Fw73WmXDyAJowa74xjn0cqQjJ7Vb1sE2oRPoe0Iv MBMgDre8qtmccz9CiWz5ucatgUDXQ/YvRysZLAUR3KXWErmTEh+vjpe0BnvwmHLCJMPH V7RGLxGVxx5vgAMmwXodGqhMuk25SFTtUDRn9+motFbSnNJWgqt8MZFXFclFK81Wl6zZ YbG+A1ox9BCDoRsi+wJtXbYo6suDzcS4GBVCkFJM7aiDBvlAImbyPddRaQcNPLKL8rsa fOheC31+G7yS9n0GSLEmQYEfs5u2v5qT/2i3OoHJ5zOjTps6XyAdBYuKCmb4gggZ/9YA 4GZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sb2IUPKP; 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 11si4037140pgs.126.2018.12.14.04.26.25; Fri, 14 Dec 2018 04:26:40 -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=sb2IUPKP; 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 S1731594AbeLNMYa (ORCPT + 99 others); Fri, 14 Dec 2018 07:24:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:60486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731824AbeLNMND (ORCPT ); Fri, 14 Dec 2018 07:13:03 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 BB69720892; Fri, 14 Dec 2018 12:13:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789582; bh=ywSiPdb7y3qGEOA3G0L8r97mpbU5vnycsg1hgKr6cMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sb2IUPKPCC/1FKfZ1Eaw3oN4UezavtOsm7XCbCrgD1nB2WPDsntnCDFkSUVmbgCEJ UmTv4Mvq/0kZKRZJcrT8Sq0iHGDWD4cNHqbvZYJVVSmTWlzzFq1TTg8u44K5cPAlUX SDsxsc+5U2QLENufgZHWSJMhmx//9xiMDCimnU3I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Andrew Morton , Mark Fasheh , Joel Becker , Junxiao Bi , Joseph Qi , Changwei Ge , Linus Torvalds , Sasha Levin Subject: [PATCH 4.9 49/51] ocfs2: fix potential use after free Date: Fri, 14 Dec 2018 13:00:51 +0100 Message-Id: <20181214115717.404457127@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115713.244259772@linuxfoundation.org> References: <20181214115713.244259772@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 164f7e586739d07eb56af6f6d66acebb11f315c8 ] ocfs2_get_dentry() calls iput(inode) to drop the reference count of inode, and if the reference count hits 0, inode is freed. However, in this function, it then reads inode->i_generation, which may result in a use after free bug. Move the put operation later. Link: http://lkml.kernel.org/r/1543109237-110227-1-git-send-email-bianpan2016@163.com Fixes: 781f200cb7a("ocfs2: Remove masklog ML_EXPORT.") Signed-off-by: Pan Bian Reviewed-by: Andrew Morton Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Joseph Qi Cc: Changwei Ge Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ocfs2/export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c index 827fc9809bc2..3494e220b510 100644 --- a/fs/ocfs2/export.c +++ b/fs/ocfs2/export.c @@ -125,10 +125,10 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, check_gen: if (handle->ih_generation != inode->i_generation) { - iput(inode); trace_ocfs2_get_dentry_generation((unsigned long long)blkno, handle->ih_generation, inode->i_generation); + iput(inode); result = ERR_PTR(-ESTALE); goto bail; } -- 2.19.1