Re: [PATCH] firewire: core: add __counted_by_ptr to struct fw_packet

From: Takashi Sakamoto

Date: Sat Sep 26 2026 - 21:48:32 EST


On Fri, Sep 25, 2026 at 09:09:12PM +0000, Bill Wendling wrote:
> In 'struct fw_packet', the 'payload' field points to a buffer of size
> 'payload_length' bytes. To enable compiler bounds checking (via KASAN
> and __builtin_dynamic_object_size), add the '__counted_by_ptr' attribute
> to the 'payload' pointer, associated with the 'payload_length' count.
>
> A thorough analysis of all allocation and initialization points for
> 'struct fw_packet' was conducted. The pointer and its length are
> assigned together.
>
> Because the count field is always correctly initialized before the
> pointer is accessed, the '__counted_by_ptr' attribute is fully safe and
> will not cause runtime false positives or panics.
>
> Cc: codemender-patching+linux@xxxxxxxxxx
> Assisted-by: LLM
> Signed-off-by: Bill Wendling <morbo@xxxxxxxxxx>
> ---
> include/linux/firewire.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-next branch.


Thanks

Takashi Sakamoto