* [PATCH v2 0/6] Avoid clashing function prototypes
@ 2022-10-27 20:16 Gustavo A. R. Silva
2022-10-27 20:22 ` [PATCH v2 6/6] staging: ks7010: " Gustavo A. R. Silva
0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2022-10-27 20:16 UTC (permalink / raw)
To: Kalle Valo, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Greg Kroah-Hartman, Jouni Malinen,
Stanislav Yakovlev, Johannes Berg
Cc: linux-staging, netdev, linux-wireless, linux-kernel, Kees Cook,
Gustavo A. R. Silva, linux-hardening
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].
This series fixes a total of 424 -Wcast-function-type-strict warnings.
Link: https://reviews.llvm.org/D134831 [1]
Changes in v2:
- Squash previous patches 1, 2 and 3 into a single patch
cfg80211.
- Add a couple more patches: bna and staging.
- Fix 254 (227 in bna and 27 in staging) more
-Wcast-function-type-strict warnings.
v1:
- Link: https://lore.kernel.org/linux-hardening/cover.1666038048.git.gustavoars@kernel.org/
Gustavo A. R. Silva (6):
cfg80211: Avoid clashing function prototypes
hostap: Avoid clashing function prototypes
zd1201: Avoid clashing function prototypes
airo: Avoid clashing function prototypes
bna: Avoid clashing function prototypes
staging: ks7010: Avoid clashing function prototypes
drivers/net/ethernet/brocade/bna/bfa_cs.h | 60 +++--
drivers/net/ethernet/brocade/bna/bfa_ioc.c | 10 +-
drivers/net/ethernet/brocade/bna/bfa_ioc.h | 8 +-
drivers/net/ethernet/brocade/bna/bfa_msgq.h | 8 +-
drivers/net/ethernet/brocade/bna/bna_enet.c | 6 +-
drivers/net/ethernet/brocade/bna/bna_tx_rx.c | 6 +-
drivers/net/ethernet/brocade/bna/bna_types.h | 27 +-
drivers/net/wireless/cisco/airo.c | 204 ++++++++-------
drivers/net/wireless/intel/ipw2x00/ipw2200.c | 2 +-
.../wireless/intersil/hostap/hostap_ioctl.c | 234 ++++++++++--------
drivers/net/wireless/intersil/orinoco/wext.c | 113 +++++----
drivers/net/wireless/zydas/zd1201.c | 162 ++++++------
drivers/staging/ks7010/ks_wlan_net.c | 184 +++++++-------
include/net/cfg80211-wext.h | 20 +-
net/wireless/scan.c | 3 +-
net/wireless/wext-compat.c | 180 ++++++--------
net/wireless/wext-compat.h | 8 +-
net/wireless/wext-sme.c | 5 +-
18 files changed, 661 insertions(+), 579 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 6/6] staging: ks7010: Avoid clashing function prototypes
2022-10-27 20:16 [PATCH v2 0/6] Avoid clashing function prototypes Gustavo A. R. Silva
@ 2022-10-27 20:22 ` Gustavo A. R. Silva
2022-10-29 7:20 ` Kees Cook
0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2022-10-27 20:22 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-staging, linux-kernel, Kees Cook, Gustavo A. R. Silva,
linux-hardening
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 27 warnings like these:
drivers/staging/ks7010/ks_wlan_net.c:2415:2: 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_handler)ks_wlan_get_firmware_version,/* 3 KS_WLAN_GET_FIRM_VERSION */
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ks_wlan_net 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
before/after changes.
Link: https://reviews.llvm.org/D134831 [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
Changes in v2:
- None. This patch is new in the series.
drivers/staging/ks7010/ks_wlan_net.c | 184 ++++++++++++++-------------
1 file changed, 94 insertions(+), 90 deletions(-)
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 7e8d37c169f0..835fa3637bd8 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1763,8 +1763,8 @@ static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev)
}
static int ks_wlan_set_stop_request(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -1772,7 +1772,7 @@ static int ks_wlan_set_stop_request(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
- if (!(*uwrq))
+ if (!(uwrq->mode))
return -EINVAL;
hostif_sme_enqueue(priv, SME_STOP_REQUEST);
@@ -1786,7 +1786,9 @@ static int ks_wlan_set_mlme(struct net_device *dev,
{
struct ks_wlan_private *priv = netdev_priv(dev);
struct iw_mlme *mlme = (struct iw_mlme *)extra;
- __u32 mode = 1;
+ union iwreq_data uwrq;
+
+ uwrq.mode = 1;
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
@@ -1799,13 +1801,14 @@ static int ks_wlan_set_mlme(struct net_device *dev,
mlme->reason_code == WLAN_REASON_MIC_FAILURE)
return 0;
- return ks_wlan_set_stop_request(dev, NULL, &mode, NULL);
+ return ks_wlan_set_stop_request(dev, NULL, &uwrq, NULL);
}
static int ks_wlan_get_firmware_version(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *uwrq, char *extra)
{
+ struct iw_point *dwrq = &uwrq->data;
struct ks_wlan_private *priv = netdev_priv(dev);
dwrq->length = priv->version_size + 1;
@@ -1814,8 +1817,8 @@ static int ks_wlan_get_firmware_version(struct net_device *dev,
}
static int ks_wlan_set_preamble(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -1823,17 +1826,17 @@ static int ks_wlan_set_preamble(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq != LONG_PREAMBLE && *uwrq != SHORT_PREAMBLE)
+ if (uwrq->mode != LONG_PREAMBLE && uwrq->mode != SHORT_PREAMBLE)
return -EINVAL;
- priv->reg.preamble = *uwrq;
+ priv->reg.preamble = uwrq->mode;
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
}
static int ks_wlan_get_preamble(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -1841,37 +1844,37 @@ static int ks_wlan_get_preamble(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
- *uwrq = priv->reg.preamble;
+ uwrq->mode = priv->reg.preamble;
return 0;
}
static int ks_wlan_set_power_mgmt(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
- if (*uwrq != POWER_MGMT_ACTIVE &&
- *uwrq != POWER_MGMT_SAVE1 &&
- *uwrq != POWER_MGMT_SAVE2)
+ if (uwrq->mode != POWER_MGMT_ACTIVE &&
+ uwrq->mode != POWER_MGMT_SAVE1 &&
+ uwrq->mode != POWER_MGMT_SAVE2)
return -EINVAL;
- if ((*uwrq == POWER_MGMT_SAVE1 || *uwrq == POWER_MGMT_SAVE2) &&
+ if ((uwrq->mode == POWER_MGMT_SAVE1 || uwrq->mode == POWER_MGMT_SAVE2) &&
(priv->reg.operation_mode != MODE_INFRASTRUCTURE))
return -EINVAL;
- priv->reg.power_mgmt = *uwrq;
+ priv->reg.power_mgmt = uwrq->mode;
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
return 0;
}
static int ks_wlan_get_power_mgmt(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -1879,13 +1882,13 @@ static int ks_wlan_get_power_mgmt(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
- *uwrq = priv->reg.power_mgmt;
+ uwrq->mode = priv->reg.power_mgmt;
return 0;
}
static int ks_wlan_set_scan_type(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -1893,39 +1896,39 @@ static int ks_wlan_set_scan_type(struct net_device *dev,
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq != ACTIVE_SCAN && *uwrq != PASSIVE_SCAN)
+ if (uwrq->mode != ACTIVE_SCAN && uwrq->mode != PASSIVE_SCAN)
return -EINVAL;
- priv->reg.scan_type = *uwrq;
+ priv->reg.scan_type = uwrq->mode;
return 0;
}
static int ks_wlan_get_scan_type(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- *uwrq = priv->reg.scan_type;
+ uwrq->mode = priv->reg.scan_type;
return 0;
}
static int ks_wlan_set_beacon_lost(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq > BEACON_LOST_COUNT_MAX)
+ if (uwrq->mode > BEACON_LOST_COUNT_MAX)
return -EINVAL;
- priv->reg.beacon_lost_count = *uwrq;
+ priv->reg.beacon_lost_count = uwrq->mode;
if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
priv->need_commit |= SME_MODE_SET;
@@ -1936,101 +1939,101 @@ static int ks_wlan_set_beacon_lost(struct net_device *dev,
}
static int ks_wlan_get_beacon_lost(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- *uwrq = priv->reg.beacon_lost_count;
+ uwrq->mode = priv->reg.beacon_lost_count;
return 0;
}
static int ks_wlan_set_phy_type(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
- if (*uwrq != D_11B_ONLY_MODE &&
- *uwrq != D_11G_ONLY_MODE &&
- *uwrq != D_11BG_COMPATIBLE_MODE)
+ if (uwrq->mode != D_11B_ONLY_MODE &&
+ uwrq->mode != D_11G_ONLY_MODE &&
+ uwrq->mode != D_11BG_COMPATIBLE_MODE)
return -EINVAL;
/* for SLEEP MODE */
- priv->reg.phy_type = *uwrq;
+ priv->reg.phy_type = uwrq->mode;
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
}
static int ks_wlan_get_phy_type(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- *uwrq = priv->reg.phy_type;
+ uwrq->mode = priv->reg.phy_type;
return 0;
}
static int ks_wlan_set_cts_mode(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq != CTS_MODE_FALSE && *uwrq != CTS_MODE_TRUE)
+ if (uwrq->mode != CTS_MODE_FALSE && uwrq->mode != CTS_MODE_TRUE)
return -EINVAL;
- priv->reg.cts_mode = (*uwrq == CTS_MODE_FALSE) ? *uwrq :
+ priv->reg.cts_mode = (uwrq->mode == CTS_MODE_FALSE) ? uwrq->mode :
(priv->reg.phy_type == D_11G_ONLY_MODE ||
priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) ?
- *uwrq : !*uwrq;
+ uwrq->mode : !uwrq->mode;
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
}
static int ks_wlan_get_cts_mode(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- *uwrq = priv->reg.cts_mode;
+ uwrq->mode = priv->reg.cts_mode;
return 0;
}
static int ks_wlan_set_sleep_mode(struct net_device *dev,
struct iw_request_info *info,
- __u32 *uwrq, char *extra)
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
- if (*uwrq != SLP_SLEEP &&
- *uwrq != SLP_ACTIVE) {
- netdev_err(dev, "SET_SLEEP_MODE %d error\n", *uwrq);
+ if (uwrq->mode != SLP_SLEEP &&
+ uwrq->mode != SLP_ACTIVE) {
+ netdev_err(dev, "SET_SLEEP_MODE %d error\n", uwrq->mode);
return -EINVAL;
}
- priv->sleep_mode = *uwrq;
+ priv->sleep_mode = uwrq->mode;
netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode);
- if (*uwrq == SLP_SLEEP)
+ if (uwrq->mode == SLP_SLEEP)
hostif_sme_enqueue(priv, SME_STOP_REQUEST);
hostif_sme_enqueue(priv, SME_SLEEP_REQUEST);
@@ -2040,52 +2043,53 @@ static int ks_wlan_set_sleep_mode(struct net_device *dev,
static int ks_wlan_get_sleep_mode(struct net_device *dev,
struct iw_request_info *info,
- __u32 *uwrq, char *extra)
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
- *uwrq = priv->sleep_mode;
+ uwrq->mode = priv->sleep_mode;
return 0;
}
static int ks_wlan_set_wps_enable(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq != 0 && *uwrq != 1)
+ if (uwrq->mode != 0 && uwrq->mode != 1)
return -EINVAL;
- priv->wps.wps_enabled = *uwrq;
+ priv->wps.wps_enabled = uwrq->mode;
hostif_sme_enqueue(priv, SME_WPS_ENABLE_REQUEST);
return 0;
}
static int ks_wlan_get_wps_enable(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- *uwrq = priv->wps.wps_enabled;
- netdev_info(dev, "return=%d\n", *uwrq);
+ uwrq->mode = priv->wps.wps_enabled;
+ netdev_info(dev, "return=%d\n", uwrq->mode);
return 0;
}
static int ks_wlan_set_wps_probe_req(struct net_device *dev,
struct iw_request_info *info,
- struct iw_point *dwrq, char *extra)
+ union iwreq_data *uwrq, char *extra)
{
+ struct iw_point *dwrq = &uwrq->data;
u8 *p = extra;
unsigned char len;
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -2114,76 +2118,76 @@ static int ks_wlan_set_wps_probe_req(struct net_device *dev,
}
static int ks_wlan_set_tx_gain(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq > 0xFF)
+ if (uwrq->mode > 0xFF)
return -EINVAL;
- priv->gain.tx_gain = (u8)*uwrq;
+ priv->gain.tx_gain = (u8)uwrq->mode;
priv->gain.tx_mode = (priv->gain.tx_gain < 0xFF) ? 1 : 0;
hostif_sme_enqueue(priv, SME_SET_GAIN);
return 0;
}
static int ks_wlan_get_tx_gain(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- *uwrq = priv->gain.tx_gain;
+ uwrq->mode = priv->gain.tx_gain;
hostif_sme_enqueue(priv, SME_GET_GAIN);
return 0;
}
static int ks_wlan_set_rx_gain(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- if (*uwrq > 0xFF)
+ if (uwrq->mode > 0xFF)
return -EINVAL;
- priv->gain.rx_gain = (u8)*uwrq;
+ priv->gain.rx_gain = (u8)uwrq->mode;
priv->gain.rx_mode = (priv->gain.rx_gain < 0xFF) ? 1 : 0;
hostif_sme_enqueue(priv, SME_SET_GAIN);
return 0;
}
static int ks_wlan_get_rx_gain(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
if (priv->sleep_mode == SLP_SLEEP)
return -EPERM;
/* for SLEEP MODE */
- *uwrq = priv->gain.rx_gain;
+ uwrq->mode = priv->gain.rx_gain;
hostif_sme_enqueue(priv, SME_GET_GAIN);
return 0;
}
static int ks_wlan_get_eeprom_cksum(struct net_device *dev,
- struct iw_request_info *info, __u32 *uwrq,
- char *extra)
+ struct iw_request_info *info,
+ union iwreq_data *uwrq, char *extra)
{
struct ks_wlan_private *priv = netdev_priv(dev);
- *uwrq = priv->eeprom_checksum;
+ uwrq->mode = priv->eeprom_checksum;
return 0;
}
@@ -2302,7 +2306,7 @@ static void print_hif_event(struct net_device *dev, int event)
/* get host command history */
static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *info,
- __u32 *uwrq, char *extra)
+ union iwreq_data *uwrq, char *extra)
{
int i, event;
struct ks_wlan_private *priv = netdev_priv(dev);
@@ -2461,7 +2465,7 @@ static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq,
switch (cmd) {
case SIOCIWFIRSTPRIV + 20: /* KS_WLAN_SET_STOP_REQ */
- ret = ks_wlan_set_stop_request(dev, NULL, &wrq->u.mode, NULL);
+ ret = ks_wlan_set_stop_request(dev, NULL, &wrq->u, NULL);
break;
// All other calls are currently unsupported
default:
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 6/6] staging: ks7010: Avoid clashing function prototypes
2022-10-27 20:22 ` [PATCH v2 6/6] staging: ks7010: " Gustavo A. R. Silva
@ 2022-10-29 7:20 ` Kees Cook
0 siblings, 0 replies; 3+ messages in thread
From: Kees Cook @ 2022-10-29 7:20 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Greg Kroah-Hartman, linux-staging, linux-kernel, linux-hardening
On Thu, Oct 27, 2022 at 03:22:46PM -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 27 warnings like these:
>
> drivers/staging/ks7010/ks_wlan_net.c:2415:2: 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_handler)ks_wlan_get_firmware_version,/* 3 KS_WLAN_GET_FIRM_VERSION */
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> The ks_wlan_net 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
> before/after changes.
>
> Link: https://reviews.llvm.org/D134831 [1]
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> ---
> Changes in v2:
> - None. This patch is new in the series.
>
> drivers/staging/ks7010/ks_wlan_net.c | 184 ++++++++++++++-------------
I think the casts in ks_wlan_private_handler can be removed, too?
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-29 7:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-27 20:16 [PATCH v2 0/6] Avoid clashing function prototypes Gustavo A. R. Silva
2022-10-27 20:22 ` [PATCH v2 6/6] staging: ks7010: " Gustavo A. R. Silva
2022-10-29 7:20 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox