aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/sco.c
diff options
context:
space:
mode:
authorMateusz Jurczyk <mjurczyk@google.com>2017-06-29 14:04:59 +0200
committerMarcel Holtmann <marcel@holtmann.org>2017-06-29 14:37:57 +0200
commitd2ecfa765dff59145a4ba9c84856e50c4f43c2b2 (patch)
tree234b4b6a034d7398be70b2ca7dd655de5aad864d /net/bluetooth/sco.c
parentbluetooth: remove WQ_MEM_RECLAIM from hci workqueues (diff)
downloadlinux-dev-d2ecfa765dff59145a4ba9c84856e50c4f43c2b2.tar.xz
linux-dev-d2ecfa765dff59145a4ba9c84856e50c4f43c2b2.zip
Bluetooth: Add sockaddr length checks before accessing sa_family in bind and connect handlers
Verify that the caller-provided sockaddr structure is large enough to contain the sa_family field, before accessing it in bind() and connect() handlers of the Bluetooth sockets. Since neither syscall enforces a minimum size of the corresponding memory region, very short sockaddrs (zero or one byte long) result in operating on uninitialized memory while referencing sa_family. Signed-off-by: Mateusz Jurczyk <mjurczyk@google.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/sco.c')
-rw-r--r--net/bluetooth/sco.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 728e0c8dc8e7..795e920a3281 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -524,10 +524,8 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr,
BT_DBG("sk %p %pMR", sk, &sa->sco_bdaddr);
- if (!addr || addr->sa_family != AF_BLUETOOTH)
- return -EINVAL;
-
- if (addr_len < sizeof(struct sockaddr_sco))
+ if (!addr || addr_len < sizeof(struct sockaddr_sco) ||
+ addr->sa_family != AF_BLUETOOTH)
return -EINVAL;
lock_sock(sk);