Skip to content

Commit 0cf88a0

Browse files
author
Michael Scott
committed
bluetooth: 6lowpan: remove status from skb_cb struct
A status field in the skb_cb struct was storing a channel status based on channel suspend/resume events. This stored status was then used to return EAGAIN if there were packet sending issues in snd_pkt(). The issue is that the skb has been freed by the time the callback to 6lowpan's suspend/resume was called. So, this generates a "use after free" issue that was noticed while running kernel tests with KASAN debug enabled. Let's eliminate the status field entirely as we can use the channel tx_credits to indicate whether we should return EAGAIN when handling packets. Signed-off-by: Michael Scott <[email protected]>
1 parent 80f040d commit 0cf88a0

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

net/bluetooth/6lowpan.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ struct skb_cb {
3838
struct in6_addr addr;
3939
struct in6_addr gw;
4040
struct l2cap_chan *chan;
41-
int status;
4241
};
4342
#define lowpan_cb(skb) ((struct skb_cb *)((skb)->cb))
4443

@@ -528,7 +527,7 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb,
528527
}
529528

530529
if (!err)
531-
err = lowpan_cb(skb)->status;
530+
err = (!chan->tx_credits ? -EAGAIN : 0);
532531

533532
if (err < 0) {
534533
if (err == -EAGAIN)
@@ -964,26 +963,12 @@ static struct sk_buff *chan_alloc_skb_cb(struct l2cap_chan *chan,
964963

965964
static void chan_suspend_cb(struct l2cap_chan *chan)
966965
{
967-
struct sk_buff *skb = chan->data;
968-
969-
BT_DBG("chan %p conn %p skb %p", chan, chan->conn, skb);
970-
971-
if (!skb)
972-
return;
973-
974-
lowpan_cb(skb)->status = -EAGAIN;
966+
BT_DBG("chan %p suspend", chan);
975967
}
976968

977969
static void chan_resume_cb(struct l2cap_chan *chan)
978970
{
979-
struct sk_buff *skb = chan->data;
980-
981-
BT_DBG("chan %p conn %p skb %p", chan, chan->conn, skb);
982-
983-
if (!skb)
984-
return;
985-
986-
lowpan_cb(skb)->status = 0;
971+
BT_DBG("chan %p resume", chan);
987972
}
988973

989974
static long chan_get_sndtimeo_cb(struct l2cap_chan *chan)

0 commit comments

Comments
 (0)