* [PATCH] afs: Fix uninit var in afs_alloc_anon_key()
@ 2025-11-29 0:40 David Howells
2025-11-29 0:49 ` Linus Torvalds
0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2025-11-29 0:40 UTC (permalink / raw)
To: Christian Brauner
Cc: dhowells, Paulo Alcantra, torvalds, syzbot+41c68824eefb67cdf00c,
Marc Dionne, linux-afs, linux-fsdevel, linux-kernel
Fix an uninitialised variable (key) in afs_alloc_anon_key() by setting it
to cell->anonymous_key. Without this change, the error check may return a
false failure with a bad error number.
Most of the time this is unlikely to happen because the first encounter
with afs_alloc_anon_key() will usually be from (auto)mount, for which all
subsequent operations must wait - apart from other (auto)mounts. Once the
call->anonymous_key is allocated, all further calls to afs_request_key()
will skip the call to afs_alloc_anon_key() for that cell.
Fixes: d27c71257825 ("afs: Fix delayed allocation of a cell's anonymous key")
Reported-by: Paulo Alcantra <pc@manguebit.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Paulo Alcantara <pc@manguebit.org>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: syzbot+41c68824eefb67cdf00c@syzkaller.appspotmail.com
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
---
fs/afs/security.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/afs/security.c b/fs/afs/security.c
index ff8830e6982f..55ddce94af03 100644
--- a/fs/afs/security.c
+++ b/fs/afs/security.c
@@ -26,7 +26,8 @@ static int afs_alloc_anon_key(struct afs_cell *cell)
struct key *key;
mutex_lock(&afs_key_lock);
- if (!cell->anonymous_key) {
+ key = cell->anonymous_key;
+ if (!key) {
key = rxrpc_get_null_key(cell->key_desc);
if (!IS_ERR(key))
cell->anonymous_key = key;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] afs: Fix uninit var in afs_alloc_anon_key()
2025-11-29 0:40 [PATCH] afs: Fix uninit var in afs_alloc_anon_key() David Howells
@ 2025-11-29 0:49 ` Linus Torvalds
0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2025-11-29 0:49 UTC (permalink / raw)
To: David Howells
Cc: Christian Brauner, Paulo Alcantra, syzbot+41c68824eefb67cdf00c,
Marc Dionne, linux-afs, linux-fsdevel, linux-kernel
I've applied this directly, since it seems to be a recent regression
and final 6.18 is days away.
And it seems like an obvious fix. Famous last words...
Linus
On Fri, 28 Nov 2025 at 16:40, David Howells <dhowells@redhat.com> wrote:
>
> Fix an uninitialised variable (key) in afs_alloc_anon_key() by setting it
> to cell->anonymous_key. Without this change, the error check may return a
> false failure with a bad error number.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-29 0:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-29 0:40 [PATCH] afs: Fix uninit var in afs_alloc_anon_key() David Howells
2025-11-29 0:49 ` Linus Torvalds
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®