From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C75F26F461; Tue, 8 Apr 2025 13:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744117206; cv=none; b=ZnYTNBbWMDqH4Pqyb/sKXn0hjPEB4FkpQYuBdqhPyiPTT+jUPuoF/20y9Oew5QOF5fUFE13IhgaHFaGxYb53aHGDEr74TglbMcn8Oy1nO9ZERWlX3MLlt0bQuMsbox3BMCryqUQZEIsaTvWkPMpbr8BQO/Y/4rh2QCwN/TBSTpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744117206; c=relaxed/simple; bh=kD5mmHZ2DrKLthcvBX9OwF+WUUOXt7+nUDziUOkAxzY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V8vLPemJkDfeoE14T/p7udBbMwzTsmEh//0aRLT0zMbFeDviTXj90lJ3mhoIBajCDSwCKxTqBpfjcinupvCbquX5QKW98zaBN9H/BJhb+w8bkoKb+gZGtUGvooGvK7JgtmXpj5L4vOUeYUZUPfzFP4JqQ7UVTJxwVTrksRlX4Sk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iCTd6UaU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="iCTd6UaU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66C1BC4CEE5; Tue, 8 Apr 2025 13:00:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744117205; bh=kD5mmHZ2DrKLthcvBX9OwF+WUUOXt7+nUDziUOkAxzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iCTd6UaU6Prx1FjaEElRDb+yF/MG4Rq/0RAM2e609B0lVGZLg3QHRm6ynXTkxz2B3 mjF0uWyS2CmK/6sYx73EKw3yVXPmWERkbJ6ABuApVxNQLg91Jvzhci+T2hSF4Sm0rL AGeR4PKZVvJjgN2WBNsK4Cr/I7i1/JjPBU0V8L90= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Trond Myklebust , Jeff Layton , Chuck Lever Subject: [PATCH 6.12 422/423] NFSD: Never return NFS4ERR_FILE_OPEN when removing a directory Date: Tue, 8 Apr 2025 12:52:28 +0200 Message-ID: <20250408104855.764997222@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104845.675475678@linuxfoundation.org> References: <20250408104845.675475678@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chuck Lever commit 370345b4bd184a49ac68d6591801e5e3605b355a upstream. RFC 8881 Section 18.25.4 paragraph 5 tells us that the server should return NFS4ERR_FILE_OPEN only if the target object is an opened file. This suggests that returning this status when removing a directory will confuse NFS clients. This is a version-specific issue; nfsd_proc_remove/rmdir() and nfsd3_proc_remove/rmdir() already return nfserr_access as appropriate. Unfortunately there is no quick way for nfsd4_remove() to determine whether the target object is a file or not, so the check is done in in nfsd_unlink() for now. Reported-by: Trond Myklebust Fixes: 466e16f0920f ("nfsd: check for EBUSY from vfs_rmdir/vfs_unink.") Reviewed-by: Jeff Layton Cc: stable@vger.kernel.org Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/vfs.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -1935,9 +1935,17 @@ out: return err; } -/* - * Unlink a file or directory - * N.B. After this call fhp needs an fh_put +/** + * nfsd_unlink - remove a directory entry + * @rqstp: RPC transaction context + * @fhp: the file handle of the parent directory to be modified + * @type: enforced file type of the object to be removed + * @fname: the name of directory entry to be removed + * @flen: length of @fname in octets + * + * After this call fhp needs an fh_put. + * + * Returns a generic NFS status code in network byte-order. */ __be32 nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, @@ -2011,10 +2019,14 @@ out_drop_write: fh_drop_write(fhp); out_nfserr: if (host_err == -EBUSY) { - /* name is mounted-on. There is no perfect - * error status. + /* + * See RFC 8881 Section 18.25.4 para 4: NFSv4 REMOVE + * wants a status unique to the object type. */ - err = nfserr_file_open; + if (type != S_IFDIR) + err = nfserr_file_open; + else + err = nfserr_acces; } out: return err != nfs_ok ? err : nfserrno(host_err);