Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4689173rdb; Fri, 29 Dec 2023 09:54:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGh/ZI7iuyni/tW8N5p3qPladbxcilwYol3dh5sRw5oOXEdXLd0S+gDXC5AsEYlW6vX1bNH X-Received: by 2002:ac8:5f4c:0:b0:425:4043:29d7 with SMTP id y12-20020ac85f4c000000b00425404329d7mr13430474qta.82.1703872475471; Fri, 29 Dec 2023 09:54:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703872475; cv=none; d=google.com; s=arc-20160816; b=dK5yQa8r8urTrK9NU4bJfxmHh14IbrcdqXh6IsAxxpGKpy99tKuiMGBonhT3KvQhNp rLaS/SPcuPT8etY6fFMWU35T31sv8n3uHnIMr0sfAHSNrKUi+0pOs2NKPEyRV7aiZ3Gm DUDTOpZRUyKypgIBJOb7cCmjgc5vOLCv8Q/6BoHVia2iaSTrTHaoyCpMNOxrOxmFm7ya CduJb393axdE5MCbrSKgPEORR8Alw8bjgbxNWGM+XcGZVYzfcjrGppmVz++fJxiMGuMN jddd9L4m9ytnPdCSfr6W6PHW1vZErpzmYlSO2N7+9gNTjeU3iGvLg8Sn1InOmFocUEnA 2SWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=HgJgtyWKKmG9drWdDVYQvzVHZZPAT+G8Hw1ZAEuDKug=; fh=rwiaHyY90Ka0dv121XHQKS8Ghig5+12psWf/wF0vE1o=; b=w3deIzFBdKPO4VtYMzPHs0XfGooY2DvEr6W1AYY1T2cf97Kmc92hf70/R9689VWjpz +Zc8DiXHvvhSsHCrtmcs/ago3a2LfqMbZLo4rhUFClszPaFvxM2tkczge/jas/ibK8Sh YU2Ti5PclsQAb6ScDGd6OMpav66+nmDlwIJ34lENBbXdpXzlGNnXdFBGDboPyCEBjkOo UQ8HeR5/M+TkxfgdYUv0E/eSwkxB+pmmSXyhSq+Hqzt8ENjffgmg5Rs0DOO+o2fqSMUG NuaPY6KpHZojvSK3+umftgoJ3FnRvuClIs/XrN2mgkZuHKscLHyy+jVrVTokYBkd7pUP NktA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YKrdhbpt; spf=pass (google.com: domain of linux-nfs+bounces-837-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v8-20020a05622a014800b0042616ca3137si19489677qtw.484.2023.12.29.09.54.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 09:54:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-837-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=@gmail.com header.s=20230601 header.b=YKrdhbpt; spf=pass (google.com: domain of linux-nfs+bounces-837-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 200B61C20D45 for ; Fri, 29 Dec 2023 17:54:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B14D12B86; Fri, 29 Dec 2023 17:54:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YKrdhbpt" X-Original-To: linux-nfs@vger.kernel.org Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE28612B82; Fri, 29 Dec 2023 17:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-680496bc3aaso16998616d6.0; Fri, 29 Dec 2023 09:54:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703872468; x=1704477268; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=HgJgtyWKKmG9drWdDVYQvzVHZZPAT+G8Hw1ZAEuDKug=; b=YKrdhbpto/+l5mtvxoy9HLedD+uSUt++APeVuaJUpWzH8d0ArVt1obaVHVMbDW+mC9 rS0Pi+QcuFO2wthgjjsnI99P6ll7HP0OykvskB5M+LZiQa53oaadKIKpdAJqssULWF/l xeTMFKgN4zl3At51J9M5D4QNgYqzjnXUMlw6CTYh/oLAXRpsY3SRBLFHK8ImtQpVmkBF RX3eFQCiUXC14rXJxDPKGB3U0qko3ihkYNynF6DvBFsp0WazQ6gw4QSKB0dmi5160pJA uW5WR4tNilfpggbWSTCJ4n2O+c3vZ2v/ab5qQkljLAX7qzLDzqFe4lFAPzVVIz11/+im FL5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703872468; x=1704477268; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HgJgtyWKKmG9drWdDVYQvzVHZZPAT+G8Hw1ZAEuDKug=; b=OJy+hVWYqhJTMSCl1i0OjF3OodSjcbkSiNnKOTj086IlWn3dDfD96S2hUHBf13cERc AcANJOV2dKpo2wP9PinLGJeYRRTU6mVctKkO+6uldHPsG9Pk+vmmnYAoQweiHTKRdfsi suORN9kRA1TO3wwJzbpIbDMxA1PXYBvAJ8X7PiGLda/diCLHiQ6Z3JLzryoGA1ZWlEVL yY3j5n4GejDnotozvFcvt15FXuI6fYxYL+bN7bGr21ap0NGIXB7zCicJzQNrkgzvMU7g MbUWj1RSxqNmp/JAiSA0dNhdp+VWUKINPx6ZX6Sls7U1PcnjZhE4bKDkMpEekvSn5/qk HGWw== X-Gm-Message-State: AOJu0YyH1yXp1oTZFkTfAjnBDWt130vFY/rDbJrwmQjNRgxYBKBHc068 g6SNLcrO333gMUHsa0rL8MbugHWybtPQSP/ooJu/4Ehqj6s= X-Received: by 2002:a0c:ea25:0:b0:67f:998b:bfbd with SMTP id t5-20020a0cea25000000b0067f998bbfbdmr12262650qvp.123.1703872467755; Fri, 29 Dec 2023 09:54:27 -0800 (PST) Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231228201510.985235-1-trondmy@kernel.org> In-Reply-To: From: Amir Goldstein Date: Fri, 29 Dec 2023 19:54:16 +0200 Message-ID: Subject: Re: [PATCH] knfsd: fix the fallback implementation of the get_name export operation To: Trond Myklebust Cc: "linux-nfs@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "viro@zeniv.linux.org.uk" , "chuck.lever@oracle.com" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 29, 2023 at 5:22=E2=80=AFPM Trond Myklebust wrote: > > On Fri, 2023-12-29 at 07:46 +0200, Amir Goldstein wrote: > > [CC: fsdevel, viro] > > > > On Thu, Dec 28, 2023 at 10:22=E2=80=AFPM wrote: > > > > > > 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. > > > > Ouch. Nasty. > > > > Looks to me like the root cause is "filesystems that violate POSIX > > requirements around uniqueness of inode numbers". > > This violation can cause any of the parent's children to wrongly > > match > > get_name() not only '.' and '..' and fail the d_inode sanity check > > after > > lookup_one(). > > > > I understand why this would be common with parent of snapshot dir, > > but the only fs that support snapshots that I know of (btrfs, > > bcachefs) > > do implement ->get_name(), so which filesystem did you encounter > > this behavior with? can it be fixed by implementing a snapshot > > aware ->get_name()? > > NFS (i.e. re-exporting NFS). > Ah. > Why do you not want a fix in the generic code? > I do not object to your fix at all. I only objected to the Fixes tag. I was just pointing out that this is not a complete solution. A decode of an NFS (re-exported) file handle could fail if get_name() iterates the parent of a snapshot root dir and finds a false match (which is not "." nor "..") before it finds the snapshot subdir name. It may be solved by nfs_get_name() which does not stop when if finds an ino match but checks further, but I don't know nfs re-export to know what else could be checked. Anyway, for this patch, without the Fixes tag, feel free to add: Acked-by: Amir Goldstein I'd prefer the use of is_dot_dotdot(), but I do not insist. Thanks and a happy new year! Amir.