]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
Bluetooth: Improve setsockopt() handling of malformed user input
authorMichal Luczaj <mhal@rbox.co>
Tue, 19 Nov 2024 13:31:40 +0000 (14:31 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Dec 2024 17:13:17 +0000 (18:13 +0100)
commit13ba06e2601e8a334bd206a3b6e7167dd8dd26a8
tree6d67defebd1e4e6a6b764a326d174dff8c9c48d4
parente4ac72dd79e0687eaf2f4b622c15fd2ff62d9c23
Bluetooth: Improve setsockopt() handling of malformed user input

[ Upstream commit 3e643e4efa1e87432204b62f9cfdea3b2508c830 ]

The bt_copy_from_sockptr() return value is being misinterpreted by most
users: a non-zero result is mistakenly assumed to represent an error code,
but actually indicates the number of bytes that could not be copied.

Remove bt_copy_from_sockptr() and adapt callers to use
copy_safe_from_sockptr().

For sco_sock_setsockopt() (case BT_CODEC) use copy_struct_from_sockptr() to
scrub parts of uninitialized buffer.

Opportunistically, rename `len` to `optlen` in hci_sock_setsockopt_old()
and hci_sock_setsockopt().

Fixes: 51eda36d33e4 ("Bluetooth: SCO: Fix not validating setsockopt user input")
Fixes: a97de7bff13b ("Bluetooth: RFCOMM: Fix not validating setsockopt user input")
Fixes: 4f3951242ace ("Bluetooth: L2CAP: Fix not validating setsockopt user input")
Fixes: 9e8742cdfc4b ("Bluetooth: ISO: Fix not validating setsockopt user input")
Fixes: b2186061d604 ("Bluetooth: hci_sock: Fix not validating setsockopt user input")
Reviewed-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Reviewed-by: David Wei <dw@davidwei.uk>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/bluetooth/bluetooth.h
net/bluetooth/hci_sock.c
net/bluetooth/iso.c
net/bluetooth/l2cap_sock.c
net/bluetooth/rfcomm/sock.c
net/bluetooth/sco.c