| From 7cf765151ec7afc5326384ab54add0ede7272158 Mon Sep 17 00:00:00 2001 | |
| From: Sasha Levin <sashal@kernel.org> | |
| Date: Fri, 6 Nov 2026 17:24:57 +0000 | |
| Subject: Bluetooth: reject invalid LE supervision timeout relationships | |
| From: Kyle Pepper <cochcoder@proton.me> | |
| [ Upstream commit c1d50a71cdee90a0c68b7a67221d8aae96d14a0c ] | |
| The LE parameter validator calculates an unsigned maximum latency by | |
| subtracting one from a truncated quotient. If the quotient is zero, | |
| this wraps and accepts invalid parameters. Exact quotient boundaries | |
| also accept equality where the supervision timeout must be greater. | |
| Compare the products directly after checking the field bounds. The | |
| validated interval and latency limits keep the products within int. | |
| This enforces the strict timeout relationship without division or | |
| unsigned subtraction. | |
| Sashiko identified the underflow while reviewing the soft interval | |
| preference RFC. The bug is already present in its unpatched base; keep | |
| this common-validator fix independent of that preference policy. | |
| Fixes: 8757825b128e ("Bluetooth: hci_check_conn_params() check proper range") | |
| Assisted-by: LLM | |
| Signed-off-by: Kyle Pepper <cochcoder@proton.me> | |
| Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | |
| Signed-off-by: Sasha Levin <sashal@kernel.org> | |
| --- | |
| include/net/bluetooth/hci_core.h | 13 +++---------- | |
| 1 file changed, 3 insertions(+), 10 deletions(-) | |
| diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h | |
| index cac282584c616..3a1169e19eb80 100644 | |
| --- a/include/net/bluetooth/hci_core.h | |
| +++ b/include/net/bluetooth/hci_core.h | |
| @@ -2320,8 +2320,6 @@ static inline struct smp_irk *hci_get_irk(struct hci_dev *hdev, | |
| static inline int hci_check_conn_params(u16 min, u16 max, u16 latency, | |
| u16 to_multiplier) | |
| { | |
| - u16 max_latency; | |
| - | |
| if (min > max) { | |
| BT_WARN("min %d > max %d", min, max); | |
| return -EINVAL; | |
| @@ -2347,19 +2345,14 @@ static inline int hci_check_conn_params(u16 min, u16 max, u16 latency, | |
| return -EINVAL; | |
| } | |
| - if (max >= to_multiplier * 8) { | |
| - BT_WARN("max %d >= to_multiplier %d * 8", max, to_multiplier); | |
| - return -EINVAL; | |
| - } | |
| - | |
| - max_latency = (to_multiplier * 4 / max) - 1; | |
| if (latency > 499) { | |
| BT_WARN("latency %d > 499", latency); | |
| return -EINVAL; | |
| } | |
| - if (latency > max_latency) { | |
| - BT_WARN("latency %d > max_latency %d", latency, max_latency); | |
| + if ((latency + 1) * max >= to_multiplier * 4) { | |
| + BT_WARN("latency %d, max %d and timeout %d are incompatible", | |
| + latency, max, to_multiplier); | |
| return -EINVAL; | |
| } | |
| -- | |
| 2.53.0 | |