nuttx/wireless/bluetooth
Alan Carvalho de Assis a73bea0653 wireless/bluetooth: Reject GATT operations on unconnected peers.
The GATT ioctls looked up a connection by address and then checked only
that a connection object existed, not that it had reached CONNECTED.
While a connection is still being established conn->att is NULL, and
bt_att_create_pdu() dereferenced it to read the ATT MTU, so issuing
SIOCBTEXCHANGE, SIOCBTDISCOVER, SIOCBTGATTRD or SIOCBTGATTWR for a peer
that is merely pending faulted.  Any task with access to the network
device can reach that path, and in PROTECTED and KERNEL builds the fault
is taken in the kernel on behalf of user code.

Require CONNECTED in those four ioctls, releasing the reference the
lookup took, and make bt_att_create_pdu() return NULL when there is no
ATT context instead of relying on every caller having checked first.

Testing: builds for sim:bluetooth with Make; every commit in this series
verified to build individually.  On sim:bluetooth with CONFIG_BTSAK=y:

  nsh> ifup bnep0
  ifup bnep0...OK
  nsh> bt bnep0 gatt connect 11:22:33:44:55:66 public
  Connect pending...
  nsh> bt bnep0 gatt exchange-mtu 11:22:33:44:55:66 public
  ERROR:  ioctl(SIOCBTEXCHANGE) failed: 107

107 is ENOTCONN, and the shell continues to run; before this change the
same sequence terminated the simulator in bt_att_create_pdu().

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Code Opus 5
2026-09-24 09:51:44 +02:00
..
bt_atomic.h nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-08-24 13:20:45 +08:00
bt_att.c wireless/bluetooth: Reject GATT operations on unconnected peers. 2026-09-24 09:51:44 +02:00
bt_att.h
bt_buf.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_buf.h
bt_conn.c wireless/bluetooth: Fix bad aligment 2026-09-22 10:07:09 -03:00
bt_conn.h
bt_gatt.c wireless/bluetooth: Fix record stride in descriptor discovery response. 2026-09-18 11:18:36 +08:00
bt_hcicore.c wireless/bluetooth: Validate event length before parsing HCI events. 2026-09-23 08:58:44 -03:00
bt_hcicore.h
bt_ioctl.c wireless/bluetooth: Reject GATT operations on unconnected peers. 2026-09-24 09:51:44 +02:00
bt_ioctl.h
bt_keys.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_keys.h
bt_l2cap.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_l2cap.h
bt_netdev.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_queue.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_queue.h
bt_services.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_smp.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_smp.h
bt_uuid.c
CMakeLists.txt
Kconfig
Make.defs