* [PATCH] afs: Fix poential UAF in afs_make_call
@ 2022-12-29 16:40 Zheng Wang
2023-01-11 15:13 ` David Howells
0 siblings, 1 reply; 2+ messages in thread
From: Zheng Wang @ 2022-12-29 16:40 UTC (permalink / raw)
To: dhowells
Cc: marc.dionne, linux-afs, linux-kernel, hackerzheng666,
alex000young, security, Zheng Wang
There is a function call : afs_fs_get_capabilities calls afs_make_call, in
afs_make_call, if error occurs in rxrpc_kernel_send_data, it will call
afs_put_call twice, which will free the call. And the access of
call->state will trigger a use-after-free bug.
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
---
fs/afs/rxrpc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/afs/rxrpc.c b/fs/afs/rxrpc.c
index c62939e5ea1f..4871210c4b81 100644
--- a/fs/afs/rxrpc.c
+++ b/fs/afs/rxrpc.c
@@ -422,8 +422,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)
call->rxcall = NULL;
}
if (call->async) {
- if (cancel_work_sync(&call->async_work))
- afs_put_call(call);
+ cancel_work_sync(&call->async_work);
afs_put_call(call);
}
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] afs: Fix poential UAF in afs_make_call
2022-12-29 16:40 [PATCH] afs: Fix poential UAF in afs_make_call Zheng Wang
@ 2023-01-11 15:13 ` David Howells
0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2023-01-11 15:13 UTC (permalink / raw)
To: Zheng Wang
Cc: dhowells, marc.dionne, linux-afs, linux-kernel, hackerzheng666,
alex000young, security
Zheng Wang <zyytlz.wz@163.com> wrote:
> There is a function call : afs_fs_get_capabilities calls afs_make_call, in
> afs_make_call, if error occurs in rxrpc_kernel_send_data, it will call
> afs_put_call twice, which will free the call. And the access of
> call->state will trigger a use-after-free bug.
Are you sure of that? Did you actually trigger a UAF?
> - if (cancel_work_sync(&call->async_work))
> - afs_put_call(call);
> + cancel_work_sync(&call->async_work);
The problem with this change is that it will leak a ref if the work item was
queued but gets cancelled before being run, given to it here:
static void afs_wake_up_async_call(struct sock *sk, struct rxrpc_call *rxcall,
unsigned long call_user_ID)
{
struct afs_call *call = (struct afs_call *)call_user_ID;
int r;
trace_afs_notify_call(rxcall, call);
call->need_attention = true;
if (__refcount_inc_not_zero(&call->ref, &r)) { <----
trace_afs_call(call->debug_id, afs_call_trace_wake, r + 1,
atomic_read(&call->net->nr_outstanding_calls),
__builtin_return_address(0));
if (!queue_work(afs_async_calls, &call->async_work))
afs_put_call(call);
}
}
I *think* that cancel_work_sync() returns false if the work item is executing,
but hasn't been requeued.
David
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-11 15:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-29 16:40 [PATCH] afs: Fix poential UAF in afs_make_call Zheng Wang
2023-01-11 15:13 ` David Howells
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®