Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ] adapter: Fix crash on UUID discovery filter match
@ 2026-07-09 12:27 Tom Catshoek
  2026-07-09 14:21 ` Bastien Nocera
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Tom Catshoek @ 2026-07-09 12:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Tom Catshoek

is_filter_match() looks up each discovery-filter UUID in the queue of
services parsed from a device advertisement. When that services list was
migrated from a GSList to a struct queue, the queue_find() call kept
GLib's g_slist_find_custom() argument order, passing the UUID string
where queue_find() expects a match function and the comparison function
where it expects the match data.

As a result queue_find() calls the UUID string as if it were a function,
jumping into non-executable heap and crashing bluetoothd with SIGSEGV as
soon as an advertisement matches a UUID filter configured via
SetDiscoveryFilter.

Add a queue_match_func_t helper and pass the arguments in the correct
order.

Fixes: https://github.com/bluez/bluez/issues/2282
---
 src/adapter.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 210225243..4ffa32a52 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -7184,6 +7184,14 @@ static void adapter_msd_notify(struct btd_adapter *adapter,
 	}
 }
 
+static bool match_uuid(const void *data, const void *match_data)
+{
+	const char *uuid = data;
+	const char *match = match_data;
+
+	return strcmp(uuid, match) == 0;
+}
+
 static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data,
 								int8_t rssi)
 {
@@ -7216,8 +7224,7 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data,
 				 * uuid.
 				 */
 				if (queue_find(eir_data->services,
-							m->data,
-							g_strcmp) != NULL)
+							match_uuid, m->data))
 					got_match = true;
 			}
 		}
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-07-09 16:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 12:27 [PATCH BlueZ] adapter: Fix crash on UUID discovery filter match Tom Catshoek
2026-07-09 14:21 ` Bastien Nocera
2026-07-09 15:00   ` Luiz Augusto von Dentz
2026-07-09 16:21     ` Tom Catshoek
2026-07-09 16:23       ` Luiz Augusto von Dentz
2026-07-09 16:31         ` Tom Catshoek
2026-07-09 14:46 ` [BlueZ] " bluez.test.bot
2026-07-09 15:30 ` [PATCH BlueZ] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox