From b6a1402e852d328d0892a93c2546f12991094aa5 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 29 Sep 2017 16:13:28 -0700 Subject: [PATCH] Bluetooth: bnep: bnep_add_connection() should verify that it's dealing with l2cap socket same story as cmtp Bug: 33982955 Change-Id: I60ce3e3b5a5a0e41ddaec155a0c6a46307eedeb7 Signed-off-by: Al Viro Signed-off-by: Marcel Holtmann Signed-off-by: Francisco Franco --- net/bluetooth/bnep/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index f50492192197..77cdd94fd607 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c @@ -50,6 +50,7 @@ #include #include +#include #include #include @@ -565,6 +566,9 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock) BT_DBG(""); + if (!l2cap_is_socket(sock)) + return -EBADFD; + baswap((void *) dst, &bt_sk(sock->sk)->dst); baswap((void *) src, &bt_sk(sock->sk)->src);