afs: Fix uninitialized count on split reply in afs_deliver_fs_get_capabilities()
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.
--- fs/afs/fsclient.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/fsclient.c +1 -1
@@ -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