Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp296838rdb; Mon, 22 Jan 2024 04:42:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9xT1vgp2hy/OOMgRvzzSf0gp3AwZ1BBCdMkQRPCMn1sJMJT6PHDTsT7QHgGlS8B53VYCN X-Received: by 2002:a05:6512:33cf:b0:50e:7e53:8f6b with SMTP id d15-20020a05651233cf00b0050e7e538f6bmr1758356lfg.127.1705927369463; Mon, 22 Jan 2024 04:42:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705927369; cv=pass; d=google.com; s=arc-20160816; b=wLgf4bOizUXezcMmN9Nytv4fE6dkIH4r4mqU9DR3Iwn18ZHUmGTRF2ST4vf9QB60eR kgKl7wAe89ZdfT+/mDKivhCAXucbtXGPHMcxNpRK+C27eJbYvUZyDIzL3CZZvc4f2F/5 P9Qcjzs5cpFu0cZQ7SKisJ1b0nPPGVSZgj94TFa6c7/8muTb7RK8IeiTtlK9QI3JeLfy OhbbSO4fJuNato3AL1cmCK6AzdbZtKBecDyFmLE2rt3LvVN1o71fsyingIQ2Y1mlVjcx SG9zTnOZ5nUF48C48SPADcfCRk0sYlS+xU3QOaW/hgQ/OGPqJF00pQYX1Ey0SeokT1uC 17tA== ARC-Message-Signature: i=2; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=AQmuqxaeIGZelSODTss8gWd4P9SrQf4vDlsO0SnTpdE=; fh=jD/G7UrdWzQUaVcsyZL0Br5qChVzoyKXvXZLpQibT6A=; b=rQ44drnfO4+Fd53WgwiCyqMeqZqWs3nb+qwNvdf2IAud2zp+0+C0E0C2ng2+40Qtod Rc+qyWjAcDLxXSRerXtsUntLpMfO4EEt6934jk6uiDroAQt3ufTZuk+OJ6S+qxVFqX+r TeB4WOGGhbx5FuFz3VDEZ0ot3SLbNZl9kbfomTlqx4Kmv59jUSyuh8aiD7TyXR9Gi+hC DM/Xt/d4N+SVnQULkw+YkcONq69p/QKoqzah77B43Inivn2wwFu8ravInMGcUimGtAzo 7eMKQ71gXjmrQsZMbEZLzBadgdksJQ5xrDQFsVsf0Zbta5SwS/NhsQEWjZXX+D7QXUO8 uT2Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H9SPVxQH; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-nfs+bounces-1231-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1231-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x101-20020a50baee000000b00553be25f7c0si11300018ede.433.2024.01.22.04.42.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 04:42:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-1231-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H9SPVxQH; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-nfs+bounces-1231-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-1231-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3A4601F22ACB for ; Mon, 22 Jan 2024 12:42:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA44D3E472; Mon, 22 Jan 2024 12:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H9SPVxQH" X-Original-To: linux-nfs@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 66A813DB84 for ; Mon, 22 Jan 2024 12:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705927156; cv=none; b=VNdGNeZd/G+lZHiepmsXGgIlj1KCH7kRfI7T7y1C8Kfg2NcToCJ73A7xEKBIGvCq4PEBpkmXDy2f+BZyJSTWUjTjAspcR+veH6vpv1ZtCbV+S28waNkO6YEXovmwr54u5GYsn+WDfBx2CYmT69D+7Kyl1AJq3ySQ8Qv0Qj73SoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705927156; c=relaxed/simple; bh=6H3U2xFlfhw33p6fngsaEo/JwWggI7/BGAeipSgCLFM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z+jfKH+7By4U/T6Z6Yjl8xsp1XyU5xje3VPZsXArckmZ4b4JOa3gY1FKsV1AXsmxvTEI83q7ZFvRXR3mQjFp3treXdFSfS3AQCQLbl6gfQRfk/z/xzwMY/EswtyQA9ZvEu1RemlubXsjTVJsOcZUGP4Nwnw28SgovO8x+xqllS0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=H9SPVxQH; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705927154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AQmuqxaeIGZelSODTss8gWd4P9SrQf4vDlsO0SnTpdE=; b=H9SPVxQHF/T8m/Xg+PL+h0/sOVy8oYrsGttidz3Hq+ydhxd/iAAaPizagU+DhHRnlhL7jc SekqssKcun8UCdkE0f49aI+qkRItTxyeFNy5tbZnZAHBA0HLrOxKh5xIWmmUzkAwC2Yv89 S8fLxaRKhTZnvioTzhz1blhnFRME3Us= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-494-LKHoZoERMie5-61Ndg59yw-1; Mon, 22 Jan 2024 07:39:11 -0500 X-MC-Unique: LKHoZoERMie5-61Ndg59yw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 958913C000A4; Mon, 22 Jan 2024 12:39:10 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id A65D8492BC6; Mon, 22 Jan 2024 12:39:08 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Marc Dionne Subject: [PATCH 07/10] afs: Hide silly-rename files from userspace Date: Mon, 22 Jan 2024 12:38:40 +0000 Message-ID: <20240122123845.3822570-8-dhowells@redhat.com> In-Reply-To: <20240122123845.3822570-1-dhowells@redhat.com> References: <20240122123845.3822570-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 There appears to be a race between silly-rename files being created/removed and various userspace tools iterating over the contents of a directory, leading to such errors as: find: './kernel/.tmp_cpio_dir/include/dt-bindings/reset/.__afs2080': No such file or directory tar: ./include/linux/greybus/.__afs3C95: File removed before we read it when building a kernel. Fix afs_readdir() so that it doesn't return .__afsXXXX silly-rename files to userspace. This doesn't stop them being looked up directly by name as we need to be able to look them up from within the kernel as part of the silly-rename algorithm. Fixes: 79ddbfa500b3 ("afs: Implement sillyrename for unlink and rename") Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/dir.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 3f73d61f7c8a..eface67ccc06 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -474,6 +474,14 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode, continue; } + /* Don't expose silly rename entries to userspace. */ + if (nlen > 6 && + dire->u.name[0] == '.' && + ctx->actor != afs_lookup_filldir && + ctx->actor != afs_lookup_one_filldir && + memcmp(dire->u.name, ".__afs", 6) == 0) + continue; + /* found the next entry */ if (!dir_emit(ctx, dire->u.name, nlen, ntohl(dire->u.vnode),