<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/net/bluetooth/hci_debugfs.c, branch v6.6.133</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.6.133</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.6.133'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2024-04-10T14:35:49+00:00</updated>
<entry>
<title>Bluetooth: Fix TOCTOU in HCI debugfs implementation</title>
<updated>2024-04-10T14:35:49+00:00</updated>
<author>
<name>Bastien Nocera</name>
<email>hadess@hadess.net</email>
</author>
<published>2024-03-27T14:24:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d75632d0db3cdc31873d25756066a7f56bc87737'/>
<id>urn:sha1:d75632d0db3cdc31873d25756066a7f56bc87737</id>
<content type='text'>
commit 7835fcfd132eb88b87e8eb901f88436f63ab60f7 upstream.

struct hci_dev members conn_info_max_age, conn_info_min_age,
le_conn_max_interval, le_conn_min_interval, le_adv_max_interval,
and le_adv_min_interval can be modified from the HCI core code, as well
through debugfs.

The debugfs implementation, that's only available to privileged users,
will check for boundaries, making sure that the minimum value being set
is strictly above the maximum value that already exists, and vice-versa.

However, as both minimum and maximum values can be changed concurrently
to us modifying them, we need to make sure that the value we check is
the value we end up using.

For example, with -&gt;conn_info_max_age set to 10, conn_info_min_age_set()
gets called from vfs handlers to set conn_info_min_age to 8.

In conn_info_min_age_set(), this goes through:
	if (val == 0 || val &gt; hdev-&gt;conn_info_max_age)
		return -EINVAL;

Concurrently, conn_info_max_age_set() gets called to set to set the
conn_info_max_age to 7:
	if (val == 0 || val &gt; hdev-&gt;conn_info_max_age)
		return -EINVAL;
That check will also pass because we used the old value (10) for
conn_info_max_age.

After those checks that both passed, the struct hci_dev access
is mutex-locked, disabling concurrent access, but that does not matter
because the invalid value checks both passed, and we'll end up with
conn_info_min_age = 8 and conn_info_max_age = 7

To fix this problem, we need to lock the structure access before so the
check and assignment are not interrupted.

This fix was originally devised by the BassCheck[1] team, and
considered the problem to be an atomicity one. This isn't the case as
there aren't any concerns about the variable changing while we check it,
but rather after we check it parallel to another change.

This patch fixes CVE-2024-24858 and CVE-2024-24857.

[1] https://sites.google.com/view/basscheck/

Co-developed-by: Gui-Dong Han &lt;2045gemini@gmail.com&gt;
Signed-off-by: Gui-Dong Han &lt;2045gemini@gmail.com&gt;
Link: https://lore.kernel.org/linux-bluetooth/20231222161317.6255-1-2045gemini@gmail.com/
Link: https://nvd.nist.gov/vuln/detail/CVE-2024-24858
Link: https://lore.kernel.org/linux-bluetooth/20231222162931.6553-1-2045gemini@gmail.com/
Link: https://lore.kernel.org/linux-bluetooth/20231222162310.6461-1-2045gemini@gmail.com/
Link: https://nvd.nist.gov/vuln/detail/CVE-2024-24857
Fixes: 31ad169148df ("Bluetooth: Add conn info lifetime parameters to debugfs")
Fixes: 729a1051da6f ("Bluetooth: Expose default LE advertising interval via debugfs")
Fixes: 71c3b60ec6d2 ("Bluetooth: Move BR/EDR debugfs file creation into hci_debugfs.c")
Signed-off-by: Bastien Nocera &lt;hadess@hadess.net&gt;
Signed-off-by: Luiz Augusto von Dentz &lt;luiz.von.dentz@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Fix atomicity violation in {min,max}_key_size_set</title>
<updated>2024-01-25T23:35:46+00:00</updated>
<author>
<name>Gui-Dong Han</name>
<email>2045gemini@gmail.com</email>
</author>
<published>2023-12-22T15:12:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f56e715ef1c19c42c6aa6cb9280947dea13aab2e'/>
<id>urn:sha1:f56e715ef1c19c42c6aa6cb9280947dea13aab2e</id>
<content type='text'>
commit da9065caa594d19b26e1a030fd0cc27bd365d685 upstream.

In min_key_size_set():
    if (val &gt; hdev-&gt;le_max_key_size || val &lt; SMP_MIN_ENC_KEY_SIZE)
        return -EINVAL;
    hci_dev_lock(hdev);
    hdev-&gt;le_min_key_size = val;
    hci_dev_unlock(hdev);

In max_key_size_set():
    if (val &gt; SMP_MAX_ENC_KEY_SIZE || val &lt; hdev-&gt;le_min_key_size)
        return -EINVAL;
    hci_dev_lock(hdev);
    hdev-&gt;le_max_key_size = val;
    hci_dev_unlock(hdev);

The atomicity violation occurs due to concurrent execution of set_min and
set_max funcs.Consider a scenario where setmin writes a new, valid 'min'
value, and concurrently, setmax writes a value that is greater than the
old 'min' but smaller than the new 'min'. In this case, setmax might check
against the old 'min' value (before acquiring the lock) but write its
value after the 'min' has been updated by setmin. This leads to a
situation where the 'max' value ends up being smaller than the 'min'
value, which is an inconsistency.

This possible bug is found by an experimental static analysis tool
developed by our team, BassCheck[1]. This tool analyzes the locking APIs
to extract function pairs that can be concurrently executed, and then
analyzes the instructions in the paired functions to identify possible
concurrency bugs including data races and atomicity violations. The above
possible bug is reported when our tool analyzes the source code of
Linux 5.17.

To resolve this issue, it is suggested to encompass the validity checks
within the locked sections in both set_min and set_max funcs. The
modification ensures that the validation of 'val' against the
current min/max values is atomic, thus maintaining the integrity of the
settings. With this patch applied, our tool no longer reports the bug,
with the kernel configuration allyesconfig for x86_64. Due to the lack of
associated hardware, we cannot test the patch in runtime testing, and just
verify it according to the code logic.

[1] https://sites.google.com/view/basscheck/

Fixes: 18f81241b74f ("Bluetooth: Move {min,max}_key_size debugfs ...")
Cc: stable@vger.kernel.org
Signed-off-by: Gui-Dong Han &lt;2045gemini@gmail.com&gt;
Signed-off-by: Luiz Augusto von Dentz &lt;luiz.von.dentz@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_debugfs: Use kstrtobool() instead of strtobool()</title>
<updated>2023-08-11T18:47:44+00:00</updated>
<author>
<name>Christophe JAILLET</name>
<email>christophe.jaillet@wanadoo.fr</email>
</author>
<published>2023-07-11T17:41:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=82eae9dc438cd7932b5a1c79057378839f1e61e0'/>
<id>urn:sha1:82eae9dc438cd7932b5a1c79057378839f1e61e0</id>
<content type='text'>
strtobool() is the same as kstrtobool().
However, the latter is more used within the kernel.

In order to remove strtobool() and slightly simplify kstrtox.h, switch to
the other function name.

While at it, include the corresponding header file (&lt;linux/kstrtox.h&gt;)

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Signed-off-by: Luiz Augusto von Dentz &lt;luiz.von.dentz@intel.com&gt;
</content>
</entry>
<entry>
<title>Bluetooth: fix inconsistent indenting</title>
<updated>2023-04-24T05:02:14+00:00</updated>
<author>
<name>Lanzhe Li</name>
<email>u202212060@hust.edu.cn</email>
</author>
<published>2023-04-09T13:02:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=3c690a0d64f5964977050a91b6bba8de09c13d94'/>
<id>urn:sha1:3c690a0d64f5964977050a91b6bba8de09c13d94</id>
<content type='text'>
Fixed a wrong indentation before "return".This line uses a 7 space
indent instead of a tab.

Signed-off-by: Lanzhe Li &lt;u202212060@hust.edu.cn&gt;
Signed-off-by: Luiz Augusto von Dentz &lt;luiz.von.dentz@intel.com&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_sync: Fix not able to set force_static_address</title>
<updated>2022-12-12T22:19:23+00:00</updated>
<author>
<name>Luiz Augusto von Dentz</name>
<email>luiz.von.dentz@intel.com</email>
</author>
<published>2022-10-08T01:08:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=eeb1aafe97fa6da558157d2eb18cce25878b8656'/>
<id>urn:sha1:eeb1aafe97fa6da558157d2eb18cce25878b8656</id>
<content type='text'>
force_static_address shall be writable while hdev is initing but is not
considered powered yet since the static address is written only when
powered.

Signed-off-by: Luiz Augusto von Dentz &lt;luiz.von.dentz@intel.com&gt;
Tested-by: Brian Gix &lt;brian.gix@intel.com&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_debugfs: Fix not checking conn-&gt;debugfs</title>
<updated>2022-09-21T22:01:21+00:00</updated>
<author>
<name>Luiz Augusto von Dentz</name>
<email>luiz.von.dentz@intel.com</email>
</author>
<published>2022-09-19T17:57:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7096daba731eea262e0f7bf03453ceddcad89f70'/>
<id>urn:sha1:7096daba731eea262e0f7bf03453ceddcad89f70</id>
<content type='text'>
hci_debugfs_create_conn shall check if conn-&gt;debugfs has already been
created and don't attempt to overwrite it.

Signed-off-by: Luiz Augusto von Dentz &lt;luiz.von.dentz@intel.com&gt;
</content>
</entry>
<entry>
<title>Bluetooth: hci_core: Move all debugfs handling to hci_debugfs.c</title>
<updated>2021-09-22T14:17:13+00:00</updated>
<author>
<name>Luiz Augusto von Dentz</name>
<email>luiz.von.dentz@intel.com</email>
</author>
<published>2021-09-21T18:25:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=8331dc487fc55963e853b6858af716907717e181'/>
<id>urn:sha1:8331dc487fc55963e853b6858af716907717e181</id>
<content type='text'>
This moves hci_debugfs_create_basic to hci_debugfs.c which is where all
the others debugfs entries are handled.

Signed-off-by: Luiz Augusto von Dentz &lt;luiz.von.dentz@intel.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: use inclusive language when filtering devices</title>
<updated>2021-06-26T05:12:44+00:00</updated>
<author>
<name>Archie Pusaka</name>
<email>apusaka@chromium.org</email>
</author>
<published>2021-06-04T08:26:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=3d4f9c00492b4e21641e5140a5e78cb50b58d60b'/>
<id>urn:sha1:3d4f9c00492b4e21641e5140a5e78cb50b58d60b</id>
<content type='text'>
This patch replaces some non-inclusive terms based on the appropriate
language mapping table compiled by the Bluetooth SIG:
https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf

Specifically, these terms are replaced:
blacklist -&gt; reject list
whitelist -&gt; accept list

Signed-off-by: Archie Pusaka &lt;apusaka@chromium.org&gt;
Reviewed-by: Miao-chen Chou &lt;mcchou@chromium.org&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: Coding style fix</title>
<updated>2021-04-02T09:03:04+00:00</updated>
<author>
<name>Meng Yu</name>
<email>yumeng18@huawei.com</email>
</author>
<published>2021-04-01T06:50:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=149b3f13b4b11175c81105f32b048260e63fdc34'/>
<id>urn:sha1:149b3f13b4b11175c81105f32b048260e63fdc34</id>
<content type='text'>
1. Add space when needed;
2. Block comments style fix;
3. Move open brace '{' following function definitions to the next line;
4. Remove unnecessary braces '{}' for single statement blocks.

Signed-off-by: Meng Yu &lt;yumeng18@huawei.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
<entry>
<title>Bluetooth: fix coccicheck warnings debugfs</title>
<updated>2021-01-29T15:51:35+00:00</updated>
<author>
<name>Jiapeng Zhong</name>
<email>abaci-bugfix@linux.alibaba.com</email>
</author>
<published>2021-01-27T06:17:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=231ee8bd837f00bbffedbe0ebccbc7da1d1a9f02'/>
<id>urn:sha1:231ee8bd837f00bbffedbe0ebccbc7da1d1a9f02</id>
<content type='text'>
Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
for debugfs files.

Reported-by: Abaci Robot&lt;abaci@linux.alibaba.com&gt;
Signed-off-by: Jiapeng Zhong &lt;abaci-bugfix@linux.alibaba.com&gt;
Signed-off-by: Marcel Holtmann &lt;marcel@holtmann.org&gt;
</content>
</entry>
</feed>
