[PATCH] afs: Fix uninitialized count on split reply in afs_deliver_fs_get_capabilities()

From: Ian Rogers

Date: Thu Nov 19 2026 - 12:03:57 EST


In afs_deliver_fs_get_capabilities(), case 1 extracts the capabilities
word count into local variable count, saves it in call->count, advances
call->unmarshall to 2, and falls through to case 2 to extract the first
capabilities word.

If the RxRPC reply is split across packets such that afs_extract_data()
in case 2 returns -EAGAIN, the next delivery call enters the switch
directly at case 2 with local variable count uninitialized and passes
(count - 1) * sizeof(__be32) to afs_extract_discard(), corrupting stream
unmarshalling or hanging the call waiting for a garbage discard length.

Use call->count when computing the discard byte count in case 2.

Found by enabling Clang's -Wconditional-uninitialized on an x86_64
allyesconfig build, with AI coding assistant help to audit the warning
and prepare the fix. Build-tested with Clang; not runtime-tested against
an AFS fileserver.

Fixes: b537a3c21775 ("afs: Fix corruption in reads at fpos 2G-4G from an OpenAFS server")
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
fs/afs/fsclient.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c
index 1a3f186a6a11..7b5fb8b122ab 100644
--- a/fs/afs/fsclient.c
+++ b/fs/afs/fsclient.c
@@ -1707,7 +1707,7 @@ static int afs_deliver_fs_get_capabilities(struct afs_call *call)
if (ret < 0)
return ret;

- afs_extract_discard(call, (count - 1) * sizeof(__be32));
+ afs_extract_discard(call, (call->count - 1) * sizeof(__be32));
call->unmarshall++;
fallthrough;

--
2.56.1.708.g77570a6a1d-goog