Blame SOURCES/CVE-2022-42896.patch

edb02f
From 5fe8bfedd40a614374fdcb430694de00aedae2c5 Mon Sep 17 00:00:00 2001
edb02f
From: Joe Lawrence <joe.lawrence@redhat.com>
edb02f
Date: Thu, 18 Jan 2024 09:42:47 -0500
edb02f
Subject: [KPATCH CVE-2022-42896] kpatch fixes for CVE-2022-42896
edb02f
MIME-Version: 1.0
edb02f
Content-Type: text/plain; charset=UTF-8
edb02f
Content-Transfer-Encoding: 8bit
edb02f
edb02f
Kernels:
edb02f
3.10.0-1160.95.1.el7
edb02f
3.10.0-1160.99.1.el7
edb02f
3.10.0-1160.102.1.el7
edb02f
3.10.0-1160.105.1.el7
edb02f
edb02f
edb02f
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/66
edb02f
Changes since last build:
edb02f
[x86_64]:
edb02f
igb_main.o: changed function: igb_configure
edb02f
l2cap_core.o: changed function: l2cap_chan_hold
edb02f
l2cap_core.o: changed function: l2cap_conn_get
edb02f
l2cap_core.o: changed function: l2cap_global_chan_by_psm
edb02f
l2cap_core.o: changed function: l2cap_recv_frame
edb02f
l2cap_core.o: new function: klp_l2cap_le_sig_cmd
edb02f
sch_atm.o: changed function: atm_tc_peek
edb02f
sch_atm.o: changed function: sch_atm_dequeue
edb02f
sch_drr.o: changed function: drr_dequeue
edb02f
sch_dsmark.o: changed function: dsmark_peek
edb02f
sch_hfsc.o: changed function: hfsc_enqueue
edb02f
sch_hfsc.o: changed function: qdisc_peek_len
edb02f
sch_multiq.o: changed function: multiq_peek
edb02f
sch_prio.o: changed function: prio_peek
edb02f
sch_qfq.o: changed function: qfq_change_class
edb02f
sch_qfq.o: changed function: qfq_dequeue
edb02f
sch_red.o: changed function: red_peek
edb02f
sch_sfb.o: changed function: sfb_peek
edb02f
sch_tbf.o: changed function: tbf_dequeue
edb02f
edb02f
[ppc64le]:
edb02f
l2cap_core.o: changed function: __l2cap_chan_add
edb02f
l2cap_core.o: changed function: __l2cap_physical_cfm
edb02f
l2cap_core.o: changed function: __set_monitor_timer
edb02f
l2cap_core.o: changed function: __set_retrans_timer.part.24
edb02f
l2cap_core.o: changed function: l2cap_ack_timeout
edb02f
l2cap_core.o: changed function: l2cap_build_conf_req
edb02f
l2cap_core.o: changed function: l2cap_chan_busy
edb02f
l2cap_core.o: changed function: l2cap_chan_close
edb02f
l2cap_core.o: changed function: l2cap_chan_connect
edb02f
l2cap_core.o: changed function: l2cap_chan_del
edb02f
l2cap_core.o: changed function: l2cap_chan_hold
edb02f
l2cap_core.o: changed function: l2cap_chan_put
edb02f
l2cap_core.o: changed function: l2cap_chan_send
edb02f
l2cap_core.o: changed function: l2cap_chan_timeout
edb02f
l2cap_core.o: changed function: l2cap_conn_add.part.28
edb02f
l2cap_core.o: changed function: l2cap_conn_del
edb02f
l2cap_core.o: changed function: l2cap_conn_start
edb02f
l2cap_core.o: changed function: l2cap_connect
edb02f
l2cap_core.o: changed function: l2cap_connect_cfm
edb02f
l2cap_core.o: changed function: l2cap_connect_create_rsp
edb02f
l2cap_core.o: changed function: l2cap_data_channel
edb02f
l2cap_core.o: changed function: l2cap_disconn_cfm
edb02f
l2cap_core.o: changed function: l2cap_do_create
edb02f
l2cap_core.o: changed function: l2cap_do_start
edb02f
l2cap_core.o: changed function: l2cap_ertm_resend
edb02f
l2cap_core.o: changed function: l2cap_ertm_send
edb02f
l2cap_core.o: changed function: l2cap_global_fixed_chan
edb02f
l2cap_core.o: changed function: l2cap_handle_rej
edb02f
l2cap_core.o: changed function: l2cap_handle_srej
edb02f
l2cap_core.o: changed function: l2cap_logical_cfm
edb02f
l2cap_core.o: changed function: l2cap_monitor_timeout
edb02f
l2cap_core.o: changed function: l2cap_move_done
edb02f
l2cap_core.o: changed function: l2cap_move_setup
edb02f
l2cap_core.o: changed function: l2cap_parse_conf_rsp.constprop.36
edb02f
l2cap_core.o: changed function: l2cap_pass_to_tx
edb02f
l2cap_core.o: changed function: l2cap_process_reqseq
edb02f
l2cap_core.o: changed function: l2cap_recv_frame
edb02f
l2cap_core.o: changed function: l2cap_retrans_timeout
edb02f
l2cap_core.o: changed function: l2cap_retransmit_all
edb02f
l2cap_core.o: changed function: l2cap_rx
edb02f
l2cap_core.o: changed function: l2cap_rx_state_recv
edb02f
l2cap_core.o: changed function: l2cap_security_cfm
edb02f
l2cap_core.o: changed function: l2cap_send_ack
edb02f
l2cap_core.o: changed function: l2cap_send_efs_conf_rsp
edb02f
l2cap_core.o: changed function: l2cap_send_i_or_rr_or_rnr
edb02f
l2cap_core.o: changed function: l2cap_send_move_chan_cfm
edb02f
l2cap_core.o: changed function: l2cap_send_move_chan_cfm_icid
edb02f
l2cap_core.o: changed function: l2cap_send_move_chan_req
edb02f
l2cap_core.o: changed function: l2cap_send_rr_or_rnr
edb02f
l2cap_core.o: changed function: l2cap_send_sframe
edb02f
l2cap_core.o: changed function: l2cap_send_srej
edb02f
l2cap_core.o: changed function: l2cap_send_srej_tail
edb02f
l2cap_core.o: changed function: l2cap_start_connection
edb02f
l2cap_core.o: new function: l2cap_connect_req
edb02f
sch_atm.o: changed function: atm_tc_bind_filter
edb02f
sch_atm.o: changed function: atm_tc_change
edb02f
sch_atm.o: changed function: atm_tc_delete
edb02f
sch_atm.o: changed function: atm_tc_destroy
edb02f
sch_atm.o: changed function: atm_tc_enqueue
edb02f
sch_atm.o: changed function: atm_tc_find
edb02f
sch_atm.o: changed function: atm_tc_graft
edb02f
sch_atm.o: changed function: atm_tc_leaf
edb02f
sch_atm.o: changed function: atm_tc_peek
edb02f
sch_atm.o: changed function: atm_tc_put
edb02f
sch_atm.o: changed function: atm_tc_reset
edb02f
sch_atm.o: changed function: atm_tc_tcf_block
edb02f
sch_atm.o: changed function: sch_atm_dequeue
edb02f
sch_drr.o: changed function: drr_dequeue
edb02f
sch_dsmark.o: changed function: dsmark_bind_filter
edb02f
sch_dsmark.o: changed function: dsmark_change
edb02f
sch_dsmark.o: changed function: dsmark_destroy
edb02f
sch_dsmark.o: changed function: dsmark_dump_class
edb02f
sch_dsmark.o: changed function: dsmark_init
edb02f
sch_dsmark.o: changed function: dsmark_peek
edb02f
sch_dsmark.o: changed function: dsmark_reset
edb02f
sch_hfsc.o: changed function: hfsc_change_class
edb02f
sch_hfsc.o: changed function: hfsc_dequeue
edb02f
sch_hfsc.o: changed function: hfsc_enqueue
edb02f
sch_multiq.o: changed function: multiq_peek
edb02f
sch_prio.o: changed function: prio_peek
edb02f
sch_qfq.o: changed function: qfq_change_class
edb02f
sch_qfq.o: changed function: qfq_dequeue
edb02f
sch_red.o: changed function: red_peek
edb02f
sch_sfb.o: changed function: sfb_peek
edb02f
sch_tbf.o: changed function: tbf_dequeue
edb02f
edb02f
---------------------------
edb02f
edb02f
Modifications:
edb02f
- function l2cap_le_sig_cmd has no fentry/mcount call, so add a "klp_"
edb02f
  prefix to the patched version and its callers
edb02f
- for ppc64le, add __attribute__((optimize("-fno-optimize-sibling-calls")))
edb02f
    l2cap_chan_hold()
edb02f
    l2cap_disconn_cfm()
edb02f
    l2cap_handle_rej()
edb02f
    l2cap_handle_srej()
edb02f
    l2cap_monitor_timeout()
edb02f
    l2cap_pass_to_tx()
edb02f
    l2cap_retransmit_all()
edb02f
    l2cap_send_efs_conf_rsp()
edb02f
    l2cap_send_sframe()
edb02f
edb02f
commit d8f15b60a96ba8ce5d3d55518eb939d9bebd87a9
edb02f
Author: David Marlin <dmarlin@redhat.com>
edb02f
Date:   Tue Jan 9 23:44:57 2024 -0600
edb02f
edb02f
    Bluetooth: L2CAP: Fix L2CAP_CR_SCID_IN_USE value
edb02f
edb02f
    JIRA: https://issues.redhat.com/browse/RHEL-2742
edb02f
    CVE: CVE-2022-42896
edb02f
edb02f
    commit d8edd9ed156a1a840f1b1c2dbbf458684d6eea6e
edb02f
    Author: Marcin Kraglak <marcin.kraglak@tieto.com>
edb02f
    Date:   Wed Mar 8 14:09:41 2017 +0100
edb02f
edb02f
        Bluetooth: L2CAP: Fix L2CAP_CR_SCID_IN_USE value
edb02f
edb02f
        Fix issue found during L2CAP qualification test TP/LE/CFC/BV-20-C.
edb02f
edb02f
        Signed-off-by: Marcin Kraglak <marcin.kraglak@tieto.com>
edb02f
        Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
edb02f
edb02f
    Signed-off-by: David Marlin <dmarlin@redhat.com>
edb02f
edb02f
commit ae6cdce73d24b5cdccb89f88552bd6a9074f0aed
edb02f
Author: David Marlin <dmarlin@redhat.com>
edb02f
Date:   Tue Jan 9 23:45:05 2024 -0600
edb02f
edb02f
    Bluetooth: Use separate L2CAP LE credit based connection result values
edb02f
edb02f
    JIRA: https://issues.redhat.com/browse/RHEL-2742
edb02f
    CVE: CVE-2022-42896
edb02f
edb02f
    commit 571f739083e2544b343b5998608de679519de4e9
edb02f
    Author: Mallikarjun Phulari <mallikarjun.phulari@intel.com>
edb02f
    Date:   Fri Oct 5 14:48:12 2018 +0530
edb02f
edb02f
        Bluetooth: Use separate L2CAP LE credit based connection result values
edb02f
edb02f
        Add the result values specific to L2CAP LE credit based connections
edb02f
        and change the old result values wherever they were used.
edb02f
edb02f
        Signed-off-by: Mallikarjun Phulari <mallikarjun.phulari@intel.com>
edb02f
        Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
edb02f
edb02f
    Signed-off-by: David Marlin <dmarlin@redhat.com>
edb02f
edb02f
commit b45513e7819c6d7fe8bcd8bcf94670e0da9cc949
edb02f
Author: David Marlin <dmarlin@redhat.com>
edb02f
Date:   Tue Jan 9 23:46:25 2024 -0600
edb02f
edb02f
    Bluetooth: L2CAP: Fix accepting connection request for invalid SPSM
edb02f
edb02f
    JIRA: https://issues.redhat.com/browse/RHEL-2742
edb02f
edb02f
    CVE: CVE-2022-42896
edb02f
edb02f
    Conflicts:
edb02f
    Our 3.10 tree does not include support for Bluetooth Enhanced Credit Based Mode,
edb02f
    so omit hunk #2 of:
edb02f
      711f8c3fb3db  Bluetooth: L2CAP: Fix accepting connection request for invalid SPSM
edb02f
edb02f
    commit 711f8c3fb3db61897080468586b970c87c61d9e4
edb02f
    Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
edb02f
    Date:   Mon Oct 31 16:10:32 2022 -0700
edb02f
edb02f
        Bluetooth: L2CAP: Fix accepting connection request for invalid SPSM
edb02f
edb02f
        The Bluetooth spec states that the valid range for SPSM is from
edb02f
        0x0001-0x00ff so it is invalid to accept values outside of this range:
edb02f
edb02f
          BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 3, Part A
edb02f
          page 1059:
edb02f
          Table 4.15: L2CAP_LE_CREDIT_BASED_CONNECTION_REQ SPSM ranges
edb02f
edb02f
        CVE: CVE-2022-42896
edb02f
        CC: stable@vger.kernel.org
edb02f
        Reported-by: Tamás Koczka <poprdi@google.com>
edb02f
        Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
edb02f
        Reviewed-by: Tedd Ho-Jeong An <tedd.an@intel.com>
edb02f
edb02f
    Signed-off-by: David Marlin <dmarlin@redhat.com>
edb02f
edb02f
commit a766b7a5d576eb559319776f8fa400f00128937e
edb02f
Author: David Marlin <dmarlin@redhat.com>
edb02f
Date:   Tue Jan 9 23:47:13 2024 -0600
edb02f
edb02f
    Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm
edb02f
edb02f
    JIRA: https://issues.redhat.com/browse/RHEL-2742
edb02f
    CVE: CVE-2022-42896
edb02f
edb02f
    commit f937b758a188d6fd328a81367087eddbb2fce50f
edb02f
    Author: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
edb02f
    Date:   Mon Oct 31 16:10:33 2022 -0700
edb02f
edb02f
        Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm
edb02f
edb02f
        l2cap_global_chan_by_psm shall not return fixed channels as they are not
edb02f
        meant to be connected by (S)PSM.
edb02f
edb02f
        Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
edb02f
        Reviewed-by: Tedd Ho-Jeong An <tedd.an@intel.com>
edb02f
edb02f
    Signed-off-by: David Marlin <dmarlin@redhat.com>
edb02f
edb02f
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
edb02f
---
edb02f
 include/net/bluetooth/l2cap.h | 17 +++++++----
edb02f
 net/bluetooth/l2cap_core.c    | 55 +++++++++++++++++++++++++----------
edb02f
 2 files changed, 50 insertions(+), 22 deletions(-)
edb02f
edb02f
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
edb02f
index 45f3a951974c..1b0dfbb0eb82 100644
edb02f
--- a/include/net/bluetooth/l2cap.h
edb02f
+++ b/include/net/bluetooth/l2cap.h
edb02f
@@ -277,12 +277,17 @@ struct l2cap_conn_rsp {
edb02f
 #define L2CAP_CR_SEC_BLOCK	0x0003
edb02f
 #define L2CAP_CR_NO_MEM		0x0004
edb02f
 #define L2CAP_CR_BAD_AMP	0x0005
edb02f
-#define L2CAP_CR_AUTHENTICATION	0x0005
edb02f
-#define L2CAP_CR_AUTHORIZATION	0x0006
edb02f
-#define L2CAP_CR_BAD_KEY_SIZE	0x0007
edb02f
-#define L2CAP_CR_ENCRYPTION	0x0008
edb02f
-#define L2CAP_CR_INVALID_SCID	0x0009
edb02f
-#define L2CAP_CR_SCID_IN_USE	0x0010
edb02f
+
edb02f
+/* credit based connect results */
edb02f
+#define L2CAP_CR_LE_SUCCESS		0x0000
edb02f
+#define L2CAP_CR_LE_BAD_PSM		0x0002
edb02f
+#define L2CAP_CR_LE_NO_MEM		0x0004
edb02f
+#define L2CAP_CR_LE_AUTHENTICATION	0x0005
edb02f
+#define L2CAP_CR_LE_AUTHORIZATION	0x0006
edb02f
+#define L2CAP_CR_LE_BAD_KEY_SIZE	0x0007
edb02f
+#define L2CAP_CR_LE_ENCRYPTION		0x0008
edb02f
+#define L2CAP_CR_LE_INVALID_SCID	0x0009
edb02f
+#define L2CAP_CR_LE_SCID_IN_USE		0X000A
edb02f
 
edb02f
 /* connect/create channel status */
edb02f
 #define L2CAP_CS_NO_INFO	0x0000
edb02f
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
edb02f
index 4338810b0d58..a3bed86517e7 100644
edb02f
--- a/net/bluetooth/l2cap_core.c
edb02f
+++ b/net/bluetooth/l2cap_core.c
edb02f
@@ -480,6 +480,7 @@ static void l2cap_chan_destroy(struct kref *kref)
edb02f
 	kfree(chan);
edb02f
 }
edb02f
 
edb02f
+__attribute__((optimize("-fno-optimize-sibling-calls")))
edb02f
 void l2cap_chan_hold(struct l2cap_chan *c)
edb02f
 {
edb02f
 	BT_DBG("chan %p orig refcnt %d", c, kref_read(&c->kref));
edb02f
@@ -682,9 +683,9 @@ static void l2cap_chan_le_connect_reject(struct l2cap_chan *chan)
edb02f
 	u16 result;
edb02f
 
edb02f
 	if (test_bit(FLAG_DEFER_SETUP, &chan->flags))
edb02f
-		result = L2CAP_CR_AUTHORIZATION;
edb02f
+		result = L2CAP_CR_LE_AUTHORIZATION;
edb02f
 	else
edb02f
-		result = L2CAP_CR_BAD_PSM;
edb02f
+		result = L2CAP_CR_LE_BAD_PSM;
edb02f
 
edb02f
 	l2cap_state_change(chan, BT_DISCONN);
edb02f
 
edb02f
@@ -1067,6 +1068,7 @@ static struct sk_buff *l2cap_create_sframe_pdu(struct l2cap_chan *chan,
edb02f
 	return skb;
edb02f
 }
edb02f
 
edb02f
+__attribute__((optimize("-fno-optimize-sibling-calls")))
edb02f
 static void l2cap_send_sframe(struct l2cap_chan *chan,
edb02f
 			      struct l2cap_ctrl *control)
edb02f
 {
edb02f
@@ -1792,7 +1794,7 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm,
edb02f
 		if (link_type == LE_LINK && c->src_type == BDADDR_BREDR)
edb02f
 			continue;
edb02f
 
edb02f
-		if (c->psm == psm) {
edb02f
+		if (c->chan_type != L2CAP_CHAN_FIXED && c->psm == psm) {
edb02f
 			int src_match, dst_match;
edb02f
 			int src_any, dst_any;
edb02f
 
edb02f
@@ -1822,6 +1824,7 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm,
edb02f
 	return c1;
edb02f
 }
edb02f
 
edb02f
+__attribute__((optimize("-fno-optimize-sibling-calls")))
edb02f
 static void l2cap_monitor_timeout(struct work_struct *work)
edb02f
 {
edb02f
 	struct l2cap_chan *chan = container_of(work, struct l2cap_chan,
edb02f
@@ -2062,6 +2065,7 @@ static void l2cap_retransmit(struct l2cap_chan *chan,
edb02f
 	l2cap_ertm_resend(chan);
edb02f
 }
edb02f
 
edb02f
+__attribute__((optimize("-fno-optimize-sibling-calls")))
edb02f
 static void l2cap_retransmit_all(struct l2cap_chan *chan,
edb02f
 				 struct l2cap_ctrl *control)
edb02f
 {
edb02f
@@ -2862,6 +2866,7 @@ static void l2cap_tx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
edb02f
 	}
edb02f
 }
edb02f
 
edb02f
+__attribute__((optimize("-fno-optimize-sibling-calls")))
edb02f
 static void l2cap_pass_to_tx(struct l2cap_chan *chan,
edb02f
 			     struct l2cap_ctrl *control)
edb02f
 {
edb02f
@@ -3702,7 +3707,7 @@ void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan)
edb02f
 	rsp.mtu     = cpu_to_le16(chan->imtu);
edb02f
 	rsp.mps     = cpu_to_le16(chan->mps);
edb02f
 	rsp.credits = cpu_to_le16(chan->rx_credits);
edb02f
-	rsp.result  = cpu_to_le16(L2CAP_CR_SUCCESS);
edb02f
+	rsp.result  = cpu_to_le16(L2CAP_CR_LE_SUCCESS);
edb02f
 
edb02f
 	l2cap_send_cmd(conn, chan->ident, L2CAP_LE_CONN_RSP, sizeof(rsp),
edb02f
 		       &rsp;;
edb02f
@@ -4055,6 +4060,8 @@ static inline void set_default_fcs(struct l2cap_chan *chan)
edb02f
 		chan->fcs = L2CAP_FCS_CRC16;
edb02f
 }
edb02f
 
edb02f
+
edb02f
+__attribute__((optimize("-fno-optimize-sibling-calls")))
edb02f
 static void l2cap_send_efs_conf_rsp(struct l2cap_chan *chan, void *data,
edb02f
 				    u8 ident, u16 flags)
edb02f
 {
edb02f
@@ -5318,7 +5325,7 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
edb02f
 	credits = __le16_to_cpu(rsp->credits);
edb02f
 	result  = __le16_to_cpu(rsp->result);
edb02f
 
edb02f
-	if (result == L2CAP_CR_SUCCESS && (mtu < 23 || mps < 23 ||
edb02f
+	if (result == L2CAP_CR_LE_SUCCESS && (mtu < 23 || mps < 23 ||
edb02f
 					   dcid < L2CAP_CID_DYN_START ||
edb02f
 					   dcid > L2CAP_CID_LE_DYN_END))
edb02f
 		return -EPROTO;
edb02f
@@ -5339,7 +5346,7 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
edb02f
 	l2cap_chan_lock(chan);
edb02f
 
edb02f
 	switch (result) {
edb02f
-	case L2CAP_CR_SUCCESS:
edb02f
+	case L2CAP_CR_LE_SUCCESS:
edb02f
 		if (__l2cap_get_chan_by_dcid(conn, dcid)) {
edb02f
 			err = -EBADSLT;
edb02f
 			break;
edb02f
@@ -5353,8 +5360,8 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
edb02f
 		l2cap_chan_ready(chan);
edb02f
 		break;
edb02f
 
edb02f
-	case L2CAP_CR_AUTHENTICATION:
edb02f
-	case L2CAP_CR_ENCRYPTION:
edb02f
+	case L2CAP_CR_LE_AUTHENTICATION:
edb02f
+	case L2CAP_CR_LE_ENCRYPTION:
edb02f
 		/* If we already have MITM protection we can't do
edb02f
 		 * anything.
edb02f
 		 */
edb02f
@@ -5493,11 +5500,24 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
edb02f
 	BT_DBG("psm 0x%2.2x scid 0x%4.4x mtu %u mps %u", __le16_to_cpu(psm),
edb02f
 	       scid, mtu, mps);
edb02f
 
edb02f
+	/* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 3, Part A
edb02f
+	 * page 1059:
edb02f
+	 *
edb02f
+	 * Valid range: 0x0001-0x00ff
edb02f
+	 *
edb02f
+	 * Table 4.15: L2CAP_LE_CREDIT_BASED_CONNECTION_REQ SPSM ranges
edb02f
+	 */
edb02f
+	if (!psm || __le16_to_cpu(psm) > L2CAP_PSM_LE_DYN_END) {
edb02f
+		result = L2CAP_CR_LE_BAD_PSM;
edb02f
+		chan = NULL;
edb02f
+		goto response;
edb02f
+	}
edb02f
+
edb02f
 	/* Check if we have socket listening on psm */
edb02f
 	pchan = l2cap_global_chan_by_psm(BT_LISTEN, psm, &conn->hcon->src,
edb02f
 					 &conn->hcon->dst, LE_LINK);
edb02f
 	if (!pchan) {
edb02f
-		result = L2CAP_CR_BAD_PSM;
edb02f
+		result = L2CAP_CR_LE_BAD_PSM;
edb02f
 		chan = NULL;
edb02f
 		goto response;
edb02f
 	}
edb02f
@@ -5507,28 +5527,28 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
edb02f
 
edb02f
 	if (!smp_sufficient_security(conn->hcon, pchan->sec_level,
edb02f
 				     SMP_ALLOW_STK)) {
edb02f
-		result = L2CAP_CR_AUTHENTICATION;
edb02f
+		result = L2CAP_CR_LE_AUTHENTICATION;
edb02f
 		chan = NULL;
edb02f
 		goto response_unlock;
edb02f
 	}
edb02f
 
edb02f
 	/* Check for valid dynamic CID range */
edb02f
 	if (scid < L2CAP_CID_DYN_START || scid > L2CAP_CID_LE_DYN_END) {
edb02f
-		result = L2CAP_CR_INVALID_SCID;
edb02f
+		result = L2CAP_CR_LE_INVALID_SCID;
edb02f
 		chan = NULL;
edb02f
 		goto response_unlock;
edb02f
 	}
edb02f
 
edb02f
 	/* Check if we already have channel with that dcid */
edb02f
 	if (__l2cap_get_chan_by_dcid(conn, scid)) {
edb02f
-		result = L2CAP_CR_SCID_IN_USE;
edb02f
+		result = L2CAP_CR_LE_SCID_IN_USE;
edb02f
 		chan = NULL;
edb02f
 		goto response_unlock;
edb02f
 	}
edb02f
 
edb02f
 	chan = pchan->ops->new_connection(pchan);
edb02f
 	if (!chan) {
edb02f
-		result = L2CAP_CR_NO_MEM;
edb02f
+		result = L2CAP_CR_LE_NO_MEM;
edb02f
 		goto response_unlock;
edb02f
 	}
edb02f
 
edb02f
@@ -5563,7 +5583,7 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
edb02f
 		chan->ops->defer(chan);
edb02f
 	} else {
edb02f
 		l2cap_chan_ready(chan);
edb02f
-		result = L2CAP_CR_SUCCESS;
edb02f
+		result = L2CAP_CR_LE_SUCCESS;
edb02f
 	}
edb02f
 
edb02f
 response_unlock:
edb02f
@@ -5665,7 +5685,7 @@ done:
edb02f
 	return 0;
edb02f
 }
edb02f
 
edb02f
-static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn,
edb02f
+static inline int klp_l2cap_le_sig_cmd(struct l2cap_conn *conn,
edb02f
 				   struct l2cap_cmd_hdr *cmd, u16 cmd_len,
edb02f
 				   u8 *data)
edb02f
 {
edb02f
@@ -5738,7 +5758,7 @@ static inline void l2cap_le_sig_channel(struct l2cap_conn *conn,
edb02f
 		goto drop;
edb02f
 	}
edb02f
 
edb02f
-	err = l2cap_le_sig_cmd(conn, cmd, len, skb->data);
edb02f
+	err = klp_l2cap_le_sig_cmd(conn, cmd, len, skb->data);
edb02f
 	if (err) {
edb02f
 		struct l2cap_cmd_rej_unk rej;
edb02f
 
edb02f
@@ -6012,6 +6032,7 @@ static int l2cap_rx_queued_iframes(struct l2cap_chan *chan)
edb02f
 	return err;
edb02f
 }
edb02f
 
edb02f
+__attribute__((optimize("-fno-optimize-sibling-calls")))
edb02f
 static void l2cap_handle_srej(struct l2cap_chan *chan,
edb02f
 			      struct l2cap_ctrl *control)
edb02f
 {
edb02f
@@ -6070,6 +6091,7 @@ static void l2cap_handle_srej(struct l2cap_chan *chan,
edb02f
 	}
edb02f
 }
edb02f
 
edb02f
+__attribute__((optimize("-fno-optimize-sibling-calls")))
edb02f
 static void l2cap_handle_rej(struct l2cap_chan *chan,
edb02f
 			     struct l2cap_ctrl *control)
edb02f
 {
edb02f
@@ -7442,6 +7464,7 @@ int l2cap_disconn_ind(struct hci_conn *hcon)
edb02f
 	return conn->disc_reason;
edb02f
 }
edb02f
 
edb02f
+__attribute__((optimize("-fno-optimize-sibling-calls")))
edb02f
 static void l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason)
edb02f
 {
edb02f
 	if (hcon->type != ACL_LINK && hcon->type != LE_LINK)
edb02f
-- 
edb02f
2.44.0
edb02f
edb02f