aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/l2cap_sock.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-04-11 16:15:36 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-11 16:15:36 -0400
commit676d23690fb62b5d51ba5d659935e9f7d9da9f8e (patch)
treef6fbceee43e05c724868153ca37b702fb5e43b8c /net/bluetooth/l2cap_sock.c
parentad20d5f673898578f9d8a156d7a4c921f5ca4584 (diff)
net: Fix use after free by removing length arg from sk_data_ready callbacks.
Several spots in the kernel perform a sequence like: skb_queue_tail(&sk->s_receive_queue, skb); sk->sk_data_ready(sk, skb->len); But at the moment we place the SKB onto the socket receive queue it can be consumed and freed up. So this skb->len access is potentially to freed up memory. Furthermore, the skb->len can be modified by the consumer so it is possible that the value isn't accurate. And finally, no actual implementation of this callback actually uses the length argument. And since nobody actually cared about it's value, lots of call sites pass arbitrary values in such as '0' and even '1'. So just remove the length argument from the callback, that way there is no confusion whatsoever and all of these use-after-free cases get fixed as a side effect. Based upon a patch by Eric Dumazet and his suggestion to audit this issue tree-wide. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bluetooth/l2cap_sock.c')
-rw-r--r--net/bluetooth/l2cap_sock.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index f59e00c2daa9..ef5e5b04f34f 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1271,7 +1271,7 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err)
1271 1271
1272 if (parent) { 1272 if (parent) {
1273 bt_accept_unlink(sk); 1273 bt_accept_unlink(sk);
1274 parent->sk_data_ready(parent, 0); 1274 parent->sk_data_ready(parent);
1275 } else { 1275 } else {
1276 sk->sk_state_change(sk); 1276 sk->sk_state_change(sk);
1277 } 1277 }
@@ -1327,7 +1327,7 @@ static void l2cap_sock_ready_cb(struct l2cap_chan *chan)
1327 sk->sk_state_change(sk); 1327 sk->sk_state_change(sk);
1328 1328
1329 if (parent) 1329 if (parent)
1330 parent->sk_data_ready(parent, 0); 1330 parent->sk_data_ready(parent);
1331 1331
1332 release_sock(sk); 1332 release_sock(sk);
1333} 1333}
@@ -1340,7 +1340,7 @@ static void l2cap_sock_defer_cb(struct l2cap_chan *chan)
1340 1340
1341 parent = bt_sk(sk)->parent; 1341 parent = bt_sk(sk)->parent;
1342 if (parent) 1342 if (parent)
1343 parent->sk_data_ready(parent, 0); 1343 parent->sk_data_ready(parent);
1344 1344
1345 release_sock(sk); 1345 release_sock(sk);
1346} 1346}