提交 32333edb 编写于 作者: V Vignesh Raman 提交者: Marcel Holtmann

Bluetooth: Avoid use of session socket after the session gets freed

The commits 08c30aca "Bluetooth: Remove
RFCOMM session refcnt" and 8ff52f7d
"Bluetooth: Return RFCOMM session ptrs to avoid freed session"
allow rfcomm_recv_ua and rfcomm_session_close to delete the session
(and free the corresponding socket) and propagate NULL session pointer
to the upper callers.

Additional fix is required to terminate the loop in rfcomm_process_rx
function to avoid use of freed 'sk' memory.

The issue is only reproducible with kernel option CONFIG_PAGE_POISONING
enabled making freed memory being changed and filled up with fixed char
value used to unmask use-after-free issues.
Signed-off-by: NVignesh Raman <Vignesh_Raman@mentor.com>
Signed-off-by: NVitaly Kuzmichev <Vitaly_Kuzmichev@mentor.com>
Acked-by: NDean Jenkins <Dean_Jenkins@mentor.com>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
Cc: stable@vger.kernel.org
上级 c2aef6e8
......@@ -1910,10 +1910,13 @@ static struct rfcomm_session *rfcomm_process_rx(struct rfcomm_session *s)
/* Get data directly from socket receive queue without copying it. */
while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
skb_orphan(skb);
if (!skb_linearize(skb))
if (!skb_linearize(skb)) {
s = rfcomm_recv_frame(s, skb);
else
if (!s)
break;
} else {
kfree_skb(skb);
}
}
if (s && (sk->sk_state == BT_CLOSED))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册