Bluetooth: hidp: verify l2cap sockets
authorDavid Herrmann <dh.herrmann@gmail.com>
Fri, 5 Apr 2013 12:57:34 +0000 (14:57 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 1 Jan 2018 20:51:03 +0000 (20:51 +0000)
commit6b369a5d1ed6c5c04a76db01c21802e1ca11ec82
tree898ba3e7e0b531e6841b9ee7e8729efcec9e72c3
parente23d13a89d8ca5fe717d75248672e1b8bc4a3be8
Bluetooth: hidp: verify l2cap sockets

commit b3916db32c4a3124eee9f3742a2f4723731d7602 upstream.

We need to verify that the given sockets actually are l2cap sockets. If
they aren't, we are not supposed to access bt_sk(sock) and we shouldn't
start the session if the offsets turn out to be valid local BT addresses.

That is, if someone passes a TCP socket to HIDCONNADD, then we access some
random offset in the TCP socket (which isn't even guaranteed to be valid).

Fix this by checking that the socket is an l2cap socket.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
include/net/bluetooth/l2cap.h
net/bluetooth/hidp/core.c
net/bluetooth/l2cap_sock.c