Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2013271imu; Fri, 14 Dec 2018 04:30:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/WNMghL3flQ2gPhiMtfnriMvveYqVqiox3VexuUklJRHcgK56BCyrzSdwd2mfud/OiIVabq X-Received: by 2002:a63:91c1:: with SMTP id l184mr2566265pge.29.1544790647524; Fri, 14 Dec 2018 04:30:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790647; cv=none; d=google.com; s=arc-20160816; b=aGD0JhLTaOvtNWejDj9ZV9xiVtl7xMWqStUfh8MneQlzOeQOAuKW/BoyTEj3Rg+Q1F rgB6v9rLeJ74KOL3pMGAkkfH4lT/HJYyYz3n4H9FDbBHVgnXAPUke/dP1ROgX1BoouCn 4jM4fHFdgBSL7vHzNlwSDHxiKW1aqCJfy09/IiqIVzLUZejKKyVsqFRIlagDVZf1ZdXh 2Y/faYr/2cubiC8dBzDPK3rMeP+xukAs/sjxdBJ9prcObYB6f+lhUu93n4zU7PSEVEu1 zR6oBraA0hMan/RgzLm1ApaY51oyrSP8Aa7wHA35HcwZ5i6e+jjE6229b6k5qDb5MANi HQnw== 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=ytj3olw0o6oUQL+tJvXFchYqQIFntjpC0b2HlTQ2vBQ=; b=IDQv7LYfv5GmzWqZQgR+xFNu7cORvBopduflQ5YSNE1waNh1wVyErAJUXgtPWl7Wvi AYPsktb2pBzRjs/FuTbYToANpp6zb+WRIuiQIJtv+tWI5GbVfE8MKXxu3OlawmixsCHw MLdmoaPUpeJTNwcrCeTVULYs69/dwH8coWM8PEbl4oagubAMsztpkUEHgWk5BvaiU5DO 0efBuU0FzyxKnyjL3muX/drOuyxTek0pHMpoq0h8zW3GkO9BUbazf5bMxR+jb3IVbM3y VSJ0uytD9GxUSq8ZXXHHnXwbwje9WOjZDw5ROMO55XXCu5hIQ415FhkVgLb/hrid58Yg V+/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GSrCxZJT; 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 z6si929502pgl.109.2018.12.14.04.30.32; Fri, 14 Dec 2018 04:30:47 -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=GSrCxZJT; 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 S1731607AbeLNMK3 (ORCPT + 99 others); Fri, 14 Dec 2018 07:10:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:56362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731085AbeLNMK1 (ORCPT ); Fri, 14 Dec 2018 07:10:27 -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 12EF72146D; Fri, 14 Dec 2018 12:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789426; bh=iqaYgmRMF0wZBLQDhaHrmCFen7HDfd9wWlMW4oVP9Xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GSrCxZJTWVOAlLPD1Z/DE88w1Ep3XXfWOZwIWZiyQvb/z9Qn9yo0rD+wCxrPEg6nm Q+xDaszFexRbNPElI/mkzm7tKSoeaktiioAOZr+VS205Rb2vS5mTJNAcjOZqeQl0YD bg/lEiJzMOL6/c3DtCmDch39bMZsGlShJ8kjeIEg= 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.14 78/89] ocfs2: fix potential use after free Date: Fri, 14 Dec 2018 13:00:31 +0100 Message-Id: <20181214115733.547997569@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115729.658859279@linuxfoundation.org> References: <20181214115729.658859279@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.14-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 9f88188060db..4bf8d5854b27 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