From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 DD20E36A035 for ; Mon, 22 Jun 2026 09:09:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119361; cv=none; b=UXprzA9mKByvR8G3QDnMGYlWgD4cBtWo6TotcwhlPKC/+6Y2sLRorRuzO4cjr0TOJav1hD/w+VJMRf+tPrKXsx5iXyGl1cTIKOsOGbauFBLPtH3eBSm1Y27VYpWEnkYsKXUXuGttJwhPjLEzcURjsCWiDiikX8SnFklM3iCdJvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119361; c=relaxed/simple; bh=Qot/PJkxpbE9FxlSLjM1IYuTW1mM4PdPtQlpfM51lxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p/UJeLdB/oSHQS7P5Ing/REKd1UlFW3hjZL4Fh8O4BAzczRgaRoi5tsRZokJFBqe2Htsj+koxubQ4ZJoPfjSaoHT3DpwkQGOIL83IiugBlroT+nWiz6uXA9Mmd/5hTf3TWcbSn4T8jac0Exm4P4Z6VuzfLmDAuMNRWrz0LxQ6tU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=GTmYxpsk; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GTmYxpsk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119358; 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=aXYfuW0iimSyufRjo4SpIMOrUHwhtivd5e9rju7+Kzw=; b=GTmYxpsknnRz0C3oqGTnga0oidou5O/31b/BzkUf7OVrzVBAthyxWW5/lPY41E9+eDzkN7 JN/vfRmNhvq8fUZsGA54ojgRjCu+o7NTYpjZ0Wg3hqXxZ3dH6x0WdY/h5Hkbpvt+H+g6VI fSDYCoimV1F6TPc5zsdL69BrTsCmq5A= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-311-FCvniTrtOaqsREI815yq3g-1; Mon, 22 Jun 2026 05:09:12 -0400 X-MC-Unique: FCvniTrtOaqsREI815yq3g-1 X-Mimecast-MFC-AGG-ID: FCvniTrtOaqsREI815yq3g_1782119350 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E79DD1955F11; Mon, 22 Jun 2026 09:09:09 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1AC593001D84; Mon, 22 Jun 2026 09:09:04 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Nan Li , stable@kernel.org, Yuan Tan , Yifan Wu , Juefei Pu , Xin Liu , Ren Wei Subject: [PATCH v4 01/21] afs: handle CB.InitCallBackState3 requests without a server record Date: Mon, 22 Jun 2026 10:08:35 +0100 Message-ID: <20260622090856.2746629-2-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" From: Nan Li The cache manager callback path now attaches the server record to an incoming call through the rxrpc peer's app data. That association is not guaranteed to exist for every callback request, and most callback handlers already tolerate that case. Make CB.InitCallBackState3 follow the same pattern by checking whether a server record was attached before using it. If the peer is not mapped to a server record, trace the request and ignore it, matching the existing behaviour for other unmatched callback requests. This keeps the callback handler consistent with the rest of the cache manager service and avoids depending on peer state that may not be available for a given request. Fixes: 40e8b52fe8c8 ("afs: Use the per-peer app data provided by rxrpc") Cc: stable@kernel.org Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Xin Liu Signed-off-by: Nan Li Signed-off-by: Ren Wei Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/cmservice.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c index 5540ae1cad59..263c60c811a5 100644 --- a/fs/afs/cmservice.c +++ b/fs/afs/cmservice.c @@ -364,6 +364,11 @@ static int afs_deliver_cb_init_call_back_state3(struct= afs_call *call) if (!afs_check_call_state(call, AFS_CALL_SV_REPLYING)) return afs_io_error(call, afs_io_error_cm_reply); =20 + if (!call->server) { + trace_afs_cm_no_server_u(call, call->request); + return 0; + } + if (memcmp(call->request, &call->server->_uuid, sizeof(call->server->_uui= d)) !=3D 0) { pr_notice("Callback UUID does not match fileserver UUID\n"); trace_afs_cm_no_server_u(call, call->request); From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 14A0136A34F for ; Mon, 22 Jun 2026 09:09:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119360; cv=none; b=peeg8Q6liusgMbO8ZbbVVvOB/kI634budWJu5dtqO0+P2e5Wm4aZ/Q/n0IVtcKh+0aye81nbN2OzNsUIWiShb7jNUzjhJGVZisEZV0jLRRLea27vETh8u0W+1MV7ExEvvWeKPF3/IW6xc8eGrXfvyHi9r/bOBBn3pGiIIyvJ6PI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119360; c=relaxed/simple; bh=5RJ6eiIgrQbHS3f0m3cyvgeCO0KVe9moitLn3vgds+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DT5LD0KUTTlseRo2u893dlSk9FOQeDyFHOryLYm1DSyYFltBWPbHdgmWAr2VPp8k+J3nbkQXdvHfMd9Jnyiq2wy7ZJRdzSf2qKKIf+YJ2IPf7r/G3fa92fkMY0P2g0+GqDTK/+ZoZmGdAOHQYwLYfCLtA3zHIG647mRDyRB7TqY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=FL/Bv6LD; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FL/Bv6LD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119358; 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=dAsVS8agY9JmTA40Ge2IgO0QMtWkhH47Q/93WbUEoqc=; b=FL/Bv6LDlYBDNUukrgWiXMkoq/neEUpLC0r1xqIbHC2FkNnl8Ukwvvl/oTJhAvH7Q2e0h8 BcU50YEmEPSwCvNVm+snkM/QWb2zD6CBfBD+odlJ2vmUIcoN2yoz6ZmWkKAF1xxTrZvl6y lqwG2uotqf22ZvnJ5uG/1wLUMEk1Dws= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-uTOzeF70PW6dkxWXRVh7Yg-1; Mon, 22 Jun 2026 05:09:15 -0400 X-MC-Unique: uTOzeF70PW6dkxWXRVh7Yg-1 X-Mimecast-MFC-AGG-ID: uTOzeF70PW6dkxWXRVh7Yg_1782119354 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 990D118002C8; Mon, 22 Jun 2026 09:09:14 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D9BB1180058F; Mon, 22 Jun 2026 09:09:11 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Dan Carpenter Subject: [PATCH v4 02/21] afs: Fix error code in afs_extract_vl_addrs() Date: Mon, 22 Jun 2026 10:08:36 +0100 Message-ID: <20260622090856.2746629-3-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" From: Dan Carpenter The error codes on these paths are only set on the first iteration through the loop. Set the correct error code on every iteration. Fixes: 0a5143f2f89c ("afs: Implement VL server rotation") Signed-off-by: Dan Carpenter Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/vl_list.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/afs/vl_list.c b/fs/afs/vl_list.c index 3e4966915ea4..003889cf0f18 100644 --- a/fs/afs/vl_list.c +++ b/fs/afs/vl_list.c @@ -92,7 +92,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(struct = afs_net *net, { struct afs_addr_list *alist; const u8 *b =3D *_b; - int ret =3D -EINVAL; + int ret; =20 alist =3D afs_alloc_addrlist(nr_addrs); if (!alist) @@ -110,6 +110,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(struc= t afs_net *net, case DNS_ADDRESS_IS_IPV4: if (end - b < 4) { _leave(" =3D -EINVAL [short inet]"); + ret =3D -EINVAL; goto error; } memcpy(x, b, 4); @@ -122,6 +123,7 @@ static struct afs_addr_list *afs_extract_vl_addrs(struc= t afs_net *net, case DNS_ADDRESS_IS_IPV6: if (end - b < 16) { _leave(" =3D -EINVAL [short inet6]"); + ret =3D -EINVAL; goto error; } memcpy(x, b, 16); From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 EFB3039B486 for ; Mon, 22 Jun 2026 09:09:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119366; cv=none; b=FGSXrdfLv0I4Z8+KQWUGaekTFv46UMCBx4I+orbyuQH3WaKnjO2dQnMVMYnSVzJE7hbpPKgRsx8AvBaTe4XHLsrT2wSydFjTsDYipHBUdmvPbLceEZhqJ6SYnz1FNijduPRyaPjKtzYflYMWTVD9SKgBkaT0uEjbKwM/mj0ae8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119366; c=relaxed/simple; bh=zD16fMf0ZMJoNAbDkUkjkvBtlSpglsJNvNSt8JU7lxs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RqXXe7k9AWpn1+W0QOun2FCJl0Hdo2IfqS/HyJhxBcmdDQ97v8kydF3EnykiHR3dE1SqILMVEwUJ/PMOdYEzzK+l6YdqItvSkbm1zgAsPaT2RzGxbIZXERHO73TOKMwJNtmuo9p6X9B71v/mWIbIsghgOoCATYJY+FnuE4nZLO0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=i3OnYuAu; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i3OnYuAu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119364; 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=FfHVYwJjeckBljNNeVdi/xVk7ybji0LvQllDM/zHzBw=; b=i3OnYuAuDbRTuyipOlmsUiXkZBirOkUe4klfSzKgkX7oOqOSd95U3yWB6foKqd1uUZdRuA 7bQu6OkHOYUXqUzZnqn95paYejS86nzBjP9+8yBDES7M6v/mzGgq7w1kmxWFcVHNdb6lkP 30Ve9+ux/uIEC9Ss/9B6Xryc+ND39Lo= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-211-C7_5JNSJNF-KAA2Gr5_g0A-1; Mon, 22 Jun 2026 05:09:20 -0400 X-MC-Unique: C7_5JNSJNF-KAA2Gr5_g0A-1 X-Mimecast-MFC-AGG-ID: C7_5JNSJNF-KAA2Gr5_g0A_1782119359 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0575819560BE; Mon, 22 Jun 2026 09:09:19 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 105F81956096; Mon, 22 Jun 2026 09:09:15 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Matvey Kovalev , stable@vger.kernel.org Subject: [PATCH v4 03/21] afs: fix NULL pointer dereference in afs_get_tree() Date: Mon, 22 Jun 2026 10:08:37 +0100 Message-ID: <20260622090856.2746629-4-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" From: Matvey Kovalev afs_alloc_sbi() uses kzalloc for memory allocation. And, if ctx->dyn_root is not null, as->cell and as->volume are null. In trace_afs_get_tree() they are dereferenced. KASAN error message: KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 2 PID: 18478 Comm: syz-executor.7 Not tainted 5.10.246-syzkaller #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 RIP: 0010:perf_trace_afs_get_tree+0x1d9/0x550 include/trace/events/afs.h:1365 Call Trace: trace_afs_get_tree include/trace/events/afs.h:1365 [inline] afs_get_tree+0x922/0x1350 fs/afs/super.c:599 vfs_get_tree+0x8e/0x300 fs/super.c:1572 do_new_mount fs/namespace.c:3011 [inline] path_mount+0x14a5/0x2220 fs/namespace.c:3341 do_mount fs/namespace.c:3354 [inline] __do_sys_mount fs/namespace.c:3562 [inline] __se_sys_mount fs/namespace.c:3539 [inline] __x64_sys_mount+0x283/0x300 fs/namespace.c:3539 do_syscall_64+0x33/0x50 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x67/0xd1 Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Fixes: 80548b03991f5 ("afs: Add more tracepoints") Cc: stable@vger.kernel.org Signed-off-by: Matvey Kovalev Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/afs/super.c b/fs/afs/super.c index 942f3e9800d7..dec091e569c4 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c @@ -587,7 +587,8 @@ static int afs_get_tree(struct fs_context *fc) } =20 fc->root =3D dget(sb->s_root); - trace_afs_get_tree(as->cell, as->volume); + if (!ctx->dyn_root) + trace_afs_get_tree(as->cell, as->volume); _leave(" =3D 0 [%p]", sb); return 0; From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 2AAB239D6F2 for ; Mon, 22 Jun 2026 09:09:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119369; cv=none; b=jHpPeAQ/r4LroTUeEZ2uyfNSVOsrZiHGnmITFV3V9GjVAyfvJz23pRUpM90PvRO4j1Gf3LV3zVQgpQ6Q/+fTyp4REsO7NOdRM/u2f32Bq29rR+S8ZkbB2p+ASCDQPLbBUxe61AE19Cmtt1NlMDmf/JinpIhTa/PndybphjYWKp8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119369; c=relaxed/simple; bh=4LZrYHCv8Z8tYJatoibL0nKnnCTtLNyEQNO8TuA4qRg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cmUEzMhZtxIpzk7l2MWB3kWiaRmiKUO+yoJydquJG6WD4qVCyaFcG6ui2aWBP/Rt4K/4NtRHSJWXxURT6i+PfGgEv/rvgBRtAMzVOiF0x6r6FANJ1r87f/TY1VOd8yrwPx+QwkD+i5DdpmxxylB6DWKJl8M6djnZbdmdAqZL/Bk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=SxduzIgr; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SxduzIgr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119367; 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=RqJX4I5D9uTmO8hOkb2ZiaXwu5L4z4jELuMPRRLbbgo=; b=SxduzIgr+8R4VWXOTZVm9CkXtgTIgeTDPLd/jtVOH1XrwtASKRe8eY0m1oCEdAF21k6+kN Wd5B+alCjI/yWI2wQTqgm95fcK3fb83ojAX3dyN3hYDCm2jl5ct3pe4ESAsUYKpp4r8sgB /b9zJ3HntL2pBdvqAroac5bHgUzC4j4= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-oTjnp6dsOb-Go14F1iAJWg-1; Mon, 22 Jun 2026 05:09:23 -0400 X-MC-Unique: oTjnp6dsOb-Go14F1iAJWg-1 X-Mimecast-MFC-AGG-ID: oTjnp6dsOb-Go14F1iAJWg_1782119362 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 71CFF1805A35; Mon, 22 Jun 2026 09:09:22 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 83D3F1956096; Mon, 22 Jun 2026 09:09:20 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/21] afs: Fix double netfs initialisation in afs_root_iget() Date: Mon, 22 Jun 2026 10:08:38 +0100 Message-ID: <20260622090856.2746629-5-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Fix afs_root_iget() to leave initialisation of the netfs_inode part of the afs_vnode to afs_inode_init_from_status(). Fixes: bc899ee1c898 ("netfs: Add a netfs inode context") Closes: https://sashiko.dev/#/patchset/20260609081738.770127-1-dhowells%40r= edhat.com Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/inode.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 3f48458694ba..a88995629d72 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -566,7 +566,6 @@ struct inode *afs_root_iget(struct super_block *sb, str= uct key *key) =20 vnode =3D AFS_FS_I(inode); vnode->cb_v_check =3D atomic_read(&as->volume->cb_v_break); - afs_set_netfs_context(vnode); =20 op =3D afs_alloc_operation(key, as->volume); if (IS_ERR(op)) { From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 8288E39EF23 for ; Mon, 22 Jun 2026 09:09:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119376; cv=none; b=q85SyyB7KkVC8WtW4rSuDo2ubqdvPj8GLbjIS2ZWRZHwWyZotdHjnTEwyoH1V+/ui+3tcBGE5rFPYb37t3gmpUP9voWT2Qz6jh4YBj2nQWIiZ5nugzCAxzza6pEyRlMitwW+RLKX9JHfRsAn8hf2HuyKJ/YyRJQPIhj1cTzYxDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119376; c=relaxed/simple; bh=iQtx8dJ1H75UyPTc9jNPVBqavNS4Gkuvx4tGLdQKHJA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YHDALbYUAOOxuI7qaaTv3ucazrd3P092zacOVn8flXbyQfYvC8g3vIaBKgY75K+lkh45NDo379LqE/ihiyE0LiWZs/oA4kybEfIDhkPm4zHpckyoD7qPjQmQy4pu3F9G/zjYepyITPmMWzpUPNKs9D46IucbcfLseyi0AV2X2UI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=EAXaAyx7; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EAXaAyx7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119373; 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=1HKD12eeMPKp0iBSty4CB/WcgM2VDHkm0pAmvTc2/RI=; b=EAXaAyx76eJ1UMhevMYz+OH6YVHbgzm2isL7It6KOyrTFco4MfgFvYecPdxfESDbchFjB6 i0jLtz7VY1mD7i1ZyslT5gOL0dnIvbgHFX9BjD+vLA6qlCtSbFrNWLHRHXJmhH8Qr+O/TU Fit1bjGN4N4joCMPK4GVJ+lUMQf3vss= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-KECnKP3sNXKR6vbDI-_RPA-1; Mon, 22 Jun 2026 05:09:27 -0400 X-MC-Unique: KECnKP3sNXKR6vbDI-_RPA-1 X-Mimecast-MFC-AGG-ID: KECnKP3sNXKR6vbDI-_RPA_1782119366 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 578ED1955E92; Mon, 22 Jun 2026 09:09:26 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 155E11956096; Mon, 22 Jun 2026 09:09:23 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Deepakkumar Karn Subject: [PATCH v4 05/21] afs: Remove setting of AS_RELEASE_ALWAYS for symlinks and mountpoints Date: Mon, 22 Jun 2026 10:08:39 +0100 Message-ID: <20260622090856.2746629-6-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Regular AFS files correctly use afs_file_aops which have release_folio set as netfs_release_folio, so AS_RELEASE_ALWAYS is valid for them when fscache is enabled (set via afs_vnode_set_cache()). Symlinks and mountpoints in AFS use afs_dir_aops, which does not provide a release_folio callback. However, afs_apply_status() unconditionally calls mapping_set_release_always() for these. In such case when memory management code attempts to release folios, filemap_release_folio() checks folio_needs_release() which returns true due to AS_RELEASE_ALWAYS being set. Since there is no release_folio callback, it falls through to try_to_free_buffers(), which at present expects buffer_heads to be not null. For symlinks and mountpoints without buffer_heads, this causes pointer dereference. [dh: Added more bits that were missed] Fixes: eae9e78951bb ("afs: Use netfslib for symlinks, allowing them to be c= ached") Signed-off-by: Deepakkumar Karn Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/inode.c | 7 +++---- fs/afs/internal.h | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index a88995629d72..54ac6ec21daf 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -52,9 +52,9 @@ static noinline void dump_vnode(struct afs_vnode *vnode, = struct afs_vnode *paren /* * Set parameters for the netfs library */ -static void afs_set_netfs_context(struct afs_vnode *vnode) +static void afs_set_netfs_context(struct afs_vnode *vnode, bool is_file) { - netfs_inode_init(&vnode->netfs, &afs_req_ops, true); + netfs_inode_init(&vnode->netfs, &afs_req_ops, is_file); } =20 /* @@ -126,7 +126,6 @@ static int afs_inode_init_from_status(struct afs_operat= ion *op, } inode->i_mapping->a_ops =3D &afs_symlink_aops; inode_nohighmem(inode); - mapping_set_release_always(inode->i_mapping); break; default: dump_vnode(vnode, op->file[0].vnode !=3D vnode ? op->file[0].vnode : NUL= L); @@ -136,7 +135,7 @@ static int afs_inode_init_from_status(struct afs_operat= ion *op, =20 i_size_write(inode, status->size); inode_set_bytes(inode, status->size); - afs_set_netfs_context(vnode); + afs_set_netfs_context(vnode, status->type =3D=3D AFS_FTYPE_FILE); =20 vnode->invalid_before =3D status->data_version; trace_afs_set_dv(vnode, status->data_version); diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 0b72a8566299..785c646856d7 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -750,8 +750,6 @@ static inline void afs_vnode_set_cache(struct afs_vnode= *vnode, { #ifdef CONFIG_AFS_FSCACHE vnode->netfs.cache =3D cookie; - if (cookie) - mapping_set_release_always(vnode->netfs.inode.i_mapping); #endif } From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 8292339EF24 for ; Mon, 22 Jun 2026 09:09:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119375; cv=none; b=pXBdEF/JckuFy8A1fJHEtwOkhOoBUO5eynP0pji4c+ecCUXMaznR22cOkeKnkw4j4icuaok8PE4j/BXFeF0RY5cJqxh9//liUD8HaQmePUbNCO9Uz/tHZk1SUjL73QJTrJsig5oabsrKvTNNPgfoQe41QOfNBy/9JPI/Puo0A9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119375; c=relaxed/simple; bh=BzAy9vOlIl1GkEbdmZ/Yvd0aG0LXsNqv7b45yxqnrto=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fw3k7pK/dCO1rDcCBY/BuK9BqQNi0raDci9I4v29A2dnBPhgj2e2Cdf2WqiXgqJnSQBmcEgE0Kqx8ECz42Hbnoc1hOoZ2P++FcJ7wyVgaqxlnB1b0i6k+0HjqobgaPwetS+jmUfTxlZxZXXk1GYxOx6oTQYURPMkJoKNgFOfFV4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=f1S5rDhO; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f1S5rDhO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119373; 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=WT83b6gXE3N1B9YG199zJ4htShGRe10XfT/ZY1w3/Wo=; b=f1S5rDhOyeEHSC0N2coNZHJ4x/jlteQYMo/6ORZe3VBoBfrUxjUmoyfxY8fUTtVnc4FrnP yCGJYHEVAURMi6WmED3YDzM8LI28/8HN20p5DhcAl6mPeedSO1JSabOQL6iE1D198wed4t rNNQyC5M/1YbS7HS9PX6mdYtTjpnOIw= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-t949-xJVPt6aZw8D_Ob5gw-1; Mon, 22 Jun 2026 05:09:32 -0400 X-MC-Unique: t949-xJVPt6aZw8D_Ob5gw-1 X-Mimecast-MFC-AGG-ID: t949-xJVPt6aZw8D_Ob5gw_1782119371 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1306C1955BCB; Mon, 22 Jun 2026 09:09:31 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 248701800480; Mon, 22 Jun 2026 09:09:27 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 06/21] afs: Fix directory inode initialisation order Date: Mon, 22 Jun 2026 10:08:40 +0100 Message-ID: <20260622090856.2746629-7-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Fix afs_inode_init_from_status() to call afs_set_netfs_context() before the switch to do file type-specific initialisation because local directory changes don't get uploaded to the server, only stored in the cache. This requires that the file size be set before, so move that up too. Without this, NETFS_ICTX_SINGLE_NO_UPLOAD as set on directories gets clobbered. Closes: https://sashiko.dev/#/patchset/20260618074903.2374756-1-dhowells%40= redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org Fixes: 6dd80936618c ("afs: Use netfslib for directories") --- fs/afs/inode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 54ac6ec21daf..51c28f148845 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -93,6 +93,10 @@ static int afs_inode_init_from_status(struct afs_operati= on *op, inode->i_gid =3D make_kgid(&init_user_ns, status->group); set_nlink(&vnode->netfs.inode, status->nlink); =20 + i_size_write(inode, status->size); + inode_set_bytes(inode, status->size); + afs_set_netfs_context(vnode, status->type =3D=3D AFS_FTYPE_FILE); + switch (status->type) { case AFS_FTYPE_FILE: inode->i_mode =3D S_IFREG | (status->mode & S_IALLUGO); @@ -133,10 +137,6 @@ static int afs_inode_init_from_status(struct afs_opera= tion *op, return afs_protocol_error(NULL, afs_eproto_file_type); } =20 - i_size_write(inode, status->size); - inode_set_bytes(inode, status->size); - afs_set_netfs_context(vnode, status->type =3D=3D AFS_FTYPE_FILE); - vnode->invalid_before =3D status->data_version; trace_afs_set_dv(vnode, status->data_version); inode_set_iversion_raw(&vnode->netfs.inode, status->data_version); From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 C697C363C64 for ; Mon, 22 Jun 2026 09:09:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119383; cv=none; b=PhTQa6rjvr/S5LOxus+eZMZBP2jB20tWc6HzOvjiZX6tlkaW0uMcwBUfkcG2BOON//GwFiMo7m550UFmbEADlRsSS94bGqneIPMlbzPRaE1Y3U/esbatMzBA4PVRhIMZBewtRKQ73g8rWkkySG0K9I1rORF1oD6t3+MP1i5G3eQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119383; c=relaxed/simple; bh=Ku+iUkufAwmtJpETezJUe09aZfxio81saVT3fFwz4ME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l1E5VTdDIdtAfOvtibh/9dcvCuYTJ+8uDog0GYqQ5wZGJ0zGM3sAl0Yh0U1C+0lsXqdE90rK4Gu/ZcZDch2DonAkLXZSLLUaM6wTjmiwkIuA5COU+EV4FRRp3x1mnzzjt6lrYAqLHlFmTS4O0I3bVZP+At279nDKpieBURzI1Ew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=T6BnOSPV; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="T6BnOSPV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119381; 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=GFX3o+6uVpWAIF9G35ytiuiiBM53y5xUy8RADSTHhfg=; b=T6BnOSPVK8XkPYo43oU6C0XmVBz+75GGpcpgdNwp2Y+UW2tvdinhkW/kPnqj+fyfjgeUQe G6OJaP+WLCfMMEO0C27ogXUN3hMoSTXMml/XKT2tTg5+tCPW7ND8lsircdZXlX1KRZqE7v z0s61Uq67o4cHpoqIGmGrl+Lp1yIRJ0= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-237-h0S8YdqIOA2lmLEB9oWR1A-1; Mon, 22 Jun 2026 05:09:37 -0400 X-MC-Unique: h0S8YdqIOA2lmLEB9oWR1A-1 X-Mimecast-MFC-AGG-ID: h0S8YdqIOA2lmLEB9oWR1A_1782119376 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3BF841800361; Mon, 22 Jun 2026 09:09:35 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AC2291956096; Mon, 22 Jun 2026 09:09:32 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Zilin Guan Subject: [PATCH v4 07/21] afs: use kvfree() to free memory allocated by kvcalloc() Date: Mon, 22 Jun 2026 10:08:41 +0100 Message-ID: <20260622090856.2746629-8-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" From: Zilin Guan op->more_files is allocated with kvcalloc() but released via afs_put_operation(), which uses kfree() internally. This mismach prevents the resource from being released properly and may lead to undefined behavior. Fix this by using kvfree() to free op->more_files to match its allocation method. Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" conce= pt") Signed-off-by: Zilin Guan Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/fs_operation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/afs/fs_operation.c b/fs/afs/fs_operation.c index c0dbbc6d3716..20801b29521d 100644 --- a/fs/afs/fs_operation.c +++ b/fs/afs/fs_operation.c @@ -348,7 +348,7 @@ int afs_put_operation(struct afs_operation *op) for (i =3D 0; i < op->nr_files - 2; i++) if (op->more_files[i].put_vnode) iput(&op->more_files[i].vnode->netfs.inode); - kfree(op->more_files); + kvfree(op->more_files); } =20 if (op->estate) { From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 7B5153A1A23 for ; Mon, 22 Jun 2026 09:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119386; cv=none; b=IkMOmJHjfbAOGsCKfH/v0/dddDgQfKInfxlnXwl5eZ2P9KyhXQy4+pShTHbKw9NLL4Bc+ukoL7huCNXsI6Wd04KUNiyYjmel1SFWt4JLj7icSSTbDNg8WHjyC2rRV/U4jGWJFslUtRKHvylCF7ZjcE/tyw6Br0xafS9sGx7PVWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119386; c=relaxed/simple; bh=qCZbMwp1OW2TXKC1sonQRFQ2DJkiYewc/7vnI2vOLJ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tNMjE63N61tW5ETOz33ZLhY1aN5FBE/oO2LGzRcQm2bKsl6a8F8Xe8FRS1xtG4QNg6THy+uuf+x8O077QsY21VjNQkbQnF0ltdOyyGcyS271VtLjQ1m6gCe1tNA97h/N3MY6l5rK+k3b/qKajVGVX48UakDpnMUQ2MyraS88lFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=irvm3yBY; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="irvm3yBY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119384; 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=TMVGSaJr9BRs+PB33hr9kQshem3jjHWSU14iYsrL8cA=; b=irvm3yBYViaim7DnE3M1dwiT7+kVSQ4WGfYz3FF4/gsVWg58sO/OojDMB3bn3fXZQXV5A0 n6uBzBQYL/3dqjJl2EbJpv5VwK6UufjyLRuhnxKn8eGm2Rki0IsbwPdyO7z+DHwbuBpPbp c0jVqLzUbtVXrOQiMq7eoISo/s39ePg= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-G4kvWLfsMy-huNcWJi4myA-1; Mon, 22 Jun 2026 05:09:41 -0400 X-MC-Unique: G4kvWLfsMy-huNcWJi4myA-1 X-Mimecast-MFC-AGG-ID: G4kvWLfsMy-huNcWJi4myA_1782119380 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 39B1A195605E; Mon, 22 Jun 2026 09:09:40 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D744A1953946; Mon, 22 Jun 2026 09:09:36 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Li RongQing , Oleg Nesterov Subject: [PATCH v4 08/21] afs: Remove erroneous seq |= 1 in volume lookup loop Date: Mon, 22 Jun 2026 10:08:42 +0100 Message-ID: <20260622090856.2746629-9-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" From: Li RongQing The `seq |=3D 1` operation in the volume lookup loop is incorrect because: seq is already incremented at start, making it odd in next iteration which triggers lock, but The `|=3D 1` operation causes seq to be even and unintended lockless operation Remove this erroneous operation to maintain proper lock sequencing. Fixes: 32222f09782f ("afs: Apply server breaks to mmap'd files in the call = processor") Signed-off-by: Li RongQing Signed-off-by: David Howells Reviewed-by: Oleg Nesterov cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/callback.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/afs/callback.c b/fs/afs/callback.c index 894d2bad6b6c..833ac3178ddc 100644 --- a/fs/afs/callback.c +++ b/fs/afs/callback.c @@ -140,7 +140,6 @@ static struct afs_volume *afs_lookup_volume_rcu(struct = afs_cell *cell, break; if (!need_seqretry(&cell->volume_lock, seq)) break; - seq |=3D 1; /* Want a lock next time */ } =20 done_seqretry(&cell->volume_lock, seq); From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 9C21C3A1A23 for ; Mon, 22 Jun 2026 09:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119393; cv=none; b=gNfriBqu1z4ky9rR6aO6LYqNtfFJRbFmG+AxUBIGygMDVwxH+29pFOIj/LHHvyrIUrjoDPldn8XAG5uzfphFpBmECpkZhdKA+iODg4richOqvJQJn+hDPdcLfvqIfN8z6zIXiU8+ZIYBvEvRhvNstm7B/otWUQ6bluiaXmZ7nSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119393; c=relaxed/simple; bh=5yGL3PEJFf2X6TSkKCo77ZK11ii9FSksKLLHtbLPJIk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mGngT6ntWSRy6IKggW1a4S0ztypxyRyJ2pwYc7v1gv43s13cNB7kxh/gEP+4CZkv26szHI524HgC16j4fIMtC6tpaaPBCuX8BKh2AYJbE6Z8N/hgmEapawjblirDpqyEEdxMq7LXmBNZ7hwP/j26yoBYw5xKmQoSGQ4KALxduek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=M9BjytBB; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M9BjytBB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119391; 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=jIqFmNE1LEqFQYtf7qHKkz6E/HgqKNnGDlkW0ueT7Q0=; b=M9BjytBBt8JMENTeuGFff+TimwuWdhT93ZD6UXMJGV062DHqdF6mzwDNUV0uC0lssRi+u/ q4MsqPRnEhDFG9tkMowCkgOtwuLq9NZLflu+JtZpoz76+DjLejV0neOO3N4IwrQOGJqgYT uVnddEmbpTLW3MgvyMB0xSoiLV1X2K8= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-35-gWd3FKJZPxinpKX-Xh8xtA-1; Mon, 22 Jun 2026 05:09:45 -0400 X-MC-Unique: gWd3FKJZPxinpKX-Xh8xtA-1 X-Mimecast-MFC-AGG-ID: gWd3FKJZPxinpKX-Xh8xtA_1782119384 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0964A1955F01; Mon, 22 Jun 2026 09:09:44 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E183F18005AE; Mon, 22 Jun 2026 09:09:41 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Yuto Ohnuki Subject: [PATCH v4 09/21] afs: check for duplicate servers in VL server list Date: Mon, 22 Jun 2026 10:08:43 +0100 Message-ID: <20260622090856.2746629-10-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" From: Yuto Ohnuki The DNS response may contain the same server more than once. Check for duplicates by name and port before inserting into the list to avoid duplicate entries. Addresses the TODO comment in afs_extract_vlserver_list(). Signed-off-by: Yuto Ohnuki Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/vl_list.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/afs/vl_list.c b/fs/afs/vl_list.c index 003889cf0f18..8e1cf6cdcf71 100644 --- a/fs/afs/vl_list.c +++ b/fs/afs/vl_list.c @@ -289,8 +289,20 @@ struct afs_vlserver_list *afs_extract_vlserver_list(st= ruct afs_cell *cell, afs_put_addrlist(old, afs_alist_trace_put_vlserver_old); } =20 + /* Check for duplicates in the server list */ + for (j =3D 0; j < vllist->nr_servers; j++) { + struct afs_vlserver *s =3D vllist->servers[j].server; =20 - /* TODO: Might want to check for duplicates */ + if (s->name_len =3D=3D server->name_len && + s->port =3D=3D server->port && + strncasecmp(s->name, server->name, server->name_len) =3D=3D 0) { + afs_put_vlserver(cell->net, server); + server =3D NULL; + break; + } + } + if (!server) + continue; =20 /* Insertion-sort by priority and weight */ for (j =3D 0; j < vllist->nr_servers; j++) { From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 C1F5C36BCC0 for ; Mon, 22 Jun 2026 09:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119394; cv=none; b=tyhvDGtS1of530yemDHaLCauI1RV4f3IOYwS+gLs/JAGzYIZ9D34aBNG9rtrhrWvHV7Zxobn/xJ9SyM8I8kfICjHVz/iy978f23ozuwsTUDg3TPAsJuLkbzmFHyNuWnlVMu3v4mDep/xYt5R9j3KKnbjby0AlSbP7aFtVnEdjlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119394; c=relaxed/simple; bh=eeLCwMM/on2XWB2MsCivkQkkL7LpErxuT6jfJeZc4l0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jxnJc48mY9JD6qRnCCe+jp44V3JeJHVJnjYiVIYhDw3ctuxIdZAt8ldxUmGEr04zxA/j9FlqVJh+Moz24ABe6XZgRe6hCrTVEQTfGR4y+MdEeEhRCX5CAu+Nwv3e/1t2i73x5ziIDNVZjmlOmRhqk0VHOa2fCEC1C1AJsbZh/g8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=blV+rSzi; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="blV+rSzi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119392; 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=Hh/qa1hXxOSb0BuMIMtmXpp20WZ4x3jnxiyageTsNFQ=; b=blV+rSzi9X+jvoMzjGwjWeyGD/GIwAGaQGdP5QGmr270AD4uhxxq7ZgHPrAG9OdCkfVr9G 1HyH3O9Cgx8a0IReM4mD9Cy130ei5ifF1x6Fcau3C2CpnkHdS7D93SrjfSGeAcW4GV57GW csLjEgECw4PiuvthsYRVzShGrJp6XKQ= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-Y3ugc210NwmwNPvDIsYhzA-1; Mon, 22 Jun 2026 05:09:49 -0400 X-MC-Unique: Y3ugc210NwmwNPvDIsYhzA-1 X-Mimecast-MFC-AGG-ID: Y3ugc210NwmwNPvDIsYhzA_1782119387 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C170C1954B2B; Mon, 22 Jun 2026 09:09:47 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A3E8C3001D84; Mon, 22 Jun 2026 09:09:45 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Amir Goldstein Subject: [PATCH v4 10/21] afs: Fix bulk lookup malfunction due to change in dir_emit() API Date: Mon, 22 Jun 2026 10:08:44 +0100 Message-ID: <20260622090856.2746629-11-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" afs_do_lookup() and afs_do_lookup_one() use the same directory parsing code as afs_readdir() and were supplying alternative dir_context actors to retrieve dirents, but because lookup needs the vnode's uniquifier as part of the reference, but not the DT flags, the uniquifier was being passed in the dt flags argument to the lookup actors. Unfortunately, commit c644bce62b9c, added to fix overlayfs with fuse, broke this by masking off part of the uniquifier. This doesn't matter enough to be directly noticeable, instead causing bulk advance inode lookups to fail (which are retried later) and may cause dir revalidation to malfunction if the uniquifier is changed by masking. Fix this by making the afs directory parsing code take special ->actor values of AFS_LOOKUP or AFS_LOOKUP_ONE instead that tell it to call afs_lookup_filldir() or afs_lookup_one_filldir() directly rather than going through dir_emit(). dir_emit() is still used for readdir. Fixes: c644bce62b9c ("readdir: require opt-in for d_type flags") Reported-by: Marc Dionne Signed-off-by: David Howells cc: Amir Goldstein cc: linux-afs@lists.infradead.org --- fs/afs/dir.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 498b99ccdf0e..6df56fe9163f 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -28,9 +28,11 @@ static int afs_d_revalidate(struct inode *dir, const str= uct qstr *name, static int afs_d_delete(const struct dentry *dentry); static void afs_d_iput(struct dentry *dentry, struct inode *inode); static bool afs_lookup_one_filldir(struct dir_context *ctx, const char *na= me, int nlen, - loff_t fpos, u64 ino, unsigned dtype); + u64 ino, u32 uniquifier); +#define AFS_LOOKUP_ONE ((filldir_t)0x123UL) static bool afs_lookup_filldir(struct dir_context *ctx, const char *name, = int nlen, - loff_t fpos, u64 ino, unsigned dtype); + u64 ino, u32 uniquifier); +#define AFS_LOOKUP ((filldir_t)0x137UL) static int afs_create(struct mnt_idmap *idmap, struct inode *dir, struct dentry *dentry, umode_t mode, bool excl); static struct dentry *afs_mkdir(struct mnt_idmap *idmap, struct inode *dir, @@ -421,11 +423,18 @@ static int afs_dir_iterate_block(struct afs_vnode *dv= node, } =20 /* found the next entry */ - if (!dir_emit(ctx, dire->u.name, nlen, - ntohl(dire->u.vnode), - (ctx->actor =3D=3D afs_lookup_filldir || - ctx->actor =3D=3D afs_lookup_one_filldir)? - ntohl(dire->u.unique) : DT_UNKNOWN)) { + if (ctx->actor =3D=3D AFS_LOOKUP) { + if (!afs_lookup_filldir(ctx, dire->u.name, nlen, + ntohl(dire->u.vnode), + ntohl(dire->u.unique))) + return 0; + } else if (ctx->actor =3D=3D AFS_LOOKUP_ONE) { + if (!afs_lookup_one_filldir(ctx, dire->u.name, nlen, + ntohl(dire->u.vnode), + ntohl(dire->u.unique))) + return 0; + } else if (!dir_emit(ctx, dire->u.name, nlen, + ntohl(dire->u.vnode), DT_UNKNOWN)) { _leave(" =3D 0 [full]"); return 0; } @@ -545,6 +554,7 @@ static int afs_readdir(struct file *file, struct dir_co= ntext *ctx) { afs_dataversion_t dir_version; =20 + ctx->dt_flags_mask =3D UINT_MAX; return afs_dir_iterate(file_inode(file), ctx, file, &dir_version); } =20 @@ -554,14 +564,14 @@ static int afs_readdir(struct file *file, struct dir_= context *ctx) * uniquifier through dtype */ static bool afs_lookup_one_filldir(struct dir_context *ctx, const char *na= me, - int nlen, loff_t fpos, u64 ino, unsigned dtype) + int nlen, u64 ino, u32 uniquifier) { struct afs_lookup_one_cookie *cookie =3D container_of(ctx, struct afs_lookup_one_cookie, ctx); =20 _enter("{%s,%u},%s,%u,,%llu,%u", cookie->name.name, cookie->name.len, name, nlen, - (unsigned long long) ino, dtype); + (unsigned long long) ino, uniquifier); =20 /* insanity checks first */ BUILD_BUG_ON(sizeof(union afs_xdr_dir_block) !=3D 2048); @@ -574,7 +584,7 @@ static bool afs_lookup_one_filldir(struct dir_context *= ctx, const char *name, } =20 cookie->fid.vnode =3D ino; - cookie->fid.unique =3D dtype; + cookie->fid.unique =3D uniquifier; cookie->found =3D 1; =20 _leave(" =3D false [found]"); @@ -591,7 +601,7 @@ static int afs_do_lookup_one(struct inode *dir, const s= truct qstr *name, { struct afs_super_info *as =3D dir->i_sb->s_fs_info; struct afs_lookup_one_cookie cookie =3D { - .ctx.actor =3D afs_lookup_one_filldir, + .ctx.actor =3D AFS_LOOKUP_ONE, .name =3D *name, .fid.vid =3D as->volume->vid }; @@ -622,14 +632,14 @@ static int afs_do_lookup_one(struct inode *dir, const= struct qstr *name, * uniquifier through dtype */ static bool afs_lookup_filldir(struct dir_context *ctx, const char *name, - int nlen, loff_t fpos, u64 ino, unsigned dtype) + int nlen, u64 ino, u32 uniquifier) { struct afs_lookup_cookie *cookie =3D container_of(ctx, struct afs_lookup_cookie, ctx); =20 _enter("{%s,%u},%s,%u,,%llu,%u", cookie->name.name, cookie->name.len, name, nlen, - (unsigned long long) ino, dtype); + (unsigned long long) ino, uniquifier); =20 /* insanity checks first */ BUILD_BUG_ON(sizeof(union afs_xdr_dir_block) !=3D 2048); @@ -637,7 +647,7 @@ static bool afs_lookup_filldir(struct dir_context *ctx,= const char *name, =20 if (cookie->nr_fids < 50) { cookie->fids[cookie->nr_fids].vnode =3D ino; - cookie->fids[cookie->nr_fids].unique =3D dtype; + cookie->fids[cookie->nr_fids].unique =3D uniquifier; cookie->nr_fids++; } =20 @@ -778,7 +788,7 @@ static struct inode *afs_do_lookup(struct inode *dir, s= truct dentry *dentry) =20 for (i =3D 0; i < ARRAY_SIZE(cookie->fids); i++) cookie->fids[i].vid =3D dvnode->fid.vid; - cookie->ctx.actor =3D afs_lookup_filldir; + cookie->ctx.actor =3D AFS_LOOKUP; cookie->name =3D dentry->d_name; cookie->nr_fids =3D 2; /* slot 1 is saved for the fid we actually want * and slot 0 for the directory */ From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 19DAF3624C2 for ; Mon, 22 Jun 2026 09:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119400; cv=none; b=pM85/omoyADMMmnPdY3nt8+k1CsanvOxNBr+i2enrQQdwWTxHfsJEDgnIuFvQ5hhSiNbpE1cI+n+M4loN/LjVHds+lB2UcTSjIGEjSwIt9Y1O31MezfYGka0hhhKBbCIK4RPR+WHaxm8QyI3A7nf0w/Rn9wRVHDhrE+YJOWO8hs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119400; c=relaxed/simple; bh=/fsjfjNKtSfO4Vam4ufvsdasBcCg/2mdCnyqyUq+WvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tVz2NaN1niKM9H2h/Oe9E+FQLwGtil08Ieopiw2WhZGuaa2FA1yZjqAQiuEbhwF5S+2NyIvNp+LS+GDkqzJQB0am+6U4vad+hutbcHDPGb1xZH87clGkEdp3Pwa8mGzYMUgTmmFjm4zNn2cwzdoBl/yrnq6fFb+sPuMSBjT+byk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=NG5vLaDY; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NG5vLaDY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119398; 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=CxsEpgmRoMeDmx5HmC7wIc5r2HzgDTOugg9rSTYQcLY=; b=NG5vLaDYP6UjwRCnEoSyi5wB7pJsjcq2q4IhNtkMFjMegSlqj6Lvqol88lErgmmxhPInqu k71pQ31Wk2cJSins+7ttVGsdaIBExIcQEj+8ZZx5wxjJOi/hy1H0I9F3HJuGlnbI2g/seW l6GHCm/vPrCxkUi554LnoSJxMaYQeAs= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-9-8VuJoh2qOW6q0hKhG62iDQ-1; Mon, 22 Jun 2026 05:09:53 -0400 X-MC-Unique: 8VuJoh2qOW6q0hKhG62iDQ-1 X-Mimecast-MFC-AGG-ID: 8VuJoh2qOW6q0hKhG62iDQ_1782119392 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 309D718001E6; Mon, 22 Jun 2026 09:09:52 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 691EF3001D84; Mon, 22 Jun 2026 09:09:49 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Hillf Danton Subject: [PATCH v4 11/21] afs: Fix misplaced inc of net->cells_outstanding Date: Mon, 22 Jun 2026 10:08:45 +0100 Message-ID: <20260622090856.2746629-12-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Fix net->cells_outstanding being incremented before the check for failure of idr_alloc_cyclic(), leaving the count incremented on error. Fixes: 88c853c3f5c0 ("afs: Fix cell refcounting by splitting the usage coun= ter") Reported-by: Hillf Danton Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/cell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/afs/cell.c b/fs/afs/cell.c index 9738684dbdd2..e0fab1609f27 100644 --- a/fs/afs/cell.c +++ b/fs/afs/cell.c @@ -205,11 +205,11 @@ static struct afs_cell *afs_alloc_cell(struct afs_net= *net, cell->dns_source =3D vllist->source; cell->dns_status =3D vllist->status; smp_store_release(&cell->dns_lookup_count, 1); /* vs source/status */ - atomic_inc(&net->cells_outstanding); ret =3D idr_alloc_cyclic(&net->cells_dyn_ino, cell, 2, INT_MAX / 2, GFP_KERNEL); if (ret < 0) goto error; + atomic_inc(&net->cells_outstanding); cell->dynroot_ino =3D ret; cell->debug_id =3D atomic_inc_return(&cell_debug_id); From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 DB8023A48CE for ; Mon, 22 Jun 2026 09:10:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119403; cv=none; b=qksMz79gqagjtlajtZx5lHJvMiowyjo+SO7OcYne1R+IODHYvOuej9HLFO5dwwx3fsrhBtWBC2jXy7SuDtojRF9fXw+JwUi9LAZntRSA35qFl2tpPTJWKGCjMhPmKKNcSEgQwuRkmpyBRZCppDfW86ewJ+MtUz691mQZZHDDYJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119403; c=relaxed/simple; bh=GMV1hdmoLC3L6lmOCH7vr6X6rbMxY/dM9l3QrU8iWh0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=acb7NCjj53s4QXDK9xPs8t560+oU5wVUeUzeYJyfJ+sd9CE7HVDJ8Y7t5h8xoP4VfoA6UeftIrOqBuwbvaaZIotSng54BhfHuNr9qGdwfTlgp087xBA0a3OsRA4R8xYiCKbsxgZwgUYJhZLTZviCeVuHyyivC1y6C0Nd1o7DNBY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=KFUUZYUi; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KFUUZYUi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119401; 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=1d+piwZQ3ibpiXXf29Tyf3HGnNohEDRji+q7FdFyYRo=; b=KFUUZYUiPjQ8xHqZfXhp/3VxEgDPYTkZjX0GwOzFo+lVF6+v9Ez/3zRS/Z+iqx68g6fuwr J3LaEpiwrg9EDDGpT7897cGSMPiQOnOxzTnEAbXhw3WW6Ae8zlnM42xsnn8xIA8KXggGno Mc+vvcubVpDDW5l6kcrBfE0hMCzokSY= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-161-eZLEspJiNPmK1P7QDpDPYw-1; Mon, 22 Jun 2026 05:09:57 -0400 X-MC-Unique: eZLEspJiNPmK1P7QDpDPYw-1 X-Mimecast-MFC-AGG-ID: eZLEspJiNPmK1P7QDpDPYw_1782119396 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EC5231955E8F; Mon, 22 Jun 2026 09:09:55 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B60621953946; Mon, 22 Jun 2026 09:09:53 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner Subject: [PATCH v4 12/21] afs: Fix reinitialisation of the inode, in particular ->lock_work Date: Mon, 22 Jun 2026 10:08:46 +0100 Message-ID: <20260622090856.2746629-13-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" It seems that initalising afs_vnode::lock_work a single time in the slab's init function isn't sufficient for work_structs. This results in the DEBUG_OBJECTS debugging stuff producing a warning occasionally when running the generic/131 xfstest: ODEBUG: activate not available (active state 0) object: 0000000016d8760f o= bject type: work_struct hint: afs_lock_work+0x0/0x220 WARNING: lib/debugobjects.c:629 at debug_print_object+0x4b/0x90, CPU#3: lo= cktest/7695 ... CPU: 3 UID: 0 PID: 7695 Comm: locktest Tainted: G S 7.1.0= -build3+ #2771 PREEMPT ... RIP: 0010:debug_print_object+0x65/0x90 ... Call Trace: ? __pfx_afs_lock_work+0x10/0x10 debug_object_activate+0x122/0x170 insert_work+0x25/0x60 __queue_work+0x2e0/0x340 queue_delayed_work_on+0x48/0x70 afs_fl_release_private+0x57/0x70 locks_release_private+0x5c/0xa0 locks_free_lock+0xe/0x20 posix_lock_inode+0x55f/0x5b0 locks_lock_inode_wait+0x81/0x140 ? file_write_and_wait_range+0x50/0x70 afs_lock+0xcd/0x110 fcntl_setlk+0x10d/0x260 do_fcntl+0x24e/0x5b0 __do_sys_fcntl+0x6a/0x90 do_syscall_64+0x11e/0x310 entry_SYSCALL_64_after_hwframe+0x71/0x79 Fix this by reinitialising ->lock_work after allocating an inode. Also, flush ->lock_work when the inode is being evicted to make sure it's not still running. Fixes: e8d6c554126b ("AFS: implement file locking") Signed-off-by: David Howells cc: Marc Dionne cc: Thomas Gleixner cc: linux-afs@lists.infradead.org --- fs/afs/inode.c | 1 + fs/afs/super.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 51c28f148845..14f39a9bea6c 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -680,6 +680,7 @@ void afs_evict_inode(struct inode *inode) inode->i_mapping->a_ops->writepages(inode->i_mapping, &wbc); } =20 + flush_delayed_work(&vnode->lock_work); netfs_wait_for_outstanding_io(inode); truncate_inode_pages_final(&inode->i_data); netfs_free_folioq_buffer(vnode->directory); diff --git a/fs/afs/super.c b/fs/afs/super.c index dec091e569c4..82bb713825a0 100644 --- a/fs/afs/super.c +++ b/fs/afs/super.c @@ -660,7 +660,6 @@ static void afs_i_init_once(void *_vnode) INIT_LIST_HEAD(&vnode->wb_keys); INIT_LIST_HEAD(&vnode->pending_locks); INIT_LIST_HEAD(&vnode->granted_locks); - INIT_DELAYED_WORK(&vnode->lock_work, afs_lock_work); INIT_LIST_HEAD(&vnode->cb_mmap_link); seqlock_init(&vnode->cb_lock); } @@ -694,6 +693,7 @@ static struct inode *afs_alloc_inode(struct super_block= *sb) =20 init_rwsem(&vnode->rmdir_lock); INIT_WORK(&vnode->cb_work, afs_invalidate_mmap_work); + INIT_DELAYED_WORK(&vnode->lock_work, afs_lock_work); =20 _leave(" =3D %p", &vnode->netfs.inode); return &vnode->netfs.inode; From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 067A2369985 for ; Mon, 22 Jun 2026 09:10:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119408; cv=none; b=Q/Tcg1a/Nlxxe3crYAJ8Vwr66u8OTUIg4skx65tzwW8gTKVaFO21T6bXLWexJjwyxEJB1WR+dZCCD9qFD3/JJ6zwYXDWzfvAlMppq3+obXca7He9t0eED08dQuwZ1ctIEV443tdappcTeZ2b23vci6+nVCQl5VDRHqq2T+R9M9g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119408; c=relaxed/simple; bh=7HWvW1/Gzg8CtTGgN9Xrd5C+91FhwGE8Ckgq3W/SNmc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WFLiIrnPwz5RgQoIgLmLiDHMhUDePciO5ZA5dFvFVRF/B9eNtJR9IUU947SDXJX6U/hfZY4bnVBGJiU87eOwheLWy6wSnoo0f84zPthqhavErbvGQUzJ97DLzpABewgG+47XI3XlaAfP6awsH4OY3BhYQ2fHDERukdbe30rjxU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=Z6B/Cic3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z6B/Cic3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119406; 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=WpWGh2RkvMERtuFWMD+GKvljNRdbEH4YvY5+n+DOWRw=; b=Z6B/Cic3CvEKZW+kieBoaA8EoNhWV/JPFdUBRkri6OdeG39myV/qEmC2X2hva56bagFSCA FPPLUbaW/pOId43/XsEhVXF5EtJ9Z4IZqEiL0gYN4C68DCjjLYdoqpIa1G99LTB4Lkb7Vt 2wAAzjiJ7NeBWDvDvz585bkWJvIaRUw= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-AdCmCHSnP-SToZQCFLrh_w-1; Mon, 22 Jun 2026 05:10:00 -0400 X-MC-Unique: AdCmCHSnP-SToZQCFLrh_w-1 X-Mimecast-MFC-AGG-ID: AdCmCHSnP-SToZQCFLrh_w_1782119399 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8A8991955F01; Mon, 22 Jun 2026 09:09:59 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7845A3691E; Mon, 22 Jun 2026 09:09:57 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 13/21] afs: Fix callback service message parsers to pass through -EAGAIN Date: Mon, 22 Jun 2026 10:08:47 +0100 Message-ID: <20260622090856.2746629-14-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Content-Type: text/plain; charset="utf-8" The AFS filesystem client uses an rxrpc server to listen for callback notifications. Each callback call type handler has a delivery function that parses the incoming request stream, and this should return -EAGAIN the last packet hasn't yet been seen, but all currently queued received data is consumed. afs_extract_data() does this, but the -EAGAIN return is switched to 0 inadvertantly Fix callback service message parsers to pass through -EAGAIN Fixes: d001648ec7cf ("rxrpc: Don't expose skbs to in-kernel users [ver #2]") Closes: https://sashiko.dev/#/patchset/20260609081738.770127-1-dhowells%40r= edhat.com Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/cmservice.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c index 263c60c811a5..db394f101fc6 100644 --- a/fs/afs/cmservice.c +++ b/fs/afs/cmservice.c @@ -334,7 +334,6 @@ static int afs_deliver_cb_init_call_back_state3(struct = afs_call *call) ret =3D afs_extract_data(call, false); switch (ret) { case 0: break; - case -EAGAIN: return 0; default: return ret; } =20 @@ -456,7 +455,6 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *c= all) ret =3D afs_extract_data(call, false); switch (ret) { case 0: break; - case -EAGAIN: return 0; default: return ret; } From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 3218A36AB54 for ; Mon, 22 Jun 2026 09:10:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119410; cv=none; b=jI8FRwrJx7XgnacmKUepyvAo9lsRyJT7I5ljHhuc2xLeOJnx8kJFgEhMjAt+WspAXdA53uTMDMzkQ1dvCGb60bYJnSBMrzkeCyy0TTY5EyjQv6OT8tdkiO1z/c1ervcTgHsAmAYwl9+x+WiBnyVeRCv2tgJvYK679EX0tMUjEy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119410; c=relaxed/simple; bh=CDRo5Sn8GoMnntxTGICc+VdYzjPZ8p+5fD2/m8ruIlM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kdb9kI6wrZCXDAo5eCSr8hPQS/CBo6+PdMz24RW7AgVUU7E+rnqbaIaJ4qVidRdZ6oqOJeLw96B2NHmEr21zae9kO925OtgcuQufT35+Gps4wCIvajoZ1HJ3JU6cIsD16gH+vU5fBB8VZRY6e2gdXp8wSteGzremKHFKT1p0L30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=g9EtiBbo; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="g9EtiBbo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119408; 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=UtGq+8xrlndkaebP7J0Gra2CXKff3gN3lEQhe92RAnc=; b=g9EtiBbod0KfNlxejvAhSpU4147N5wPXQUEb5vYVEVfHlTE72smC6RvADmT0lC14o3eChE yagNyyJSsdSDOitOo3awz/oQjeopQwjolq86+DYyW+0HRPG64dHZJ5CMvuFmBE50CMZSab u6BVnQP5MJW9rRN9IWD7Gsr23f3vncg= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-685-LZ1lA8lsOSG7qEJ1amyfqQ-1; Mon, 22 Jun 2026 05:10:05 -0400 X-MC-Unique: LZ1lA8lsOSG7qEJ1amyfqQ-1 X-Mimecast-MFC-AGG-ID: LZ1lA8lsOSG7qEJ1amyfqQ_1782119404 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E9F411801BE8; Mon, 22 Jun 2026 09:10:03 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 33FF11800347; Mon, 22 Jun 2026 09:10:00 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Oleg Nesterov , Li RongQing Subject: [PATCH v4 14/21] afs: Use scoped_seqlock_read() rather than manually doing seqlock stuff Date: Mon, 22 Jun 2026 10:08:48 +0100 Message-ID: <20260622090856.2746629-15-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" This is an addendum to the patch to remove the erroneous seq |=3D 1 in volu= me lookup loop. Switch to using scoped_seqlock_read() as suggested by Oleg Nesterov[1]. Signed-off-by: David Howells Reviewed-by: Oleg Nesterov cc: Marc Dionne cc: Li RongQing cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/aifaeKvz3KemfzaS@redhat.com/ [1] --- fs/afs/callback.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/fs/afs/callback.c b/fs/afs/callback.c index 833ac3178ddc..dd7a407ea368 100644 --- a/fs/afs/callback.c +++ b/fs/afs/callback.c @@ -113,16 +113,12 @@ static struct afs_volume *afs_lookup_volume_rcu(struc= t afs_cell *cell, { struct afs_volume *volume =3D NULL; struct rb_node *p; - int seq =3D 1; =20 - for (;;) { + scoped_seqlock_read(&cell->volume_lock, ss_lock) { /* Unfortunately, rbtree walking doesn't give reliable results * under just the RCU read lock, so we have to check for * changes. */ - seq++; /* 2 on the 1st/lockless path, otherwise odd */ - read_seqbegin_or_lock(&cell->volume_lock, &seq); - p =3D rcu_dereference_raw(cell->volumes.rb_node); while (p) { volume =3D rb_entry(p, struct afs_volume, cell_node); @@ -138,11 +134,8 @@ static struct afs_volume *afs_lookup_volume_rcu(struct= afs_cell *cell, =20 if (volume && afs_try_get_volume(volume, afs_volume_trace_get_callback)) break; - if (!need_seqretry(&cell->volume_lock, seq)) - break; } =20 - done_seqretry(&cell->volume_lock, seq); return volume; } From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 6CD8E36AB54 for ; Mon, 22 Jun 2026 09:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119414; cv=none; b=se4bawtH2QkWIVnNqvGVTrKvSNCSTEvEQKfrR/muFfh+9gIDhAH6vQ0ecYHXEbSZdNd7rWhmb20BPy3p1Lwjv7P20bhxuGrbmv1J+UjI+9KL/ZnCO90VD7VnE3eAUPb7Ld6NadsBVgFfvtoFeuXA8sY5eykxeO7Ueqxua9kvnbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119414; c=relaxed/simple; bh=emZ0QDE8xtwAHSOOHBkl2wF5xEV74Ei+8u0Wic4KOzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pUPr2IjHLBb2+2HO6aNvduUDyubACtzGriS1lXBCueY+b/TRqcPu8VG+rA+OEDpfOFhu7YvhBb6GCdUUKBVrjVaxelQvK2PLZH8nHi6XtOk8/+GI2NUX8Hy9e3lVsubzwwflO2vUgc6TzHtU8ue/AVm2KCq73cK8etP6lGF4n3g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=elIvyp7D; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="elIvyp7D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119412; 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=OHyOfb8VJSFVtmkEeEvssOoq5TzHE5avjjCbE1NwPK8=; b=elIvyp7DVdgo3c8GrQrSVflOLdQH45BJU5oZ8m1FQ8bjfktj+LzVvLXDVcYsOv2VdJxCMf 2cIJHlz6pJpFfhzu6OopIpcbWP5ryLNsG5+/awo5FE2MzILZtdaC+upGB0lLltNIQcImO/ 69eQnjIxtSwfy3CRQoGuJJzX24190+8= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-tGA2uRdYO6a6t1E04Ch3Ug-1; Mon, 22 Jun 2026 05:10:08 -0400 X-MC-Unique: tGA2uRdYO6a6t1E04Ch3Ug-1 X-Mimecast-MFC-AGG-ID: tGA2uRdYO6a6t1E04Ch3Ug_1782119407 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7F65A1955F2B; Mon, 22 Jun 2026 09:10:07 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 90B073001D84; Mon, 22 Jun 2026 09:10:05 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 15/21] afs: Fix missing NULL pointer check in afs_break_some_callbacks() Date: Mon, 22 Jun 2026 10:08:49 +0100 Message-ID: <20260622090856.2746629-16-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Fix afs_break_some_callbacks() to check to see if afs_lookup_volume_rcu() returned NULL (e.g. the specified volume is unknown). Fixes: 8230fd8217b7 ("afs: Make callback processing more efficient.") Closes: https://sashiko.dev/#/patchset/20260609081738.770127-1-dhowells%40r= edhat.com Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/callback.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/afs/callback.c b/fs/afs/callback.c index dd7a407ea368..74853e0d0435 100644 --- a/fs/afs/callback.c +++ b/fs/afs/callback.c @@ -213,7 +213,11 @@ static void afs_break_some_callbacks(struct afs_server= *server, =20 rcu_read_lock(); volume =3D afs_lookup_volume_rcu(server->cell, vid); - if (cbb->fid.vnode =3D=3D 0 && cbb->fid.unique =3D=3D 0) { + if (!volume) { + /* Ignore breaks on unknown volumes. */ + rcu_read_unlock(); + *_count =3D 0; + } else if (cbb->fid.vnode =3D=3D 0 && cbb->fid.unique =3D=3D 0) { afs_break_volume_callback(server, volume); *_count -=3D 1; if (*_count) From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 9431D3976A9 for ; Mon, 22 Jun 2026 09:10:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119417; cv=none; b=nJA0sRp4mrujiA5FTHRPIHFQUMJDIAosJttWdu4xyrEn3P9J0F71EfVW3qle6n3HNi3b6/VNDj5kXepLzuKP009DytH2i08GHV1dWx7zH6YbLfrtxC8C+aw72bIkW00x9FsrgX/EbtFLyKMfSm3uFHOkJfiEoxH6msFzzFxpW4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119417; c=relaxed/simple; bh=4Fuay67XwiOklTEly0gEQjwYrrWebeys8qbnLlZTUXo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WssEJW0zmYliX/5X+g4tmJzeAyIDseLnOOKmMvLx40SkqARryglZWXnoqpXF/uSEESpKNsRHlPN4WXbnkFBUP0TOKoLLfYNOBWexdk9ZGj6HgHaUuNlzu9GFvMAcvoTFWbFdMrkybO9RzKNGUErFBYOxqOtcGaDbPzzekbjDYWw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=WqwB2/y4; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WqwB2/y4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119415; 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=ED6N2Drlsei75IIZPCydMGtt9kEdxgMUpbSFFwguS/g=; b=WqwB2/y4SN/2TcWbhptkeOTgCSmLt7QwXqzd5JOLszR/0cMDsBqXrwxmlIbI1Ebhw1Whve YxfjjUxbM3O3dRRxXA6RAFQDM9Dyb0DMgJOlaY+U05SpRS0RZY/uvgFJF8kPz7oCzZ8anO OFMvZHHf29qJEfx83Mfr1dVRkLF2t0I= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-BL-dO_zFOSOyS3qYulLPnA-1; Mon, 22 Jun 2026 05:10:12 -0400 X-MC-Unique: BL-dO_zFOSOyS3qYulLPnA-1 X-Mimecast-MFC-AGG-ID: BL-dO_zFOSOyS3qYulLPnA_1782119411 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4DE6E1801BDA; Mon, 22 Jun 2026 09:10:11 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 276D93001D84; Mon, 22 Jun 2026 09:10:08 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Deepakkumar Karn Subject: [PATCH v4 16/21] afs: Fix leak of ungot volume Date: Mon, 22 Jun 2026 10:08:50 +0100 Message-ID: <20260622090856.2746629-17-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" Fix afs_lookup_volume_rcu() so that it doesn't leak a dying volume if afs_try_get_volume() fails. Fixes: 32222f09782f ("afs: Apply server breaks to mmap'd files in the call = processor") Closes: https://sashiko.dev/#/patchset/20260609081738.770127-1-dhowells%40r= edhat.com Signed-off-by: David Howells cc: Marc Dionne cc: Deepakkumar Karn cc: linux-afs@lists.infradead.org --- fs/afs/callback.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/afs/callback.c b/fs/afs/callback.c index 74853e0d0435..61354003c006 100644 --- a/fs/afs/callback.c +++ b/fs/afs/callback.c @@ -134,6 +134,7 @@ static struct afs_volume *afs_lookup_volume_rcu(struct = afs_cell *cell, =20 if (volume && afs_try_get_volume(volume, afs_volume_trace_get_callback)) break; + volume =3D NULL; } =20 return volume; From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 2843A3A6F19 for ; Mon, 22 Jun 2026 09:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119421; cv=none; b=YDUN3aUvVFy8SWncXEiYPKMOEtpmIGieKCGAamWf2+S66eIWjrrg+fedcgRxOX1JKQKt9tRzIi1fuxEzgreS7uTf1YLJqSFDTw1xgQqorm92ReXU4DE0cmGiPgveLYzEyk5WwBxvcYvT4moCdFDjcUvTQ9wN5t5J/x61Bc89f9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119421; c=relaxed/simple; bh=GuAnvlb8FEY8sez1wbAfUs6fiMrA6S5hlCwzTfveE14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NX6hWAs6E/xEwt/t9DaTqU8d2OFqyAHjA2zYSLF8Un+RwRglQSvAttNAvBAlnu1iyC/8Wo9ENv4lymD287Ni6VUkXpuardIWDtXloRd7c1etR0j+Hr0AQlN5dXgViPTsPMhFvyfyH9W6Gw6CbDj1jZIk3Sm/+CihfT8eIKHq1/E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=A099O6rE; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A099O6rE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119419; 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=OW1K1BXP4XEqieQzQiZKHQvagjteaHvJHIAh6dS1QFg=; b=A099O6rEbtnCdSWDoQgmE0QVVeB6IfAQq0w1gFOiCpey62nQXWe/MeOfqsbVhRKnqyyfmV vn53s/iFqGTPtagg1IkUX6f74zM/qA493a3WxDsbjKr2ELdG7FL1Y0ii/Ou/dK6QNfEyx6 vJgrNatLLU4F7y7j3kht1trGDx4KV64= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-uW79c5kQP66dao7ZWgmfPA-1; Mon, 22 Jun 2026 05:10:16 -0400 X-MC-Unique: uW79c5kQP66dao7ZWgmfPA-1 X-Mimecast-MFC-AGG-ID: uW79c5kQP66dao7ZWgmfPA_1782119415 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D8685180034E; Mon, 22 Jun 2026 09:10:14 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E95FC18005B5; Mon, 22 Jun 2026 09:10:12 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 17/21] afs: Fix vllist leak Date: Mon, 22 Jun 2026 10:08:51 +0100 Message-ID: <20260622090856.2746629-18-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Fix a leak of the new vllist in afs_update_cell() in the event that it is an empty list (nr_servers =3D=3D 0), in which case the old list isn't displaced unless the old list is also empty. Fixes: d5c32c89b208 ("afs: Fix cell DNS lookup") Closes: https://sashiko.dev/#/patchset/20260609081738.770127-1-dhowells%40r= edhat.com Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/cell.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/afs/cell.c b/fs/afs/cell.c index e0fab1609f27..fbb8a43aa7cd 100644 --- a/fs/afs/cell.c +++ b/fs/afs/cell.c @@ -547,6 +547,8 @@ static int afs_update_cell(struct afs_cell *cell) rcu_assign_pointer(cell->vl_servers, vllist); cell->dns_source =3D vllist->source; old =3D p; + } else { + old =3D vllist; } write_unlock(&cell->vl_servers_lock); afs_put_vlserverlist(cell->net, old); From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 CFD793A7595 for ; Mon, 22 Jun 2026 09:10:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119425; cv=none; b=h6bZXqKVAN/rLlfSVBC6OqBTOeHzyoDHBHsKSdLQlu9W0vvKsfrtUdDNbwW5aPygJiLKExoycruDKqBNGn8fYBsyfCslyYl6DaPWUE078FruO6Ds77VQ26oqmpB1COwYfr4Zt9Nuwc1o3hzJXCUSkZcV2zCOzKrimKLdVmJwvYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119425; c=relaxed/simple; bh=Zb3uzmxuliah1WLkHf3aISWbottq6Pz73CvyrjhnDJ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uaDjAer2iNxNmm54SbN5bb6XbvvSvjZHq9YIgr9bNknJAL4KA9y1kXwy4s58LWaJUSou3FqUx3rSsScp3EgHCbEfNMAADeRWoBqMqKeJvOuoEyPv+ixg61r61ChrK20Lhmb6sirYZZYiqZWYkJFDLYh3z+0Vi7RWtpLUM66g7HA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=ArxNpInC; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ArxNpInC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119423; 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=eyyQwlxIuAX3COzyoSlpJ5w5gYTJ6EubEwvoUtFL6K4=; b=ArxNpInClm+pBd/dtfXdHl+QQKPMB7ZsN7RzMwtb5JaMX72l3Ft4cf4Q5k2+rNK/Q7dQna 0Y1cB25JmmXbHsaYMp2zj05M6yqreJtuSnXkKxQxRRn1cOcj/skAmGJoNwgnm+IiDFJ8st UTLxXkKlkxzLT9mdC1B/ohCJoljOAGU= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-m11h2FGHMUCLSsaDk5Pp9w-1; Mon, 22 Jun 2026 05:10:19 -0400 X-MC-Unique: m11h2FGHMUCLSsaDk5Pp9w-1 X-Mimecast-MFC-AGG-ID: m11h2FGHMUCLSsaDk5Pp9w_1782119418 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 621801806C99; Mon, 22 Jun 2026 09:10:18 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7C8691800480; Mon, 22 Jun 2026 09:10:16 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 18/21] afs: Fix lack of locking around modifications of net->cells_dyn_ino Date: Mon, 22 Jun 2026 10:08:52 +0100 Message-ID: <20260622090856.2746629-19-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Fix the lack of locking around modifications of net->cells_dyn_ino by taking net->cells_lock exclusively. This also requires to cell to be removed from net->cells_dyn_ino in afs_destroy_cell_work() rather than in afs_cell_destroy() as the latter runs in RCU cleanup context and sleeping locks cannot be taken there. Fixes: 1d0b929fc070 ("afs: Change dynroot to create contents on demand") Closes: https://sashiko.dev/#/patchset/20260618074903.2374756-1-dhowells%40= redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/cell.c | 8 +++++++- fs/afs/dynroot.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/afs/cell.c b/fs/afs/cell.c index fbb8a43aa7cd..9d8937ae24e2 100644 --- a/fs/afs/cell.c +++ b/fs/afs/cell.c @@ -205,8 +205,10 @@ static struct afs_cell *afs_alloc_cell(struct afs_net = *net, cell->dns_source =3D vllist->source; cell->dns_status =3D vllist->status; smp_store_release(&cell->dns_lookup_count, 1); /* vs source/status */ + down_write(&net->cells_lock); ret =3D idr_alloc_cyclic(&net->cells_dyn_ino, cell, 2, INT_MAX / 2, GFP_KERNEL); + up_write(&net->cells_lock); if (ret < 0) goto error; atomic_inc(&net->cells_outstanding); @@ -579,7 +581,6 @@ static void afs_cell_destroy(struct rcu_head *rcu) afs_put_vlserverlist(net, rcu_access_pointer(cell->vl_servers)); afs_unuse_cell(cell->alias_of, afs_cell_trace_unuse_alias); key_put(cell->anonymous_key); - idr_remove(&net->cells_dyn_ino, cell->dynroot_ino); kfree(cell->name - 1); kfree(cell); =20 @@ -594,6 +595,11 @@ static void afs_destroy_cell_work(struct work_struct *= work) afs_see_cell(cell, afs_cell_trace_destroy); timer_delete_sync(&cell->management_timer); cancel_work_sync(&cell->manager); + + down_write(&cell->net->cells_lock); + idr_remove(&cell->net->cells_dyn_ino, cell->dynroot_ino); + up_write(&cell->net->cells_lock); + call_rcu(&cell->rcu, afs_cell_destroy); } =20 diff --git a/fs/afs/dynroot.c b/fs/afs/dynroot.c index 1d5e33bc7502..6e3c8c691ba9 100644 --- a/fs/afs/dynroot.c +++ b/fs/afs/dynroot.c @@ -278,7 +278,7 @@ static struct dentry *afs_lookup_atcell(struct inode *d= ir, struct dentry *dentry } =20 /* - * Transcribe the cell database into readdir content under the RCU read lo= ck. + * Transcribe the cell database into readdir content under net->cells_lock. * Each cell produces two entries, one prefixed with a dot and one not. */ static int afs_dynroot_readdir_cells(struct afs_net *net, struct dir_conte= xt *ctx) From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 4ADBD3A75A6 for ; Mon, 22 Jun 2026 09:10:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119428; cv=none; b=qA1I/T37lxzKf+BEsQejOcCo8PWCc/T/O7VCo2/36sQyGLx0uch0Hro2qspsfkwzvwShL9ed9tlRNGqZAEoWTvLP0PRoR6qV7tnaDGZkmxJup+eK5CXB3hFRFPVe5tSM9Mdznu/dJYXLIbJwmMbynSx5t1ZQICLp2lgaTVQefKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119428; c=relaxed/simple; bh=svxPEDSaFUJW1uCJX3VJjP5uyQ25iA0A76oqVEXg0hQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MfuA4q/maApmj/O/Jys9lpOsPKf8meVREiMDBMeOZyf/9dEret6hJnD95wBsgaMhnmRtNG73hGX8LJ0893OMrcdA7z64HJ60tr84aJ/Ukub3Ncu7x2NuBSPT45PZW0NuE7ccO7x9DMtxkKDxf5XHjuUz9iHHTwVJFObVcDx1qlE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=O4wuqN/d; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O4wuqN/d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119426; 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=qc3AUaJBiNCkiBRvrTGrdtukzI4PlxpQ5/Yzj4K7t9M=; b=O4wuqN/dCw9atOJVPd7XGAj0cI3KwqFFM7ZqtLfaKfsdy6daBw6/gXjKAz3P6YtEvocv1m 2T8jg+/syT6wIRyrs3pIXeb5ux68unBTHpy/rZ2kXvCt6RomskLXfZ4gQq7QHGSGROAOL0 D8SB1nErdhwO2h7i0g3zkEctxBe4+Nk= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-xO3PVpK8NES8cNOpfXoSwg-1; Mon, 22 Jun 2026 05:10:23 -0400 X-MC-Unique: xO3PVpK8NES8cNOpfXoSwg-1 X-Mimecast-MFC-AGG-ID: xO3PVpK8NES8cNOpfXoSwg_1782119422 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E37711805C30; Mon, 22 Jun 2026 09:10:21 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0983D1953946; Mon, 22 Jun 2026 09:10:19 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 19/21] afs: Fix premature cell exposure through /afs Date: Mon, 22 Jun 2026 10:08:53 +0100 Message-ID: <20260622090856.2746629-20-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Type: text/plain; charset="utf-8" AFS cell records are prematurely exposured through the /afs dynamic root by virtue of adding them immediately to the net->cells_dyn_ino IDR when the cell is allocated rather than when it is added to the lookup tree. This allows a candidate record to be accessed, even if it's actually a duplicate or not published yet. Fix this by not adding the cell to cells_dyn_ino until it's confirmed non-duplicate and is being published. A flag is then used to record whether it is added to the IDR to make removal from the IDR conditional. Closes: https://sashiko.dev/#/patchset/20260618155141.2513212-1-dhowells%40= redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/cell.c | 27 +++++++++++++++++---------- fs/afs/internal.h | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/fs/afs/cell.c b/fs/afs/cell.c index 9d8937ae24e2..47a2645768d7 100644 --- a/fs/afs/cell.c +++ b/fs/afs/cell.c @@ -205,14 +205,7 @@ static struct afs_cell *afs_alloc_cell(struct afs_net = *net, cell->dns_source =3D vllist->source; cell->dns_status =3D vllist->status; smp_store_release(&cell->dns_lookup_count, 1); /* vs source/status */ - down_write(&net->cells_lock); - ret =3D idr_alloc_cyclic(&net->cells_dyn_ino, cell, - 2, INT_MAX / 2, GFP_KERNEL); - up_write(&net->cells_lock); - if (ret < 0) - goto error; atomic_inc(&net->cells_outstanding); - cell->dynroot_ino =3D ret; cell->debug_id =3D atomic_inc_return(&cell_debug_id); =20 trace_afs_cell(cell->debug_id, 1, 0, afs_cell_trace_alloc); @@ -306,6 +299,13 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net, goto cell_already_exists; } =20 + ret =3D idr_alloc_cyclic(&net->cells_dyn_ino, candidate, + 2, INT_MAX / 2, GFP_KERNEL); + if (ret < 0) + goto cant_alloc_ino; + candidate->dynroot_ino =3D ret; + set_bit(AFS_CELL_FL_HAVE_INO, &candidate->flags); + cell =3D candidate; candidate =3D NULL; afs_use_cell(cell, trace); @@ -380,6 +380,11 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net, _leave(" =3D %p [cell]", cell); return cell; =20 +cant_alloc_ino: + up_write(&net->cells_lock); + afs_put_cell(candidate, afs_cell_trace_put_candidate); + goto error_noput; + cell_already_exists: _debug("cell exists"); cell =3D cursor; @@ -596,9 +601,11 @@ static void afs_destroy_cell_work(struct work_struct *= work) timer_delete_sync(&cell->management_timer); cancel_work_sync(&cell->manager); =20 - down_write(&cell->net->cells_lock); - idr_remove(&cell->net->cells_dyn_ino, cell->dynroot_ino); - up_write(&cell->net->cells_lock); + if (test_bit(AFS_CELL_FL_HAVE_INO, &cell->flags)) { + down_write(&cell->net->cells_lock); + idr_remove(&cell->net->cells_dyn_ino, cell->dynroot_ino); + up_write(&cell->net->cells_lock); + } =20 call_rcu(&cell->rcu, afs_cell_destroy); } diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 785c646856d7..601f01e5c15f 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -388,6 +388,7 @@ struct afs_cell { #define AFS_CELL_FL_NO_GC 0 /* The cell was added manually, don't auto-gc= */ #define AFS_CELL_FL_DO_LOOKUP 1 /* DNS lookup requested */ #define AFS_CELL_FL_CHECK_ALIAS 2 /* Need to check for aliases */ +#define AFS_CELL_FL_HAVE_INO 3 /* Have dynroot_ino */ enum afs_cell_state state; short error; enum dns_record_source dns_source:8; /* Latest source of data from lookup= */ From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 1199A3A7F60 for ; Mon, 22 Jun 2026 09:10:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119433; cv=none; b=XxQgGkKMjQ3R1e3iOEC93I+U90kulgJb0rMP+imAFbjV0tImbTPkE3Wyb/lTXE0Bscq6CvBwXfEH/B1jvW5wLA+UrrjcLp2yNWqAKnLSnOF/fYgcJLT5V0CQaAy13xHKyQobbNn78zbg5/2JMSsJWM/m+dD2xUOoOqq+3O6IT7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119433; c=relaxed/simple; bh=0HmkqP/RuhjLxCSpGGAOzCvPlOP9+EPBd7TYOa9/lMo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s9b9C0pv4rFzR1GGOcKyn4zDbJRaY2ZEKfEkfJ4/0pq6Cl4kpta0k1LXmsHmvE9iY+T59kmHjqUP5dSJ+hNntfWlgX42FROjUIGBILwk2Ebhlrccw5yfvJDz2t2j+gGWXzARHaEtdjHXV6khu7/x5a1dSmcVkFegoTZ6mHdscSY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=Wgx2e9vc; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Wgx2e9vc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119430; 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=iw9uGhm3LO9PdxkRoOT9J8m9qRxzmFyZf0B6bVDSkuM=; b=Wgx2e9vcxoIBjOSYiWPZfcFIf2T/f4tTY3op1U0GpW/sEg+A5l023F1OmemHDFegOA1p53 wb0AeqmAUMU/LGYTPQniW/FwuolyTSZKKcOuvvfPSK9SkdIhM2BFkBqPJTExIka5tmHzR3 zhrJRODOgHA3Oa5oDCPeDaUHemKsu0s= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-VoJ3GrymNtuOi-Svw5F28A-1; Mon, 22 Jun 2026 05:10:26 -0400 X-MC-Unique: VoJ3GrymNtuOi-Svw5F28A-1 X-Mimecast-MFC-AGG-ID: VoJ3GrymNtuOi-Svw5F28A_1782119425 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5F1891800596; Mon, 22 Jun 2026 09:10:25 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6FF4A180058F; Mon, 22 Jun 2026 09:10:23 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 20/21] afs: Fix the volume AFS_VOLUME_RM_TREE is set on Date: Mon, 22 Jun 2026 10:08:54 +0100 Message-ID: <20260622090856.2746629-21-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Fix afs_insert_volume_into_cell() to set AFS_VOLUME_RM_TREE on the volume replaced, not the new volume, as it's now removed from the cell's volume tree. This will cause the old volume to be removed from the tree twice and the new volume never to be removed. Fixes: 9a6b294ab496 ("afs: Fix use-after-free due to get/remove race in vol= ume tree") Closes: https://sashiko.dev/#/patchset/20260618074903.2374756-1-dhowells%40= redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/volume.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/afs/volume.c b/fs/afs/volume.c index 9ae5c8ad2e04..4f79d25ec37f 100644 --- a/fs/afs/volume.c +++ b/fs/afs/volume.c @@ -40,7 +40,7 @@ static struct afs_volume *afs_insert_volume_into_cell(str= uct afs_cell *cell, goto found; } =20 - set_bit(AFS_VOLUME_RM_TREE, &volume->flags); + set_bit(AFS_VOLUME_RM_TREE, &p->flags); rb_replace_node_rcu(&p->cell_node, &volume->cell_node, &cell->volumes); } } From nobody Tue Jul 14 14:06:55 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 4FAE939B954 for ; Mon, 22 Jun 2026 09:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119438; cv=none; b=ssB/XjlyQJ/Rbw0TK5h+koxEF+Bw7IL6C6P5004QhLPpjFU1A+uhShnnpGfGVQnHglJwNO6aYDXTHue4dDi8ITHUh0+msO+VpHP6BhaInLgQu7IxEjtvf5CBlGMFOJwKDMhAPvdBcqopC0KxVVS4yUA/AC1j81lpcp+9pS0imiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782119438; c=relaxed/simple; bh=pVlDnhTNgy9VLUDjua7j8BYyIUIHs0re8lGz7SsZBvo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j5y4jNYde9BDoOqOup+rCy1DfCwSZTYY9DAP1+kGMNoOb0j2/qwW6JR0DJhN/wDMlt6VmVrtOC4OqLknxJwrJw71xho2tIg0ria80JEcbN5TJDnPd2If85z0dVmbbruFbuEVP9URYMLKKZ4BGOopPdQBs2Fni9Nn4aXC4z0lXoM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=L7B7vV0p; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L7B7vV0p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782119436; 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=8l0L9lAz4zYqt1sff+b3aAkYIIeMJGlrOGTd9ASx6w8=; b=L7B7vV0prNJRTC3OKdFkH5UfMjfdn3YK9/ZRm/hucLruNTDb1zIl6h67gDzYi+QELYTMc5 RfXiP6nR5juDlQjStVJ+vFccZMGSsHsaquKRX8SkMODGuTmFtvN7On6etvZhJavH/w7LqZ LGFPRQMUJydvJc0DE/z8e6HqyRFKRUg= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649-sTPOQI0hMqC-Zx_yotccWA-1; Mon, 22 Jun 2026 05:10:29 -0400 X-MC-Unique: sTPOQI0hMqC-Zx_yotccWA-1 X-Mimecast-MFC-AGG-ID: sTPOQI0hMqC-Zx_yotccWA_1782119428 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C7B811956042; Mon, 22 Jun 2026 09:10:28 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.48.242]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E4A8C1800661; Mon, 22 Jun 2026 09:10:26 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Marc Dionne , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 21/21] afs: Fix unchecked-length string display in debug statement Date: Mon, 22 Jun 2026 10:08:55 +0100 Message-ID: <20260622090856.2746629-22-dhowells@redhat.com> In-Reply-To: <20260622090856.2746629-1-dhowells@redhat.com> References: <20260622090856.2746629-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Content-Type: text/plain; charset="utf-8" Fix afs_extract_vlserver_list() to limit the length of the displayed string in a debug statement(). Fixes: 0a5143f2f89c ("afs: Implement VL server rotation") Closes: https://sashiko.dev/#/patchset/20260618074903.2374756-1-dhowells%40= redhat.com Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/vl_list.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/afs/vl_list.c b/fs/afs/vl_list.c index 8e1cf6cdcf71..c1dac5dbed0d 100644 --- a/fs/afs/vl_list.c +++ b/fs/afs/vl_list.c @@ -200,6 +200,8 @@ struct afs_vlserver_list *afs_extract_vlserver_list(str= uct afs_cell *cell, =20 b +=3D sizeof(*hdr); while (end - b >=3D sizeof(bs)) { + int nlen; + bs.name_len =3D afs_extract_le16(&b); bs.priority =3D afs_extract_le16(&b); bs.weight =3D afs_extract_le16(&b); @@ -209,10 +211,12 @@ struct afs_vlserver_list *afs_extract_vlserver_list(s= truct afs_cell *cell, bs.protocol =3D *b++; bs.nr_addrs =3D *b++; =20 + nlen =3D min3(bs.name_len, end - b, 255); + _debug("extract %u %u %u %u %u %u %*.*s", bs.name_len, bs.priority, bs.weight, bs.port, bs.protocol, bs.nr_addrs, - bs.name_len, bs.name_len, b); + bs.name_len, nlen, b); =20 if (end - b < bs.name_len) break;