Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2007324imu; Fri, 14 Dec 2018 04:24:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/W2HID3RAyDlO9kwvyalNm88IQ7EYdJMz4koMdByh8Wh+bu2jW1qDpQtHsR3+BixpmPpJyy X-Received: by 2002:a17:902:142:: with SMTP id 60mr2763810plb.330.1544790293180; Fri, 14 Dec 2018 04:24:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790293; cv=none; d=google.com; s=arc-20160816; b=tGP1xO8JVoXWBhYRvbs10D9pQW+3kH9FHVPwtpfCg9lZInENq/ms3JZrgdFoLHnVfY 3KD5qOZyep/b/4peRFKjpdW01NUqmz0bvFQbE68NnuM93yGdsE/GbVUhiTuPUCI6Wfe2 HiXDj1hQpBtThvWHAhXYX1t+NgQRFnnP2a6gw81VYWxPsqC8C8XXz52jsncHQmkq/Uin u1k43pMCiWiVzWbiHZr5u9rq//v6JU0oGBt1S+EV03wQzLS7gdUJL4OsjHFbaSNlrkZW 5UiMmMHqI0+5FmEkmg6+BQxyfEN0sS5wFu5CQGLeQ/GM3cK1DIJc8i76j/PUttac5S1n aJSw== 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=ArH3myUFW2/4GGzFOvj1xrF0a5BWLBGUIwYIvPLntcw=; b=SpisMNflR4uEBto7MCblq74QRICKxv3BDRbKi7c9tZG08sd1s8ue6shNYkfO04B+K0 fjDywKu51QGGlw//0gPTF6Q0rzgOtkypcWGVloUnAdA5H/Loi8TkjjsPVeYgsMgdc8sm XNP+lXQHuq9o9mTsLqxW3lcEXVRJ1ol2mon6Sc5khmVSoZz7thAYWYpZCVLs4Utembgy gXPc1z5bAGb3rY92Xi+cSW7FUErsJdKXRxo5J4syXp5XftLNfIlETvYC/sCIkw6UeHw0 ZGBDD5xqusXXUf2SKYaikJ84T5mWfGr0L8NV30FDdKCi2Ndxn+zjtDZalQvp8gBtN4u/ y64g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UAOqauAj; 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 p5si3769079pls.338.2018.12.14.04.24.38; Fri, 14 Dec 2018 04:24:53 -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=UAOqauAj; 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 S1732151AbeLNMWp (ORCPT + 99 others); Fri, 14 Dec 2018 07:22:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:33580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732243AbeLNMOB (ORCPT ); Fri, 14 Dec 2018 07:14:01 -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 8A315214DE; Fri, 14 Dec 2018 12:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789641; bh=Ejgt2V9/hAck2JFzpuI+RIWSsf1uZJdWJt1fE4q8E/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UAOqauAjogkkGbxqxE+itHWumpyEfBeQR7WZgd57EdwX4ApNFHzWJgp3D1OlXFiyT EfA6/grIezHqt9uhLR1KZZce+LRsUVaoi5sQECVWd8lzypg1soAhSc5jmDHHO/K0f2 SU5CD4NyRdh16fHrP0F0Rpo0fMsF4+BjSca5VI+U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Al Viro , Sasha Levin Subject: [PATCH 4.4 20/88] exportfs: do not read dentry after free Date: Fri, 14 Dec 2018 12:59:54 +0100 Message-Id: <20181214115703.775074180@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115702.151309521@linuxfoundation.org> References: <20181214115702.151309521@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 2084ac6c505a58f7efdec13eba633c6aaa085ca5 ] The function dentry_connected calls dput(dentry) to drop the previously acquired reference to dentry. In this case, dentry can be released. After that, IS_ROOT(dentry) checks the condition (dentry == dentry->d_parent), which may result in a use-after-free bug. This patch directly compares dentry with its parent obtained before dropping the reference. Fixes: a056cc8934c("exportfs: stop retrying once we race with rename/remove") Signed-off-by: Pan Bian Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- fs/exportfs/expfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c index 714cd37a6ba3..6599c6124552 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c @@ -76,7 +76,7 @@ static bool dentry_connected(struct dentry *dentry) struct dentry *parent = dget_parent(dentry); dput(dentry); - if (IS_ROOT(dentry)) { + if (dentry == parent) { dput(parent); return false; } -- 2.19.1