From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 2/2] ranging: Fail CS Config Complete on role mismatch
Date: Tue, 27 Oct 2026 10:09:53 -0400 [thread overview]
Message-ID: <20261027140953.1854740-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20261027140953.1854740-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When the role reported in CS Config Complete is not allowed by the
Role_Enable set with CS Set Default Settings, the state machine carried
on with the reported role. A Reflector-only Peripheral receiving a config
reporting Initiator ended up in CS_STATE_HOLD from the security path, so
every following Subevent Result was dropped with "Received Subevent when
CS Procedure is inactive!".
Move to CS_STATE_HOLD at Config Complete and report the mismatch instead.
Fixes: 20cc88874d57 ("profiles: ranging: Add CS Initiator cmd and evt handling")
Assisted-by: OpenCode:claude-opus-5.5
---
profiles/ranging/rap_hci.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/profiles/ranging/rap_hci.c b/profiles/ranging/rap_hci.c
index fee769e9b438..62760b5c092e 100644
--- a/profiles/ranging/rap_hci.c
+++ b/profiles/ranging/rap_hci.c
@@ -964,6 +964,15 @@ static void rap_cs_config_cmplt_evt(const void *data, uint8_t size,
* (CS_INITIATOR=0x00, CS_REFLECTOR=0x01)
* which is different from the role_enable value sent in HCI command
*/
+ if ((is_initiator_role(sm) && rap_ev.role != CS_INITIATOR) ||
+ (!is_initiator_role(sm) && !is_both_role(sm) &&
+ rap_ev.role != CS_REFLECTOR)) {
+ error("CS Config role 0x%02X doesn't match role enable 0x%02X",
+ rap_ev.role, sm->role_enable);
+ cs_set_state(sm, CS_STATE_HOLD);
+ return;
+ }
+
sm->cs_opt.role = rap_ev.role;
sm->cs_opt.rtt_type = rap_ev.rtt_type;
--
2.56.0
next prev parent reply other threads:[~2026-10-27 14:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 14:09 [PATCH BlueZ v1 1/2] ranging: Issue CS Security Enable based on the ACL role Luiz Augusto von Dentz
2026-10-27 14:09 ` Luiz Augusto von Dentz [this message]
2026-10-27 15:20 ` [BlueZ,v1,1/2] " bluez.test.bot
2026-10-28 13:30 ` [PATCH BlueZ v1 1/2] " patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261027140953.1854740-2-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox