mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] firewire: core: add __counted_by_ptr to struct fw_packet
@ 2026-09-25 21:09 Bill Wendling
  2026-09-27  1:48 ` Takashi Sakamoto
  0 siblings, 1 reply; 2+ messages in thread
From: Bill Wendling @ 2026-09-25 21:09 UTC (permalink / raw)
  To: Takashi Sakamoto
  Cc: Kees Cook, Gustavo A. R. Silva, linux1394-devel, linux-kernel,
	linux-hardening, Bill Wendling, codemender-patching+linux

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@google.com
Assisted-by: LLM
Signed-off-by: Bill Wendling <morbo@google.com>
---
 include/linux/firewire.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/firewire.h b/include/linux/firewire.h
index fd35a6570cd8..9f313b47a694 100644
--- a/include/linux/firewire.h
+++ b/include/linux/firewire.h
@@ -322,7 +322,7 @@ struct fw_packet {
 	int generation;
 	u32 header[4];
 	size_t header_length;
-	void *payload;
+	void *payload __counted_by_ptr(payload_length);
 	size_t payload_length;
 	dma_addr_t payload_bus;
 	bool payload_mapped;
-- 
2.56.0.rc1.315.gc6ed9934b7-goog


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

* Re: [PATCH] firewire: core: add __counted_by_ptr to struct fw_packet
  2026-09-25 21:09 [PATCH] firewire: core: add __counted_by_ptr to struct fw_packet Bill Wendling
@ 2026-09-27  1:48 ` Takashi Sakamoto
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Sakamoto @ 2026-09-27  1:48 UTC (permalink / raw)
  To: Bill Wendling
  Cc: Kees Cook, Gustavo A. R. Silva, linux1394-devel, linux-kernel,
	linux-hardening, codemender-patching+linux

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@google.com
> Assisted-by: LLM
> Signed-off-by: Bill Wendling <morbo@google.com>
> ---
>  include/linux/firewire.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to for-next branch.


Thanks

Takashi Sakamoto

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

end of thread, other threads:[~2026-09-27  1:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 21:09 [PATCH] firewire: core: add __counted_by_ptr to struct fw_packet Bill Wendling
2026-09-27  1:48 ` Takashi Sakamoto

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

all inboxes | Powered by JetHome®