Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6c640d9 authored by DC Xu's avatar DC Xu Committed by dcxu
Browse files

L2CAP: Add log for exception code branching and rewrite p_ccb check in

l2c_link_sec_comp()

Bug: 317482448
Bug: 326686472
Test: atest l2cap | manual test

Change-Id: Id38694d6a85a58bc7a48f7ecf66062e6e56df5ec
parent c3aa1ff8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -645,6 +645,7 @@ cc_fuzz {
        "l2cap/*.cc",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "libbluetooth-types",
        "libbluetooth_hci_pdl",
        "libbluetooth_l2cap_pdl",
@@ -655,6 +656,9 @@ cc_fuzz {
        "libbt_shim_ffi",
        "libgmock",
    ],
    shared_libs: [
        "server_configurable_flags",
    ],
    target: {
        android: {
            shared_libs: [
+52 −18
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
 ******************************************************************************/
#define LOG_TAG "l2c_link"

#include <android_bluetooth_flags.h>
#include <bluetooth/log.h>

#include <cstdint>
@@ -214,6 +215,38 @@ void l2c_link_sec_comp(const RawAddress* p_bda,
    return;
  }

  if (IS_FLAG_ENABLED(l2cap_p_ccb_check_rewrite)) {
    if (!p_ref_data) {
      log::warn("Argument p_ref_data is NULL");
      return;
    }

    /* Match p_ccb with p_ref_data returned by sec manager */
    p_ccb = (tL2C_CCB*)p_ref_data;

    if (p_lcb != p_ccb->p_lcb) {
      log::warn("p_ref_data doesn't match with sec manager record");
      return;
    }

    switch (status) {
      case BTM_SUCCESS:
        l2c_csm_execute(p_ccb, L2CEVT_SEC_COMP, &ci);
        break;

      case BTM_DELAY_CHECK:
        /* start a timer - encryption change not received before L2CAP connect
         * req */
        alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
                           L2CAP_DELAY_CHECK_SM4_TIMEOUT_MS,
                           l2c_ccb_timer_timeout, p_ccb);
        return;

      default:
        l2c_csm_execute(p_ccb, L2CEVT_SEC_COMP_NEG, &ci);
        break;
    }
  } else {
    /* Match p_ccb with p_ref_data returned by sec manager */
    for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_next_ccb) {
      p_next_ccb = p_ccb->p_next_ccb;
@@ -225,8 +258,8 @@ void l2c_link_sec_comp(const RawAddress* p_bda,
            break;

          case BTM_DELAY_CHECK:
          /* start a timer - encryption change not received before L2CAP connect
           * req */
            /* start a timer - encryption change not received before L2CAP
             * connect req */
            alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
                               L2CAP_DELAY_CHECK_SM4_TIMEOUT_MS,
                               l2c_ccb_timer_timeout, p_ccb);
@@ -239,6 +272,7 @@ void l2c_link_sec_comp(const RawAddress* p_bda,
      }
    }
  }
}

/*******************************************************************************
**