From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48A81C43381 for ; Tue, 12 Mar 2019 17:19:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B287214AE for ; Tue, 12 Mar 2019 17:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552411186; bh=nInn66kLdAyEWINs8d1XXJnfyoUWoyEMoGetgkOFhzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=yM+piSTB1U3PvEoLvrxv+tLKWy2vOuuf0ZXDbf3Wk/Uis9PJGVFQQUC+USd8I9uTp LLAJlGW9bhqMcOPqZHthjZ4PiKIqDBpiEog1Hub9PZfxEcmbtmD/qTVR8a/mCh6dpS 0Oi0eAUWlr1gJN2cd9GLQbZed50Z5MR8JAMIMB1k= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730148AbfCLRSr (ORCPT ); Tue, 12 Mar 2019 13:18:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:34984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729924AbfCLRSG (ORCPT ); Tue, 12 Mar 2019 13:18:06 -0400 Received: from localhost (unknown [104.133.8.98]) (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 A95BB21741; Tue, 12 Mar 2019 17:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552411085; bh=nInn66kLdAyEWINs8d1XXJnfyoUWoyEMoGetgkOFhzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BUfezR99x8ooBJCwTOWFnxYTw0CjSrFlYzNrOPvljStOAAgibYpr6lNySM0MwjfwT TkwNtkbO8TfFH0d4cvW+g2yFCq5Dy4yiwlZYL/DZA5BDlLRzazpkEuBnOGeH/WTdEL NfdMFfjSLzOhqMSZyzThfoLN4R46uSifpm7n1qSU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Ian Kent , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.9 63/96] autofs: drop dentry reference only when it is never used Date: Tue, 12 Mar 2019 10:10:21 -0700 Message-Id: <20190312171039.291363881@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190312171034.530434962@linuxfoundation.org> References: <20190312171034.530434962@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 63ce5f552beb9bdb41546b3a26c4374758b21815 ] autofs_expire_run() calls dput(dentry) to drop the reference count of dentry. However, dentry is read via autofs_dentry_ino(dentry) after that. This may result in a use-free-bug. The patch drops the reference count of dentry only when it is never used. Link: http://lkml.kernel.org/r/154725122396.11260.16053424107144453867.stgit@pluto-themaw-net Signed-off-by: Pan Bian Signed-off-by: Ian Kent Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/autofs4/expire.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c index d8e6d421c27f..2e1f50e467f1 100644 --- a/fs/autofs4/expire.c +++ b/fs/autofs4/expire.c @@ -563,7 +563,6 @@ int autofs4_expire_run(struct super_block *sb, pkt.len = dentry->d_name.len; memcpy(pkt.name, dentry->d_name.name, pkt.len); pkt.name[pkt.len] = '\0'; - dput(dentry); if (copy_to_user(pkt_p, &pkt, sizeof(struct autofs_packet_expire))) ret = -EFAULT; @@ -576,6 +575,8 @@ int autofs4_expire_run(struct super_block *sb, complete_all(&ino->expire_complete); spin_unlock(&sbi->fs_lock); + dput(dentry); + return ret; } -- 2.19.1