wifi: ath9k: fix LNA selection in ath_ant_try_scan()
Subsystems (12)
Sasha Levin
maintainerPATCH 1/31 wifi: ath9k: fix LNA selection in ath_ant_try_scan()
From: Dmitry Antipov <[email protected]>
[ Upstream commit d6b27eb997ef9a2aa51633b3111bc4a04748e6d3 ]
In 'ath_ant_try_scan()', (most likely) the 2nd LNA's signal strength should be used in comparison against RSSI when selecting first LNA as the main one. Compile tested only.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wireless/ath/ath9k/antenna.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/antenna.c +1 -1
@@ -643,7 +643,7 @@ static void ath_ant_try_scan(struct ath_ant_comb *antcomb, conf->main_lna_conf =ATH_ANT_DIV_COMB_LNA1 ; conf->alt_lna_conf =ATH_ANT_DIV_COMB_LNA1_PLUS_LNA2 ; }else if (antcomb->rssi_sub > - antcomb->rssi_lna1) { + antcomb->rssi_lna2) {/* set to A-B */ conf->main_lna_conf =ATH_ANT_DIV_COMB_LNA1 ; conf->alt_lna_conf =ATH_ANT_DIV_COMB_LNA1_MINUS_LNA2 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/31 bnx2x: Fix firmware version string character counts
From: Kees Cook <[email protected]>
[ Upstream commit 5642c82b9463c3263c086efb002516244bd4c668 ]
A potential string truncation was reported in bnx2x_fill_fw_str(), when a long bp->fw_ver and a long phy_fw_ver might coexist, but seems unlikely with real-world hardware.
Use scnprintf() to indicate the intent that truncations are tolerated.
While reading this code, I found a collection of various buffer size counting issues. None looked like they might lead to a buffer overflow with current code (the small buffers are 20 bytes and might only ever consume 10 bytes twice with a trailing %NUL). However, early truncation (due to a %NUL in the middle of the string) might be happening under likely rare conditions. Regardless fix the formatters and related functions:
- Switch from a separate strscpy() to just adding an additional "%s" to the format string that immediately follows it in bnx2x_fill_fw_str().
- Use sizeof() universally instead of using unbound defines.
- Fix bnx2x_7101_format_ver() and bnx2x_null_format_ver() to report the number of characters written, not including the trailing %NUL (as already done with the other firmware formatting functions).
- Require space for at least 1 byte in bnx2x_get_ext_phy_fw_version() for the trailing %NUL.
- Correct the needed buffer size in bnx2x_3_seq_format_ver().
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 9 +++++---- .../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 14 +++++++------- 3 files changed, 13 insertions(+), 12 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +5 -4
@@ -147,10 +147,11 @@ void bnx2x_fill_fw_str(struct bnx2x *bp, char *buf, size_t buf_len) phy_fw_ver[0 ] ='\0' ;bnx2x_get_ext_phy_fw_version (&bp->link_params, - phy_fw_ver,PHY_FW_VER_LEN ); -strscpy (buf, bp->fw_ver, buf_len); - snprintf(buf + strlen(bp->fw_ver), 32 - strlen(bp->fw_ver), - "bc %d.%d.%d%s%s", + phy_fw_ver,sizeof (phy_fw_ver)); +/* This may become truncated. */ + scnprintf(buf, buf_len, + "%sbc %d.%d.%d%s%s", + bp->fw_ver, (bp->common.bc_ver & 0xff0000) >> 16, (bp->common.bc_ver & 0xff00) >> 8, (bp->common.bc_ver & 0xff),
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +1 -1
@@ -1132,7 +1132,7 @@ static void bnx2x_get_drvinfo(struct net_device *dev, }memset (version,0 ,sizeof (version)); -bnx2x_fill_fw_str (bp, version,ETHTOOL_FWVERS_LEN ); +bnx2x_fill_fw_str (bp, version,sizeof (version));strlcat (info->fw_version, version,sizeof (info->fw_version));strscpy (info->bus_info,pci_name (bp->pdev),sizeof (info->bus_info));
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +7 -7
@@ -6163,8 +6163,8 @@ static void bnx2x_link_int_ack(struct link_params *params,static int bnx2x_null_format_ver (u32 spirom_ver,u8 *str,u16 *len) { - str[0 ] ='\0' ; - (*len)--; +if (*len) + str[0 ] ='\0' ;return 0 ; }
@@ -6173,7 +6173,7 @@ static int bnx2x_format_ver(u32 num, u8 *str, u16 *len)u16 ret;if (*len <10 ) { -/* Need more than 10chars for this format */ +/* Need more than 10 chars for this format */ bnx2x_null_format_ver (num, str, len);return -EINVAL ; }
@@ -6188,8 +6188,8 @@ static int bnx2x_3_seq_format_ver(u32 num, u8 *str, u16 *len) {u16 ret; -if (*len <10 ) { -/* Need more than 10chars for this format */ +if (*len <9 ) { +/* Need more than 9 chars for this format */ bnx2x_null_format_ver (num, str, len);return -EINVAL ; }
@@ -6208,7 +6208,7 @@ int bnx2x_get_ext_phy_fw_version(struct link_params *params, u8 *version,int status =0 ;u8 *ver_p = version;u16 remain_len = len; -if (version ==NULL || params ==NULL ) +if (version ==NULL || params ==NULL || len ==0 )return -EINVAL ; bp = params->bp;
@@ -11546,7 +11546,7 @@ static int bnx2x_7101_format_ver(u32 spirom_ver, u8 *str, u16 *len) str[2 ] = (spirom_ver &0xFF0000 ) >>16 ; str[3 ] = (spirom_ver &0xFF000000 ) >>24 ; str[4 ] ='\0' ; - *len -=5 ; + *len -=4 ;return 0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/31 batman-adv: Return directly after a failed batadv_dat_select_candidates() in batadv_dat_forward_data()
In reply to Sasha LevinFrom: Markus Elfring <[email protected]>
[ Upstream commit ffc15626c861f811f9778914be004fcf43810a91 ]
The kfree() function was called in one case by
the batadv_dat_forward_data() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software.
* Thus return directly after a batadv_dat_select_candidates() call failed at the beginning.
* Delete the label “out” which became unnecessary with this refactoring.
--- net/batman-adv/distributed-arp-table.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/batman-adv/distributed-arp-table.c +1 -2
@@ -684,7 +684,7 @@ static bool batadv_dat_forward_data(struct batadv_priv *bat_priv, cand =batadv_dat_select_candidates (bat_priv, ip, vid);if (!cand) - goto out; +return ret;batadv_dbg (BATADV_DBG_DAT , bat_priv,"DHT_SEND for %pI4\n" , &ip);
@@ -728,7 +728,6 @@ static bool batadv_dat_forward_data(struct batadv_priv *bat_priv,batadv_orig_node_put (cand[i].orig_node); } -out:kfree (cand);return ret; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/31 batman-adv: Improve exception handling in batadv_throw_uevent()
In reply to Sasha LevinFrom: Markus Elfring <[email protected]>
[ Upstream commit 5593e9abf1cf2bf096366d8c7fd933bc69d561ce ]
The kfree() function was called in up to three cases by the batadv_throw_uevent() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software.
* Thus adjust jump targets.
* Reorder kfree() calls at the end.
--- net/batman-adv/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
net/batman-adv/main.c +8 -6
@@ -688,29 +688,31 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,"%s%s" ,BATADV_UEV_TYPE_VAR , batadv_uev_type_str[type]);if (!uevent_env[0 ]) - goto out; + goto report_error; uevent_env[1 ] =kasprintf (GFP_ATOMIC ,"%s%s" ,BATADV_UEV_ACTION_VAR , batadv_uev_action_str[action]);if (!uevent_env[1 ]) - goto out; + goto free_first_env;/* If the event is DEL, ignore the data field */ if (action !=BATADV_UEV_DEL ) { uevent_env[2 ] =kasprintf (GFP_ATOMIC ,"%s%s" ,BATADV_UEV_DATA_VAR , data);if (!uevent_env[2 ]) - goto out; + goto free_second_env; } ret =kobject_uevent_env (bat_kobj,KOBJ_CHANGE , uevent_env); -out: -kfree (uevent_env[0 ]); -kfree (uevent_env[1 ]);kfree (uevent_env[2 ]); +free_second_env: +kfree (uevent_env[1 ]); +free_first_env: +kfree (uevent_env[0 ]);if (ret) +report_error: batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", batadv_uev_type_str[type],
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/31 wifi: rtw89: pci: enlarge RX DMA buffer to consider size of RX descriptor
In reply to Sasha LevinFrom: Ping-Ke Shih <[email protected]>
[ Upstream commit c108b4a50dd7650941d4f4ec5c161655a73711db ]
Hardware puts RX descriptor and packet in RX DMA buffer, so it could be over one buffer size if packet size is 11454, and then it will be split into two segments. WiFi 7 chips use larger size of RX descriptor, so enlarge DMA buffer size according to RX descriptor to have better performance and simple flow.
--- drivers/net/wireless/realtek/rtw89/pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/pci.h +1 -1
@@ -546,7 +546,7 @@#define RTW89_PCI_TXWD_NUM_MAX 512#define RTW89_PCI_TXWD_PAGE_SIZE 128#define RTW89_PCI_ADDRINFO_MAX 4 -#define RTW89_PCI_RX_BUF_SIZE 11460 +#define RTW89_PCI_RX_BUF_SIZE (11454 + 40)/* +40 for rtw89_rxdesc_long_v2 */ #define RTW89_PCI_POLL_BDRAM_RST_CNT 100#define RTW89_PCI_MULTITAG 8
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/31 VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host()
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 19b070fefd0d024af3daa7329cbc0d00de5302ec ]
Syzkaller hit 'WARNING in dg_dispatch_as_host' bug.
memcpy: detected field-spanning write (size 56) of single field "&dg_info->msg"
at drivers/misc/vmw_vmci/vmci_datagram.c:237 (size 24) WARNING: CPU: 0 PID: 1555 at drivers/misc/vmw_vmci/vmci_datagram.c:237 dg_dispatch_as_host+0x88e/0xa60 drivers/misc/vmw_vmci/vmci_datagram.c:237
Some code commentry, based on my understanding:
544 #define VMCI_DG_SIZE(_dg) (VMCI_DG_HEADERSIZE + (size_t)(_dg)->payload_size) /// This is 24 + payload_size
memcpy(&dg_info->msg, dg, dg_size); Destination = dg_info->msg ---> this is a 24 byte structure(struct vmci_datagram) Source = dg --> this is a 24 byte structure (struct vmci_datagram) Size = dg_size = 24 + payload_size
{payload_size = 56-24 =32} -- Syzkaller managed to set payload_size to 32.
35 struct delayed_datagram_info {
36 struct datagram_entry *entry; 37 struct work_struct work; 38 bool in_dg_host_queue; 39 /* msg and msg_payload must be together. */ 40 struct vmci_datagram msg; 41 u8 msg_payload[];
42 };
So those extra bytes of payload are copied into msg_payload[], a run time warning is seen while fuzzing with Syzkaller.
One possible way to fix the warning is to split the memcpy() into two parts -- one -- direct assignment of msg and second taking care of payload.
Gustavo quoted:
"Under FORTIFY_SOURCE we should not copy data across multiple members in a structure."
--- drivers/misc/vmw_vmci/vmci_datagram.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/misc/vmw_vmci/vmci_datagram.c +2 -1
@@ -234,7 +234,8 @@ static int dg_dispatch_as_host(u32 context_id, struct vmci_datagram *dg) dg_info->in_dg_host_queue = true; dg_info->entry = dst_entry; -memcpy (&dg_info->msg, dg, dg_size); + dg_info->msg = *dg; +memcpy (&dg_info->msg_payload, dg +1 , dg->payload_size);INIT_WORK (&dg_info->work, dg_delayed_dispatch);schedule_work (&dg_info->work);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/31 wifi: iwlwifi: pcie: Add the PCI device id for new hardware
In reply to Sasha LevinFrom: Mukesh Sisodiya <[email protected]>
[ Upstream commit 6770eee75148ba10c0c051885379714773e00b48 ]
Add the support for a new PCI device id.
--- drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +1 -0
@@ -505,6 +505,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = {/* Bz devices */ {IWL_PCI_DEVICE(0x2727, PCI_ANY_ID, iwl_bz_trans_cfg)}, + {IWL_PCI_DEVICE(0x272D, PCI_ANY_ID, iwl_bz_trans_cfg)}, {IWL_PCI_DEVICE(0x272b, PCI_ANY_ID, iwl_bz_trans_cfg)}, {IWL_PCI_DEVICE(0xA840, PCI_ANY_ID, iwl_bz_trans_cfg)}, {IWL_PCI_DEVICE(0x7740, PCI_ANY_ID, iwl_bz_trans_cfg)},
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 8/31 panic: Flush kernel log buffer at the end
In reply to Sasha LevinFrom: John Ogness <[email protected]>
[ Upstream commit d988d9a9b9d180bfd5c1d353b3b176cb90d6861b ]
If the kernel crashes in a context where printk() calls always defer printing (such as in NMI or inside a printk_safe section) then the final panic messages will be deferred to irq_work. But if irq_work is not available, the messages will not get printed unless explicitly flushed. The result is that the final "end Kernel panic" banner does not get printed.
Add one final flush after the last printk() call to make sure the final panic messages make it out as well.
--- kernel/panic.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/panic.c +8 -0
@@ -441,6 +441,14 @@ void panic(const char *fmt, ...)/* Do not scroll important messages printed above */ suppress_printk =1 ; + +/* +* The final messages may not have been printed if in a context that +* defers printing (such as NMI) and irq_work is not available. +* Explicitly flush the kernel log buffer one last time. +*/ +console_flush_on_panic (CONSOLE_FLUSH_PENDING ); +local_irq_enable ();for (i =0 ; ; i +=PANIC_TIMER_STEP ) {touch_softlockup_watchdog ();
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/31 cpuidle: Avoid potential overflow in integer multiplication
In reply to Sasha LevinFrom: C Cheng <[email protected]>
[ Upstream commit 88390dd788db485912ee7f9a8d3d56fc5265d52f ]
In detail:
In C language, when you perform a multiplication operation, if both operands are of int type, the multiplication operation is performed on the int type, and then the result is converted to the target type. This means that if the product of int type multiplication exceeds the range that int type can represent, an overflow will occur even if you store the result in a variable of int64_t type.
For a multiplication of two int values, it is better to use mul_u32_u32() rather than s->exit_latency_ns = s->exit_latency * NSEC_PER_USEC to avoid potential overflow happenning.
--- drivers/cpuidle/driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/cpuidle/driver.c +2 -1
@@ -16,6 +16,7 @@#include <linux/cpumask.h> #include <linux/tick.h> #include <linux/cpu.h> +#include <linux/math64.h> #include "cpuidle.h"
@@ -185,7 +186,7 @@ static void __cpuidle_driver_init(struct cpuidle_driver *drv) s->target_residency_ns =0 ;if (s->exit_latency >0 ) - s->exit_latency_ns = s->exit_latency *NSEC_PER_USEC ; + s->exit_latency_ns =mul_u32_u32 (s->exit_latency,NSEC_PER_USEC );else if (s->exit_latency_ns <0 ) s->exit_latency_ns =0 ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 10/31 arm64: dts: rockchip: fix rk3328 hdmi ports node
In reply to Sasha LevinFrom: Johan Jonker <[email protected]>
[ Upstream commit 1d00ba4700d1e0f88ae70d028d2e17e39078fa1c ]
Fix rk3328 hdmi ports node so that it matches the
rockchip,dw-hdmi.yaml binding.
--- arch/arm64/boot/dts/rockchip/rk3328.dtsi | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3328.dtsi +10 -1
@@ -741,11 +741,20 @@ hdmi: hdmi@ff3c0000 { status = "disabled"; ports { - hdmi_in: port { + #address-cells = <1>; + #size-cells = <0>; + + hdmi_in: port@0 { + reg = <0>; + hdmi_in_vop: endpoint { remote-endpoint = <&vop_out_hdmi>; }; }; + + hdmi_out: port@1 { + reg = <1>; + }; }; };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 11/31 arm64: dts: rockchip: fix rk3399 hdmi ports node
In reply to Sasha LevinFrom: Johan Jonker <[email protected]>
[ Upstream commit f051b6ace7ffcc48d6d1017191f167c0a85799f6 ]
Fix rk3399 hdmi ports node so that it matches the
rockchip,dw-hdmi.yaml binding.
--- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +10 -2
@@ -1906,6 +1906,7 @@ simple-audio-card,codec { hdmi: hdmi@ff940000 { compatible = "rockchip,rk3399-dw-hdmi"; reg = <0x0 0xff940000 0x0 0x20000>; + reg-io-width = <4>; interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH 0>; clocks = <&cru PCLK_HDMI_CTRL>, <&cru SCLK_HDMI_SFR>,
@@ -1914,13 +1915,16 @@ hdmi: hdmi@ff940000 { <&cru PLL_VPLL>; clock-names = "iahb", "isfr", "cec", "grf", "ref"; power-domains = <&power RK3399_PD_HDCP>; - reg-io-width = <4>; rockchip,grf = <&grf>; #sound-dai-cells = <0>; status = "disabled"; ports { - hdmi_in: port { + #address-cells = <1>; + #size-cells = <0>; + + hdmi_in: port@0 { + reg = <0>; #address-cells = <1>; #size-cells = <0>;
@@ -1933,6 +1937,10 @@ hdmi_in_vopl: endpoint@1 { remote-endpoint = <&vopl_out_hdmi>; }; }; + + hdmi_out: port@1 { + reg = <1>; + }; }; };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 12/31 ionic: set adminq irq affinity
In reply to Sasha LevinFrom: Shannon Nelson <[email protected]>
[ Upstream commit c699f35d658f3c21b69ed24e64b2ea26381e941d ]
We claim to have the AdminQ on our irq0 and thus cpu id 0, but we need to be sure we set the affinity hint to try to keep it there.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +4 -1
@@ -3216,9 +3216,12 @@ static int ionic_lif_adminq_init(struct ionic_lif *lif)napi_enable (&qcq->napi); -if (qcq->flags &IONIC_QCQ_F_INTR ) +if (qcq->flags &IONIC_QCQ_F_INTR ) { +irq_set_affinity_hint (qcq->intr.vector, + &qcq->intr.affinity_mask);ionic_intr_mask (idev->intr_ctrl, qcq->intr.index,IONIC_INTR_MASK_CLEAR ); + } qcq->flags |=IONIC_QCQ_F_INITED ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 13/31 net: skbuff: add overflow debug check to pull/push helpers
In reply to Sasha LevinFrom: Florian Westphal <[email protected]>
[ Upstream commit 219eee9c0d16f1b754a8b85275854ab17df0850a ]
syzbot managed to trigger following splat:
BUG: KASAN: use-after-free in __skb_flow_dissect+0x4a3b/0x5e50 Read of size 1 at addr ffff888208a4000e by task a.out/2313 [..] __skb_flow_dissect+0x4a3b/0x5e50 __skb_get_hash+0xb4/0x400 ip_tunnel_xmit+0x77e/0x26f0 ipip_tunnel_xmit+0x298/0x410 ..
Analysis shows that the skb has a valid ->head, but bogus ->data pointer.
skb->data gets its bogus value via the neigh layer, which does:
1556 __skb_pull(skb, skb_network_offset(skb));
... and the skb was already dodgy at this point:
skb_network_offset(skb) returns a negative value due to an earlier overflow of skb->network_header (u16). __skb_pull thus "adjusts" skb->data by a huge offset, pointing outside skb->head area.
Allow debug builds to splat when we try to pull/push more than INT_MAX bytes.
After this, the syzkaller reproducer yields a more precise splat before the flow dissector attempts to read off skb->data memory:
WARNING: CPU: 5 PID: 2313 at include/linux/skbuff.h:2653 neigh_connected_output+0x28e/0x400 ip_finish_output2+0xb25/0xed0 iptunnel_xmit+0x4ff/0x870 ipgre_xmit+0x78e/0xbb0
--- include/linux/skbuff.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/linux/skbuff.h +6 -0
@@ -2608,6 +2608,8 @@ static inline void skb_put_u8(struct sk_buff *skb, u8 val)void *skb_push (struct sk_buff *skb,unsigned int len);static inline void *__skb_push (struct sk_buff *skb,unsigned int len) { +DEBUG_NET_WARN_ON_ONCE (len >INT_MAX ); + skb->data -= len; skb->len += len;return skb->data;
@@ -2616,6 +2618,8 @@ static inline void *__skb_push(struct sk_buff *skb, unsigned int len)void *skb_pull (struct sk_buff *skb,unsigned int len);static inline void *__skb_pull (struct sk_buff *skb,unsigned int len) { +DEBUG_NET_WARN_ON_ONCE (len >INT_MAX ); + skb->len -= len;if (unlikely (skb->len < skb->data_len)) {#if defined(CONFIG_DEBUG_NET )
@@ -2639,6 +2643,8 @@ void *__pskb_pull_tail(struct sk_buff *skb, int delta);static inline bool pskb_may_pull (struct sk_buff *skb,unsigned int len) { +DEBUG_NET_WARN_ON_ONCE (len >INT_MAX ); +if (likely (len <=skb_headlen (skb)))return true;if (unlikely (len > skb->len))
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 14/31 firmware: tegra: bpmp: Return directly after a failed kzalloc() in get_filename()
In reply to Sasha LevinFrom: Markus Elfring <[email protected]>
[ Upstream commit 1315848f1f8a0100cb6f8a7187bc320c5d98947f ]
The kfree() function was called in one case by the get_filename() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software.
Thus return directly after a call of the function “kzalloc” failed at the beginning.
--- drivers/firmware/tegra/bpmp-debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/tegra/bpmp-debugfs.c +1 -1
@@ -81,7 +81,7 @@ static const char *get_filename(struct tegra_bpmp *bpmp, root_path_buf =kzalloc (root_path_buf_len,GFP_KERNEL );if (!root_path_buf) - goto out; +return NULL ; root_path =dentry_path (bpmp->debugfs_mirror, root_path_buf, root_path_buf_len);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 15/31 wifi: brcmfmac: Add DMI nvram filename quirk for ACEPC W5 Pro
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 32167707aa5e7ae4b160c18be79d85a7b4fdfcfb ]
The ACEPC W5 Pro HDMI stick contains quite generic names in the sys_vendor and product_name DMI strings, without this patch brcmfmac will try to load:
"brcmfmac43455-sdio.$(DEFAULT_STRING)-$(DEFAULT_STRING).txt" as nvram file which is both too generic and messy with the $ symbols in the name.
The ACEPC W5 Pro uses the same Ampak AP6255 module as the ACEPC T8 and the nvram for the T8 is already in linux-firmware, so point the new DMI nvram filename quirk to the T8 nvram file.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c +9 -0
@@ -82,6 +82,15 @@ static const struct dmi_system_id dmi_platform_data[] = { }, .driver_data = (void *)&acepc_t8_data, }, + { +/* ACEPC W5 Pro Cherry Trail Z8350 HDMI stick, same wifi as the T8 */ + .matches = { +DMI_MATCH (DMI_BOARD_NAME ,"T3 MRD" ), +DMI_MATCH (DMI_CHASSIS_TYPE ,"3" ), + DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."), + }, + .driver_data = (void *)&acepc_t8_data, + }, {/* Chuwi Hi8 Pro with D2D3_Hi8Pro.233 BIOS */ .matches = {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 16/31 pstore/zone: Add a null pointer check to the psz_kmsg_read
In reply to Sasha LevinFrom: Kunwu Chan <[email protected]>
[ Upstream commit 98bc7e26e14fbb26a6abf97603d59532475e97f8 ]
kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity.
--- fs/pstore/zone.c | 2 ++ 1 file changed, 2 insertions(+)
fs/pstore/zone.c +2 -0
@@ -973,6 +973,8 @@ static ssize_t psz_kmsg_read(struct pstore_zone *zone,char *buf =kasprintf (GFP_KERNEL ,"%s: Total %d times\n" ,kmsg_dump_reason_str (record->reason), record->count); +if (!buf) +return -ENOMEM ; hlen =strlen (buf); record->buf =krealloc (buf, hlen + size,GFP_KERNEL );if (!record->buf) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 17/31 tools/power x86_energy_perf_policy: Fix file leak in get_pkg_num()
In reply to Sasha LevinFrom: Samasth Norway Ananda <[email protected]>
[ Upstream commit f85450f134f0b4ca7e042dc3dc89155656a2299d ]
In function get_pkg_num() if fopen_or_die() succeeds it returns a file pointer to be used. But fclose() is never called before returning from the function.
--- tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 1 + 1 file changed, 1 insertion(+)
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +1 -0
@@ -1241,6 +1241,7 @@ unsigned int get_pkg_num(int cpu) retval =fscanf (fp,"%d\n" , &pkg);if (retval !=1 )errx (1 ,"%s: failed to parse" , pathname); +fclose (fp);return pkg; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 18/31 net: pcs: xpcs: Return EINVAL in the internal methods
In reply to Sasha LevinFrom: Serge Semin <[email protected]>
[ Upstream commit f5151005d379d9ce42e327fd3b2d2aaef61cda81 ]
In particular the xpcs_soft_reset() and xpcs_do_config() functions currently return -1 if invalid auto-negotiation mode is specified. That value might be then passed to the generic kernel subsystems which require a standard kernel errno value. Even though the erroneous conditions are very specific (memory corruption or buggy driver implementation) using a hard-coded -1 literal doesn't seem correct anyway especially when it comes to passing it higher to the network subsystem or printing to the system log. Convert the hard-coded error values to -EINVAL then.
--- drivers/net/pcs/pcs-xpcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/pcs/pcs-xpcs.c +2 -2
@@ -262,7 +262,7 @@ static int xpcs_soft_reset(struct dw_xpcs *xpcs, dev =MDIO_MMD_VEND2 ;break ;default : -return -1 ; +return -EINVAL ; } ret =xpcs_write (xpcs, dev,MDIO_CTRL1 ,MDIO_CTRL1_RESET );
@@ -904,7 +904,7 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface,return ret;break ;default : -return -1 ; +return -EINVAL ; }if (compat->pma_config) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 19/31 dma-direct: Leak pages on dma_set_decrypted() failure
In reply to Sasha LevinFrom: Rick Edgecombe <[email protected]>
[ Upstream commit b9fa16949d18e06bdf728a560f5c8af56d2bdcaf ]
On TDX it is possible for the untrusted host to cause set_memory_encrypted() or set_memory_decrypted() to fail such that an error is returned and the resulting memory is shared. Callers need to take care to handle these errors to avoid returning decrypted (shared) memory to the page allocator, which could lead to functional or security issues.
DMA could free decrypted/shared pages if dma_set_decrypted() fails. This should be a rare case. Just leak the pages in this case instead of freeing them.
--- kernel/dma/direct.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/dma/direct.c +5 -4
@@ -296,7 +296,7 @@ void *dma_direct_alloc(struct device *dev, size_t size, }else { ret =page_address (page);if (dma_set_decrypted (dev, ret, size)) - goto out_free_pages; + goto out_leak_pages; }memset (ret,0 , size);
@@ -317,6 +317,8 @@ void *dma_direct_alloc(struct device *dev, size_t size, out_free_pages:__dma_direct_free_pages (dev, page, size);return NULL ; +out_leak_pages: +return NULL ; } void dma_direct_free(struct device *dev, size_t size,
@@ -379,12 +381,11 @@ struct page *dma_direct_alloc_pages(struct device *dev, size_t size, ret =page_address (page);if (dma_set_decrypted (dev, ret, size)) - goto out_free_pages; + goto out_leak_pages;memset (ret,0 , size); *dma_handle =phys_to_dma_direct (dev,page_to_phys (page));return page; -out_free_pages: -__dma_direct_free_pages (dev, page, size); +out_leak_pages:return NULL ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 20/31 wifi: ath11k: decrease MHI channel buffer length to 8KB
In reply to Sasha LevinFrom: Baochen Qiang <[email protected]>
[ Upstream commit 1cca1bddf9ef080503c15378cecf4877f7510015 ]
Currently buf_len field of ath11k_mhi_config_qca6390 is assigned with 0, making MHI use a default size, 64KB, to allocate channel buffers. This is likely to fail in some scenarios where system memory is highly fragmented and memory compaction or reclaim is not allowed.
There is a fail report which is caused by it:
kworker/u32:45: page allocation failure: order:4, mode:0x40c00(GFP_NOIO|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0
CPU: 0 PID: 19318 Comm: kworker/u32:45 Not tainted 6.8.0-rc3-1.gae4495f-default #1 openSUSE Tumbleweed (unreleased) 493b6d5b382c603654d7a81fc3c144d59a1dfceb Workqueue: events_unbound async_run_entry_fn Call Trace: <TASK> dump_stack_lvl+0x47/0x60 warn_alloc+0x13a/0x1b0 ? srso_alias_return_thunk+0x5/0xfbef5 ? __alloc_pages_direct_compact+0xab/0x210 __alloc_pages_slowpath.constprop.0+0xd3e/0xda0 __alloc_pages+0x32d/0x350 ? mhi_prepare_channel+0x127/0x2d0 [mhi 40df44e07c05479f7a6e7b90fba9f0e0031a7814] __kmalloc_large_node+0x72/0x110 __kmalloc+0x37c/0x480 ? mhi_map_single_no_bb+0x77/0xf0 [mhi 40df44e07c05479f7a6e7b90fba9f0e0031a7814] ? mhi_prepare_channel+0x127/0x2d0 [mhi 40df44e07c05479f7a6e7b90fba9f0e0031a7814] mhi_prepare_channel+0x127/0x2d0 [mhi 40df44e07c05479f7a6e7b90fba9f0e0031a7814] __mhi_prepare_for_transfer+0x44/0x80 [mhi 40df44e07c05479f7a6e7b90fba9f0e0031a7814] ? __pfx_____mhi_prepare_for_transfer+0x10/0x10 [mhi 40df44e07c05479f7a6e7b90fba9f0e0031a7814] device_for_each_child+0x5c/0xa0 ? __pfx_pci_pm_resume+0x10/0x10 ath11k_core_resume+0x65/0x100 [ath11k a5094e22d7223135c40d93c8f5321cf09fd85e4e] ? srso_alias_return_thunk+0x5/0xfbef5 ath11k_pci_pm_resume+0x32/0x60 [ath11k_pci 830b7bfc3ea80ebef32e563cafe2cb55e9cc73ec] ? srso_alias_return_thunk+0x5/0xfbef5 dpm_run_callback+0x8c/0x1e0 device_resume+0x104/0x340 ? __pfx_dpm_watchdog_handler+0x10/0x10 async_resume+0x1d/0x30 async_run_entry_fn+0x32/0x120 process_one_work+0x168/0x330 worker_thread+0x2f5/0x410 ? __pfx_worker_thread+0x10/0x10 kthread+0xe8/0x120 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x34/0x50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1b/0x30 </TASK>
Actually those buffers are used only by QMI target -> host communication. And for WCN6855 and QCA6390, the largest packet size for that is less than 6KB. So change buf_len field to 8KB, which results in order 1 allocation if page size is 4KB. In this way, we can at least save some memory, and as well as decrease the possibility of allocation failure in those scenarios.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.30
--- drivers/net/wireless/ath/ath11k/mhi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/mhi.c +1 -1
@@ -105,7 +105,7 @@ static struct mhi_controller_config ath11k_mhi_config_qca6390 = { .max_channels = 128, .timeout_ms = 2000, .use_bounce_buf = false, - .buf_len = 0, + .buf_len = 8192, .num_channels = ARRAY_SIZE(ath11k_mhi_channels_qca6390), .ch_cfg = ath11k_mhi_channels_qca6390, .num_events = ARRAY_SIZE(ath11k_mhi_events_qca6390),
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 21/31 sparc: vdso: Disable UBSAN instrumentation
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit d4be85d068b4418c341f79b654399f7f0891069a ]
The UBSAN instrumentation cannot work in the vDSO since it is executing in userspace, so disable it in the Makefile. Fixes the build failures such as:
arch/sparc/vdso/vclock_gettime.c:217: undefined reference to `__ubsan_handle_shift_out_of_bounds'
--- arch/sparc/vdso/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/sparc/vdso/Makefile +1 -0
@@ -2,6 +2,7 @@ # # Building vDSO images for sparc. # +UBSAN_SANITIZE := n VDSO64-$(CONFIG_SPARC64) := y VDSOCOMPAT-$(CONFIG_COMPAT) := y
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 22/31 cpufreq: Don't unregister cpufreq cooling on CPU hotplug
In reply to Sasha LevinFrom: Viresh Kumar <[email protected]>
[ Upstream commit c4d61a529db788d2e52654f5b02c8d1de4952c5b ]
Offlining a CPU and bringing it back online is a common operation and it happens frequently during system suspend/resume, where the non-boot CPUs are hotplugged out during suspend and brought back at resume.
The cpufreq core already tries to make this path as fast as possible as the changes are only temporary in nature and full cleanup of resources isn't required in this case. For example the drivers can implement online()/offline() callbacks to avoid a lot of tear down of resources.
On similar lines, there is no need to unregister the cpufreq cooling device during suspend / resume, but only while the policy is getting removed.
Moreover, unregistering the cpufreq cooling device is resulting in an unwanted outcome, where the system suspend is eventually aborted in the process. Currently, during system suspend the cpufreq core unregisters the cooling device, which in turn removes a kobject using device_del() and that generates a notification to the userspace via uevent broadcast. This causes system suspend to abort in some setups.
This was also earlier reported (indirectly) by Roman [1]. Maybe there is another way around to fixing that problem properly, but this change makes sense anyways.
Move the registering and unregistering of the cooling device to policy creation and removal times onlyy.
--- drivers/cpufreq/cpufreq.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/cpufreq/cpufreq.c +11 -6
@@ -1525,7 +1525,8 @@ static int cpufreq_online(unsigned int cpu)if (cpufreq_driver->ready) cpufreq_driver->ready (policy); -if (cpufreq_thermal_control_enabled (cpufreq_driver)) +/* Register cpufreq cooling only for a new policy */ +if (new_policy &&cpufreq_thermal_control_enabled (cpufreq_driver)) policy->cdev =of_cpufreq_cooling_register (policy);pr_debug ("initialization complete\n" );
@@ -1609,11 +1610,6 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)else policy->last_policy = policy->policy; -if (cpufreq_thermal_control_enabled (cpufreq_driver)) { -cpufreq_cooling_unregister (policy->cdev); - policy->cdev =NULL ; - } -if (has_target ())cpufreq_exit_governor (policy);
@@ -1674,6 +1670,15 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)return ; } +/* +* Unregister cpufreq cooling once all the CPUs of the policy are +* removed. +*/ +if (cpufreq_thermal_control_enabled (cpufreq_driver)) { +cpufreq_cooling_unregister (policy->cdev); + policy->cdev =NULL ; + } +/* We did light-weight exit earlier, do full tear down now */ if (cpufreq_driver->offline) cpufreq_driver->exit (policy);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 23/31 sh: Fix build with CONFIG_UBSAN=y
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit e36b70fb8c707a0688960184380bc151390d671b ]
The early boot stub for sh had UBSan instrumentation present where it is not supported. Disable it for this part of the build.
sh4-linux-ld: arch/sh/boot/compressed/misc.o: in function `zlib_inflate_table':
misc.c:(.text+0x670): undefined reference to `__ubsan_handle_shift_out_of_bounds'
--- arch/sh/boot/compressed/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/sh/boot/compressed/Makefile +1 -0
@@ -19,6 +19,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \ vmlinux.bin.lzma vmlinux.bin.xz vmlinux.bin.lzo $(OBJECTS) GCOV_PROFILE := n +UBSAN_SANITIZE := n # # IMAGE_OFFSET is the load offset of the compression loader
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 24/31 btrfs: preallocate temporary extent buffer for inode logging when needed
In reply to Sasha LevinFrom: Filipe Manana <[email protected]>
[ Upstream commit e383e158ed1b6abc2d2d3e6736d77a46393f80fa ]
When logging an inode and we require to copy items from subvolume leaves to the log tree, we clone each subvolume leaf and than use that clone to copy items to the log tree. This is required to avoid possible deadlocks as stated in commit 796787c978ef ("btrfs: do not modify log tree while holding a leaf from fs tree locked").
The cloning requires allocating an extent buffer (struct extent_buffer) and then allocating pages (folios) to attach to the extent buffer. This may be slow in case we are under memory pressure, and since we are doing the cloning while holding a read lock on a subvolume leaf, it means we can be blocking other operations on that leaf for significant periods of time, which can increase latency on operations like creating other files, renaming files, etc. Similarly because we're under a log transaction, we may also cause extra delay on other tasks doing an fsync, because syncing the log requires waiting for tasks that joined a log transaction to exit the transaction.
So to improve this, for any inode logging operation that needs to copy items from a subvolume leaf ("full sync" or "copy everything" bit set in the inode), preallocate a dummy extent buffer before locking any extent buffer from the subvolume tree, and even before joining a log transaction, add it to the log context and then use it when we need to copy items from a subvolume leaf to the log tree. This avoids making other operations get extra latency when waiting to lock a subvolume leaf that is used during inode logging and we are under heavy memory pressure.
The following test script with bonnie++ was used to test this:
$ cat test.sh #!/bin/bash
DEV=/dev/sdh
MNT=/mnt/sdh
MOUNT_OPTIONS="-o ssd"
MEMTOTAL_BYTES=`free -b | grep Mem: | awk '{ print $2 }'`
NR_DIRECTORIES=20
NR_FILES=20480
DATASET_SIZE=$((MEMTOTAL_BYTES * 2 / 1048576))
DIRECTORY_SIZE=$((MEMTOTAL_BYTES * 2 / NR_FILES))
NR_FILES=$((NR_FILES / 1024))
echo "performance" | \
tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor umount $DEV &> /dev/null
mkfs.btrfs -f $MKFS_OPTIONS $DEV
mount $MOUNT_OPTIONS $DEV $MNT
bonnie++ -u root -d $MNT \
-n $NR_FILES:$DIRECTORY_SIZE:$DIRECTORY_SIZE:$NR_DIRECTORIES \
-r 0 -s $DATASET_SIZE -bumount $MNT
The results of this test on a 8G VM running a non-debug kernel (Debian's default kernel config), were the following.
Before this change:
Version 2.00a ------Sequential Output------ --Sequential Input- --Random-
-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Name:Size etc /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
debian0 7501M 376k 99 1.4g 96 117m 14 1510k 99 2.5g 95 +++++ +++
Latency 35068us 24976us 2944ms 30725us 71770us 26152us
Version 2.00a ------Sequential Create------ --------Random Create--------
debian0 -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
20:384100:384100/20 20480 32 20480 58 20480 48 20480 39 20480 56 20480 61
Latency 411ms 11914us 119ms 617ms 10296us 110msAfter this change:
Version 2.00a ------Sequential Output------ --Sequential Input- --Random-
-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Name:Size etc /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
debian0 7501M 375k 99 1.4g 97 117m 14 1546k 99 2.3g 98 +++++ +++
Latency 35975us 20945us 2144ms 10297us 2217us 6004us
Version 2.00a ------Sequential Create------ --------Random Create--------
debian0 -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
files:max:min /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
20:384100:384100/20 20480 35 20480 58 20480 48 20480 40 20480 57 20480 59
Latency 320ms 11237us 77779us 518ms 6470us 86389us--- fs/btrfs/file.c | 12 ++++++ fs/btrfs/tree-log.c | 93 +++++++++++++++++++++++++++------------------ fs/btrfs/tree-log.h | 25 ++++++++++++ 3 files changed, 94 insertions(+), 36 deletions(-)
fs/btrfs/file.c +12 -0
@@ -1905,6 +1905,8 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) goto out_release_extents; } +btrfs_init_log_ctx_scratch_eb (&ctx); +/* * We use start here because we will need to wait on the IO to complete * in btrfs_sync_log, which could require joining a transaction (for
@@ -1924,6 +1926,15 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) trans->in_fsync = true; ret =btrfs_log_dentry_safe (trans, dentry, &ctx); +/* +* Scratch eb no longer needed, release before syncing log or commit +* transaction, to avoid holding unnecessary memory during such long +* operations. +*/ +if (ctx.scratch_eb) { +free_extent_buffer (ctx.scratch_eb); + ctx.scratch_eb =NULL ; + }btrfs_release_log_ctx_extents (&ctx);if (ret <0 ) {/* Fallthrough and commit/free transaction. */
@@ -1999,6 +2010,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) ret =btrfs_commit_transaction (trans); out: +free_extent_buffer (ctx.scratch_eb);ASSERT (list_empty (&ctx.list));ASSERT (list_empty (&ctx.conflict_inodes)); err =file_check_and_advance_wb_err (file);
fs/btrfs/tree-log.c +57 -36
248 lines not on this page · raw message
fs/btrfs/tree-log.h +25 -0
@@ -30,6 +30,15 @@ struct btrfs_log_ctx {struct list_head conflict_inodes;int num_conflict_inodes;bool logging_conflict_inodes; +/* +* Used for fsyncs that need to copy items from the subvolume tree to +* the log tree (full sync flag set or copy everything flag set) to +* avoid allocating a temporary extent buffer while holding a lock on +* an extent buffer of the subvolume tree and under the log transaction. +* Also helps to avoid allocating and freeing a temporary extent buffer +* in case we need to process multiple leaves from the subvolume tree. +*/ +struct extent_buffer *scratch_eb; }; static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx,
@@ -47,6 +56,22 @@ static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx,INIT_LIST_HEAD (&ctx->conflict_inodes); ctx->num_conflict_inodes =0 ; ctx->logging_conflict_inodes = false; + ctx->scratch_eb =NULL ; +} + +static inline void btrfs_init_log_ctx_scratch_eb (struct btrfs_log_ctx *ctx) +{ +struct btrfs_inode *inode =BTRFS_I (ctx->inode); + +if (!test_bit (BTRFS_INODE_NEEDS_FULL_SYNC , &inode->runtime_flags) && + !test_bit (BTRFS_INODE_COPY_EVERYTHING , &inode->runtime_flags)) +return ; + +/* +* Don't care about allocation failure. This is just for optimization, +* if we fail to allocate here, we will try again later if needed. +*/ + ctx->scratch_eb =alloc_dummy_extent_buffer (inode->root->fs_info,0 ); }static inline void btrfs_release_log_ctx_extents (struct btrfs_log_ctx *ctx)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 25/31 btrfs: handle chunk tree lookup error in btrfs_relocate_sys_chunks()
In reply to Sasha LevinFrom: David Sterba <[email protected]>
[ Upstream commit 7411055db5ce64f836aaffd422396af0075fdc99 ]
The unhandled case in btrfs_relocate_sys_chunks() loop is a corruption, as it could be caused only by two impossible conditions:
- at first the search key is set up to look for a chunk tree item, with offset -1, this is an inexact search and the key->offset will contain the correct offset upon a successful search, a valid chunk tree item cannot have an offset -1
- after first successful search, the found_key corresponds to a chunk item, the offset is decremented by 1 before the next loop, it's impossible to find a chunk item there due to alignment and size constraints
--- fs/btrfs/volumes.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
fs/btrfs/volumes.c +11 -1
@@ -3381,7 +3381,17 @@ static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info)mutex_unlock (&fs_info->reclaim_bgs_lock); goto error; } -BUG_ON (ret ==0 );/* Corruption */ +if (ret ==0 ) { +/* +* On the first search we would find chunk tree with +* offset -1, which is not possible. On subsequent +* loops this would find an existing item on an invalid +* offset (one less than the previous one, wrong +* alignment and size). +*/ + ret = -EUCLEAN ; + goto error; + } ret =btrfs_previous_item (chunk_root, path, key.objectid, key.type);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 26/31 btrfs: export: handle invalid inode or root reference in btrfs_get_parent()
In reply to Sasha LevinFrom: David Sterba <[email protected]>
[ Upstream commit 26b66d1d366a375745755ca7365f67110bbf6bd5 ]
The get_parent handler looks up a parent of a given dentry, this can be either a subvolume or a directory. The search is set up with offset -1 but it's never expected to find such item, as it would break allowed range of inode number or a root id. This means it's a corruption (ext4 also returns this error code).
--- fs/btrfs/export.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/export.c +8 -1
@@ -161,8 +161,15 @@ struct dentry *btrfs_get_parent(struct dentry *child) ret =btrfs_search_slot (NULL , root, &key, path,0 ,0 );if (ret <0 ) goto fail; +if (ret ==0 ) { +/* +* Key with offset of -1 found, there would have to exist an +* inode with such number or a root with such id. +*/ + ret = -EUCLEAN ; + goto fail; + } -BUG_ON (ret ==0 );/* Key with offset of -1 found */ if (path->slots[0 ] ==0 ) { ret = -ENOENT ; goto fail;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 27/31 btrfs: send: handle path ref underflow in header iterate_inode_ref()
In reply to Sasha LevinFrom: David Sterba <[email protected]>
[ Upstream commit 3c6ee34c6f9cd12802326da26631232a61743501 ]
Change BUG_ON to proper error handling if building the path buffer fails. The pointers are not printed so we don't accidentally leak kernel addresses.
--- fs/btrfs/send.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/btrfs/send.c +9 -1
@@ -1015,7 +1015,15 @@ static int iterate_inode_ref(struct btrfs_root *root, struct btrfs_path *path, ret =PTR_ERR (start); goto out; } -BUG_ON (start < p->buf); +if (unlikely (start < p->buf)) { +btrfs_err (root->fs_info, +"send: path ref buffer underflow for key (%llu %u %llu)" , + found_key->objectid, + found_key->type, + found_key->offset); + ret = -EINVAL ; + goto out; + } } p->start = start; }else {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 28/31 ice: use relative VSI index for VFs instead of PF VSI number
In reply to Sasha LevinFrom: Jacob Keller <[email protected]>
[ Upstream commit 11fbb1bfb5bc8c98b2d7db9da332b5e568f4aaab ]
When initializing over virtchnl, the PF is required to pass a VSI ID to the VF as part of its capabilities exchange. The VF driver reports this value back to the PF in a variety of commands. The PF driver validates that this value matches the value it sent to the VF.
Some hardware families such as the E700 series could use this value when reading RSS registers or communicating directly with firmware over the Admin Queue.
However, E800 series hardware does not support any of these interfaces and the VF's only use for this value is to report it back to the PF. Thus, there is no requirement that this value be an actual VSI ID value of any kind.
The PF driver already does not trust that the VF sends it a real VSI ID. The VSI structure is always looked up from the VF structure. The PF does validate that the VSI ID provided matches a VSI associated with the VF, but otherwise does not use the VSI ID for any purpose.
Instead of reporting the VSI number relative to the PF space, report a fixed value of 1. When communicating with the VF over virtchnl, validate that the VSI number is returned appropriately.
This avoids leaking information about the firmware of the PF state. Currently the ice driver only supplies a VF with a single VSI. However, it appears that virtchnl has some support for allowing multiple VSIs. I did not attempt to implement this. However, space is left open to allow further relative indexes if additional VSIs are provided in future feature development. For this reason, keep the ice_vc_isvalid_vsi_id function in place to allow extending it for multiple VSIs in the future.
This change will also simplify handling of live migration in a future series. Since we no longer will provide a real VSI number to the VF, there will be no need to keep track of this number when migrating to a new host.
--- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 9 ++------- drivers/net/ethernet/intel/ice/ice_virtchnl.h | 9 +++++++++ 2 files changed, 11 insertions(+), 7 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +2 -7
@@ -500,7 +500,7 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg) vfres->rss_lut_size =ICE_VSIQF_HLUT_ARRAY_SIZE ; vfres->max_mtu =ice_vc_get_max_frame_size (vf); - vfres->vsi_res[0 ].vsi_id = vf->lan_vsi_num; + vfres->vsi_res[0 ].vsi_id =ICE_VF_VSI_ID ; vfres->vsi_res[0 ].vsi_type =VIRTCHNL_VSI_SRIOV ; vfres->vsi_res[0 ].num_queue_pairs = vsi->num_txq; ether_addr_copy(vfres->vsi_res[0].default_mac_addr,
@@ -546,12 +546,7 @@ static void ice_vc_reset_vf_msg(struct ice_vf *vf)*/ bool ice_vc_isvalid_vsi_id (struct ice_vf *vf,u16 vsi_id) { -struct ice_pf *pf = vf->pf; -struct ice_vsi *vsi; - - vsi =ice_find_vsi (pf, vsi_id); - -return (vsi && (vsi->vf == vf)); +return vsi_id ==ICE_VF_VSI_ID ; }/**
drivers/net/ethernet/intel/ice/ice_virtchnl.h +9 -0
@@ -18,6 +18,15 @@*/ #define ICE_MAX_MACADDR_PER_VF 18 +/* VFs only get a single VSI. For ice hardware, the VF does not need to know +* its VSI index. However, the virtchnl interface requires a VSI number, +* mainly due to legacy hardware. +* +* Since the VF doesn't need this information, report a static value to the VF +* instead of leaking any information about the PF or hardware setup. +*/ +#define ICE_VF_VSI_ID 1 +struct ice_virtchnl_ops {int (*get_ver_msg)(struct ice_vf *vf,u8 *msg);int (*get_vf_res_msg)(struct ice_vf *vf,u8 *msg);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 29/31 net/smc: reduce rtnl pressure in smc_pnet_create_pnetids_list()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 00af2aa93b76b1bade471ad0d0525d4d29ca5cc0 ]
Many syzbot reports show extreme rtnl pressure, and many of them hint that smc acquires rtnl in netns creation for no good reason [1]
This patch returns early from smc_pnet_net_init()
if there is no netdevice yet.
I am not even sure why smc_pnet_create_pnetids_list() even exists, because smc_pnet_netdev_event() is also calling smc_pnet_add_base_pnetid() when handling NETDEV_UP event.
[1] extract of typical syzbot reports
2 locks held by syz-executor.3/12252:
#0: ffffffff8f369610 (pernet_ops_rwsem){++++}-{3:3}, at: copy_net_ns+0x4c7/0x7b0 net/core/net_namespace.c:491 #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_create_pnetids_list net/smc/smc_pnet.c:809 [inline] #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_net_init+0x10a/0x1e0 net/smc/smc_pnet.c:878
2 locks held by syz-executor.4/12253:
#0: ffffffff8f369610 (pernet_ops_rwsem){++++}-{3:3}, at: copy_net_ns+0x4c7/0x7b0 net/core/net_namespace.c:491 #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_create_pnetids_list net/smc/smc_pnet.c:809 [inline] #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_net_init+0x10a/0x1e0 net/smc/smc_pnet.c:878
2 locks held by syz-executor.1/12257:
#0: ffffffff8f369610 (pernet_ops_rwsem){++++}-{3:3}, at: copy_net_ns+0x4c7/0x7b0 net/core/net_namespace.c:491 #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_create_pnetids_list net/smc/smc_pnet.c:809 [inline] #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_net_init+0x10a/0x1e0 net/smc/smc_pnet.c:878
2 locks held by syz-executor.2/12261:
#0: ffffffff8f369610 (pernet_ops_rwsem){++++}-{3:3}, at: copy_net_ns+0x4c7/0x7b0 net/core/net_namespace.c:491 #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_create_pnetids_list net/smc/smc_pnet.c:809 [inline] #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_net_init+0x10a/0x1e0 net/smc/smc_pnet.c:878
2 locks held by syz-executor.0/12265:
#0: ffffffff8f369610 (pernet_ops_rwsem){++++}-{3:3}, at: copy_net_ns+0x4c7/0x7b0 net/core/net_namespace.c:491 #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_create_pnetids_list net/smc/smc_pnet.c:809 [inline] #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_net_init+0x10a/0x1e0 net/smc/smc_pnet.c:878
2 locks held by syz-executor.3/12268:
#0: ffffffff8f369610 (pernet_ops_rwsem){++++}-{3:3}, at: copy_net_ns+0x4c7/0x7b0 net/core/net_namespace.c:491 #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_create_pnetids_list net/smc/smc_pnet.c:809 [inline] #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_net_init+0x10a/0x1e0 net/smc/smc_pnet.c:878
2 locks held by syz-executor.4/12271:
#0: ffffffff8f369610 (pernet_ops_rwsem){++++}-{3:3}, at: copy_net_ns+0x4c7/0x7b0 net/core/net_namespace.c:491 #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_create_pnetids_list net/smc/smc_pnet.c:809 [inline] #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_net_init+0x10a/0x1e0 net/smc/smc_pnet.c:878
2 locks held by syz-executor.1/12274:
#0: ffffffff8f369610 (pernet_ops_rwsem){++++}-{3:3}, at: copy_net_ns+0x4c7/0x7b0 net/core/net_namespace.c:491 #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_create_pnetids_list net/smc/smc_pnet.c:809 [inline] #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_net_init+0x10a/0x1e0 net/smc/smc_pnet.c:878
2 locks held by syz-executor.2/12280:
#0: ffffffff8f369610 (pernet_ops_rwsem){++++}-{3:3}, at: copy_net_ns+0x4c7/0x7b0 net/core/net_namespace.c:491 #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_create_pnetids_list net/smc/smc_pnet.c:809 [inline] #1: ffffffff8f375b88 (rtnl_mutex){+.+.}-{3:3}, at: smc_pnet_net_init+0x10a/0x1e0 net/smc/smc_pnet.c:878
--- net/smc/smc_pnet.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
net/smc/smc_pnet.c +10 -0
@@ -802,6 +802,16 @@ static void smc_pnet_create_pnetids_list(struct net *net)u8 ndev_pnetid[SMC_MAX_PNETID_LEN ];struct net_device *dev; +/* Newly created netns do not have devices. +* Do not even acquire rtnl. +*/ +if (list_empty (&net->dev_base_head)) +return ; + +/* Note: This might not be needed, because smc_pnet_netdev_event() +* is also calling smc_pnet_add_base_pnetid() when handling +* NETDEV_UP event. +*/ rtnl_lock ();for_each_netdev (net, dev)smc_pnet_add_base_pnetid (net, dev, ndev_pnetid);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 30/31 Bluetooth: btintel: Fix null ptr deref in btintel_read_version
In reply to Sasha LevinFrom: Edward Adam Davis <[email protected]>
[ Upstream commit b79e040910101b020931ba0c9a6b77e81ab7f645 ]
If hci_cmd_sync_complete() is triggered and skb is NULL, then hdev->req_skb is NULL, which will cause this issue.
--- drivers/bluetooth/btintel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bluetooth/btintel.c +1 -1
@@ -405,7 +405,7 @@ int btintel_read_version(struct hci_dev *hdev, struct intel_version *ver)struct sk_buff *skb; skb =__hci_cmd_sync (hdev,0xfc05 ,0 ,NULL ,HCI_CMD_TIMEOUT ); -if (IS_ERR (skb)) { +if (IS_ERR_OR_NULL (skb)) {bt_dev_err (hdev,"Reading Intel version information failed (%ld)" ,PTR_ERR (skb));return PTR_ERR (skb);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 31/31 Bluetooth: btmtk: Add MODULE_FIRMWARE() for MT7922
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit 3e465a07cdf444140f16bc57025c23fcafdde997 ]
Since dracut refers to the module info for defining the required firmware files and btmtk driver doesn't provide the firmware info for MT7922, the generate initrd misses the firmware, resulting in the broken Bluetooth.
This patch simply adds the MODULE_FIRMWARE() for the missing entry for covering that.
--- drivers/bluetooth/btmtk.c | 1 + drivers/bluetooth/btmtk.h | 1 + 2 files changed, 2 insertions(+)
drivers/bluetooth/btmtk.c +1 -0
@@ -288,4 +288,5 @@ MODULE_LICENSE("GPL");MODULE_FIRMWARE (FIRMWARE_MT7622 );MODULE_FIRMWARE (FIRMWARE_MT7663 );MODULE_FIRMWARE (FIRMWARE_MT7668 ); +MODULE_FIRMWARE (FIRMWARE_MT7922 );MODULE_FIRMWARE (FIRMWARE_MT7961 );
drivers/bluetooth/btmtk.h +1 -0
@@ -4,6 +4,7 @@#define FIRMWARE_MT7622 "mediatek/mt7622pr2h.bin"#define FIRMWARE_MT7663 "mediatek/mt7663pr2h.bin"#define FIRMWARE_MT7668 "mediatek/mt7668pr2h.bin" +#define FIRMWARE_MT7922 "mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin"#define FIRMWARE_MT7961 "mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin"#define HCI_EV_WMT 0xe4
Signature · 1 line
2.43.0