Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4381177pxb; Mon, 21 Feb 2022 19:43:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzzYC7erMZ4jveBX5jhUGbga4wNvN628B+a5G1F9PorssV94sf8jrmpu7F0FMB0GeaBMYQ X-Received: by 2002:a05:6a00:139a:b0:4cd:8c6c:1e97 with SMTP id t26-20020a056a00139a00b004cd8c6c1e97mr23065108pfg.66.1645501398029; Mon, 21 Feb 2022 19:43:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645501398; cv=none; d=google.com; s=arc-20160816; b=mxJvEAPFh32nQaPQAKX4RsIdNN+o0pXNOC0FKMBXy8UDLLKFcMG0a4uL9jF4FrlOfu 6N0rTu1dWUb4ejwFcCd4K0aMu8XFZFS8y1aMQ2i1oq86oq3VMIEtfcHmqjRVX1eOo9+9 D5CDgcXJuIcNUJnnOFPo3XTNM5Cnk90MT/gr2KwXeBRjvvf3hWF+i0YBOe6ov5qohod4 x7DFkHRCQWfR4L3gfpwbtPkxh3fydNys0/HFwHXm5HX+YVR0rTod8KFnvXYMiu2Eglh2 0h5I0IJVmRurzB75P8i7/8e7GXgkGoJW/CZ02VhCl8NPxXl/uz29m47R9vm6t75jVVV3 IzXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H77557zizM+w4aLiJM31gSdkFWzA2tOYtuPpWIeEUIM=; b=be70ynVdLtKNwzeW8dbrCHBFME8vj/EBg+XbLTgYycvjUg/gf+2SDQQlvGFw0kvoec CSszn89s/vtA3uBqRvmgr0JD43qtQPiXn3DF7FMcKNLj6GatelO0MqdEbep3uouyC0Ef xSpTMSu9Eu6y+8MI2gVr0uECm4LmUwI9QoxEkopR5sSWo/dyLKL2l6NR/PdY+92ZmDxe /yjuv0eORN7Jh5qDmI0xullsrgsR2sJwKQopwVHaYybz/Y2NYteM1xMWJ7BsYiGLUAoP vgs6HkkiJV47hyAOskCNA5viZacmM2oOaNUr+qmR0YM69w3115kRDK/u9vyvqGWWbgZb pT5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uardooxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9si2825923plm.150.2022.02.21.19.43.02; Mon, 21 Feb 2022 19:43:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uardooxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245419AbiBUJOX (ORCPT + 99 others); Mon, 21 Feb 2022 04:14:23 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347855AbiBUJJA (ORCPT ); Mon, 21 Feb 2022 04:09:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 045FDFF4; Mon, 21 Feb 2022 01:01:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 95525611F4; Mon, 21 Feb 2022 09:01:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D61CC340EB; Mon, 21 Feb 2022 09:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645434081; bh=25js9VCWbrkkR5tekcOAtjE8leOjYh28nQ5IV8FeWRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uardooxO8ax9W4Y0fs+vi0oeRiNZetWNZnBwcoBkL4Ju1yvubUr2iSHSfDWcKMkKR fNZoxUN3ilsqZ3aZdUs2jVCHYXYGUX6pxirn2YyM7SO0OFA9C4aR3kZXMtzskVzoZ5 n24ubacNiD2NdROr+T/eJXWigIls62vWS2GIk80U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Menzel , Trond Myklebust , Donald Buczek , Anna Schumaker Subject: [PATCH 5.4 55/80] NFS: LOOKUP_DIRECTORY is also ok with symlinks Date: Mon, 21 Feb 2022 09:49:35 +0100 Message-Id: <20220221084917.380113774@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084915.554151737@linuxfoundation.org> References: <20220221084915.554151737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust commit e0caaf75d443e02e55e146fd75fe2efc8aed5540 upstream. Commit ac795161c936 (NFSv4: Handle case where the lookup of a directory fails) [1], part of Linux since 5.17-rc2, introduced a regression, where a symbolic link on an NFS mount to a directory on another NFS does not resolve(?) the first time it is accessed: Reported-by: Paul Menzel Fixes: ac795161c936 ("NFSv4: Handle case where the lookup of a directory fails") Signed-off-by: Trond Myklebust Tested-by: Donald Buczek Signed-off-by: Anna Schumaker Signed-off-by: Greg Kroah-Hartman --- fs/nfs/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1641,14 +1641,14 @@ no_open: if (!res) { inode = d_inode(dentry); if ((lookup_flags & LOOKUP_DIRECTORY) && inode && - !S_ISDIR(inode->i_mode)) + !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) res = ERR_PTR(-ENOTDIR); else if (inode && S_ISREG(inode->i_mode)) res = ERR_PTR(-EOPENSTALE); } else if (!IS_ERR(res)) { inode = d_inode(res); if ((lookup_flags & LOOKUP_DIRECTORY) && inode && - !S_ISDIR(inode->i_mode)) { + !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) { dput(res); res = ERR_PTR(-ENOTDIR); } else if (inode && S_ISREG(inode->i_mode)) {