Re: [PATCH] wifi: atmel: Avoid clashing function prototypes

From: Kalle Valo
Date: Wed Oct 05 2022 - 03:51:24 EST

Kees Cook <keescook@xxxxxxxxxxxx> wrote:

> When built with Control Flow Integrity, function prototypes between
> caller and function declaration must match. These mismatches are visible
> at compile time with the new -Wcast-function-type-strict in Clang[1].
> Of the 1549 warnings found, 188 come from the atmel driver. For example:
> drivers/net/wireless/atmel/atmel.c:2518:2: warning: cast from 'int (*)(struct net_device *, struct iw_request_info *, void *, char *)' to 'iw_handler' (aka 'int (*)(struct net_device *, struct iw_request_info *, union iwreq_data *, char *)') converts to incompatible function type [-Wcast-function-type-strict]
> (iw_handler) atmel_config_commit, /* SIOCSIWCOMMIT */
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> The atmel Wireless Extension handler callbacks (iw_handler) use a union
> for the data argument. Actually use the union and perform explicit
> member selection in the function body instead of having a function
> prototype mismatch. There are no resulting binary differences.
> This patch is a cleanup based on Brad Spengler/PaX Team's modifications
> to the atmel driver in their last public patch of grsecurity/PaX based
> on my understanding of the code. Changes or omissions from the original
> code are mine and don't reflect the original grsecurity/PaX code.
> [1]
> Cc: Simon Kelley <simon@xxxxxxxxxxxxxxxxx>
> Cc: Kalle Valo <kvalo@xxxxxxxxxx>
> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
> Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
> Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
> Cc: linux-wireless@xxxxxxxxxxxxxxx
> Cc: netdev@xxxxxxxxxxxxxxx
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>

Patch applied to wireless-next.git, thanks.

8af9d4068e86 wifi: atmel: Avoid clashing function prototypes