From: David Howells <dhowells@redhat.com>
To: Zheng Wang <zyytlz.wz@163.com>
Cc: dhowells@redhat.com, marc.dionne@auristor.com,
linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org,
hackerzheng666@gmail.com, alex000young@gmail.com,
security@kernel.org
Subject: Re: [PATCH] afs: Fix poential UAF in afs_make_call
Date: Wed, 11 Jan 2023 15:13:01 +0000 [thread overview]
Message-ID: <2427545.1673449981@warthog.procyon.org.uk> (raw)
In-Reply-To: <20221229164029.3009754-1-zyytlz.wz@163.com>
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
prev parent reply other threads:[~2023-01-11 15:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-29 16:40 Zheng Wang
2023-01-11 15:13 ` David Howells [this message]
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=2427545.1673449981@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=alex000young@gmail.com \
--cc=hackerzheng666@gmail.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.dionne@auristor.com \
--cc=security@kernel.org \
--cc=zyytlz.wz@163.com \
/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®