Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7185649rdb; Wed, 3 Jan 2024 07:19:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWAWJU65sOBU6v/gyYDrtIO+7W3fhMzuwGFbqNAU5jlh0LIenDSXcpXbXWwIrhCYu1dI9V X-Received: by 2002:ad4:5def:0:b0:67f:4833:2168 with SMTP id jn15-20020ad45def000000b0067f48332168mr1608786qvb.32.1704295197599; Wed, 03 Jan 2024 07:19:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704295197; cv=none; d=google.com; s=arc-20160816; b=ZEpoT99Am3qTGleYZtJo7W5Yetr78/fv3XTnPSVo/KAixF8QRvRYBItfbUnhzbO1za KWR9jfE64H+z3oOPpOWcums9yS9S4McoBUgpFnabOcvMy7QqrwOLERkrFYHUHge1vDvg 7WLuDXau86qfFoNPCaFGzn3iY0cKLHTl9LBzB+oJlFFiSE31Ed4RcA9NaBsh/FGFkC05 WvBw436p9XVic1wI54PRo5fP/c95bmNPJ/tJGc9OUMvcZCzlA8h0Mg8Z4EeCp/hWfCiL 1pvduGlSsQvQZycry6Mamf9Kyc/6Sjp4X6c+Okl/UIyO9m5JLFwwnL5R+R0uTO6GlIF/ UPsw== 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:user-agent:references:in-reply-to :message-id:date:cc:to:from:subject:dkim-signature; bh=CPR0PBbyWGMbqpDgXUJcLUhDGEPDTKC5VnJ+KnN0FQM=; fh=BnHOaJ5Y/F0Gld3qwFSHSY+pG1ABTeDGkzW0J3bQbKc=; b=boHPQ/tTD+dwvy4GxeaByrFNfQXGmLcjkjtNX0t5D1DdKn1hvo2irBV0rg2Fupl8CE XDvYmaplUIliJintPMyHMEIJVKlI49DlfBBLqX5TGpJSpoj7O+VBPo5HYVJYx6OJ4R2U Q2vCQEmXi0APxg8x2AQzbSEJnou6aotRTP51RwtrJeGzEJKtNFT1mmBJARdc7jYFbDJb zSECKxSQcS0u4SXsmQb42vTKFIJmnmVltfH+hnAn6Fr3qEkIysK76LLSpj7MvBsokrKU 9BO1ZvC/afnncFT6MbYEA/FaP5XA5DgjSpNQ2cZxXaRvO9wJXhESzUz4arZgqMmQ9ghS SPzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=plE6VWuw; spf=pass (google.com: domain of linux-nfs+bounces-887-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-887-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a1-20020a0ce341000000b0067f85f97066si27735581qvm.586.2024.01.03.07.19.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 07:19:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-887-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=plE6VWuw; spf=pass (google.com: domain of linux-nfs+bounces-887-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-887-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CE3131C2374D for ; Wed, 3 Jan 2024 15:19:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D6B81B27B; Wed, 3 Jan 2024 15:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="plE6VWuw" 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 E42C31B279; Wed, 3 Jan 2024 15:19:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD6CAC433C8; Wed, 3 Jan 2024 15:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704295179; bh=IhnX4hHtRzrAnyp6d66bwgBG87Kr2elb7Rz8vNJe5Ow=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=plE6VWuwt6yn2R19NJuwEhxEQ475wHEH7bMh1cK8HNRiLKQbsQKb2UYafOeBlVA8k +RPwQ0S69JONgea/v32RnpGSkgy1Gcm6URJgWqP6VPGeO8ahrhWqRcWZD5qbT9TuYm 1fESNLkXF39Hj5b5xbk5z5FrxsiMFoXNFeHNeip/ruF7U84ooIarcU9ShyfRgW5Gz1 +cqKK9HtkHjDyeeQNCdBYNsoE5bXEK50inR8yy82XNjNgYopamSoYNnI0X+SNj5/C7 edeN0J0cxrP4XwTsRaQisn7WPZA9YWRm2Rkz3+aBqFToJzlMUP1nuK7VeUSLhHxWod lVrRD+JRJCUZA== Subject: [PATCH v2 1/2] exportfs: fix the fallback implementation of the get_name export operation From: Chuck Lever To: jlayton@redhat.com, amir73il@gmail.com Cc: Trond Myklebust , Jeff Layton , Chuck Lever , linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, trondmy@hammerspace.com, viro@zeniv.linux.org.uk, brauner@kernel.org Date: Wed, 03 Jan 2024 10:19:37 -0500 Message-ID: <170429517779.50646.9656897459585544068.stgit@bazille.1015granger.net> In-Reply-To: <170429478711.50646.12675561629884992953.stgit@bazille.1015granger.net> References: <170429478711.50646.12675561629884992953.stgit@bazille.1015granger.net> User-Agent: StGit/1.5 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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. Signed-off-by: Trond Myklebust Reviewed-by: Jeff Layton Acked-by: Amir Goldstein Link: https://lore.kernel.org/linux-nfs/CAOQ4uxiOZobN76OKB-VBNXWeFKVwLW_eK5QtthGyYzWU9mjb7Q@mail.gmail.com/ Signed-off-by: Chuck Lever --- 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;