wifi: plfxlc: fix clang-specific fortify warning
Subsystems (10)
Sasha Levin
maintainerPATCH 1/18 wifi: plfxlc: fix clang-specific fortify warning
From: Dmitry Antipov <[email protected]>
[ Upstream commit a763e92c78615ea838f5b9a841398b1d4adb968e ]
When compiling with clang 16.0.6 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following (somewhat confusing due to absence of an actual source code location):
In file included from drivers/net/wireless/purelifi/plfxlc/mac.c:6:
In file included from ./include/linux/netdevice.h:24:
In file included from ./include/linux/timer.h:6:
In file included from ./include/linux/ktime.h:24:
In file included from ./include/linux/time.h:60:
In file included from ./include/linux/time32.h:13:
In file included from ./include/linux/timex.h:67:
In file included from ./arch/x86/include/asm/timex.h:5:
In file included from ./arch/x86/include/asm/processor.h:23:
In file included from ./arch/x86/include/asm/msr.h:11:
In file included from ./arch/x86/include/asm/cpumask.h:5:
In file included from ./include/linux/cpumask.h:12:
In file included from ./include/linux/bitmap.h:11:
In file included from ./include/linux/string.h:254:./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
__read_overflow2_field(q_size_field, size);
The compiler actually complains on 'plfxlc_get_et_strings()' where fortification logic inteprets call to 'memcpy()' as an attempt to copy the whole 'et_strings' array from its first member and so issues an overread warning. This warning may be silenced by passing an address of the whole array and not the first member to 'memcpy()'.
--- drivers/net/wireless/purelifi/plfxlc/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/purelifi/plfxlc/mac.c +1 -1
@@ -666,7 +666,7 @@ static void plfxlc_get_et_strings(struct ieee80211_hw *hw, u32 sset, u8 *data) {if (sset ==ETH_SS_STATS ) -memcpy (data, *et_strings,sizeof (et_strings)); +memcpy (data, et_strings,sizeof (et_strings)); } static void plfxlc_get_et_stats(struct ieee80211_hw *hw,
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 2/18 wifi: mac80211_hwsim: fix clang-specific fortify warning
From: Dmitry Antipov <[email protected]>
[ Upstream commit cbaccdc42483c65016f1bae89128c08dc17cfb2a ]
When compiling with clang 16.0.6 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following (somewhat confusing due to absence of an actual source code location):
In file included from drivers/net/wireless/virtual/mac80211_hwsim.c:18:
In file included from ./include/linux/slab.h:16:
In file included from ./include/linux/gfp.h:7:
In file included from ./include/linux/mmzone.h:8:
In file included from ./include/linux/spinlock.h:56:
In file included from ./include/linux/preempt.h:79:
In file included from ./arch/x86/include/asm/preempt.h:9:
In file included from ./include/linux/thread_info.h:60:
In file included from ./arch/x86/include/asm/thread_info.h:53:
In file included from ./arch/x86/include/asm/cpufeature.h:5:
In file included from ./arch/x86/include/asm/processor.h:23:
In file included from ./arch/x86/include/asm/msr.h:11:
In file included from ./arch/x86/include/asm/cpumask.h:5:
In file included from ./include/linux/cpumask.h:12:
In file included from ./include/linux/bitmap.h:11:
In file included from ./include/linux/string.h:254:./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
__read_overflow2_field(q_size_field, size);
The compiler actually complains on 'mac80211_hwsim_get_et_strings()' where fortification logic inteprets call to 'memcpy()' as an attempt to copy the whole 'mac80211_hwsim_gstrings_stats' array from its first member and so issues an overread warning. This warning may be silenced by passing an address of the whole array and not the first member to 'memcpy()'.
--- drivers/net/wireless/mac80211_hwsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mac80211_hwsim.c +1 -1
@@ -3021,7 +3021,7 @@ static void mac80211_hwsim_get_et_strings(struct ieee80211_hw *hw, u32 sset, u8 *data) {if (sset ==ETH_SS_STATS ) -memcpy (data, *mac80211_hwsim_gstrings_stats, +memcpy (data, mac80211_hwsim_gstrings_stats,sizeof (mac80211_hwsim_gstrings_stats)); }
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 3/18 wifi: mac80211: don't return unset power in ieee80211_get_tx_power()
In reply to Sasha LevinFrom: Ping-Ke Shih <[email protected]>
[ Upstream commit e160ab85166e77347d0cbe5149045cb25e83937f ]
We can get a UBSAN warning if ieee80211_get_tx_power() returns the INT_MIN value mac80211 internally uses for "unset power level".
UBSAN: signed-integer-overflow in net/wireless/nl80211.c:3816:5 -2147483648 * 100 cannot be represented in type 'int' CPU: 0 PID: 20433 Comm: insmod Tainted: G WC OE Call Trace: dump_stack+0x74/0x92 ubsan_epilogue+0x9/0x50 handle_overflow+0x8d/0xd0 __ubsan_handle_mul_overflow+0xe/0x10 nl80211_send_iface+0x688/0x6b0 [cfg80211] [...] cfg80211_register_wdev+0x78/0xb0 [cfg80211] cfg80211_netdev_notifier_call+0x200/0x620 [cfg80211] [...] ieee80211_if_add+0x60e/0x8f0 [mac80211] ieee80211_register_hw+0xda5/0x1170 [mac80211]
In this case, simply return an error instead, to indicate that no data is available.
--- net/mac80211/cfg.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mac80211/cfg.c +4 -0
@@ -3006,6 +3006,10 @@ static int ieee80211_get_tx_power(struct wiphy *wiphy,else *dbm = sdata->vif.bss_conf.txpower; +/* INT_MIN indicates no power level was set yet */ +if (*dbm ==INT_MIN ) +return -EINVAL ; +return 0 ; }
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 4/18 atl1c: Work around the DMA RX overflow issue
In reply to Sasha LevinFrom: Sieng-Piaw Liew <[email protected]>
[ Upstream commit 86565682e9053e5deb128193ea9e88531bbae9cf ]
This is based on alx driver commit 881d0327db37 ("net: alx: Work around the DMA RX overflow issue").
The alx and atl1c drivers had RX overflow error which was why a custom allocator was created to avoid certain addresses. The simpler workaround then created for alx driver, but not for atl1c due to lack of tester.
Instead of using a custom allocator, check the allocated skb address and use skb_reserve() to move away from problematic 0x...fc0 address.
Tested on AR8131 on Acer 4540.
--- drivers/net/ethernet/atheros/atl1c/atl1c.h | 3 - .../net/ethernet/atheros/atl1c/atl1c_main.c | 67 +++++-------------- 2 files changed, 16 insertions(+), 54 deletions(-)
drivers/net/ethernet/atheros/atl1c/atl1c.h +0 -3
@@ -504,15 +504,12 @@ struct atl1c_rrd_ring {u16 next_to_use;u16 next_to_clean;struct napi_struct napi; -struct page *rx_page; -unsigned int rx_page_offset; };/* board specific private data structure */ struct atl1c_adapter {struct net_device *netdev;struct pci_dev *pdev; -unsigned int rx_frag_size;struct atl1c_hw hw;struct atl1c_hw_stats hw_stats;struct mii_if_info mii;/* MII interface info */
drivers/net/ethernet/atheros/atl1c/atl1c_main.c +16 -51
111 lines not on this page · raw message
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 5/18 bpf: Detect IP == ksym.end as part of BPF program
In reply to Sasha LevinFrom: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit 66d9111f3517f85ef2af0337ece02683ce0faf21 ]
Now that bpf_throw kfunc is the first such call instruction that has noreturn semantics within the verifier, this also kicks in dead code elimination in unprecedented ways. For one, any instruction following a bpf_throw call will never be marked as seen. Moreover, if a callchain ends up throwing, any instructions after the call instruction to the eventually throwing subprog in callers will also never be marked as seen.
The tempting way to fix this would be to emit extra 'int3' instructions which bump the jited_len of a program, and ensure that during runtime when a program throws, we can discover its boundaries even if the call instruction to bpf_throw (or to subprogs that always throw) is emitted as the final instruction in the program.
An example of such a program would be this:
do_something():
... r0 = 0 exit
foo():
r1 = 0 call bpf_throw r0 = 0 exit
bar(cond):
if r1 != 0 goto pc+2 call do_something exit call foo r0 = 0 // Never seen by verifier exit //
main(ctx):
r1 = ... call bar r0 = 0 exit
Here, if we do end up throwing, the stacktrace would be the following:
bpf_throw
foo
bar
main
In bar, the final instruction emitted will be the call to foo, as such, the return address will be the subsequent instruction (which the JIT emits as int3 on x86). This will end up lying outside the jited_len of the program, thus, when unwinding, we will fail to discover the return address as belonging to any program and end up in a panic due to the unreliable stack unwinding of BPF programs that we never expect.
To remedy this case, make bpf_prog_ksym_find treat IP == ksym.end as part of the BPF program, so that is_bpf_text_address returns true when such a case occurs, and we are able to unwind reliably when the final instruction ends up being a call instruction.
--- kernel/bpf/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/bpf/core.c +5 -1
@@ -608,7 +608,11 @@ static __always_inline int bpf_tree_comp(void *key, struct latch_tree_node *n)if (val < ksym->start)return -1 ; -if (val >= ksym->end) +/* Ensure that we detect return addresses as part of the program, when +* the final instruction is a call for a program part of the stack +* trace. Therefore, do val > ksym->end instead of val >= ksym->end. +*/ +if (val > ksym->end)return 1 ;return 0 ;
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 6/18 wifi: ath9k: fix clang-specific fortify warnings
In reply to Sasha LevinFrom: Dmitry Antipov <[email protected]>
[ Upstream commit 95f97fe0ac974467ab4da215985a32b2fdf48af0 ]
When compiling with clang 16.0.6 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following (somewhat confusing due to absence of an actual source code location):
In file included from drivers/net/wireless/ath/ath9k/debug.c:17:
In file included from ./include/linux/slab.h:16:
In file included from ./include/linux/gfp.h:7:
In file included from ./include/linux/mmzone.h:8:
In file included from ./include/linux/spinlock.h:56:
In file included from ./include/linux/preempt.h:79:
In file included from ./arch/x86/include/asm/preempt.h:9:
In file included from ./include/linux/thread_info.h:60:
In file included from ./arch/x86/include/asm/thread_info.h:53:
In file included from ./arch/x86/include/asm/cpufeature.h:5:
In file included from ./arch/x86/include/asm/processor.h:23:
In file included from ./arch/x86/include/asm/msr.h:11:
In file included from ./arch/x86/include/asm/cpumask.h:5:
In file included from ./include/linux/cpumask.h:12:
In file included from ./include/linux/bitmap.h:11:
In file included from ./include/linux/string.h:254:./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
__read_overflow2_field(q_size_field, size);
In file included from drivers/net/wireless/ath/ath9k/htc_drv_debug.c:17:
In file included from drivers/net/wireless/ath/ath9k/htc.h:20:
In file included from ./include/linux/module.h:13:
In file included from ./include/linux/stat.h:19:
In file included from ./include/linux/time.h:60:
In file included from ./include/linux/time32.h:13:
In file included from ./include/linux/timex.h:67:
In file included from ./arch/x86/include/asm/timex.h:5:
In file included from ./arch/x86/include/asm/processor.h:23:
In file included from ./arch/x86/include/asm/msr.h:11:
In file included from ./arch/x86/include/asm/cpumask.h:5:
In file included from ./include/linux/cpumask.h:12:
In file included from ./include/linux/bitmap.h:11:
In file included from ./include/linux/string.h:254:./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
__read_overflow2_field(q_size_field, size);
The compiler actually complains on 'ath9k_get_et_strings()' and 'ath9k_htc_get_et_strings()' due to the same reason: fortification logic inteprets call to 'memcpy()' as an attempt to copy the whole array from it's first member and so issues an overread warning. These warnings may be silenced by passing an address of the whole array and not the first member to 'memcpy()'.
--- drivers/net/wireless/ath/ath9k/debug.c | 2 +- drivers/net/wireless/ath/ath9k/htc_drv_debug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/debug.c +1 -1
@@ -1333,7 +1333,7 @@ void ath9k_get_et_strings(struct ieee80211_hw *hw, u32 sset, u8 *data) {if (sset ==ETH_SS_STATS ) -memcpy (data, *ath9k_gstrings_stats, +memcpy (data, ath9k_gstrings_stats,sizeof (ath9k_gstrings_stats)); }
drivers/net/wireless/ath/ath9k/htc_drv_debug.c +1 -1
@@ -428,7 +428,7 @@ void ath9k_htc_get_et_strings(struct ieee80211_hw *hw, u32 sset, u8 *data) {if (sset ==ETH_SS_STATS ) -memcpy (data, *ath9k_htc_gstrings_stats, +memcpy (data, ath9k_htc_gstrings_stats,sizeof (ath9k_htc_gstrings_stats)); }
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 7/18 wifi: ath10k: fix clang-specific fortify warning
In reply to Sasha LevinFrom: Dmitry Antipov <[email protected]>
[ Upstream commit cb4c132ebfeac5962f7258ffc831caa0c4dada1a ]
When compiling with clang 16.0.6 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following (somewhat confusing due to absence of an actual source code location):
In file included from drivers/net/wireless/ath/ath10k/debug.c:8:
In file included from ./include/linux/module.h:13:
In file included from ./include/linux/stat.h:19:
In file included from ./include/linux/time.h:60:
In file included from ./include/linux/time32.h:13:
In file included from ./include/linux/timex.h:67:
In file included from ./arch/x86/include/asm/timex.h:5:
In file included from ./arch/x86/include/asm/processor.h:23:
In file included from ./arch/x86/include/asm/msr.h:11:
In file included from ./arch/x86/include/asm/cpumask.h:5:
In file included from ./include/linux/cpumask.h:12:
In file included from ./include/linux/bitmap.h:11:
In file included from ./include/linux/string.h:254:./include/linux/fortify-string.h:592:4: warning: call to '__read_overflow2_field' declared with 'warning' attribute: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
__read_overflow2_field(q_size_field, size);
The compiler actually complains on 'ath10k_debug_get_et_strings()' where fortification logic inteprets call to 'memcpy()' as an attempt to copy the whole 'ath10k_gstrings_stats' array from it's first member and so issues an overread warning. This warning may be silenced by passing an address of the whole array and not the first member to 'memcpy()'.
--- drivers/net/wireless/ath/ath10k/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/debug.c +1 -1
@@ -1139,7 +1139,7 @@ void ath10k_debug_get_et_strings(struct ieee80211_hw *hw, u32 sset, u8 *data) {if (sset ==ETH_SS_STATS ) -memcpy (data, *ath10k_gstrings_stats, +memcpy (data, ath10k_gstrings_stats,sizeof (ath10k_gstrings_stats)); }
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 8/18 net: annotate data-races around sk->sk_tx_queue_mapping
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 0bb4d124d34044179b42a769a0c76f389ae973b6 ]
This field can be read or written without socket lock being held.
Add annotations to avoid load-store tearing.
--- include/net/sock.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
include/net/sock.h +16 -4
@@ -2032,21 +2032,33 @@ static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)/* sk_tx_queue_mapping accept only upto a 16-bit value */ if (WARN_ON_ONCE ((unsigned short )tx_queue >=USHRT_MAX ))return ; - sk->sk_tx_queue_mapping = tx_queue; +/* Paired with READ_ONCE() in sk_tx_queue_get() and +* other WRITE_ONCE() because socket lock might be not held. +*/ +WRITE_ONCE (sk->sk_tx_queue_mapping, tx_queue); }#define NO_QUEUE_MAPPING USHRT_MAXstatic inline void sk_tx_queue_clear (struct sock *sk) { - sk->sk_tx_queue_mapping =NO_QUEUE_MAPPING ; +/* Paired with READ_ONCE() in sk_tx_queue_get() and +* other WRITE_ONCE() because socket lock might be not held. +*/ +WRITE_ONCE (sk->sk_tx_queue_mapping,NO_QUEUE_MAPPING ); }static inline int sk_tx_queue_get (const struct sock *sk) { -if (sk && sk->sk_tx_queue_mapping !=NO_QUEUE_MAPPING ) -return sk->sk_tx_queue_mapping; +if (sk) { +/* Paired with WRITE_ONCE() in sk_tx_queue_clear() +* and sk_tx_queue_set(). +*/ +int val =READ_ONCE (sk->sk_tx_queue_mapping); +if (val !=NO_QUEUE_MAPPING ) +return val; + }return -1 ; }
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 9/18 net: annotate data-races around sk->sk_dst_pending_confirm
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit eb44ad4e635132754bfbcb18103f1dcb7058aedd ]
This field can be read or written without socket lock being held.
Add annotations to avoid load-store tearing.
--- include/net/sock.h | 6 +++--- net/core/sock.c | 2 +- net/ipv4/tcp_output.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
include/net/sock.h +3 -3
@@ -2207,7 +2207,7 @@ static inline void __dst_negative_advice(struct sock *sk)if (ndst != dst) {rcu_assign_pointer (sk->sk_dst_cache, ndst);sk_tx_queue_clear (sk); - sk->sk_dst_pending_confirm =0 ; +WRITE_ONCE (sk->sk_dst_pending_confirm,0 ); } } }
@@ -2224,7 +2224,7 @@ __sk_dst_set(struct sock *sk, struct dst_entry *dst)struct dst_entry *old_dst;sk_tx_queue_clear (sk); - sk->sk_dst_pending_confirm =0 ; +WRITE_ONCE (sk->sk_dst_pending_confirm,0 ); old_dst =rcu_dereference_protected (sk->sk_dst_cache,lockdep_sock_is_held (sk));rcu_assign_pointer (sk->sk_dst_cache, dst);
@@ -2237,7 +2237,7 @@ sk_dst_set(struct sock *sk, struct dst_entry *dst)struct dst_entry *old_dst;sk_tx_queue_clear (sk); - sk->sk_dst_pending_confirm =0 ; +WRITE_ONCE (sk->sk_dst_pending_confirm,0 ); old_dst =xchg ((__force struct dst_entry **)&sk->sk_dst_cache, dst);dst_release (old_dst); }
net/core/sock.c +1 -1
@@ -596,7 +596,7 @@ struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie) INDIRECT_CALL_INET(dst->ops->check, ip6_dst_check, ipv4_dst_check, dst, cookie) == NULL) {sk_tx_queue_clear (sk); - sk->sk_dst_pending_confirm =0 ; +WRITE_ONCE (sk->sk_dst_pending_confirm,0 );RCU_INIT_POINTER (sk->sk_dst_cache,NULL );dst_release (dst);return NULL ;
net/ipv4/tcp_output.c +1 -1
@@ -1319,7 +1319,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, skb->destructor =skb_is_tcp_pure_ack (skb) ? __sock_wfree : tcp_wfree;refcount_add (skb->truesize, &sk->sk_wmem_alloc); -skb_set_dst_pending_confirm (skb, sk->sk_dst_pending_confirm); +skb_set_dst_pending_confirm (skb,READ_ONCE (sk->sk_dst_pending_confirm));/* Build TCP header and checksum it. */ th = (struct tcphdr *)skb->data;
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 10/18 wifi: ath10k: Don't touch the CE interrupt registers after power up
In reply to Sasha LevinFrom: Douglas Anderson <[email protected]>
[ Upstream commit 170c75d43a77dc937c58f07ecf847ba1b42ab74e ]
As talked about in commit d66d24ac300c ("ath10k: Keep track of which interrupts fired, don't poll them"), if we access the copy engine register at a bad time then ath10k can go boom. However, it's not necessarily easy to know when it's safe to access them.
The ChromeOS test labs saw a crash that looked like this at shutdown/reboot time (on a chromeos-5.15 kernel, but likely the problem could also reproduce upstream):
Internal error: synchronous external abort: 96000010 [#1] PREEMPT SMP ... CPU: 4 PID: 6168 Comm: reboot Not tainted 5.15.111-lockdep-19350-g1d624fe6758f #1 010b9b233ab055c27c6dc88efb0be2f4e9e86f51 Hardware name: Google Kingoftown (DT) ... pc : ath10k_snoc_read32+0x50/0x74 [ath10k_snoc] lr : ath10k_snoc_read32+0x24/0x74 [ath10k_snoc] ... Call trace: ath10k_snoc_read32+0x50/0x74 [ath10k_snoc ...] ath10k_ce_disable_interrupt+0x190/0x65c [ath10k_core ...] ath10k_ce_disable_interrupts+0x8c/0x120 [ath10k_core ...] ath10k_snoc_hif_stop+0x78/0x660 [ath10k_snoc ...] ath10k_core_stop+0x13c/0x1ec [ath10k_core ...] ath10k_halt+0x398/0x5b0 [ath10k_core ...] ath10k_stop+0xfc/0x1a8 [ath10k_core ...] drv_stop+0x148/0x6b4 [mac80211 ...] ieee80211_stop_device+0x70/0x80 [mac80211 ...] ieee80211_do_stop+0x10d8/0x15b0 [mac80211 ...] ieee80211_stop+0x144/0x1a0 [mac80211 ...] __dev_close_many+0x1e8/0x2c0 dev_close_many+0x198/0x33c dev_close+0x140/0x210 cfg80211_shutdown_all_interfaces+0xc8/0x1e0 [cfg80211 ...] ieee80211_remove_interfaces+0x118/0x5c4 [mac80211 ...] ieee80211_unregister_hw+0x64/0x1f4 [mac80211 ...] ath10k_mac_unregister+0x4c/0xf0 [ath10k_core ...] ath10k_core_unregister+0x80/0xb0 [ath10k_core ...] ath10k_snoc_free_resources+0xb8/0x1ec [ath10k_snoc ...] ath10k_snoc_shutdown+0x98/0xd0 [ath10k_snoc ...] platform_shutdown+0x7c/0xa0 device_shutdown+0x3e0/0x58c kernel_restart_prepare+0x68/0xa0 kernel_restart+0x28/0x7c
Though there's no known way to reproduce the problem, it makes sense that it would be the same issue where we're trying to access copy engine registers when it's not allowed.
Let's fix this by changing how we "disable" the interrupts. Instead of tweaking the copy engine registers we'll just use disable_irq() and enable_irq(). Then we'll configure the interrupts once at power up time.
Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.2.2.c10-00754-QCAHLSWMTPL-1
--- drivers/net/wireless/ath/ath10k/snoc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath10k/snoc.c +14 -4
@@ -828,12 +828,20 @@ static void ath10k_snoc_hif_get_default_pipe(struct ath10k *ar,static inline void ath10k_snoc_irq_disable (struct ath10k *ar) { -ath10k_ce_disable_interrupts (ar); +struct ath10k_snoc *ar_snoc =ath10k_snoc_priv (ar); +int id; + +for (id =0 ; id <CE_COUNT_MAX ; id++) +disable_irq (ar_snoc->ce_irqs[id].irq_line); }static inline void ath10k_snoc_irq_enable (struct ath10k *ar) { -ath10k_ce_enable_interrupts (ar); +struct ath10k_snoc *ar_snoc =ath10k_snoc_priv (ar); +int id; + +for (id =0 ; id <CE_COUNT_MAX ; id++) +enable_irq (ar_snoc->ce_irqs[id].irq_line); }static void ath10k_snoc_rx_pipe_cleanup (struct ath10k_snoc_pipe *snoc_pipe)
@@ -1089,6 +1097,8 @@ static int ath10k_snoc_hif_power_up(struct ath10k *ar, goto err_free_rri; } +ath10k_ce_enable_interrupts (ar); +return 0 ; err_free_rri:
@@ -1252,8 +1262,8 @@ static int ath10k_snoc_request_irq(struct ath10k *ar)for (id =0 ; id <CE_COUNT_MAX ; id++) { ret =request_irq (ar_snoc->ce_irqs[id].irq_line, - ath10k_snoc_per_engine_handler,0 , - ce_name[id], ar); + ath10k_snoc_per_engine_handler, +IRQF_NO_AUTOEN , ce_name[id], ar);if (ret) { ath10k_err(ar, "failed to register IRQ handler for CE %d: %d\n",
Signature · 7 lines
2.42.0 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Sasha Levin
maintainerPATCH 11/18 vsock: read from socket's error queue
In reply to Sasha LevinFrom: Arseniy Krasnov <[email protected]>
[ Upstream commit 49dbe25adac42d3e06f65d1420946bec65896222 ]
This adds handling of MSG_ERRQUEUE input flag in receive call. This flag is used to read socket's error queue instead of data queue. Possible scenario of error queue usage is receiving completions for transmission with MSG_ZEROCOPY flag. This patch also adds new defines: 'SOL_VSOCK' and 'VSOCK_RECVERR'.
--- include/linux/socket.h | 1 + include/uapi/linux/vm_sockets.h | 17 +++++++++++++++++ net/vmw_vsock/af_vsock.c | 6 ++++++ 3 files changed, 24 insertions(+)
include/linux/socket.h +1 -0
@@ -376,6 +376,7 @@ struct ucred {#define SOL_MPTCP 284#define SOL_MCTP 285#define SOL_SMC 286 +#define SOL_VSOCK 287/* IPX options */ #define IPX_TYPE 1
include/uapi/linux/vm_sockets.h +17 -0
@@ -191,4 +191,21 @@ struct sockaddr_vm {#define IOCTL_VM_SOCKETS_GET_LOCAL_CID _IO(7, 0xb9) +/* MSG_ZEROCOPY notifications are encoded in the standard error format, +* sock_extended_err. See Documentation/networking/msg_zerocopy.rst in +* kernel source tree for more details. +*/ + +/* 'cmsg_level' field value of 'struct cmsghdr' for notification parsing +* when MSG_ZEROCOPY flag is used on transmissions. +*/ + +#define SOL_VSOCK 287 + +/* 'cmsg_type' field value of 'struct cmsghdr' for notification parsing +* when MSG_ZEROCOPY flag is used on transmissions. +*/ + +#define VSOCK_RECVERR 1 +#endif /* _UAPI_VM_SOCKETS_H */
net/vmw_vsock/af_vsock.c +6 -0
@@ -89,6 +89,7 @@#include <linux/types.h> #include <linux/bitops.h> #include <linux/cred.h> +#include <linux/errqueue.h> #include <linux/init.h> #include <linux/io.h> #include <linux/kernel.h>
@@ -110,6 +111,7 @@#include <linux/workqueue.h> #include <net/sock.h> #include <net/af_vsock.h> +#include <uapi/linux/vm_sockets.h> static int __vsock_bind (struct sock *sk,struct sockaddr_vm *addr);static void vsock_sk_destruct (struct sock *sk);
@@ -2096,6 +2098,10 @@ vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,int err; sk = sock->sk; + +if (unlikely (flags &MSG_ERRQUEUE )) +return sock_recv_errqueue (sk, msg, len,SOL_VSOCK ,VSOCK_RECVERR ); + vsk =vsock_sk (sk); err =0 ;
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 12/18 bpf: Ensure proper register state printing for cond jumps
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 1a8a315f008a58f54fecb012b928aa6a494435b3 ]
Verifier emits relevant register state involved in any given instruction next to it after ; to the right, if possible. Or, worst case, on the separate line repeating instruction index.
E.g., a nice and simple case would be:
2: (d5) if r0 s<= 0x0 goto pc+1 ; R0_w=0
But if there is some intervening extra output (e.g., precision backtracking log) involved, we are supposed to see the state after the precision backtrack log:
4: (75) if r0 s>= 0x0 goto pc+1
mark_precise: frame0: last_idx 4 first_idx 0 subseq_idx -1
mark_precise: frame0: regs=r0 stack= before 2: (d5) if r0 s<= 0x0 goto pc+1
mark_precise: frame0: regs=r0 stack= before 1: (b7) r0 = 0
6: R0_w=0
First off, note that in 6: R0_w=0 instruction index corresponds to the next instruction, not to the conditional jump instruction itself, which is wrong and we'll get to that.
But besides that, the above is a happy case that does work today. Yet, if it so happens that precision backtracking had to traverse some of the parent states, this 6: R0_w=0 state output would be missing.
This is due to a quirk of print_verifier_state() routine, which performs mark_verifier_state_clean(env) at the end. This marks all registers as "non-scratched", which means that subsequent logic to print *relevant* registers (that is, "scratched ones") fails and doesn't see anything relevant to print and skips the output altogether.
print_verifier_state() is used both to print instruction context, but also to print an **entire** verifier state indiscriminately, e.g., during precision backtracking (and in a few other situations, like during entering or exiting subprogram). Which means if we have to print entire parent state before getting to printing instruction context state, instruction context is marked as clean and is omitted.
Long story short, this is definitely not intentional. So we fix this behavior in this patch by teaching print_verifier_state() to clear scratch state only if it was used to print instruction state, not the parent/callback state. This is determined by print_all option, so if it's not set, we don't clear scratch state. This fixes missing instruction state for these cases.
As for the mismatched instruction index, we fix that by making sure we call print_insn_state() early inside check_cond_jmp_op() before we adjusted insn_idx based on jump branch taken logic. And with that we get desired correct information:
9: (16) if w4 == 0x1 goto pc+9
mark_precise: frame0: last_idx 9 first_idx 9 subseq_idx -1
mark_precise: frame0: parent state regs=r4 stack=: R2_w=1944 R4_rw=P1 R10=fp0
mark_precise: frame0: last_idx 8 first_idx 0 subseq_idx 9
mark_precise: frame0: regs=r4 stack= before 8: (66) if w4 s> 0x3 goto pc+5
mark_precise: frame0: regs=r4 stack= before 7: (b7) r4 = 1
9: R4=1
--- kernel/bpf/verifier.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/bpf/verifier.c +6 -1
@@ -978,7 +978,8 @@ static void print_verifier_state(struct bpf_verifier_env *env,if (state->in_async_callback_fn)verbose (env," async_cb" );verbose (env,"\n" ); -mark_verifier_state_clean (env); +if (!print_all) +mark_verifier_state_clean (env); }static inline u32 vlog_alignment (u32 pos)
@@ -10476,6 +10477,8 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, !sanitize_speculative_path (env, insn, *insn_idx +1 , *insn_idx)) return -EFAULT; +if (env->log.level &BPF_LOG_LEVEL ) +print_insn_state (env, this_branch->frame[this_branch->curframe]); *insn_idx += insn->off;return 0 ; }else if (pred ==0 ) {
@@ -10488,6 +10491,8 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, *insn_idx + insn->off + 1, *insn_idx))return -EFAULT ; +if (env->log.level &BPF_LOG_LEVEL ) +print_insn_state (env, this_branch->frame[this_branch->curframe]);return 0 ; }
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 13/18 Bluetooth: btusb: Add date->evt_skb is NULL check
In reply to Sasha LevinFrom: youwan Wang <[email protected]>
[ Upstream commit 624820f7c8826dd010e8b1963303c145f99816e9 ]
fix crash because of null pointers
[ 6104.969662] BUG: kernel NULL pointer dereference, address: 00000000000000c8 [ 6104.969667] #PF: supervisor read access in kernel mode [ 6104.969668] #PF: error_code(0x0000) - not-present page [ 6104.969670] PGD 0 P4D 0 [ 6104.969673] Oops: 0000 [#1] SMP NOPTI [ 6104.969684] RIP: 0010:btusb_mtk_hci_wmt_sync+0x144/0x220 [btusb] [ 6104.969688] RSP: 0018:ffffb8d681533d48 EFLAGS: 00010246 [ 6104.969689] RAX: 0000000000000000 RBX: ffff8ad560bb2000 RCX: 0000000000000006 [ 6104.969691] RDX: 0000000000000000 RSI: ffffb8d681533d08 RDI: 0000000000000000 [ 6104.969692] RBP: ffffb8d681533d70 R08: 0000000000000001 R09: 0000000000000001 [ 6104.969694] R10: 0000000000000001 R11: 00000000fa83b2da R12: ffff8ad461d1d7c0 [ 6104.969695] R13: 0000000000000000 R14: ffff8ad459618c18 R15: ffffb8d681533d90 [ 6104.969697] FS: 00007f5a1cab9d40(0000) GS:ffff8ad578200000(0000) knlGS:00000 [ 6104.969699] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 6104.969700] CR2: 00000000000000c8 CR3: 000000018620c001 CR4: 0000000000760ef0 [ 6104.969701] PKRU: 55555554 [ 6104.969702] Call Trace: [ 6104.969708] btusb_mtk_shutdown+0x44/0x80 [btusb] [ 6104.969732] hci_dev_do_close+0x470/0x5c0 [bluetooth] [ 6104.969748] hci_rfkill_set_block+0x56/0xa0 [bluetooth] [ 6104.969753] rfkill_set_block+0x92/0x160 [ 6104.969755] rfkill_fop_write+0x136/0x1e0 [ 6104.969759] __vfs_write+0x18/0x40 [ 6104.969761] vfs_write+0xdf/0x1c0 [ 6104.969763] ksys_write+0xb1/0xe0 [ 6104.969765] __x64_sys_write+0x1a/0x20 [ 6104.969769] do_syscall_64+0x51/0x180 [ 6104.969771] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 6104.969773] RIP: 0033:0x7f5a21f18fef [ 6104.9] RSP: 002b:00007ffeefe39010 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 [ 6104.969780] RAX: ffffffffffffffda RBX: 000055c10a7560a0 RCX: 00007f5a21f18fef [ 6104.969781] RDX: 0000000000000008 RSI: 00007ffeefe39060 RDI: 0000000000000012 [ 6104.969782] RBP: 00007ffeefe39060 R08: 0000000000000000 R09: 0000000000000017 [ 6104.969784] R10: 00007ffeefe38d97 R11: 0000000000000293 R12: 0000000000000002 [ 6104.969785] R13: 00007ffeefe39220 R14: 00007ffeefe391a0 R15: 000055c10a72acf0
--- drivers/bluetooth/btusb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/bluetooth/btusb.c +3 -0
@@ -2638,6 +2638,9 @@ static int btusb_mtk_hci_wmt_sync(struct hci_dev *hdev, goto err_free_wc; } +if (data->evt_skb ==NULL ) + goto err_free_wc; +/* Parse and handle the return WMT event */ wmt_evt = (struct btmtk_hci_wmt_evt *)data->evt_skb->data;if (wmt_evt->whdr.op != hdr->op) {
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 14/18 Bluetooth: Fix double free in hci_conn_cleanup
In reply to Sasha LevinFrom: ZhengHan Wang <[email protected]>
[ Upstream commit a85fb91e3d728bdfc80833167e8162cce8bc7004 ]
syzbot reports a slab use-after-free in hci_conn_hash_flush [1]. After releasing an object using hci_conn_del_sysfs in the hci_conn_cleanup function, releasing the same object again using the hci_dev_put and hci_conn_put functions causes a double free. Here's a simplified flow:
hci_conn_del_sysfs:
hci_dev_put
put_device
kobject_put
kref_put
kobject_release
kobject_cleanup
kfree_const
kfree(name)
hci_dev_put:
...
kfree(name)
hci_conn_put:
put_device
...
kfree(name)This patch drop the hci_dev_put and hci_conn_put function call in hci_conn_cleanup function, because the object is freed in hci_conn_del_sysfs function.
This patch also fixes the refcounting in hci_conn_add_sysfs() and hci_conn_del_sysfs() to take into account device_add() failures.
This fixes CVE-2023-28464.
--- net/bluetooth/hci_conn.c | 6 ++---- net/bluetooth/hci_sysfs.c | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-)
net/bluetooth/hci_conn.c +2 -4
@@ -168,13 +168,11 @@ static void hci_conn_cleanup(struct hci_conn *conn) hdev->notify (hdev,HCI_NOTIFY_CONN_DEL ); } -hci_conn_del_sysfs (conn); -debugfs_remove_recursive (conn->debugfs); -hci_dev_put (hdev); +hci_conn_del_sysfs (conn); -hci_conn_put (conn); +hci_dev_put (hdev); }static void le_scan_cleanup (struct work_struct *work)
net/bluetooth/hci_sysfs.c +12 -11
@@ -33,7 +33,7 @@ void hci_conn_init_sysfs(struct hci_conn *conn) {struct hci_dev *hdev = conn->hdev; -BT_DBG ("conn %p" , conn); +bt_dev_dbg (hdev,"conn %p" , conn); conn->dev.type = &bt_link; conn->dev.class = bt_class;
@@ -46,27 +46,30 @@ void hci_conn_add_sysfs(struct hci_conn *conn) {struct hci_dev *hdev = conn->hdev; -BT_DBG ("conn %p" , conn); +bt_dev_dbg (hdev,"conn %p" , conn);if (device_is_registered (&conn->dev))return ;dev_set_name (&conn->dev,"%s:%d" , hdev->name, conn->handle); -if (device_add (&conn->dev) <0 ) { +if (device_add (&conn->dev) <0 )bt_dev_err (hdev,"failed to register connection device" ); -return ; - } - -hci_dev_hold (hdev); }void hci_conn_del_sysfs (struct hci_conn *conn) {struct hci_dev *hdev = conn->hdev; -if (!device_is_registered (&conn->dev)) +bt_dev_dbg (hdev,"conn %p" , conn); + +if (!device_is_registered (&conn->dev)) { +/* If device_add() has *not* succeeded, use *only* put_device() +* to drop the reference count. +*/ +put_device (&conn->dev);return ; + }while (1 ) {struct device *dev;
@@ -78,9 +81,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn)put_device (dev); } -device_del (&conn->dev); - -hci_dev_put (hdev); +device_unregister (&conn->dev); }static void bt_host_release (struct device *dev)
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 15/18 ACPI: EC: Add quirk for HP 250 G7 Notebook PC
In reply to Sasha LevinFrom: Jonathan Denose <[email protected]>
[ Upstream commit 891ddc03e2f4395e24795596e032f57d5ab37fe7 ]
Add GPE quirk entry for HP 250 G7 Notebook PC.
This change allows the lid switch to be identified as the lid switch and not a keyboard button. With the lid switch properly identified, the device triggers suspend correctly on lid close.
--- drivers/acpi/ec.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/acpi/ec.c +10 -0
@@ -1897,6 +1897,16 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Gaming Laptop 15-dk1xxx"), }, }, + { +/* +* HP 250 G7 Notebook PC +*/ + .callback = ec_honor_dsdt_gpe, + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"HP" ), + DMI_MATCH(DMI_PRODUCT_NAME, "HP 250 G7 Notebook PC"), + }, + }, {/* * Samsung hardware
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 16/18 tsnep: Fix tsnep_request_irq() format-overflow warning
In reply to Sasha LevinFrom: Gerhard Engleder <[email protected]>
[ Upstream commit 00e984cb986b31e9313745e51daceaa1e1eb7351 ]
Compiler warns about a possible format-overflow in tsnep_request_irq():drivers/net/ethernet/engleder/tsnep_main.c:884:55: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
sprintf(queue->name, "%s-rx-%d", name,
^
drivers/net/ethernet/engleder/tsnep_main.c:881:55: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
sprintf(queue->name, "%s-tx-%d", name,
^
drivers/net/ethernet/engleder/tsnep_main.c:878:49: warning: '-txrx-' directive writing 6 bytes into a region of size between 5 and 25 [-Wformat-overflow=]
sprintf(queue->name, "%s-txrx-%d", name,
^~~~~~Actually overflow cannot happen. Name is limited to IFNAMSIZ, because netdev_name() is called during ndo_open(). queue_index is single char, because less than 10 queues are supported.
Fix warning with snprintf(). Additionally increase buffer to 32 bytes, because those 7 additional bytes were unused anyway.
--- drivers/net/ethernet/engleder/tsnep.h | 2 +- drivers/net/ethernet/engleder/tsnep_main.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/ethernet/engleder/tsnep.h +1 -1
@@ -123,7 +123,7 @@ struct tsnep_rx {struct tsnep_queue {struct tsnep_adapter *adapter; -char name[IFNAMSIZ +9 ]; +char name[IFNAMSIZ +16 ];struct tsnep_tx *tx;struct tsnep_rx *rx;
drivers/net/ethernet/engleder/tsnep_main.c +6 -6
@@ -973,14 +973,14 @@ static int tsnep_request_irq(struct tsnep_queue *queue, bool first) dev = queue->adapter; }else {if (queue->tx && queue->rx) -sprintf (queue->name,"%s-txrx-%d" , name, - queue->rx->queue_index); +snprintf (queue->name,sizeof (queue->name),"%s-txrx-%d" , + name, queue->rx->queue_index);else if (queue->tx) -sprintf (queue->name,"%s-tx-%d" , name, - queue->tx->queue_index); +snprintf (queue->name,sizeof (queue->name),"%s-tx-%d" , + name, queue->tx->queue_index);else -sprintf (queue->name,"%s-rx-%d" , name, - queue->rx->queue_index); +snprintf (queue->name,sizeof (queue->name),"%s-rx-%d" , + name, queue->rx->queue_index); handler = tsnep_irq_txrx; dev = queue; }
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 17/18 platform/chrome: kunit: initialize lock for fake ec_dev
In reply to Sasha LevinFrom: Tzung-Bi Shih <[email protected]>
[ Upstream commit e410b4ade83d06a046f6e32b5085997502ba0559 ]
cros_ec_cmd_xfer() uses ec_dev->lock. Initialize it.
Otherwise, dmesg shows the following:
Quoted 8 lines
DEBUG_LOCKS_WARN_ON(lock->magic != lock)
...Call Trace: ? __mutex_lock ? __warn ? __mutex_lock ... ? cros_ec_cmd_xfer
--- drivers/platform/chrome/cros_ec_proto_test.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/chrome/cros_ec_proto_test.c +1 -0
@@ -2667,6 +2667,7 @@ static int cros_ec_proto_test_init(struct kunit *test) ec_dev->dev->release = cros_ec_proto_test_release; ec_dev->cmd_xfer = cros_kunit_ec_xfer_mock; ec_dev->pkt_xfer = cros_kunit_ec_xfer_mock; +mutex_init (&ec_dev->lock); priv->msg = (struct cros_ec_command *)priv->_msg;
Signature · 1 line
2.42.0
Sasha Levin
maintainerPATCH 18/18 platform/x86: thinkpad_acpi: Add battery quirk for Thinkpad X120e
In reply to Sasha LevinFrom: Olli Asikainen <[email protected]>
[ Upstream commit 916646758aea81a143ce89103910f715ed923346 ]
Thinkpad X120e also needs this battery quirk.
--- drivers/platform/x86/thinkpad_acpi.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/thinkpad_acpi.c +1 -0
@@ -9946,6 +9946,7 @@ static const struct tpacpi_quirk battery_quirk_table[] __initconst = {* Individual addressing is broken on models that expose the * primary battery as BAT1. */ +TPACPI_Q_LNV ('8' ,'F' , true),/* Thinkpad X120e */ TPACPI_Q_LNV ('J' ,'7' , true),/* B5400 */ TPACPI_Q_LNV ('J' ,'I' , true),/* Thinkpad 11e */ TPACPI_Q_LNV3('R', '0', 'B', true), /* Thinkpad 11e gen 3 */
Signature · 1 line
2.42.0