* [PATCH BlueZ] profiles/audio: fix UAF on external media service teardown
@ 2026-07-15 15:51 Frédéric Danis
2026-07-15 17:00 ` patchwork-bot+bluetooth
0 siblings, 1 reply; 2+ messages in thread
From: Frédéric Danis @ 2026-07-15 15:51 UTC (permalink / raw)
To: linux-bluetooth
Keep media_app endpoint/player queues in sync with object lifetime to
avoid stale pointers during proxy removal.
When admin allowlist reapply removes audio services, endpoint/player
objects may be destroyed through non-proxy paths first.
Later proxy_removed_cb calls queue_remove_if() and matching by path
can dereference freed endpoint/player memory.
Fix by:
- adding media_app back-references in media_endpoint/local_player
- unlinking from app queues inside media_endpoint_remove or
local_player_remove
- setting ownership when app-registering endpoint/player objects
This prevents heap-use-after-free in match_endpoint_by_path or
match_player_by_path during service disconnect.
Assisted-by: GPT:GPT-5.3-Codex
---
profiles/audio/media.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 5d9ea2cbc..95f9580b0 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -136,12 +136,14 @@ struct media_endpoint {
guint watch;
GSList *requests;
struct media_adapter *adapter;
+ struct media_app *app;
GSList *transports;
struct endpoint_features features;
};
struct local_player {
struct media_adapter *adapter;
+ struct media_app *app;
char *sender; /* Player DBus bus id */
char *path; /* Player object path */
GHashTable *settings; /* Player settings */
@@ -305,6 +307,11 @@ static void media_endpoint_remove(void *data)
}
#endif
+ if (endpoint->app) {
+ queue_remove(endpoint->app->endpoints, endpoint);
+ endpoint->app = NULL;
+ }
+
info("Endpoint unregistered: sender=%s path=%s", endpoint->sender,
endpoint->path);
@@ -2076,6 +2083,11 @@ static void local_player_remove(void *data)
{
struct local_player *mp = data;
+ if (mp->app) {
+ queue_remove(mp->app->players, mp);
+ mp->app = NULL;
+ }
+
info("Player unregistered: sender=%s path=%s", mp->sender, mp->path);
local_player_destroy(mp);
@@ -3168,6 +3180,8 @@ static void app_register_endpoint(void *data, void *user_data)
return;
}
+ endpoint->app = app;
+
queue_push_tail(app->endpoints, endpoint);
return;
@@ -3196,6 +3210,8 @@ static void app_register_player(void *data, void *user_data)
if (!player)
return;
+ player->app = app;
+
if (g_dbus_proxy_get_property(proxy, "PlaybackStatus", &iter)) {
if (!set_status(player, &iter))
goto fail;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH BlueZ] profiles/audio: fix UAF on external media service teardown
2026-07-15 15:51 [PATCH BlueZ] profiles/audio: fix UAF on external media service teardown Frédéric Danis
@ 2026-07-15 17:00 ` patchwork-bot+bluetooth
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+bluetooth @ 2026-07-15 17:00 UTC (permalink / raw)
To: =?utf-8?b?RnLDqWTDqXJpYyBEYW5pcyA8ZnJlZGVyaWMuZGFuaXNAY29sbGFib3JhLmNvbT4=?=
Cc: linux-bluetooth
Hello:
This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Wed, 15 Jul 2026 17:51:44 +0200 you wrote:
> Keep media_app endpoint/player queues in sync with object lifetime to
> avoid stale pointers during proxy removal.
>
> When admin allowlist reapply removes audio services, endpoint/player
> objects may be destroyed through non-proxy paths first.
> Later proxy_removed_cb calls queue_remove_if() and matching by path
> can dereference freed endpoint/player memory.
>
> [...]
Here is the summary with links:
- [BlueZ] profiles/audio: fix UAF on external media service teardown
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7482aceece70
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-15 17:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15 15:51 [PATCH BlueZ] profiles/audio: fix UAF on external media service teardown Frédéric Danis
2026-07-15 17:00 ` 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