mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] afs: Fix uninitialized count on split reply in afs_deliver_fs_get_capabilities()
@ 2026-11-19 17:03 Ian Rogers
  0 siblings, 0 replies; only message in thread
From: Ian Rogers @ 2026-11-19 17:03 UTC (permalink / raw)
  To: David Howells, Marc Dionne
  Cc: linux-afs, linux-kernel, llvm, Elkin Cruz, Ian Rogers

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@google.com>
---
 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-19 17:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 17:03 [PATCH] afs: Fix uninitialized count on split reply in afs_deliver_fs_get_capabilities() Ian Rogers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®