Skip to contentSkip to conversation

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

PATCH New Ian Rogers 1 participant 1 message Nov 19 Afs filesystem

lore
Share & tools
lore

Ian Rogers

author
#0 lore raw

PATCH 1/1 afs: Fix uninitialized count on split reply in afs_deliver_fs_get_capabilities()

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")
---
 fs/afs/fsclient.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/fsclient.c +1 -1
index 1a3f186a6a11..7b5fb8b122ab 100644
@@ -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;
 
Signature · 1 line
2.56.1.708.g77570a6a1d-goog