mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Elkin Cruz <elkin@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, irogers@google.com,
	Elkin Cruz <elkin@google.com>,
	 stable@vger.kernel.org
Subject: [PATCH 1/2] afs: Guard NULL alist on restart in afs_select_vlserver()
Date: Wed, 25 Nov 2026 22:17:29 +0000	[thread overview]
Message-ID: <20261125221730.1421806-2-elkin@google.com> (raw)
In-Reply-To: <20261125221730.1421806-1-elkin@google.com>

In afs_select_vlserver(), restart_from_beginning: is reached from
no_more_servers: after pick_server:, where alist and vc->alist have
already been cleared to NULL at next_server:. If an earlier VL call
received a response (vc->call_responded == true) before failing with
-ECONNRESET (setting AFS_VL_CURSOR_RETRY), vc->call_responded remains
true until another server address is selected, causing
restart_from_beginning: to dereference a NULL vc->alist.

Guard the preferred-address update and afs_put_addrlist() at
restart_from_beginning: with if (alist), matching the failed: path.

Fixes: 98f9fda2057b ("afs: Fold the afs_addr_cursor struct in")
Cc: stable@vger.kernel.org
Signed-off-by: Elkin Cruz <elkin@google.com>
---
 fs/afs/vl_rotate.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fs/afs/vl_rotate.c b/fs/afs/vl_rotate.c
index 6ad9688d8f4b..8381d6a35d3e 100644
--- a/fs/afs/vl_rotate.c
+++ b/fs/afs/vl_rotate.c
@@ -171,12 +171,15 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)
 
 restart_from_beginning:
 	_debug("restart");
-	if (vc->call_responded &&
-	    vc->addr_index != vc->alist->preferred &&
-	    test_bit(alist->preferred, &vc->addr_tried))
-		WRITE_ONCE(alist->preferred, vc->addr_index);
-	afs_put_addrlist(alist, afs_alist_trace_put_vlrotate_restart);
-	alist = vc->alist = NULL;
+	if (alist) {
+		if (vc->call_responded &&
+		    vc->addr_index != alist->preferred &&
+		    test_bit(alist->preferred, &vc->addr_tried))
+			WRITE_ONCE(alist->preferred, vc->addr_index);
+		afs_put_addrlist(alist, afs_alist_trace_put_vlrotate_restart);
+		vc->alist = NULL;
+		alist = NULL;
+	}
 
 	afs_put_vlserverlist(vc->cell->net, vc->server_list);
 	vc->server_list = NULL;
-- 
2.56.1.839.g22a8290db9-goog


  reply	other threads:[~2026-11-25 22:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 22:17 [PATCH 0/2] afs: fix NULL alist dereference and address bitmask shifts Elkin Cruz
2026-11-25 22:17 ` Elkin Cruz [this message]
2026-11-25 22:17 ` [PATCH 2/2] afs: Use bitops for fileserver address bitmasks Elkin Cruz

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=20261125221730.1421806-2-elkin@google.com \
    --to=elkin@google.com \
    --cc=dhowells@redhat.com \
    --cc=irogers@google.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=marc.dionne@auristor.com \
    --cc=stable@vger.kernel.org \
    /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®