linux/fs/afs
David Howells 4af1ec68d5
afs: Fix UAF when sending a message
In afs_make_call(), there's a race with async call reception and
destruction.  If a call is dispatched that doesn't have call->write_iter
set (used to specify the data content for FS.StoreData), then the first
rxrpc_kernel_send_data() will not set MSG_MORE in the msghdr.

Once rxrpc_send_data() queues the last request packet, the response could
come in at any time and cause the call to be completed and put.  However,
afs_make_call() will look at the call again to see it ->write_iter should
be handled - something it's only allowed to do if it has its own ref on the
call.  Whilst this is the case for synchronous calls, it isn't true for
async calls such as FS.FetchData.

There's also a potential UAF in afs_make_call() in the event that an
asynchronous call is being sent, but the call fails in some way (e.g. it
gets aborted from the server).  The problem there is that afs_make_call()
tries to abort a call if the rxrpc send fails, but the asynchronous
notification from rxrpc may have caused the afs_call to be torn down.

generic/650 plays games with randomly taking CPUs offline, and can
interject a significant delay such that the call is deallocated before
afs_make_call() gets to check call->write_iter - and a UAF ensues (caught
by KASAN).

   BUG: KASAN: slab-use-after-free in afs_make_call+0x1c90/0x2210 [kafs]
   Read of size 8 at addr ffff888035e050e8 by task fsstress/1409

Fix this by making afs_make_op_call() give the op->call its own ref rather
than transferring the caller's ref to it and then dropping the ref when
afs_make_call() returns.

This also means that the afs_make_call() func never loses its ref on the
call now.

Fixes: eddf51f2bb ("afs: Make {Y,}FS.FetchData an asynchronous operation")
Fixes: e49c7b2f6d ("afs: Build an abstraction around an "operation" concept")
Link: https://sashiko.dev/#/patchset/20260702144919.172295-1-dhowells%40redhat.com
Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260723113452.566619-4-dhowells@redhat.com
cc: Jeffrey Altman <jaltman@auristor.com>
cc: linux-afs@lists.infradead.org
cc: stable@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-07-28 09:20:44 +02:00
..
addr_list.c rxrpc, afs: Fix missing error pointer check after rxrpc_kernel_lookup_peer() 2026-03-06 17:49:52 -08:00
addr_prefs.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
afs_cm.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
afs_fs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
afs_vl.h afs: Fix the maximum cell name length 2025-01-07 15:55:25 +01:00
afs.h afs: Fix the maximum cell name length 2025-01-07 15:55:25 +01:00
callback.c afs: Fix leak of ungot volume 2026-07-01 15:26:21 +02:00
cell.c afs: Fix premature cell exposure through /afs 2026-07-01 15:26:22 +02:00
cm_security.c afs: Fix uncancelled rxrpc OOB message handler 2026-06-25 10:07:18 -07:00
cmservice.c afs: Fix callback service message parsers to pass through -EAGAIN 2026-07-01 15:26:20 +02:00
dir_edit.c afs: Fix afs_edit_dir_remove() to get, not find, block 0 2026-07-23 11:32:40 +02:00
dir_search.c treewide: change inode->i_ino from unsigned long to u64 2026-03-06 14:31:28 +01:00
dir_silly.c VFS: use wait_var_event for waiting in d_alloc_parallel() 2026-06-05 00:34:54 -04:00
dir.c afs: Fix bulk lookup malfunction due to change in dir_emit() API 2026-07-01 15:26:20 +02:00
dynroot.c afs: Fix lack of locking around modifications of net->cells_dyn_ino 2026-07-01 15:26:21 +02:00
file.c netfs: Fix potential for tearing in ->remote_i_size and ->zero_point 2026-05-12 14:42:30 +02:00
flock.c afs: adapt to breakup of struct file_lock 2024-02-05 13:11:42 +01:00
fs_operation.c afs: use kvfree() to free memory allocated by kvcalloc() 2026-07-01 15:26:19 +02:00
fs_probe.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
fsclient.c afs: Fix afs_fs_fetch_data() to subtract transferred from len 2026-07-28 09:20:44 +02:00
inode.c afs: Fix reinitialisation of the inode, in particular ->lock_work 2026-07-01 15:26:20 +02:00
internal.h afs: Fix UAF when sending a message 2026-07-28 09:20:44 +02:00
Kconfig afs: Use rxgk RESPONSE to pass token for callback channel 2025-04-14 17:36:42 -07:00
main.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
Makefile afs: Fix the locking used by afs_get_link() 2026-05-12 14:42:33 +02:00
misc.c afs: Add support for RENAME_NOREPLACE and RENAME_EXCHANGE 2025-09-25 09:19:07 +02:00
mntpt.c afs: Fix dynamic lookup to fail on cell lookup failure 2025-10-29 13:51:38 +01:00
proc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
protocol_afs.h afs: Fix corruption in reads at fpos 2G-4G from an OpenAFS server 2021-09-13 09:14:21 +01:00
protocol_uae.h afs: Add support for the UAE error table 2019-06-28 18:37:53 +01:00
protocol_yfs.h afs: Add support for RENAME_NOREPLACE and RENAME_EXCHANGE 2025-09-25 09:19:07 +02:00
rotate.c Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
rxrpc.c afs: Fix uncancelled rxrpc OOB message handler 2026-06-25 10:07:18 -07:00
security.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
server_list.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
server.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
super.c afs: Fix reinitialisation of the inode, in particular ->lock_work 2026-07-01 15:26:20 +02:00
symlink.c netfs: Replace wb_lock with a bit lock for asynchronicity 2026-07-01 15:26:29 +02:00
validation.c afs: Fix the locking used by afs_get_link() 2026-05-12 14:42:33 +02:00
vl_alias.c afs: Fix dynamic lookup to fail on cell lookup failure 2025-10-29 13:51:38 +01:00
vl_list.c afs: Fix unchecked-length string display in debug statement 2026-07-01 15:26:22 +02:00
vl_probe.c afs: Keep a record of the current fileserver endpoint state 2024-01-01 16:37:27 +00:00
vl_rotate.c afs: Simplify cell record handling 2025-03-10 09:47:15 +00:00
vlclient.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
volume.c afs: Fix the volume AFS_VOLUME_RM_TREE is set on 2026-07-01 15:26:22 +02:00
write.c netfs: Fix potential for tearing in ->remote_i_size and ->zero_point 2026-05-12 14:42:30 +02:00
xattr.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
xdr_fs.h afs: Fix directory format encoding struct 2024-12-20 22:34:04 +01:00
yfsclient.c afs: Fix the locking used by afs_get_link() 2026-05-12 14:42:33 +02:00