[PATCH] bus: fsl-mc: Annotate fsl_mc_io.portal_virt_addr with __counted_by_ptr

Ioana Ciornei ioana.ciornei at nxp.com
Fri Oct 2 05:55:01 PDT 2026


On Tue, Sep 22, 2026 at 10:35:38PM +0000, Bill Wendling wrote:
> The GCC and Clang compilers provide the __counted_by_ptr attribute,
> which is used by KASAN and compiler bounds-checking to detect
> out-of-bounds accesses to pointer fields.
> 
> In "struct fsl_mc_io", the "portal_virt_addr" pointer points to the MC
> command portal virtual address. The size of this allocated portal in
> bytes is tracked by the "portal_size" field within the same structure.
> 
> Annotate the "portal_virt_addr" pointer field with
> "__counted_by_ptr(portal_size)" to enable compiler bounds-checking and
> harden against potential out-of-bounds accesses.
> 
> Cc: codemender-patching+linux at google.com
> Assisted-by: LLM
> Signed-off-by: Bill Wendling <morbo at google.com>

Reviewed-by: Ioana Ciornei <ioana.ciornei at nxp.com>




More information about the linux-arm-kernel mailing list