summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Pepper <cochcoder@proton.me>2026-11-06 17:24:57 +0000
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2026-11-06 13:49:56 -0500
commitc1d50a71cdee90a0c68b7a67221d8aae96d14a0c (patch)
tree77add6d7eca66b55c49974a27529b9c25cfee9d6
parent868c886f45f7c10dc888b94c6993352702a84d04 (diff)
Bluetooth: reject invalid LE supervision timeout relationships
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>
-rw-r--r--include/net/bluetooth/hci_core.h13
1 files changed, 3 insertions, 10 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 908acbad7177..6fb713d5e4be 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -2367,8 +2367,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;
@@ -2394,19 +2392,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;
}