|
|
81ae6d |
From 6b5f1ddf8fdf04b977a2523a103d03e807fc0471 Mon Sep 17 00:00:00 2001
|
|
|
81ae6d |
From: Ryan Sullivan <rysulliv@redhat.com>
|
|
|
81ae6d |
Date: Mon, 23 Jan 2023 11:48:28 -0500
|
|
|
81ae6d |
Subject: [KPATCH CVE-2022-3564] kpatch fixes for CVE-2022-3564
|
|
|
81ae6d |
|
|
|
81ae6d |
Kernels:
|
|
|
81ae6d |
5.14.0-162.6.1.el9_1
|
|
|
81ae6d |
|
|
|
81ae6d |
|
|
|
81ae6d |
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-9/-/merge_requests/16
|
|
|
81ae6d |
Approved-by: Joe Lawrence (@joe.lawrence)
|
|
|
81ae6d |
Approved-by: Yannick Cote (@ycote1)
|
|
|
81ae6d |
Changes since last build:
|
|
|
81ae6d |
arches: x86_64 ppc64le
|
|
|
81ae6d |
l2cap_core.o: changed function: l2cap_rx_state_recv
|
|
|
81ae6d |
l2cap_core.o: changed function: l2cap_stream_rx
|
|
|
81ae6d |
nfs4proc.o: changed function: nfsd4_copy
|
|
|
81ae6d |
nfs4proc.o: changed function: nfsd4_do_async_copy
|
|
|
81ae6d |
nft_payload.o: changed function: nft_payload_copy_vlan
|
|
|
81ae6d |
sysctl.o: changed function: __do_proc_dointvec
|
|
|
81ae6d |
sysctl.o: changed function: __do_proc_douintvec
|
|
|
81ae6d |
sysctl.o: changed function: __do_proc_doulongvec_minmax
|
|
|
81ae6d |
sysctl.o: changed function: proc_get_long.constprop.0
|
|
|
81ae6d |
---------------------------
|
|
|
81ae6d |
|
|
|
81ae6d |
Modifications: none
|
|
|
81ae6d |
|
|
|
81ae6d |
commit c4f4f4633ff2000f9f67db4271b8186939690908
|
|
|
81ae6d |
Author: Ricardo Robaina <rrobaina@redhat.com>
|
|
|
81ae6d |
Date: Wed Jan 11 14:57:13 2023 -0300
|
|
|
81ae6d |
|
|
|
81ae6d |
Bluetooth: L2CAP: Fix use-after-free caused by l2cap_reassemble_sdu
|
|
|
81ae6d |
|
|
|
81ae6d |
Bugzilla: https://bugzilla.redhat.com/2152929
|
|
|
81ae6d |
CVE: CVE-2022-3564
|
|
|
81ae6d |
Y-Commit: 7de3277fe8bf62a5af7d2758f1b13cea20541724
|
|
|
81ae6d |
|
|
|
81ae6d |
O-Bugzilla: https://bugzilla.redhat.com/2152931
|
|
|
81ae6d |
O-CVE: CVE-2022-3564
|
|
|
81ae6d |
|
|
|
81ae6d |
commit 3aff8aaca4e36dc8b17eaa011684881a80238966
|
|
|
81ae6d |
Author: Maxim Mikityanskiy <maxtram95@gmail.com>
|
|
|
81ae6d |
Date: Wed Oct 5 00:27:18 2022 +0300
|
|
|
81ae6d |
|
|
|
81ae6d |
Bluetooth: L2CAP: Fix use-after-free caused by l2cap_reassemble_sdu
|
|
|
81ae6d |
|
|
|
81ae6d |
Fix the race condition between the following two flows that run in
|
|
|
81ae6d |
parallel:
|
|
|
81ae6d |
|
|
|
81ae6d |
1. l2cap_reassemble_sdu -> chan->ops->recv (l2cap_sock_recv_cb) ->
|
|
|
81ae6d |
__sock_queue_rcv_skb.
|
|
|
81ae6d |
|
|
|
81ae6d |
2. bt_sock_recvmsg -> skb_recv_datagram, skb_free_datagram.
|
|
|
81ae6d |
|
|
|
81ae6d |
An SKB can be queued by the first flow and immediately dequeued and
|
|
|
81ae6d |
freed by the second flow, therefore the callers of l2cap_reassemble_sdu
|
|
|
81ae6d |
can't use the SKB after that function returns. However, some places
|
|
|
81ae6d |
continue accessing struct l2cap_ctrl that resides in the SKB's CB for a
|
|
|
81ae6d |
short time after l2cap_reassemble_sdu returns, leading to a
|
|
|
81ae6d |
use-after-free condition (the stack trace is below, line numbers for
|
|
|
81ae6d |
kernel 5.19.8).
|
|
|
81ae6d |
|
|
|
81ae6d |
Fix it by keeping a local copy of struct l2cap_ctrl.
|
|
|
81ae6d |
|
|
|
81ae6d |
BUG: KASAN: use-after-free in l2cap_rx_state_recv (net/bluetooth/l2cap_core.c:6906) bluetooth
|
|
|
81ae6d |
Read of size 1 at addr ffff88812025f2f0 by task kworker/u17:3/43169
|
|
|
81ae6d |
|
|
|
81ae6d |
Workqueue: hci0 hci_rx_work [bluetooth]
|
|
|
81ae6d |
Call Trace:
|
|
|
81ae6d |
<TASK>
|
|
|
81ae6d |
dump_stack_lvl (lib/dump_stack.c:107 (discriminator 4))
|
|
|
81ae6d |
print_report.cold (mm/kasan/report.c:314 mm/kasan/report.c:429)
|
|
|
81ae6d |
? l2cap_rx_state_recv (net/bluetooth/l2cap_core.c:6906) bluetooth
|
|
|
81ae6d |
kasan_report (mm/kasan/report.c:162 mm/kasan/report.c:493)
|
|
|
81ae6d |
? l2cap_rx_state_recv (net/bluetooth/l2cap_core.c:6906) bluetooth
|
|
|
81ae6d |
l2cap_rx_state_recv (net/bluetooth/l2cap_core.c:6906) bluetooth
|
|
|
81ae6d |
l2cap_rx (net/bluetooth/l2cap_core.c:7236 net/bluetooth/l2cap_core.c:7271) bluetooth
|
|
|
81ae6d |
ret_from_fork (arch/x86/entry/entry_64.S:306)
|
|
|
81ae6d |
</TASK>
|
|
|
81ae6d |
|
|
|
81ae6d |
Allocated by task 43169:
|
|
|
81ae6d |
kasan_save_stack (mm/kasan/common.c:39)
|
|
|
81ae6d |
__kasan_slab_alloc (mm/kasan/common.c:45 mm/kasan/common.c:436 mm/kasan/common.c:469)
|
|
|
81ae6d |
kmem_cache_alloc_node (mm/slab.h:750 mm/slub.c:3243 mm/slub.c:3293)
|
|
|
81ae6d |
__alloc_skb (net/core/skbuff.c:414)
|
|
|
81ae6d |
l2cap_recv_frag (./include/net/bluetooth/bluetooth.h:425 net/bluetooth/l2cap_core.c:8329) bluetooth
|
|
|
81ae6d |
l2cap_recv_acldata (net/bluetooth/l2cap_core.c:8442) bluetooth
|
|
|
81ae6d |
hci_rx_work (net/bluetooth/hci_core.c:3642 net/bluetooth/hci_core.c:3832) bluetooth
|
|
|
81ae6d |
process_one_work (kernel/workqueue.c:2289)
|
|
|
81ae6d |
worker_thread (./include/linux/list.h:292 kernel/workqueue.c:2437)
|
|
|
81ae6d |
kthread (kernel/kthread.c:376)
|
|
|
81ae6d |
ret_from_fork (arch/x86/entry/entry_64.S:306)
|
|
|
81ae6d |
|
|
|
81ae6d |
Freed by task 27920:
|
|
|
81ae6d |
kasan_save_stack (mm/kasan/common.c:39)
|
|
|
81ae6d |
kasan_set_track (mm/kasan/common.c:45)
|
|
|
81ae6d |
kasan_set_free_info (mm/kasan/generic.c:372)
|
|
|
81ae6d |
____kasan_slab_free (mm/kasan/common.c:368 mm/kasan/common.c:328)
|
|
|
81ae6d |
slab_free_freelist_hook (mm/slub.c:1780)
|
|
|
81ae6d |
kmem_cache_free (mm/slub.c:3536 mm/slub.c:3553)
|
|
|
81ae6d |
skb_free_datagram (./include/net/sock.h:1578 ./include/net/sock.h:1639 net/core/datagram.c:323)
|
|
|
81ae6d |
bt_sock_recvmsg (net/bluetooth/af_bluetooth.c:295) bluetooth
|
|
|
81ae6d |
l2cap_sock_recvmsg (net/bluetooth/l2cap_sock.c:1212) bluetooth
|
|
|
81ae6d |
sock_read_iter (net/socket.c:1087)
|
|
|
81ae6d |
new_sync_read (./include/linux/fs.h:2052 fs/read_write.c:401)
|
|
|
81ae6d |
vfs_read (fs/read_write.c:482)
|
|
|
81ae6d |
ksys_read (fs/read_write.c:620)
|
|
|
81ae6d |
do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80)
|
|
|
81ae6d |
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120)
|
|
|
81ae6d |
|
|
|
81ae6d |
Link: https://lore.kernel.org/linux-bluetooth/CAKErNvoqga1WcmoR3-0875esY6TVWFQDandbVZncSiuGPBQXLA@mail.gmail.com/T/#u
|
|
|
81ae6d |
Fixes: d2a7ac5d5d3a ("Bluetooth: Add the ERTM receive state machine")
|
|
|
81ae6d |
Fixes: 4b51dae96731 ("Bluetooth: Add streaming mode receive and incoming packet classifier")
|
|
|
81ae6d |
Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
|
|
|
81ae6d |
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
|
|
|
81ae6d |
|
|
|
81ae6d |
Signed-off-by: Ricardo Robaina <rrobaina@redhat.com>
|
|
|
81ae6d |
Signed-off-by: Patrick Talbert <ptalbert@redhat.com>
|
|
|
81ae6d |
|
|
|
81ae6d |
Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
|
|
|
81ae6d |
---
|
|
|
81ae6d |
net/bluetooth/l2cap_core.c | 48 ++++++++++++++++++++++++++++++++------
|
|
|
81ae6d |
1 file changed, 41 insertions(+), 7 deletions(-)
|
|
|
81ae6d |
|
|
|
81ae6d |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
|
|
|
81ae6d |
index e817ff0607a0..e95c1a019de9 100644
|
|
|
81ae6d |
--- a/net/bluetooth/l2cap_core.c
|
|
|
81ae6d |
+++ b/net/bluetooth/l2cap_core.c
|
|
|
81ae6d |
@@ -6842,6 +6842,7 @@ static int l2cap_rx_state_recv(struct l2cap_chan *chan,
|
|
|
81ae6d |
struct l2cap_ctrl *control,
|
|
|
81ae6d |
struct sk_buff *skb, u8 event)
|
|
|
81ae6d |
{
|
|
|
81ae6d |
+ struct l2cap_ctrl local_control;
|
|
|
81ae6d |
int err = 0;
|
|
|
81ae6d |
bool skb_in_use = false;
|
|
|
81ae6d |
|
|
|
81ae6d |
@@ -6866,15 +6867,32 @@ static int l2cap_rx_state_recv(struct l2cap_chan *chan,
|
|
|
81ae6d |
chan->buffer_seq = chan->expected_tx_seq;
|
|
|
81ae6d |
skb_in_use = true;
|
|
|
81ae6d |
|
|
|
81ae6d |
+ /* l2cap_reassemble_sdu may free skb, hence invalidate
|
|
|
81ae6d |
+ * control, so make a copy in advance to use it after
|
|
|
81ae6d |
+ * l2cap_reassemble_sdu returns and to avoid the race
|
|
|
81ae6d |
+ * condition, for example:
|
|
|
81ae6d |
+ *
|
|
|
81ae6d |
+ * The current thread calls:
|
|
|
81ae6d |
+ * l2cap_reassemble_sdu
|
|
|
81ae6d |
+ * chan->ops->recv == l2cap_sock_recv_cb
|
|
|
81ae6d |
+ * __sock_queue_rcv_skb
|
|
|
81ae6d |
+ * Another thread calls:
|
|
|
81ae6d |
+ * bt_sock_recvmsg
|
|
|
81ae6d |
+ * skb_recv_datagram
|
|
|
81ae6d |
+ * skb_free_datagram
|
|
|
81ae6d |
+ * Then the current thread tries to access control, but
|
|
|
81ae6d |
+ * it was freed by skb_free_datagram.
|
|
|
81ae6d |
+ */
|
|
|
81ae6d |
+ local_control = *control;
|
|
|
81ae6d |
err = l2cap_reassemble_sdu(chan, skb, control);
|
|
|
81ae6d |
if (err)
|
|
|
81ae6d |
break;
|
|
|
81ae6d |
|
|
|
81ae6d |
- if (control->final) {
|
|
|
81ae6d |
+ if (local_control.final) {
|
|
|
81ae6d |
if (!test_and_clear_bit(CONN_REJ_ACT,
|
|
|
81ae6d |
&chan->conn_state)) {
|
|
|
81ae6d |
- control->final = 0;
|
|
|
81ae6d |
- l2cap_retransmit_all(chan, control);
|
|
|
81ae6d |
+ local_control.final = 0;
|
|
|
81ae6d |
+ l2cap_retransmit_all(chan, &local_control);
|
|
|
81ae6d |
l2cap_ertm_send(chan);
|
|
|
81ae6d |
}
|
|
|
81ae6d |
}
|
|
|
81ae6d |
@@ -7254,11 +7272,27 @@ static int l2cap_rx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
|
|
|
81ae6d |
static int l2cap_stream_rx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
|
|
|
81ae6d |
struct sk_buff *skb)
|
|
|
81ae6d |
{
|
|
|
81ae6d |
+ /* l2cap_reassemble_sdu may free skb, hence invalidate control, so store
|
|
|
81ae6d |
+ * the txseq field in advance to use it after l2cap_reassemble_sdu
|
|
|
81ae6d |
+ * returns and to avoid the race condition, for example:
|
|
|
81ae6d |
+ *
|
|
|
81ae6d |
+ * The current thread calls:
|
|
|
81ae6d |
+ * l2cap_reassemble_sdu
|
|
|
81ae6d |
+ * chan->ops->recv == l2cap_sock_recv_cb
|
|
|
81ae6d |
+ * __sock_queue_rcv_skb
|
|
|
81ae6d |
+ * Another thread calls:
|
|
|
81ae6d |
+ * bt_sock_recvmsg
|
|
|
81ae6d |
+ * skb_recv_datagram
|
|
|
81ae6d |
+ * skb_free_datagram
|
|
|
81ae6d |
+ * Then the current thread tries to access control, but it was freed by
|
|
|
81ae6d |
+ * skb_free_datagram.
|
|
|
81ae6d |
+ */
|
|
|
81ae6d |
+ u16 txseq = control->txseq;
|
|
|
81ae6d |
+
|
|
|
81ae6d |
BT_DBG("chan %p, control %p, skb %p, state %d", chan, control, skb,
|
|
|
81ae6d |
chan->rx_state);
|
|
|
81ae6d |
|
|
|
81ae6d |
- if (l2cap_classify_txseq(chan, control->txseq) ==
|
|
|
81ae6d |
- L2CAP_TXSEQ_EXPECTED) {
|
|
|
81ae6d |
+ if (l2cap_classify_txseq(chan, txseq) == L2CAP_TXSEQ_EXPECTED) {
|
|
|
81ae6d |
l2cap_pass_to_tx(chan, control);
|
|
|
81ae6d |
|
|
|
81ae6d |
BT_DBG("buffer_seq %u->%u", chan->buffer_seq,
|
|
|
81ae6d |
@@ -7281,8 +7315,8 @@ static int l2cap_stream_rx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
|
|
|
81ae6d |
}
|
|
|
81ae6d |
}
|
|
|
81ae6d |
|
|
|
81ae6d |
- chan->last_acked_seq = control->txseq;
|
|
|
81ae6d |
- chan->expected_tx_seq = __next_seq(chan, control->txseq);
|
|
|
81ae6d |
+ chan->last_acked_seq = txseq;
|
|
|
81ae6d |
+ chan->expected_tx_seq = __next_seq(chan, txseq);
|
|
|
81ae6d |
|
|
|
81ae6d |
return 0;
|
|
|
81ae6d |
}
|
|
|
81ae6d |
--
|
|
|
81ae6d |
2.39.1
|
|
|
81ae6d |
|
|
|
81ae6d |
|