]> git.itanic.dy.fi Git - linux-stable/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Jun 2023 07:07:04 +0000 (09:07 +0200)
commite4d2e6c3054b974125bdae74ee57017964232c4a
tree4c068d1d411ee1499e1b4ef6d3fc143de617d6e6
parent6a0712d9fe46678c65e7844f1b1d4ef9a0bb36de
bluetooth: Add cmd validity checks at the start of hci_sock_ioctl()

commit 000c2fa2c144c499c881a101819cf1936a1f7cf2 upstream.

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>
Signed-off-by: Dragos-Marian Panait <dragos.panait@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/bluetooth/hci_sock.c