Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2020543imu; Fri, 14 Dec 2018 04:37:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/VK0L8MKF3/sLqAe2XfFzNMEFn/1oefVDXHTDh1fs6CuxYblJiQyZmxHDLJMT9wBtgtTzIY X-Received: by 2002:a17:902:9006:: with SMTP id a6mr2710254plp.334.1544791044388; Fri, 14 Dec 2018 04:37:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544791044; cv=none; d=google.com; s=arc-20160816; b=Y1Z06FKiz5dPFvnWTs8I5Nj5vwBSU5VRTJ1CGEAN0tCFmGjku5btgimRqErftrd1ST nfuNz9F7+NSg5yxDuhDy5orracrPqNqQsiLTyUNbB2rHg7E2c3xzfJz5X7pOAZN6dIxm cshNIKB+WXc+fPHPbIzqsa1jkw5Vc/ZSwIOYVqWzrxBEGNLMizCbo1YmfC7iBJit7aSH whnK21TPAf9iH0XnwUGjkcgOGwVlof7zM/mce63hLZS45kAKK+jyVbjTGslWptBS9E9w jPqP4/iqbVgpSEN1lDzQqLT5fqwMXYRNMosV41ys/1zmPH56q/kWqwq9AYaQ3TPA9ZQ2 AkuA== 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=JEZQmcUzh9qziGIlEWC1OeBJSHuovGuTszD3DZJ9/l0=; b=GSB3nQA4NsuqaVsqtRkFgM99QUbW72E6YHWBflUMtIvH2nPWjZLKQ7oOLLoCm6OEd1 opoAiPcX5dZbj/h6FL0xrqhmaMZ3Bifv/YtCLueqtxZVN8TVJ3Ae0OzMkPHPh4/Dv80g uPFei78q5qVlgmq8ohUenGf14SyXy6BM2S+93Bi1ZOkEsVwByfeAyAoqgE8F92HuHVNx PplaD2wMjGpkPZQAYKqpXL7LEmrWHfv1SSlGsgTsfK7v3cC2+AWyqVh83klmV6DtWgkz tXdF44VjL3j9PRCy4RJa3KT9cTyOvq7oSqrqD07x5iss68vpAU1uPOCSlpcFLtKXGXgr fstQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aPmbNpfW; 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 90si1913765plb.17.2018.12.14.04.37.10; Fri, 14 Dec 2018 04:37:24 -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=aPmbNpfW; 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 S1730978AbeLNMGo (ORCPT + 99 others); Fri, 14 Dec 2018 07:06:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:51712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730953AbeLNMGh (ORCPT ); Fri, 14 Dec 2018 07:06:37 -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 4497B21479; Fri, 14 Dec 2018 12:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789196; bh=ZE7nbhjTofNuXNdZQ7JCeevw9+3jJetsPmwLZJw7sXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aPmbNpfWIwn9ovSU6izlXREwMg6xFT7TlW3ZGTHIguPUVHDI8m+5HGUTbfZPBSRuX sV8YAqX+NUCmi3sb/vuHp4Es+O6BOhuMOGAjs3jXt06ya3QN01vtykg+eo8LORQU1n 2AKHm9+7BKS/Pwylh+ENSinnHqJyJG4cjqMSAcVo= 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.19 132/142] ocfs2: fix potential use after free Date: Fri, 14 Dec 2018 13:00:17 +0100 Message-Id: <20181214115752.319078972@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115747.053633987@linuxfoundation.org> References: <20181214115747.053633987@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.19-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(-) --- a/fs/ocfs2/export.c +++ b/fs/ocfs2/export.c @@ -125,10 +125,10 @@ check_err: 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; }