From: Laxman Acharya Padhya <acharyalaxman8848@gmail.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org,
Marcel Holtmann <marcel@holtmann.org>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: hci_codec: validate vendor codec count length
Date: Mon, 24 Aug 2026 21:05:29 +0545 [thread overview]
Message-ID: <20260824152029.51492-1-acharyalaxman8848@gmail.com> (raw)
In-Reply-To: <CABBYNZKJ10anQiThzYturqWyRxhnKY-xOMKhKHF5ysx37VmHkQ@mail.gmail.com>
Hi Luiz,
Thanks for looking at this. Sorry that my earlier wording was unclear.
I agree that the uses of p inside sizeof() and __must_be_array() are
unevaluated, and that sizeof(vnd_codecs->num) is a compile-time value of
one.
The runtime access comes from the third macro argument, count. Here that
argument is the expression vnd_codecs->num. Since it is not a constant
expression, __builtin_choose_expr() selects the size_mul() branch, which
effectively evaluates:
size_mul(vnd_codecs->num, sizeof(*vnd_codecs->codec))
Evaluating the first argument reads vnd_codecs->num before the result is
compared with skb->len. Therefore, if no byte remains after the standard
codec array, the read is already out of bounds. The issue is this count
load, rather than any evaluation of the sizeof() operands.
I also verified this with a minimal reproducer using the same macro
expansion: the compiler emits a byte load from vnd_codecs, and ASan
reports a one-byte out-of-bounds read when the pointer is at the end of
the buffer.
Changing the trailing sizeof(vnd_codecs->num) to sizeof(*vnd_codecs)
would give the same size, but it would not prevent the earlier count
load. The added check ensures that the count byte is present before
flex_array_size() uses it.
Thanks,
Laxman
next prev parent reply other threads:[~2026-08-24 15:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 16:16 [PATCH] Bluetooth: hci_codec: validate vendor codec count length Laxman Acharya Padhya
2026-08-23 17:18 ` bluez.test.bot
2026-08-24 14:28 ` [PATCH] " Luiz Augusto von Dentz
2026-08-24 14:40 ` Laxman Acharya Padhya
2026-08-24 15:01 ` Luiz Augusto von Dentz
2026-08-24 15:20 ` Laxman Acharya Padhya [this message]
2026-08-24 15:31 ` Luiz Augusto von Dentz
2026-08-24 15:57 ` [PATCH v2] " Laxman Acharya Padhya
2026-08-24 16:54 ` [v2] " bluez.test.bot
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=20260824152029.51492-1-acharyalaxman8848@gmail.com \
--to=acharyalaxman8848@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=stable@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