mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: David Howells <dhowells@redhat.com>,
	Marc Dionne <marc.dionne@auristor.com>
Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org,
	 llvm@lists.linux.dev, Elkin Cruz <elkin@google.com>,
	Ian Rogers <irogers@google.com>
Subject: [PATCH] afs: Fix uninitialized count on split reply in afs_deliver_fs_get_capabilities()
Date: Thu, 19 Nov 2026 09:03:48 -0800	[thread overview]
Message-ID: <20261119170348.1509147-1-irogers@google.com> (raw)

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


                 reply	other threads:[~2026-11-19 17:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119170348.1509147-1-irogers@google.com \
    --to=irogers@google.com \
    --cc=dhowells@redhat.com \
    --cc=elkin@google.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=marc.dionne@auristor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®