Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4684904rdb; Fri, 29 Dec 2023 09:44:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdnZlbWnJkeFqSqP+NRLcTVNx11cx64ekH+6ZiIgGWi0yImxbFl5OGHJITRhmkSzPY53kY X-Received: by 2002:a05:620a:5612:b0:781:62be:76c2 with SMTP id vu18-20020a05620a561200b0078162be76c2mr4323499qkn.61.1703871876342; Fri, 29 Dec 2023 09:44:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703871876; cv=none; d=google.com; s=arc-20160816; b=zEpUTCBaCr9x/CZUrMzQtqrX4xROLyeZCRVeLJPAHePU7g0MNaK1ycyKwlKa+ChGef wdUFkONo/BWi4NT421YO7Kkj3/6jMIAkx4QTrekdPFYEmB/MaW2jAm4ti40qa7HQr47t x2p2HN49xo5uopmJ+1xASdAw3gV1H6YLOVhsc47nyzv61q439WQLPVpyVb8bcuF0q7WA 00Oci7BmR6Atd+VSZ+K0t/ctSkh2hrxcU2eE9VwQ8nhnJrFnZT8ivNHhlS/AkI/BTnC4 NC+CqvmGTbdXnc8gnL6QErmR1m7aZaK/ULx60+4AlQtnS8KXNv0LtGuMF4SKF7YXbyrJ 94uA== 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=7p7Ge5//CaATuecPJm+siWFiqUIutH8iUGl04+JepRo=; fh=L36eFGCx726rutzuK+0IDWHS1nUOQes6+K9pOHou2/I=; b=eg2Zw3/BjPYLv/VPKvugxeAr7yPftTM3ZXnWjoMZg/gQxFlKqWoTSXH4I5O/oO2iVP oWZHd9J/KXTGlyw2XoZAHp4kO2YQfregXDdWuHiUGOVHSqcD3HCV/Y/j1lKnxNeIZ9Vg ZHsNZM6h1KCFYu6Ncz68TV0IfQQWbIz1lTgqsI6tz/6ihG/r6nR9bTckBb1yCjIJJVLH RAOih3b5XRtl9twxRml9brRhnVyVvMg+GauOv59vl55VXRKFqoAOdH/gpthk7vs44vjB KV+5qbrLXGbCJJltqc7+wkkabh7ca4UudXKDRxwe7b70TdSJThr4Kk0iuUp+dMYpAhQn AYAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mR8ns4NI; spf=pass (google.com: domain of linux-nfs+bounces-836-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-836-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. [147.75.199.223]) by mx.google.com with ESMTPS id v2-20020a05620a0f0200b007817ac018d3si3408344qkl.754.2023.12.29.09.44.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 09:44:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-836-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mR8ns4NI; spf=pass (google.com: domain of linux-nfs+bounces-836-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-836-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 0AB451C209B8 for ; Fri, 29 Dec 2023 17:44:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 799C112B7F; Fri, 29 Dec 2023 17:44:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mR8ns4NI" X-Original-To: linux-nfs@vger.kernel.org Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (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 1176012B6B; Fri, 29 Dec 2023 17:44:32 +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-f50.google.com with SMTP id 6a1803df08f44-67f8a5ed1a0so46052326d6.2; Fri, 29 Dec 2023 09:44:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703871872; x=1704476672; 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=7p7Ge5//CaATuecPJm+siWFiqUIutH8iUGl04+JepRo=; b=mR8ns4NIFzmSNWfkJ5YHYCgGjpfS/ILKkUJjg9iJ50IHkkz1aexmOTQ8d9jVXcwkcv oL4YqSz2UQ1dJ/x7c5scmJmsPR9oN8cOOUMXdEozoz235O+3ILdbN5kWXLmfFH6Ttjbp xekUhxXo0q7UaZeT/aOrCL8U6va7rvT8mlOz9zU9ej5Jwjhb5lCob4ZHeitsnf9gNml6 ElMpDcUrqwNz1eSgp+RAzcXvtWbhl662ExryfXP8zlLN/g/5rbqyLgs/2nWuD/IWiJzM gTWZ9L8Ln240dOu887NWa2lRhgVH/zHAkqIm4YyWdJnlmQIudTQsjaOOmcFNrCHBARm1 ewbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703871872; x=1704476672; 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=7p7Ge5//CaATuecPJm+siWFiqUIutH8iUGl04+JepRo=; b=r3UOcD8gEqjG9QB2n8RirX+sPmHz1hvXbdsH4zC05CKBvTIZX1mv1mvnInSrMjSf4W 8DC8I0caxDCpgLgZzV/vbvGS0fdAxGazFBBawpV275jekT7drozizs+4+CfASY0xM+Y+ 7ugqxz0XWfhpA7DSXd8IOgAEb9q79ZTlXRO2MXXScwHTSEtq4Dv+LORFZWpS03SxzdJF 7+rMUw6R+GuB0WhhTcNarXfu8q4vWzuog2ygzh4MTjDFgyjkBVcRqCxTRNJgt6Rr9DoX ed/xZszfYIvJLAJVnt5MtiJytkHoxR9pX+YUi4xldxyuacvq38OZ1vVF3NsgpoQGYgqG uajA== X-Gm-Message-State: AOJu0Yyto0/flHMBC4CazbZO+C7uKgqDyjxmbkzozAqI8zAYzXQUn14+ jLts9wx1DtgZsNGqIXu6bAoq0Vod+BjcvIusGPo= X-Received: by 2002:a05:6214:e63:b0:67e:afec:e114 with SMTP id jz3-20020a0562140e6300b0067eafece114mr14394087qvb.63.1703871871905; Fri, 29 Dec 2023 09:44:31 -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:44:20 +0200 Message-ID: Subject: Re: [PATCH] knfsd: fix the fallback implementation of the get_name export operation To: Chuck Lever Cc: trondmy@kernel.org, Linux NFS Mailing List , linux-fsdevel , Al Viro Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 29, 2023 at 4:35=E2=80=AFPM Chuck Lever wrote: > > On Fri, Dec 29, 2023 at 07:46:54AM +0200, Amir Goldstein wrote: > > [CC: fsdevel, viro] > > Thanks for picking this up, Amir, and for copying viro/fsdevel. I > was planning to repost this next week when more folks are back, but > this works too. > > Trond, if you'd like, I can handle review changes if you don't have > time to follow up. > > > > 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 filena= me > > > 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 fo= r > > > filesystems that violate POSIX requirements around uniqueness of inod= e > > > 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 afte= r > > 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()? > > > > > This patch just ensures that we skip '.' and '..' rather than allowin= g a > > > match. > > > > I agree that skipping '.' and '..' makes sense, but... > > Does skipping '.' and '..' make sense for file systems that do It makes sense because if the child's name in its parent would have been "." or ".." it would have been its own parent or its own grandparent (ELOOP situation). IOW, we can safely skip "." and "..", regardless of anything else. > indeed guarantee inode number uniqueness? Given your explanation > here, I'm wondering whether the generic get_name() function is the > right place to address the issue. > > > > > Fixes: 21d8a15ac333 ("lookup_one_len: don't accept . and ..") > > > > ...This Fixes is a bit odd to me. > > Me too, but I didn't see a more obvious choice. Maybe drop the > specific Fixes: tag in favor of just Cc: stable. > Yeh, that'd be fine. Thanks, Amir.