From: dalegaard <noreply@github.com>
To: linux-bluetooth@vger.kernel.org
Subject: [bluez/bluez] c355eb: gatt-client: prevent use-after-free when clients d...
Date: Fri, 09 Jan 2026 12:39:50 -0800 [thread overview]
Message-ID: <bluez/bluez/push/refs/heads/1040618/000000-c355eb@github.com> (raw)
Branch: refs/heads/1040618
Home: https://github.com/bluez/bluez
Commit: c355ebd3953d5c830e80907839c256dfe20e180f
https://github.com/bluez/bluez/commit/c355ebd3953d5c830e80907839c256dfe20e180f
Author: Lasse Dalegaard <dalegaard@gmail.com>
Date: 2026-01-09 (Fri, 09 Jan 2026)
Changed paths:
M src/gatt-client.c
Log Message:
-----------
gatt-client: prevent use-after-free when clients disconnect
Clients with an acquired characteristic subscription would free the
client during disconnect. When notify_io_destroy then tries to remove
the client, it'll use-after-free.
Add another reference when allocating the notify_io and unref it again
in notify_io_destroy.
This was found with AddressSanitizer:
==766875==ERROR: AddressSanitizer: heap-use-after-free on address 0x7b7782a31df0 at pc 0x55d19ae87cf0 bp 0x7ffcc28ea0d0 sp 0x7ffcc28ea0c0
READ of size 8 at 0x7b7782a31df0 thread T0
#0 0x55d19ae87cef in notify_io_destroy src/gatt-client.c:1567
#1 0x55d19ae83462 in sock_io_destroy src/gatt-client.c:1171
#2 0x55d19ae83a4b in destroy_sock src/gatt-client.c:1192
#3 0x55d19ae83c52 in sock_hup src/gatt-client.c:1207
...
0x7b7782a31df0 is located 0 bytes inside of 32-byte region [0x7b7782a31df0,0x7b7782a31e10)
freed by thread T0 here:
#0 0x7f4784d1f79d in free /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:51
#1 0x55d19ae85c57 in notify_client_free src/gatt-client.c:1360
#2 0x55d19ae85dd5 in notify_client_unref src/gatt-client.c:1372
#3 0x55d19ae86517 in notify_client_disconnect src/gatt-client.c:1418
...
previously allocated by thread T0 here:
#0 0x7f4784d20cb5 in malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:67
#1 0x55d19af6154d in util_malloc src/shared/util.c:46
#2 0x55d19ae86550 in notify_client_create src/gatt-client.c:1426
#3 0x55d19ae880cd in characteristic_acquire_notify src/gatt-client.c:1593
...
Other avenues could also result in this use-after-free. The root issue
is that the client struct is put in to both the notify list, and the
notify_io struct, but without an extra reference increment.
To unsubscribe from these emails, change your notification settings at https://github.com/bluez/bluez/settings/notifications
reply other threads:[~2026-01-09 20:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=bluez/bluez/push/refs/heads/1040618/000000-c355eb@github.com \
--to=noreply@github.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