Re: [PATCH] niu: Silence randstruct warnings

From: Jakub Kicinski
Date: Wed May 11 2022 - 18:16:57 EST


On Tue, 10 May 2022 13:57:29 -0700 Kees Cook wrote:
> Clang randstruct gets upset when it sees struct addresspace (which is
> randomized) being assigned to a struct page (which is not randomized):
>
> drivers/net/ethernet/sun/niu.c:3385:12: error: casting from randomized structure pointer type 'struct address_space *' to 'struct page *'
> *link = (struct page *) page->mapping;
> ^
>
> It looks like niu.c is looking for an in-line place to chain its allocated
> pages together and is overloading the "mapping" member, as it is unused.
> This is very non-standard, and is expected to be cleaned up in the
> future[1], but there is no "correct" way to handle it today.
>
> No meaningful machine code changes result after this change, and source
> readability is improved.
>
> Drop the randstruct exception now that there is no "confusing" cross-type
> assignment.
>
> [1] https://lore.kernel.org/lkml/YnqgjVoMDu5v9PNG@xxxxxxxxxxxxxxxxxxxx/
>
> Cc: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx>
> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
> Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
> Cc: Du Cheng <ducheng2@xxxxxxxxx>
> Cc: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
> Cc: Vlastimil Babka <vbabka@xxxxxxx>
> Cc: William Kucharski <william.kucharski@xxxxxxxxxx>
> Cc: Arnd Bergmann <arnd@xxxxxxxx>
> Cc: Nathan Chancellor <nathan@xxxxxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx
> Cc: linux-mm@xxxxxxxxx
> Cc: linux-hardening@xxxxxxxxxxxxxxx
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>

I presume you prefer to take this one via your tree too, so:

Acked-by: Jakub Kicinski <kuba@xxxxxxxxxx>