]> git.ipfire.org Git - people/arne_f/kernel.git/commit
rxrpc: Fix use-after-free in rxrpc_receive_data()
authorDavid Howells <dhowells@redhat.com>
Fri, 24 Jan 2020 23:08:04 +0000 (23:08 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Feb 2020 09:32:59 +0000 (09:32 +0000)
commite115aaf85a098eb36ef5e61b83c8b7d1a01c7419
tree524285eab2daccfe8793b5218fe424d349a5c324
parenta9e3ebaf910abd7d3dab168bb679749d7d5ff525
rxrpc: Fix use-after-free in rxrpc_receive_data()

[ Upstream commit 122d74fac84204b9a98263636f6f9a3b2e665639 ]

The subpacket scanning loop in rxrpc_receive_data() references the
subpacket count in the private data part of the sk_buff in the loop
termination condition.  However, when the final subpacket is pasted into
the ring buffer, the function is no longer has a ref on the sk_buff and
should not be looking at sp->* any more.  This point is actually marked in
the code when skb is cleared (but sp is not - which is an error).

Fix this by caching sp->nr_subpackets in a local variable and using that
instead.

Also clear 'sp' to catch accesses after that point.

This can show up as an oops in rxrpc_get_skb() if sp->nr_subpackets gets
trashed by the sk_buff getting freed and reused in the meantime.

Fixes: e2de6c404898 ("rxrpc: Use info in skbuff instead of reparsing a jumbo packet")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/rxrpc/input.c