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.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 8802FC2D0D1 for ; Thu, 19 Dec 2019 18:43:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E3E224682 for ; Thu, 19 Dec 2019 18:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781007; bh=vB7fiRaxZIeNzfklFngFBYkZnjceJ4G8m0vP6KQ8yF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=oXzKVvJvokR4trYgXGv3y6/qFkDtpjUcxMnkc28Qsya7QxGWT0YplFFKwLmKIheRX Euua6m7eDCI9sH7MAzb6BPbhdqivt8DZI7eTapPBSU3BrVQxUe7OXMXGFNPLWjqXLh n/48wl+RumGb3X96tNhL3lcojO4Abh4zOZRESIBo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728496AbfLSSnZ (ORCPT ); Thu, 19 Dec 2019 13:43:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:35016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728433AbfLSSnZ (ORCPT ); Thu, 19 Dec 2019 13:43:25 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 E971324672; Thu, 19 Dec 2019 18:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781004; bh=vB7fiRaxZIeNzfklFngFBYkZnjceJ4G8m0vP6KQ8yF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EVjP31HcaCioOUDhJ1IcRNolPtdG2jeaz4rSVKVFbGwE+RWPPyldD9Ezf8FsdBTug vV5KDFA2qNhygchHriYAow7gKlS+oTpb8mHLYLsvbx9ehCRmVvbUv6VZu+N+xTTGIQ VMqFd9kDEPa0KYGTPLoDLCUweipFAYY1p1VjhqkA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Sasha Levin Subject: [PATCH 4.9 008/199] autofs: fix a leak in autofs_expire_indirect() Date: Thu, 19 Dec 2019 19:31:30 +0100 Message-Id: <20191219183215.136584672@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183214.629503389@linuxfoundation.org> References: <20191219183214.629503389@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Al Viro [ Upstream commit 03ad0d703df75c43f78bd72e16124b5b94a95188 ] if the second call of should_expire() in there ends up grabbing and returning a new reference to dentry, we need to drop it before continuing. Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- fs/autofs4/expire.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c index 2e1f50e467f15..02f0d373adbf7 100644 --- a/fs/autofs4/expire.c +++ b/fs/autofs4/expire.c @@ -469,9 +469,10 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb, */ flags &= ~AUTOFS_EXP_LEAVES; found = should_expire(expired, mnt, timeout, how); - if (!found || found != expired) - /* Something has changed, continue */ + if (found != expired) { // something has changed, continue + dput(found); goto next; + } if (expired != dentry) dput(dentry); -- 2.20.1