wifi: ath9k: fix printk specifier
Subsystems (7)
Sasha Levin
maintainerPATCH 1/8 wifi: ath9k: fix printk specifier
From: Dongliang Mu <[email protected]>
[ Upstream commit 061115fbfb2ce5870c9a004d68dc63138c07c782 ]
Smatch reports:
ath_pci_probe() warn: argument 4 to %lx specifier is cast from pointer ath_ahb_probe() warn: argument 4 to %lx specifier is cast from pointer
Fix it by modifying %lx to %p in the printk format string.
Note that with this change, the pointer address will be printed as a hashed value by default. This is appropriate because the kernel should not leak kernel pointers to user space in an informational message. If someone wants to see the real address for debugging purposes, this can be achieved with the no_hash_pointers kernel option.
--- drivers/net/wireless/ath/ath9k/ahb.c | 4 ++-- drivers/net/wireless/ath/ath9k/pci.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/ahb.c +2 -2
@@ -135,8 +135,8 @@ static int ath_ahb_probe(struct platform_device *pdev) ah = sc->sc_ah;ath9k_hw_name (ah, hw_name,sizeof (hw_name)); -wiphy_info (hw->wiphy,"%s mem=0x%lx, irq=%d\n" , - hw_name, (unsigned long )mem, irq); +wiphy_info (hw->wiphy,"%s mem=0x%p, irq=%d\n" , + hw_name, mem, irq);return 0 ;
drivers/net/wireless/ath/ath9k/pci.c +2 -2
@@ -975,8 +975,8 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) }ath9k_hw_name (sc->sc_ah, hw_name,sizeof (hw_name)); -wiphy_info (hw->wiphy,"%s mem=0x%lx, irq=%d\n" , - hw_name, (unsigned long )sc->mem, pdev->irq); +wiphy_info (hw->wiphy,"%s mem=0x%p, irq=%d\n" , + hw_name, sc->mem, pdev->irq);return 0 ;
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 2/8 wifi: mwifiex: fix fortify warning
From: Dmitry Antipov <[email protected]>
[ Upstream commit dcce94b80a954a8968ff29fafcfb066d6197fa9a ]
When compiling with gcc 13.1 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following:
In function ‘fortify_memcpy_chk’,
inlined from ‘mwifiex_construct_tdls_action_frame’ at drivers/net/wireless/marvell/mwifiex/tdls.c:765:3, inlined from ‘mwifiex_send_tdls_action_frame’ at drivers/net/wireless/marvell/mwifiex/tdls.c:856:6:./include/linux/fortify-string.h:529:25: warning: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter);
maybe use struct_group()? [-Wattribute-warning]
529 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The compiler actually complains on:
memmove(pos + ETH_ALEN, &mgmt->u.action.category,
sizeof(mgmt->u.action.u.tdls_discover_resp));
and it happens because the fortification logic interprets this as an attempt to overread 1-byte 'u.action.category' member of 'struct ieee80211_mgmt'. To silence this warning, it's enough to pass an address of 'u.action' itself instead of an address of its first member.
This also fixes an improper usage of 'sizeof()'. Since 'skb' is extended with 'sizeof(mgmt->u.action.u.tdls_discover_resp) + 1' bytes (where 1 is actually 'sizeof(mgmt->u.action.category)'), I assume that the same number of bytes should be copied.
--- drivers/net/wireless/marvell/mwifiex/tdls.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/marvell/mwifiex/tdls.c +6 -3
@@ -737,6 +737,7 @@ mwifiex_construct_tdls_action_frame(struct mwifiex_private *priv,int ret;u16 capab;struct ieee80211_ht_cap *ht_cap; +unsigned int extra;u8 radio, *pos; capab = priv->curr_bss_params.bss_descriptor.cap_info_bitmap;
@@ -755,7 +756,10 @@ mwifiex_construct_tdls_action_frame(struct mwifiex_private *priv,switch (action_code) {case WLAN_PUB_ACTION_TDLS_DISCOVER_RES : -skb_put (skb,sizeof (mgmt->u.action.u.tdls_discover_resp) +1 ); +/* See the layout of 'struct ieee80211_mgmt'. */ + extra =sizeof (mgmt->u.action.u.tdls_discover_resp) + +sizeof (mgmt->u.action.category); +skb_put (skb, extra); mgmt->u.action.category =WLAN_CATEGORY_PUBLIC ; mgmt->u.action.u.tdls_discover_resp.action_code =WLAN_PUB_ACTION_TDLS_DISCOVER_RES ;
@@ -764,8 +768,7 @@ mwifiex_construct_tdls_action_frame(struct mwifiex_private *priv, mgmt->u.action.u.tdls_discover_resp.capability =cpu_to_le16 (capab);/* move back for addr4 */ -memmove (pos +ETH_ALEN , &mgmt->u.action.category, -sizeof (mgmt->u.action.u.tdls_discover_resp)); +memmove (pos +ETH_ALEN , &mgmt->u.action, extra);/* init address 4 */ memcpy (pos, bc_addr,ETH_ALEN );
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 3/8 crypto: lib/mpi - avoid null pointer deref in mpi_cmp_ui()
In reply to Sasha LevinFrom: Mark O'Donovan <[email protected]>
[ Upstream commit 9e47a758b70167c9301d2b44d2569f86c7796f2d ]
During NVMeTCP Authentication a controller can trigger a kernel oops by specifying the 8192 bit Diffie Hellman group and passing a correctly sized, but zeroed Diffie Hellamn value. mpi_cmp_ui() was detecting this if the second parameter was 0, but 1 is passed from dh_is_pubkey_valid(). This causes the null pointer u->d to be dereferenced towards the end of mpi_cmp_ui()
--- lib/mpi/mpi-cmp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
lib/mpi/mpi-cmp.c +6 -2
@@ -25,8 +25,12 @@ int mpi_cmp_ui(MPI u, unsigned long v)mpi_limb_t limb = v;mpi_normalize (u); -if (!u->nlimbs && !limb) -return 0 ; +if (u->nlimbs ==0 ) { +if (v ==0 ) +return 0 ; +else +return -1 ; + }if (u->sign)return -1 ;if (u->nlimbs >1 )
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 4/8 tpm_tis: Resend command to recover from data transfer errors
In reply to Sasha LevinFrom: Alexander Steffen <[email protected]>
[ Upstream commit 280db21e153d8810ce3b93640c63ae922bcb9e8e ]
Similar to the transmission of TPM responses, also the transmission of TPM commands may become corrupted. Instead of aborting when detecting such issues, try resending the command again.
--- drivers/char/tpm/tpm_tis_core.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/char/tpm/tpm_tis_core.c +11 -4
@@ -364,10 +364,17 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len)int rc;u32 ordinal;unsigned long dur; - - rc =tpm_tis_send_data (chip, buf, len); -if (rc <0 ) -return rc; +unsigned int try; + +for (try =0 ; try <TPM_RETRY ; try++) { + rc =tpm_tis_send_data (chip, buf, len); +if (rc >=0 ) +/* Data transfer done successfully */ +break ; +else if (rc != -EIO ) +/* Data transfer failed, not recoverable */ +return rc; + }/* go and do it */ rc =tpm_tis_write8 (priv,TPM_STS (priv->locality),TPM_STS_GO );
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 5/8 alx: fix OOB-read compiler warning
In reply to Sasha LevinFrom: "GONG, Ruiqi" <[email protected]>
[ Upstream commit 3a198c95c95da10ad844cbeade2fe40bdf14c411 ]
The following message shows up when compiling with W=1:
In function ‘fortify_memcpy_chk’,
inlined from ‘alx_get_ethtool_stats’ at drivers/net/ethernet/atheros/alx/ethtool.c:297:2:./include/linux/fortify-string.h:592:4: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
592 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In order to get alx stats altogether, alx_get_ethtool_stats() reads beyond hw->stats.rx_ok. Fix this warning by directly copying hw->stats, and refactor the unnecessarily complicated BUILD_BUG_ON btw.
--- drivers/net/ethernet/atheros/alx/ethtool.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/atheros/alx/ethtool.c +2 -3
@@ -281,9 +281,8 @@ static void alx_get_ethtool_stats(struct net_device *netdev,spin_lock (&alx->stats_lock);alx_update_hw_stats (hw); -BUILD_BUG_ON (sizeof (hw->stats) - offsetof(struct alx_hw_stats , rx_ok) < -ALX_NUM_STATS *sizeof (u64)); -memcpy (data, &hw->stats.rx_ok,ALX_NUM_STATS *sizeof (u64)); +BUILD_BUG_ON (sizeof (hw->stats) !=ALX_NUM_STATS *sizeof (u64)); +memcpy (data, &hw->stats,sizeof (hw->stats));spin_unlock (&alx->stats_lock); }
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 6/8 netfilter: ebtables: fix fortify warnings in size_entry_mwt()
In reply to Sasha LevinFrom: "GONG, Ruiqi" <[email protected]>
[ Upstream commit a7ed3465daa240bdf01a5420f64336fee879c09d ]
When compiling with gcc 13 and CONFIG_FORTIFY_SOURCE=y, the following warning appears:
In function ‘fortify_memcpy_chk’,
inlined from ‘size_entry_mwt’ at net/bridge/netfilter/ebtables.c:2118:2:./include/linux/fortify-string.h:592:25: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror=attribute-warning]
592 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The compiler is complaining:
memcpy(&offsets[1], &entry->watchers_offset,
sizeof(offsets) - sizeof(offsets[0]));
where memcpy reads beyong &entry->watchers_offset to copy {watchers,target,next}_offset altogether into offsets[]. Silence the warning by wrapping these three up via struct_group().
--- include/uapi/linux/netfilter_bridge/ebtables.h | 14 ++++++++------ net/bridge/netfilter/ebtables.c | 3 +-- 2 files changed, 9 insertions(+), 8 deletions(-)
include/uapi/linux/netfilter_bridge/ebtables.h +8 -6
@@ -172,12 +172,14 @@ struct ebt_entry {unsigned char sourcemsk[ETH_ALEN ];unsigned char destmac[ETH_ALEN ];unsigned char destmsk[ETH_ALEN ]; -/* sizeof ebt_entry + matches */ -unsigned int watchers_offset; -/* sizeof ebt_entry + matches + watchers */ -unsigned int target_offset; -/* sizeof ebt_entry + matches + watchers + target */ -unsigned int next_offset; + __struct_group(/* no tag */, offsets, /* no attrs */, +/* sizeof ebt_entry + matches */ + unsigned int watchers_offset; +/* sizeof ebt_entry + matches + watchers */ +unsigned int target_offset; +/* sizeof ebt_entry + matches + watchers + target */ +unsigned int next_offset; + ); unsigned char elems[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); };
net/bridge/netfilter/ebtables.c +1 -2
@@ -2071,8 +2071,7 @@ static int size_entry_mwt(const struct ebt_entry *entry, const unsigned char *bareturn ret; offsets[0 ] =sizeof (struct ebt_entry );/* matches come first */ -memcpy (&offsets[1 ], &entry->watchers_offset, -sizeof (offsets) -sizeof (offsets[0 ])); +memcpy (&offsets[1 ], &entry->offsets,sizeof (entry->offsets));if (state->buf_kern_start) { buf_start = state->buf_kern_start + state->buf_kern_offset;
Signature · 1 line
2.40.1
Re: [PATCH AUTOSEL 4.14 6/8] netfilter: ebtables: fix fortify warnings in size_entry_mwt()
Hi!
Quoted 5 lines
[ Upstream commit
a7ed3465daa240bdf01a5420f64336fee879c09d]When compiling with gcc 13 and
CONFIG_FORTIFY_SOURCE=y, the following warning appears:
Quoted 8 lines
In function ‘fortify_memcpy_chk’,
inlined from ‘size_entry_mwt’ atnet/bridge/netfilter/ebtables.c:2118:2:./include/linux/fortify-string.h:592:25: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe usestruct_group()? [-Werror=attribute-warning]592 | __read_overflow2_field(q_size_field, size); |^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is not queued for 4.19. Mistake?
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Sasha Levin
maintainerPATCH 7/8 wifi: cfg80211: ocb: don't leave if not joined
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit abc76cf552e13cfa88a204b362a86b0e08e95228 ]
If there's no OCB state, don't ask the driver/mac80211 to leave, since that's just confusing. Since set/clear the chandef state, that's a simple check.
--- net/wireless/ocb.c | 3 +++ 1 file changed, 3 insertions(+)
net/wireless/ocb.c +3 -0
@@ -70,6 +70,9 @@ int __cfg80211_leave_ocb(struct cfg80211_registered_device *rdev,if (!rdev->ops->leave_ocb)return -EOPNOTSUPP ; +if (!wdev->u.ocb.chandef.chan) +return -ENOTCONN ; + err =rdev_leave_ocb (rdev, dev);if (!err)memset (&wdev->chandef,0 ,sizeof (wdev->chandef));
Signature · 1 line
2.40.1
Re: [PATCH AUTOSEL 4.14 7/8] wifi: cfg80211: ocb: don't leave if not joined
Hi!
Quoted 3 lines
If there's no OCB state, don't ask the driver/mac80211 to leave, since that's just confusing. Since set/clear the chandef state, that's a simple check.
This is not queued for 5.10. Mistake?
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Sasha Levin
maintainerPATCH 8/8 Bluetooth: btusb: Fix quirks table naming
In reply to Sasha LevinFrom: Bastien Nocera <[email protected]>
[ Upstream commit d831e3612111d385e8629104af5429808ef26e25 ]
The quirks table was named "blacklist_table" which isn't a good description for that table as devices detected using it weren't ignored by the driver.
Rename the table to match what it actually does.
--- drivers/bluetooth/btusb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bluetooth/btusb.c +2 -2
@@ -186,7 +186,7 @@ static const struct usb_device_id btusb_table[] = {MODULE_DEVICE_TABLE (usb, btusb_table); -static const struct usb_device_id blacklist_table[] = { +static const struct usb_device_id quirks_table[] = {/* CSR BlueCore devices */ {USB_DEVICE (0x0a12 ,0x0001 ), .driver_info =BTUSB_CSR },
@@ -2963,7 +2963,7 @@ static int btusb_probe(struct usb_interface *intf,if (!id->driver_info) {const struct usb_device_id *match; - match =usb_match_id (intf, blacklist_table); + match =usb_match_id (intf, quirks_table);if (match) id = match; }
Signature · 1 line
2.40.1
Re: [PATCH AUTOSEL 4.14 8/8] Bluetooth: btusb: Fix quirks table naming
Hi!
Quoted 9 lines
From: Bastien Nocera <[email protected]>
[ Upstream commit
d831e3612111d385e8629104af5429808ef26e25]The quirks table was named "
blacklist_table" which isn't a good description for that table as devices detected using it weren't ignored by the driver.Rename the table to match what it actually does.
Cleanup, not a bugfix. Don't need it in stable.
Best regards,
Pavel
Quoted 19 lines
+++
b/drivers/bluetooth/btusb.cdrivers/bluetooth/btusb.c +2
-2@@ -186,7 +186,7 @@ static const struct usb_device_id btusb_table[] = {MODULE_DEVICE_TABLE (usb, btusb_table); -static const struct usb_device_id blacklist_table[] = { +static const struct usb_device_id quirks_table[] = {/* CSR BlueCore devices */ {USB_DEVICE (0x0a12 ,0x0001 ), .driver_info =BTUSB_CSR },@@ -2963,7 +2963,7 @@ static int btusb_probe(struct usb_interface *intf,if (!id->driver_info) {const struct usb_device_id *match; - match =usb_match_id (intf, blacklist_table); + match =usb_match_id (intf, quirks_table);if (match) id = match; }
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany