Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4165969rdb; Thu, 28 Dec 2023 12:22:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHFXAKaU3ezFD3zjwq7IWTLhRIbV2vStTQDUPRen+kpgLcKYLNyQ8nz0DVHcTCuSvMFI2aY X-Received: by 2002:aa7:d845:0:b0:555:42e6:f30a with SMTP id f5-20020aa7d845000000b0055542e6f30amr1923262eds.14.1703794921664; Thu, 28 Dec 2023 12:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703794921; cv=none; d=google.com; s=arc-20160816; b=Zh5/l+uLtyhx9Lz8bzKJoQ23vBaspKaLFE5JViiD/XMuVykFl8wQwecwiRz8WpWoNS xzcwA5IRGE9YClIaU1BmjWQnh1BAmybtU8Toc9w3F1q5a3Y+t37yhrbzOS2QmnFfQDso WgEvxII72Hvkg93nywE8G1YeEEdFpy5ACzSmn+V+R6LTko79vp6CWNHb9TudNdKwMS0b Ncuua4F8jpxbrtW/XFSpPh1DCdYsVe+1jkwMFtNJ/R/w1U03/uCjTZOAKLqApjBuIT/7 gtSOEon383rYsGB44Fa0Qkc3bU6Qm5bGDUdv3p+5UBqLP6P6P+YJxrMllrRdKD2lvbxC wEgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=OTY/+nAmWlzR84vV87b3Rou80bzDMNtbMkfp61ayzEo=; fh=HzVLnJi8X0PTkh3BW9eWtTj8vN/0gVv1AW5X9gSuxbs=; b=pfrkYuU8aPD+uwvPitA+HhKHGmF6S8g4zzgZMJ+MUWuGc41f6Wu+keWXRrFS4mcPhj 83dPiRoUsRnL8a4YlbZ1CvNiEjTVqUHaC66DML/LkHHpbhlCCQl1LJMAmI+zGBcrq7LZ foE8ZeEwhlt7p0LtvmrlaqWSE7m0FegYt12g2/+APeTrIXGOjzOeIPsrJ2VYzG6jUdXy 82ZmhmrkHjqmJ4YlrWm4YhYm3oB0xJXXR9rtw7XziTMJLptGgaUPe1Gxl09ay+EF0QNi xMC2/UxdgrR8slBQF1Si8NZsC5mb4D7kgmHChFqPxf4yyzRUeNu9TZus3jNjW86ZnWPX 03hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LhCF4rwh; spf=pass (google.com: domain of linux-nfs+bounces-830-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y10-20020a056402270a00b005527ae447f1si7712185edd.112.2023.12.28.12.22.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 12:22:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-830-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LhCF4rwh; spf=pass (google.com: domain of linux-nfs+bounces-830-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 64EC41F246DB for ; Thu, 28 Dec 2023 20:22:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA2EB101FE; Thu, 28 Dec 2023 20:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LhCF4rwh" X-Original-To: linux-nfs@vger.kernel.org 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 BD806101F8 for ; Thu, 28 Dec 2023 20:21:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCC2BC433C8; Thu, 28 Dec 2023 20:21:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703794917; bh=fOdppVxrIBHYEV5j+WMfkWIo5wTTplgip4d3ftRTtEk=; h=From:To:Cc:Subject:Date:From; b=LhCF4rwhT/qVQvLfC8UGY5IYvD/JcRx93IKe7El2Ig7+b2vQhOdj63LkbCW3adWrk QFMa/txNbOlOBoxx3TEX6HFBcBmD8I6FSkxB06oAgVhkNAlwhl3HFNfPAD5VVCcKiQ gD+m2/xVMY3D909rpF4yF8/6lE6swwUEFtTum0zxz4T+lqJKo3RUMjo1ND+C22gYzT hoBCxnqOTxT5EjJUDZkXV3snxfve6C+fge5jN9pFLolDxds74kOVT7F0yE2S9YkeU1 6jo1cDufqXru06KW0Bn6nzHxUrTDrfr6BOcHQXbBA0X5Tt8rVC+i3pdkTkcciORZcO +6KCsvwICqhyg== From: trondmy@kernel.org To: Chuck Lever Cc: linux-nfs@vger.kernel.org Subject: [PATCH] knfsd: fix the fallback implementation of the get_name export operation Date: Thu, 28 Dec 2023 15:15:10 -0500 Message-ID: <20231228201510.985235-1-trondmy@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Trond Myklebust The fallback implementation for the get_name export operation uses readdir() to try to match the inode number to a filename. That filename is then used together with lookup_one() to produce a dentry. A problem arises when we match the '.' or '..' entries, since that causes lookup_one() to fail. This has sometimes been seen to occur for filesystems that violate POSIX requirements around uniqueness of inode numbers, something that is common for snapshot directories. This patch just ensures that we skip '.' and '..' rather than allowing a match. Fixes: 21d8a15ac333 ("lookup_one_len: don't accept . and ..") Signed-off-by: Trond Myklebust --- fs/exportfs/expfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c index 3ae0154c5680..84af58eaf2ca 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c @@ -255,7 +255,9 @@ static bool filldir_one(struct dir_context *ctx, const char *name, int len, container_of(ctx, struct getdents_callback, ctx); buf->sequence++; - if (buf->ino == ino && len <= NAME_MAX) { + /* Ignore the '.' and '..' entries */ + if ((len > 2 || name[0] != '.' || (len == 2 && name[1] != '.')) && + buf->ino == ino && len <= NAME_MAX) { memcpy(buf->name, name, len); buf->name[len] = '\0'; buf->found = 1; -- 2.43.0