bluetooth: Add cmd validity checks at the start of hci_sock_ioctl()
authorRuihan Li <lrh2000@pku.edu.cn>
Sun, 16 Apr 2023 08:02:51 +0000 (16:02 +0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 24 Apr 2023 05:05:06 +0000 (22:05 -0700)
commit000c2fa2c144c499c881a101819cf1936a1f7cf2
treea03ea860a1189d7302dad091abb27e3a6d0066c1
parentdb2bf510bd5d57f064d9e1db395ed86a08320c54
bluetooth: Add cmd validity checks at the start of hci_sock_ioctl()

Previously, channel open messages were always sent to monitors on the first
ioctl() call for unbound HCI sockets, even if the command and arguments
were completely invalid. This can leave an exploitable hole with the abuse
of invalid ioctl calls.

This commit hardens the ioctl processing logic by first checking if the
command is valid, and immediately returning with an ENOIOCTLCMD error code
if it is not. This ensures that ioctl calls with invalid commands are free
of side effects, and increases the difficulty of further exploitation by
forcing exploitation to find a way to pass a valid command first.

Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
Co-developed-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_sock.c