From: Kees Cook <keescook@chromium.org>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Kalle Valo <kvalo@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH 1/6][next] orinoco: Avoid clashing function prototypes
Date: Mon, 17 Oct 2022 19:26:05 -0700 [thread overview]
Message-ID: <202210171914.B3E5CE55@keescook> (raw)
In-Reply-To: <2387e02ae7f31388f24041cae8d02d5e12151708.1666038048.git.gustavoars@kernel.org>
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
next prev parent reply other threads:[~2022-10-18 2:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-17 20:32 [PATCH 0/6][next] Avoid clashing function prototypes Gustavo A. R. Silva
2022-10-17 20:33 ` [PATCH 1/6][next] orinoco: " Gustavo A. R. Silva
2022-10-18 2:26 ` Kees Cook [this message]
2022-10-17 20:34 ` [PATCH 2/6][next] cfg80211: " Gustavo A. R. Silva
2022-10-18 2:41 ` Kees Cook
2022-10-18 19:31 ` Gustavo A. R. Silva
2022-10-17 20:34 ` [PATCH 3/6][next] ipw2x00: Remove unnecessary cast to iw_handler in ipw_wx_handlers Gustavo A. R. Silva
2022-10-18 2:43 ` Kees Cook
2022-10-17 20:35 ` [PATCH 4/6][next] hostap: Avoid clashing function prototypes Gustavo A. R. Silva
2022-10-18 2:48 ` Kees Cook
2022-10-17 20:35 ` [PATCH 5/6][next] zd1201: " Gustavo A. R. Silva
2022-10-18 2:49 ` Kees Cook
2022-10-17 20:36 ` [PATCH 6/6][next] airo: " Gustavo A. R. Silva
2022-10-18 2:53 ` Kees Cook
2022-10-19 5:58 ` Gustavo A. R. Silva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202210171914.B3E5CE55@keescook \
--to=keescook@chromium.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gustavoars@kernel.org \
--cc=kuba@kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).