Bluetooth: L2CAP: Downgrade user_data API error to a warning

When user_data is not zeroed-out, the API returns an error. Downgrade
the API error to a warning log instead.

Introducing this check (#76489) broke a few PTS tests, as user_data is
not initialized by `net_buf_alloc()`. Doing so is in discussion:

https://github.com/zephyrproject-rtos/zephyr/issues/77088

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
This commit is contained in:
Jonathan Rico 2024-08-15 10:05:58 +02:00 committed by Anas Nashif
commit 6fa6c4c256
6 changed files with 4 additions and 46 deletions

View file

@ -3135,9 +3135,9 @@ static int bt_l2cap_dyn_chan_send(struct bt_l2cap_le_chan *le_chan, struct net_b
return -EINVAL; return -EINVAL;
} }
CHECKIF(user_data_not_empty(buf)) { if (user_data_not_empty(buf)) {
LOG_DBG("Please clear user_data first"); /* There may be issues if user_data is not empty. */
return -EINVAL; LOG_WRN("user_data is not empty");
} }
/* Prepend SDU length. /* Prepend SDU length.

View file

@ -14,7 +14,6 @@ app=tests/bsim/bluetooth/host/l2cap/many_conns compile
run_in_background ${ZEPHYR_BASE}/tests/bsim/bluetooth/host/l2cap/multilink_peripheral/compile.sh run_in_background ${ZEPHYR_BASE}/tests/bsim/bluetooth/host/l2cap/multilink_peripheral/compile.sh
app=tests/bsim/bluetooth/host/l2cap/general compile app=tests/bsim/bluetooth/host/l2cap/general compile
app=tests/bsim/bluetooth/host/l2cap/userdata compile app=tests/bsim/bluetooth/host/l2cap/userdata compile
app=tests/bsim/bluetooth/host/l2cap/userdata conf_file=prj_no_checks.conf compile
app=tests/bsim/bluetooth/host/l2cap/stress compile app=tests/bsim/bluetooth/host/l2cap/stress compile
app=tests/bsim/bluetooth/host/l2cap/stress conf_file=prj_nofrag.conf compile app=tests/bsim/bluetooth/host/l2cap/stress conf_file=prj_nofrag.conf compile
app=tests/bsim/bluetooth/host/l2cap/stress conf_file=prj_syswq.conf compile app=tests/bsim/bluetooth/host/l2cap/stress conf_file=prj_syswq.conf compile

View file

@ -1,16 +0,0 @@
CONFIG_BT=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_SMP=y
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
CONFIG_BT_L2CAP_ECRED=y
CONFIG_ASSERT=y
CONFIG_ARCH_POSIX_TRAP_ON_FATAL=y
CONFIG_LOG=y
CONFIG_LOG_THREAD_ID_PREFIX=y
CONFIG_THREAD_NAME=y
# CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y
CONFIG_NO_RUNTIME_CHECKS=y

View file

@ -258,20 +258,7 @@ static void test_central_main(void)
*/ */
err = bt_l2cap_chan_send(&channel.chan, buf); err = bt_l2cap_chan_send(&channel.chan, buf);
if (has_checks) { /* L2CAP will take our `buf` with non-null user_data. We verify that:
/* The stack is supposed to reject `buf` if it has non-null
* user_data.
*/
if (err == -EINVAL) {
PASS("(Enabled-checks) Test passed\n");
return;
}
FAIL("Expected EINVAL (%d) got %d\n", -EINVAL, err);
}
/* We have bypassed runtime checks of user_data. L2CAP will take our
* `buf` with non-null user_data. We verify that:
* - it is cleared * - it is cleared
* - we don't segfault later (e.g. in `tx_notify`) * - we don't segfault later (e.g. in `tx_notify`)
*/ */

View file

@ -8,6 +8,5 @@ INCR_BUILD=1
source ${ZEPHYR_BASE}/tests/bsim/compile.source source ${ZEPHYR_BASE}/tests/bsim/compile.source
app="$(guess_test_relpath)" compile app="$(guess_test_relpath)" compile
app="$(guess_test_relpath)" conf_file=prj_no_checks.conf compile
wait_for_background_jobs wait_for_background_jobs

View file

@ -20,14 +20,3 @@ Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=5e6 $@ -D=2 -sim_length=5e6 $@
wait_for_background_jobs wait_for_background_jobs
Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_l2cap_userdata_prj_no_checks_conf \
-v=${verbosity_level} -s=${simulation_id} -d=0 -testid=central
Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_l2cap_userdata_prj_no_checks_conf \
-v=${verbosity_level} -s=${simulation_id} -d=1 -testid=peripheral
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=5e6 $@
wait_for_background_jobs