From nobody Wed Apr 8 17:28:17 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F8ECECAAA1 for ; Thu, 27 Oct 2022 20:22:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236963AbiJ0UWy (ORCPT ); Thu, 27 Oct 2022 16:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236837AbiJ0UWw (ORCPT ); Thu, 27 Oct 2022 16:22:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21BF68D233; Thu, 27 Oct 2022 13:22:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A6A82624E3; Thu, 27 Oct 2022 20:22:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 493E0C433D6; Thu, 27 Oct 2022 20:22:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666902170; bh=qNWH0Mj9EV6KWOBrM1nSFfRrqpnHhdgAOSQGLJl090U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Jbmc01aw+lNn+2ABpVBYXuNzVDgN1iUKu2xNzTA6Pj90FzztZH5IzqDqvXIRCVWFF EngleDxEP/eObYt+pbI9MZ5GfOs5fswUEeqEIg61uW3vSPwuCGujh13BHLoeVwJiJ1 2JAk8bGs3G/t71GClD3FEYpAbAglZyy3RGUIhs7exV73rFmgjmRt2Bl77HNsY9CZJr 1M9XUris4WodKznX32qnG0oCGjplEhlSsKACRxY0ESkBW/12d/wL8uhMHY81vC5HR1 DBwsjGG/BLSfVrXiROZTrNDOUITZdNjDCEevEaw7OS/29m5SPWPY5SJh3lCDuq7LEM P1QSAk/Ri3Eog== Date: Thu, 27 Oct 2022 15:22:46 -0500 From: "Gustavo A. R. Silva" To: Greg Kroah-Hartman Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Kees Cook , "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH v2 6/6] staging: ks7010: Avoid clashing function prototypes Message-ID: <34bf3ce1b1ca2da4c5ec8a6e26f31bbb9ca1c4f5.1666894751.git.gustavoars@kernel.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 (*)(st= ruct 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 [-Wcas= t-function-type-strict] (iw_handler)ks_wlan_get_firmware_version,/* 3 KS_WLAN_GET_FIRM_VERS= ION */ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 --- 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(st= ruct net_device *dev) } =20 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 =3D netdev_priv(dev); =20 @@ -1772,7 +1772,7 @@ static int ks_wlan_set_stop_request(struct net_device= *dev, return -EPERM; =20 /* for SLEEP MODE */ - if (!(*uwrq)) + if (!(uwrq->mode)) return -EINVAL; =20 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 =3D netdev_priv(dev); struct iw_mlme *mlme =3D (struct iw_mlme *)extra; - __u32 mode =3D 1; + union iwreq_data uwrq; + + uwrq.mode =3D 1; =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; @@ -1799,13 +1801,14 @@ static int ks_wlan_set_mlme(struct net_device *dev, mlme->reason_code =3D=3D WLAN_REASON_MIC_FAILURE) return 0; =20 - return ks_wlan_set_stop_request(dev, NULL, &mode, NULL); + return ks_wlan_set_stop_request(dev, NULL, &uwrq, NULL); } =20 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 =3D &uwrq->data; struct ks_wlan_private *priv =3D netdev_priv(dev); =20 dwrq->length =3D priv->version_size + 1; @@ -1814,8 +1817,8 @@ static int ks_wlan_get_firmware_version(struct net_de= vice *dev, } =20 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 =3D netdev_priv(dev); =20 @@ -1823,17 +1826,17 @@ static int ks_wlan_set_preamble(struct net_device *= dev, return -EPERM; =20 /* for SLEEP MODE */ - if (*uwrq !=3D LONG_PREAMBLE && *uwrq !=3D SHORT_PREAMBLE) + if (uwrq->mode !=3D LONG_PREAMBLE && uwrq->mode !=3D SHORT_PREAMBLE) return -EINVAL; =20 - priv->reg.preamble =3D *uwrq; + priv->reg.preamble =3D uwrq->mode; priv->need_commit |=3D SME_MODE_SET; return -EINPROGRESS; /* Call commit handler */ } =20 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 =3D netdev_priv(dev); =20 @@ -1841,37 +1844,37 @@ static int ks_wlan_get_preamble(struct net_device *= dev, return -EPERM; =20 /* for SLEEP MODE */ - *uwrq =3D priv->reg.preamble; + uwrq->mode =3D priv->reg.preamble; return 0; } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; =20 - if (*uwrq !=3D POWER_MGMT_ACTIVE && - *uwrq !=3D POWER_MGMT_SAVE1 && - *uwrq !=3D POWER_MGMT_SAVE2) + if (uwrq->mode !=3D POWER_MGMT_ACTIVE && + uwrq->mode !=3D POWER_MGMT_SAVE1 && + uwrq->mode !=3D POWER_MGMT_SAVE2) return -EINVAL; =20 - if ((*uwrq =3D=3D POWER_MGMT_SAVE1 || *uwrq =3D=3D POWER_MGMT_SAVE2) && + if ((uwrq->mode =3D=3D POWER_MGMT_SAVE1 || uwrq->mode =3D=3D POWER_MGMT_S= AVE2) && (priv->reg.operation_mode !=3D MODE_INFRASTRUCTURE)) return -EINVAL; =20 - priv->reg.power_mgmt =3D *uwrq; + priv->reg.power_mgmt =3D uwrq->mode; hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); =20 return 0; } =20 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 =3D netdev_priv(dev); =20 @@ -1879,13 +1882,13 @@ static int ks_wlan_get_power_mgmt(struct net_device= *dev, return -EPERM; =20 /* for SLEEP MODE */ - *uwrq =3D priv->reg.power_mgmt; + uwrq->mode =3D priv->reg.power_mgmt; return 0; } =20 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 =3D netdev_priv(dev); =20 @@ -1893,39 +1896,39 @@ static int ks_wlan_set_scan_type(struct net_device = *dev, return -EPERM; /* for SLEEP MODE */ =20 - if (*uwrq !=3D ACTIVE_SCAN && *uwrq !=3D PASSIVE_SCAN) + if (uwrq->mode !=3D ACTIVE_SCAN && uwrq->mode !=3D PASSIVE_SCAN) return -EINVAL; =20 - priv->reg.scan_type =3D *uwrq; + priv->reg.scan_type =3D uwrq->mode; return 0; } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - *uwrq =3D priv->reg.scan_type; + uwrq->mode =3D priv->reg.scan_type; return 0; } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq > BEACON_LOST_COUNT_MAX) + if (uwrq->mode > BEACON_LOST_COUNT_MAX) return -EINVAL; =20 - priv->reg.beacon_lost_count =3D *uwrq; + priv->reg.beacon_lost_count =3D uwrq->mode; =20 if (priv->reg.operation_mode =3D=3D MODE_INFRASTRUCTURE) { priv->need_commit |=3D SME_MODE_SET; @@ -1936,101 +1939,101 @@ static int ks_wlan_set_beacon_lost(struct net_dev= ice *dev, } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - *uwrq =3D priv->reg.beacon_lost_count; + uwrq->mode =3D priv->reg.beacon_lost_count; return 0; } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; =20 - if (*uwrq !=3D D_11B_ONLY_MODE && - *uwrq !=3D D_11G_ONLY_MODE && - *uwrq !=3D D_11BG_COMPATIBLE_MODE) + if (uwrq->mode !=3D D_11B_ONLY_MODE && + uwrq->mode !=3D D_11G_ONLY_MODE && + uwrq->mode !=3D D_11BG_COMPATIBLE_MODE) return -EINVAL; =20 /* for SLEEP MODE */ - priv->reg.phy_type =3D *uwrq; + priv->reg.phy_type =3D uwrq->mode; priv->need_commit |=3D SME_MODE_SET; return -EINPROGRESS; /* Call commit handler */ } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - *uwrq =3D priv->reg.phy_type; + uwrq->mode =3D priv->reg.phy_type; return 0; } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq !=3D CTS_MODE_FALSE && *uwrq !=3D CTS_MODE_TRUE) + if (uwrq->mode !=3D CTS_MODE_FALSE && uwrq->mode !=3D CTS_MODE_TRUE) return -EINVAL; =20 - priv->reg.cts_mode =3D (*uwrq =3D=3D CTS_MODE_FALSE) ? *uwrq : + priv->reg.cts_mode =3D (uwrq->mode =3D=3D CTS_MODE_FALSE) ? uwrq->mode : (priv->reg.phy_type =3D=3D D_11G_ONLY_MODE || priv->reg.phy_type =3D=3D D_11BG_COMPATIBLE_MODE) ? - *uwrq : !*uwrq; + uwrq->mode : !uwrq->mode; =20 priv->need_commit |=3D SME_MODE_SET; return -EINPROGRESS; /* Call commit handler */ } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - *uwrq =3D priv->reg.cts_mode; + uwrq->mode =3D priv->reg.cts_mode; return 0; } =20 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 =3D netdev_priv(dev); =20 - if (*uwrq !=3D SLP_SLEEP && - *uwrq !=3D SLP_ACTIVE) { - netdev_err(dev, "SET_SLEEP_MODE %d error\n", *uwrq); + if (uwrq->mode !=3D SLP_SLEEP && + uwrq->mode !=3D SLP_ACTIVE) { + netdev_err(dev, "SET_SLEEP_MODE %d error\n", uwrq->mode); return -EINVAL; } =20 - priv->sleep_mode =3D *uwrq; + priv->sleep_mode =3D uwrq->mode; netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode); =20 - if (*uwrq =3D=3D SLP_SLEEP) + if (uwrq->mode =3D=3D SLP_SLEEP) hostif_sme_enqueue(priv, SME_STOP_REQUEST); =20 hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); @@ -2040,52 +2043,53 @@ static int ks_wlan_set_sleep_mode(struct net_device= *dev, =20 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 =3D netdev_priv(dev); =20 - *uwrq =3D priv->sleep_mode; + uwrq->mode =3D priv->sleep_mode; =20 return 0; } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq !=3D 0 && *uwrq !=3D 1) + if (uwrq->mode !=3D 0 && uwrq->mode !=3D 1) return -EINVAL; =20 - priv->wps.wps_enabled =3D *uwrq; + priv->wps.wps_enabled =3D uwrq->mode; hostif_sme_enqueue(priv, SME_WPS_ENABLE_REQUEST); =20 return 0; } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - *uwrq =3D priv->wps.wps_enabled; - netdev_info(dev, "return=3D%d\n", *uwrq); + uwrq->mode =3D priv->wps.wps_enabled; + netdev_info(dev, "return=3D%d\n", uwrq->mode); =20 return 0; } =20 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 =3D &uwrq->data; u8 *p =3D extra; unsigned char len; struct ks_wlan_private *priv =3D netdev_priv(dev); @@ -2114,76 +2118,76 @@ static int ks_wlan_set_wps_probe_req(struct net_dev= ice *dev, } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq > 0xFF) + if (uwrq->mode > 0xFF) return -EINVAL; =20 - priv->gain.tx_gain =3D (u8)*uwrq; + priv->gain.tx_gain =3D (u8)uwrq->mode; priv->gain.tx_mode =3D (priv->gain.tx_gain < 0xFF) ? 1 : 0; hostif_sme_enqueue(priv, SME_SET_GAIN); return 0; } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - *uwrq =3D priv->gain.tx_gain; + uwrq->mode =3D priv->gain.tx_gain; hostif_sme_enqueue(priv, SME_GET_GAIN); return 0; } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq > 0xFF) + if (uwrq->mode > 0xFF) return -EINVAL; =20 - priv->gain.rx_gain =3D (u8)*uwrq; + priv->gain.rx_gain =3D (u8)uwrq->mode; priv->gain.rx_mode =3D (priv->gain.rx_gain < 0xFF) ? 1 : 0; hostif_sme_enqueue(priv, SME_SET_GAIN); return 0; } =20 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 =3D netdev_priv(dev); =20 if (priv->sleep_mode =3D=3D SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - *uwrq =3D priv->gain.rx_gain; + uwrq->mode =3D priv->gain.rx_gain; hostif_sme_enqueue(priv, SME_GET_GAIN); return 0; } =20 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 =3D netdev_priv(dev); =20 - *uwrq =3D priv->eeprom_checksum; + uwrq->mode =3D priv->eeprom_checksum; return 0; } =20 @@ -2302,7 +2306,7 @@ static void print_hif_event(struct net_device *dev, i= nt event) =20 /* get host command history */ static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *i= nfo, - __u32 *uwrq, char *extra) + union iwreq_data *uwrq, char *extra) { int i, event; struct ks_wlan_private *priv =3D netdev_priv(dev); @@ -2461,7 +2465,7 @@ static int ks_wlan_netdev_ioctl(struct net_device *de= v, struct ifreq *rq, =20 switch (cmd) { case SIOCIWFIRSTPRIV + 20: /* KS_WLAN_SET_STOP_REQ */ - ret =3D ks_wlan_set_stop_request(dev, NULL, &wrq->u.mode, NULL); + ret =3D ks_wlan_set_stop_request(dev, NULL, &wrq->u, NULL); break; // All other calls are currently unsupported default: --=20 2.34.1