devlink: remove reload failed checks in params get/set callbacks
Subsystems (10)
Sasha Levin
maintainerPATCH 11/14 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
@@ -182,12 +182,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
@@ -2001,8 +2001,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
Sasha Levin
maintainerPATCH 1/14 devlink: remove reload failed checks in params get/set callbacks
From: Jiri Pirko <[email protected]>
[ Upstream commit 633d76ad01ad0321a1ace3e5cc4fed06753d7ac4 ]
The checks in question were introduced by:
commit 6b4db2e528f6 ("devlink: Fix use-after-free after a failed reload"). That fixed an issue of reload with mlxsw driver.
Back then, that was a valid fix, because there was a limitation in place that prevented drivers from registering/unregistering params when devlink instance was registered.
It was possible to do the fix differently by changing drivers to register/unregister params in appropriate places making sure the ops operate only on memory which is allocated and initialized. But that, as a dependency, would require to remove the limitation mentioned above.
Eventually, this limitation was lifted by:
commit 1d18bb1a4ddd ("devlink: allow registering parameters after the instance")
Also, the alternative fix (which also fixed another issue) was done by:
commit 74cbc3c03c82 ("mlxsw: spectrum_acl_tcam: Move devlink param to TCAM code").
Therefore, the checks are no longer relevant. Each driver should make sure to have the params registered only when the memory the ops are working with is allocated and initialized.
So remove the checks.
--- net/core/devlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/devlink.c +2 -2
@@ -3620,7 +3620,7 @@ static int devlink_param_get(struct devlink *devlink, const struct devlink_param *param, struct devlink_param_gset_ctx *ctx) { - if (!param->get || devlink->reload_failed) + if (!param->get) return -EOPNOTSUPP;return param->get (devlink, param->id, ctx); }
@@ -3629,7 +3629,7 @@ static int devlink_param_set(struct devlink *devlink, const struct devlink_param *param, struct devlink_param_gset_ctx *ctx) { - if (!param->set || devlink->reload_failed) + if (!param->set) return -EOPNOTSUPP;return param->set (devlink, param->id, ctx); }
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 10/14 alx: fix OOB-read compiler warning
From: "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 13/14 libbpf: Free btf_vmlinux when closing bpf_object
In reply to Sasha LevinFrom: Hao Luo <[email protected]>
[ Upstream commit 29d67fdebc42af6466d1909c60fdd1ef4f3e5240 ]
I hit a memory leak when testing bpf_program__set_attach_target(). Basically, set_attach_target() may allocate btf_vmlinux, for example, when setting attach target for bpf_iter programs. But btf_vmlinux is freed only in bpf_object_load(), which means if we only open bpf object but not load it, setting attach target may leak btf_vmlinux.
So let's free btf_vmlinux in bpf_object__close() anyway.
--- tools/lib/bpf/libbpf.c | 1 + 1 file changed, 1 insertion(+)
tools/lib/bpf/libbpf.c +1 -0
@@ -7962,6 +7962,7 @@ void bpf_object__close(struct bpf_object *obj)bpf_object__elf_finish (obj);bpf_object__unload (obj);btf__free (obj->btf); +btf__free (obj->btf_vmlinux);btf_ext__free (obj->btf_ext);for (i =0 ; i < obj->nr_maps; i++)
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 4/14 wifi: ath9k: fix printk specifier
In reply to Sasha LevinFrom: 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
@@ -136,8 +136,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
@@ -994,8 +994,8 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) sc->sc_ah->msi_reg =0 ;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 3/14 wifi: ath9k: fix fortify warnings
In reply to Sasha LevinFrom: Dmitry Antipov <[email protected]>
[ Upstream commit 810e41cebb6c6e394f2068f839e1a3fc745a5dcc ]
When compiling with gcc 13.1 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following:
In function ‘fortify_memcpy_chk’,
inlined from ‘ath_tx_complete_aggr’ at drivers/net/wireless/ath/ath9k/xmit.c:556:4, inlined from ‘ath_tx_process_buffer’ at drivers/net/wireless/ath/ath9k/xmit.c:773:3:./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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In function ‘fortify_memcpy_chk’,
inlined from ‘ath_tx_count_frames’ at drivers/net/wireless/ath/ath9k/xmit.c:473:3, inlined from ‘ath_tx_complete_aggr’ at drivers/net/wireless/ath/ath9k/xmit.c:572:2, inlined from ‘ath_tx_process_buffer’ at drivers/net/wireless/ath/ath9k/xmit.c:773:3:./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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~In both cases, the compiler complains on:
memcpy(ba, &ts->ba_low, WME_BA_BMP_SIZE >> 3);
which is the legal way to copy both 'ba_low' and following 'ba_high' members of 'struct ath_tx_status' at once (that is, issue one 8-byte 'memcpy()' for two 4-byte fields). Since the fortification logic seems interprets this trick as an attempt to overread 4-byte 'ba_low', silence relevant warnings by using the convenient 'struct_group()' quirk.
--- drivers/net/wireless/ath/ath9k/mac.h | 6 ++++-- drivers/net/wireless/ath/ath9k/xmit.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/mac.h +4 -2
@@ -113,8 +113,10 @@ struct ath_tx_status {u8 qid;u16 desc_id;u8 tid; -u32 ba_low; -u32 ba_high; +struct_group (ba, + u32 ba_low; + u32 ba_high; + );u32 evm0;u32 evm1;u32 evm2;
drivers/net/wireless/ath/ath9k/xmit.c +2 -2
@@ -421,7 +421,7 @@ static void ath_tx_count_frames(struct ath_softc *sc, struct ath_buf *bf, isaggr =bf_isaggr (bf);if (isaggr) { seq_st = ts->ts_seqnum; -memcpy (ba, &ts->ba_low,WME_BA_BMP_SIZE >>3 ); +memcpy (ba, &ts->ba,WME_BA_BMP_SIZE >>3 ); }while (bf) {
@@ -504,7 +504,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,if (isaggr && txok) {if (ts->ts_flags &ATH9K_TX_BA ) { seq_st = ts->ts_seqnum; -memcpy (ba, &ts->ba_low,WME_BA_BMP_SIZE >>3 ); +memcpy (ba, &ts->ba,WME_BA_BMP_SIZE >>3 ); }else {/* * AR5416 can become deaf/mute when BA
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 8/14 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
@@ -469,10 +469,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/14 wifi: mwifiex: fix fortify warning
In reply to Sasha LevinFrom: 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
@@ -735,6 +735,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;
@@ -753,7 +754,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 ;
@@ -762,8 +766,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 */ eth_broadcast_addr (pos);
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 12/14 wifi: mac80211_hwsim: drop short frames
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit fba360a047d5eeeb9d4b7c3a9b1c8308980ce9a6 ]
While technically some control frames like ACK are shorter and end after Address 1, such frames shouldn't be forwarded through wmediumd or similar userspace, so require the full 3-address header to avoid accessing invalid memory if shorter frames are passed in.
--- drivers/net/wireless/mac80211_hwsim.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/mac80211_hwsim.c +4 -3
@@ -3619,14 +3619,15 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2, frame_data_len =nla_len (info->attrs[HWSIM_ATTR_FRAME ]); frame_data = (void *)nla_data (info->attrs[HWSIM_ATTR_FRAME ]); +if (frame_data_len <sizeof (struct ieee80211_hdr_3addr ) || + frame_data_len >IEEE80211_MAX_DATA_LEN ) + goto err; +/* Allocate new skb here */ skb =alloc_skb (frame_data_len,GFP_KERNEL );if (skb ==NULL ) goto err; -if (frame_data_len >IEEE80211_MAX_DATA_LEN ) - goto err; -/* Copy the data */ skb_put_data (skb, frame_data, frame_data_len);
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 9/14 mmc: sdhci-esdhc-imx: improve ESDHC_FLAG_ERR010450
In reply to Sasha LevinFrom: Giulio Benetti <[email protected]>
[ Upstream commit 5ae4b0d8875caa44946e579420c7fd5740d58653 ]
Errata ERR010450 only shows up if voltage is 1.8V, but if the device is supplied by 3v3 the errata can be ignored. So let's check for if quirk SDHCI_QUIRK2_NO_1_8_V is defined or not before limiting the frequency.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +4 -3
@@ -166,8 +166,8 @@#define ESDHC_FLAG_HS400 BIT(9)/* * The IP has errata ERR010450 -* uSDHC: Due to the I/O timing limit, for SDR mode, SD card clock can't -* exceed 150MHz, for DDR mode, SD card clock can't exceed 45MHz. +* uSDHC: At 1.8V due to the I/O timing limit, for SDR mode, SD card +* clock can't exceed 150MHz, for DDR mode, SD card clock can't exceed 45MHz. */ #define ESDHC_FLAG_ERR010450 BIT(10)/* The IP supports HS400ES mode */
@@ -873,7 +873,8 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host, | ESDHC_CLOCK_MASK);sdhci_writel (host, temp,ESDHC_SYSTEM_CONTROL ); -if (imx_data->socdata->flags &ESDHC_FLAG_ERR010450 ) { +if ((imx_data->socdata->flags &ESDHC_FLAG_ERR010450 ) && + (!(host->quirks2 &SDHCI_QUIRK2_NO_1_8_V ))) {unsigned int max_clock; max_clock = imx_data->is_ddr ?45000000 :150000000 ;
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 6/14 wifi: wil6210: fix fortify warnings
In reply to Sasha LevinFrom: Dmitry Antipov <[email protected]>
[ Upstream commit 1ad8237e971630c66a1a6194491e0837b64d00e0 ]
When compiling with gcc 13.1 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following:
In function ‘fortify_memcpy_chk’,
inlined from ‘wil_rx_crypto_check_edma’ at drivers/net/wireless/ath/wil6210/txrx_edma.c:566:2:./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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~where the compiler complains on:
const u8 *pn;
...
pn = (u8 *)&st->ext.pn_15_0;
...memcpy(cc->pn, pn, IEEE80211_GCMP_PN_LEN);
and:
In function ‘fortify_memcpy_chk’,
inlined from ‘wil_rx_crypto_check’ at drivers/net/wireless/ath/wil6210/txrx.c:684:2:./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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~where the compiler complains on:
const u8 *pn = (u8 *)&d->mac.pn_15_0;
...memcpy(cc->pn, pn, IEEE80211_GCMP_PN_LEN);
In both cases, the fortification logic interprets 'memcpy()' as 6-byte overread of 2-byte field 'pn_15_0' of 'struct wil_rx_status_extension' and 'pn_15_0' of 'struct vring_rx_mac', respectively. To silence these warnings, last two fields of the aforementioned structures are grouped using 'struct_group_attr(pn, __packed' quirk.
--- drivers/net/wireless/ath/wil6210/txrx.c | 2 +- drivers/net/wireless/ath/wil6210/txrx.h | 6 ++++-- drivers/net/wireless/ath/wil6210/txrx_edma.c | 2 +- drivers/net/wireless/ath/wil6210/txrx_edma.h | 6 ++++-- 4 files changed, 10 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/wil6210/txrx.c +1 -1
@@ -666,7 +666,7 @@ static int wil_rx_crypto_check(struct wil6210_priv *wil, struct sk_buff *skb)struct wil_tid_crypto_rx *c = mc ? &s->group_crypto_rx : &s->tid_crypto_rx[tid];struct wil_tid_crypto_rx_single *cc = &c->key_id[key_id]; -const u8 *pn = (u8 *)&d->mac.pn_15_0; +const u8 *pn = (u8 *)&d->mac.pn;if (!cc->key_set) { wil_err_ratelimited(wil,
drivers/net/wireless/ath/wil6210/txrx.h +4 -2
@@ -343,8 +343,10 @@ struct vring_rx_mac {u32 d0;u32 d1;u16 w4; -u16 pn_15_0; -u32 pn_47_16; +struct_group_attr (pn, __packed, + u16 pn_15_0; + u32 pn_47_16; + ); } __packed;/* Rx descriptor - DMA part
drivers/net/wireless/ath/wil6210/txrx_edma.c +1 -1
@@ -548,7 +548,7 @@ static int wil_rx_crypto_check_edma(struct wil6210_priv *wil, s = &wil->sta[cid]; c = mc ? &s->group_crypto_rx : &s->tid_crypto_rx[tid]; cc = &c->key_id[key_id]; - pn = (u8 *)&st->ext.pn_15_0; + pn = (u8 *)&st->ext.pn;if (!cc->key_set) { wil_err_ratelimited(wil,
drivers/net/wireless/ath/wil6210/txrx_edma.h +4 -2
@@ -330,8 +330,10 @@ struct wil_rx_status_extension {u32 d0;u32 d1;__le16 seq_num;/* only lower 12 bits */ -u16 pn_15_0; -u32 pn_47_16; +struct_group_attr (pn, __packed, + u16 pn_15_0; + u32 pn_47_16; + ); } __packed;struct wil_rx_status_extended {
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 2/14 crypto: lrw,xts - Replace strlcpy with strscpy
In reply to Sasha LevinFrom: Azeem Shaikh <[email protected]>
[ Upstream commit babb80b3ecc6f40c962e13c654ebcd27f25ee327 ]
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy().
Direct replacement is safe here since return value of -errno is used to check for truncation instead of sizeof(dest).
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89
--- crypto/lrw.c | 6 +++--- crypto/xts.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
crypto/lrw.c +3 -3
@@ -357,10 +357,10 @@ static int lrw_create(struct crypto_template *tmpl, struct rtattr **tb)* cipher name. */ if (!strncmp (cipher_name,"ecb(" ,4 )) { -unsigned len; +int len; - len =strlcpy (ecb_name, cipher_name +4 ,sizeof (ecb_name)); -if (len <2 || len >=sizeof (ecb_name)) + len =strscpy (ecb_name, cipher_name +4 ,sizeof (ecb_name)); +if (len <2 ) goto err_free_inst;if (ecb_name[len -1 ] !=')' )
crypto/xts.c +3 -3
@@ -395,10 +395,10 @@ static int xts_create(struct crypto_template *tmpl, struct rtattr **tb)* cipher name. */ if (!strncmp (cipher_name,"ecb(" ,4 )) { -unsigned len; +int len; - len =strlcpy (ctx->name, cipher_name +4 ,sizeof (ctx->name)); -if (len <2 || len >=sizeof (ctx->name)) + len =strscpy (ctx->name, cipher_name +4 ,sizeof (ctx->name)); +if (len <2 ) goto err_free_inst;if (ctx->name[len -1 ] !=')' )
Signature · 1 line
2.40.1
Sasha Levin
maintainerPATCH 14/14 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
@@ -173,7 +173,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 },
@@ -4004,7 +4004,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
Sasha Levin
maintainerPATCH 7/14 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
Quoted 27 lines · Sasha Levin
From: Jiri Pirko <[email protected]>
[ Upstream commit
633d76ad01ad0321a1ace3e5cc4fed06753d7ac4]The checks in question were introduced by:
commit6b4db2e528f6("devlink: Fix use-after-free after a failed reload"). That fixed an issue of reload with mlxsw driver.Back then, that was a valid fix, because there was a limitation in place that prevented drivers from registering/unregistering params when devlink instance was registered.
It was possible to do the fix differently by changing drivers to register/unregister params in appropriate places making sure the ops operate only on memory which is allocated and initialized. But that, as a dependency, would require to remove the limitation mentioned above.
Eventually, this limitation was lifted by:
commit1d18bb1a4ddd("devlink: allow registering parameters after the instance")Also, the alternative fix (which also fixed another issue) was done by:
commit74cbc3c03c82("mlxsw:spectrum_acl_tcam: Move devlink param to TCAM code").Therefore, the checks are no longer relevant. Each driver should make sure to have the params registered only when the memory the ops are working with is allocated and initialized.
Quoted 8 lines
So remove the checks.
Signed-off-by Jiri Pirko <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Reviewed-by Jakub Kicinski <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>---
I believe my comments on the v5.4 backport apply here as well.
Thanks,
Jake
Re: [PATCH AUTOSEL 5.10 02/14] crypto: lrw,xts - Replace strlcpy with strscpy
In reply to Sasha LevinQuoted 11 lines · Sasha Levin
From: Azeem Shaikh <[email protected]>
[ Upstream commit
babb80b3ecc6f40c962e13c654ebcd27f25ee327]
strlcpy()reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to removestrlcpy()completely [2], replacestrlcpy()here withstrscpy().
Quoted 2 lines
Direct replacement is safe here since return value of -errno is used to check for truncation instead of sizeof(dest).
We don't need this in stable, do we?
BR,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany