wifi: ath9k: fix LNA selection in ath_ant_try_scan()
Subsystems (10)
Sasha Levin
maintainerPATCH 1/20 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/20 batman-adv: Return directly after a failed batadv_dat_select_candidates() in batadv_dat_forward_data()
From: 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 3/20 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 4/20 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 5/20 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
@@ -425,6 +425,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 6/20 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 7/20 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
@@ -728,11 +728,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 8/20 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
@@ -1801,6 +1801,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>,
@@ -1809,13 +1810,16 @@ hdmi: hdmi@ff940000 { <&cru PLL_VPLL>; clock-names = "iahb", "isfr", "cec", "grf", "vpll"; 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>;
@@ -1828,6 +1832,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 9/20 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
@@ -3232,9 +3232,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 10/20 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 11/20 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 12/20 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
@@ -242,7 +242,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 );
@@ -808,7 +808,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 13/20 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
@@ -97,7 +97,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 14/20 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 15/20 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
@@ -13,6 +13,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz \ OBJECTS = $(obj)/head_32.o $(obj)/misc.o $(obj)/cache.o 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 16/20 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
@@ -3358,7 +3358,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 17/20 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 18/20 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
@@ -976,7 +976,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 19/20 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
@@ -796,6 +796,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 20/20 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