lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202210171914.B3E5CE55@keescook>
Date:   Mon, 17 Oct 2022 19:26:05 -0700
From:   Kees Cook <keescook@...omium.org>
To:     "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc:     Kalle Valo <kvalo@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
        linux-wireless@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-hardening@...r.kernel.org
Subject: Re: [PATCH 1/6][next] orinoco: Avoid clashing function prototypes

On Mon, Oct 17, 2022 at 03:33:01PM -0500, Gustavo A. R. Silva 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].
> 
> Fix a total of 53 warnings like these:
> 
> drivers/net/wireless/intersil/orinoco/wext.c:1379:27: warning: cast from 'int (*)(struct net_device *, struct iw_request_info *, struct iw_param *, 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(SIOCGIWPOWER,        (iw_handler)orinoco_ioctl_getpower),
>                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> ../net/wireless/wext-compat.c:1607:33: warning: cast from 'int (*)(struct net_device *, struct iw_request_info *, struct iw_point *, 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_IOCTL_IDX(SIOCSIWGENIE)]    = (iw_handler) cfg80211_wext_siwgenie,
>                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thank you for working on these! Was this conversion done manually, via
coccinelle, or something else?

> The orinoco 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. No significant binary differences were seen
> before/after changes.

What does "significant" mean here? :P Anything related to line counts
can just be ignored. But I'd expect the .text output of
drivers/net/wireless/intersil/orinoco/wext.o before/after to be
identical.

> [...]
>  	IW_HANDLER(SIOCSIWRTS,		(iw_handler)cfg80211_wext_siwrts),
^^^ I think these are fixed explicitly later, but maybe better to just
collapse them into this patch?

> [...]
> @@ -1391,15 +1406,15 @@ static const iw_handler	orinoco_handler[] = {
>    Added typecasting since we no longer use iwreq_data -- Moustafa
>   */
>  static const iw_handler	orinoco_private_handler[] = {
> -	[0] = (iw_handler)orinoco_ioctl_reset,
> -	[1] = (iw_handler)orinoco_ioctl_reset,
> -	[2] = (iw_handler)orinoco_ioctl_setport3,
> -	[3] = (iw_handler)orinoco_ioctl_getport3,
> -	[4] = (iw_handler)orinoco_ioctl_setpreamble,
> -	[5] = (iw_handler)orinoco_ioctl_getpreamble,
> -	[6] = (iw_handler)orinoco_ioctl_setibssport,
> -	[7] = (iw_handler)orinoco_ioctl_getibssport,
> -	[9] = (iw_handler)orinoco_ioctl_getrid,
> +	[0] = orinoco_ioctl_reset,
> +	[1] = orinoco_ioctl_reset,
> +	[2] = orinoco_ioctl_setport3,
> +	[3] = orinoco_ioctl_getport3,
> +	[4] = orinoco_ioctl_setpreamble,
> +	[5] = orinoco_ioctl_getpreamble,
> +	[6] = orinoco_ioctl_setibssport,
> +	[7] = orinoco_ioctl_getibssport,
> +	[9] = orinoco_ioctl_getrid,

Oops, I broke atmel. These really are 0-indexed...

 static const iw_handler atmel_private_handler[] =
 {
-	NULL,				/* SIOCIWFIRSTPRIV */
+	IW_HANDLER(SIOCIWFIRSTPRIV,	NULL),
 };
 
I'll send a fix!

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ