diff options
| author | Bill Wendling <morbo@google.com> | 2026-09-25 21:25:52 +0000 |
|---|---|---|
| committer | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2026-09-25 21:25:52 +0000 |
| commit | 39e505c38ffcc845ea58259573ff34c6d98e36bb (patch) | |
| tree | 4f2d1a08874fe4e2d15715b25d61ee55562fee10 /include/linux | |
| parent | a1eae4befca272c238b6e832bbf27f49a5e03825 (diff) | |
| download | linux-39e505c38ffcc845ea58259573ff34c6d98e36bb.tar.gz linux-39e505c38ffcc845ea58259573ff34c6d98e36bb.zip | |
firewire: core: add __counted_by_ptr attribute to struct fw_device
The GCC and Clang attribute '__counted_by_ptr' associates a pointer
field with an integer field holding its element count. This enables
runtime bounds checking by KASAN and UBSAN to prevent out-of-bounds
accesses to the pointer.
In 'struct fw_device' (defined in 'include/linux/firewire.h'), the
field 'config_rom' is a pointer to the device's Configuration ROM data,
and its associated element count is stored in 'config_rom_length'.
Additionally, update the existing KUnit test in
'drivers/firewire/device-attribute-test.c' where 'config_rom_length'
was incorrectly initialized with the byte size
('sizeof(simple_avc_config_rom)') instead of the element count
('ARRAY_SIZE(simple_avc_config_rom)'). This ensures the
'__counted_by_ptr' bounds-checking annotation does not trigger any
false-positive panics or compile/runtime checks.
Cc: codemender-patching+linux@google.com
Assisted-by: LLM
Signed-off-by: Bill Wendling <morbo@google.com>
Link: https://lore.kernel.org/r/20260925212552.125652-1-morbo@google.com
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/firewire.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/firewire.h b/include/linux/firewire.h index 9d5a42724f1a..dbb5c825a1cc 100644 --- a/include/linux/firewire.h +++ b/include/linux/firewire.h @@ -224,7 +224,7 @@ struct fw_device { struct mutex client_list_mutex; struct list_head client_list; - const u32 *config_rom; + const u32 *config_rom __counted_by_ptr(config_rom_length); size_t config_rom_length; int config_rom_retries; unsigned is_local:1; |
