Bluetooth: hidp: verify l2cap sockets
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>
This commit is contained in:

committed by
Gustavo Padovan

parent
c849edbdc2
commit
b3916db32c
@@ -973,6 +973,8 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
if (!l2cap_is_socket(ctrl_sock) || !l2cap_is_socket(intr_sock))
|
||||
return -EINVAL;
|
||||
if (bacmp(&bt_sk(ctrl_sock->sk)->src, &bt_sk(intr_sock->sk)->src) ||
|
||||
bacmp(&bt_sk(ctrl_sock->sk)->dst, &bt_sk(intr_sock->sk)->dst))
|
||||
return -ENOTUNIQ;
|
||||
|
Reference in New Issue
Block a user