Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2014949imu; Fri, 14 Dec 2018 04:32:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/VOddzgeL+p0924ku8chTmLv5fc0t/02vjJFrMJHWaVaJ8aSyheXpRDD/rI2hap/y5Ecnbi X-Received: by 2002:a63:be4d:: with SMTP id g13mr2582909pgo.378.1544790736226; Fri, 14 Dec 2018 04:32:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790736; cv=none; d=google.com; s=arc-20160816; b=RMXD7wndmzCLXqfgJY0Hgp/ZPyN7vO9hRIl+QgZ/jX5P1iO6KnTrObbyha0QAcaV/1 UxAnZbezCEEfz8YVKM9S/A8NW4FMRnk2dpLWvvOOIB2sbHY6tmvZDgBnDbLu3tY/dB1E 1/4zwpNiXiUeUlSJJqa8Xed9Rx80ISpDNSpGL0Y06MaVAibQRxdj3oTe4WIGj0hlwKme D5yr48KbzQPDi6UjOWM5aushuTAQpT64uHkw89zX6zDcf8qHMUaZkEgCMycQPQlnf+YE x7WT5wTDCa1jQ6C3AKmdlHeyZxxJflVeXNdZjQFp9cyw90Fo+WKRAzz6Vbzi/dTbXACX kLxQ== 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=u9sCigouC5GEwUgeTIPOXvnf/a3/O0Ed71a5wvwBBDU=; b=hMrmQifNrfJBEN4UZC0fDjY3YSwJbz7kaO5csmE/9/yDl6HJhAMgY0tKTNDm2GUzKO 4SOR86i1unEqBmeW1K/Ytfzb+/fD1R+2kU8ogRndTqU0HG6pYGaAoreeYqmZ7+sf6jzq zvmvo6LnW+AMqZtzEETosV0b30siPJ/AdMi18yacO7n8L+Du9q+8dL90PmxyIKI082Xk I6QtDkf3VoFODXsVxWB/UQsvQOw5dDoMaRTniQPO45WNevqB9uPBJSyqJr3DqhA5CTCk Sqt8Jb8RcYFFM6pWHADrrIiCTkoWwhyVOTLe00s72y673YoIVBnln8OyIZDQn8xejsSA PA0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="t7i/XS6D"; 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 k30si3941714pgb.113.2018.12.14.04.32.01; Fri, 14 Dec 2018 04:32:16 -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="t7i/XS6D"; 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 S1731543AbeLNMKB (ORCPT + 99 others); Fri, 14 Dec 2018 07:10:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:55728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731522AbeLNMJ6 (ORCPT ); Fri, 14 Dec 2018 07:09:58 -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 2B3B1214D9; Fri, 14 Dec 2018 12:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789397; bh=xsQL5MHGZopG8Lx116rvebKPTeX/DfCCdzP4W7gHglA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t7i/XS6DmjQNLxQV1Ul0lR3sGqv/Op1UYcxrAJt5rvTfXexfjcTXDwxbvQPW10qXC 4nOA9viv3qyIZ3Kwucr0Y/Uhh6QwxRb/dXbQNIU6daiTt05oVXJFJzHoPw0mQUxFwN IQ7q44aC5vcekfzKZI3WMUiOi9JClSFZZF7Ur0M4= 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.14 44/89] exportfs: do not read dentry after free Date: Fri, 14 Dec 2018 12:59:57 +0100 Message-Id: <20181214115731.849146622@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 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 329a5d103846..c22cc9d2a5c9 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c @@ -77,7 +77,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