]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
Bluetooth: hci_event: Fix using rcu_read_(un)lock while iterating
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 4 Dec 2024 16:40:59 +0000 (11:40 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Dec 2024 17:13:20 +0000 (18:13 +0100)
commitf9ecc90b5d501b3a5a62d0685d5104f934bb0104
tree9a076276e1ae69ade811c83bef608ac7266e1a85
parent458aa6704c00cea7a9faab194c9927adc6935ee5
Bluetooth: hci_event: Fix using rcu_read_(un)lock while iterating

[ Upstream commit 581dd2dc168fe0ed2a7a5534a724f0d3751c93ae ]

The usage of rcu_read_(un)lock while inside list_for_each_entry_rcu is
not safe since for the most part entries fetched this way shall be
treated as rcu_dereference:

Note that the value returned by rcu_dereference() is valid
only within the enclosing RCU read-side critical section [1]_.
For example, the following is **not** legal::

rcu_read_lock();
p = rcu_dereference(head.next);
rcu_read_unlock();
x = p->address; /* BUG!!! */
rcu_read_lock();
y = p->data; /* BUG!!! */
rcu_read_unlock();

Fixes: a0bfde167b50 ("Bluetooth: ISO: Add support for connecting multiple BISes")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/hci_event.c