[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2427545.1673449981@warthog.procyon.org.uk>
Date: Wed, 11 Jan 2023 15:13:01 +0000
From: David Howells <dhowells@...hat.com>
To: Zheng Wang <zyytlz.wz@....com>
Cc: dhowells@...hat.com, marc.dionne@...istor.com,
linux-afs@...ts.infradead.org, linux-kernel@...r.kernel.org,
hackerzheng666@...il.com, alex000young@...il.com,
security@...nel.org
Subject: Re: [PATCH] afs: Fix poential UAF in afs_make_call
Zheng Wang <zyytlz.wz@....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
Powered by blists - more mailing lists