rxrpc: Fix read-after-free in rxrpc_queue_local()
authorDavid Howells <dhowells@redhat.com>
Tue, 13 Aug 2019 21:26:36 +0000 (22:26 +0100)
committerDavid Howells <dhowells@redhat.com>
Wed, 14 Aug 2019 10:37:51 +0000 (11:37 +0100)
commit06d9532fa6b34f12a6d75711162d47c17c1add72
tree769d038231f7e58df65b0a3332d5bfcd3fbbf82c
parentb00df840fb4004b7087940ac5f68801562d0d2de
rxrpc: Fix read-after-free in rxrpc_queue_local()

rxrpc_queue_local() attempts to queue the local endpoint it is given and
then, if successful, prints a trace line.  The trace line includes the
current usage count - but we're not allowed to look at the local endpoint
at this point as we passed our ref on it to the workqueue.

Fix this by reading the usage count before queuing the work item.

Also fix the reading of local->debug_id for trace lines, which must be done
with the same consideration as reading the usage count.

Fixes: 09d2bf595db4 ("rxrpc: Add a tracepoint to track rxrpc_local refcounting")
Reported-by: syzbot+78e71c5bab4f76a6a719@syzkaller.appspotmail.com
Signed-off-by: David Howells <dhowells@redhat.com>
include/trace/events/rxrpc.h
net/rxrpc/local_object.c