5.10.275-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 1650/1848 Bluetooth: 6LoWPAN: Use RCU-safe device list removal
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 8c27d7d06e21ba9455ddae4e14f364c57f095cba ]
RCU readers of bt_6lowpan_devices must be able to follow an adapter's forward link until their read-side critical section ends. The entries are published with list_add_rcu(), but device_event() removes an entry on NETDEV_UNREGISTER with list_del(), poisoning that link.
When an adapter is being unregistered and 6LoWPAN is enabled, a 6lowpan_control debugfs write with an existing LE L2CAP connection can enter lookup_peer() after unregister's first synchronize_net(). If the connection has no peer on that adapter, the reader must advance to the next list entry. Neither RTNL nor devices_lock excludes this RCU reader.
The last peer's chan_close_cb() schedules delete_netdev(), which reaches unregister_netdevice_many_notify() through unregister_dev() and lowpan_unregister_netdev(). The following ordering is possible:
Unregister worker Control writer
----------------- --------------
synchronize_net() returns
lowpan_control_write() lookup_peer(): rcu_read_lock() reach adapter; no matching peer
device_event(): devices_lock
list_del(&entry->list)
spin_unlock(&devices_lock)
follow poisoned next link read invalid adapter address
post-notifier synchronize_net()
waits for the reader
This invalid pointer access can fault in lookup_peer(). The first grace period drains existing readers but permits new ones to start, and the later grace period cannot prevent the intervening poisoned-link access.
Use list_del_rcu() under the existing devices_lock to preserve the forward link for readers that already reached the adapter. The existing post-notifier synchronize_net() waits for those readers before netdevice teardown frees the private storage containing lowpan_btle_dev.
KASAN report as below:
[...]
[ 45.867526] Oops: general protection fault, probably for non-canonical address 0xfbd59c0000000023: 0000 [#1] SMP KASAN NOPTI
[ 45.869489] KASAN: maybe wild-memory-access in range [0xdead000000000118-0xdead00000000011f]
[ 45.870981] CPU: 1 UID: 0 PID: 646 Comm: sh Not tainted 7.2.0-rc6-pmb-bt-functional-v1+ #4 PREEMPT(lazy)
[ 45.872609] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 45.874380] RIP: 0010:lookup_peer+0x1ba/0x320
[ 45.875067] Code: 48 89 d9 ba 04 00 00 00 4c 89 fe bf a0 06 00 00 e8 2b e8 ad fb e9 56 ff ff ff e8 01 1e c3 fb 49 8d 7f 18 48 89 f8 48 c1 e8 03 <80> 3c 28 00 0f 85 4a 01 00 00 4d 8b 47 18 4c 89 f1 ba 04 00 00 00
[ 45.878206] RSP: 0018:ffff888114d67b90 EFLAGS: 00010212
[ 45.879106] RAX: 1bd5a00000000023 RBX: 0000000000000000 RCX: ffffffff85c1d19f
[ 45.880334] RDX: ffff88810dc35700 RSI: 0000000000000000 RDI: dead000000000118
[ 45.881455] RBP: dffffc0000000000 R08: 0000000000000001 R09: 0000000000000001
[ 45.882546] R10: ffffffff893d3057 R11: ffff88810dc35700 R12: ffff88810a690000
[ 45.883839] R13: ffff888115451038 R14: ffff88810a690000 R15: dead000000000100
[ 45.885186] FS: 00007fa889bac780(0000) GS:ffff8881fd852000(0000) knlGS:0000000000000000
[ 45.886539] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 45.887527] CR2: 00007ffe304f2f80 CR3: 0000000104f64005 CR4: 0000000000770ef0
[ 45.888687] PKRU: 55555554
[ 45.889183] Call Trace:
[ 45.889666] <TASK>
[ 45.890061] lowpan_control_write+0x445/0x9e0
[ 45.890854] ? __pfx_lowpan_control_write+0x10/0x10
[ 45.891738] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.892603] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.893383] ? __debugfs_file_get+0x1bd/0x7f0
[ 45.894057] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.894902] ? lock_acquire+0x17b/0x2f0
[ 45.895593] ? ksys_write+0x111/0x200
[ 45.896290] full_proxy_write+0x11f/0x180
[ 45.896991] vfs_write+0x25a/0x1010
[ 45.897642] ? __pfx_full_proxy_write+0x10/0x10
[ 45.898440] ? __pfx_vfs_write+0x10/0x10
[ 45.899178] ? lock_release+0x11f/0x280
[ 45.899855] ksys_write+0x111/0x200
[ 45.900435] ? __pfx_ksys_write+0x10/0x10
[ 45.901074] ? irqentry_exit+0xbe/0x820
[ 45.901722] ? srso_alias_return_thunk+0x5/0xfbef5
[ 45.902489] do_syscall_64+0x115/0x6a0
[ 45.903064] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 45.903813] RIP: 0033:0x7fa889c3e687
[ 45.904359] Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
[ 45.906981] RSP: 002b:00007ffd7651b960 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
[ 45.908070] RAX: ffffffffffffffda RBX: 00007fa889bac780 RCX: 00007fa889c3e687
[ 45.909102] RDX: 000000000000001c RSI: 00005570f25e8d10 RDI: 0000000000000001
[ 45.910133] RBP: 00005570f25e8d10 R08: 0000000000000000 R09: 0000000000000000
[ 45.911162] R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000001
[ 45.912190] R13: 000000000000001c R14: 0000000000000000 R15: 00005570f25e8a78
[ 45.913208] </TASK>
[ 45.913530] Modules linked in:
[ 45.914022] ---[ end trace 0000000000000000 ]---
[ 45.914709] RIP: 0010:lookup_peer+0x1ba/0x320
[ 45.915436] Code: 48 89 d9 ba 04 00 00 00 4c 89 fe bf a0 06 00 00 e8 2b e8 ad fb e9 56 ff ff ff e8 01 1e c3 fb 49 8d 7f 18 48 89 f8 48 c1 e8 03 <80> 3c 28 00 0f 85 4a 01 00 00 4d 8b 47 18 4c 89 f1 ba 04 00 00 00
[ 45.919191] RSP: 0018:ffff888114d67b90 EFLAGS: 00010212
[ 45.920046] RAX: 1bd5a00000000023 RBX: 0000000000000000 RCX: ffffffff85c1d19f
[ 45.921129] RDX: ffff88810dc35700 RSI: 0000000000000000 RDI: dead000000000118
[ 45.922553] RBP: dffffc0000000000 R08: 0000000000000001 R09: 0000000000000001
[ 45.923653] R10: ffffffff893d3057 R11: ffff88810dc35700 R12: ffff88810a690000
[ 45.925119] R13: ffff888115451038 R14: ffff88810a690000 R15: dead000000000100
[ 45.926180] FS: 00007fa889bac780(0000) GS:ffff8881fd852000(0000) knlGS:0000000000000000
[ 45.927817] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 45.928726] CR2: 00007ffe304f2f80 CR3: 0000000104f64005 CR4: 0000000000770ef0
[ 45.930069] PKRU: 55555554
[ 45.930456] Kernel panic - not syncing: Fatal exception
[ 45.931542] Kernel Offset: disabled
[ 45.932040] Rebooting in 1 seconds..--- net/bluetooth/6lowpan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/6lowpan.c +1 -1
@@ -1325,7 +1325,7 @@ static int device_event(struct notifier_block *unused,if (entry->netdev == netdev) {BT_DBG ("Unregistered netdev %s %p" , netdev->name, netdev); -list_del (&entry->list); +list_del_rcu (&entry->list);break ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1651/1848 Bluetooth: hci_core: Keep RCU protection through LTK filtering
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 817cbcab91fe870e5b69c835cbd708242c9f8c8e ]
The LTK selected by hci_find_ltk() must remain allocated while its value is checked against the blocked-key list. The finder releases RCU before passing k->val to hci_is_blocked_key(). The helper's own RCU section protects the blocked-key list, but the selected LTK may already have been reclaimed before that section starts.
An LE ATT socket security request can reach smp_ltk_encrypt() without holding hdev->lock. With a matching stored LTK and an LTK-type blocked-key entry present, a concurrent MGMT_OP_LOAD_LONG_TERM_KEYS can remove the selected LTK in the following order:
Socket security Management / RCU reclamation
hci_find_ltk()
rcu_read_lock()
select k
rcu_read_unlock()
load_long_term_keys()
hci_dev_lock(hdev)
hci_smp_ltks_clear(hdev)
list_del_rcu(&k->list)
kfree_rcu(k, rcu)
grace period ends; k is freed
hci_is_blocked_key(..., k->val)
memcmp(b->val, val, ...)The final comparison reads freed LTK bytes. Entering a new RCU section in hci_is_blocked_key() cannot protect a pointer obtained before the completed grace period.
Keep the finder's RCU read-side section active through the blocked-key comparison and the warning that reads k->bdaddr. Release it before returning on either matched-key path. This delays reclamation until the finder has finished using the selected record, following the existing IRK lookup pattern.
KFENCE report as below:
==================================================================
BUG: KFENCE: use-after-free read in hci_is_blocked_key+0xdf/0x240
Use-after-free read at 0x00000000b9ee38e4 (in kfence-#249):
hci_is_blocked_key+0xdf/0x240
blocked_key_wrapper+0xc5/0x140 [pmbd_ltk_probe]
hci_find_ltk+0x1aa/0x3e0
smp_ltk_encrypt.isra.0+0xad/0x340
smp_conn_security+0x3b8/0x8c0
l2cap_sock_setsockopt+0x1c4b/0x2270
do_sock_setsockopt+0x1fb/0x430
__sys_setsockopt+0x106/0x180
__x64_sys_setsockopt+0xc2/0x160
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
kfence-#249: 0x00000000121f2ad9-0x000000005b5bfb3d, size=72, cache=kmalloc-96
allocated by task 495 on cpu 0 at 36.722380s (2.603973s ago):
hci_add_ltk+0x1f5/0x3a0
load_long_term_keys+0x6d0/0x860
hci_sock_sendmsg+0x128b/0x22e0
__sys_sendto+0x425/0x470
__x64_sys_sendto+0xe5/0x1c0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
freed by task 533 on cpu 0 at 36.993097s (2.339769s ago):
__rcu_free_sheaf_prepare+0x261/0x2a0
rcu_free_sheaf+0x1f/0xe0
rcu_core+0x661/0x1d10
handle_softirqs+0x201/0x930
__irq_exit_rcu+0x110/0x1e0
irq_exit_rcu+0xe/0x20
sysvec_apic_timer_interrupt+0x6c/0x80
asm_sysvec_apic_timer_interrupt+0x1a/0x20
srso_alias_return_thunk+0x0/0xfbef5
__asan_memcpy+0x23/0x60
create_monitor_ctrl_event+0x1a2/0x460
mgmt_cmd_complete+0x2da/0x580
load_long_term_keys+0x741/0x860
hci_sock_sendmsg+0x128b/0x22e0
__sys_sendto+0x425/0x470
__x64_sys_sendto+0xe5/0x1c0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
CPU: 1 UID: 0 PID: 495 Comm: python3 Tainted: G O 7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Tainted: [O]=OOT_MODULE
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
==================================================================--- net/bluetooth/hci_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/bluetooth/hci_core.c +2 -2
@@ -2378,16 +2378,16 @@ struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,continue ;if (smp_ltk_is_sc (k) ||ltk_role (k->type) == role) { -rcu_read_unlock (); -if (hci_is_blocked_key (hdev,HCI_BLOCKED_KEY_TYPE_LTK , k->val)) {bt_dev_warn_ratelimited (hdev,"LTK blocked for %pMR" , &k->bdaddr); +rcu_read_unlock ();return NULL ; } +rcu_read_unlock ();return k; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1652/1848 Bluetooth: 6lowpan: Drain RCU readers on registration failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit ebba800d140b580540ad55f670d943e4a7edaffd ]
A lowpan_btle_dev is embedded in its net_device allocation and must remain alive until readers of bt_6lowpan_devices have left their RCU sections. setup_netdev() publishes it before registration, but its error path only unlinks it before calling free_netdev().
If a second controller's registration fails while multicast is sent on an existing 6LoWPAN interface, send_mcast_pkt() can already have selected the new entry. It reads entry->netdev before checking which interface owns it. An early failure, such as allocating the device's name node, leaves NETREG_UNINITIALIZED, so free_netdev() releases the storage immediately.
The following ordering frees the selected entry before the reader loads its netdev field:
Adapter creation (controller B) Multicast on controller A
setup_netdev()
list_add_rcu()
rcu_read_lock()
select B's entry
lowpan_register_netdev() fails
list_del_rcu()
free_netdev()
read entry->netdev
rcu_read_unlock()Removing the list node does not wait for that reader, and devices_lock does not serialize the multicast reader. The subsequent field load is a use-after-free, reported by KASAN in bt_xmit().
Wait for an RCU grace period after dropping devices_lock and before free_netdev(). This keeps the failed adapter allocated until traversals that could have selected it complete. The callback is already sleepable, and the wait happens outside the list spinlock.
KASAN report as below:
==================================================================
BUG: KASAN: slab-use-after-free in bt_xmit+0x1d06/0x21e0
Read of size 8 at addr ffff88810ef45030 by task python3/556
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? bt_xmit+0x1d06/0x21e0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? bt_xmit+0x1d06/0x21e0
kasan_report+0xe0/0x110
? bt_xmit+0x1d06/0x21e0
bt_xmit+0x1d06/0x21e0
? __pfx_bt_xmit+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? lock_acquire+0x17b/0x2f0
? srso_alias_return_thunk+0x5/0xfbef5
? lock_is_held_type+0x8f/0x100
? dev_hard_start_xmit+0x187/0x660
? __pfx_bt_xmit+0x10/0x10
dev_hard_start_xmit+0x187/0x660
sch_direct_xmit+0x153/0x850
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_sch_direct_xmit+0x10/0x10
? do_raw_spin_lock+0x130/0x270
? __pfx_do_raw_spin_lock+0x10/0x10
? lock_is_held_type+0x8f/0x100
__dev_queue_xmit+0x3111/0x3aa0
? srso_alias_return_thunk+0x5/0xfbef5
? look_up_lock_class+0x59/0x130
? register_lock_class+0x41/0x790
? __pfx___dev_queue_xmit+0x10/0x10
? __lock_acquire+0x466/0x2260
? find_held_lock+0x2b/0x80
? ___neigh_create+0x1690/0x2540
? __local_bh_enable_ip+0xa6/0x120
? srso_alias_return_thunk+0x5/0xfbef5
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? lock_acquire+0x17b/0x2f0
? srso_alias_return_thunk+0x5/0xfbef5
? find_held_lock+0x2b/0x80
? ip6_finish_output2+0x8be/0x1840
? srso_alias_return_thunk+0x5/0xfbef5
? neigh_connected_output+0x39f/0x4e0
? srso_alias_return_thunk+0x5/0xfbef5
neigh_connected_output+0x33f/0x4e0
ip6_finish_output2+0x8be/0x1840
ip6_finish_output+0x424/0xd50
ip6_output+0x210/0x640
? __pfx_ip6_mr_output+0x10/0x10
ip6_local_out+0x193/0x1c0
ip6_send_skb+0xfb/0x3e0
udp_v6_send_skb+0x6e1/0x1180
udpv6_sendmsg+0x1f9b/0x2a00
? get_random_u32+0xaf/0x640
? __pfx_udpv6_sendmsg+0x10/0x10
? lock_release+0xc8/0x280
? srso_alias_return_thunk+0x5/0xfbef5
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? trace_hardirqs_on+0x18/0x160
? srso_alias_return_thunk+0x5/0xfbef5
? __local_bh_enable_ip+0xa6/0x120
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_udpv6_sendmsg+0x10/0x10
? inet6_sendmsg+0xff/0x140
inet6_sendmsg+0xff/0x140
__sys_sendto+0x320/0x470
? __pfx___sys_sendto+0x10/0x10
? exc_page_fault+0x5c/0xc0
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x280
? handle_mm_fault+0x12e/0x580
__x64_sys_sendto+0xe5/0x1c0
? lockdep_hardirqs_on_prepare+0xea/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
? trace_hardirqs_on+0x18/0x160
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Allocated by task 502:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kvmalloc_node_noprof+0x353/0x930
alloc_netdev_mqs+0xa0/0x1250
chan_ready_cb+0x198/0x1110
l2cap_recv_frame+0x6dc0/0x8830
l2cap_recv_acldata+0xe9f/0x10e0
hci_rx_work+0x5a6/0xf00
process_one_work+0x908/0x19c0
worker_thread+0x65c/0xe40
kthread+0x34f/0x460
ret_from_fork+0x659/0x940
ret_from_fork_asm+0x1a/0x30
Freed by task 502:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
free_netdev+0x6ca/0x8f0
chan_ready_cb+0xd91/0x1110
l2cap_recv_frame+0x6dc0/0x8830
l2cap_recv_acldata+0xe9f/0x10e0
hci_rx_work+0x5a6/0xf00
process_one_work+0x908/0x19c0
worker_thread+0x65c/0xe40
kthread+0x34f/0x460
ret_from_fork+0x659/0x940
ret_from_fork_asm+0x1a/0x30
The buggy address belongs to the object at ffff88810ef44000
which
belongs to the cache kmalloc-8k of size
8192
The buggy address is located 4144 bytes inside of
freed
8192-byte region [ffff88810ef44000,
ffff88810ef46000)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0
pfn:0x10ef40
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000000040(head|node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000040 ffff888100043180 dead000000000100
dead000000000122
raw: 0000000000000000 0000000000020002 00000000f5000000
0000000000000000
head: 0200000000000040 ffff888100043180 dead000000000100
dead000000000122
head: 0000000000000000 0000000000020002 00000000f5000000
0000000000000000
head: 0200000000000003 fffffffffffffe01 00000000ffffffff
00000000ffffffff
head: ffff88810ef41a80 0000000000000000 00000000ffffffff
0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88810ef44f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88810ef44f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88810ef45000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88810ef45080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88810ef45100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Disabling lock debugging due to kernel taint--- net/bluetooth/6lowpan.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/6lowpan.c +1 -0
@@ -733,6 +733,7 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_btle_dev **dev)spin_lock (&devices_lock);list_del_rcu (&(*dev)->list);spin_unlock (&devices_lock); +synchronize_rcu ();free_netdev (netdev); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1653/1848 net: stmmac: selftests: use skb_share_check() in the loopback receive hook
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit a7a89019bac0e8810bde7f1419f4adf9adc23d41 ]
The loopback hook gets a shared skb when another ETH_P_IP handler is bound to the device. skb_unshare() does not unshare it, so skb_linearize() on a non-linear frame hits BUG_ON(skb_shared()).
Use skb_share_check() instead.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1 -1
@@ -262,7 +262,7 @@ static int stmmac_test_loopback_validate(struct sk_buff *skb,struct tcphdr *thdr;struct iphdr *ihdr; - skb =skb_unshare (skb,GFP_ATOMIC ); + skb =skb_share_check (skb,GFP_ATOMIC );if (!skb) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1654/1848 net/mlx5e: use skb_share_check() in the loopback selftest hook
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit 16fb7aa6955a0af9f67ca42a61d9be58dfc9382a ]
The loopback hook gets a shared skb when another ETH_P_IP handler is bound to the device. skb_linearize() on a non-linear frame then hits BUG_ON(skb_shared()).
Call skb_share_check() before linearizing the skb.
--- drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c +4 -0
@@ -188,6 +188,10 @@ mlx5e_test_loopback_validate(struct sk_buff *skb,struct udphdr *udph;struct iphdr *iph; + skb =skb_share_check (skb,GFP_ATOMIC ); +if (!skb) + goto out; +if (skb_linearize (skb)) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1655/1848 scsi: libsas: Fix out-of-bounds memcpy() in sas_ssp_task_response()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xingui Yang <[email protected]>
[ Upstream commit 4d7f9c3fdce773f6c69d17c1d4a05bd5e17f4b99 ]
The min_t(int, ...) clamp of the device-provided sense_data_len turns negative for values >= 0x80000000 and is then used as the memcpy() length, reading and writing out of bounds. Compare as u32 instead. Well-formed responses are unaffected.
--- drivers/scsi/libsas/sas_task.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libsas/sas_task.c +1 -1
@@ -22,7 +22,7 @@ void sas_ssp_task_response(struct device *dev, struct sas_task *task,else if (iu->datapres ==2 ) { tstat->stat =SAS_SAM_STAT_CHECK_CONDITION ; tstat->buf_valid_size = -min_t (int,SAS_STATUS_BUF_SIZE , +min_t (u32,SAS_STATUS_BUF_SIZE ,be32_to_cpu (iu->sense_data_len));memcpy (tstat->buf, iu->sense_data, tstat->buf_valid_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1656/1848 dt-bindings: vendor-prefixes: add Ambarella
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Zhao <[email protected]>
[ Upstream commit 5ef299ffb56531b3a4f2b311000da76beed403ee ]
Document the Ambarella, Inc. vendor prefix so Ambarella DT bindings can be applied without waiting for the SoC series.
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -73,6 +73,8 @@ patternProperties: description: Amarula Solutions "^amazon,.*": description: Amazon.com, Inc. + "^ambarella,.*": + description: Ambarella, Inc. "^amcc,.*": description: Applied Micro Circuits Corporation (APM, formally AMCC) "^amd,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1657/1848 ata: libahci: re-enable FBS after error handling on a port multiplier
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyrylo Biryuk <[email protected]>
[ Upstream commit 23eab9e877497397a0e2394ee9174d576816209e ]
ahci_do_softreset() disables FBS before resetting a device behind a port multiplier, as required by AHCI 1.2 section 9.3.9, and re-enables it only when that softreset succeeds. If it fails, for example because a hot-plugged drive is still spinning up ("softreset failed (device not ready)"), EH escalates to a hardreset of the PMP link, and nothing turns FBS back on: only ahci_pmp_attach() does, which runs at the next boot. The port keeps working with command-based switching until then.
Seen on a Marvell 88SE9235 (1b4b:9235) with Marvell 88SM9705 port multipliers (1b4b:9705, in a Synology DX1222 expansion unit): after hot-plugging a drive, the kernel logged "FBS is disabled" followed by "softreset failed (device not ready)" and a PMP hardreset, and never "FBS is enabled" again (twice, on two different ports).
At the end of ahci_error_handler(), re-enable FBS if a PMP is still attached and FBS is supported but disabled.
--- drivers/ata/libahci.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/ata/libahci.c +15 -0
@@ -2095,6 +2095,21 @@ void ahci_error_handler(struct ata_port *ap)sata_pmp_error_handler (ap); +/* +* ahci_do_softreset() turns FBS off before resetting a fan-out link +* and turns it back on only if that reset succeeds. When it fails +* (e.g. a hot-plugged drive is still spinning up), EH escalates to a +* PMP hardreset, which never re-enables FBS, so the port would keep +* command-based switching until the PMP is attached again (reboot). +* Restore FBS once recovery is done and the PMP is still attached. +*/ +if (sata_pmp_attached (ap) &&ata_dev_enabled (ap->link.device)) { +struct ahci_port_priv *pp = ap->private_data; + +if (pp->fbs_supported && !pp->fbs_enabled) +ahci_enable_fbs (ap); + } +if (!ata_dev_enabled (ap->link.device)) hpriv->stop_engine (ap); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1658/1848 net: axienet: Clean up device used for DMA calls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Hancock <[email protected]>
[ Upstream commit 17882fd4256721451457ee57532bbae0cd5cacfe ]
Instead of using lp->ndev.parent to find the correct device to use for DMA API calls, just use the dev attribute in the device structure.
Stable-dep-of: 0c20cb4cfb40 ("net: axienet: free outstanding TX buffers in axienet_dma_bd_release()")
--- .../net/ethernet/xilinx/xilinx_axienet_main.c | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +16 -16
@@ -190,7 +190,7 @@ static void axienet_dma_bd_release(struct net_device *ndev)struct axienet_local *lp =netdev_priv (ndev);/* If we end up here, tx_bd_v must have been DMA allocated. */ -dma_free_coherent (ndev->dev.parent, +dma_free_coherent (lp->dev,sizeof (*lp->tx_bd_v) * lp->tx_bd_num, lp->tx_bd_v, lp->tx_bd_p);
@@ -215,12 +215,12 @@ static void axienet_dma_bd_release(struct net_device *ndev)*/ if (lp->rx_bd_v[i].cntrl) { phys =desc_get_phys_addr (lp, &lp->rx_bd_v[i]); -dma_unmap_single (ndev->dev.parent, phys, +dma_unmap_single (lp->dev, phys, lp->max_frm_size,DMA_FROM_DEVICE ); } } -dma_free_coherent (ndev->dev.parent, +dma_free_coherent (lp->dev,sizeof (*lp->rx_bd_v) * lp->rx_bd_num, lp->rx_bd_v, lp->rx_bd_p);
@@ -249,13 +249,13 @@ static int axienet_dma_bd_init(struct net_device *ndev) lp->rx_bd_ci =0 ;/* Allocate the Tx and Rx buffer descriptors. */ - lp->tx_bd_v =dma_alloc_coherent (ndev->dev.parent, + lp->tx_bd_v =dma_alloc_coherent (lp->dev,sizeof (*lp->tx_bd_v) * lp->tx_bd_num, &lp->tx_bd_p,GFP_KERNEL );if (!lp->tx_bd_v)return -ENOMEM ; - lp->rx_bd_v =dma_alloc_coherent (ndev->dev.parent, + lp->rx_bd_v =dma_alloc_coherent (lp->dev,sizeof (*lp->rx_bd_v) * lp->rx_bd_num, &lp->rx_bd_p,GFP_KERNEL );if (!lp->rx_bd_v)
@@ -285,9 +285,9 @@ static int axienet_dma_bd_init(struct net_device *ndev) goto out; lp->rx_bd_v[i].skb = skb; - addr =dma_map_single (ndev->dev.parent, skb->data, + addr =dma_map_single (lp->dev, skb->data, lp->max_frm_size,DMA_FROM_DEVICE ); -if (dma_mapping_error (ndev->dev.parent, addr)) { +if (dma_mapping_error (lp->dev, addr)) {netdev_err (ndev,"DMA mapping error\n" ); goto out; }
@@ -637,7 +637,7 @@ static int axienet_free_tx_chain(struct net_device *ndev, u32 first_bd,/* Ensure we see complete descriptor update */ dma_rmb (); phys =desc_get_phys_addr (lp, cur_p); -dma_unmap_single (ndev->dev.parent, phys, +dma_unmap_single (lp->dev, phys, (cur_p->cntrl &XAXIDMA_BD_CTRL_LENGTH_MASK ),DMA_TO_DEVICE );
@@ -775,9 +775,9 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev) cur_p->app0 |=2 ;/* Tx Full Checksum Offload Enabled */ } - phys =dma_map_single (ndev->dev.parent, skb->data, + phys =dma_map_single (lp->dev, skb->data,skb_headlen (skb),DMA_TO_DEVICE ); -if (unlikely (dma_mapping_error (ndev->dev.parent, phys))) { +if (unlikely (dma_mapping_error (lp->dev, phys))) {if (net_ratelimit ())netdev_err (ndev,"TX DMA mapping error\n" ); ndev->stats.tx_dropped++;
@@ -791,11 +791,11 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev) lp->tx_bd_tail =0 ; cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; frag = &skb_shinfo (skb)->frags[ii]; - phys =dma_map_single (ndev->dev.parent, + phys =dma_map_single (lp->dev,skb_frag_address (frag),skb_frag_size (frag),DMA_TO_DEVICE ); -if (unlikely (dma_mapping_error (ndev->dev.parent, phys))) { +if (unlikely (dma_mapping_error (lp->dev, phys))) {if (net_ratelimit ())netdev_err (ndev,"TX DMA mapping error\n" ); ndev->stats.tx_dropped++;
@@ -873,7 +873,7 @@ static void axienet_recv(struct net_device *ndev) length = cur_p->app4 &0x0000FFFF ; phys =desc_get_phys_addr (lp, cur_p); -dma_unmap_single (ndev->dev.parent, phys, lp->max_frm_size, +dma_unmap_single (lp->dev, phys, lp->max_frm_size,DMA_FROM_DEVICE );skb_put (skb, length);
@@ -906,10 +906,10 @@ static void axienet_recv(struct net_device *ndev)if (!new_skb)break ; - phys =dma_map_single (ndev->dev.parent, new_skb->data, + phys =dma_map_single (lp->dev, new_skb->data, lp->max_frm_size,DMA_FROM_DEVICE ); -if (unlikely (dma_mapping_error (ndev->dev.parent, phys))) { +if (unlikely (dma_mapping_error (lp->dev, phys))) {if (net_ratelimit ())netdev_err (ndev,"RX DMA mapping error\n" );dev_kfree_skb (new_skb);
@@ -1727,7 +1727,7 @@ static void axienet_dma_err_handler(struct work_struct *work)if (cur_p->cntrl) {dma_addr_t addr =desc_get_phys_addr (lp, cur_p); -dma_unmap_single (ndev->dev.parent, addr, +dma_unmap_single (lp->dev, addr, (cur_p->cntrl &XAXIDMA_BD_CTRL_LENGTH_MASK ),DMA_TO_DEVICE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1659/1848 net: axienet: free outstanding TX buffers in axienet_dma_bd_release()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Maimon <[email protected]>
[ Upstream commit 0c20cb4cfb40cf270d6c4c2c2ff5e5d72322644a ]
axienet_dma_bd_release() walks the RX ring to unmap and free every receive buffer before releasing it, but frees the TX descriptor ring with dma_free_coherent() alone. Any descriptor that axienet_free_tx_chain() had not yet reclaimed still holds its skb and its streaming DMA mapping, and both are lost.
axienet_stop() disables TX NAPI and stops the DMA engine before calling it, so nothing reclaims those descriptors afterwards. Bringing the interface down while frames are in flight therefore leaks up to lp->tx_bd_num skbs and mappings each time.
axienet_dma_err_handler() already walks the TX ring this way before it restarts the DMA engine: it unmaps every descriptor whose cntrl is still set - axienet_free_tx_chain() clears it on reclaim - frees any skb still attached, and clears the descriptor. Move that loop into a helper, axienet_free_tx_bufs(), and call it from axienet_dma_bd_release() too. This relies on axienet_stop() having stopped the DMA engine first, as the RX walk in the same function already does. The helper frees the skbs with dev_kfree_skb_any(), as drops: in the error handler, which runs from a workqueue, that frees them directly rather than deferring them to softirq as dev_kfree_skb_irq() did.
The walk must not run on a ring that is not there. axienet_open() does not check the result of the reset that runs axienet_dma_bd_init(), so when that reset fails tx_bd_v is either still NULL or, after an earlier close, points at the ring that close freed. Clear tx_bd_v and rx_bd_v once their rings are freed, and skip the walk when tx_bd_v is NULL. That also ends the second dma_free_coherent() of a stale ring which the same path already did. On the axienet_dma_bd_init() error path the TX ring has just been allocated zeroed, so the walk does nothing.
This was reported by the Sashiko AI review bot.
Tested on the AXI Ethernet MAC of an ADVA TimeCard X2 (PCIe card, with the built-in AXI DMA): traffic passes, and after each of ten down/up cycles and five module reloads, all made with traffic running and each running axienet_dma_bd_release(), traffic resumes and nothing is logged. The leak itself was not measured, and neither the failed-reset paths nor axienet_dma_err_handler() were exercised.
--- .../net/ethernet/xilinx/xilinx_axienet_main.c | 74 +++++++++++++------ 1 file changed, 50 insertions(+), 24 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +50 -24
@@ -176,6 +176,46 @@ static dma_addr_t desc_get_phys_addr(struct axienet_local *lp,return ret; } +/** +* axienet_free_tx_bufs - Release the buffers still held by the TX ring +* @lp: Pointer to the axienet_local structure +* +* Unmap every descriptor whose mapping is still live, free any skb still +* attached, and clear the descriptor for reuse. axienet_free_tx_chain() +* clears cntrl when it reclaims a descriptor, so a non-zero value means +* the mapping is live. The DMA engine must be stopped. +*/ +static void axienet_free_tx_bufs (struct axienet_local *lp) +{ +struct axidma_bd *cur_p; +u32 i; + +for (i =0 ; i < lp->tx_bd_num; i++) { + cur_p = &lp->tx_bd_v[i]; +if (cur_p->cntrl) { +dma_addr_t addr =desc_get_phys_addr (lp, cur_p); + +dma_unmap_single (lp->dev, addr, + (cur_p->cntrl & +XAXIDMA_BD_CTRL_LENGTH_MASK ), +DMA_TO_DEVICE ); + } +/* not reclaimed by axienet_free_tx_chain(), so a drop */ +if (cur_p->skb) +dev_kfree_skb_any (cur_p->skb); + cur_p->phys =0 ; + cur_p->phys_msb =0 ; + cur_p->cntrl =0 ; + cur_p->status =0 ; + cur_p->app0 =0 ; + cur_p->app1 =0 ; + cur_p->app2 =0 ; + cur_p->app3 =0 ; + cur_p->app4 =0 ; + cur_p->skb =NULL ; + } +} +/** * axienet_dma_bd_release - Release buffer descriptor rings * @ndev: Pointer to the net_device structure
@@ -189,11 +229,18 @@ static void axienet_dma_bd_release(struct net_device *ndev)int i;struct axienet_local *lp =netdev_priv (ndev); -/* If we end up here, tx_bd_v must have been DMA allocated. */ +/* tx_bd_v is NULL if axienet_dma_bd_init() did not get as far as +* allocating it, and is cleared below once the ring is freed; +* dma_free_coherent() accepts NULL. +*/ +if (lp->tx_bd_v) +axienet_free_tx_bufs (lp); +dma_free_coherent (lp->dev,sizeof (*lp->tx_bd_v) * lp->tx_bd_num, lp->tx_bd_v, lp->tx_bd_p); + lp->tx_bd_v =NULL ;if (!lp->rx_bd_v)return ;
@@ -224,6 +271,7 @@ static void axienet_dma_bd_release(struct net_device *ndev)sizeof (*lp->rx_bd_v) * lp->rx_bd_num, lp->rx_bd_v, lp->rx_bd_p); + lp->rx_bd_v =NULL ; }/**
@@ -1722,29 +1770,7 @@ static void axienet_dma_err_handler(struct work_struct *work)axienet_mdio_enable (lp);mutex_unlock (&lp->mii_bus->mdio_lock); -for (i =0 ; i < lp->tx_bd_num; i++) { - cur_p = &lp->tx_bd_v[i]; -if (cur_p->cntrl) { -dma_addr_t addr =desc_get_phys_addr (lp, cur_p); - -dma_unmap_single (lp->dev, addr, - (cur_p->cntrl & -XAXIDMA_BD_CTRL_LENGTH_MASK ), -DMA_TO_DEVICE ); - } -if (cur_p->skb) -dev_kfree_skb_irq (cur_p->skb); - cur_p->phys =0 ; - cur_p->phys_msb =0 ; - cur_p->cntrl =0 ; - cur_p->status =0 ; - cur_p->app0 =0 ; - cur_p->app1 =0 ; - cur_p->app2 =0 ; - cur_p->app3 =0 ; - cur_p->app4 =0 ; - cur_p->skb =NULL ; - } +axienet_free_tx_bufs (lp);for (i =0 ; i < lp->rx_bd_num; i++) { cur_p = &lp->rx_bd_v[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1660/1848 IB/IPoIB: Cancel normal flush work on device stop
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carolina Jubran <[email protected]>
[ Upstream commit 66196a559be5963b1ced18418c876caf9bfb76e6 ]
ipoib_ib_dev_flush_normal() can race with ipoib_stop() because the normal flush work does not run under RTNL.
Before commit a77a57a1a22a ("IPoIB: Fix deadlock on RTNL in ipoib_stop()"), ipoib_stop() flushed ipoib_workqueue after clearing IPOIB_FLAG_ADMIN_UP and before calling ipoib_ib_dev_down(). This ensured that any in-flight flush work completed before ipoib_ib_dev_down() performed the final clear of IPOIB_FLAG_OPER_UP.
After that commit removed the workqueue flush to avoid a deadlock with workqueue tasks taking RTNL, a normal flush can continue running concurrently with ipoib_stop() after IPOIB_FLAG_ADMIN_UP has been cleared.
The flush may observe IPOIB_FLAG_ADMIN_UP set and continue running while ipoib_stop() clears IPOIB_FLAG_ADMIN_UP and brings the device down. The flush can then call ipoib_ib_dev_up() and set IPOIB_FLAG_OPER_UP again after the device has already been stopped:
flush_normal (ipoib_workqueue) ipoib_stop() (RTNL held)
------------------------------ ------------------------
test_bit(ADMIN_UP) == 1
clear_bit(ADMIN_UP)
ipoib_ib_dev_down()
clear_bit(OPER_UP) ipoib_ib_dev_up()
set_bit(OPER_UP)
This leaves the interface with ADMIN_UP clear and OPER_UP set. During device removal, ipoib_ndo_uninit() waits in destroy_workqueue() while holding RTNL, while ipoib_mcast_carrier_on_task() may keep retrying rtnl_trylock() as long as OPER_UP remains set, resulting in a deadlock.
Cancel the normal flush work from ipoib_stop() after clearing IPOIB_FLAG_ADMIN_UP and before bringing the device down. A pending normal flush is canceled, while an already running flush is allowed to finish before ipoib_ib_dev_down() performs the final transition to OPER_UP clear.
Only the normal flush needs this synchronization. The heavy flush is already serialized with ipoib_stop() by RTNL, while the light flush does not bring the device back up and therefore cannot recreate this race.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_main.c +7 -0
@@ -186,6 +186,13 @@ static int ipoib_stop(struct net_device *dev)clear_bit (IPOIB_FLAG_ADMIN_UP , &priv->flags); +/* Normal flush runs without RTNL and may bring the device back +* up. Cancel it before the device down transition. +* Heavy flush is already serialized by RTNL and must not be +* waited on here while RTNL is held. +*/ +cancel_work_sync (&priv->flush_normal); +netif_stop_queue (dev);ipoib_ib_dev_down (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1661/1848 irqchip/gic-v3-its: Clear vpt_page after freeing the pending table
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 0d604b1e4617d18dbb5573290ba447d7369251d1 ]
its_vpe_teardown() frees vpt_page without clearing it, so its vpt_page == NULL guard only holds the first time it runs on a vPE. struct its_vpe outlives a failed KVM_DEV_ARM_VGIC_CTRL_INIT, so a retry that fails again frees the pending table and the vPE ID a second time.
--- drivers/irqchip/irq-gic-v3-its.c | 1 + 1 file changed, 1 insertion(+)
drivers/irqchip/irq-gic-v3-its.c +1 -0
@@ -4455,6 +4455,7 @@ static void its_vpe_teardown(struct its_vpe *vpe)its_vpe_db_proxy_unmap (vpe);its_vpe_id_free (vpe->vpe_id);its_free_pending_table (vpe->vpt_page); + vpe->vpt_page =NULL ; } static void its_vpe_irq_domain_free(struct irq_domain *domain,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1662/1848 irqchip/gic-v3-its: Give the percpu rdist struct its own flags field
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Valentin Schneider <[email protected]>
[ Upstream commit c0cdc89072a3e1ae3981437f385de14b7bba8fd8 ]
Later patches will require tracking some per-rdist status. Reuse the bytes "lost" to padding within the __percpu rdist struct as a flags field, and re-encode ->lpi_enabled within said flags.
No change in functionality intended.
Stable-dep-of: 32e056cc1d15 ("irqchip/gic-v3-its: Don't free a vPE table shared with another ITS")
--- drivers/irqchip/irq-gic-v3-its.c | 8 +++++--- include/linux/irqchip/arm-gic-v3.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +5 -3
@@ -46,6 +46,8 @@#define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING (1 << 0)#define RDIST_FLAGS_RD_TABLES_PREALLOCATED (1 << 1) +#define RD_LOCAL_LPI_ENABLED BIT(0) +static u32 lpi_id_bits;/*
@@ -3071,7 +3073,7 @@ static void its_cpu_init_lpis(void)phys_addr_t paddr;u64 val, tmp; -if (gic_data_rdist ()->lpi_enabled) +if (gic_data_rdist ()->flags &RD_LOCAL_LPI_ENABLED )return ; val =readl_relaxed (rbase +GICR_CTLR );
@@ -3185,7 +3187,7 @@ static void its_cpu_init_lpis(void)/* Make sure the GIC has seen the above */ dsb (sy); out: -gic_data_rdist ()->lpi_enabled = true; +gic_data_rdist ()->flags |=RD_LOCAL_LPI_ENABLED ; pr_info("GICv3: CPU%d: using %s LPI pending table @%pa\n", smp_processor_id(), gic_data_rdist()->pend_page ? "allocated" : "reserved",
@@ -5162,7 +5164,7 @@ static int redist_disable_lpis(void)* * If running with preallocated tables, there is nothing to do. */ -if (gic_data_rdist ()->lpi_enabled || +if ((gic_data_rdist ()->flags &RD_LOCAL_LPI_ENABLED ) || (gic_rdists->flags &RDIST_FLAGS_RD_TABLES_PREALLOCATED ))return 0 ;
include/linux/irqchip/arm-gic-v3.h +1 -1
@@ -672,7 +672,7 @@ struct rdists {void __iomem *rd_base;struct page *pend_page;phys_addr_t phys_base; -bool lpi_enabled; +u64 flags;cpumask_t *vpe_table_mask;void *vpe_l1_base; }__percpu *rdist;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1663/1848 irqchip/gic-v3-its: Postpone LPI pending table freeing and memreserve
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Valentin Schneider <[email protected]>
[ Upstream commit d23bc2bc1d634658d7fa96395419c1c553a784f0 ]
Memory used by the LPI tables have to be made persistent for kexec to have a chance to work, as explained in [1]. If they have been made persistent and we are booting into a kexec'd kernel, we also need to free the pages that were preemptively allocated by the new kernel for those tables.
Both of those operations currently happen during its_cpu_init(), which happens in a _STARTING (IOW atomic) cpuhp callback for secondary CPUs. efi_mem_reserve_iomem() issues a GFP_ATOMIC allocation, which unfortunately doesn't work under PREEMPT_RT (this ends up grabbing a non-raw spinlock, which can sleep under PREEMPT_RT). Similarly, freeing the pages ends up grabbing a sleepable spinlock.
Since the memreserve is only required by kexec, it doesn't have to be done so early in the secondary boot process. Issue the reservation in a new CPUHP_AP_ONLINE_DYN cpuhp callback, and piggy-back the page freeing on top of it. A CPU gets to run the body of this new callback exactly once.
As kexec issues a machine_shutdown() prior to machine_kexec(), it will be serialized vs a CPU being plugged to life by the hotplug machinery - either the CPU will have been brought up and have had its redistributor's pending table memreserved, or it never went online and will have its table allocated by the new kernel.
[1]: https://lore.kernel.org/lkml/[email protected]/
Stable-dep-of: 32e056cc1d15 ("irqchip/gic-v3-its: Don't free a vPE table shared with another ITS")
--- drivers/irqchip/irq-gic-v3-its.c | 58 +++++++++++++++++++++++++++--- drivers/irqchip/irq-gic-v3.c | 1 + include/linux/irqchip/arm-gic-v3.h | 1 + 3 files changed, 56 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +54 -4
@@ -47,6 +47,8 @@#define RDIST_FLAGS_RD_TABLES_PREALLOCATED (1 << 1)#define RD_LOCAL_LPI_ENABLED BIT(0) +#define RD_LOCAL_PENDTABLE_PREALLOCATED BIT(1) +#define RD_LOCAL_MEMRESERVE_DONE BIT(2)static u32 lpi_id_bits;
@@ -3092,15 +3094,13 @@ static void its_cpu_init_lpis(void) paddr &=GENMASK_ULL (51 ,16 );WARN_ON (!gic_check_reserved_range (paddr,LPI_PENDBASE_SZ )); -its_free_pending_table (gic_data_rdist ()->pend_page); -gic_data_rdist ()->pend_page =NULL ; +gic_data_rdist ()->flags |=RD_LOCAL_PENDTABLE_PREALLOCATED ; goto out; } pend_page =gic_data_rdist ()->pend_page; paddr =page_to_phys (pend_page); -WARN_ON (gic_reserve_range (paddr,LPI_PENDBASE_SZ ));/* set PROPBASE */ val = (gic_rdists->prop_table_pa |
@@ -3190,7 +3190,8 @@ static void its_cpu_init_lpis(void)gic_data_rdist ()->flags |=RD_LOCAL_LPI_ENABLED ;pr_info ("GICv3: CPU%d: using %s LPI pending table @%pa\n" ,smp_processor_id (), -gic_data_rdist ()->pend_page ?"allocated" :"reserved" , +gic_data_rdist ()->flags &RD_LOCAL_PENDTABLE_PREALLOCATED ? +"reserved" :"allocated" , &paddr); }
@@ -5226,6 +5227,38 @@ int its_cpu_init(void)return 0 ; } +static int its_cpu_memreserve_lpi (unsigned int cpu) +{ +struct page *pend_page; +int ret =0 ; + +/* This gets to run exactly once per CPU */ +if (gic_data_rdist ()->flags &RD_LOCAL_MEMRESERVE_DONE ) +return 0 ; + + pend_page =gic_data_rdist ()->pend_page; +if (WARN_ON (!pend_page)) { + ret = -ENOMEM ; + goto out; + } +/* +* If the pending table was pre-programmed, free the memory we +* preemptively allocated. Otherwise, reserve that memory for +* later kexecs. +*/ +if (gic_data_rdist ()->flags &RD_LOCAL_PENDTABLE_PREALLOCATED ) { +its_free_pending_table (pend_page); +gic_data_rdist ()->pend_page =NULL ; + }else { +phys_addr_t paddr =page_to_phys (pend_page); +WARN_ON (gic_reserve_range (paddr,LPI_PENDBASE_SZ )); + } + +out: +gic_data_rdist ()->flags |=RD_LOCAL_MEMRESERVE_DONE ; +return ret; +} +static const struct of_device_id its_device_id[] = { { .compatible ="arm,gic-v3-its" , }, {},
@@ -5411,6 +5444,23 @@ static void __init its_acpi_probe(void)static void __init its_acpi_probe (void ) { }#endif +int __init its_lpi_memreserve_init (void ) +{ +int state; + +if (!efi_enabled (EFI_CONFIG_TABLES )) +return 0 ; + + state =cpuhp_setup_state (CPUHP_AP_ONLINE_DYN , +"irqchip/arm/gicv3/memreserve:online" , + its_cpu_memreserve_lpi, +NULL ); +if (state <0 ) +return state; + +return 0 ; +} +int __init its_init (struct fwnode_handle *handle,struct rdists *rdists,struct irq_domain *parent_domain) {
drivers/irqchip/irq-gic-v3.c +1 -0
@@ -1818,6 +1818,7 @@ static int __init gic_init_bases(void __iomem *dist_base,if (gic_dist_supports_lpis ()) {its_init (handle, &gic_data.rdists, gic_data.domain);its_cpu_init (); +its_lpi_memreserve_init (); }else {if (IS_ENABLED (CONFIG_ARM_GIC_V2M ))gicv2m_init (handle, gic_data.domain);
include/linux/irqchip/arm-gic-v3.h +1 -0
@@ -689,6 +689,7 @@ struct rdists {struct irq_domain ;struct fwnode_handle ; +int __init its_lpi_memreserve_init (void );int its_cpu_init (void );int its_init (struct fwnode_handle *handle,struct rdists *rdists,struct irq_domain *domain);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1664/1848 irqchip/gic-v3-its: Reset each ITSs BASERn register before probe
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit c733ebb7cb67dfb146a07c0ae329a0de9ec52f36 ]
A recent bug report outlined that the way GICv4.1 is handled across kexec is pretty bad. We can end-up in a situation where ITSs share memory (this is the case when SVPET==1) and reprogram the base registers, creating a situation where ITSs that are part of a given affinity group see different pointers. Which is illegal. Boo.
In order to restore some sanity, reset the BASERn registers to 0 *before* probing any ITS. Although this isn't optimised at all, this is only a once-per-boot cost, which shouldn't show up on anyone's radar.
Stable-dep-of: 32e056cc1d15 ("irqchip/gic-v3-its: Don't free a vPE table shared with another ITS")
--- drivers/irqchip/irq-gic-v3-its.c | 120 +++++++++++++++++++++++++------ 1 file changed, 99 insertions(+), 21 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +99 -21
@@ -4876,6 +4876,38 @@ static struct syscore_ops its_syscore_ops = { .resume = its_restore_enable, }; +static void __init __iomem *its_map_one (struct resource *res,int *err) +{ +void __iomem *its_base; +u32 val; + + its_base =ioremap (res->start,SZ_64K ); +if (!its_base) { +pr_warn ("ITS@%pa: Unable to map ITS registers\n" , &res->start); + *err = -ENOMEM ; +return NULL ; + } + + val =readl_relaxed (its_base +GITS_PIDR2 ) &GIC_PIDR2_ARCH_MASK ; +if (val !=0x30 && val !=0x40 ) { +pr_warn ("ITS@%pa: No ITS detected, giving up\n" , &res->start); + *err = -ENODEV ; + goto out_unmap; + } + + *err =its_force_quiescent (its_base); +if (*err) { +pr_warn ("ITS@%pa: Failed to quiesce, giving up\n" , &res->start); + goto out_unmap; + } + +return its_base; + +out_unmap: +iounmap (its_base); +return NULL ; +} +static int its_init_domain (struct fwnode_handle *handle,struct its_node *its) {struct irq_domain *inner_domain;
@@ -4985,29 +5017,14 @@ static int __init its_probe_one(struct resource *res, {struct its_node *its;void __iomem *its_base; -u32 val, ctlr;u64 baser, tmp, typer;struct page *page; +u32 ctlr;int err; - its_base =ioremap (res->start,SZ_64K ); -if (!its_base) { -pr_warn ("ITS@%pa: Unable to map ITS registers\n" , &res->start); -return -ENOMEM ; - } - - val =readl_relaxed (its_base +GITS_PIDR2 ) &GIC_PIDR2_ARCH_MASK ; -if (val !=0x30 && val !=0x40 ) { -pr_warn ("ITS@%pa: No ITS detected, giving up\n" , &res->start); - err = -ENODEV ; - goto out_unmap; - } - - err =its_force_quiescent (its_base); -if (err) { -pr_warn ("ITS@%pa: Failed to quiesce, giving up\n" , &res->start); - goto out_unmap; - } + its_base =its_map_one (res, &err); +if (!its_base) +return err;pr_info ("ITS %pR\n" , res);
@@ -5259,6 +5276,23 @@ static int its_cpu_memreserve_lpi(unsigned int cpu)return ret; } +/* Mark all the BASER registers as invalid before they get reprogrammed */ +static int __init its_reset_one (struct resource *res) +{ +void __iomem *its_base; +int err, i; + + its_base =its_map_one (res, &err); +if (!its_base) +return err; + +for (i =0 ; i <GITS_BASER_NR_REGS ; i++) +gits_write_baser (0 , its_base +GITS_BASER + (i <<3 )); + +iounmap (its_base); +return 0 ; +} +static const struct of_device_id its_device_id[] = { { .compatible ="arm,gic-v3-its" , }, {},
@@ -5269,6 +5303,26 @@ static int __init its_of_probe(struct device_node *node)struct device_node *np;struct resource res; +/* +* Make sure *all* the ITS are reset before we probe any, as +* they may be sharing memory. If any of the ITS fails to +* reset, don't even try to go any further, as this could +* result in something even worse. +*/ +for (np =of_find_matching_node (node, its_device_id); np; + np =of_find_matching_node (np, its_device_id)) { +int err; + +if (!of_device_is_available (np) || + !of_property_read_bool (np,"msi-controller" ) || +of_address_to_resource (np,0 , &res)) +continue ; + + err =its_reset_one (&res); +if (err) +return err; + } +for (np =of_find_matching_node (node, its_device_id); np; np =of_find_matching_node (np, its_device_id)) {if (!of_device_is_available (np))
@@ -5433,11 +5487,35 @@ static int __init gic_acpi_parse_madt_its(union acpi_subtable_headers *header, return err; } +static int __init its_acpi_reset (union acpi_subtable_headers *header, +const unsigned long end) +{ +struct acpi_madt_generic_translator *its_entry; +struct resource res; + + its_entry = (struct acpi_madt_generic_translator *)header; + res = (struct resource ) { + .start = its_entry->base_address, + .end = its_entry->base_address +ACPI_GICV3_ITS_MEM_SIZE -1 , + .flags =IORESOURCE_MEM , + }; + +return its_reset_one (&res); +} +static void __init its_acpi_probe (void ) {acpi_table_parse_srat_its (); -acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_TRANSLATOR , - gic_acpi_parse_madt_its,0 ); +/* +* Make sure *all* the ITS are reset before we probe any, as +* they may be sharing memory. If any of the ITS fails to +* reset, don't even try to go any further, as this could +* result in something even worse. +*/ +if (acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_TRANSLATOR , + its_acpi_reset,0 ) >0 ) +acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_TRANSLATOR , + gic_acpi_parse_madt_its,0 );acpi_its_srat_maps_free (); }#else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1665/1848 irqchip/gic-v3-its: Use irq_domain_create_hierarchy()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 1e46e040decede1723a5b11f0689942134c29d9a ]
Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals.
Note that the domain host_data was first set to the struct its_node during allocation only to immediately be overwritten with the struct msi_domain_info.
Stable-dep-of: 32e056cc1d15 ("irqchip/gic-v3-its: Don't free a vPE table shared with another ITS")
--- drivers/irqchip/irq-gic-v3-its.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +7 -6
@@ -4917,18 +4917,19 @@ static int its_init_domain(struct fwnode_handle *handle, struct its_node *its)if (!info)return -ENOMEM ; - inner_domain =irq_domain_create_tree (handle, &its_domain_ops, its); + info->ops = &its_msi_domain_ops; + info->data = its; + + inner_domain =irq_domain_create_hierarchy (its_parent, + its->msi_domain_flags,0 , + handle, &its_domain_ops, + info);if (!inner_domain) {kfree (info);return -ENOMEM ; } - inner_domain->parent = its_parent;irq_domain_update_bus_token (inner_domain,DOMAIN_BUS_NEXUS ); - inner_domain->flags |= its->msi_domain_flags; - info->ops = &its_msi_domain_ops; - info->data = its; - inner_domain->host_data = info;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1666/1848 irqchip/gic-v3-its: Split allocation from initialisation of its_node
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit 9585a495ac936049dba141e8f9d99159ca06d46a ]
In order to pave the way for more fancy quirk handling without making more of a mess of this terrible driver, split the allocation of the ITS descriptor (its_node) from the actual probing.
This will allow firmware-specific hooks to be added between these two points.
Stable-dep-of: 32e056cc1d15 ("irqchip/gic-v3-its: Don't free a vPE table shared with another ITS")
--- drivers/irqchip/irq-gic-v3-its.c | 149 ++++++++++++++++++------------- 1 file changed, 89 insertions(+), 60 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +89 -60
@@ -4908,7 +4908,7 @@ static void __init __iomem *its_map_one(struct resource *res, int *err)return NULL ; } -static int its_init_domain (struct fwnode_handle *handle,struct its_node *its) +static int its_init_domain (struct its_node *its) {struct irq_domain *inner_domain;struct msi_domain_info *info;
@@ -4922,7 +4922,7 @@ static int its_init_domain(struct fwnode_handle *handle, struct its_node *its) inner_domain =irq_domain_create_hierarchy (its_parent, its->msi_domain_flags,0 , - handle, &its_domain_ops, + its->fwnode_handle, &its_domain_ops, info);if (!inner_domain) {kfree (info);
@@ -4975,8 +4975,7 @@ static int its_init_vpe_domain(void)return 0 ; } -static int __init its_compute_its_list_map (struct resource *res, -void __iomem *its_base) +static int __init its_compute_its_list_map (struct its_node *its) {int its_number;u32 ctlr;
@@ -4990,15 +4989,15 @@ static int __init its_compute_its_list_map(struct resource *res, its_number =find_first_zero_bit (&its_list_map, GICv4_ITS_LIST_MAX);if (its_number >= GICv4_ITS_LIST_MAX) {pr_err ("ITS@%pa: No ITSList entry available!\n" , - &res->start); + &its->phys_base);return -EINVAL ; } - ctlr =readl_relaxed (its_base +GITS_CTLR ); + ctlr =readl_relaxed (its->base +GITS_CTLR ); ctlr &= ~GITS_CTLR_ITS_NUMBER ; ctlr |= its_number <<GITS_CTLR_ITS_NUMBER_SHIFT ; -writel_relaxed (ctlr, its_base +GITS_CTLR ); - ctlr =readl_relaxed (its_base +GITS_CTLR ); +writel_relaxed (ctlr, its->base +GITS_CTLR ); + ctlr =readl_relaxed (its->base +GITS_CTLR );if ((ctlr &GITS_CTLR_ITS_NUMBER ) != (its_number <<GITS_CTLR_ITS_NUMBER_SHIFT )) { its_number = ctlr &GITS_CTLR_ITS_NUMBER ; its_number >>=GITS_CTLR_ITS_NUMBER_SHIFT ;
@@ -5006,75 +5005,50 @@ static int __init its_compute_its_list_map(struct resource *res,if (test_and_set_bit (its_number, &its_list_map)) {pr_err ("ITS@%pa: Duplicate ITSList entry %d\n" , - &res->start, its_number); + &its->phys_base, its_number);return -EINVAL ; }return its_number; } -static int __init its_probe_one (struct resource *res, -struct fwnode_handle *handle,int numa_node) +static int __init its_probe_one (struct its_node *its) { -struct its_node *its; -void __iomem *its_base; -u64 baser, tmp, typer; +u64 baser, tmp;struct page *page;u32 ctlr;int err; - its_base =its_map_one (res, &err); -if (!its_base) -return err; - -pr_info ("ITS %pR\n" , res); - - its =kzalloc (sizeof (*its),GFP_KERNEL ); -if (!its) { - err = -ENOMEM ; - goto out_unmap; - } - -raw_spin_lock_init (&its->lock); -mutex_init (&its->dev_alloc_lock); -INIT_LIST_HEAD (&its->entry); -INIT_LIST_HEAD (&its->its_device_list); - typer =gic_read_typer (its_base +GITS_TYPER ); - its->typer = typer; - its->base = its_base; - its->phys_base = res->start;if (is_v4 (its)) { -if (!(typer &GITS_TYPER_VMOVP )) { - err =its_compute_its_list_map (res, its_base); +if (!(its->typer &GITS_TYPER_VMOVP )) { + err =its_compute_its_list_map (its);if (err <0 ) - goto out_free_its; + goto out; its->list_nr = err;pr_info ("ITS@%pa: Using ITS number %d\n" , - &res->start, err); + &its->phys_base, err); }else { -pr_info ("ITS@%pa: Single VMOVP capable\n" , &res->start); +pr_info ("ITS@%pa: Single VMOVP capable\n" , &its->phys_base); }if (is_v4_1 (its)) { -u32 svpet =FIELD_GET (GITS_TYPER_SVPET , typer); +u32 svpet =FIELD_GET (GITS_TYPER_SVPET , its->typer); - its->sgir_base =ioremap (res->start +SZ_128K ,SZ_64K ); + its->sgir_base =ioremap (its->phys_base +SZ_128K ,SZ_64K );if (!its->sgir_base) { err = -ENOMEM ; - goto out_free_its; + goto out; } - its->mpidr =readl_relaxed (its_base +GITS_MPIDR ); + its->mpidr =readl_relaxed (its->base +GITS_MPIDR );pr_info ("ITS@%pa: Using GICv4.1 mode %08x %08x\n" , - &res->start, its->mpidr, svpet); + &its->phys_base, its->mpidr, svpet); } } - its->numa_node = numa_node; - page =alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO,get_order (ITS_CMD_QUEUE_SZ ));if (!page) {
@@ -5083,12 +5057,9 @@ static int __init its_probe_one(struct resource *res, } its->cmd_base = (void *)page_address (page); its->cmd_write = its->cmd_base; - its->fwnode_handle = handle; its->get_msi_base = its_irq_get_msi_base; its->msi_domain_flags =IRQ_DOMAIN_FLAG_MSI_REMAP ; -its_enable_quirks (its); - err =its_alloc_tables (its);if (err) goto out_free_cmd;
@@ -5129,7 +5100,7 @@ static int __init its_probe_one(struct resource *res, ctlr |= GITS_CTLR_ImDe;writel_relaxed (ctlr, its->base +GITS_CTLR ); - err =its_init_domain (handle, its); + err =its_init_domain (its);if (err) goto out_free_collection;
@@ -5148,11 +5119,8 @@ static int __init its_probe_one(struct resource *res, out_unmap_sgir:if (its->sgir_base)iounmap (its->sgir_base); -out_free_its: -kfree (its); -out_unmap: -iounmap (its_base); -pr_err ("ITS@%pa: failed probing (%d)\n" , &res->start, err); +out: +pr_err ("ITS@%pa: failed probing (%d)\n" , &its->phys_base, err);return err; }
@@ -5299,10 +5267,53 @@ static const struct of_device_id its_device_id[] = { {}, }; +static struct its_node __init *its_node_init (struct resource *res, +struct fwnode_handle *handle,int numa_node) +{ +void __iomem *its_base; +struct its_node *its; +int err; + + its_base =its_map_one (res, &err); +if (!its_base) +return NULL ; + +pr_info ("ITS %pR\n" , res); + + its =kzalloc (sizeof (*its),GFP_KERNEL ); +if (!its) + goto out_unmap; + +raw_spin_lock_init (&its->lock); +mutex_init (&its->dev_alloc_lock); +INIT_LIST_HEAD (&its->entry); +INIT_LIST_HEAD (&its->its_device_list); + + its->typer =gic_read_typer (its_base +GITS_TYPER ); + its->base = its_base; + its->phys_base = res->start; + + its->numa_node = numa_node; + its->fwnode_handle = handle; + +return its; + +out_unmap: +iounmap (its_base); +return NULL ; +} + +static void its_node_destroy (struct its_node *its) +{ +iounmap (its->base); +kfree (its); +} +static int __init its_of_probe (struct device_node *node) {struct device_node *np;struct resource res; +int err;/* * Make sure *all* the ITS are reset before we probe any, as
@@ -5312,8 +5323,6 @@ static int __init its_of_probe(struct device_node *node)*/ for (np =of_find_matching_node (node, its_device_id); np; np =of_find_matching_node (np, its_device_id)) { -int err; -if (!of_device_is_available (np) || !of_property_read_bool (np,"msi-controller" ) ||of_address_to_resource (np,0 , &res))
@@ -5326,6 +5335,8 @@ static int __init its_of_probe(struct device_node *node)for (np =of_find_matching_node (node, its_device_id); np; np =of_find_matching_node (np, its_device_id)) { +struct its_node *its; +if (!of_device_is_available (np))continue ;if (!of_property_read_bool (np,"msi-controller" )) {
@@ -5339,7 +5350,17 @@ static int __init its_of_probe(struct device_node *node)continue ; } -its_probe_one (&res, &np->fwnode,of_node_to_nid (np)); + + its =its_node_init (&res, &np->fwnode,of_node_to_nid (np)); +if (!its) +return -ENOMEM ; + +its_enable_quirks (its); + err =its_probe_one (its); +if (err) { +its_node_destroy (its); +return err; + } }return 0 ; }
@@ -5453,6 +5474,7 @@ static int __init gic_acpi_parse_madt_its(union acpi_subtable_headers *header, {struct acpi_madt_generic_translator *its_entry;struct fwnode_handle *dom_handle; +struct its_node *its;struct resource res;int err;
@@ -5477,11 +5499,18 @@ static int __init gic_acpi_parse_madt_its(union acpi_subtable_headers *header, goto dom_err; } - err =its_probe_one (&res, dom_handle, -acpi_get_its_numa_node (its_entry->translation_id)); + its =its_node_init (&res, dom_handle, +acpi_get_its_numa_node (its_entry->translation_id)); +if (!its) { + err = -ENOMEM ; + goto node_err; + } + + err =its_probe_one (its);if (!err)return 0 ; +node_err:iort_deregister_domain_token (its_entry->translation_id); dom_err:irq_domain_free_fwnode (dom_handle);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1667/1848 irqchip/gic-v3-its: Share ITS tables with a non-trusted hypervisor
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Price <[email protected]>
[ Upstream commit b08e2f42e86b5848add254da45b56fc672e2bced ]
Within a realm guest the ITS is emulated by the host. This means the allocations must have been made available to the host by a call to set_memory_decrypted(). Introduce an allocation function which performs this extra call.
For the ITT use a custom genpool-based allocator that calls set_memory_decrypted() for each page allocated, but then suballocates the size needed for each ITT. Note that there is no mechanism implemented to return pages from the genpool, but it is unlikely that the peak number of devices will be much larger than the normal level - so this isn't expected to be an issue.
Stable-dep-of: 32e056cc1d15 ("irqchip/gic-v3-its: Don't free a vPE table shared with another ITS")
--- drivers/irqchip/irq-gic-v3-its.c | 138 +++++++++++++++++++++++++------ 1 file changed, 115 insertions(+), 23 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +115 -23
@@ -13,11 +13,13 @@#include <linux/delay.h> #include <linux/dma-iommu.h> #include <linux/efi.h> +#include <linux/genalloc.h> #include <linux/interrupt.h> #include <linux/iopoll.h> #include <linux/irqdomain.h> #include <linux/list.h> #include <linux/log2.h> +#include <linux/mem_encrypt.h> #include <linux/memblock.h> #include <linux/mm.h> #include <linux/msi.h>
@@ -27,6 +29,7 @@#include <linux/of_pci.h> #include <linux/of_platform.h> #include <linux/percpu.h> +#include <linux/set_memory.h> #include <linux/slab.h> #include <linux/syscore_ops.h>
@@ -165,6 +168,7 @@ struct its_device {struct its_node *its;struct event_lpi_map event_map;void *itt; +u32 itt_sz;u32 nr_ites;u32 device_id;bool shared;
@@ -200,6 +204,87 @@ static DEFINE_IDA(its_vpeid_ida);#define gic_data_rdist_rd_base () (gic_data_rdist()->rd_base)#define gic_data_rdist_vlpi_base () (gic_data_rdist_rd_base() + SZ_128K) +static struct page *its_alloc_pages_node (int node,gfp_t gfp, +unsigned int order) +{ +struct page *page; +int ret =0 ; + + page =alloc_pages_node (node, gfp, order); + +if (!page) +return NULL ; + + ret =set_memory_decrypted ((unsigned long )page_address (page), +1 << order); +/* +* If set_memory_decrypted() fails then we don't know what state the +* page is in, so we can't free it. Instead we leak it. +* set_memory_decrypted() will already have WARNed. +*/ +if (ret) +return NULL ; + +return page; +} + +static struct page *its_alloc_pages (gfp_t gfp,unsigned int order) +{ +return its_alloc_pages_node (NUMA_NO_NODE , gfp, order); +} + +static void its_free_pages (void *addr,unsigned int order) +{ +/* +* If the memory cannot be encrypted again then we must leak the pages. +* set_memory_encrypted() will already have WARNed. +*/ +if (set_memory_encrypted ((unsigned long )addr,1 << order)) +return ; +free_pages ((unsigned long )addr, order); +} + +static struct gen_pool *itt_pool; + +static void *itt_alloc_pool (int node,int size) +{ +unsigned long addr; +struct page *page; + +if (size >=PAGE_SIZE ) { + page =its_alloc_pages_node (node,GFP_KERNEL | __GFP_ZERO,get_order (size)); + +return page ?page_address (page) :NULL ; + } + +do { + addr =gen_pool_alloc (itt_pool, size); +if (addr) +break ; + + page =its_alloc_pages_node (node,GFP_KERNEL | __GFP_ZERO,1 ); +if (!page) +break ; + +gen_pool_add (itt_pool, (unsigned long )page_address (page),PAGE_SIZE , node); + }while (!addr); + +return (void *)addr; +} + +static void itt_free_pool (void *addr,int size) +{ +if (!addr) +return ; + +if (size >=PAGE_SIZE ) { +its_free_pages (addr,get_order (size)); +return ; + } + +gen_pool_free (itt_pool, (unsigned long )addr, size); +} +/* * Skip ITSs that have no vLPIs mapped, unless we're on GICv4.1, as we * always have vSGIs mapped.
@@ -2203,7 +2288,8 @@ static struct page *its_allocate_prop_table(gfp_t gfp_flags) {struct page *prop_page; - prop_page =alloc_pages (gfp_flags,get_order (LPI_PROPBASE_SZ )); + prop_page =its_alloc_pages (gfp_flags, +get_order (LPI_PROPBASE_SZ ));if (!prop_page)return NULL ;
@@ -2214,8 +2300,7 @@ static struct page *its_allocate_prop_table(gfp_t gfp_flags)static void its_free_prop_table (struct page *prop_page) { -free_pages ((unsigned long )page_address (prop_page), -get_order (LPI_PROPBASE_SZ )); +its_free_pages (page_address (prop_page),get_order (LPI_PROPBASE_SZ )); }static bool gic_check_reserved_range (phys_addr_t addr,unsigned long size)
@@ -2337,7 +2422,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, order =get_order (GITS_BASER_PAGES_MAX * psz); } - page =alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO, order); + page =its_alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO, order);if (!page)return -ENOMEM ;
@@ -2350,7 +2435,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,/* 52bit PA is supported only when PageSize=64K */ if (psz !=SZ_64K ) {pr_err ("ITS: no 52bit PA support when psz=%d\n" , psz); -free_pages ((unsigned long )base, order); +its_free_pages (base, order);return -ENXIO ; }
@@ -2404,7 +2489,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,pr_err ("ITS@%pa: %s doesn't stick: %llx %llx\n" , &its->phys_base, its_base_type_string[type], val, tmp); -free_pages ((unsigned long )base, order); +its_free_pages (base, order);return -ENXIO ; }
@@ -2543,8 +2628,7 @@ static void its_free_tables(struct its_node *its)for (i =0 ; i <GITS_BASER_NR_REGS ; i++) {if (its->tables[i].base) { -free_pages ((unsigned long )its->tables[i].base, - its->tables[i].order); +its_free_pages (its->tables[i].base, its->tables[i].order); its->tables[i].base =NULL ; } }
@@ -2803,7 +2887,7 @@ static bool allocate_vpe_l2_table(int cpu, u32 id)/* Allocate memory for 2nd level table */ if (!table[idx]) { - page =alloc_pages (GFP_KERNEL | __GFP_ZERO,get_order (psz)); + page =its_alloc_pages (GFP_KERNEL | __GFP_ZERO,get_order (psz));if (!page)return false;
@@ -2922,7 +3006,7 @@ static int allocate_vpe_l1_table(void)pr_debug ("np = %d, npg = %lld, psz = %d, epp = %d, esz = %d\n" , np, npg, psz, epp, esz); - page =alloc_pages (GFP_ATOMIC | __GFP_ZERO,get_order (np *PAGE_SIZE )); + page =its_alloc_pages (GFP_ATOMIC | __GFP_ZERO,get_order (np *PAGE_SIZE ));if (!page)return -ENOMEM ;
@@ -2966,8 +3050,7 @@ static struct page *its_allocate_pending_table(gfp_t gfp_flags) {struct page *pend_page; - pend_page =alloc_pages (gfp_flags | __GFP_ZERO, -get_order (LPI_PENDBASE_SZ )); + pend_page =its_alloc_pages (gfp_flags | __GFP_ZERO,get_order (LPI_PENDBASE_SZ ));if (!pend_page)return NULL ;
@@ -2979,7 +3062,7 @@ static struct page *its_allocate_pending_table(gfp_t gfp_flags)static void its_free_pending_table (struct page *pt) { -free_pages ((unsigned long )page_address (pt),get_order (LPI_PENDBASE_SZ )); +its_free_pages (page_address (pt),get_order (LPI_PENDBASE_SZ )); }/*
@@ -3298,8 +3381,8 @@ static bool its_alloc_table_entry(struct its_node *its,/* Allocate memory for 2nd level table */ if (!table[idx]) { - page =alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO, -get_order (baser->psz)); + page =its_alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO, +get_order (baser->psz));if (!page)return false;
@@ -3395,7 +3478,6 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,if (WARN_ON (!is_power_of_2 (nvecs))) nvecs =roundup_pow_of_two (nvecs); - dev =kzalloc (sizeof (*dev),GFP_KERNEL );/* * Even if the device wants a single LPI, the ITT must be * sized as a power of two (and you need at least one bit...).
@@ -3406,7 +3488,11 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, nr_ites =max (2 , nvecs); sz = nr_ites * (FIELD_GET (GITS_TYPER_ITT_ENTRY_SIZE , its->typer) +1 ); sz =max (sz,ITS_ITT_ALIGN ) +ITS_ITT_ALIGN -1 ; - itt =kzalloc_node (sz,GFP_KERNEL , its->numa_node); + + itt =itt_alloc_pool (its->numa_node, sz); + + dev =kzalloc (sizeof (*dev),GFP_KERNEL ); +if (alloc_lpis) { lpi_map =its_lpi_alloc (nvecs, &lpi_base, &nr_lpis);if (lpi_map)
@@ -3418,9 +3504,9 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, lpi_base =0 ; } -if (!dev || !itt || !col_map || (!lpi_map && alloc_lpis)) { +if (!dev || !itt || !col_map || (!lpi_map && alloc_lpis)) {kfree (dev); -kfree (itt); +itt_free_pool (itt, sz);bitmap_free (lpi_map);kfree (col_map);return NULL ;
@@ -3430,6 +3516,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, dev->its = its; dev->itt = itt; + dev->itt_sz = sz; dev->nr_ites = nr_ites; dev->event_map.lpi_map = lpi_map; dev->event_map.col_map = col_map;
@@ -3457,7 +3544,7 @@ static void its_free_device(struct its_device *its_dev)list_del (&its_dev->entry);raw_spin_unlock_irqrestore (&its_dev->its->lock, flags);kfree (its_dev->event_map.col_map); -kfree (its_dev->itt); +itt_free_pool (its_dev->itt, its_dev->itt_sz);kfree (its_dev); }
@@ -5049,8 +5136,9 @@ static int __init its_probe_one(struct its_node *its) } } - page =alloc_pages_node (its->numa_node,GFP_KERNEL | __GFP_ZERO, -get_order (ITS_CMD_QUEUE_SZ )); + page =its_alloc_pages_node (its->numa_node, +GFP_KERNEL | __GFP_ZERO, +get_order (ITS_CMD_QUEUE_SZ ));if (!page) { err = -ENOMEM ; goto out_unmap_sgir;
@@ -5115,7 +5203,7 @@ static int __init its_probe_one(struct its_node *its) out_free_tables:its_free_tables (its); out_free_cmd: -free_pages ((unsigned long )its->cmd_base,get_order (ITS_CMD_QUEUE_SZ )); +its_free_pages (its->cmd_base,get_order (ITS_CMD_QUEUE_SZ )); out_unmap_sgir:if (its->sgir_base)iounmap (its->sgir_base);
@@ -5578,6 +5666,10 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists,bool has_v4_1 = false;int err; + itt_pool =gen_pool_create (get_order (ITS_ITT_ALIGN ),-1 ); +if (!itt_pool) +return -ENOMEM ; + gic_rdists = rdists; its_parent = parent_domain;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1668/1848 irqchip/gic-v3-its: Dont free a vPE table shared with another ITS
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 32e056cc1d1582951f981113ca8b98914f29c32a ]
On GICv4.1, its_alloc_tables() copies a sibling's vPE table baser rather than allocating one, but its_free_tables() frees it like the rest. A probe failure on the copying ITS then frees pages the enabled sibling still points GITS_BASER2 at, and the kernel comes up running on that sibling.
Mark a shared table so its_free_tables() skips it.
--- drivers/irqchip/irq-gic-v3-its.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +5 -1
@@ -85,6 +85,8 @@ struct its_baser {u64 val;u32 order;u32 psz; +/* Inherited from a sibling ITS, not freed here */ +bool shared; };struct its_device ;
@@ -2628,7 +2630,8 @@ static void its_free_tables(struct its_node *its)for (i =0 ; i <GITS_BASER_NR_REGS ; i++) {if (its->tables[i].base) { -its_free_pages (its->tables[i].base, its->tables[i].order); +if (!its->tables[i].shared) +its_free_pages (its->tables[i].base, its->tables[i].order); its->tables[i].base =NULL ; } }
@@ -2722,6 +2725,7 @@ static int its_alloc_tables(struct its_node *its)WARN_ON (i !=2 );if ((sibling =find_sibling_its (its))) { *baser = sibling->tables[2 ]; + baser->shared = true;its_write_baser (its, baser, baser->val);continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1669/1848 irqchip/gic-v3-its: Dont free the tables of an enabled ITS
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit d09b36d8e0e60f35bd1cd7d63aadc6dfad61700c ]
its_probe_one() enables the ITS before its_init_domain(), the last step that can fail, and the unwind from there frees the tables and the command queue without disabling it. The kernel comes up with an enabled ITS pointing at freed pages.
Enable the ITS last. Nothing reaches the new domain before then: this runs from init_IRQ(), and the ITS joins its_nodes only after the enable.
--- drivers/irqchip/irq-gic-v3-its.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +6 -4
@@ -5186,16 +5186,18 @@ static int __init its_probe_one(struct its_node *its) }gits_write_cwriter (0 , its->base +GITS_CWRITER ); + + err =its_init_domain (its); +if (err) + goto out_free_collection; + +/* Enable last: the unwind frees memory an enabled ITS may access */ ctlr =readl_relaxed (its->base +GITS_CTLR ); ctlr |=GITS_CTLR_ENABLE ;if (is_v4 (its)) ctlr |= GITS_CTLR_ImDe;writel_relaxed (ctlr, its->base +GITS_CTLR ); - err =its_init_domain (its); -if (err) - goto out_free_collection; -raw_spin_lock (&its_lock);list_add (&its->entry, &its_nodes);raw_spin_unlock (&its_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1670/1848 RDMA/rxe: bound the WQE opcode before indexing rxe_wr_opcode_info[]
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youngsung Ahn <[email protected]>
[ Upstream commit c887e53e1c852b88bd5442d1bf4717ee3e7aadda ]
wr_opcode_mask() indexes the global rxe_wr_opcode_info[] array with a caller-supplied opcode and no bounds check. For a user QP the WQE comes from an mmap'd SQ ring, so wqe->wr.opcode is an attacker-controlled __u32 read back by the requester (req_next_wqe() -> rxe_requester()); rxe_post_send() takes the qp->is_user branch and never runs validate_send_wr(), whose only opcode check is itself !wr_opcode_mask() (it indexes before it checks). rxe_wr_opcode_info[] has entries only up to IB_WR_REG_MR, so an out-of-range opcode reads out of bounds and the result is used as a mask and dereferenced; observed as a KASAN global-out-of-bounds "Read of size 4" and a wild-pointer oops.
Return a zero mask for an out-of-range opcode, matching how validate_send_wr() already treats a zero mask (an invalid WR), so no path indexes the array out of bounds.
--- drivers/infiniband/sw/rxe/rxe_loc.h | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/sw/rxe/rxe_loc.h +3 -0
@@ -213,6 +213,9 @@ void rxe_comp_queue_pkt(struct rxe_qp *qp, struct sk_buff *skb);static inline unsigned int wr_opcode_mask (int opcode,struct rxe_qp *qp) { +if (unlikely (opcode <0 || opcode >IB_WR_REG_MR )) +return 0 ; +return rxe_wr_opcode_info[opcode].mask[qp->ibqp.qp_type]; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1671/1848 kselftest/arm64: signal: copy each test binary only once
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 7b3b147c4104f8211ad356a78cff9a2dcd966312 ]
The signal tests are built in testcases/ and then copied to the output directory. The copy rule lists every generated program as a target and copies all of them in each recipe:
$(TEST_GEN_PROGS): $(PROGS)
cp $(PROGS) $(OUTPUT)/In a parallel build make runs that recipe once for each program, so several cp processes write the same destination files at the same time. cp then fails with "cannot create regular file ...: File exists", which fails the arm64 build even though every test compiled. A cross build of the arm64 signal tests at -j8 hit this in all of 8 runs.
Use a static pattern rule so that each output depends on, and copies, only its own binary.
--- tools/testing/selftests/arm64/signal/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/arm64/signal/Makefile +2 -2
@@ -18,8 +18,8 @@ KSFT_KHDR_INSTALL := 1 # the toplevel makefile include ../../lib.mk -$(TEST_GEN_PROGS): $(PROGS) - cp $(PROGS) $(OUTPUT)/ +$(TEST_GEN_PROGS): $(OUTPUT)/%: testcases/% + cp $< $@ # Common test-unit targets to build common-layout test-cases executables # Needs secondary expansion to properly include the testcase c-file in pre-reqs
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1672/1848 selftests: keep the build status from wrapping to success
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit 907d138279ee3747efedc9f7403d8b0edb52aca2 ]
The top-level all and install rules return failure only when every selected target fails, which commit cad6f32665cb ("selftests: Deescalate error reporting") deliberately kept as the default. They implement this by multiplying the exit statuses of the targets:
ret=$$((ret * $$?))
A failing recursive make exits with status 2, so eight failing targets produce 256, and "exit 256" reports success. Building eight or more targets that all fail therefore succeeds, and install goes on to package an empty installation.
Record a successful target instead of multiplying statuses. The rules still fail only when no target succeeds, and FORCE_TARGETS still stops at the first failure.
--- tools/testing/selftests/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/Makefile +2 -2
@@ -172,7 +172,7 @@ all: khdr mkdir $$BUILD_TARGET -p; \ $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET \ $(if $(FORCE_TARGETS),|| exit); \ - ret=$$((ret * $$?)); \ + [ $$? -eq 0 ] && ret=0; \ done; exit $$ret; run_tests: all
@@ -230,7 +230,7 @@ ifdef INSTALL_PATH BUILD_TARGET=$$BUILD/$$TARGET; \ $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install \ $(if $(FORCE_TARGETS),|| exit); \ - ret=$$((ret * $$?)); \ + [ $$? -eq 0 ] && ret=0; \ done; exit $$ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1673/1848 ASoC: ops: Fix return value in snd_soc_limit_volume()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amadeusz Sławiński <[email protected]>
[ Upstream commit 223ec2a93bec6c5ee859094c826fec78516a0bb3 ]
As documented snd_soc_limit_volume() should return 0 on success, however at some point in time this promise was broken when snd_soc_clip_to_platform_max() was refactored, refactor it once again using __free() to automatically free struct snd_ctl_elem_value and return proper value.
--- sound/soc/soc-ops.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
sound/soc/soc-ops.c +5 -5
@@ -618,7 +618,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_range);static int snd_soc_clip_to_platform_max (struct snd_kcontrol *kctl) {struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value; -struct snd_ctl_elem_value *uctl; + struct snd_ctl_elem_value *uctl __free(kfree) = NULL;int ret;if (!mc->platform_max)
@@ -630,7 +630,7 @@ static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl) ret = kctl->get (kctl, uctl);if (ret <0 ) - goto out; +return ret;if (uctl->value.integer.value[0 ] > mc->platform_max) uctl->value.integer.value[0 ] = mc->platform_max;
@@ -640,10 +640,10 @@ static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl) uctl->value.integer.value[1 ] = mc->platform_max; ret = kctl->put (kctl, uctl); +if (ret <0 ) +return ret; -out: -kfree (uctl); -return ret; +return 0 ; }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1674/1848 ASoC: soc-ac97: Fix error handling in snd_soc_new_ac97_component()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amadeusz Sławiński <[email protected]>
[ Upstream commit fc081cdfc6b370f6b6853cdeb4313f92561770d1 ]
If call to snd_soc_ac97_init_gpio() fails, proper removal procedure should mirror snd_soc_free_ac97_component() behaviour and call device_del() before put_device().
--- sound/soc/soc-ac97.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/soc-ac97.c +3 -1
@@ -237,10 +237,12 @@ struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component, ret =snd_soc_ac97_init_gpio (ac97, component);if (ret) - goto err_put_device; + goto err_del_device;return ac97; +err_del_device: +device_del (&ac97->dev); err_put_device:put_device (&ac97->dev);return ERR_PTR (ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1675/1848 ASoC: soc-component: Fix return type of snd_soc_pcm_component_pointer()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amadeusz Sławiński <[email protected]>
[ Upstream commit 9df30adce80dd6b0646e58c12a4cf7c6c88d0778 ]
Both caller and pointer callback expect the return value to be snd_pcm_uframes_t, however it was defined incorrectly leading to potential truncation of returned value.
--- include/sound/soc-component.h | 2 +- sound/soc/soc-component.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/sound/soc-component.h +1 -1
@@ -444,7 +444,7 @@ int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,struct of_phandle_args *args, const char **dai_name); -int snd_soc_pcm_component_pointer (struct snd_pcm_substream *substream); +snd_pcm_uframes_t snd_soc_pcm_component_pointer (struct snd_pcm_substream *substream);int snd_soc_pcm_component_ioctl (struct snd_pcm_substream *substream,unsigned int cmd,void *arg);int snd_soc_pcm_component_sync_stop (struct snd_pcm_substream *substream);
sound/soc/soc-component.c +1 -1
@@ -613,7 +613,7 @@ int snd_soc_component_test_bits(struct snd_soc_component *component, }EXPORT_SYMBOL_GPL (snd_soc_component_test_bits); -int snd_soc_pcm_component_pointer (struct snd_pcm_substream *substream) +snd_pcm_uframes_t snd_soc_pcm_component_pointer (struct snd_pcm_substream *substream) {struct snd_soc_pcm_runtime *rtd =asoc_substream_to_rtd (substream);struct snd_soc_component *component;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1676/1848 tracing: Print a signed histogram key as signed
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <[email protected]>
[ Upstream commit d3e0dfc1ba49a0ab6aeddbb4bcde4bfc0e171a02 ]
A histogram sorts its rows by the key named in sort=, and for a key over a signed event field it sorts them signed: create_tracing_map_fields() picks the comparison function with
else cmp_fn = tracing_map_cmp_num(field->size, field->is_signed);
hist_trigger_print_key() does not look at is_signed at all. Every numeric key is printed with %llu, so a sorted histogram over a signed field comes out looking unsorted. syscalls/sys_exit_lseek carries "long ret", which SYSCALL_FIELD() marks signed and which is negative on every error:
# echo 'hist:keys=ret:sort=ret' > events/syscalls/sys_exit_lseek/trigger # echo 1 > events/syscalls/sys_exit_lseek/enable # (five lseek(2) calls returning -ESPIPE, -EINVAL, -EBADF, 0 and 100) # cat events/syscalls/sys_exit_lseek/hist
{ ret: 18446744073709551587 } hitcount: 1
{ ret: 18446744073709551594 } hitcount: 1
{ ret: 18446744073709551607 } hitcount: 1 { ret: 0 } hitcount: 1
{ ret: 100 } hitcount: 1
The rows are in ascending order and the numbers are not, because the three leading ones are -29, -22 and -9 rendered as their two's complement.
Take the rendering from the same place the sort order comes from: the event field when the key has one, and the hist_field itself when it does not. The same histogram then reads
{ ret: -29 } hitcount: 1
{ ret: -22 } hitcount: 1
{ ret: -9 } hitcount: 1
{ ret: 0 } hitcount: 1
{ ret: 100 } hitcount: 1A ".buckets" key stays unsigned here, and not because it is right. hist_field_bucket() divides as unsigned, so the group holding S64_MAX also holds S64_MIN, reported at
https://lore.kernel.org/all/[email protected]/
Printing that group signed would name a range that does not contain S64_MIN, so the grouping has to be fixed with it, in a patch of its own.
--- kernel/trace/trace_events_hist.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +13 -1
@@ -200,6 +200,14 @@ static u64 hist_field_pstring(struct hist_field *hist_field,return (u64 )(unsigned long )*addr; } +static bool hist_field_is_signed (struct hist_field *hist_field) +{ +if (hist_field->field) +return hist_field->field->is_signed; + +return hist_field->is_signed; +} + static u64 hist_field_log2(struct hist_field *hist_field, struct tracing_map_elt *elt, struct ring_buffer_event *rbe,
@@ -4706,7 +4714,11 @@ static void hist_trigger_print_key(struct seq_file *m, (char *)(key + key_field->offset)); }else { uval = *(u64 *)(key + key_field->offset); -seq_printf (m,"%s: %10llu" , field_name, uval); +if (hist_field_is_signed (key_field)) +seq_printf (m,"%s: %10lld" , field_name, + (s64 )uval); +else +seq_printf (m,"%s: %10llu" , field_name, uval); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1677/1848 macsec: prevent AES-GCM nonce reuse after packet number wrap
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 94d51c59f0a872c57cb8daa1964ec033d77a79fb ]
After allocating the last valid packet number, MACsec wraps next_pn to zero and deactivates the transmit SA. This happens for both 32- and 64-bit types of packet numbers (at values 0xffffffff and 0xffffffffffffffff, respectively).
TX packets that were still getting processed during deactivation keep being processed and then receive packet numbers. The first gets 0 and is correctly dropped, but next_pn is incremented to 1, which makes the next packet take number 1. It then does not get dropped and may induce a reuse of the AES-GCM nonce corresponding to value 1.
This race affects TX packets that have already passed the SA activity
check: packets that observe the inactive SA are correctly dropped. Reactivating the SA after PN wrap without a packet number can also cause nonce reuse. Keep next_pn at 0 after wrap, even if the SA is reactivated, so further packet number allocations return 0 and the corresponding packets are dropped.
--- drivers/net/macsec.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/macsec.c +5 -0
@@ -500,6 +500,9 @@ static pn_t tx_sa_update_pn(struct macsec_tx_sa *tx_sa,spin_lock_bh (&tx_sa->lock); pn = tx_sa->next_pn_halves; +if (unlikely (pn.full64 ==0 )) + goto out; +if (secy->xpn) tx_sa->next_pn++;else
@@ -507,6 +510,8 @@ static pn_t tx_sa_update_pn(struct macsec_tx_sa *tx_sa,if (tx_sa->next_pn ==0 )__macsec_pn_wrapped (secy, tx_sa); + +out:spin_unlock_bh (&tx_sa->lock);return pn;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1678/1848 net: usb: lan78xx: reject invalid EEPROM write requests
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Munari <[email protected]>
[ Upstream commit 9272297df14124fe603c81e40b52ff0c5dd88652 ]
The runtime PM handling removed the -EINVAL return for invalid EEPROM/OTP write requests. These requests now return zero from a successful usb_autopm_get_interface() call, even though no data is written.
Set ret to -EINVAL for invalid requests while preserving the runtime PM reference release.
--- drivers/net/usb/lan78xx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/usb/lan78xx.c +6 -3
@@ -1374,13 +1374,16 @@ static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,/* Invalid EEPROM_INDICATOR at offset zero will result in a failure * to load data from EEPROM */ -if (ee->magic ==LAN78XX_EEPROM_MAGIC ) +if (ee->magic ==LAN78XX_EEPROM_MAGIC ) { ret =lan78xx_write_raw_eeprom (dev, ee->offset, ee->len, data); -else if ((ee->magic ==LAN78XX_OTP_MAGIC ) && + }else if ((ee->magic ==LAN78XX_OTP_MAGIC ) && (ee->offset ==0 ) && (ee->len ==512 ) && - (data[0 ] ==OTP_INDICATOR_1 )) + (data[0 ] ==OTP_INDICATOR_1 )) { ret =lan78xx_write_raw_otp (dev, ee->offset, ee->len, data); + }else { + ret = -EINVAL ; + }usb_autopm_put_interface (dev->intf);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1679/1848 HID: wacom: fix wacom_intuos_irq NULL pen_input deref
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matheus Alves de Almeida <[email protected]>
[ Upstream commit 2f985de0afbe9366af9d322ea20589712c1dc8fe ]
Currently, wacom_intuos_irq() passes the parent of wacom_wac's pen_input to the dev_dbg() in the unknown report path. However, pen_input can be NULL on interfaces without a pen, causing a NULL pointer dereference.
Get the HID device from the enclosing struct wacom and use hid_dbg() instead.
--- drivers/hid/wacom_wac.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/hid/wacom_wac.c +7 -7
@@ -1066,10 +1066,10 @@ static int wacom_intuos_general(struct wacom_wac *wacom)return 2 ; } -static int wacom_intuos_irq (struct wacom_wac *wacom) +static int wacom_intuos_irq (struct wacom_wac *wacom_wac) { -unsigned char *data = wacom->data; -struct input_dev *input = wacom->pen_input; +unsigned char *data = wacom_wac->data; + struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);int result; if (data[0] != WACOM_REPORT_PENABLED &&
@@ -1080,23 +1080,23 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) data[0] != WACOM_REPORT_CINTIQ && data[0] != WACOM_REPORT_CINTIQPAD && data[0] != WACOM_REPORT_INTUOS5PAD) { -dev_dbg (input->dev.parent, +hid_dbg (wacom->hdev,"%s: received unknown report #%d\n" , __func__, data[0 ]);return 0 ; }/* process pad events */ - result =wacom_intuos_pad (wacom); + result =wacom_intuos_pad (wacom_wac);if (result)return result;/* process in/out prox events */ - result =wacom_intuos_inout (wacom); + result =wacom_intuos_inout (wacom_wac);if (result)return result -1 ;/* process general packets */ - result =wacom_intuos_general (wacom); + result =wacom_intuos_general (wacom_wac);if (result)return result -1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1680/1848 bpftool: Fix inverted tracefs validation when scanning /proc/mounts
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Chen <[email protected]>
[ Upstream commit 21c755efaab1f40c2588ae5acbfa319a6d7d3638 ]
The /proc/mounts fallback in get_tracefs_pipe() accepts only non-tracefs mount points, so a tracefs mounted outside the default locations is
ignored: bpftool prog tracelog then mounts a second tracefs, or exits silently with --nomount. Negate the condition.
--- tools/bpf/bpftool/tracelog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/bpftool/tracelog.c +1 -1
@@ -88,7 +88,7 @@ static bool get_tracefs_pipe(char *mnt)fclose (fp);/* The string from fscanf() might be truncated, check mnt is valid */ -if (found &&validate_tracefs_mnt (mnt,TRACEFS_MAGIC )) +if (found && !validate_tracefs_mnt (mnt,TRACEFS_MAGIC )) goto exit_found;if (block_mount)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1681/1848 blk-iocost: charge zone appends as writes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Cui <[email protected]>
[ Upstream commit febdbf5682fa7e8f325b07a2c115e7632c4252bd ]
Zone append is a primary write operation for zoned devices; zoned xfs and btrfs use it for data writes. It is priced at zero, so the zone append portion of zoned workloads runs outside the controller: a 1%-weight cgroup issued 16000 appends at zero cost on a zoned null_blk.
Treat REQ_OP_ZONE_APPEND the same as REQ_OP_WRITE so it goes through the existing seq/rand classification and charging.
--- block/blk-iocost.c | 1 + 1 file changed, 1 insertion(+)
block/blk-iocost.c +1 -0
@@ -2515,6 +2515,7 @@ static void calc_vtime_cost_builtin(struct bio *bio, struct ioc_gq *iocg, coef_randio = ioc->params.lcoefs[LCOEF_RRANDIO ]; coef_page = ioc->params.lcoefs[LCOEF_RPAGE ];break ; +case REQ_OP_ZONE_APPEND :case REQ_OP_WRITE : coef_seqio = ioc->params.lcoefs[LCOEF_WSEQIO ]; coef_randio = ioc->params.lcoefs[LCOEF_WRANDIO ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1682/1848 blk-iocost: account zone append completions in latency stats
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Cui <[email protected]>
[ Upstream commit c38975c427cc3d3f6eb66a36143893be5cdf4ebd ]
ioc_rqos_done() only accounts READ and WRITE completions, so zone append completions are excluded from the latency window: the vrate feedback loop cannot see ZA-induced latency, leaving it unable to respond to device saturation caused by zone appends. Similarly, calc_size_vtime_cost_builtin() does not classify zone append as a write operation.
Charging (the cost model) and feedback (the latency window) are separate mechanisms, so this is not covered by the previous patch that prices zone appends.
Treat zone append as WRITE for both latency accounting and cost classification.
--- block/blk-iocost.c | 2 ++ 1 file changed, 2 insertions(+)
block/blk-iocost.c +2 -0
@@ -2559,6 +2559,7 @@ static void calc_size_vtime_cost_builtin(struct request *rq, struct ioc *ioc,case REQ_OP_READ : *costp = pages * ioc->params.lcoefs[LCOEF_RPAGE ];break ; +case REQ_OP_ZONE_APPEND :case REQ_OP_WRITE : *costp = pages * ioc->params.lcoefs[LCOEF_WPAGE ];break ;
@@ -2795,6 +2796,7 @@ static void ioc_rqos_done(struct rq_qos *rqos, struct request *rq) pidx =QOS_RLAT ; rw =READ ;break ; +case REQ_OP_ZONE_APPEND :case REQ_OP_WRITE : pidx =QOS_WLAT ; rw =WRITE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1683/1848 ima: reject a kexec buffer whose declared size exceeds the buffer
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrice Derepas <[email protected]>
[ Upstream commit ceb24c7052cc4649e3b52a51a7cca7dfe4896cec ]
ima_restore_measurement_list() parses the measurement list persisted across kexec. It computes the parse end directly from the blob:
bufendp = buf + khdr->buffer_size;
khdr->buffer_size is a u64 read straight from the persisted buffer. The only length checks in the function are size >= sizeof(*khdr), version == 1 and count -- none relates buffer_size to size, the actual buffer size the caller (ima_load_kexec_buffer()) obtained from the ima-kexec-buffer region. ima_parse_buf() bounds every field read to bufendp, so a blob whose internal buffer_size exceeds the real size makes the parse loop read past the end of the buffer (CWE-125).
The buffer's memory range is validated against addressable RAM by commit cbf9c4b9617b ("of: check previous kernel's ima-kexec-buffer against memory bounds") and commit c5489d04337b ("x86/kexec: add a sanity check on previous kernel's ima kexec buffer"), but the blob's own declared size is never clamped to it. Reject a buffer_size larger than size before the loop.
This is on the boot-time kexec-restore path (__init) and the buffer comes from the previous kernel, so triggering it requires control of the persisted buffer; it is an out-of-bounds read only.
--- security/integrity/ima/ima_template.c | 5 +++++ 1 file changed, 5 insertions(+)
security/integrity/ima/ima_template.c +5 -0
@@ -399,6 +399,11 @@ int ima_restore_measurement_list(loff_t size, void *buf)return -EINVAL ; } +if (khdr->buffer_size > size) { +pr_err ("attempting to restore a corrupted measurement list" ); +return -EINVAL ; + } +bitmap_zero (hdr_mask,HDR__LAST );bitmap_set (hdr_mask,HDR_PCR ,1 );bitmap_set (hdr_mask,HDR_DIGEST ,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1684/1848 net: core: add dev_get_tstats64 as a ndo_get_stats64 implementation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
[ Upstream commit a18394269fc87276963e8d965c730900178d7e4b ]
It's a frequent pattern to use netdev->stats for the less frequently accessed counters and per-cpu counters for the frequently accessed counters (rx/tx bytes/packets). Add a default ndo_get_stats64() implementation for this use case.
Stable-dep-of: 95a5c641fc7b ("usbnet: fix smp_processor_id() use in preemptible context")
--- include/linux/netdevice.h | 1 + net/core/dev.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)
include/linux/netdevice.h +1 -0
@@ -4613,6 +4613,7 @@ void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, const struct net_device_stats *netdev_stats);void dev_fetch_sw_netstats (struct rtnl_link_stats64 *s,const struct pcpu_sw_netstats __percpu *netstats); +void dev_get_tstats64 (struct net_device *dev,struct rtnl_link_stats64 *s);extern int netdev_max_backlog;extern int netdev_tstamp_prequeue;
net/core/dev.c +15 -0
@@ -10450,6 +10450,21 @@ void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s, }EXPORT_SYMBOL_GPL (dev_fetch_sw_netstats); +/** +* dev_get_tstats64 - ndo_get_stats64 implementation +* @dev: device to get statistics from +* @s: place to store stats +* +* Populate @s from dev->stats and dev->tstats. Can be used as +* ndo_get_stats64() callback. +*/ +void dev_get_tstats64 (struct net_device *dev,struct rtnl_link_stats64 *s) +{ +netdev_stats_to_stats64 (s, &dev->stats); +dev_fetch_sw_netstats (s, dev->tstats); +} +EXPORT_SYMBOL_GPL (dev_get_tstats64); +struct netdev_queue *dev_ingress_queue_create (struct net_device *dev) {struct netdev_queue *queue =dev_ingress_queue (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1685/1848 usbnet: switch to core handling of rx/tx byte/packet counters
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
[ Upstream commit af0c351cc34857ad7b254850b9392d99da46be9e ]
Use netdev->tstats instead of a member of usbnet for storing a pointer to the per-cpu counters. This allows us to use core functionality for statistics handling.
Stable-dep-of: 95a5c641fc7b ("usbnet: fix smp_processor_id() use in preemptible context")
--- drivers/net/usb/usbnet.c | 23 +++++++---------------- include/linux/usb/usbnet.h | 6 ++---- 2 files changed, 9 insertions(+), 20 deletions(-)
drivers/net/usb/usbnet.c +7 -16
@@ -314,7 +314,7 @@ static void __usbnet_status_stop_force(struct usbnet *dev)*/ void usbnet_skb_return (struct usbnet *dev,struct sk_buff *skb) { -struct pcpu_sw_netstats *stats64 =this_cpu_ptr (dev->stats64); +struct pcpu_sw_netstats *stats64 =this_cpu_ptr (dev->net->tstats);unsigned long flags;int status;
@@ -990,15 +990,6 @@ int usbnet_set_link_ksettings(struct net_device *net, }EXPORT_SYMBOL_GPL (usbnet_set_link_ksettings); -void usbnet_get_stats64 (struct net_device *net,struct rtnl_link_stats64 *stats) -{ -struct usbnet *dev =netdev_priv (net); - -netdev_stats_to_stats64 (stats, &net->stats); -dev_fetch_sw_netstats (stats, dev->stats64); -} -EXPORT_SYMBOL_GPL (usbnet_get_stats64); -u32 usbnet_get_link (struct net_device *net) {struct usbnet *dev =netdev_priv (net);
@@ -1233,7 +1224,7 @@ static void tx_complete (struct urb *urb)struct usbnet *dev = entry->dev;if (urb->status ==0 ) { -struct pcpu_sw_netstats *stats64 =this_cpu_ptr (dev->stats64); +struct pcpu_sw_netstats *stats64 =this_cpu_ptr (dev->net->tstats);unsigned long flags; flags =u64_stats_update_begin_irqsave (&stats64->syncp);
@@ -1614,7 +1605,7 @@ void usbnet_disconnect (struct usb_interface *intf)usb_free_urb (dev->interrupt);kfree (dev->padding_pkt); -free_percpu (dev->stats64); +free_percpu (net->tstats);free_netdev (net); }EXPORT_SYMBOL_GPL (usbnet_disconnect);
@@ -1626,7 +1617,7 @@ static const struct net_device_ops usbnet_netdev_ops = { .ndo_tx_timeout = usbnet_tx_timeout, .ndo_set_rx_mode = usbnet_set_rx_mode, .ndo_change_mtu = usbnet_change_mtu, - .ndo_get_stats64 = usbnet_get_stats64, + .ndo_get_stats64 = dev_get_tstats64, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, };
@@ -1689,8 +1680,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) dev->driver_info = info; dev->driver_name = name; - dev->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); -if (!dev->stats64) + net->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); +if (!net->tstats) goto out0; dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV
@@ -1842,7 +1833,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)*/ cancel_work_sync (&dev->kevent);del_timer_sync (&dev->delay); -free_percpu (dev->stats64); +free_percpu (net->tstats); out0:free_netdev (net); out:
include/linux/usb/usbnet.h +2 -4
@@ -65,8 +65,6 @@ struct usbnet {struct usb_anchor deferred;struct tasklet_struct bh; -struct pcpu_sw_netstats __percpu *stats64; -struct work_struct kevent;unsigned long flags;# define EVENT_TX_HALT 0
@@ -288,7 +286,7 @@ extern int usbnet_status_start(struct usbnet *dev, gfp_t mem_flags);extern void usbnet_status_stop (struct usbnet *dev);extern void usbnet_update_max_qlen (struct usbnet *dev); -extern void usbnet_get_stats64 (struct net_device *dev, -struct rtnl_link_stats64 *stats); + +#define usbnet_get_stats64 dev_get_tstats64#endif /* __LINUX_USB_USBNET_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1686/1848 usbnet: fix smp_processor_id() use in preemptible context
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ömer Mete Kaya <[email protected]>
[ Upstream commit 95a5c641fc7becab441bf244baa73b0b0f8b7dea ]
tx_complete() calls this_cpu_ptr() before disabling preemption, which triggers a BUG when running with CONFIG_DEBUG_PREEMPT:
BUG: using smp_processor_id() in preemptible code in tx_complete
Fix by using get_cpu_ptr()/put_cpu_ptr() which disable preemption and return the per-CPU pointer atomically. The usbnet_skb_return() hunk is a hardening change: that path runs in softirq context so no warning fires there, but the same fix is applied for consistency.
--- drivers/net/usb/usbnet.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/usb/usbnet.c +6 -2
@@ -314,7 +314,7 @@ static void __usbnet_status_stop_force(struct usbnet *dev)*/ void usbnet_skb_return (struct usbnet *dev,struct sk_buff *skb) { -struct pcpu_sw_netstats *stats64 =this_cpu_ptr (dev->net->tstats); +struct pcpu_sw_netstats *stats64;unsigned long flags;int status;
@@ -327,10 +327,12 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)if (skb->protocol ==0 ) skb->protocol =eth_type_trans (skb, dev->net); + stats64 =get_cpu_ptr (dev->net->tstats); flags =u64_stats_update_begin_irqsave (&stats64->syncp); stats64->rx_packets++; stats64->rx_bytes += skb->len;u64_stats_update_end_irqrestore (&stats64->syncp, flags); +put_cpu_ptr (dev->net->tstats);netif_dbg (dev, rx_status, dev->net,"< rx, len %zu, type 0x%x\n" , skb->len +sizeof (struct ethhdr ), skb->protocol);
@@ -1224,13 +1226,15 @@ static void tx_complete (struct urb *urb)struct usbnet *dev = entry->dev;if (urb->status ==0 ) { -struct pcpu_sw_netstats *stats64 =this_cpu_ptr (dev->net->tstats); +struct pcpu_sw_netstats *stats64;unsigned long flags; + stats64 =get_cpu_ptr (dev->net->tstats); flags =u64_stats_update_begin_irqsave (&stats64->syncp); stats64->tx_packets += entry->packets; stats64->tx_bytes += entry->length;u64_stats_update_end_irqrestore (&stats64->syncp, flags); +put_cpu_ptr (dev->net->tstats); }else { dev->net->stats.tx_errors++;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1687/1848 ALSA: 6fire: take stream_mutex in the Digital Thru control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Piotr Gliźniewicz <[email protected]>
[ Upstream commit d030561d53cb272bb55ba2dd11aaa609e8240b7e ]
usb6fire_control_digital_thru_put() calls usb6fire_control_streaming_update(), which on an idle card with Digital Thru on selects altsetting 2 and writes the clock register for 96 kHz through usb6fire_control_set_rate(). usb6fire_pcm_prepare() calls both functions through usb6fire_pcm_set_rate() under rt->stream_mutex. The put does not take stream_mutex, so the two can run at the same time.
500 runs of a 0.2 s aplay at 48 kHz while a second loop toggled "Digital Thru Playback Route" with amixer (12693 on/off cycles, kernel 7.2.9): in 216 cases the two usb_set_interface() calls ran at the same time and the kernel logged "sysfs: cannot create duplicate filename '.../3-2:1.1/ep_82'" with a stack dump. 27 of the aplay runs failed, and for each of them the kernel logged "could not start pcm stream".
Take stream_mutex in the put. The pcm runtime is created before the controls and freed with the card, so chip->pcm is valid whenever the put runs. The put waits for a running prepare, which makes synchronous USB transfers under stream_mutex; on a card that responds late the wait can reach about 12 s, or 24 s with Digital Thru on, and during the wait the other controls of the card can be neither read nor written, because snd_ctl_elem_write() holds controls_rwsem around the put. Before this patch the put already made transfers of the same kind under controls_rwsem. No code that holds stream_mutex takes controls_rwsem.
The same test on kernel 7.2.10 with this patch (12863 cycles) gave no failed aplay run and no "duplicate filename" message.
--- sound/usb/6fire/control.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/usb/6fire/control.c +7 -0
@@ -20,6 +20,7 @@#include "control.h" #include "comm.h" #include "chip.h" +#include "pcm.h" static const char *const opt_coax_texts[2 ] = {"Optical" ,"Coax" };static const char *const line_phono_texts[2 ] = {"Line" ,"Phono" };
@@ -383,6 +384,12 @@ static int usb6fire_control_digital_thru_put(struct snd_kcontrol *kcontrol,struct control_runtime *rt =snd_kcontrol_chip (kcontrol);int changed =0 ; +/* +* with Digital Thru on, streaming_update() selects the altsetting and +* writes the clock register of an idle card; prepare does the same +* under stream_mutex +*/ +guard (mutex)(&rt->chip->pcm->stream_mutex);if (rt->digital_thru_switch != ucontrol->value.integer.value[0 ]) { rt->digital_thru_switch = ucontrol->value.integer.value[0 ];usb6fire_control_streaming_update (rt);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1688/1848 arch: arc: Remove CONFIG_OPROFILE support
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viresh Kumar <[email protected]>
[ Upstream commit 993b832fda6ad4f350dcc4440113ba95c05621ae ]
The "oprofile" user-space tools don't use the kernel OPROFILE support any more, and haven't in a long time. User-space has been converted to the perf interfaces.
Remove the old oprofile's architecture specific support.
Stable-dep-of: ca201ad6e92a ("ARC: Strip libgcc debug information when generating BTF")
--- arch/arc/Kconfig | 1 - arch/arc/Makefile | 2 -- arch/arc/oprofile/Makefile | 10 ---------- arch/arc/oprofile/common.c | 23 ----------------------- 4 files changed, 36 deletions(-) delete mode 100644 arch/arc/oprofile/Makefile delete mode 100644 arch/arc/oprofile/common.c
arch/arc/Kconfig +0 -1
@@ -38,7 +38,6 @@ config ARC select HAVE_KPROBES select HAVE_KRETPROBES select HAVE_MOD_ARCH_SPECIFIC - select HAVE_OPROFILE select HAVE_PERF_EVENTS select HANDLE_DOMAIN_IRQ select IRQ_DOMAIN
arch/arc/Makefile +0 -2
@@ -96,8 +96,6 @@ core-$(CONFIG_ARC_PLAT_TB10X) += arch/arc/plat-tb10x/ core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/ core-$(CONFIG_ARC_SOC_HSDK) += arch/arc/plat-hsdk/ -drivers-$(CONFIG_OPROFILE) += arch/arc/oprofile/ - libs-y += arch/arc/lib/ $(LIBGCC) boot := arch/arc/boot
arch/arc/oprofile/Makefile deleted +0 -10
@@ -1,10 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_OPROFILE) += oprofile.o - -DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ - oprof.o cpu_buffer.o buffer_sync.o \ - event_buffer.o oprofile_files.o \ - oprofilefs.o oprofile_stats.o \ - timer_int.o ) - -oprofile-y := $(DRIVER_OBJS) common.o
arch/arc/oprofile/common.c deleted +0 -23
@@ -1,23 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* -* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) -* -* Based on orig code from @author John Levon <[email protected]> -*/ - -#include <linux/oprofile.h> -#include <linux/perf_event.h> - -int __init oprofile_arch_init (struct oprofile_operations *ops) -{ -/* -* A failure here, forces oprofile core to switch to Timer based PC -* sampling, which will happen if say perf is not enabled/available -*/ -return oprofile_perf_init (ops); -} - -void oprofile_arch_exit (void ) -{ -oprofile_perf_exit (); -}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1689/1848 ARC: Strip libgcc debug information when generating BTF
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
[ Upstream commit ca201ad6e92a1924138e83ff966f7a091e3bbe6e ]
ARC links against the compiler's libgcc archive. The ARC GNU 2023.03 toolchain ships this library with debug information, including complex floating-point types in integer arithmetic helpers such as __udivdi3. These types reach vmlinux even though the kernel does not use complex floating-point arithmetic.
When floating-point BTF encoding is enabled, pahole rejects those types:
Complex, interval and imaginary float types are not supported Error while encoding BTF.
FAILED: load BTF from .tmp_vmlinux1.BTF.1: No such file or directory
KernelCI's upgrade to pahole 1.31 exposed this long-standing problem as failed ARC builds. As of 1.32, pahole still rejects these types, and older versions will stay in use, so the kernel build has to keep them out of vmlinux. Commit f122668ddcce ("ARC: Add eBPF JIT support") documented the same failure along with a workaround of disabling floating-point BTF encoding, but that also discards supported floating-point types from kernel BTF.
For CONFIG_DEBUG_INFO_BTF, generate a debug-stripped copy of the selected libgcc archive in the output tree and link that copy. Preserve the archive structure so that only needed helpers are linked, and use the normal Kbuild objcopy rule to track input and command changes. The trade-off is that vmlinux in BTF-enabled builds no longer carries DWARF for the libgcc helpers. Debug information for kernel code, the installed toolchain and non-BTF builds stay unchanged.
Reproduced and tested with ARC GCC 12.2.1 and pahole 1.31 and 1.32 using an ARCv2 tinyconfig with BPF_SYSCALL and DWARF4/BTF enabled. Before and after vmlinux.o files are identical after stripping debug information.
--- arch/arc/Makefile | 9 ++++++++- arch/arc/lib/Makefile | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
arch/arc/Makefile +8 -1
@@ -96,7 +96,14 @@ core-$(CONFIG_ARC_PLAT_TB10X) += arch/arc/plat-tb10x/ core-$(CONFIG_ARC_PLAT_AXS10X) += arch/arc/plat-axs10x/ core-$(CONFIG_ARC_SOC_HSDK) += arch/arc/plat-hsdk/ -libs-y += arch/arc/lib/ $(LIBGCC) +libs-y += arch/arc/lib/ + +ifdef CONFIG_DEBUG_INFO_BTF +export LIBGCC := $(LIBGCC) +libs-y += arch/arc/lib/libgcc.a +else +libs-y += $(LIBGCC) +endif boot := arch/arc/boot
arch/arc/lib/Makefile +8 -0
@@ -13,3 +13,11 @@ lib-$(CONFIG_ISA_ARCV2) +=memcpy-archs-unaligned.o else lib-$(CONFIG_ISA_ARCV2) +=memcpy-archs.o endif + +# libgcc can contain complex floating-point debug types unsupported by BTF. +# Strip only the debug information from a local copy of the selected archive. +always-$(CONFIG_DEBUG_INFO_BTF) += libgcc.a +OBJCOPYFLAGS_libgcc.a := --strip-debug + +$(obj)/libgcc.a: $(LIBGCC) FORCE + $(call if_changed,objcopy)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1690/1848 ASoC: codecs: da732x: Fix definition of ADC2 EQ Overall Volume control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit ebef9212cb469706e28002a20f9d48307d1fd867 ]
The ADC2 EQ overall volume is in DA732X_REG_ADC2_EQ5 (0x9F), not in DA732X_REG_ADC1_EQ5 (0x97), which holds the ADC1 one.
--- sound/soc/codecs/da732x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/da732x.c +1 -1
@@ -516,7 +516,7 @@ static const struct snd_kcontrol_new da732x_snd_controls[] = {SOC_SINGLE_TLV ("ACD2 EQ Band 5 Volume" ,DA732X_REG_ADC2_EQ5 ,DA732X_EQ_BAND5_SHIFT ,DA732X_EQ_VOL_VAL_MAX ,DA732X_INVERT , eq_band_pga_tlv), -SOC_SINGLE_TLV ("ADC2 EQ Overall Volume" ,DA732X_REG_ADC1_EQ5 , +SOC_SINGLE_TLV ("ADC2 EQ Overall Volume" ,DA732X_REG_ADC2_EQ5 ,DA732X_EQ_OVERALL_SHIFT ,DA732X_EQ_OVERALL_VOL_VAL_MAX , DA732X_INVERT, eq_overall_tlv),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1691/1848 ASoC: codecs: sta32x: Fix definition of Ch2 and Ch3 Volume Bypass controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit ea53ab9003d8655cf7e94428de3006e86fbd06a0 ]
Each channel's master volume bypass (CxVBP) is in its own configuration register, C2CFG and C3CFG, not in C1CFG, which holds the channel 1 bit.
--- sound/soc/codecs/sta32x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/sta32x.c +2 -2
@@ -468,8 +468,8 @@ SOC_SINGLE("Ch2 Tone Control Bypass Switch", STA32X_C2CFG, STA32X_CxCFG_TCB_SHIFSOC_SINGLE ("Ch1 EQ Bypass Switch" ,STA32X_C1CFG , STA32X_CxCFG_EQBP_SHIFT,1 ,0 ),SOC_SINGLE ("Ch2 EQ Bypass Switch" ,STA32X_C2CFG , STA32X_CxCFG_EQBP_SHIFT,1 ,0 ),SOC_SINGLE ("Ch1 Master Volume Bypass Switch" ,STA32X_C1CFG , STA32X_CxCFG_VBP_SHIFT,1 ,0 ), -SOC_SINGLE ("Ch2 Master Volume Bypass Switch" ,STA32X_C1CFG , STA32X_CxCFG_VBP_SHIFT,1 ,0 ), -SOC_SINGLE ("Ch3 Master Volume Bypass Switch" ,STA32X_C1CFG , STA32X_CxCFG_VBP_SHIFT,1 ,0 ), +SOC_SINGLE ("Ch2 Master Volume Bypass Switch" ,STA32X_C2CFG , STA32X_CxCFG_VBP_SHIFT,1 ,0 ), +SOC_SINGLE ("Ch3 Master Volume Bypass Switch" ,STA32X_C3CFG , STA32X_CxCFG_VBP_SHIFT,1 ,0 ),SOC_ENUM ("Ch1 Limiter Select" , sta32x_limiter_ch1_enum),SOC_ENUM ("Ch2 Limiter Select" , sta32x_limiter_ch2_enum), SOC_ENUM("Ch3 Limiter Select", sta32x_limiter_ch3_enum),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1692/1848 ASoC: codecs: sta350: Fix definition of Ch2 and Ch3 Volume Bypass controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 7308ce7c8459e994a36a22607e974e3e132a9275 ]
Each channel's master volume bypass (CxVBP) is in its own configuration register, C2CFG and C3CFG, not in C1CFG, which holds the channel 1 bit.
--- sound/soc/codecs/sta350.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/sta350.c +2 -2
@@ -485,9 +485,9 @@ SOC_SINGLE("Ch2 EQ Bypass Switch",SOC_SINGLE ("Ch1 Master Volume Bypass Switch" ,STA350_C1CFG , STA350_CxCFG_VBP_SHIFT,1 ,0 ),SOC_SINGLE ("Ch2 Master Volume Bypass Switch" , -STA350_C1CFG , STA350_CxCFG_VBP_SHIFT,1 ,0 ), +STA350_C2CFG , STA350_CxCFG_VBP_SHIFT,1 ,0 ),SOC_SINGLE ("Ch3 Master Volume Bypass Switch" , -STA350_C1CFG , STA350_CxCFG_VBP_SHIFT,1 ,0 ), +STA350_C3CFG , STA350_CxCFG_VBP_SHIFT,1 ,0 ),SOC_ENUM ("Ch1 Binary Output Select" , sta350_binary_output_ch1_enum),SOC_ENUM ("Ch2 Binary Output Select" , sta350_binary_output_ch2_enum), SOC_ENUM("Ch3 Binary Output Select", sta350_binary_output_ch3_enum),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1693/1848 calipso: update payload_len when removing the CALIPSO option
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <[email protected]>
[ Upstream commit 00accbd9d5021b942a16078bd5717d7865f6971c ]
calipso_skbuff_delattr() removes the CALIPSO option from the hop-by-hop extension header, or the whole extension header if CALIPSO is its only option, and pulls the skb by the removed length. It never updates ipv6hdr->payload_len, so after a successful removal the header still claims the original length.
calipso_skbuff_setattr() already adjusts payload_len by the length it adds; the delete path was missed.
This is reached on the forward path when a packet carrying CALIPSO is sent to a destination mapped to an unlabeled NetLabel domain. The forwarded packet then has a payload_len larger than its real payload by the removed length (8 to 264 bytes), and the receiver drops it as truncated. So removing the label on the forward path has been broken for every packet that is not resegmented later (SYN, UDP, ICMPv6...).
Adjust payload_len after the header is moved. BIG TCP packets carry payload_len == 0 (see ipv6_set_payload_len()), and ipv6_payload_len() then falls back to skb->len, so leave them alone.
Tested with client, router and server network namespaces on one kernel (arm64, QEMU): SELinux permissive with a minimal mdp-generated policy (network_peer_controls=1), "netlabelctl calipso add pass doi:16", the default NetLabel mapping left unlabeled, IPv6 forwarding on the router. The client sends 5 UDP datagrams with a CALIPSO hop-by-hop option (DOI 16, set through IPV6_HOPOPTS) to the server through the router:
before: router Ip6OutForwDatagrams 5, server receives 0,
server Ip6InTruncatedPkts 5
after: router Ip6OutForwDatagrams 5, server receives 5,
server Ip6InTruncatedPkts 0
--- net/ipv6/calipso.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv6/calipso.c +4 -0
@@ -1432,6 +1432,10 @@ static int calipso_skbuff_delattr(struct sk_buff *skb)skb_pull (skb, delta);memmove ((char *)ip6_hdr + delta, ip6_hdr, size);skb_reset_network_header (skb); + ip6_hdr =ipv6_hdr (skb); +/* BIG TCP packets have payload_len == 0 */ +if (ip6_hdr->payload_len) +be16_add_cpu (&ip6_hdr->payload_len, -delta); }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1694/1848 gre: keep the UDP tunnel GSO type when completing GRO
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brad Fitzpatrick <[email protected]>
[ Upstream commit 718f364a20ecee4f25986789c25550cf4da73b4c ]
gre_gro_complete() assigns SKB_GSO_GRE to gso_type rather than OR-ing it in. When GRE is carried over UDP by FOU or GUE, udp_gro_complete() has already set SKB_GSO_UDP_TUNNEL{,_CSUM} before calling into the FOU or GUE gro_complete handler and then gre_gro_complete(), so that bit is lost.
That has broken forwarding of such packets since FOU gained GRO: if a host with a FOU or GUE socket on the tunnel's port merges transit packets and then forwards them out a device that can't segment them itself, udp4_ufo_fragment() finds neither tunnel bit and fails, and the packets are dropped. Since commit 3d010c8031e3 ("udp: do not accept non-tunnel GSO skbs landing in a tunnel"), local receive is broken too:udp_unexpected_gso() considers the merged skb, which reaches the encapsulation socket without either UDP tunnel bit, unexpected and hands it to udp_rcv_segment(). Segmenting fails, so the packet is freed and counted in UdpInErrors. Either way, only packets GRO didn't merge get through, so TCP over FOU or GUE GRE tunnels slows to about one segment per round trip whenever the receiving device has GRO enabled.
OR in SKB_GSO_GRE instead, as ipip_gro_complete() and sit_gro_complete() do for SKB_GSO_IPXIP4. For plain GRE, gso_type is still zero at this point unless the driver set it, so nothing changes there in the usual case.
The assignment dates to commit bf5a755f5e91 ("net-gre-gro: Add GRE support to the GRO stack"), but nothing set gso_type before it until FOU GRO came along, so the Fixes tag points there.
Tested under virtme-ng with bulk TCP over a GRE tunnel between two network namespaces joined by a veth, with GRO on the receiving veth and segmentation off on the sending one, so GRO sees wire-sized packets. 32 MiB took:
before after FOU over IPv4 26.0s, 9658 UDP errors 0.28s, 0 errors GUE over IPv4 26.1s, 9686 UDP errors 0.39s, 0 errors FOU over IPv6 26.4s, 9860 UDP errors 0.16s, 0 errors plain GRE 0.17s 0.15s
Forwarding the same FOU traffic through a third namespace with its own FOU socket on the port, GRO on its ingress and segmentation off on its egress, took 26.0s with 4826 egress drops before and 0.31s with none after. On v6.8, before 3d010c8031e3, local receive was fine but forwarding failed the same way (25.7s, 4764 drops).
With GRO off on the receiver, all took under 0.2s both before and after. The gre_gso.sh and fou_mcast_encap.sh selftests give the same results before and after.
--- net/ipv4/gre_offload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/gre_offload.c +1 -1
@@ -239,7 +239,7 @@ static int gre_gro_complete(struct sk_buff *skb, int nhoff)__be16 type; skb->encapsulation =1 ; -skb_shinfo (skb)->gso_type =SKB_GSO_GRE ; +skb_shinfo (skb)->gso_type |=SKB_GSO_GRE ; type = greh->protocol;if (greh->flags &GRE_KEY )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1695/1848 bpf: Fix verifier WARN on narrow read of bpf_tcp_sock u64 fields
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit af873495cbcb066ab029f7f63b94410d4db47628 ]
A BPF program can read the middle of a u64 field in struct bpf_tcp_sock:
tp = bpf_tcp_sock(listener); /* +0x54 is in the middle of the u64 bytes_received */ unsigned hi = *(unsigned *)((char *)tp + 0x54);
bpf_tcp_sock_is_valid_access() allows this 4-byte read (the default case only checks size == 4), but bpf_tcp_sock_convert_ctx_access() only knows the field starts and has no idea how to handle such an offset. It emits no instruction, cnt stays 0 and the fixup pass trips verifier_bug():
verifier bug: error during ctx access conversion (0)
Just disallow the narrower access by matching the whole u64 range of the two fields, so it is turned down at check time:
invalid tcp_sock access off=84 size=4
--- net/core/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/filter.c +2 -2
@@ -6384,8 +6384,8 @@ bool bpf_tcp_sock_is_valid_access(int off, int size, enum bpf_access_type type,return false;switch (off) { -case offsetof(struct bpf_tcp_sock , bytes_received): -case offsetof(struct bpf_tcp_sock , bytes_acked): + case bpf_ctx_range(struct bpf_tcp_sock, bytes_received): + case bpf_ctx_range(struct bpf_tcp_sock, bytes_acked):return size ==sizeof (__u64);default :return size ==sizeof (__u32);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1696/1848 bpf: Validate the SRH which End.DT6 uncovers in End.BPF
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit e8b084646b946cc6f7976365588035947a296184 ]
input_action_end_bpf() validates the SRH of a packet and pulls it into the head before the program runs. If the program decapsulates the packet with bpf_lwt_seg6_action(SEG6_LOCAL_ACTION_END_DT6), bpf_update_srh_state() looks for a routing header in the inner packet and takes it for the new SRH as it is.
Nobody has looked at that header, and whoever has sent the packet has written it. ipv6_find_hdr() finds it in a fragment of the skb as well, but hdrlen is then read at that offset from skb->data, past the end of the head. The header need not be an SRH, and its hdrlen need not fit into the packet, but it is marked as valid, and bpf_lwt_seg6_adjust_srh() and bpf_lwt_seg6_store_bytes() check their offsets against it.
A program which then adds a TLV at the end of the SRH, where hdrlen has it, makes bpf_lwt_seg6_adjust_srh() move and write memory behind the head of the skb, as far as the sender likes within the 2 KB that hdrlen can say:
BUG: KASAN: slab-out-of-bounds in bpf_skb_net_hdr_push+0x185/0x240 Read of size 2088 at addr ffff888107d6f09e by task srh/102 BUG: KASAN: slab-out-of-bounds in bpf_skb_net_hdr_push+0x1b5/0x240 Write of size 8 at addr ffff888107d6f8be by task srh/102
Use seg6_get_srh(), which pulls and validates the header. Without a valid SRH the state says that there is none, and the packet goes its way as before. The pull can move the head, so compute the data pointers behind it.
--- net/core/filter.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/core/filter.c +5 -5
@@ -5862,15 +5862,15 @@ static void bpf_update_srh_state(struct sk_buff *skb) {struct seg6_bpf_srh_state *srh_state =this_cpu_ptr (&seg6_bpf_srh_states); -int srhoff =0 ; -if (ipv6_find_hdr (skb, &srhoff,IPPROTO_ROUTING ,NULL ,NULL ) <0 ) { - srh_state->srh =NULL ; - }else { - srh_state->srh = (struct ipv6_sr_hdr *)(skb->data + srhoff); +/* Behind a decapsulation this is a header that nobody has looked at */ + srh_state->srh =seg6_get_srh (skb,0 ); +if (srh_state->srh) { srh_state->hdrlen = srh_state->srh->hdrlen <<3 ; srh_state->valid = true; } +/* it may have been pulled into the head */ +bpf_compute_data_pointers (skb); } BPF_CALL_4(bpf_lwt_seg6_action, struct sk_buff *, skb,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1697/1848 bpf: Pull the inner header for End.DT6 in End.BPF
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 434324c611a98bc76dc850d45d67756dae5622cf ]
bpf_lwt_seg6_action(SEG6_LOCAL_ACTION_END_DT6) pulls the outer headers off the packet and hands it to seg6_lookup_nexthop(), which reads the inner IPv6 header at skb->data. Nothing says that this header is in the head of the skb, or that there is one. If the head ends with the outer headers, the route is looked up for whatever lies behind the head, and the packet is dropped or leaves by the wrong route. If the program then pushes an SRH with SEG6_LOCAL_ACTION_END_B6, seg6_do_srh_inline() pulls an IPv6 header off a head which has none, and __skb_pull() hits its BUG(): the kernel panics on a packet from the network.
GRO pulls the inner header of a plain IPv6 in IPv6 packet into the head. It takes a packet which GRO does not look into that far, one with a fragment header in front of the inner header for example, or a device without GRO, and a driver which leaves the inner header in a fragment.
Make sure of the inner header together with the outer ones. The program goes on behind an error of the helper, so do it before the packet is changed. A pull which fails can still have moved the head, so look for the SRH again.
--- net/core/filter.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/core/filter.c +6 -1
@@ -5902,9 +5902,14 @@ BPF_CALL_4(bpf_lwt_seg6_action, struct sk_buff *, skb,if (ipv6_find_hdr (skb, &hdroff,IPPROTO_IPV6 ,NULL ,NULL ) <0 )return -EBADMSG ; -if (!pskb_pull (skb, hdroff)) +/* As long as nothing has been changed, the program goes on */ +if (!pskb_may_pull (skb, hdroff +sizeof (struct ipv6hdr ))) { +/* but the head may have moved */ +bpf_update_srh_state (skb);return -EBADMSG ; + } +__skb_pull (skb, hdroff);skb_postpull_rcsum (skb,skb_network_header (skb), hdroff);skb_reset_network_header (skb);skb_reset_transport_header (skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1698/1848 bpf: Update the SRH state if End.B6 fails late
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 427e751a231aa781441d51c42e716905ee348099 ]
For SEG6_LOCAL_ACTION_END_B6 and END_B6_ENCAP bpf_lwt_seg6_action() looks for the SRH again only if bpf_push_seg6_encap() has succeeded. That function pushes the new header, for which the head of the skb is reallocated if it has not got the room, and then looks up the route to the first segment. If there is none, it returns an error, and the pointer to the SRH in seg6_bpf_srh_states still points into the old head, which has been freed.
The program goes on behind the error. bpf_lwt_seg6_store_bytes() and bpf_lwt_seg6_adjust_srh() read the SRH through that pointer.
Look for the SRH whatever bpf_push_seg6_encap() says.
--- net/core/filter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/core/filter.c +4 -4
@@ -5923,8 +5923,8 @@ BPF_CALL_4(bpf_lwt_seg6_action, struct sk_buff *, skb,return -EBADMSG ; err =bpf_push_seg6_encap (skb,BPF_LWT_ENCAP_SEG6_INLINE , param, param_len); -if (!err) -bpf_update_srh_state (skb); +/* The header can be in place although err says otherwise */ +bpf_update_srh_state (skb);return err;case SEG6_LOCAL_ACTION_END_B6_ENCAP :
@@ -5932,8 +5932,8 @@ BPF_CALL_4(bpf_lwt_seg6_action, struct sk_buff *, skb,return -EBADMSG ; err =bpf_push_seg6_encap (skb,BPF_LWT_ENCAP_SEG6 , param, param_len); -if (!err) -bpf_update_srh_state (skb); +/* The header can be in place although err says otherwise */ +bpf_update_srh_state (skb);return err;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1699/1848 bpf: Bound the nesting that the BTF show code follows
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 13ac7c05bc45d3445b580da186548dd3487fae4e ]
btf_struct_show() and btf_array_show() recurse for every nested struct and array. MAX_RESOLVE_DEPTH bounds one resolve walk when BTF is loaded, not the nesting: a member whose type is resolved already is not walked again, so BTF that defines its types from the inside out can nest them as deep as it has types.
Whoever may load BTF, with CAP_BPF or a BPF token, can give such a type to the value of a map. Reading the file of that map in bpffs then overruns the kernel stack: with a few hundred levels the stack guard page is hit and the kernel panics.
Stop at 32 levels. That is MAX_RESOLVE_DEPTH, and __btf_show_indent() has as many columns. Nothing is shown for a member that lies deeper, and the status becomes -E2BIG, which bpf_snprintf_btf() and bpf_seq_printf_btf() return. The types of an x86_64 defconfig kernel nest 14 deep.
--- kernel/bpf/btf.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
kernel/bpf/btf.c +13 -1
@@ -751,6 +751,8 @@ static const struct btf_type *btf_type_skip_qualifiers(const struct btf *btf, }#define BTF_SHOW_MAX_ITER 10 +/* nested structs and arrays shown; __btf_show_indent() has as many columns */ +#define BTF_SHOW_MAX_DEPTH 32#define BTF_KIND_BIT (kind) (1ULL << kind)
@@ -1142,8 +1144,18 @@ static void *btf_show_start_aggr_type(struct btf_show *show,const struct btf_type *t, u32 type_id, void *data) { - void *safe_data = btf_show_start_type(show, t, type_id, data); + void *safe_data; +/* +* Structs and arrays are shown by recursion. BTF loading bounds the +* depth of one resolve walk, not how deep resolved types may nest. +*/ +if (show->state.depth >=BTF_SHOW_MAX_DEPTH ) { + show->state.status = -E2BIG ; +return NULL ; + } + + safe_data =btf_show_start_type (show, t, type_id, data);if (!safe_data)return safe_data;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1700/1848 bpf: Dont take an extension for an iterator program
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 7cc639dc45c5d3b69acb2a2fc834e9eec51e0214 ]
An extension inherits the expected_attach_type of the program it extends. If that is BPF_TRACE_ITER, check_attach_btf_id() hands the extension to bpf_iter_prog_supported(), which goes by the name of the attach function. For an extension that is the name of the subprogram it replaces, so the load fails with -EINVAL, unless that subprogram is called like the function of a target, bpf_iter_bpf_map_elem for example.
Then the extension gets the context of that target. If the subprogram has as many arguments, it can use the key and the value as buffers, but how far it reaches is noted in the extension, where the test of the iterator link does not look: it reads and writes behind the elements of the map. And the id of the subprogram in the BTF of the program is cached as the id of the target, so that programs of that target which are loaded already cannot be attached.
Refuse all extensions here.
--- kernel/bpf/bpf_iter.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/bpf/bpf_iter.c +7 -0
@@ -321,6 +321,13 @@ bool bpf_iter_prog_supported(struct bpf_prog *prog)int prefix_len =strlen (prefix);bool supported = false; +/* +* The attach function of an extension is a subprogram of the iterator +* program that it extends, whatever its name is. +*/ +if (prog->type ==BPF_PROG_TYPE_EXT ) +return -EINVAL ; +if (strncmp (attach_fname, prefix, prefix_len))return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1701/1848 netfilter: conntrack: fix unlikely UaF in gc worker
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 9836164821a46af07428bb2a5e14137bf0c7bd6e ]
When early-drop scan is enabled, gc_worker() reads tmp->ct_net, resolves cnet with nf_ct_pernet(), and reads cnet->count with RCU read lock held but before acquiring a reference to tmp.
Its unlikely but possible that the worker gets preempted before reading cnet->count while nf_conntrack_cleanup_net_list manages to unlink all conntracks and returns in the mean time.
This allows for the pernet memory to get free'd.
On resume, use after free would occur when the worker reads cnet->count.
This can be solved either via another synchronize_rcu() in nf_conntrack_cleanup_net_list or via cheaper flush_work(). If work wasn't running no race can happen as next call cannot observe already-unlinked conntrack objects.
This is an LLM finding with no reproducer, but it appears to be correct.
--- net/netfilter/nf_conntrack_core.c | 5 +++++ 1 file changed, 5 insertions(+)
net/netfilter/nf_conntrack_core.c +5 -0
@@ -2457,6 +2457,11 @@ void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list) goto i_see_dead_people; } +/* must wait for current scan loop, worker also looks at +* struct nf_conntrack_net, which is about to be free'd. +*/ +flush_work (&conntrack_gc_work.dwork.work); +list_for_each_entry (net, net_exit_list, exit_list) {nf_conntrack_proto_pernet_fini (net);nf_conntrack_ecache_pernet_fini (net);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1702/1848 selftests: netfilter: conntrack_vrf.sh: move to lib.sh infra
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 954398b4d83759244656d37b4b626e912dc0969c ]
swap test for "ip" with "conntrack", former is already accounted for via setup_ns helper. Also switch to bash.
Stable-dep-of: a20a01ae8981 ("selftests: netfilter: fix return value in zone subtest")
--- .../selftests/netfilter/conntrack_vrf.sh | 101 +++++++----------- 1 file changed, 39 insertions(+), 62 deletions(-)
tools/testing/selftests/netfilter/conntrack_vrf.sh +39 -62
@@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # This script demonstrates interaction of conntrack and vrf. # The vrf driver calls the netfilter hooks again, with oif/iif
@@ -28,84 +28,65 @@ # that was supposed to be fixed by the commit mentioned above to make sure # that any fix to test case 1 won't break masquerade again. -ksft_skip=4 +source lib.sh IP0=172.30.30.1 IP1=172.30.30.2 PFXL=30 ret=0 -sfx=$(mktemp -u "XXXXXXXX") -ns0="ns0-$sfx" -ns1="ns1-$sfx" - cleanup() { ip netns pids $ns0 | xargs kill 2>/dev/null ip netns pids $ns1 | xargs kill 2>/dev/null - ip netns del $ns0 $ns1 + cleanup_all_ns } -nft --version > /dev/null 2>&1 -if [ $? -ne 0 ];then +if ! nft --version > /dev/null 2>&1;then echo "SKIP: Could not run test without nft tool" exit $ksft_skip fi -ip -Version > /dev/null 2>&1 -if [ $? -ne 0 ];then - echo "SKIP: Could not run test without ip tool" - exit $ksft_skip -fi - -ip netns add "$ns0" -if [ $? -ne 0 ];then - echo "SKIP: Could not create net namespace $ns0" +if ! conntrack --version > /dev/null 2>&1;then + echo "SKIP: Could not run test without conntrack tool" exit $ksft_skip fi -ip netns add "$ns1" trap cleanup EXIT -ip netns exec $ns0 sysctl -q -w net.ipv4.conf.default.rp_filter=0 -ip netns exec $ns0 sysctl -q -w net.ipv4.conf.all.rp_filter=0 -ip netns exec $ns0 sysctl -q -w net.ipv4.conf.all.rp_filter=0 +setup_ns ns0 ns1 -ip link add veth0 netns "$ns0" type veth peer name veth0 netns "$ns1" > /dev/null 2>&1 -if [ $? -ne 0 ];then +ip netns exec "$ns0" sysctl -q -w net.ipv4.conf.default.rp_filter=0 +ip netns exec "$ns0" sysctl -q -w net.ipv4.conf.all.rp_filter=0 +ip netns exec "$ns0" sysctl -q -w net.ipv4.conf.all.rp_filter=0 + +if ! ip link add veth0 netns "$ns0" type veth peer name veth0 netns "$ns1" > /dev/null 2>&1; then echo "SKIP: Could not add veth device" exit $ksft_skip fi -ip -net $ns0 li add tvrf type vrf table 9876 -if [ $? -ne 0 ];then +if ! ip -net "$ns0" li add tvrf type vrf table 9876; then echo "SKIP: Could not add vrf device" exit $ksft_skip fi -ip -net $ns0 li set lo up - -ip -net $ns0 li set veth0 master tvrf -ip -net $ns0 li set tvrf up -ip -net $ns0 li set veth0 up -ip -net $ns1 li set veth0 up +ip -net "$ns0" li set veth0 master tvrf +ip -net "$ns0" li set tvrf up +ip -net "$ns0" li set veth0 up +ip -net "$ns1" li set veth0 up -ip -net $ns0 addr add $IP0/$PFXL dev veth0 -ip -net $ns1 addr add $IP1/$PFXL dev veth0 +ip -net "$ns0" addr add $IP0/$PFXL dev veth0 +ip -net "$ns1" addr add $IP1/$PFXL dev veth0 -ip netns exec $ns1 iperf3 -s > /dev/null 2>&1& -if [ $? -ne 0 ];then - echo "SKIP: Could not start iperf3" - exit $ksft_skip -fi +ip netns exec "$ns1" iperf3 -s > /dev/null 2>&1 & # test vrf ingress handling. # The incoming connection should be placed in conntrack zone 1, # as decided by the first iteration of the ruleset. test_ct_zone_in() { -ip netns exec $ns0 nft -f - <<EOF +ip netns exec "$ns0" nft -f - <<EOF table testct { chain rawpre { type filter hook prerouting priority raw;
@@ -126,21 +107,21 @@ table testct { } } EOF - ip netns exec $ns1 ping -W 1 -c 1 -I veth0 $IP0 > /dev/null + ip netns exec "$ns1" ping -W 1 -c 1 -I veth0 "$IP0" > /dev/null # should be in zone 1, not zone 2 - count=$(ip netns exec $ns0 conntrack -L -s $IP1 -d $IP0 -p icmp --zone 1 2>/dev/null | wc -l) - if [ $count -eq 1 ]; then + count=$(ip netns exec "$ns0" conntrack -L -s $IP1 -d $IP0 -p icmp --zone 1 2>/dev/null | wc -l) + if [ "$count" -eq 1 ]; then echo "PASS: entry found in conntrack zone 1" else echo "FAIL: entry not found in conntrack zone 1" - count=$(ip netns exec $ns0 conntrack -L -s $IP1 -d $IP0 -p icmp --zone 2 2> /dev/null | wc -l) - if [ $count -eq 1 ]; then + count=$(ip netns exec "$ns0" conntrack -L -s $IP1 -d $IP0 -p icmp --zone 2 2> /dev/null | wc -l) + if [ "$count" -eq 1 ]; then echo "FAIL: entry found in zone 2 instead" else echo "FAIL: entry not in zone 1 or 2, dumping table" - ip netns exec $ns0 conntrack -L - ip netns exec $ns0 nft list ruleset + ip netns exec "$ns0" conntrack -L + ip netns exec "$ns0" nft list ruleset fi fi }
@@ -153,12 +134,12 @@ test_masquerade_vrf() local qdisc=$1 if [ "$qdisc" != "default" ]; then - tc -net $ns0 qdisc add dev tvrf root $qdisc + tc -net "$ns0" qdisc add dev tvrf root "$qdisc" fi - ip netns exec $ns0 conntrack -F 2>/dev/null + ip netns exec "$ns0" conntrack -F 2>/dev/null -ip netns exec $ns0 nft -f - <<EOF +ip netns exec "$ns0" nft -f - <<EOF flush ruleset table ip nat { chain rawout {
@@ -179,17 +160,15 @@ table ip nat { } } EOF - ip netns exec $ns0 ip vrf exec tvrf iperf3 -t 1 -c $IP1 >/dev/null - if [ $? -ne 0 ]; then + if ! ip netns exec "$ns0" ip vrf exec tvrf iperf3 -t 1 -c $IP1 >/dev/null; then echo "FAIL: iperf3 connect failure with masquerade + sport rewrite on vrf device" ret=1 return fi # must also check that nat table was evaluated on second (lower device) iteration. - ip netns exec $ns0 nft list table ip nat |grep -q 'counter packets 2' && - ip netns exec $ns0 nft list table ip nat |grep -q 'untracked counter packets [1-9]' - if [ $? -eq 0 ]; then + ip netns exec "$ns0" nft list table ip nat |grep -q 'counter packets 2' && + if ip netns exec "$ns0" nft list table ip nat |grep -q 'untracked counter packets [1-9]'; then echo "PASS: iperf3 connect with masquerade + sport rewrite on vrf device ($qdisc qdisc)" else echo "FAIL: vrf rules have unexpected counter value"
@@ -197,7 +176,7 @@ EOF fi if [ "$qdisc" != "default" ]; then - tc -net $ns0 qdisc del dev tvrf root + tc -net "$ns0" qdisc del dev tvrf root fi }
@@ -206,8 +185,8 @@ EOF # oifname is the lower device (veth0 in this case). test_masquerade_veth() { - ip netns exec $ns0 conntrack -F 2>/dev/null -ip netns exec $ns0 nft -f - <<EOF + ip netns exec "$ns0" conntrack -F 2>/dev/null +ip netns exec "$ns0" nft -f - <<EOF flush ruleset table ip nat { chain postrouting {
@@ -216,16 +195,14 @@ table ip nat { } } EOF - ip netns exec $ns0 ip vrf exec tvrf iperf3 -t 1 -c $IP1 > /dev/null - if [ $? -ne 0 ]; then + if ! ip netns exec "$ns0" ip vrf exec tvrf iperf3 -t 1 -c $IP1 > /dev/null; then echo "FAIL: iperf3 connect failure with masquerade + sport rewrite on veth device" ret=1 return fi # must also check that nat table was evaluated on second (lower device) iteration. - ip netns exec $ns0 nft list table ip nat |grep -q 'counter packets 2' - if [ $? -eq 0 ]; then + if ip netns exec "$ns0" nft list table ip nat |grep -q 'counter packets 2'; then echo "PASS: iperf3 connect with masquerade + sport rewrite on veth device" else echo "FAIL: vrf masq rule has unexpected counter value"
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1703/1848 selftests: netfilter: conntrack_vrf.sh: prefer socat, not iperf3
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 99bc5950ebd4f84e48b5d1c53c13cf117031de82 ]
Use socat, like most of the other scripts already do. This also makes the script complete slightly faster (3s -> 1s).
iperf3 establishes two connections (1 control connection, and 1+x depending on test), so adjust expected counter values as well.
Stable-dep-of: a20a01ae8981 ("selftests: netfilter: fix return value in zone subtest")
--- .../selftests/netfilter/conntrack_vrf.sh | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-)
tools/testing/selftests/netfilter/conntrack_vrf.sh +21 -19
@@ -43,15 +43,9 @@ cleanup() cleanup_all_ns } -if ! nft --version > /dev/null 2>&1;then - echo "SKIP: Could not run test without nft tool" - exit $ksft_skip -fi - -if ! conntrack --version > /dev/null 2>&1;then - echo "SKIP: Could not run test without conntrack tool" - exit $ksft_skip -fi +checktool "nft --version" "run test without nft" +checktool "conntrack --version" "run test without conntrack" +checktool "socat -h" "run test without socat" trap cleanup EXIT
@@ -79,7 +73,15 @@ ip -net "$ns1" li set veth0 up ip -net "$ns0" addr add $IP0/$PFXL dev veth0 ip -net "$ns1" addr add $IP1/$PFXL dev veth0 -ip netns exec "$ns1" iperf3 -s > /dev/null 2>&1 & +listener_ready() +{ + local ns="$1" + + ss -N "$ns" -l -n -t -o "sport = :55555" | grep -q "55555" +} + +ip netns exec "$ns1" socat -u -4 TCP-LISTEN:55555,reuseaddr,fork STDOUT > /dev/null & +busywait $BUSYWAIT_TIMEOUT listener_ready "$ns1" # test vrf ingress handling. # The incoming connection should be placed in conntrack zone 1,
@@ -160,16 +162,16 @@ table ip nat { } } EOF - if ! ip netns exec "$ns0" ip vrf exec tvrf iperf3 -t 1 -c $IP1 >/dev/null; then - echo "FAIL: iperf3 connect failure with masquerade + sport rewrite on vrf device" + if ! ip netns exec "$ns0" ip vrf exec tvrf socat -u -4 STDIN TCP:"$IP1":55555 < /dev/null > /dev/null;then + echo "FAIL: connect failure with masquerade + sport rewrite on vrf device" ret=1 return fi # must also check that nat table was evaluated on second (lower device) iteration. - ip netns exec "$ns0" nft list table ip nat |grep -q 'counter packets 2' && - if ip netns exec "$ns0" nft list table ip nat |grep -q 'untracked counter packets [1-9]'; then - echo "PASS: iperf3 connect with masquerade + sport rewrite on vrf device ($qdisc qdisc)" + if ip netns exec "$ns0" nft list table ip nat |grep -q 'counter packets 1' && + ip netns exec "$ns0" nft list table ip nat |grep -q 'untracked counter packets [1-9]'; then + echo "PASS: connect with masquerade + sport rewrite on vrf device ($qdisc qdisc)" else echo "FAIL: vrf rules have unexpected counter value" ret=1
@@ -195,15 +197,15 @@ table ip nat { } } EOF - if ! ip netns exec "$ns0" ip vrf exec tvrf iperf3 -t 1 -c $IP1 > /dev/null; then - echo "FAIL: iperf3 connect failure with masquerade + sport rewrite on veth device" + if ! ip netns exec "$ns0" ip vrf exec tvrf socat -u -4 STDIN TCP:"$IP1":55555 < /dev/null > /dev/null;then + echo "FAIL: connect failure with masquerade + sport rewrite on veth device" ret=1 return fi # must also check that nat table was evaluated on second (lower device) iteration. - if ip netns exec "$ns0" nft list table ip nat |grep -q 'counter packets 2'; then - echo "PASS: iperf3 connect with masquerade + sport rewrite on veth device" + if ip netns exec "$ns0" nft list table ip nat |grep -q 'counter packets 1'; then + echo "PASS: connect with masquerade + sport rewrite on veth device" else echo "FAIL: vrf masq rule has unexpected counter value" ret=1
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1704/1848 selftests: netfilter: fix return value in zone subtest
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit a20a01ae89813ef493dc416d69f2b2ad17afb54c ]
zone subtest prints FAIL, but did not set 'ret=1', so kselftest framework reports success.
While at it, also fail when "nft -f" returns an error.
Noticed thanks to a (broken) local patch that should have caused this selftest (resp. the kselftest framework) to report a failure.
--- .../selftests/netfilter/conntrack_vrf.sh | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
tools/testing/selftests/netfilter/conntrack_vrf.sh +22 -3
@@ -88,7 +88,7 @@ busywait $BUSYWAIT_TIMEOUT listener_ready "$ns1" # as decided by the first iteration of the ruleset. test_ct_zone_in() { -ip netns exec "$ns0" nft -f - <<EOF +if ! ip netns exec "$ns0" nft -f - <<EOF table testct { chain rawpre { type filter hook prerouting priority raw;
@@ -109,6 +109,12 @@ table testct { } } EOF + then + echo "FAIL: cannot load testct nft ruleset" + ret=1 + return + fi + ip netns exec "$ns1" ping -W 1 -c 1 -I veth0 "$IP0" > /dev/null # should be in zone 1, not zone 2
@@ -117,6 +123,7 @@ EOF echo "PASS: entry found in conntrack zone 1" else echo "FAIL: entry not found in conntrack zone 1" + ret=1 count=$(ip netns exec "$ns0" conntrack -L -s $IP1 -d $IP0 -p icmp --zone 2 2> /dev/null | wc -l) if [ "$count" -eq 1 ]; then echo "FAIL: entry found in zone 2 instead"
@@ -141,7 +148,7 @@ test_masquerade_vrf() ip netns exec "$ns0" conntrack -F 2>/dev/null -ip netns exec "$ns0" nft -f - <<EOF +if ! ip netns exec "$ns0" nft -f - <<EOF flush ruleset table ip nat { chain rawout {
@@ -162,6 +169,12 @@ table ip nat { } } EOF + then + echo "FAIL: cannot load ip nat nft ruleset" + ret=1 + return + fi + if ! ip netns exec "$ns0" ip vrf exec tvrf socat -u -4 STDIN TCP:"$IP1":55555 < /dev/null > /dev/null;then echo "FAIL: connect failure with masquerade + sport rewrite on vrf device" ret=1
@@ -188,7 +201,7 @@ EOF test_masquerade_veth() { ip netns exec "$ns0" conntrack -F 2>/dev/null -ip netns exec "$ns0" nft -f - <<EOF +if ! ip netns exec "$ns0" nft -f - <<EOF flush ruleset table ip nat { chain postrouting {
@@ -197,6 +210,12 @@ table ip nat { } } EOF + then + echo "FAIL: cannot load ip nat postrouting ruleset" + ret=1 + return + fi + if ! ip netns exec "$ns0" ip vrf exec tvrf socat -u -4 STDIN TCP:"$IP1":55555 < /dev/null > /dev/null;then echo "FAIL: connect failure with masquerade + sport rewrite on veth device" ret=1
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1705/1848 netfilter: nft_compat: restrict raw table targets/matches
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit ac364eb4d6d747b15df17e5fc9e442c318afaaac ]
xt targets and matches declaring .table = "raw" (CT, NOTRACK) rely on only ever running in the legacy raw table's prerouting/output chains, ahead of conntrack. nft_compat_chain_validate_dependency() already enforces this kind of correspondence for "nat" by requiring the chain type to actually be NAT, but did nothing for "raw": a rule wrapping the CT target could be loaded into any hook and any priority via nft_compat, including after the real conntrack hook has already run.
The CT target attaches a conntrack template to the skb when none is set yet.
Require that a "raw" table dependency actually matches what xtables enforces via the implict/builtin table dependency.
--- net/netfilter/nft_compat.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
net/netfilter/nft_compat.c +15 -0
@@ -14,6 +14,7 @@#include <linux/netfilter/nf_tables.h> #include <linux/netfilter/nf_tables_compat.h> #include <linux/netfilter/x_tables.h> +#include <linux/netfilter_ipv4.h> #include <linux/netfilter_ipv4/ip_tables.h> #include <linux/netfilter_ipv6/ip6_tables.h> #include <linux/netfilter_bridge/ebtables.h>
@@ -44,6 +45,20 @@ static int nft_compat_chain_validate_dependency(const struct nft_ctx *ctx, type =NFT_CHAIN_T_NAT ;if (basechain->type->type != type)return -EINVAL ; + }else if (strcmp (tablename,"raw" ) ==0 ) { +/* iptables-nft emulates the legacy raw table, which only +* ever has prerouting/output chains at this exact priority. +*/ +if (ctx->family !=NFPROTO_IPV4 && + ctx->family !=NFPROTO_IPV6 ) +return -EINVAL ; + +if (basechain->ops.hooknum !=NF_INET_PRE_ROUTING && + basechain->ops.hooknum !=NF_INET_LOCAL_OUT ) +return -EINVAL ; + +if (basechain->ops.priority !=NF_IP_PRI_RAW ) +return -EINVAL ; }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1706/1848 bpf: Dont take a program with a target program for an iterator
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <[email protected]>
[ Upstream commit b83bacf2161d0f8583e3f1e9c90402638992ad82 ]
bpf_iter_prog_supported() goes by the name of the attach function. Commit 7cc639dc45c5 ("bpf: Don't take an extension for an iterator program") keeps out extensions, for which that is the name of a function of another program. A tracing program with BPF_TRACE_ITER that is loaded with attach_prog_fd gets there as well: unlike for BPF_TRACE_RAW_TP, bpf_check_attach_target() does not mind the target program.
If the function is called like that of an iterator target, bpf_iter_bpf_map for example, its id in the BTF of the program is cached as the id of the target, even if the load fails later. Programs of that target which are loaded already cannot be attached any more. And the program itself can be attached as an iterator of that target, with a context that the verifier has taken from the prototype of that function:
BUG: KASAN: stack-out-of-bounds in bpf_prog_66d4234e2e50f5b6_ts26_forged+0x12a/0x20b Read of size 8 at addr ffffc90000d9fc48 by task ts26/104
Refuse every program that has a target program. That covers extensions.
--- kernel/bpf/bpf_iter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/bpf_iter.c +3 -3
@@ -322,10 +322,10 @@ bool bpf_iter_prog_supported(struct bpf_prog *prog)bool supported = false;/* -* The attach function of an extension is a subprogram of the iterator -* program that it extends, whatever its name is. +* The attach function of a program that has a target program is a +* function of that program, whatever its name is. */ -if (prog->type ==BPF_PROG_TYPE_EXT ) +if (prog->aux->dst_prog)return -EINVAL ;if (strncmp (attach_fname, prefix, prefix_len))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1707/1848 usb: gadget: dummy_hcd: fix SuperSpeed ep0 maxpacket
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Skalkin <[email protected]>
[ Upstream commit e68f245bcb1f863aeb8eab617bd06878c078029a ]
For USB_SPEED_SUPER, dummy_hcd sets ep0 maxpacket to 9. That is incorrect for SuperSpeed ep0 and breaks short packet handling in control transfer tests.
Set ep0 maxpacket to 512 for SuperSpeed.
--- drivers/usb/gadget/udc/dummy_hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/dummy_hcd.c +1 -1
@@ -912,7 +912,7 @@ static int dummy_set_selfpowered(struct usb_gadget *_gadget, int value)static void dummy_udc_update_ep0 (struct dummy *dum) {if (dum->gadget.speed ==USB_SPEED_SUPER ) - dum->ep[0 ].ep.maxpacket =9 ; + dum->ep[0 ].ep.maxpacket =512 ;else dum->ep[0 ].ep.maxpacket =64 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1708/1848 usb: gadget: dummy_hcd: prevent unbind via sysfs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Nogikh <[email protected]>
[ Upstream commit bdf12cde30830d46a8ef1ba93986356f1164b4f1 ]
The dummy_hcd (Host Controller) and dummy_udc (Device Controller) are implemented as two separate platform drivers that share the same underlying state (struct dummy). They are designed to be created and destroyed together during the module's init and exit phases.
If userspace forces the dummy_hcd driver to unbind from the device via sysfs, dummy_hcd_remove() cleans up the host controllers and sets the pointers to NULL (dum->hs_hcd = NULL). However, the dummy_udc driver is still bound to its device, meaning the USB gadget is still registered with the udc-core subsystem.
If a new gadget driver is subsequently registered, it binds to the still-registered dummy_udc gadget, invoking the dummy_udc_start() callback. This callback attempts to retrieve the HCD state using gadget_to_dummy_hcd(), which returns NULL because of the unbind. This results in a null-pointer dereference:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] ... RIP: 0010:dummy_udc_start+0xd0/0x1f0 drivers/usb/gadget/udc/dummy_hcd.c:1022 ... Call Trace: <TASK> usb_gadget_udc_start_locked drivers/usb/gadget/udc/core.c:1237 [inline] gadget_bind_driver+0x3a8/0x9e0 drivers/usb/gadget/udc/core.c:1667 call_driver_probe drivers/base/dd.c:-1 [inline] really_probe+0x254/0xae0 drivers/base/dd.c:706 __driver_probe_device+0x1e8/0x360 drivers/base/dd.c:868 driver_probe_device+0x4f/0x240 drivers/base/dd.c:898 __driver_attach+0x339/0x600 drivers/base/dd.c:1292 bus_for_each_dev+0x23b/0x2c0 drivers/base/bus.c:383 bus_add_driver+0x345/0x670 drivers/base/bus.c:763 driver_register+0x23a/0x320 drivers/base/driver.c:174 usb_gadget_register_driver_owner+0xf9/0x270 drivers/usb/gadget/udc/core.c:1752 raw_ioctl_run drivers/usb/gadget/legacy/raw_gadget.c:596 [inline] raw_ioctl+0x1541/0x41c0 drivers/usb/gadget/legacy/raw_gadget.c:1307
Adding NULL checks to the UDC callbacks is not a robust solution because there is no synchronization between dummy_hcd_remove() and the UDC callbacks, which would result in a use-after-free race condition if the HCD were unbound concurrently.
Fix this by setting .suppress_bind_attrs = true in both driver definitions. This prevents userspace from unbinding these drivers dynamically, ensuring their lifecycles remain strictly synchronized with the module's load/unload process.
--- drivers/usb/gadget/udc/dummy_hcd.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/gadget/udc/dummy_hcd.c +2 -0
@@ -1171,6 +1171,7 @@ static struct platform_driver dummy_udc_driver = { .resume = dummy_udc_resume, .driver = { .name = gadget_name, + .suppress_bind_attrs = true, }, };
@@ -2778,6 +2779,7 @@ static struct platform_driver dummy_hcd_driver = { .resume = dummy_hcd_resume, .driver = { .name = driver_name, + .suppress_bind_attrs = true, }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1709/1848 power: supply: gpio-charger: Report discharging without input power
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Velkov <[email protected]>
[ Upstream commit f0f400459bf6a037e70768de623fff3f8920b8bb ]
The status property follows only the charge-status GPIO. Without input power a charger such as the BQ24133 releases its open-drain STAT pin, and depending on the board the GPIO then reads as charging.
On Kobol Helios64 the board runs from its battery after a mains loss, and the charger reports online 0 with status "Charging".
Report "Discharging" whenever the online GPIO is present and inactive.
--- drivers/power/supply/gpio-charger.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/power/supply/gpio-charger.c +4 -1
@@ -100,7 +100,10 @@ static int gpio_charger_get_property(struct power_supply *psy, val->intval =gpiod_get_value_cansleep (gpio_charger->gpiod);break ;case POWER_SUPPLY_PROP_STATUS : -if (gpiod_get_value_cansleep (gpio_charger->charge_status)) +/* Without input power the battery discharges, whatever the status pin says */ +if (gpio_charger->gpiod && !gpiod_get_value_cansleep (gpio_charger->gpiod)) + val->intval =POWER_SUPPLY_STATUS_DISCHARGING ; +else if (gpiod_get_value_cansleep (gpio_charger->charge_status)) val->intval =POWER_SUPPLY_STATUS_CHARGING ;else val->intval =POWER_SUPPLY_STATUS_NOT_CHARGING ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1710/1848 RDMA/core: Preserve the selected source GID on failed AH modification
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit d01ee4c84193196b6e4be4caf1ff8fdcc441ed96 ]
When an address-handle modification fails, the core replaces its source-GID reference. The old address then loses the reference which keeps its source entry alive.
--- drivers/infiniband/core/verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/verbs.c +2 -1
@@ -951,7 +951,8 @@ int rdma_modify_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr) ah->device->ops.modify_ah(ah, ah_attr) : -EOPNOTSUPP ; - ah->sgid_attr =rdma_update_sgid_attr (ah_attr, ah->sgid_attr); +if (!ret) + ah->sgid_attr =rdma_update_sgid_attr (ah_attr, ah->sgid_attr);rdma_unfill_sgid_attr (ah_attr, old_sgid_attr);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1711/1848 RDMA/core: Remove device argument from rdma_build_skb()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yunsheng Lin <[email protected]>
[ Upstream commit 05195dcb43504e381bf383e837fc935aac4258cc ]
'device' argument is never used since rdma_build_skb() is introduced, so remove it.
Stable-dep-of: fdfd099222d9 ("RDMA/core: Reject LAG selection when source MAC lookup fails")
--- drivers/infiniband/core/lag.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/core/lag.c +2 -3
@@ -7,8 +7,7 @@#include <rdma/ib_cache.h> #include <rdma/lag.h> -static struct sk_buff *rdma_build_skb (struct ib_device *device, -struct net_device *netdev, +static struct sk_buff *rdma_build_skb (struct net_device *netdev,struct rdma_ah_attr *ah_attr,gfp_t flags) {
@@ -86,7 +85,7 @@ static struct net_device *rdma_get_xmit_slave_udp(struct ib_device *device,struct net_device *slave;struct sk_buff *skb; - skb =rdma_build_skb (device, master, ah_attr, flags); + skb =rdma_build_skb (master, ah_attr, flags);if (!skb)return ERR_PTR (-ENOMEM );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1712/1848 RDMA/core: Reject LAG selection when source MAC lookup fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit fdfd099222d9de9e2f1b8d69e94494c5489272cc ]
GID deletion can clear the source device association after LAG lookup retains the bonding master. Ignoring the resulting L2 lookup failure copies uninitialized source MAC bytes into the synthetic hash packet.
Read the source MAC before allocating the packet and propagate lookup errors to the caller, so failed lookups cannot influence slave selection.
--- drivers/infiniband/core/lag.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/infiniband/core/lag.c +8 -4
@@ -19,6 +19,11 @@ static struct sk_buff *rdma_build_skb(struct net_device *netdev,u8 smac[ETH_ALEN ];bool is_ipv4;int hdr_len; +int ret; + + ret =rdma_read_gid_l2_fields (ah_attr->grh.sgid_attr,NULL , smac); +if (ret) +return ERR_PTR (ret); is_ipv4 =ipv6_addr_v4mapped ((struct in6_addr *)ah_attr->grh.dgid.raw); hdr_len =ETH_HLEN +sizeof (struct udphdr ) +LL_RESERVED_SPACE (netdev);
@@ -26,7 +31,7 @@ static struct sk_buff *rdma_build_skb(struct net_device *netdev, skb =alloc_skb (hdr_len, flags);if (!skb) -return NULL ; +return ERR_PTR (-ENOMEM ); skb->dev = netdev;skb_reserve (skb, hdr_len);
@@ -70,7 +75,6 @@ static struct sk_buff *rdma_build_skb(struct net_device *netdev,skb_reset_mac_header (skb); eth =eth_hdr (skb); skb->protocol = eth->h_proto =htons (is_ipv4 ?ETH_P_IP :ETH_P_IPV6 ); -rdma_read_gid_l2_fields (ah_attr->grh.sgid_attr,NULL , smac);memcpy (eth->h_source, smac,ETH_ALEN );memcpy (eth->h_dest, ah_attr->roce.dmac,ETH_ALEN );
@@ -86,8 +90,8 @@ static struct net_device *rdma_get_xmit_slave_udp(struct ib_device *device,struct sk_buff *skb; skb =rdma_build_skb (master, ah_attr, flags); -if (!skb) -return ERR_PTR (-ENOMEM ); +if (IS_ERR (skb)) +return ERR_CAST (skb);rcu_read_lock (); slave = netdev_get_xmit_slave(master, skb,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1713/1848 RDMA/srp: Avoid reading uninitialized has_port on srp_parse_in() failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Serhat Kumral <[email protected]>
[ Upstream commit 4b8f20dc8d25f575e8b8bb5abb09ab803a7e1a3f ]
srp_parse_in() returns -ENOMEM without initializing *has_port if kstrdup() fails. Only check has_port when srp_parse_in() succeeds.
--- drivers/infiniband/ulp/srp/ib_srp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/srp/ib_srp.c +1 -1
@@ -3449,7 +3449,7 @@ static int srp_parse_options(struct net *net, const char *buf, } ret =srp_parse_in (net, &target->rdma_cm.dst.ss, p, &has_port); -if (!has_port) +if (ret ==0 && !has_port) ret = -EINVAL ;if (ret <0 ) {pr_warn ("bad dest parameter '%s'\n" , p);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1714/1848 ASoC: codecs: sta32x: Fix definition of limiter threshold controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit e06bf60ee5bffa9eeacff0bf8b03d4572b04f67d ]
The limiter attack and release thresholds are the two 4-bit halves of one register, so their maximum is 15, not 16. With 16 the controls on bits 3:0 also write bit 4, which belongs to the other threshold.
--- sound/soc/codecs/sta32x.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/soc/codecs/sta32x.c +8 -8
@@ -484,21 +484,21 @@ SOC_ENUM("Limiter2 Release Rate (dB/ms)", sta32x_limiter2_release_rate_enum),* two different enum definitions; provide both */ SOC_SINGLE_TLV ("Limiter1 Attack Threshold (AC Mode)" ,STA32X_L1ATRT , STA32X_LxA_SHIFT, -16 ,0 , sta32x_limiter_ac_attack_tlv), +15 ,0 , sta32x_limiter_ac_attack_tlv),SOC_SINGLE_TLV ("Limiter2 Attack Threshold (AC Mode)" ,STA32X_L2ATRT , STA32X_LxA_SHIFT, -16 ,0 , sta32x_limiter_ac_attack_tlv), +15 ,0 , sta32x_limiter_ac_attack_tlv),SOC_SINGLE_TLV ("Limiter1 Release Threshold (AC Mode)" ,STA32X_L1ATRT , STA32X_LxR_SHIFT, -16 ,0 , sta32x_limiter_ac_release_tlv), +15 ,0 , sta32x_limiter_ac_release_tlv),SOC_SINGLE_TLV ("Limiter2 Release Threshold (AC Mode)" ,STA32X_L2ATRT , STA32X_LxR_SHIFT, -16 ,0 , sta32x_limiter_ac_release_tlv), +15 ,0 , sta32x_limiter_ac_release_tlv),SOC_SINGLE_TLV ("Limiter1 Attack Threshold (DRC Mode)" ,STA32X_L1ATRT , STA32X_LxA_SHIFT, -16 ,0 , sta32x_limiter_drc_attack_tlv), +15 ,0 , sta32x_limiter_drc_attack_tlv),SOC_SINGLE_TLV ("Limiter2 Attack Threshold (DRC Mode)" ,STA32X_L2ATRT , STA32X_LxA_SHIFT, -16 ,0 , sta32x_limiter_drc_attack_tlv), +15 ,0 , sta32x_limiter_drc_attack_tlv),SOC_SINGLE_TLV ("Limiter1 Release Threshold (DRC Mode)" ,STA32X_L1ATRT , STA32X_LxR_SHIFT, -16 ,0 , sta32x_limiter_drc_release_tlv), +15 ,0 , sta32x_limiter_drc_release_tlv),SOC_SINGLE_TLV ("Limiter2 Release Threshold (DRC Mode)" ,STA32X_L2ATRT , STA32X_LxR_SHIFT, -16 ,0 , sta32x_limiter_drc_release_tlv), +15 ,0 , sta32x_limiter_drc_release_tlv),BIQUAD_COEFS ("Ch1 - Biquad 1" ,0 ), BIQUAD_COEFS("Ch1 - Biquad 2", 5),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1715/1848 ASoC: codecs: sta350: Fix definition of limiter threshold controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 77623752c156763d7a80414afe5b769ba4532bd3 ]
The limiter attack and release thresholds are the two 4-bit halves of one register, so their maximum is 15, not 16. With 16 the controls on bits 3:0 also write bit 4, which belongs to the other threshold.
--- sound/soc/codecs/sta350.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/soc/codecs/sta350.c +8 -8
@@ -510,28 +510,28 @@ SOC_ENUM("Limiter2 Release Rate (dB/ms)", sta350_limiter2_release_rate_enum),*/ SOC_SINGLE_TLV ("Limiter1 Attack Threshold (AC Mode)" ,STA350_L1ATRT , STA350_LxA_SHIFT, -16 ,0 , sta350_limiter_ac_attack_tlv), +15 ,0 , sta350_limiter_ac_attack_tlv),SOC_SINGLE_TLV ("Limiter2 Attack Threshold (AC Mode)" ,STA350_L2ATRT , STA350_LxA_SHIFT, -16 ,0 , sta350_limiter_ac_attack_tlv), +15 ,0 , sta350_limiter_ac_attack_tlv),SOC_SINGLE_TLV ("Limiter1 Release Threshold (AC Mode)" ,STA350_L1ATRT , STA350_LxR_SHIFT, -16 ,0 , sta350_limiter_ac_release_tlv), +15 ,0 , sta350_limiter_ac_release_tlv),SOC_SINGLE_TLV ("Limiter2 Release Threshold (AC Mode)" ,STA350_L2ATRT , STA350_LxR_SHIFT, -16 ,0 , sta350_limiter_ac_release_tlv), +15 ,0 , sta350_limiter_ac_release_tlv),SOC_SINGLE_TLV ("Limiter1 Attack Threshold (DRC Mode)" ,STA350_L1ATRT , STA350_LxA_SHIFT, -16 ,0 , sta350_limiter_drc_attack_tlv), +15 ,0 , sta350_limiter_drc_attack_tlv),SOC_SINGLE_TLV ("Limiter2 Attack Threshold (DRC Mode)" ,STA350_L2ATRT , STA350_LxA_SHIFT, -16 ,0 , sta350_limiter_drc_attack_tlv), +15 ,0 , sta350_limiter_drc_attack_tlv),SOC_SINGLE_TLV ("Limiter1 Release Threshold (DRC Mode)" ,STA350_L1ATRT , STA350_LxR_SHIFT, -16 ,0 , sta350_limiter_drc_release_tlv), +15 ,0 , sta350_limiter_drc_release_tlv),SOC_SINGLE_TLV ("Limiter2 Release Threshold (DRC Mode)" ,STA350_L2ATRT , STA350_LxR_SHIFT, -16 ,0 , sta350_limiter_drc_release_tlv), +15 ,0 , sta350_limiter_drc_release_tlv),BIQUAD_COEFS ("Ch1 - Biquad 1" ,0 ), BIQUAD_COEFS("Ch1 - Biquad 2", 5),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1716/1848 RDMA/rxe: Remove unused pkt->offset
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bob Pearson <[email protected]>
[ Upstream commit bf139b58af09eaed8828510adc094fc281deaf73 ]
The pkt->offset field is never used except to assign it to 0. But it adds lots of unneeded code. This patch removes the field and related code. This causes a measurable improvement in performance.
Stable-dep-of: 7d7214b39b14 ("RDMA/rxe: Clear pkt->qp before the early drop exits in rxe_rcv()")
--- drivers/infiniband/sw/rxe/rxe_hdr.h | 178 +++++++++++++-------------- drivers/infiniband/sw/rxe/rxe_recv.c | 4 +- drivers/infiniband/sw/rxe/rxe_req.c | 1 - drivers/infiniband/sw/rxe/rxe_resp.c | 3 +- 4 files changed, 90 insertions(+), 96 deletions(-)
drivers/infiniband/sw/rxe/rxe_hdr.h +88 -90
@@ -22,7 +22,6 @@ struct rxe_pkt_info {u16 paylen;/* length of bth - icrc */ u8 port_num;/* port pkt received on */ u8 opcode;/* bth opcode of packet */ -u8 offset;/* bth offset from pkt->hdr */ };/* Macros should be used only for received skb */
@@ -280,134 +279,134 @@ static inline void __bth_set_psn(void *arg, u32 psn)static inline u8 bth_opcode (struct rxe_pkt_info *pkt) { -return __bth_opcode (pkt->hdr + pkt->offset); +return __bth_opcode (pkt->hdr); }static inline void bth_set_opcode (struct rxe_pkt_info *pkt,u8 opcode) { -__bth_set_opcode (pkt->hdr + pkt->offset, opcode); +__bth_set_opcode (pkt->hdr, opcode); }static inline u8 bth_se (struct rxe_pkt_info *pkt) { -return __bth_se (pkt->hdr + pkt->offset); +return __bth_se (pkt->hdr); }static inline void bth_set_se (struct rxe_pkt_info *pkt,int se) { -__bth_set_se (pkt->hdr + pkt->offset, se); +__bth_set_se (pkt->hdr, se); }static inline u8 bth_mig (struct rxe_pkt_info *pkt) { -return __bth_mig (pkt->hdr + pkt->offset); +return __bth_mig (pkt->hdr); }static inline void bth_set_mig (struct rxe_pkt_info *pkt,u8 mig) { -__bth_set_mig (pkt->hdr + pkt->offset, mig); +__bth_set_mig (pkt->hdr, mig); }static inline u8 bth_pad (struct rxe_pkt_info *pkt) { -return __bth_pad (pkt->hdr + pkt->offset); +return __bth_pad (pkt->hdr); }static inline void bth_set_pad (struct rxe_pkt_info *pkt,u8 pad) { -__bth_set_pad (pkt->hdr + pkt->offset, pad); +__bth_set_pad (pkt->hdr, pad); }static inline u8 bth_tver (struct rxe_pkt_info *pkt) { -return __bth_tver (pkt->hdr + pkt->offset); +return __bth_tver (pkt->hdr); }static inline void bth_set_tver (struct rxe_pkt_info *pkt,u8 tver) { -__bth_set_tver (pkt->hdr + pkt->offset, tver); +__bth_set_tver (pkt->hdr, tver); }static inline u16 bth_pkey (struct rxe_pkt_info *pkt) { -return __bth_pkey (pkt->hdr + pkt->offset); +return __bth_pkey (pkt->hdr); }static inline void bth_set_pkey (struct rxe_pkt_info *pkt,u16 pkey) { -__bth_set_pkey (pkt->hdr + pkt->offset, pkey); +__bth_set_pkey (pkt->hdr, pkey); }static inline u32 bth_qpn (struct rxe_pkt_info *pkt) { -return __bth_qpn (pkt->hdr + pkt->offset); +return __bth_qpn (pkt->hdr); }static inline void bth_set_qpn (struct rxe_pkt_info *pkt,u32 qpn) { -__bth_set_qpn (pkt->hdr + pkt->offset, qpn); +__bth_set_qpn (pkt->hdr, qpn); }static inline int bth_fecn (struct rxe_pkt_info *pkt) { -return __bth_fecn (pkt->hdr + pkt->offset); +return __bth_fecn (pkt->hdr); }static inline void bth_set_fecn (struct rxe_pkt_info *pkt,int fecn) { -__bth_set_fecn (pkt->hdr + pkt->offset, fecn); +__bth_set_fecn (pkt->hdr, fecn); }static inline int bth_becn (struct rxe_pkt_info *pkt) { -return __bth_becn (pkt->hdr + pkt->offset); +return __bth_becn (pkt->hdr); }static inline void bth_set_becn (struct rxe_pkt_info *pkt,int becn) { -__bth_set_becn (pkt->hdr + pkt->offset, becn); +__bth_set_becn (pkt->hdr, becn); }static inline u8 bth_resv6a (struct rxe_pkt_info *pkt) { -return __bth_resv6a (pkt->hdr + pkt->offset); +return __bth_resv6a (pkt->hdr); }static inline void bth_set_resv6a (struct rxe_pkt_info *pkt) { -__bth_set_resv6a (pkt->hdr + pkt->offset); +__bth_set_resv6a (pkt->hdr); }static inline int bth_ack (struct rxe_pkt_info *pkt) { -return __bth_ack (pkt->hdr + pkt->offset); +return __bth_ack (pkt->hdr); }static inline void bth_set_ack (struct rxe_pkt_info *pkt,int ack) { -__bth_set_ack (pkt->hdr + pkt->offset, ack); +__bth_set_ack (pkt->hdr, ack); }static inline void bth_set_resv7 (struct rxe_pkt_info *pkt) { -__bth_set_resv7 (pkt->hdr + pkt->offset); +__bth_set_resv7 (pkt->hdr); }static inline u32 bth_psn (struct rxe_pkt_info *pkt) { -return __bth_psn (pkt->hdr + pkt->offset); +return __bth_psn (pkt->hdr); }static inline void bth_set_psn (struct rxe_pkt_info *pkt,u32 psn) { -__bth_set_psn (pkt->hdr + pkt->offset, psn); +__bth_set_psn (pkt->hdr, psn); }static inline void bth_init (struct rxe_pkt_info *pkt,u8 opcode,int se,int mig,int pad,u16 pkey,u32 qpn,int ack_req,u32 psn) { -struct rxe_bth *bth = (struct rxe_bth *)(pkt->hdr + pkt->offset); +struct rxe_bth *bth = (struct rxe_bth *)(pkt->hdr); bth->opcode = opcode; bth->flags = (pad <<4 ) &BTH_PAD_MASK ;
@@ -448,14 +447,14 @@ static inline void __rdeth_set_een(void *arg, u32 een)static inline u8 rdeth_een (struct rxe_pkt_info *pkt) { -return __rdeth_een (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_RDETH ]); +return __rdeth_een (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_RDETH ]); }static inline void rdeth_set_een (struct rxe_pkt_info *pkt,u32 een) { -__rdeth_set_een (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_RDETH ], een); +__rdeth_set_een (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_RDETH ], een); }/******************************************************************************
@@ -499,26 +498,26 @@ static inline void __deth_set_sqp(void *arg, u32 sqp)static inline u32 deth_qkey (struct rxe_pkt_info *pkt) { -return __deth_qkey (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_DETH ]); +return __deth_qkey (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_DETH ]); }static inline void deth_set_qkey (struct rxe_pkt_info *pkt,u32 qkey) { -__deth_set_qkey (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_DETH ], qkey); +__deth_set_qkey (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_DETH ], qkey); }static inline u32 deth_sqp (struct rxe_pkt_info *pkt) { -return __deth_sqp (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_DETH ]); +return __deth_sqp (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_DETH ]); }static inline void deth_set_sqp (struct rxe_pkt_info *pkt,u32 sqp) { -__deth_set_sqp (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_DETH ], sqp); +__deth_set_sqp (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_DETH ], sqp); }/******************************************************************************
@@ -574,38 +573,38 @@ static inline void __reth_set_len(void *arg, u32 len)static inline u64 reth_va (struct rxe_pkt_info *pkt) { -return __reth_va (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_RETH ]); +return __reth_va (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_RETH ]); }static inline void reth_set_va (struct rxe_pkt_info *pkt,u64 va) { -__reth_set_va (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_RETH ], va); +__reth_set_va (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_RETH ], va); }static inline u32 reth_rkey (struct rxe_pkt_info *pkt) { -return __reth_rkey (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_RETH ]); +return __reth_rkey (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_RETH ]); }static inline void reth_set_rkey (struct rxe_pkt_info *pkt,u32 rkey) { -__reth_set_rkey (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_RETH ], rkey); +__reth_set_rkey (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_RETH ], rkey); }static inline u32 reth_len (struct rxe_pkt_info *pkt) { -return __reth_len (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_RETH ]); +return __reth_len (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_RETH ]); }static inline void reth_set_len (struct rxe_pkt_info *pkt,u32 len) { -__reth_set_len (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_RETH ], len); +__reth_set_len (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_RETH ], len); }/******************************************************************************
@@ -676,50 +675,50 @@ static inline void __atmeth_set_comp(void *arg, u64 comp)static inline u64 atmeth_va (struct rxe_pkt_info *pkt) { -return __atmeth_va (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ]); +return __atmeth_va (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ]); }static inline void atmeth_set_va (struct rxe_pkt_info *pkt,u64 va) { -__atmeth_set_va (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ], va); +__atmeth_set_va (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ], va); }static inline u32 atmeth_rkey (struct rxe_pkt_info *pkt) { -return __atmeth_rkey (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ]); +return __atmeth_rkey (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ]); }static inline void atmeth_set_rkey (struct rxe_pkt_info *pkt,u32 rkey) { -__atmeth_set_rkey (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ], rkey); +__atmeth_set_rkey (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ], rkey); }static inline u64 atmeth_swap_add (struct rxe_pkt_info *pkt) { -return __atmeth_swap_add (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ]); +return __atmeth_swap_add (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ]); }static inline void atmeth_set_swap_add (struct rxe_pkt_info *pkt,u64 swap_add) { -__atmeth_set_swap_add (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ], swap_add); +__atmeth_set_swap_add (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ], swap_add); }static inline u64 atmeth_comp (struct rxe_pkt_info *pkt) { -return __atmeth_comp (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ]); +return __atmeth_comp (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ]); }static inline void atmeth_set_comp (struct rxe_pkt_info *pkt,u64 comp) { -__atmeth_set_comp (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ], comp); +__atmeth_set_comp (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_ATMETH ], comp); }/******************************************************************************
@@ -780,26 +779,26 @@ static inline void __aeth_set_msn(void *arg, u32 msn)static inline u8 aeth_syn (struct rxe_pkt_info *pkt) { -return __aeth_syn (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_AETH ]); +return __aeth_syn (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_AETH ]); }static inline void aeth_set_syn (struct rxe_pkt_info *pkt,u8 syn) { -__aeth_set_syn (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_AETH ], syn); +__aeth_set_syn (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_AETH ], syn); }static inline u32 aeth_msn (struct rxe_pkt_info *pkt) { -return __aeth_msn (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_AETH ]); +return __aeth_msn (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_AETH ]); }static inline void aeth_set_msn (struct rxe_pkt_info *pkt,u32 msn) { -__aeth_set_msn (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_AETH ], msn); +__aeth_set_msn (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_AETH ], msn); }/******************************************************************************
@@ -825,14 +824,14 @@ static inline void __atmack_set_orig(void *arg, u64 orig)static inline u64 atmack_orig (struct rxe_pkt_info *pkt) { -return __atmack_orig (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_ATMACK ]); +return __atmack_orig (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_ATMACK ]); }static inline void atmack_set_orig (struct rxe_pkt_info *pkt,u64 orig) { -__atmack_set_orig (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_ATMACK ], orig); +__atmack_set_orig (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_ATMACK ], orig); }/******************************************************************************
@@ -858,14 +857,14 @@ static inline void __immdt_set_imm(void *arg, __be32 imm)static inline __be32 immdt_imm (struct rxe_pkt_info *pkt) { -return __immdt_imm (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_IMMDT ]); +return __immdt_imm (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_IMMDT ]); }static inline void immdt_set_imm (struct rxe_pkt_info *pkt,__be32 imm) { -__immdt_set_imm (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_IMMDT ], imm); +__immdt_set_imm (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_IMMDT ], imm); }/******************************************************************************
@@ -891,14 +890,14 @@ static inline void __ieth_set_rkey(void *arg, u32 rkey)static inline u32 ieth_rkey (struct rxe_pkt_info *pkt) { -return __ieth_rkey (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_IETH ]); +return __ieth_rkey (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_IETH ]); }static inline void ieth_set_rkey (struct rxe_pkt_info *pkt,u32 rkey) { -__ieth_set_rkey (pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_IETH ], rkey); +__ieth_set_rkey (pkt->hdr + + rxe_opcode[pkt->opcode].offset[RXE_IETH ], rkey); }enum rxe_hdr_length {
@@ -915,13 +914,12 @@ enum rxe_hdr_length {static inline size_t header_size (struct rxe_pkt_info *pkt) { -return pkt->offset + rxe_opcode[pkt->opcode].length; +return rxe_opcode[pkt->opcode].length; }static inline void *payload_addr (struct rxe_pkt_info *pkt) { -return pkt->hdr + pkt->offset - + rxe_opcode[pkt->opcode].offset[RXE_PAYLOAD ]; +return pkt->hdr + rxe_opcode[pkt->opcode].offset[RXE_PAYLOAD ]; }static inline size_t payload_size (struct rxe_pkt_info *pkt)
drivers/infiniband/sw/rxe/rxe_recv.c +1 -3
@@ -349,9 +349,7 @@ void rxe_rcv(struct sk_buff *skb)__be32 *icrcp;u32 calc_icrc, pack_icrc; - pkt->offset =0 ; - -if (unlikely (skb->len < pkt->offset +RXE_BTH_BYTES )) +if (unlikely (skb->len <RXE_BTH_BYTES )) goto drop;if (rxe_chk_dgid (rxe, skb) <0 ) {
drivers/infiniband/sw/rxe/rxe_req.c +0 -1
@@ -375,7 +375,6 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp, pkt->psn = qp->req.psn; pkt->mask = rxe_opcode[opcode].mask; pkt->paylen = paylen; - pkt->offset =0 ; pkt->wqe = wqe;/* init skb */
drivers/infiniband/sw/rxe/rxe_resp.c +1 -2
@@ -594,11 +594,10 @@ static struct sk_buff *prepare_ack_packet(struct rxe_qp *qp, ack->qp = qp; ack->opcode = opcode; ack->mask = rxe_opcode[opcode].mask; - ack->offset = pkt->offset; ack->paylen = paylen;/* fill in bth using the request packet headers */ -memcpy (ack->hdr, pkt->hdr, pkt->offset +RXE_BTH_BYTES ); +memcpy (ack->hdr, pkt->hdr,RXE_BTH_BYTES );bth_set_opcode (ack, opcode);bth_set_qpn (ack, qp->attr.dest_qp_num);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1717/1848 RDMA/rxe: Clear pkt->qp before the early drop exits in rxe_rcv()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiwei Zhang <[email protected]>
[ Upstream commit 7d7214b39b14c9763c14445b139f63369063b65e ]
rxe_rcv() puts pkt->qp at its drop label, but leaves pkt->qp uninitialized on the two paths that take an early goto:
if (unlikely(skb->len < RXE_BTH_BYTES)) goto drop; if (rxe_chk_dgid(rxe, skb) < 0) goto drop; pkt->opcode = bth_opcode(pkt); pkt->psn = bth_psn(pkt); pkt->qp = NULL; <- too late for the gotos above ... drop: if (pkt->qp) rxe_put(pkt->qp);
pkt points into skb->cb, which rxe does not own at this point: the network stack has used that space for its own state. For IPv6, ip6_rcv_core() memsets inet6_skb_parm and then writes
IP6CB(skb)->nhoff = offsetof(struct ipv6hdr, nexthdr);
at offset 14, so the qword at cb + 8, which is where pkt->qp lives, reads back as 0x0006000000000000 for every IPv6 packet.
Any IPv6 datagram to port 4791 whose payload is shorter than the BTH takes the first goto and reaches the drop label with that value, so rxe_put() runs refcount_dec_and_test() on 0x0006000000000150 and the kernel faults, in softirq, on a non-canonical address:
general protection fault, probably for non-canonical address 0x0006000000000150: 0000 [#1] PREEMPT SMP RIP: 0010:__rxe_put+0x.../... Call Trace: <IRQ> rxe_rcv+0x.../... [rdma_rxe] rxe_udp_encap_recv+0x.../... [rdma_rxe] udp_queue_rcv_one_skb ... Kernel panic - not syncing: Fatal exception in interrupt
The fault happens in softirq, so it panics even with panic_on_oops=0, and with panic=0 the machine hangs until it is power cycled. A remote sender only needs to send an empty UDP datagram to port 4791; no RDMA connection, GID or other state is involved and the rxe socket is bound in init_net.
IPv4 is not affected: ip_rcv_core() memsets the whole inet_skb_parm, so the pkt->qp slot is zero there.
Fix by clearing pkt->qp before the first early exit. pkt->qp is only ever assigned a reference-owning value by hdr_check() and rxe_rcv_mcast_pkt(), both of which run after this point, so the put at the drop label stays balanced.
The ordering has been unsafe since the driver was merged: the two early gotos have preceded pkt->qp = NULL in every version since 8700e3e7c485.
Testing done: the driver was built and run on a 6.2 vendor tree that carries this code, where a single 0-byte IPv6 datagram to port 4791 reproduced the panic above (that tree does not pull the UDP header in rxe_udp_encap_recv(), so payloads of 0..3 bytes reach the first goto there, versus 0..11 on mainline). With this change, the same packets are dropped as intended and tracing the drop label shows pkt->qp is 0 on every path that reaches it. Not done: the mainline tree was not built in the environment used to prepare this, and the reproducer is left out of this message on purpose - both are available on request.
--- drivers/infiniband/sw/rxe/rxe_recv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_recv.c +8 -1
@@ -349,6 +349,14 @@ void rxe_rcv(struct sk_buff *skb)__be32 *icrcp;u32 calc_icrc, pack_icrc; +/* +* pkt lives in skb->cb, which the network stack has already used +* for its own state: for IPv6 the qword holding pkt->qp holds +* inet6_skb_parm.nhoff. The drop label puts pkt->qp, so clear +* it before the first early exit. +*/ + pkt->qp =NULL ; +if (unlikely (skb->len <RXE_BTH_BYTES )) goto drop;
@@ -359,7 +367,6 @@ void rxe_rcv(struct sk_buff *skb) pkt->opcode =bth_opcode (pkt); pkt->psn =bth_psn (pkt); - pkt->qp =NULL ; pkt->mask |= rxe_opcode[pkt->opcode].mask;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1718/1848 RDMA/usnic: Bound buffer size to sizeof(buf) in flowinfo_read()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Serhat Kumral <[email protected]>
[ Upstream commit 9dd8b9a337af844291edcd9139c927d0f7958dbe ]
In flowinfo_read(), 'left' tracks the remaining space in the 512-byte stack buffer 'buf', but it is initialized to 'count'.
Initialize 'left' to sizeof(buf) instead of 'count'.
--- drivers/infiniband/hw/usnic/usnic_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/usnic/usnic_debugfs.c +1 -1
@@ -77,7 +77,7 @@ static ssize_t flowinfo_read(struct file *f, char __user *data, qp_flow = f->private_data; ptr = buf; - left = count; + left =sizeof (buf);if (*ppos >0 )return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1719/1848 dt-bindings: Add Sercomm (Suzhou) Corporation vendor prefix
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Zhilkin <[email protected]>
[ Upstream commit d217c4d968bb590e5aa1ff7d02f680c9ba5c1cec ]
Add "sercomm" vendor prefix for "Sercomm (Suzhou) Corporation".
Company website:
Stable-dep-of: f4ba4f8cc8e8 ("dt-bindings: vendor-prefixes: Add Sensylink")
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -988,6 +988,8 @@ patternProperties: description: Sensirion AG "^sensortek,.*": description: Sensortek Technology Corporation + "^sercomm,.*": + description: Sercomm (Suzhou) Corporation "^sff,.*": description: Small Form Factor Committee "^sgd,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1720/1848 dt-bindings: vendor-prefixes: Add Sensylink
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Troy Mitchell <[email protected]>
[ Upstream commit f4ba4f8cc8e8df45e57c1754955b3a6b9b089a97 ]
Add the vendor prefix for Sensylink Microelectronics.
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -988,6 +988,8 @@ patternProperties: description: Sensirion AG "^sensortek,.*": description: Sensortek Technology Corporation + "^sensylink,.*": + description: Sensylink Microelectronics Technology Co., Ltd. "^sercomm,.*": description: Sercomm (Suzhou) Corporation "^sff,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1721/1848 ALSA: oss: Keep emulation modules loaded until object teardown
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit f0780cfa6acf72576464dc3b40431db389f46ee8 ]
OSS proc entries and notifier callbacks can remain in use without an open OSS device file. Normal snd-pcm-oss removal can therefore delete an existing PCM's OSS proc entry while late HDA codec binding repeats snd_card_register() on the same live card:
OSS PCM module unload Card registration
--------------------- -----------------
snd_info_free_entry(entry)
proc_remove(entry->p)
clear entry->p
snd_info_card_register()
republish linked entry
unlink and free entry
The new proc node retains a pointer to freed storage. Mixer OSS removal can likewise release an adapter while a card notification still uses it.
Hold a snd-pcm-oss module reference for each PCM registered with its notifier and a snd-mixer-oss reference for each card adapter. Release them at final unregister or FREE, after proc and adapter cleanup. Normal module unload can no longer initiate removal while these objects exist.
Track PCM OSS registration with a separate bool registered. Unlike oss.reg, this state also covers unmapped PCMs and remains set across DISCONNECT until final unregister. BUILD-state and creation-error cleanup must not drop a reference when registration never acquired one. The PCM notifier's register_mutex serialization keeps the final put ahead of notifier removal and module teardown until dispatch has finished.
For mixer OSS, serialize callback publication, dispatch and withdrawal in the core so module exit waits for callbacks, including one dropping the last reference, to return. Keep card enumeration in the OSS module, with card references released after dispatch drops the mutex. Ignore duplicate REGISTER notifications so a delayed registration cannot replace an adapter retained across DISCONNECT and leak its module pin.
Partial HDA codec teardown can still remove an individual PCM while the card remains registered; its object-lifetime handling is separate.
--- include/sound/core.h | 3 ++- include/sound/pcm_oss.h | 1 + sound/core/init.c | 29 +++++++++++++++++++++-------- sound/core/oss/mixer_oss.c | 36 ++++++++++++++++++++---------------- sound/core/oss/pcm_oss.c | 12 ++++++++++++ 5 files changed, 56 insertions(+), 25 deletions(-)
include/sound/core.h +2 -1
@@ -220,7 +220,8 @@ int snd_card_locked(int card);#define SND_MIXER_OSS_NOTIFY_REGISTER 0#define SND_MIXER_OSS_NOTIFY_DISCONNECT 1#define SND_MIXER_OSS_NOTIFY_FREE 2 -extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card,int cmd); +void snd_mixer_oss_set_notify (int (*callback)(struct snd_card *card,int cmd)); +void snd_mixer_oss_notify (struct snd_card *card,int cmd);#endif int snd_card_new(struct device *parent, int idx, const char *xid,
include/sound/pcm_oss.h +1 -0
@@ -70,6 +70,7 @@ struct snd_pcm_oss_stream {struct snd_pcm_oss {int reg;unsigned int reg_mask; +bool registered; };#endif /* __SOUND_PCM_OSS_H */
sound/core/init.c +21 -8
@@ -81,8 +81,24 @@ static int module_slot_match(struct module *module, int idx) }#if IS_ENABLED (CONFIG_SND_MIXER_OSS ) -int (*snd_mixer_oss_notify_callback)(struct snd_card *card,int free_flag); -EXPORT_SYMBOL (snd_mixer_oss_notify_callback); +static DEFINE_MUTEX (mixer_oss_notify_mutex); +static int (*mixer_oss_notify_callback)(struct snd_card *card,int cmd); + +void snd_mixer_oss_notify (struct snd_card *card,int cmd) +{ +guard (mutex)(&mixer_oss_notify_mutex); +if (mixer_oss_notify_callback) +mixer_oss_notify_callback (card, cmd); +} +EXPORT_SYMBOL (snd_mixer_oss_notify); + +void snd_mixer_oss_set_notify (int (*callback)(struct snd_card *,int )) +{ +/* Wait for callbacks, including a final module_put(), to return. */ +guard (mutex)(&mixer_oss_notify_mutex); + mixer_oss_notify_callback = callback; +} +EXPORT_SYMBOL (snd_mixer_oss_set_notify);#endif static int check_empty_slot (struct module *module,int slot)
@@ -410,8 +426,7 @@ int snd_card_disconnect(struct snd_card *card)/* at this point, they cannot respond to any calls except release() */ #if IS_ENABLED (CONFIG_SND_MIXER_OSS ) -if (snd_mixer_oss_notify_callback) -snd_mixer_oss_notify_callback (card,SND_MIXER_OSS_NOTIFY_DISCONNECT ); +snd_mixer_oss_notify (card,SND_MIXER_OSS_NOTIFY_DISCONNECT );#endif /* notify all devices that we are disconnected */
@@ -471,8 +486,7 @@ EXPORT_SYMBOL_GPL(snd_card_disconnect_sync);static int snd_card_do_free (struct snd_card *card) {#if IS_ENABLED (CONFIG_SND_MIXER_OSS ) -if (snd_mixer_oss_notify_callback) -snd_mixer_oss_notify_callback (card,SND_MIXER_OSS_NOTIFY_FREE ); +snd_mixer_oss_notify (card,SND_MIXER_OSS_NOTIFY_FREE );#endif snd_device_free_all (card);if (card->private_free)
@@ -790,8 +804,7 @@ int snd_card_register(struct snd_card *card)return err;#if IS_ENABLED (CONFIG_SND_MIXER_OSS ) -if (snd_mixer_oss_notify_callback) -snd_mixer_oss_notify_callback (card,SND_MIXER_OSS_NOTIFY_REGISTER ); +snd_mixer_oss_notify (card,SND_MIXER_OSS_NOTIFY_REGISTER );#endif return 0 ; }
sound/core/oss/mixer_oss.c +20 -16
@@ -1358,13 +1358,22 @@ static int snd_mixer_oss_free1(void *private) static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) { struct snd_mixer_oss *mixer; + int err; if (cmd == SND_MIXER_OSS_NOTIFY_REGISTER) { - int idx, err; + int idx; + + /* Module loading and card registration can both notify us. */ + if (card->mixer_oss) + return 0; mixer = kcalloc(2, sizeof(*mixer), GFP_KERNEL); if (mixer == NULL) return -ENOMEM; + if (!try_module_get(THIS_MODULE)) { + kfree(mixer); + return -ENODEV; + } mutex_init(&mixer->reg_mutex); if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, card, 0,
@@ -1373,6 +1382,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)"unable to register OSS mixer device %i:%i\n" , card->number, 0);kfree (mixer); +module_put (THIS_MODULE );return err; } mixer->oss_dev_alloc =1 ;
@@ -1406,7 +1416,10 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)if (cmd ==SND_MIXER_OSS_NOTIFY_DISCONNECT )return 0 ;snd_mixer_oss_proc_done (mixer); -return snd_mixer_oss_free1 (mixer); + err =snd_mixer_oss_free1 (mixer); +if (!err) +module_put (THIS_MODULE ); +return err; }return 0 ; }
@@ -1415,12 +1428,12 @@ static int __init alsa_mixer_oss_init(void) {struct snd_card *card;int idx; - - snd_mixer_oss_notify_callback = snd_mixer_oss_notify_handler; + +snd_mixer_oss_set_notify (snd_mixer_oss_notify_handler);for (idx =0 ; idx <SNDRV_CARDS ; idx++) { card =snd_card_ref (idx);if (card) { -snd_mixer_oss_notify_handler (card,SND_MIXER_OSS_NOTIFY_REGISTER ); +snd_mixer_oss_notify (card,SND_MIXER_OSS_NOTIFY_REGISTER );snd_card_unref (card); } }
@@ -1429,17 +1442,8 @@ static int __init alsa_mixer_oss_init(void) static void __exit alsa_mixer_oss_exit(void) { -struct snd_card *card; -int idx; - - snd_mixer_oss_notify_callback =NULL ; -for (idx =0 ; idx <SNDRV_CARDS ; idx++) { - card =snd_card_ref (idx); -if (card) { -snd_mixer_oss_notify_handler (card,SND_MIXER_OSS_NOTIFY_FREE ); -snd_card_unref (card); - } - } +/* Live adapters hold module references and prevent normal unload. */ +snd_mixer_oss_set_notify (NULL ); }module_init (alsa_mixer_oss_init)
sound/core/oss/pcm_oss.c +12 -0
@@ -3122,6 +3122,12 @@ static void register_oss_dsp(struct snd_pcm *pcm, int index)static int snd_pcm_oss_register_minor (struct snd_pcm *pcm) { +if (pcm->oss.registered) +return 0 ; +if (!try_module_get (THIS_MODULE )) +return -ENODEV ; + pcm->oss.registered = true; + pcm->oss.reg =0 ;if (dsp_map[pcm->card->number] == (int )pcm->device) {char name[128 ];
@@ -3176,8 +3182,14 @@ static int snd_pcm_oss_disconnect_minor(struct snd_pcm *pcm)static int snd_pcm_oss_unregister_minor (struct snd_pcm *pcm) { +/* BUILD-state and creation-error cleanup need not have registered us. */ +if (!pcm->oss.registered) +return 0 ; +snd_pcm_oss_disconnect_minor (pcm);snd_pcm_oss_proc_done (pcm); + pcm->oss.registered = false; +module_put (THIS_MODULE );return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1722/1848 octeontx2-af: Fix CQ enable state tracking after AQ writes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit 07bd391eb9572e74f073c49acef327611234f9bb ]
Use the CQ context's ena field when updating the CQ enable bitmap. The current code reads rq.ena, which overlaps bit 0 of the CQ base address and can leave the bitmap out of sync with the hardware context. This can cause enabled CQs to be skipped during teardown.
Use sq.ena for the SQ bitmap update as well, so each queue type reads its own context.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +2 -2
@@ -799,7 +799,7 @@ static int rvu_nix_aq_enq_inst(struct rvu *rvu, struct nix_aq_enq_req *req,__clear_bit (req->qidx, pfvf->rq_bmap); }if (req->ctype ==NIX_AQ_CTYPE_SQ ) { - ena = (req->rq.ena & req->sq_mask.ena) | + ena = (req->sq.ena & req->sq_mask.ena) | (test_bit (req->qidx, pfvf->sq_bmap) & ~req->sq_mask.ena);if (ena)
@@ -808,7 +808,7 @@ static int rvu_nix_aq_enq_inst(struct rvu *rvu, struct nix_aq_enq_req *req,__clear_bit (req->qidx, pfvf->sq_bmap); }if (req->ctype ==NIX_AQ_CTYPE_CQ ) { - ena = (req->rq.ena & req->cq_mask.ena) | + ena = (req->cq.ena & req->cq_mask.ena) | (test_bit (req->qidx, pfvf->cq_bmap) & ~req->cq_mask.ena);if (ena)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1723/1848 netfilter: nf_conntrack: avoid truncating IPv6 nexthdr offset
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 48d522b65fb0ce2bd54f8f5838d77b48afcf1f3e ]
find_prev_fhdr() returns the offset of the Next Header field before an IPv6 Fragment header through an int pointer, but stores the offset in a u8 local. An extension header chain can put this field beyond byte 255, causing the offset to wrap before it is saved in the fragment queue.
Reassembly later uses the wrapped value to update the preceding Next Header field. This overwrites another byte in the IPv6 header chain and can make conntrack parse a different transport tuple from the one used by IPv6 local delivery. A two-fragment packet can, for example, be recorded as UDP destination port 53 while its payload is delivered to UDP port 9999.
Use int for the working offset, matching the output argument and the other offset variables in this path.
--- net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/netfilter/nf_conntrack_reasm.c +1 -1
@@ -394,7 +394,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff) {u8 nexthdr =ipv6_hdr (skb)->nexthdr;const int netoff =skb_network_offset (skb); -u8 prev_nhoff = netoff + offsetof(struct ipv6hdr , nexthdr); +int prev_nhoff = netoff + offsetof(struct ipv6hdr , nexthdr);int start = netoff +sizeof (struct ipv6hdr );int len = skb->len - start;u8 prevhdr =NEXTHDR_IPV6 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1724/1848 netfilter: xt_dccp: handle reserved options as single-byte
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <[email protected]>
[ Upstream commit 2edda78aa4eb04cd8f112a81897510ee0cdd7099 ]
The DCCP UAPI defines option numbers 3 through 31 as reserved. Like Padding and Mandatory, these options occupy one byte. dccp_find_option() only treats values below 2 as single-byte and interprets the byte after a reserved option as a TLV length.
This can skip a later option and invert an XT_DCCP_OPTION rule result. A local production-hook fixture installed the same DROP rule for IPv4 and IPv6. In three fresh boots per kernel, a target-only packet was dropped 20/20 times, while adding reserved option 3 before the same target let 20/20 packets reach the protected receiver. The fixed kernel dropped all trigger packets in three fresh boots and preserved the normal controls.
Treat every option up to DCCPO_MAX_RESERVED as single-byte, matching the protocol definition. Triggering requires CONFIG_NETFILTER_XTABLES_LEGACY, CONFIG_NETFILTER_XT_MATCH_DCCP, an option-based rule, and remote protocol-33 reachability. The touched source is unchanged at 0c2669a9f4a1d607e7591ae50ccf3c432a0aff08, where the patch applies and builds cleanly.
--- net/netfilter/xt_dccp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_dccp.c +1 -1
@@ -62,7 +62,7 @@ dccp_find_option(u_int8_t option,return true; } -if (op[i] <2 || i == optlen -1 ) +if (op[i] <=DCCPO_MAX_RESERVED || i == optlen -1 ) i++;else i += op[i +1 ] ? :1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1725/1848 nios2: ksyms: Declare __mulsi3 export
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 2180d11e06fb56fd13643ae59964f144896870be ]
GCC may emit libcalls to __mulsi3(). As modpost is not aware that this function is provided through the linked in libgcc, it fails:
ERROR: modpost: kernel/locking/test-ww_mutex.ko: symbol '__mulsi3' undefined!
ERROR: modpost: kernel/time/test_udelay.ko: symbol '__mulsi3' undefined!
ERROR: modpost: kernel/resource_kunit.ko: symbol '__mulsi3' undefined!
ERROR: modpost: fs/fuse/virtiofs.ko: symbol '__mulsi3' undefined! etc.
Make sure modpost can see the symbol from libgcc.
--- arch/nios2/kernel/nios2_ksyms.c | 1 + 1 file changed, 1 insertion(+)
arch/nios2/kernel/nios2_ksyms.c +1 -0
@@ -39,6 +39,7 @@ DECLARE_EXPORT(__udivsi3);DECLARE_EXPORT (__umoddi3);DECLARE_EXPORT (__umodsi3);DECLARE_EXPORT (__muldi3); +DECLARE_EXPORT (__mulsi3);DECLARE_EXPORT (__ucmpdi2);DECLARE_EXPORT (__lshrdi3);DECLARE_EXPORT (__ashldi3);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1726/1848 ALSA: pcm: Remove channel-map controls before freeing substreams
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit d5dd05c1f72a95d8ab06828d7272a185ad2b9185 ]
A late HDA codec bind on an already registered card builds new PCMs before registering them. add_std_chmaps() publishes generic channel-map controls during this BUILD stage. If an earlier chmap succeeds and a later allocation fails, probe cleanup frees the BUILD PCM while the card's control device remains accessible.
These generic controls are added directly by snd_pcm_add_chmap_ctls(); snd_hda_ctls_clear() only removes codec-tracked mixer controls. BUILD devices also skip dev_disconnect. snd_pcm_free_stream() then frees the substreams before free_chmap() withdraws their generic control:
Late HDA codec bind / rollback Control GET on the live card
------------------------------ ----------------------------
hda_codec_driver_probe()
snd_hda_codec_build_pcms()
PCM is BUILD
snd_hda_codec_build_controls()
add_std_chmaps()
publish an earlier chmap
later allocation: -ENOMEM
snd_hda_codec_cleanup_for_unbind()
snd_hda_ctls_clear()
generic chmap remains
codec_release_pcms()
snd_device_free()
BUILD: skip dev_disconnect snd_pcm_free_stream()
kfree(substream)
snd_ctl_elem_read()
down_read(controls_rwsem) pcm_chmap_ctl_get()
walk freed substream
free_chmap()
snd_ctl_remove()
wait for GET
up_read(controls_rwsem)
The control read lock cannot protect a substream already freed before control removal starts. The failure above occurs before snd_card_register(), so the PCM has not transitioned out of BUILD.
Move free_chmap() before the substream free loop. Its snd_ctl_remove() withdraws the control and drains readers under controls_rwsem before any substream is released. Normal registered-device disconnect already removes the control, so the later call remains harmless on that path.
--- sound/core/pcm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/core/pcm.c +3 -1
@@ -830,6 +830,9 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr)/* free all proc files under the stream */ snd_pcm_stream_proc_done (pstr); +/* Drain channel-map callbacks before freeing the substreams. */ +free_chmap (pstr); + substream = pstr->substream;while (substream) { substream_next = substream->next;
@@ -844,7 +847,6 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr) kfree(setup); }#endif -free_chmap (pstr);if (pstr->substream_count)put_device (&pstr->dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1727/1848 cgroup/cpuset: use mems_allowed_seq when checking a policy nodemask
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price (Meta) <[email protected]>
[ Upstream commit b0cec62d2867ab3ed27604d5c177b8960c43b17a ]
A cpuset update changes the task's mems_allowed and rebinds its mempolicy in separate steps under mems_allowed_seq, but the check reads both without it. This can cause a spurious numa placement miss under some cpuset/mempolicy combinations.
A reader that loads one mask before the update and the other after it can see a spurious empty intersection and drop the nodemask.
For example, a task with cpuset.mems={0} and MPOL_BIND={0}. If the cpuset moves to mems={1,2}, the policy is rebound to {1}.
The allocator can race and compare the old mems_allowed {0} against the new policy {1} - which will result in a dropped nodemask and a misplaced allocation on node 2.
Simply retry the intersection until mems_allowed_seq is stable.
This covers the task policy, which is rebound under mems_allowed_seq. VMA policies are rebound afterwards by mpol_rebind_mm(), outside mems_allowed_seq, and are not covered by this change.
--- kernel/cgroup/cpuset.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
kernel/cgroup/cpuset.c +12 -1
@@ -3516,10 +3516,21 @@ nodemask_t cpuset_mems_allowed(struct task_struct *tsk)* @nodemask: the nodemask to be checked * * Are any of the nodes in the nodemask allowed in current->mems_allowed? +* +* A cpuset update rebinds the task's mempolicy and changes mems_allowed in +* separate steps, so retry if an update raced with the check. */ int cpuset_nodemask_valid_mems_allowed (nodemask_t *nodemask) { -return nodes_intersects (*nodemask, current->mems_allowed); +unsigned int seq; +int ret; + +do { + seq =read_mems_allowed_begin (); + ret =nodes_intersects (*nodemask, current->mems_allowed); + }while (read_mems_allowed_retry (seq)); + +return ret; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1728/1848 net/sched: act_api: reject duplicate actions in a batch
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit f67b3ed1308d7a282e2d6202d61af052ab0da39e ]
tca_action_gd() builds actions[] with one tcf_action_get_1() per nested TCA_ACT_TAB entry. Each successful lookup takes its own reference to the resolved action, so repeated TCA_ACT_INDEX entries in one request yield the same pointer in multiple slots.
For RTM_DELACTION, tcf_action_delete() then consumes two references per
slot: one in tcf_action_put() and one in tcf_idr_delete_index(). A duplicate therefore drives the refcount to zero mid-walk -- the delete frees the action and removes its IDR slot -- and the next slot calls tcf_action_put() on the freed action:
refcount_t: underflow; use-after-free.
WARNING: lib/refcount.c:87 at refcount_dec_not_one refcount_dec_and_mutex_lock __tcf_action_put tca_action_gd
Three duplicate entries are enough. Reject a repeated action while a delete batch is built, dropping the reference the extra lookup took, and return -EINVAL. RTM_GETACTION balances its own references and keeps accepting duplicate entries.
Conditions to recreate the bug:
tc actions add action gact index 100
tc actions delete action gact index 100 action gact index 100 \
action gact index 100
--- net/sched/act_api.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
net/sched/act_api.c +20 -1
@@ -1445,7 +1445,7 @@ static int tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, u32 portid, int event, struct netlink_ext_ack *extack) { - int i, ret; + int i, j, ret;struct nlattr *tb[TCA_ACT_MAX_PRIO +1 ];struct tc_action *act;size_t attr_size =0 ;
@@ -1470,6 +1470,25 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, ret =PTR_ERR (act); goto err; } + +/* A delete consumes two references per slot (tcf_action_put() +* and tcf_idr_delete_index()) but each entry takes one, so a +* repeated action would hit zero mid-walk. GET balances its +* own references and keeps accepting duplicates. +*/ +if (event ==RTM_DELACTION ) { +for (j =0 ; j < i -1 ; j++) { +if (actions[j] != act) +continue ; + +tcf_action_put (act); +NL_SET_ERR_MSG (extack, +"Duplicate TC action in a delete batch" ); + ret = -EINVAL ; + goto err; + } + } + attr_size +=tcf_action_fill_size (act); actions[i -1 ] = act; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1729/1848 RDMA/mlx5: Fix CQ resize destination index mask
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 0fe31052d948a3a993bb2f58cd5886f7ec279ea7 ]
In copy_resize_cqes, the destination CQE index is computed as (i + 1) & cq->resize_buf->nent, but resize_buf->nent is produced by roundup_pow_of_two(), so it is a power of two with exactly one bit set. Masking with a single-bit value can only yield 0 or nent itself. The buffer has nent entries, so valid indices are 0 .. nent - 1 and nent is one past the last slot; whenever the masked result is nent the following memcpy writes one entry out of bounds.
Use (nent - 1) as the wrap mask instead. For a power-of-two nent, (i + 1) & (nent - 1) is the correct modulo-nent reduction, keeping the index within [0, nent - 1]. This matches get_sw_cqe(), which addresses the CQ buffer via n & cq->ibcq.cqe, where cq->ibcq.cqe == entries - 1 is exactly the nent - 1 wrap mask.
--- drivers/infiniband/hw/mlx5/cq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/cq.c +1 -1
@@ -1215,7 +1215,7 @@ static int copy_resize_cqes(struct mlx5_ib_cq *cq)while (get_cqe_opcode (scqe64) !=MLX5_CQE_RESIZE_CQ ) { dcqe =mlx5_frag_buf_get_wqe (&cq->resize_buf->fbc, - (i +1 ) & cq->resize_buf->nent); + (i +1 ) & (cq->resize_buf->nent -1 )); dcqe64 = dsize ==64 ? dcqe : dcqe +64 ; sw_own =sw_ownership_bit (i +1 , cq->resize_buf->nent);memcpy (dcqe, scqe, dsize);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1730/1848 rtc: class: Make the time32 hctosys limit configurable
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit b253c2e96a80aac8e2bc67b425bf007ed78d4d8c ]
The RTC_HCTOSYS feature faces an impossible dilemma on 32-bit systems:
a) systemd requires RTC_HCTOSYS=y with the correct timestamp for its intended operation
b) broken RTC hardware can produce random future timestamps beyond 2038 at boot time
c) time32 userspace immediately hangs if the time is set to a date beyond 2038 and requires timestamps to be clamped
d) time64 userspace is intended to survive the actual 2038 date and requires timestamps to not be clamped
Commit b3a5ac42ab18 ("rtc: hctosys: Ensure system time doesn't overflow time_t") introduced this limit to protect time32 userspace from future RTC dates that can break boot and address constraints a), b) and c), but broke d) in the process by limiting RTC_HCTOSYS to the time32 range and falling back to RTC_HCTOSYS=n behavior when the RTC time overflows that.
Make the behavior configurable with a new RTC_HCTOSYS_TIME32_LIMIT option that chooses between breaking c) or d). On systems with COMPAT_32BIT_TIME=n, only RTC_HCTOSYS_TIME32_LIMIT=n is allowed since userspace can be assumed to be fully built for time64. 64-bit kernels running 32-bit userland never had the cutoff and continue to not offer the option.
Warn on rejection with the RTC date and option name so users can identify the cause and find the setting.
[arnd: reword Kconfig text and patch description,
add COMPAT_32BIT_TIME dependency]
----
I ended up rewriting most of the text but kept Karl's ownership as he did the original patch.
--- drivers/rtc/Kconfig | 21 +++++++++++++++++++++ drivers/rtc/class.c | 8 +++++--- 2 files changed, 26 insertions(+), 3 deletions(-)
drivers/rtc/Kconfig +21 -0
@@ -40,6 +40,27 @@ config RTC_HCTOSYS the value read from a specified RTC device. This is useful to avoid unnecessary fsck runs at boot time, and to network better. +config RTC_HCTOSYS_TIME32_LIMIT + bool "Reject RTC dates after the 2038 cutoff" + depends on RTC_HCTOSYS && COMPAT_32BIT_TIME && !64BIT + default y + help + Reject RTC dates after 03:14:07 UTC on 19 January 2038 when + initializing the system clock in order to work around broken + RTC implementations that produce nondeterministic timestamps + without a working backup battery. + + A rejected date leaves system time unchanged, normally near + the Unix epoch, and the RTC's hctosys sysfs attribute reads + 0. Userspace must supply the time if no other source has + initialized it. + + Say Y here if the kernel may have to run old time32 userspace on + hardware that can produce unpredictable RTC timestamps. If the + kernel is intended to only run time64 compatible userspace and + continue working past 2038, you must pick N here in order to + have a working RTC_HCTOSYS functionality. + config RTC_HCTOSYS_DEVICE string "RTC used to set the system time" depends on RTC_HCTOSYS
drivers/rtc/class.c +5 -3
@@ -72,12 +72,14 @@ static void rtc_hctosys(struct rtc_device *rtc) tv64.tv_sec =rtc_tm_to_time64 (&tm); -#if BITS_PER_LONG ==32 -if (tv64.tv_sec >INT_MAX ) { +if (IS_ENABLED (CONFIG_RTC_HCTOSYS_TIME32_LIMIT ) && + tv64.tv_sec >INT_MAX ) { +dev_warn (rtc->dev.parent, +"hctosys: rejecting %ptR UTC due to CONFIG_RTC_HCTOSYS_TIME32_LIMIT=y\n" , + &tm); err = -ERANGE ; goto err_read; } -#endif err =do_settimeofday64 (&tv64);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1731/1848 timers: Move timer sysctl into the timer code
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: tangmeng <[email protected]>
[ Upstream commit efaa0227f6c6a5073951b20cf2f8c63c4155306c ]
This is part of the effort to reduce kernel/sysctl.c to only contain the core logic.
Stable-dep-of: e7cad586d732 ("timers: Clear pending_map on CPU hotplug")
--- include/linux/timer.h | 8 ------- kernel/sysctl.c | 11 --------- kernel/time/timer.c | 53 +++++++++++++++++++++++++++++++------------ 3 files changed, 38 insertions(+), 34 deletions(-)
include/linux/timer.h +0 -8
@@ -205,14 +205,6 @@ extern void run_local_timers(void);struct hrtimer ;extern enum hrtimer_restart it_real_fn (struct hrtimer *); -#if defined(CONFIG_SMP ) && defined(CONFIG_NO_HZ_COMMON ) -struct ctl_table ; - -extern unsigned int sysctl_timer_migration; -int timer_migration_handler (struct ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos); -#endif -unsigned long __round_jiffies (unsigned long j,int cpu);unsigned long __round_jiffies_relative (unsigned long j,int cpu);unsigned long round_jiffies (unsigned long j);
kernel/sysctl.c +0 -11
@@ -2735,17 +2735,6 @@ static struct ctl_table kern_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = SYSCTL_ONE, }, -#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) - { - .procname = "timer_migration", - .data = &sysctl_timer_migration, - .maxlen = sizeof(unsigned int), - .mode = 0644, - .proc_handler = timer_migration_handler, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE, - }, -#endif#ifdef CONFIG_BPF_SYSCALL { .procname = "unprivileged_bpf_disabled",
kernel/time/timer.c +38 -15
77 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1732/1848 timers: Clear pending_map on CPU hotplug
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Hao <[email protected]>
[ Upstream commit e7cad586d73276cbd4466de81b2092287d7475c0 ]
CPU hotplug migration leaves pending_map bits set on the outgoing CPU while its wheel vectors are empty. After re-online, a later next_expiry recalc can treat those empty buckets as pending and temporarily pull next_expiry forward until collect drains the bits.
Clear pending_map under the base lock after migration in timers_dead_cpu().
--- kernel/time/timer.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/time/timer.c +2 -0
@@ -45,6 +45,7 @@#include <linux/compat.h> #include <linux/random.h> #include <linux/sysctl.h> +#include <linux/bitmap.h> #include <linux/uaccess.h> #include <asm/unistd.h>
@@ -2035,6 +2036,7 @@ int timers_dead_cpu(unsigned int cpu)for (i =0 ; i <WHEEL_SIZE ; i++)migrate_timer_list (new_base, old_base->vectors + i); +bitmap_zero (old_base->pending_map,WHEEL_SIZE );raw_spin_unlock (&old_base->lock);raw_spin_unlock_irq (&new_base->lock);put_cpu_ptr (&timer_bases);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1733/1848 ASoC: cs42l56: Remove the ADC Mute Switch control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit ff404ef11b975baf38c4472c51a6674c239e8021 ]
The ADC Mute Switch control writes bits 2 and 3 of the Misc ADC Control register. These are the ADCA Invert and ADCB Invert bits, which have their own controls. The ADC mute bits are bits 0 and 1, and the DAI mute callback already sets them.
So the control has never muted the ADCs, and nobody can be relying on it. Remove it rather than point it at the mute bits, so the ADCs are muted in one place only.
--- sound/soc/codecs/cs42l56.c | 1 - 1 file changed, 1 deletion(-)
sound/soc/codecs/cs42l56.c +0 -1
@@ -387,7 +387,6 @@ static const struct snd_kcontrol_new cs42l56_snd_controls[] = { CS42L56_PGAB_MUX_VOLUME, 0, 0x34, 0x24, pga_tlv),SOC_DOUBLE_R_TLV ("ADC Volume" ,CS42L56_ADCA_ATTENUATOR ,CS42L56_ADCB_ATTENUATOR ,0 ,0x00 ,1 , adc_tlv), -SOC_DOUBLE ("ADC Mute Switch" ,CS42L56_MISC_ADC_CTL ,2 ,3 ,1 ,1 ),SOC_DOUBLE ("ADC Boost Switch" ,CS42L56_GAIN_BIAS_CTL ,3 ,2 ,1 ,1 ), SOC_DOUBLE_R_SX_TLV("Headphone Volume", CS42L56_HPA_VOLUME,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1734/1848 net: openvswitch: skip IPv4 later fragments on TCP/UDP set actions
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 14c0350142ab0a10ebeefed03b779df23749e16a ]
An IPv4 later fragment carries no L4 header, but key extraction leaves ip.proto set to the real protocol and the flow may wildcard the frag field, so validate_set() accepts such packets. set_tcp() and set_udp() then treat the first bytes of the fragment payload as an L4 header, rewrite them as ports and patch the bytes at the checksum offset, corrupting the packet.
Skip these actions for OVS_FRAG_TYPE_LATER. IPv6 later fragments are not affected, since their ip.proto is NEXTHDR_FRAGMENT and validate_set() rejects L4 set actions for them.
--- net/openvswitch/actions.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/openvswitch/actions.c +6 -0
@@ -616,6 +616,9 @@ static int set_udp(struct sk_buff *skb, struct sw_flow_key *flow_key,__be16 src, dst;int err; +if (flow_key->ip.frag ==OVS_FRAG_TYPE_LATER ) +return 0 ; + err =skb_ensure_writable (skb,skb_transport_offset (skb) +sizeof (struct udphdr ));if (unlikely (err))
@@ -659,6 +662,9 @@ static int set_tcp(struct sk_buff *skb, struct sw_flow_key *flow_key,__be16 src, dst;int err; +if (flow_key->ip.frag ==OVS_FRAG_TYPE_LATER ) +return 0 ; + err =skb_ensure_writable (skb,skb_transport_offset (skb) +sizeof (struct tcphdr ));if (unlikely (err))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1735/1848 net: openvswitch: drop IP fragments on SCTP set action
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 4d0d8f491307f22aea34b22f73351e1cd2ede735 ]
The SCTP checksum is a CRC32c over the whole SCTP packet. set_sctp() updates it as old_csum ^ old_correct_csum ^ new_csum, with the two CRCs computed over the bytes of the current skb only. That is correct only when the skb holds the whole SCTP packet. For a first fragment, and for a later fragment, it holds just a part of it, and the CRC delta of a change at the start of the packet depends on how many bytes follow, so the checksum written is wrong. The receiver drops the reassembled packet.
validate_set() accepts SCTP set action for any flow with ip.proto set to SCTP, regardless of the fragmentation bits, as it only receives the masked key. As the checksum cannot be fixed up without the whole datagram, fail the action for packets that are IP fragments of either family, so the packet is dropped with OVS_DROP_ACTION_ERROR instead of being forwarded with modified ports and an invalid checksum.
--- net/openvswitch/actions.c | 3 +++ 1 file changed, 3 insertions(+)
net/openvswitch/actions.c +3 -0
@@ -695,6 +695,9 @@ static int set_sctp(struct sk_buff *skb, struct sw_flow_key *flow_key,__le32 old_correct_csum, new_csum, old_csum;int err; +if (flow_key->ip.frag !=OVS_FRAG_TYPE_NONE ) +return -EINVAL ; + err =skb_ensure_writable (skb, sctphoff +sizeof (struct sctphdr ));if (unlikely (err))return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1736/1848 tls: device: protect async RX resync state during device-down
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rishikesh Jethwani <[email protected]>
[ Upstream commit f89a228125238f8d4c7e2b8161e2a85fe35307b6 ]
tls_device_rx_resync_new_rec() can run in process context with the socket lock held, but without an RCU read lock: from the strparser work item (tls_strp_work()) and from the receive paths (tls_rx_rec_wait(), tls_rx_rec_done()). The resync_async pointer belongs to the driver RX context, which tls_device_down() tears down from the netdev notifier without taking the socket lock; only the softirq entry to the parser is implicitly inside an RCU section.
If the parser passes the TLS_RX_DEV_DEGRADED check before device-down sets it, tls_device_down() can complete synchronize_net() and delete the driver context before the parser accesses resync_async->req or its record log. In the asynchronous stage the parser also writes the record log, so this is a write to freed memory, not only a stale read. The RCU section in tls_device_resync_rx() starts after those accesses and therefore does not prevent the use-after-free.
Found by code inspection; not reproduced. Hitting the window requires the parser to be preempted between the DEGRADED check and the resync_async access across the device-down grace period and the driver's teardown.
--- net/tls/tls_device.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
net/tls/tls_device.c +15 -6
@@ -767,8 +767,15 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)if (tls_ctx->rx_conf !=TLS_HW )return ; + +/* The parser also runs in process context, without an RCU read lock. +* Protect the driver's resync_async state before checking the flags: +* device-down sets DEGRADED and waits for synchronize_net() before +* freeing it, without taking the socket lock. +*/ +rcu_read_lock ();if (unlikely (test_bit (TLS_RX_DEV_DEGRADED , &tls_ctx->flags))) -return ; + goto out; prot = &tls_ctx->prot_info; rx_ctx =tls_offload_ctx_rx (tls_ctx);
@@ -783,11 +790,11 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)if (likely (!is_req_pending) || req_seq != seq || !atomic64_try_cmpxchg (&rx_ctx->resync_req, &resync_req,0 )) -return ; + goto out;break ;case TLS_OFFLOAD_SYNC_TYPE_CORE_NEXT_HINT :if (likely (!rx_ctx->resync_nh_do_now)) -return ; + goto out;/* head of next rec is already in, note that the sock_inq will * include the currently parsed message when called from parser
@@ -796,7 +803,7 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)if (sock_data > rcd_len) {trace_tls_device_rx_resync_nh_delay (sk, sock_data, rcd_len); -return ; + goto out; } rx_ctx->resync_nh_do_now =0 ;
@@ -807,16 +814,18 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq) resync_req =atomic64_read (&rx_ctx->resync_async->req); is_req_pending = resync_req;if (likely (!is_req_pending)) -return ; + goto out;if (!tls_device_rx_resync_async (rx_ctx->resync_async, resync_req, &seq, &rcd_delta)) -return ; + goto out;tls_bigint_subtract (rcd_sn, rcd_delta);break ; }tls_device_resync_rx (tls_ctx, sk, seq, rcd_sn); +out: +rcu_read_unlock (); } static void tls_device_core_ctrl_rx_resync(struct tls_context *tls_ctx,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1737/1848 net: hix5hd2: serialize timeout recovery with interface teardown
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 87cce46329a811ea3fe108ac721e0a2400d0a3bb ]
The timeout worker calls the driver's close and open methods without RTNL or a running-state check. A timeout queued before an interface is closed can call close again after ndo_stop has disabled NAPI. The second napi_disable() can then wait indefinitely. The worker can also race with an ongoing close.
Take RTNL and skip recovery when the interface is no longer running. Use the netdev core close and open helpers so a failed reopen leaves the interface down, rather than leaving it marked running with NAPI disabled.
After unregister_netdev() has stopped the watchdog, drain the worker before releasing its MDIO and descriptor resources. This wait is outside RTNL, allowing an already queued worker to take RTNL, observe the down state, and finish.
This issue was identified as part of our ongoing research while reviewing kernel code.
--- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +9 -3
@@ -11,6 +11,7 @@#include <linux/of_net.h> #include <linux/of_mdio.h> #include <linux/reset.h> +#include <linux/rtnetlink.h> #include <linux/clk.h> #include <linux/circ_buf.h>
@@ -889,8 +890,13 @@ static void hix5hd2_tx_timeout_task(struct work_struct *work)struct hix5hd2_priv *priv; priv = container_of(work, struct hix5hd2_priv, tx_timeout_task); -hix5hd2_net_close (priv->netdev); -hix5hd2_net_open (priv->netdev); + +rtnl_lock (); +if (netif_running (priv->netdev)) { +dev_close (priv->netdev); +dev_open (priv->netdev,NULL ); + } +rtnl_unlock (); }static void hix5hd2_net_timeout (struct net_device *dev,unsigned int txqueue)
@@ -1292,6 +1298,7 @@ static int hix5hd2_dev_remove(struct platform_device *pdev)struct hix5hd2_priv *priv =netdev_priv (ndev);unregister_netdev (ndev); +cancel_work_sync (&priv->tx_timeout_task);mdiobus_unregister (priv->bus);mdiobus_free (priv->bus);
@@ -1299,7 +1306,6 @@ static int hix5hd2_dev_remove(struct platform_device *pdev)hix5hd2_destroy_sg_desc_queue (priv);hix5hd2_destroy_hw_desc_queue (priv);of_node_put (priv->phy_node); -cancel_work_sync (&priv->tx_timeout_task);free_netdev (ndev);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1738/1848 net: axienet: release every RX buffer in axienet_dma_bd_release()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Maimon <[email protected]>
[ Upstream commit b59787892d04a5647a7e662fbb02cd0abdb1a993 ]
The RX walk in axienet_dma_bd_release() stops at the first descriptor without an skb, assuming that such a slot and all after it were never filled. That holds on the axienet_dma_bd_init() error path, but not once the ring has been running: when axienet_rx_poll() fails to allocate or map a replacement buffer it leaves the slot it emptied with a NULL skb, in the middle of a populated ring, until a later poll refills it. Closing the interface before then leaks the skb and the streaming DMA mapping of every descriptor after that slot, which can be most of the ring, and is most likely under memory pressure.
The walk also frees each skb before unmapping it. With swiotlb, the DMA_FROM_DEVICE unmap copies the bounce buffer back into the skb data that was just freed, and on non-coherent platforms it invalidates cache lines that may already belong to a new owner.
Skip empty slots instead of stopping at the first one. An emptied slot still has a non-zero cntrl but its buffer is already unmapped, so the skip has to cover the unmap too, which it does by coming before it. Then unmap before freeing, as axienet_rx_poll() does.
This was reported by the Sashiko AI review bot.
Tested on the AXI Ethernet MAC of an ADVA TimeCard X2 (PCIe card, with the built-in AXI DMA): traffic passes after each of ten down/up cycles, each running axienet_dma_bd_release(), so the unmap-then-free order is exercised on every buffer. A failed RX refill was not reproduced, so the skip over an empty slot was not exercised.
--- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +7 -5
@@ -248,13 +248,13 @@ static void axienet_dma_bd_release(struct net_device *ndev)for (i =0 ; i < lp->rx_bd_num; i++) {dma_addr_t phys; -/* A NULL skb means this descriptor has not been initialised -* at all. +/* A NULL skb means the descriptor holds no buffer: it was +* never filled, or axienet_rx_poll() took its skb and could +* not refill it, having already unmapped the old buffer. +* Such slots can sit anywhere in a ring that has been running. */ if (!lp->rx_bd_v[i].skb) -break ; - -dev_kfree_skb (lp->rx_bd_v[i].skb); +continue ;/* For each descriptor, we programmed cntrl with the (non-zero) * descriptor size, after it had been successfully allocated.
@@ -265,6 +265,8 @@ static void axienet_dma_bd_release(struct net_device *ndev)dma_unmap_single (lp->dev, phys, lp->max_frm_size,DMA_FROM_DEVICE ); } + +dev_kfree_skb (lp->rx_bd_v[i].skb); } dma_free_coherent(lp->dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1739/1848 ipv6: account route exceptions to the netns of their dst
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 8ff017b891e89276c15f06dfd7155981d572af77 ]
rt6_insert_exception() and rt6_remove_exception() update rt6_stats->fib_rt_cache of dev_net(rt6i->dst.dev), but the device of an exception dst can move to another netns while the exception is still in its bucket.
This happens when the bucket is flushed from an RCU callback, for instance from nexthop_free_rcu() for the nh_info of a replaced nexthop, whose exceptions still point to live routes. If the device moves to another netns before that callback runs, the decrement hits the other netns, whose u32 counter underflows in /proc/net/rt6_stats, while the counter of the original netns never goes back down.
Account exceptions to the netns their dst was allocated in, derived from dst->ops as ip6_dst_gc() already does, which does not depend on the device. The dst already relies on that netns' ip6_dst_ops being alive when it is destroyed, which happens after the exception is removed.
--- net/ipv6/route.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
net/ipv6/route.c +11 -2
@@ -1437,6 +1437,15 @@ static struct rt6_info *rt6_make_pcpu_route(struct net *net,*/ static DEFINE_SPINLOCK (rt6_exception_lock); +/* Exceptions are accounted to the netns their dst was allocated in. +* Unlike dev_net(dst->dev), it does not change when the device moves to +* another netns or when dst_dev_put() points the dst to blackhole_netdev. +*/ +static struct net *rt6_exception_net (const struct rt6_info *rt) +{ + return container_of(rt->dst.ops, struct net, ipv6.ip6_dst_ops); +} +/* Remove rt6_ex from hash table and free the memory * Caller must hold rt6_exception_lock */
@@ -1449,7 +1458,7 @@ static void rt6_remove_exception(struct rt6_exception_bucket *bucket,if (!bucket || !rt6_ex)return ; - net =dev_net (rt6_ex->rt6i->dst.dev); + net =rt6_exception_net (rt6_ex->rt6i); net->ipv6.rt6_stats->fib_rt_cache--;/* purge completely the exception to allow releasing the held resources:
@@ -1711,7 +1720,7 @@ static int rt6_insert_exception(struct rt6_info *nrt, rt6_ex->stamp = jiffies;hlist_add_head_rcu (&rt6_ex->hlist, &bucket->chain); bucket->depth++; - net->ipv6.rt6_stats->fib_rt_cache++; +rt6_exception_net (nrt)->ipv6.rt6_stats->fib_rt_cache++;/* Randomize max depth to avoid some side channels attacks. */ max_depth =FIB6_MAX_DEPTH +prandom_u32_max (FIB6_MAX_DEPTH );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1740/1848 team: reject CAN, IEEE 802.15.4 and 6LoWPAN devices in team_port_add
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 9043be310c6a4c5e57f7bba4b9870554eac7aa96 ]
When the first port has a non-Ethernet type, team_setup_by_port() copies port_dev->type to the team device while netdev_priv() of the team device still holds a struct team. Several L2 stacks identify their devices by dev->type alone and then access type specific data that the team driver never sets up:
- CAN protocols rely on the CAN mid-layer private data (ml_priv)
- IEEE 802.15.4 code dereferences ieee802154_ptr and the mlme ops in ml_priv
- the 6LoWPAN netdev notifier writes through lowpan_dev(dev) on NETDEV_DOWN and reads it on NETDEV_UP/NETDEV_CHANGE
Enslaving such a device (e.g. vxcan, wpan0, lowpan0) therefore leads to NULL pointer dereferences or to writes into struct team.
This is the same problem that syzbot reported for the bonding driver with a vxcan device enslaved to a bond master, which crashed in can_rx_unregister() and was fixed by commit 8ba68464e478 ("bonding:
refuse to enslave CAN devices"). The team driver has the same gap.
Reject ARPHRD_CAN, ARPHRD_IEEE802154, ARPHRD_IEEE802154_MONITOR and ARPHRD_6LOWPAN devices in team_port_add().
--- drivers/net/team/team.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/team/team.c +11 -0
@@ -1163,6 +1163,17 @@ static int team_port_add(struct team *team, struct net_device *port_dev,return -EINVAL ; } +if (port_dev->type ==ARPHRD_CAN || + port_dev->type ==ARPHRD_IEEE802154 || + port_dev->type ==ARPHRD_IEEE802154_MONITOR || + port_dev->type ==ARPHRD_6LOWPAN ) { +NL_SET_ERR_MSG (extack, +"CAN, IEEE 802.15.4 and 6LoWPAN devices can't be added as a team port" ); +netdev_err (dev,"Device %s is CAN, IEEE 802.15.4 or 6LoWPAN. These device types can't be added as a team port\n" , + portname); +return -EINVAL ; + } +if (netif_is_team_port (port_dev)) {NL_SET_ERR_MSG (extack,"Device is already a port of a team device" ); netdev_err(dev, "Device %s is already a port "
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1741/1848 ibmveth: fix netpoll races with RX replenish
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
[ Upstream commit 8d9ecac6b96e61d0e6d126c60644829fd9f66952 ]
ibmveth_poll_controller() runs RX replenish outside NAPI and without a lock, racing NAPI's replenish on another CPU. Both can fill the same slot, so an skb and its DMA mapping leak and PHYP can write into an unmapped buffer. netpoll calls it from netconsole and from netpoll-enabled bonds.
ibmveth_open() also enables NAPI before the RX resources exist. ibmveth_change_mtu(), veth_pool_store(), ibmveth_set_csum_offload() and ibmveth_set_tso() call close() and open() directly, so while open() is still setting up, netpoll and the direct ibmveth_interrupt() calls can replenish NULL pools and read freed memory.
Remove the callback, as Eric Dumazet did for many drivers after commit ac3d9dd034e5 ("netpoll: make ndo_poll_controller() optional"), including ibmvnic in commit 0c3b9d1b37df ("ibmvnic: remove ndo_poll_controller"). netpoll then polls NAPI itself with budget 0. napi->poll_owner serializes that with NAPI, but not with a NAPI poll that was already running when netpoll was set up, so skip RX replenish at budget 0, which netpoll uses for TX only. TX completes synchronously, so ibmveth_poll() has nothing else to do for netpoll.
Enable NAPI just before request_irq(), once everything ibmveth_poll() touches exists.
Found in review of the ibmveth multi-queue RX series and confirmed by code inspection of poll_one_napi() and the direct close()/open() callers; neither race was reproduced. Tested on a POWER10 LPAR with netconsole over ibmveth: a ping flood (678,470 packets, no loss) during a printk flood, and MTU changes and buffer pool toggles under traffic, with no warnings. No kernel selftests cover ibmveth.
--- drivers/net/ethernet/ibm/ibmveth.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/net/ethernet/ibm/ibmveth.c +13 -15
@@ -507,8 +507,6 @@ static int ibmveth_open(struct net_device *netdev)netdev_dbg (netdev,"open starting\n" ); -napi_enable (&adapter->napi); -for (i =0 ; i <IBMVETH_NUM_BUFF_POOLS ; i++) rxq_entries += adapter->rx_buff_pool[i].size;
@@ -591,10 +589,18 @@ static int ibmveth_open(struct net_device *netdev) } } +/* NAPI can run as soon as it is enabled, from netpoll during the +* direct close()/open() pairs or from a direct ibmveth_interrupt() +* call, so enable it only once everything ibmveth_poll() touches +* exists. +*/ +napi_enable (&adapter->napi); +netdev_dbg (netdev,"registering irq 0x%x\n" , netdev->irq); rc =request_irq (netdev->irq, ibmveth_interrupt,0 , netdev->name, netdev);if (rc !=0 ) { +napi_disable (&adapter->napi);netdev_err (netdev,"unable to request irq 0x%x, rc %d\n" , netdev->irq, rc); goto out_free_buffer_pools;
@@ -651,7 +657,6 @@ static int ibmveth_open(struct net_device *netdev) out_free_buffer_list:free_page ((unsigned long )adapter->buffer_list_addr); out: -napi_disable (&adapter->napi);return rc; }
@@ -1407,7 +1412,11 @@ static int ibmveth_poll(struct napi_struct *napi, int budget) } } -ibmveth_replenish_task (adapter); +/* netpoll polls with budget 0 for TX only, and is not serialized +* with a NAPI poll that was already running when it was set up +*/ +if (budget) +ibmveth_replenish_task (adapter);if (frames_processed < budget) {napi_complete_done (napi, frames_processed);
@@ -1545,14 +1554,6 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)return -EINVAL ; } -#ifdef CONFIG_NET_POLL_CONTROLLER -static void ibmveth_poll_controller (struct net_device *dev) -{ -ibmveth_replenish_task (netdev_priv (dev)); -ibmveth_interrupt (dev->irq, dev); -} -#endif -/** * ibmveth_get_desired_dma - Calculate IO memory desired by the driver *
@@ -1652,9 +1653,6 @@ static const struct net_device_ops ibmveth_netdev_ops = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = ibmveth_set_mac_addr, .ndo_features_check = ibmveth_features_check, -#ifdef CONFIG_NET_POLL_CONTROLLER - .ndo_poll_controller = ibmveth_poll_controller, -#endif };static int ibmveth_probe (struct vio_dev *dev,const struct vio_device_id *id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1742/1848 ibmveth: wait for the RX poll to return before freeing the RX queue
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingming Cao <[email protected]>
[ Upstream commit 3f872b34368c7c1d2a8900950e0fee4cb4dd9a34 ]
napi_disable() returns once ibmveth_poll() has called napi_complete_done(), but the poll is not finished: it then re-enables the interrupt and calls ibmveth_rxq_pending_buffer(), which reads the RX queue. ibmveth_close() can free that queue in the meantime, and the late enable can leave the interrupt unmasked after close() masked it. The request_irq() failure path in ibmveth_open() frees the same memory after napi_disable() too.
Call synchronize_net() after napi_disable() on both paths. Every caller of ibmveth_poll() runs it with bottom halves or interrupts disabled, so this waits for the poll to return.
Found in review of the ibmveth multi-queue RX series and confirmed by code inspection; also raised by the Sashiko review of the first version of this series. The race was not reproduced. Tested on a POWER10 LPAR under an incoming ping flood with 30 rapid link down/up cycles and 30 rapid MTU cycles (1500 <-> 9000); ran cleanly with no warnings or faults. No kernel selftests cover ibmveth.
--- drivers/net/ethernet/ibm/ibmveth.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/ibm/ibmveth.c +6 -0
@@ -601,6 +601,7 @@ static int ibmveth_open(struct net_device *netdev) netdev);if (rc !=0 ) {napi_disable (&adapter->napi); +synchronize_net ();netdev_err (netdev,"unable to request irq 0x%x, rc %d\n" , netdev->irq, rc); goto out_free_buffer_pools;
@@ -670,6 +671,11 @@ static int ibmveth_close(struct net_device *netdev)netdev_dbg (netdev,"close starting\n" );napi_disable (&adapter->napi); +/* napi_disable() returns once ibmveth_poll() has called +* napi_complete_done(), but the poll still re-enables the +* interrupt and reads the RX queue after that. +*/ +synchronize_net ();if (!adapter->pool_config)netif_stop_queue (netdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1743/1848 ocfs2: reserve xattr value tree metadata only once
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 5365f1f417b36627f825aacf9844ae24b671b525 ]
ocfs2_calc_xattr_set_need() asks for the new value's extent tree twice when it replaces an inline value smaller than a value root with one large enough to be stored outside. The "stored outside" branch reserves the tree and then falls through to meta_guess instead of going out:
if (!ocfs2_xattr_is_local(xe)) {
...
xv = (struct ocfs2_xattr_value_root *)
(base + name_offset + name_len);
value_size = OCFS2_XATTR_ROOT_SIZE;
} else
xv = &def_xv.xv;
if (old_clusters >= new_clusters) {
...
goto out;
} else {
meta_add += ocfs2_extend_meta_needed(&xv->xr_list);
...
if (value_size >= OCFS2_XATTR_ROOT_SIZE)
goto out;
}On the fall-through xv is def_xv, so what gets added here is the two blocks ocfs2_extend_meta_needed() wants for an empty value root -- and both sides of meta_guess reserve that same tree again. The create side has done so since commit 3ed2be719eb9 ("ocfs2: allow for more than one data extent when creating xattr"), which ported this reservation to the create case without noticing it was already on the way in, and the existing-block side since commit 0cdc7dde00ec ("ocfs2: fix missing metadata reservation for large xattrs"). Both were chasing the same RESTART_META failure in ocfs2_xattr_extend_allocation(), for xattr create and then for xattr update.
ocfs2_init_xattr_set_ctxt() hands the total straight to ocfs2_reserve_new_metadata_blocks(), so the surplus is two blocks held for the whole transaction. A setxattr that would otherwise fit can come back -ENOSPC on a filesystem whose metadata allocator is nearly exhausted.
Move the reservation into the branch that stops there, leaving meta_guess as the only place that reserves for a value tree the fall through is about to create. The paths that do go out keep reserving against the value root they already have, which for an external old value is the on-disk one and so can legitimately ask for more than two blocks.
Both sides of meta_guess have to come out even on their own now that the copy covering for them is gone. The existing-block side only started reserving the value tree in the commit this one is tagged against. The create side has reserved the tree since 3ed2be719eb9, but only the tree:
the block ocfs2_create_xattr_block() claims came out of the same two, and on the fall-through it was the duplicate removed here that made up the difference. So "ocfs2: reserve metadata for a new xattr block and its value tree" has to land first -- without it the create side reserves 2 where 3 are needed and the value tree is back to RESTART_META. That one fixes a shortfall of its own on the path that reaches meta_guess directly, where there was never a duplicate to cover it, so it is worth taking alone; this patch is not.
--- fs/ocfs2/xattr.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
fs/ocfs2/xattr.c +15 -2
@@ -3205,12 +3205,21 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode, credits +=ocfs2_remove_extent_credits (inode->i_sb); goto out; }else { - meta_add +=ocfs2_extend_meta_needed (&xv->xr_list); clusters_add += new_clusters - old_clusters; credits +=ocfs2_calc_extend_credits (inode->i_sb, &xv->xr_list); -if (value_size >=OCFS2_XATTR_ROOT_SIZE ) +/* +* The old value occupies at least as much room as a +* value root, whether it sat outside or inline, so the +* new root fits where it was and no new xattr block or +* bucket is needed -- only the metadata to extend the +* tree hanging off it. A smaller one is replaced +* outright, which meta_guess below reserves for. +*/ +if (value_size >=OCFS2_XATTR_ROOT_SIZE ) { + meta_add +=ocfs2_extend_meta_needed (&xv->xr_list); goto out; + } } }else {/*
@@ -3262,6 +3271,10 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode,* Reserve metadata for the new xattr's value extent tree. * The not_found path above adds credits for this tree but * omits meta_add, leaving meta_ac NULL for large values. +* +* This is all of meta_ac on this side beyond the xattr tree +* above: no xattr block is allocated here, and a new bucket or +* index block is paid for out of data_ac. */ if (xi->xi_value_len >OCFS2_XATTR_INLINE_SIZE ) meta_add +=ocfs2_extend_meta_needed (&def_xv.xv.xr_list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1744/1848 ocfs2: initialize status waiters before publishing them
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit f6bfa6c458288d72948af95391b205f3eb775721 ]
o2net_prep_nsw() publishes its stack waiter in nn_status_idr and nn_status_list under nn_lock, then initializes the wait queue and completion status after releasing the lock. A concurrent disconnect can find that waiter through o2net_complete_nodes_nsw() and call wake_up() before the wait queue has a valid lock and list head. The sender can also overwrite a completion status with its initial value.
Initialize the wait queue and status before publishing the waiter. nn_lock then orders publication against completion, and no reader can observe a partially initialized object. Leave the IDR allocation and its failure handling unchanged.
A controlled case-modified test kernel used a synthetic connection to enter the real send path and overlap publication with disconnect. The candidate completion and wake-up code were unchanged. Its Oops includes:
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:__wake_up_common+0xa0/0x1f0 Call Trace: <TASK> __wake_up+0x36/0x60 o2net_complete_nsw_locked+0x222/0x370 o2net_set_nn_state+0x917/0xea0 o2net_disconnect_node+0xd0/0x190 o2net_validate_control_write+0x454/0x500 full_proxy_write+0x11f/0x180 vfs_write+0x25a/0x1010 ksys_write+0x111/0x200 do_syscall_64+0x114/0x620 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> Modules linked in:
--- fs/ocfs2/cluster/tcp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ocfs2/cluster/tcp.c +5 -3
@@ -295,6 +295,11 @@ static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw) {int ret; +/* Initialize all completion-visible state before publishing the waiter. */ +init_waitqueue_head (&nsw->ns_wq); + nsw->ns_sys_status =O2NET_ERR_NONE ; + nsw->ns_status =0 ; +spin_lock (&nn->nn_lock); ret =idr_alloc (&nn->nn_status_idr, nsw,0 ,0 ,GFP_ATOMIC );if (ret >=0 ) {
@@ -305,9 +310,6 @@ static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw)if (ret <0 )return ret; -init_waitqueue_head (&nsw->ns_wq); - nsw->ns_sys_status =O2NET_ERR_NONE ; - nsw->ns_status =0 ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1745/1848 platform/x86: ibm_rtl: Fix potential OOB read at signature search
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit f1d81af2521ad504a20481fef12c358d26e6c3a6 ]
The loop for signature search fetches 22 bytes of struct ibm_rtl_table at each check, while the loop count is calculated in 4 bytes unit, which means that, at the last entry, it fetches over the limit.
Rewrite the loop to use the byte offset and correct the boundary condition check for avoiding the potential OOB access.
--- drivers/platform/x86/ibm_rtl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/x86/ibm_rtl.c +4 -4
@@ -223,9 +223,9 @@ static const struct dmi_system_id ibm_rtl_dmi_table[] __initconst = { };static int __init ibm_rtl_init (void ) { -unsigned long ebda_addr, ebda_size; +unsigned long ebda_addr, ebda_size, offset;unsigned int ebda_kb; -int ret = -ENODEV , i; +int ret = -ENODEV ;if (force)pr_warn ("module loaded by force\n" );
@@ -260,9 +260,9 @@ static int __init ibm_rtl_init(void) {return -ENOMEM ;/* search for the _RTL_ signature at the start of the table */ -for (i =0 ; i < ebda_size/sizeof (unsigned int ); i++) { +for (offset =0 ; offset +sizeof (*rtl_table) <= ebda_size; offset +=4 ) {struct ibm_rtl_table __iomem * tmp; - tmp = (struct ibm_rtl_table __iomem *) (ebda_map + i*sizeof (unsigned int )); + tmp = (struct ibm_rtl_table __iomem *) (ebda_map + offset);if ((readq (&tmp->signature) &RTL_MASK ) ==RTL_SIGNATURE ) {phys_addr_t addr;unsigned int plen;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1746/1848 gtp: set a valid genl command in PDP context get and dump replies
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anil Kaushik <[email protected]>
[ Upstream commit 758d8928d2c5d6703da827577cef86d643155236 ]
gtp_genl_fill_info() stamps the reply with the command its callers pass in. gtp_genl_get_pdp() and gtp_genl_dump_pdp() pass nlmsg_type, which in a genl message is the dynamically assigned family id rather than a GTP_CMD_* value, so replies to a PDP context get or dump carry a meaningless command number.
libgtpnl ignores the command and is unaffected, but parsers that check it (for example the ynl tooling) treat the reply as an unknown command and discard it. Pass GTP_CMD_GETPDP, as gtp_tunnel_notify() already passes a real command on the notification path. No uapi change.
--- drivers/net/gtp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/gtp.c +2 -2
@@ -1283,7 +1283,7 @@ static int gtp_genl_get_pdp(struct sk_buff *skb, struct genl_info *info) } err =gtp_genl_fill_info (skb2,NETLINK_CB (skb).portid, info->snd_seq, -0 , info->nlhdr->nlmsg_type, pctx); +0 ,GTP_CMD_GETPDP , pctx);if (err <0 ) goto err_unlock_free;
@@ -1330,7 +1330,7 @@ static int gtp_genl_dump_pdp(struct sk_buff *skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, NLM_F_MULTI, - cb->nlh->nlmsg_type, pctx)) { + GTP_CMD_GETPDP, pctx)) { cb->args[0 ] = i; cb->args[1 ] = j; cb->args[2 ] = (unsigned long )gtp;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1747/1848 gtp: hold RCU for the device lookup when adding a PDP context
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anil Kaushik <[email protected]>
[ Upstream commit fe3e1a42fb7eb18d8c55d714b50a3d51f8cd6ffe ]
gtp_genl_new_pdp() calls gtp_find_dev(), which looks the device up with dev_get_by_index_rcu(). Since commit e2d1baca2b33 ("gtp: remove useless rcu_read_lock()"), this only runs under the rtnl lock, and kernels with CONFIG_PROVE_RCU_LIST warn:
WARNING: suspicious RCU usage
net/core/dev.c:1047 RCU-list traversed in non-reader section!!
...
dev_get_by_index_rcu
gtp_find_dev
gtp_genl_new_pdp
Hold the RCU read lock around the lookup only: gtp_pdp_add() allocates with GFP_KERNEL, and the rtnl lock keeps the device alive afterwards.
Found with the gtp selftest on a debug kernel.
--- drivers/net/gtp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/gtp.c +3 -0
@@ -1085,7 +1085,10 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)rtnl_lock (); +/* the rtnl lock keeps the device alive once found */ +rcu_read_lock (); gtp =gtp_find_dev (sock_net (skb->sk), info->attrs); +rcu_read_unlock ();if (!gtp) { err = -ENODEV ; goto out_unlock;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1748/1848 ASoC: wm8994: fix MCLK gating for AIF clocks sourced from MCLK2
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 872215109fc880de7a03fa30437346f9212649e8 ]
aif_mclk_set() masks the AIFnCLK_SRC field of the AIFn clocking register, but compares the result with unshifted field values. The MCLK2 source (0x08) therefore never matches, so MCLK2 is never enabled for an AIF clocked from it, and the AIF relies on other users of that clock to keep it running.
On the Exynos4412 Trats2 board, AIF1 and SYSCLK run from MCLK2, the 32768Hz PMIC clock, while the codec is idle. That clock is shared with the WLAN and Bluetooth chips, which enable it only once their drivers are loaded. Until then the codec runs from a stopped clock: FLL1 fails to lock when configured from that state, and the codec floods the kernel log with FIFO error interrupts once a digital path is powered up:
wm8994-codec wm8994-codec: Timed out waiting for FLL lock wm8994-codec wm8994-codec: FIFO error
Booting with clk_ignore_unused, which keeps that clock running from the bootloader, makes both issues disappear.
Fixing just the comparison is not enough. The AIF clock source can be changed while the AIF clock is running, for example the Midas machine driver switches AIF1 between MCLK2 and FLL1 while AIF1CLK is kept enabled for jack detection. Looking up the clock again on disable can then release a different MCLK than the one enabled, leaking the enable count of one clock and underflowing the other.
Shift the field value before decoding it, and remember which MCLK has been enabled for each AIF, so that the same clock is released on disable. While at it, report the MCLK number 1-based in the error message.
--- sound/soc/codecs/wm8994.c | 28 ++++++++++++++++++---------- sound/soc/codecs/wm8994.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)
sound/soc/codecs/wm8994.c +18 -10
@@ -1062,13 +1062,24 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablunsigned int offset, val, clk_idx;int ret; +/* +* The AIF clock source may be changed while the AIF clock is +* running, so release the MCLK which has been enabled for it +* instead of the one currently selected. +*/ +if (!enable) { +clk_disable_unprepare (wm8994->aif_mclk[aif]); + wm8994->aif_mclk[aif] =NULL ; +return 0 ; + } +if (aif) offset =4 ;else offset =0 ; val =snd_soc_component_read (component,WM8994_AIF1_CLOCKING_1 + offset); - val &=WM8994_AIF1CLK_SRC_MASK ; + val = (val &WM8994_AIF1CLK_SRC_MASK ) >>WM8994_AIF1CLK_SRC_SHIFT ;switch (val) {case 0 :
@@ -1081,16 +1092,13 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablreturn 0 ; } -if (enable) { - ret =clk_prepare_enable (wm8994->mclk[clk_idx].clk); -if (ret <0 ) { -dev_err (component->dev,"Failed to enable MCLK%d\n" , - clk_idx); -return ret; - } - }else { -clk_disable_unprepare (wm8994->mclk[clk_idx].clk); + ret =clk_prepare_enable (wm8994->mclk[clk_idx].clk); +if (ret <0 ) { +dev_err (component->dev,"Failed to enable MCLK%d\n" , + clk_idx +1 ); +return ret; } + wm8994->aif_mclk[aif] = wm8994->mclk[clk_idx].clk;return 0 ; }
sound/soc/codecs/wm8994.h +1 -0
@@ -81,6 +81,7 @@ struct wm8994_priv {struct wm_hubs_data hubs;struct wm8994 *wm8994;struct clk_bulk_data mclk[WM8994_NUM_MCLK ]; +struct clk *aif_mclk[2 ];int sysclk[2 ];int sysclk_rate[2 ];int mclk_rate[2 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1749/1848 ASoC: wm8994: dont lose the AIF clock ratio when staying at 32kHz SYSCLK
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 693574504051a19383640cfb99524a6b69e4624f ]
When SYSCLK drops below 50kHz, the AIFnCLK rate ratio is saved and temporarily lowered to 128fs for accessory detection, then restored once SYSCLK gets fast enough again. The ratio is however saved again on each clock reconfiguration done while SYSCLK is still slow, which overwrites the original ratio with the 128fs one.
This happens on the Exynos4412 Trats2 board, which set MCLK2 as SYSCLK twice during the card probe and then configure FLL1 while still running from MCLK2. Once SYSCLK is switched to FLL1, the 128fs ratio is "restored", so AIF1 is left configured for 48kHz at 128fs while being clocked at 256fs. If any digital path is powered up before a stream reconfigures the AIF, the codec raises FIFO error interrupts every 10ms, flooding the kernel log:
wm8994-codec wm8994-codec: FIFO error
Save the original ratio only when entering the low SYSCLK mode. While at it, move the code duplicated in _wm8994_set_fll() and wm8994_set_dai_sysclk() to a common helper.
--- sound/soc/codecs/wm8994.c | 94 +++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 54 deletions(-)
sound/soc/codecs/wm8994.c +40 -54
@@ -2210,6 +2210,44 @@ static int wm8994_get_fll_config(struct wm8994 *control, struct fll_div *fll,return 0 ; } +/* +* If SYSCLK is less than 50kHz adjust AIFnCLK dividers for detection, +* restoring the original ones once SYSCLK is fast enough again. +*/ +static void wm8994_update_aif_clk_rate (struct snd_soc_component *component) +{ +struct wm8994_priv *wm8994 =snd_soc_component_get_drvdata (component); + +if (max (wm8994->aifclk[0 ], wm8994->aifclk[1 ]) <50000 ) { +/* Don't overwrite the saved dividers with the 128fs ones */ +if (!wm8994->aifdiv[0 ]) { +dev_dbg (component->dev,"Configuring AIFs for 128fs\n" ); + + wm8994->aifdiv[0 ] =snd_soc_component_read (component, +WM8994_AIF1_RATE ) + &WM8994_AIF1CLK_RATE_MASK ; + wm8994->aifdiv[1 ] =snd_soc_component_read (component, +WM8994_AIF2_RATE ) + &WM8994_AIF1CLK_RATE_MASK ; + } + +snd_soc_component_update_bits (component,WM8994_AIF1_RATE , +WM8994_AIF1CLK_RATE_MASK ,0x1 ); +snd_soc_component_update_bits (component,WM8994_AIF2_RATE , +WM8994_AIF2CLK_RATE_MASK ,0x1 ); + }else if (wm8994->aifdiv[0 ]) { +snd_soc_component_update_bits (component,WM8994_AIF1_RATE , +WM8994_AIF1CLK_RATE_MASK , + wm8994->aifdiv[0 ]); +snd_soc_component_update_bits (component,WM8994_AIF2_RATE , +WM8994_AIF2CLK_RATE_MASK , + wm8994->aifdiv[1 ]); + + wm8994->aifdiv[0 ] =0 ; + wm8994->aifdiv[1 ] =0 ; + } +} +static int _wm8994_set_fll (struct snd_soc_component *component,int id,int src,unsigned int freq_in,unsigned int freq_out) {
@@ -2444,33 +2482,7 @@ static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src,configure_clock (component); -/* -* If SYSCLK will be less than 50kHz adjust AIFnCLK dividers -* for detection. -*/ -if (max (wm8994->aifclk[0 ], wm8994->aifclk[1 ]) <50000 ) { -dev_dbg (component->dev,"Configuring AIFs for 128fs\n" ); - - wm8994->aifdiv[0 ] =snd_soc_component_read (component,WM8994_AIF1_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - wm8994->aifdiv[1 ] =snd_soc_component_read (component,WM8994_AIF2_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK ,0x1 ); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK ,0x1 ); - }else if (wm8994->aifdiv[0 ]) { -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK , - wm8994->aifdiv[0 ]); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK , - wm8994->aifdiv[1 ]); - - wm8994->aifdiv[0 ] =0 ; - wm8994->aifdiv[1 ] =0 ; - } +wm8994_update_aif_clk_rate (component);return 0 ; }
@@ -2588,33 +2600,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,configure_clock (component); -/* -* If SYSCLK will be less than 50kHz adjust AIFnCLK dividers -* for detection. -*/ -if (max (wm8994->aifclk[0 ], wm8994->aifclk[1 ]) <50000 ) { -dev_dbg (component->dev,"Configuring AIFs for 128fs\n" ); - - wm8994->aifdiv[0 ] =snd_soc_component_read (component,WM8994_AIF1_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - wm8994->aifdiv[1 ] =snd_soc_component_read (component,WM8994_AIF2_RATE ) - &WM8994_AIF1CLK_RATE_MASK ; - -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK ,0x1 ); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK ,0x1 ); - }else if (wm8994->aifdiv[0 ]) { -snd_soc_component_update_bits (component,WM8994_AIF1_RATE , -WM8994_AIF1CLK_RATE_MASK , - wm8994->aifdiv[0 ]); -snd_soc_component_update_bits (component,WM8994_AIF2_RATE , -WM8994_AIF2CLK_RATE_MASK , - wm8994->aifdiv[1 ]); - - wm8994->aifdiv[0 ] =0 ; - wm8994->aifdiv[1 ] =0 ; - } +wm8994_update_aif_clk_rate (component);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1750/1848 ASoC: wm8994: fix MCLK index used for setting MCLK rate
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 7916b55b100973b5fb5b974e8f7c8ae9f3ac1d2e ]
wm8994_set_dai_sysclk() passes the AIF index (dai->id - 1) to wm8994_set_mclk_rate(), which uses it to index the MCLK clocks and their cached rates. As a result, selecting MCLK2 as the AIF1 clock source sets and reads back the rate of MCLK1 instead, and the rate of MCLK1 is then stored as the MCLK2 rate.
On the Exynos4412 Trats2 board, where MCLK1 is a fixed 24MHz clock and MCLK2 a 32768Hz clock used when the codec is idle, this gives:
wm8994-codec wm8994-codec: AIF1 using MCLK2 at 24000000Hz
so the driver assumes a 12MHz SYSCLK while it actually runs at 32kHz. This skips the 128fs AIF clock ratio setup for low SYSCLK rates and makes the mic detection rate configuration use the wrong clock rate.
Pass the MCLK index matching the selected clock source instead.
--- sound/soc/codecs/wm8994.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/wm8994.c +2 -2
@@ -2542,7 +2542,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,case WM8994_SYSCLK_MCLK1 : wm8994->sysclk[dai->id -1 ] =WM8994_SYSCLK_MCLK1 ; - ret =wm8994_set_mclk_rate (wm8994, dai->id -1 , &freq); + ret =wm8994_set_mclk_rate (wm8994,WM8994_MCLK1 , &freq);if (ret <0 )return ret;
@@ -2555,7 +2555,7 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,/* TODO: Set GPIO AF */ wm8994->sysclk[dai->id -1 ] =WM8994_SYSCLK_MCLK2 ; - ret =wm8994_set_mclk_rate (wm8994, dai->id -1 , &freq); + ret =wm8994_set_mclk_rate (wm8994,WM8994_MCLK2 , &freq);if (ret <0 )return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1751/1848 ionic: remove some unnecessary oom messages
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shannon Nelson <[email protected]>
[ Upstream commit c0c682eeb8ccb11c05c29c34820224b7556cdf19 ]
Remove memory allocation fail messages where the OOM stack trace will make it obvious which allocation request failed.
Stable-dep-of: d90d1a768b3b ("ionic: fix port_info use-after-free on firmware recovery")
--- drivers/net/ethernet/pensando/ionic/ionic_dev.c | 2 +- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 8 +++----- drivers/net/ethernet/pensando/ionic/ionic_main.c | 4 +--- 3 files changed, 5 insertions(+), 9 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +1 -1
@@ -142,7 +142,7 @@ int ionic_heartbeat_check(struct ionic *ionic) work =kzalloc (sizeof (*work),GFP_ATOMIC );if (!work) { -dev_err (ionic->dev,"%s OOM\n" , __func__); +dev_err (ionic->dev,"LIF reset trigger dropped\n" ); }else { work->type =IONIC_DW_TYPE_LIF_RESET ; if (fw_status & IONIC_FW_STS_F_RUNNING &&
drivers/net/ethernet/pensando/ionic/ionic_lif.c +3 -5
@@ -855,7 +855,7 @@ static bool ionic_notifyq_service(struct ionic_cq *cq,case IONIC_EVENT_RESET : work =kzalloc (sizeof (*work),GFP_ATOMIC );if (!work) { -netdev_err (lif->netdev,"%s OOM\n" , __func__); +netdev_err (lif->netdev,"Reset event dropped\n" ); }else { work->type =IONIC_DW_TYPE_LIF_RESET ;ionic_lif_deferred_enqueue (&lif->deferred, work);
@@ -1064,10 +1064,8 @@ static int ionic_lif_addr(struct ionic_lif *lif, const u8 *addr, bool add,if (!can_sleep) { work =kzalloc (sizeof (*work),GFP_ATOMIC ); -if (!work) { -netdev_err (lif->netdev,"%s OOM\n" , __func__); +if (!work)return -ENOMEM ; - } work->type = add ?IONIC_DW_TYPE_RX_ADDR_ADD :IONIC_DW_TYPE_RX_ADDR_DEL ;memcpy (work->addr, addr,ETH_ALEN );
@@ -1200,7 +1198,7 @@ static void ionic_set_rx_mode(struct net_device *netdev, bool can_sleep)if (!can_sleep) { work =kzalloc (sizeof (*work),GFP_ATOMIC );if (!work) { -netdev_err (lif->netdev,"%s OOM\n" , __func__); +netdev_err (lif->netdev,"rxmode change dropped\n" );return ; } work->type =IONIC_DW_TYPE_RX_MODE ;
drivers/net/ethernet/pensando/ionic/ionic_main.c +1 -3
@@ -513,10 +513,8 @@ int ionic_port_init(struct ionic *ionic) idev->port_info_sz, &idev->port_info_pa, GFP_KERNEL); -if (!idev->port_info) { -dev_err (ionic->dev,"Failed to allocate port info\n" ); +if (!idev->port_info)return -ENOMEM ; - } } sz =min (sizeof (ident->port.config),sizeof (idev->dev_cmd_regs->data));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1752/1848 ionic: fix port_info use-after-free on firmware recovery
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit d90d1a768b3b022c52beafb3a4701ee2ee3d2b5e ]
ionic_port_init() allocates port_info when the pointer is NULL, but its error path frees it without checking whether this call allocated it. Before commit ddc5911b9bd2 ("ionic: call ionic_port_init after fw-upgrade") the function returned early when the buffer already existed, so the two were symmetric.
Since then a failed PORT_INIT on either recovery path - fw_up or reset_done - frees a buffer an earlier init owns, while the netdev is registered and the ethtool ops are reading it.
Free only what this call allocated.
--- drivers/net/ethernet/pensando/ionic/ionic_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_main.c +9 -4
@@ -504,6 +504,7 @@ int ionic_port_init(struct ionic *ionic) {struct ionic_identity *ident = &ionic->ident;struct ionic_dev *idev = &ionic->idev; +bool allocated = false;size_t sz;int err;
@@ -515,6 +516,8 @@ int ionic_port_init(struct ionic *ionic) GFP_KERNEL);if (!idev->port_info)return -ENOMEM ; + + allocated = true; } sz =min (sizeof (ident->port.config),sizeof (idev->dev_cmd_regs->data));
@@ -531,10 +534,12 @@ int ionic_port_init(struct ionic *ionic)mutex_unlock (&ionic->dev_cmd_lock);if (err) {dev_err (ionic->dev,"Failed to init port\n" ); -dma_free_coherent (ionic->dev, idev->port_info_sz, - idev->port_info, idev->port_info_pa); - idev->port_info =NULL ; - idev->port_info_pa =0 ; +if (allocated) { +dma_free_coherent (ionic->dev, idev->port_info_sz, + idev->port_info, idev->port_info_pa); + idev->port_info =NULL ; + idev->port_info_pa =0 ; + } }return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1753/1848 tg3: Add Datto SIRIS 5 1U Server to restart AER quirk table
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Travis Howard <[email protected]>
[ Upstream commit a55eb6a622141352131aa6156bbd6ce5da79d9b5 ]
The Datto SIRIS 5 1U Server is a Dell OEMR XL R640 (Dell's OEM-ready variant of the PowerEdge R640) sold under Datto's identity. Its DMI strings report sys_vendor "datto" and product_name "SIRIS 5 1U Server", so it does not match the existing "PowerEdge R640" entry in tg3_restart_aer_quirk_table.
As on the PowerEdge R640, a system restart triggers a fatal PCIe AER on the BCM5720 during ACPI _PTS for S5, which the iDRAC logs as PCI1318 and which hangs the reboot. Power off is unaffected.
Clearing the same PCI_EXP_DEVCTL error-reporting bits on both BCM5720 functions from userspace immediately before restart allows the system to reboot normally, confirming the quirk applies to this platform.
--- drivers/net/ethernet/broadcom/tg3.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/broadcom/tg3.c +6 -0
@@ -18203,6 +18203,12 @@ static const struct dmi_system_id tg3_restart_snp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge R750"), }, }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "datto"), + DMI_MATCH(DMI_PRODUCT_NAME, "SIRIS 5 1U Server"), + }, + }, {} };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1754/1848 ata: libata-core: Ignore forced transfer modes the host does not support
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rand Deeb <[email protected]>
[ Upstream commit ea5a5af9159cc89e8bcb7a95336e02c8b70aa3d2 ]
The libata.force parameter can force a transfer mode (pio0-6, mwdma0-4, udma0-7) for a port or device. ata_force_xfermask() applies it in ata_do_set_mode() right after ata_dev_xfermask() has limited the device masks to what the host supports. It replaces those masks with the forced mode without checking the host masks, so a mode the controller does not support is passed to the driver's ->set_piomode() or ->set_dmamode().
Several PATA drivers rely on the host masks to keep the mode number in range when indexing their timing tables. ata_piix, pata_efar, pata_it8213, pata_oldpiix, pata_radisys and pata_rdc declare ATA_PIO4 and ATA_MWDMA12_ONLY, index a five-entry PIO timing table with pio_mode - XFER_PIO_0, and index a three-entry needed_pio[] table with dma_mode - XFER_MW_DMA_0. Booting with libata.force=pio5, pio6, mwdma3 or mwdma4 makes them read past those tables, use the values read as further indices into the timing table, and write the result to the controller's timing registers.
Make ata_force_xfermask() skip, with a warning, a forced transfer mode that is not in the port's PIO, MWDMA or UDMA mask, and keep looking for an earlier matching libata.force entry, as it already does for entries that do not apply to the device. With libata.force=pio4,1.0:pio5 on a PIO4 host, device 1.0 now gets pio4 instead of pio5. Forcing a mode the host supports still works as before, including a mode that ata_dev_xfermask() removed for the device or cable.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/ata/libata-core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/ata/libata-core.c +12 -0
@@ -402,6 +402,7 @@ static void ata_force_link_limits(struct ata_link *link)*/ static void ata_force_xfermask (struct ata_device *dev) { +struct ata_port *ap = dev->link->ap;int devno = dev->link->pmp + dev->devno;int alt_devno = devno;int i;
@@ -426,6 +427,17 @@ static void ata_force_xfermask(struct ata_device *dev)ata_unpack_xfermask (fe->param.xfer_mask, &pio_mask, &mwdma_mask, &udma_mask); + +/* Make sure that the port supports the specified xfer modes. */ +if (!(pio_mask & ap->pio_mask) && + !(mwdma_mask & ap->mwdma_mask) && + !(udma_mask & ap->udma_mask)) { +ata_dev_warn (dev, +"FORCE: ignoring unsupported xfer_mask %s\n" , + fe->param.name); +continue ; + } +if (udma_mask) dev->udma_mask = udma_mask;else if (mwdma_mask) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1755/1848 tipc: fix use-after-free of broadcast reception link at node release
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit 473167593f42551ce6b00c05cee8cd20309d45ac ]
When the last reference to a tipc_node is dropped, the node itself is deferred to the RCU callback tipc_node_free(), but the nested broadcast reception link, n->bc_entry.link, is kfree()d synchronously in tipc_node_kref_release(), before call_rcu(), and the pointer is never cleared. Readers that obtained the node from node_list and then dereference bc_entry.link deep into the link (tipc_link_name() in tipc_nl_node_reset_link_stats(), bcl->name/stats in tipc_nl_add_bc_link() on the link dump path) therefore touch freed memory although the enclosing node stays alive for a full grace period. The sibling per-bearer links get "kfree + NULL" under the node write lock in tipc_node_clear_links(); the broadcast entry was missed.
The race is reachable through the node cleanup timer: once a peer has been unreachable for NODE_CLEANUP_AFTER (300 s), tipc_node_timeout() -> tipc_node_cleanup() unlinks the node under the write lock, and the final tipc_node_put() at the caller runs outside node_list_lock, so the kfree executes in timer softirq context, concurrently with genl dump/ reset walkers that hold only rcu_read_lock(). (A netlink "peer remove" cannot race those walkers itself: tipc_genl_family has no parallel_ops, so all doit/dumpit calls serialize on the global genl lock.)
Reproduced in a QEMU/KVM guest running v7.3.0 with KASAN and PREEMPT(full): 10 TIPC peer namespaces on veth bearers, bearer removal staggered so the 300 s node cleanup timers expire while other tasks loop link dumps with the broadcast filter and reset-link-stats lookups. KASAN hit within two cleanup cycles:
BUG: KASAN: slab-use-after-free in strlen+0x85/0xa0 Read of size 1 at addr ffff88800b54a004 by task poc_eth/371 strlen+0x85/0xa0 tipc_nl_add_bc_link+0x2f9/0xd40 __tipc_nl_add_node_links+0x10c/0x140 tipc_nl_node_dump_link+0x8d5/0xd50 Freed by task 0: kfree+0x121/0x380 tipc_node_timeout+0xa33/0xcf0 run_timer_softirq+0x144/0x250 sysvec_apic_timer_interrupt
with the freed object being the kmalloc-1k tipc_link allocated by tipc_link_bc_create() during peer discovery. The same defect fires in strcmp() called from tipc_nl_node_reset_link_stats().
Move the kfree of n->bc_entry.link into the tipc_node_free() RCU callback so the broadcast link lives exactly as long as the enclosing node. All readers are covered: the netlink walkers are inside rcu_read_lock(), and the packet reception path reaches the node via tipc_node_find(), whose kref defers kref_release itself.
Found during a static-analysis-assisted audit: candidate sites were surfaced by a Coccinelle rule, and the reader/writer paths were confirmed by LLM-assisted (GLM-5.3) code inspection.
--- net/tipc/node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tipc/node.c +1 -1
@@ -295,6 +295,7 @@ static void tipc_node_free(struct rcu_head *rp)#ifdef CONFIG_TIPC_CRYPTO tipc_crypto_stop (&n->crypto_rx);#endif +kfree (n->bc_entry.link);kfree (n); }
@@ -302,7 +303,6 @@ static void tipc_node_kref_release(struct kref *kref) { struct tipc_node *n = container_of(kref, struct tipc_node, kref); -kfree (n->bc_entry.link);call_rcu (&n->rcu, tipc_node_free); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1756/1848 ASoC: wm8994: follow AIF clock source changes in MCLK gating
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 8731e33a3b98ea1ccade059b3a1ce06b7dd66b17 ]
The AIF clock source can be changed by configure_aif_clock() while the AIF clock is running, for example the Midas machine driver switches AIF1 between MCLK2 and FLL1 while AIF1CLK is kept enabled for jack detection. aif_mclk_set() only enables the MCLK selected at the time the AIF clock is turned on, so an MCLK selected later this way is never enabled, and the codec may run from a stopped clock.
Track whether the AIF clock is running and, if so, enable the newly selected MCLK in configure_aif_clock() before switching to it, then release the previously enabled one.
--- sound/soc/codecs/wm8994.c | 27 +++++++++++++++++++++++++++ sound/soc/codecs/wm8994.h | 1 + 2 files changed, 28 insertions(+)
sound/soc/codecs/wm8994.c +27 -0
@@ -162,9 +162,12 @@ static void wm8958_micd_set_rate(struct snd_soc_component *component)static int configure_aif_clock (struct snd_soc_component *component,int aif) {struct wm8994_priv *wm8994 =snd_soc_component_get_drvdata (component); +struct clk *mclk =NULL ; +bool switch_mclk;int rate;int reg1 =0 ;int offset; +int ret;if (aif) offset =4 ;
@@ -173,11 +176,13 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif)switch (wm8994->sysclk[aif]) {case WM8994_SYSCLK_MCLK1 : + mclk = wm8994->mclk[WM8994_MCLK1 ].clk; rate = wm8994->mclk_rate[0 ];break ;case WM8994_SYSCLK_MCLK2 : reg1 |=0x8 ; + mclk = wm8994->mclk[WM8994_MCLK2 ].clk; rate = wm8994->mclk_rate[1 ];break ;
@@ -195,6 +200,20 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif)return -EINVAL ; } +/* +* If the AIF clock is running, enable the new MCLK before switching +* to it and release the previous one afterwards. +*/ + switch_mclk = wm8994->aif_clk_on[aif] && mclk != wm8994->aif_mclk[aif]; +if (switch_mclk) { + ret =clk_prepare_enable (mclk); +if (ret <0 ) { +dev_err (component->dev, +"Failed to enable MCLK for AIF%d\n" , aif +1 ); +return ret; + } + } +if (rate >=13500000 ) { rate /=2 ; reg1 |=WM8994_AIF1CLK_DIV ;
@@ -209,6 +228,11 @@ static int configure_aif_clock(struct snd_soc_component *component, int aif)WM8994_AIF1CLK_SRC_MASK |WM8994_AIF1CLK_DIV , reg1); +if (switch_mclk) { +clk_disable_unprepare (wm8994->aif_mclk[aif]); + wm8994->aif_mclk[aif] = mclk; + } +return 0 ; }
@@ -1070,6 +1094,7 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablif (!enable) {clk_disable_unprepare (wm8994->aif_mclk[aif]); wm8994->aif_mclk[aif] =NULL ; + wm8994->aif_clk_on[aif] = false;return 0 ; }
@@ -1089,6 +1114,7 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enabl clk_idx =WM8994_MCLK2 ;break ;default : + wm8994->aif_clk_on[aif] = true;return 0 ; }
@@ -1099,6 +1125,7 @@ static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enablreturn ret; } wm8994->aif_mclk[aif] = wm8994->mclk[clk_idx].clk; + wm8994->aif_clk_on[aif] = true;return 0 ; }
sound/soc/codecs/wm8994.h +1 -0
@@ -82,6 +82,7 @@ struct wm8994_priv {struct wm8994 *wm8994;struct clk_bulk_data mclk[WM8994_NUM_MCLK ];struct clk *aif_mclk[2 ]; +bool aif_clk_on[2 ];int sysclk[2 ];int sysclk_rate[2 ];int mclk_rate[2 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1757/1848 eventpoll: propagate wakeup source creation failure in ep_modify()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianyi Chen <[email protected]>
[ Upstream commit 9f2b8f4a452db79741c06e6ea91448347f4a975c ]
When EPOLL_CTL_MOD adds EPOLLWAKEUP, ep_modify() ignores the return value of ep_create_wakeup_source(). If allocation fails, it returns success with EPOLLWAKEUP set but no per-item wakeup source, so the requested suspend protection is missing.
This can happen without fault injection on SELinux systems: creating the wakeup source's sysfs nodes can require GFP_KERNEL_ACCOUNT allocations for security.selinux xattrs, which can fail when the caller's memory cgroup is over its limit.
Create the wakeup source before updating the event mask and data, and return the error if creation fails. Leave any newly created per-epoll source in place until ep_free(), as ep_insert() does on failure.
--- fs/eventpoll.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
fs/eventpoll.c +13 -5
@@ -1635,11 +1635,22 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, {int pwake =0 ;poll_table pt; +int error;lockdep_assert_irqs_enabled ();init_poll_funcptr (&pt,NULL ); +/* +* Create the wakeup source before committing the new event mask. +* Leave the old mask and data unchanged if allocation fails. +*/ +if ((event->events &EPOLLWAKEUP ) && !ep_has_wakeup_source (epi)) { + error =ep_create_wakeup_source (epi); +if (error) +return error; + } +/* * Set the new event interest mask before calling f_op->poll(); * otherwise we might miss an event that happens between the
@@ -1647,12 +1658,9 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi,*/ epi->event.events = event->events;/* need barrier below */ epi->event.data = event->data;/* protected by mtx */ -if (epi->event.events &EPOLLWAKEUP ) { -if (!ep_has_wakeup_source (epi)) -ep_create_wakeup_source (epi); - }else if (ep_has_wakeup_source (epi)) { +if (!(epi->event.events &EPOLLWAKEUP ) && +ep_has_wakeup_source (epi))ep_destroy_wakeup_source (epi); - }/* * The following barrier has two effects:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1758/1848 signal: skip blocked signals in dequeue_synchronous_signal()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit 4bd3a0e8e53decd614853fbb487a268f139f679e ]
dequeue_synchronous_signal() checks whether an unblocked synchronous signal is pending, but its queue scan can select a different blocked entry with a positive si_code. This can deliver a signal while it is still blocked.
Check the blocked mask for each queued entry. Forced faults are unblocked when necessary by force_sig_info_to_task(), and the existing pending bookkeeping is unchanged.
--- kernel/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/signal.c +3 -2
@@ -717,12 +717,13 @@ static int dequeue_synchronous_signal(kernel_siginfo_t *info)return 0 ;/* -* Return the first synchronous signal in the queue. +* Return the first unblocked synchronous signal in the queue. */ list_for_each_entry (q, &pending->list, list) {/* Synchronous signals have a positive si_code */ if ((q->info.si_code >SI_USER ) && - (sigmask (q->info.si_signo) &SYNCHRONOUS_MASK )) { + (sigmask (q->info.si_signo) &SYNCHRONOUS_MASK ) && + !sigismember (&tsk->blocked, q->info.si_signo)) { sync = q; goto next; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1759/1848 nsproxy: Fix cred leak in the error path of prepare_nsset()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nickolai Zeldovich <[email protected]>
[ Upstream commit e08601d3a7b2236f4915497dca353dcf117bab5c ]
A task that calls setns() with CLONE_NEWUSER together with CLONE_NEWNS and at least one more namespace flag leaks a struct cred (and the user_namespace, ucounts and group_info references it holds) whenever the call fails at the fs_struct copy. On a kernel with CONFIG_USER_NS the leak is one cred per failed setns(); under memory pressure, or driven by a fault-injecting attacker, it accumulates and pins user namespaces that can then never be freed.
prepare_nsset() sets nsset->flags only on the success path:
if (flags & CLONE_NEWUSER)
nsset->cred = prepare_creds();
...
} else if (flags & CLONE_NEWNS) {
nsset->fs = copy_fs_struct(me->fs);
if (!nsset->fs)
goto out; /* flags still 0 here */
}
nsset->flags = flags;
return 0;
out:
put_nsset(nsset);put_nsset() decides what to release from nsset->flags:
if (flags & CLONE_NEWUSER) put_cred(nsset_cred(nsset));
On the copy_fs_struct() failure arm prepare_creds() has already allocated the cred, but nsset->flags is still the zero from the caller's "struct nsset nsset = {}", so put_nsset() does not see CLONE_NEWUSER and never drops it. The caller (__do_sys_setns) returns the error without touching nsset, so the cred is lost.
Set nsset->flags at the start of prepare_nsset(), before anything can fail, so every error exit through put_nsset() releases what was taken. commit_nsset(), which clears nsset->cred on success, is unaffected.
Reproduced on x86_64 under QEMU with failslab aimed at the fs_struct cache and kmemleak enabled: 500 calls ofsetns(pidfd, CLONE_NEWUSER | CLONE_NEWNS | CLONE_NEWUTS) each fail with -ENOMEM and leave 851 unreferenced cred objects allocated from prepare_creds() via setns() before the fix, and none after (the program is in the notes below).
Found by formal verification of kernel/nsproxy.c.
--- kernel/nsproxy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/nsproxy.c +1 -1
@@ -318,6 +318,7 @@ static int prepare_nsset(unsigned flags, struct nsset *nsset) {struct task_struct *me = current; + nsset->flags = flags; nsset->nsproxy =create_new_namespaces (0 , me,current_user_ns (), me->fs);if (IS_ERR (nsset->nsproxy))return PTR_ERR (nsset->nsproxy);
@@ -338,7 +339,6 @@ static int prepare_nsset(unsigned flags, struct nsset *nsset) goto out; } - nsset->flags = flags;return 0 ; out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1760/1848 ACPICA: Initialize parser_state.aml_end in acpi_install_method()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Hu <[email protected]>
[ Upstream commit ec696f34774db985841bac9a2df179c0040ef073 ]
In AcpiInstallMethod(), the local ParserState is stack-allocated and only ParserState.Aml was initialized. Parser helpers called by this path read ParserState.AmlEnd for bounds checking: AcpiPsPeekOpcode() reads it before validating the first AML opcode, and AcpiPsGetNextPackageEnd() reads it indirectly via AcpiPsGetNextPackageLength(). The subsequent package-limit check also compares against ParserState.AmlEnd. Because AmlEnd was never set, these checks operated on an uninitialized value, which Coverity flagged as an uninitialized read (CID 1684785) and which could lead to incorrect parser bounds decisions.
Coverity report:
*** CID 1684785: Memory - illegal accesses (UNINIT)
/src/acpica/source/components/namespace/nsxfname.c: 712 in AcpiInstallMethod()
ParserState.Aml += AcpiPsGetOpcodeSize (Opcode);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
CID 1684785: Memory - illegal accesses (UNINIT)
Using uninitialized value "ParserState.AmlEnd" when calling
"AcpiPsGetNextPackageEnd".
ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState);Initialize ParserState.AmlEnd to the end of the table (Buffer + Table->Length) so the parser bounds checks operate on a valid limit.
--- drivers/acpi/acpica/nsxfname.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/acpica/nsxfname.c +1 -0
@@ -503,6 +503,7 @@ acpi_status acpi_install_method(u8 *buffer)/* First AML opcode in the table must be a control method */ parser_state.aml = buffer +sizeof (struct acpi_table_header ); + parser_state.aml_end = buffer + table->length; opcode =acpi_ps_peek_opcode (&parser_state);if (opcode !=AML_METHOD_OP ) {return (AE_BAD_PARAMETER );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1761/1848 ASoC: amd: raven: Fix memory leak in acp3x_dma_close()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit e0b17f84f6e3fa1201b8e2857094023c42ce5636 ]
acp3x_dma_open() allocates a struct i2s_stream_instance for each substream, but acp3x_dma_close() never frees it, leaking it on every open/close cycle.
Free it in acp3x_dma_close().
--- sound/soc/amd/raven/acp3x-pcm-dma.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/amd/raven/acp3x-pcm-dma.c +2 -0
@@ -363,6 +363,8 @@ static int acp3x_dma_close(struct snd_soc_component *component, } } +kfree (ins); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1762/1848 cgroup/cpuset: check effective mems for a movable-only configuration
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price (Meta) <[email protected]>
[ Upstream commit 4c047bd0499602161959478b90e66f4c8e523c9b ]
check_insane_mems_config() warns and enables cpusets_insane_config_key when a cpuset's tasks can allocate only from movable memory.
In cgroup v2 the request may name a memoryless node, which has no zones and cpusets reports it as a movable-only nodemask.
For example, with node 2 a CPU-only node:
# echo +cpuset > /sys/fs/cgroup/cgroup.subtree_control
# mkdir /sys/fs/cgroup/test
# echo 2 > /sys/fs/cgroup/test/cpuset.mems
# cat /sys/fs/cgroup/test/cpuset.mems.effective
0-1
# dmesg
Unsupported (movable nodes only) cpuset configuration detected (nmask=2)!This is a bit confusing, especially consider mems.effective ends up with a valid nodemask by-design (cpuset.mems is treated as-if it were empty).
Check each new effective mask in update_nodemasks_hier() instead, as the hotplug path already does. The allocator's bail-out tests the task's mems_allowed, which comes from the effective mask.
A request naming a movable-only not present in the parent's nodemask no longer warns (since, again, the cpuset.mems gets overridden and treated as empty). However, it will warn if the parent's mems include the node later.
For Example, with node 3 a movable-only node:
# echo 0 > /sys/fs/cgroup/test/cpuset.mems
# echo 3 > /sys/fs/cgroup/test/child/cpuset.mems
# cat /sys/fs/cgroup/test/child/cpuset.mems.effective
0
# dmesg
{ empty }
# echo 0,3 > /sys/fs/cgroup/test/cpuset.mems
# cat /sys/fs/cgroup/test/child/cpuset.mems.effective
3
# dmesg
Unsupported (movable nodes only) cpuset configuration detected (nmask=3)!--- kernel/cgroup/cpuset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cgroup/cpuset.c +2 -2
@@ -1831,6 +1831,8 @@ static void update_nodemasks_hier(struct cpuset *cs, nodemask_t *new_mems)continue ;rcu_read_unlock (); +check_insane_mems_config (new_mems); +spin_lock_irq (&callback_lock); cp->effective_mems = *new_mems;spin_unlock_irq (&callback_lock);
@@ -1901,8 +1903,6 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,if (retval <0 ) goto done; -check_insane_mems_config (&trialcs->mems_allowed); -spin_lock_irq (&callback_lock); cs->mems_allowed = trialcs->mems_allowed;spin_unlock_irq (&callback_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1763/1848 ALSA: sh: aica: Fix spu_memset() stride
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fuchs <[email protected]>
[ Upstream commit 0d01f90b07e877ef31f9959e9b0bc6bcca9b99df ]
spu_memset() writes one 32-bit word per iteration, but advances the destination offset by only one byte. spu_reset() calls it with 0x200000 / 4 words to clear the 2 MiB of sound RAM, so:
- three out of four writel() calls target an unaligned address. The SH4 can't do that. Each one traps and is emulated by the unaligned access fixup. This call to spu_memset() causes 393216 unaligned accesses, visible in /proc/cpu/alignment.
- the clear covered only about 512 KiB of sound RAM, not 2 MiB.
Advance the offset by the size of the written word, to clear the full sound RAM using aligned writes.
--- sound/sh/aica.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/sh/aica.c +1 -1
@@ -96,7 +96,7 @@ static void spu_memset(u32 toi, u32 what, int length)local_irq_save (flags);writel (what, toi +SPU_MEMORY_BASE );local_irq_restore (flags); - toi++; + toi +=sizeof (what); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1764/1848 net: fix frag_list leak in skb_segment_list() error path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 546daf344420b5dce27eded3ad15be12628dd185 ]
skb_segment_list() detaches the frag_list from the head skb and moves its members one by one to the skb->next chain. On error, err_linearize frees that chain with kfree_skb_list(skb->next), relying on the members not yet processed to still be linked after the current one.
This does not hold when the current member was shared: it is replaced by skb_clone(), and __skb_clone() clears ->next. If __skb_linearize() then fails on that clone, the remaining members are no longer reachable from skb->next nor from skb_shinfo(skb)->frag_list, and they leak.
The skb_shared() error branch already relinks nskb->next to list_skb before jumping to err_linearize. Do it unconditionally right after nskb is added to the chain, so every error exit sees the remaining members. On the last member list_skb is NULL, which still terminates the chain.
--- net/core/skbuff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/core/skbuff.c +6 -3
@@ -3838,10 +3838,13 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb,else tail->next = nskb; -if (unlikely (err)) { - nskb->next = list_skb; +/* nskb may be a clone with a NULL ->next: keep the remaining +* members linked so that err_linearize frees them. +*/ + nskb->next = list_skb; + +if (unlikely (err)) goto err_linearize; - } tail = nskb;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1765/1848 net/rds: include the scope id in the sendmsg connection cache check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit b7dfff5e3eb3984d42026a6d653ec2a3d5cec729 ]
rds_sendmsg() reuses the connection cached in rs->rs_conn when its peer address and ToS match the request. The interface index is part of a connection's identity as well: rds_conn_create_outgoing() passes the request's scope_id down as dev_if, and rds_conn_lookup() compares c_dev_if, so sends to the same link-local address through two interfaces are two different connections. The cache-hit test never looked at it.
A socket bound to a non-link-local address has rs_bound_scope_id 0, and the scope check at the top of rds_sendmsg() accepts any non-zero destination scope for such a socket. So after a send to fe80::x%ifA, a send to fe80::x%ifB hits the cached ifA connection and the datagram leaves through ifA, to whichever peer answers to that address there.
Compare c_dev_if with the request's scope_id in the cache test, so that such a send takes the lookup path and finds, or creates, the ifB connection - the same key the lookup uses. A send without a destination takes its scope from the socket, and the connection it created was keyed on that same scope, so the comparison holds for it too; the next patch gives that send the connected peer's own scope.
Found by inspection while reworking this cache for the connection lifetime series on net-next; not observed in the field.
--- net/rds/send.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/rds/send.c +2 -1
@@ -1309,7 +1309,8 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)/* rds_conn_create has a spinlock that runs with IRQ off. * Caching the conn in the socket helps a lot. */ if (rs->rs_conn &&ipv6_addr_equal (&rs->rs_conn->c_faddr, &daddr) && - rs->rs_tos == rs->rs_conn->c_tos) { + rs->rs_tos == rs->rs_conn->c_tos && + rs->rs_conn->c_dev_if == scope_id) { conn = rs->rs_conn; }else { conn = rds_conn_create_outgoing(sock_net(sock->sk),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1766/1848 net/rds: keep the connected peers scope id apart from the bound one
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 3fe64a5f670dbd6c7c84c2345b0b9726b3b79b31 ]
rds_connect() has nowhere to keep the scope of a link-local peer, so it stores it in rs_bound_scope_id, the scope of the socket's own bound address, for rds_bind() to check a later link-local bind against. That field is then also what a send without a destination uses as the request's scope, what getpeername() and recvmsg() report as the peer's scope, and what a later bind() overwrites:rds_add_bound() stores the bound address's scope unconditionally, which for a non-link-local address is 0.
So after connect(fe80::x%ifA) followed by bind(global), a send() with no destination asks for fe80::x with scope 0. rds_conn_lookup() keys on the interface, so that finds or creates a connection with c_dev_if 0, which the TCP transport then tries to connect through sin6_scope_id 0 and tcp_v6_connect() rejects for a link-local peer:
the connected socket's data is queued on a connection that can never come up. In the other order, bind(global) then connect(fe80::x%ifB), the connect leaves a global-bound socket with rs_bound_scope_id ifB, so sends to other link-local peers are refused as off-link and sends to global peers inherit a meaningless interface.
Give the connected peer its own rs_conn_scope_id. rds_connect() records it there and leaves the bound scope alone, rds_bind()'s connected-socket check compares against it, and the destination-less send takes its scope from it - falling back to the bound scope for a non-link-local peer, so that send() and sendto() to the connected peer compute the same scope, and so the same connection. getpeername() reports the connected peer with its own scope. recvmsg() used to report every sender with the socket's bound scope; a connected socket receives from any peer, so neither the bound scope nor the connected peer's scope is right for an arbitrary sender. It now reports a link-local sender with the interface recorded on its connection, c_dev_if: the TCP accept path takes it from the incoming socket, and the IB passive side resolves it from the local address, the closest the CM gets to the arrival interface. Any other sender is reported with scope 0, the inet6 convention. Either way, a reply to the address an application was given reaches the same connection.
Found by inspection while reworking the sendmsg connection cache; not observed in the field.
--- net/rds/af_rds.c | 15 +++++++++------ net/rds/bind.c | 4 ++-- net/rds/rds.h | 2 ++ net/rds/recv.c | 11 ++++++++++- net/rds/send.c | 6 +++++- 5 files changed, 28 insertions(+), 10 deletions(-)
net/rds/af_rds.c +9 -6
@@ -135,8 +135,7 @@ static int rds_getname(struct socket *sock, struct sockaddr *uaddr, sin6->sin6_port = rs->rs_conn_port; sin6->sin6_addr = rs->rs_conn_addr; sin6->sin6_flowinfo =0 ; -/* scope_id is the same as in the bound address. */ - sin6->sin6_scope_id = rs->rs_bound_scope_id; + sin6->sin6_scope_id = rs->rs_conn_scope_id; uaddr_len =sizeof (*sin6); } }else {
@@ -568,6 +567,7 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr, }ipv6_addr_set_v4mapped (sin->sin_addr.s_addr, &rs->rs_conn_addr); rs->rs_conn_port = sin->sin_port; + rs->rs_conn_scope_id =0 ;break ;#if IS_ENABLED (CONFIG_IPV6 )
@@ -612,11 +612,14 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr, ret = -EINVAL ;break ; } -/* Remember the connected address scope ID. It will -* be checked against the binding local address when -* the socket is bound. +/* Remember the connected address scope ID. It is +* checked against the binding local address when +* the socket is bound, and gives a send without a +* destination its scope. */ - rs->rs_bound_scope_id = sin6->sin6_scope_id; + rs->rs_conn_scope_id = sin6->sin6_scope_id; + }else { + rs->rs_conn_scope_id =0 ; } rs->rs_conn_addr = sin6->sin6_addr; rs->rs_conn_port = sin6->sin6_port;
net/rds/bind.c +2 -2
@@ -233,8 +233,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)* non-link local address (scope_id is 0). */ if (!ipv6_addr_any (&rs->rs_conn_addr) && scope_id && - rs->rs_bound_scope_id && - scope_id != rs->rs_bound_scope_id) { + rs->rs_conn_scope_id && + scope_id != rs->rs_conn_scope_id) { ret = -EINVAL ; goto out; }
net/rds/rds.h +2 -0
@@ -613,6 +613,8 @@ struct rds_sock {struct in6_addr rs_conn_addr;#define rs_conn_addr_v4 rs_conn_addr.s6_addr32[3]__be16 rs_conn_port; +/* scope of rs_conn_addr when it is link-local, 0 otherwise */ +__u32 rs_conn_scope_id;struct rds_transport *rs_transport;/*
net/rds/recv.c +10 -1
@@ -758,7 +758,16 @@ int rds_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, sin6->sin6_port = inc->i_hdr.h_sport; sin6->sin6_addr = inc->i_saddr; sin6->sin6_flowinfo =0 ; - sin6->sin6_scope_id = rs->rs_bound_scope_id; +/* A link-local sender is reported with the +* interface recorded on its connection (the +* accepting socket's device for TCP, the one +* resolved for the local address on IB); any +* other sender has no scope. +*/ + sin6->sin6_scope_id = + (ipv6_addr_type (&inc->i_saddr) & +IPV6_ADDR_LINKLOCAL ) ? + inc->i_conn->c_dev_if :0 ; msg->msg_namelen =sizeof (*sin6); } }
net/rds/send.c +5 -1
@@ -1222,7 +1222,11 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)lock_sock (sk); daddr = rs->rs_conn_addr; dport = rs->rs_conn_port; - scope_id = rs->rs_bound_scope_id; +/* The connected peer's scope for a link-local peer, else +* the bound scope, as an explicit send to that peer would +* compute below. +*/ + scope_id = rs->rs_conn_scope_id ?: rs->rs_bound_scope_id;release_sock (sk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1767/1848 selftests/net: Add SHA256 computation over data sent in tcp_mmap
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaoyan Li <[email protected]>
[ Upstream commit 5c5945dc695c54f2b55a934a10b6c4e220f9c140 ]
Add option to compute and send SHA256 over data sent (-i).
This is to ensure the correctness of data received. Data is randomly populated from /dev/urandom.
Tested:
./tcp_mmap -s -z -i
./tcp_mmap -z -H $ADDR -i
SHA256 is correct
./tcp_mmap -s -i
./tcp_mmap -H $ADDR -i
SHA256 is correct
Stable-dep-of: 5536d5553f27 ("selftests/net: tcp_mmap: remove unused -k option and keepflag")
--- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/tcp_mmap.c | 102 ++++++++++++++++++++++--- 2 files changed, 92 insertions(+), 12 deletions(-)
tools/testing/selftests/net/Makefile +1 -1
@@ -39,5 +39,5 @@ KSFT_KHDR_INSTALL := 1 include ../lib.mk $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma -$(OUTPUT)/tcp_mmap: LDLIBS += -lpthread +$(OUTPUT)/tcp_mmap: LDLIBS += -lpthread -lcrypto $(OUTPUT)/tcp_inq: LDLIBS += -lpthread
tools/testing/selftests/net/tcp_mmap.c +91 -11
222 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1768/1848 selftests/net: tcp_mmap: remove unused -k option and keepflag
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Thelen <[email protected]>
[ Upstream commit 5536d5553f274c8baa77c44854c9091657213970 ]
Commit aacb0c2e524c ("selftests: net: tcp_mmap must use TCP_ZEROCOPY_RECEIVE") removed the only read of keepflag in child_thread(), leaving the file-scope keepflag variable set by the -k option in main() but never read. This triggers a Clang 23 warning:
tcp_mmap.c:91:12: error: variable 'keepflag' set but not used [-Werror,-Wunused-but-set-global]
Remove the unused keepflag variable and the dead -k getopt option.
--- tools/testing/selftests/net/tcp_mmap.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
tools/testing/selftests/net/tcp_mmap.c +1 -5
@@ -85,7 +85,6 @@ static int rcvbuf; /* Default: autotuning. Can be set with -r <integer> optionstatic int sndbuf;/* Default: autotuning. Can be set with -w <integer> option */ static int zflg;/* zero copy option. (MSG_ZEROCOPY for sender, mmap() for receiver */ static int xflg;/* hash received data (simple xor) (-h option) */ -static int keepflag;/* -k option: receiver shall keep all received file in memory (no munmap() calls) */ static int integrity;/* -i option: sender and receiver compute sha256 over the data.*/ static size_t chunk_size =512 *1024 ;
@@ -439,7 +438,7 @@ int main(int argc, char *argv[])int sflg =0 ;int mss =0 ; -while ((c =getopt (argc, argv,"46p:svr:w:H:zxkP:M:C:a:i" )) !=-1 ) { +while ((c =getopt (argc, argv,"46p:svr:w:H:zxP:M:C:a:i" )) !=-1 ) {switch (c) {case '4' : cfg_family =PF_INET ;
@@ -473,9 +472,6 @@ int main(int argc, char *argv[])case 'x' : xflg =1 ;break ; -case 'k' : - keepflag =1 ; -break ;case 'P' : max_pacing_rate =atoi (optarg) ;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1769/1848 net/sched: etf: initialise the sock_exterr_skb before filling it
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
[ Upstream commit 7076f684d5132e6a6145e1da2fa74771ecd052e5 ]
report_sock_error() clones the transmitted skb, overlays a struct sock_exterr_skb on its control block and fills in the seven struct sock_extended_err fields, but never clears addr_offset and port. skb_clone() copies cb[] verbatim, so the errqueue entry carries the TX skb's stale control block to the receive side, and the ipv4 error-queue reader trusts those bytes:
net/ipv4/ip_sockglue.c:556
sin->sin_addr.s_addr = *(__be32 *)(skb_network_header(skb) + serr->addr_offset); sin->sin_port = serr->port;
The gate that is supposed to guard that read only asks whether an address was requested at all:
net/ipv4/ip_sockglue.c:484
return serr->ee.ee_origin == SO_EE_ORIGIN_ICMP || serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL || serr->port;
SO_EE_ORIGIN_TXTIME is neither ICMP nor LOCAL, so for sch_etf the gate is decided by serr->port alone -- by the stale byte pair. When it is non-zero the reader dereferences skb_network_header() + addr_offset with an arbitrary offset. On the TCP path cb[40..44) is not zero: the transmit path stored delivered_mstamp there (tcp_rate_skb_sent()), which is exactly where addr_offset/port sit in the arm64 struct layout.
Reached with an unmodified 7.3-rc4 (arm64, KASAN, in-tree modules): a TCP socket enables TX-timestamp error reporting (SO_TXTIME with SOF_TXTIME_REPORT_ERRORS), a sch_etf qdisc drops the packet, and a recvmsg() reaches ip_recv_error():
BUG: KASAN: slab-out-of-bounds in ip_recv_error+0x970/0xa0c Read of size 4 at addr ffff0000158ffdd5 by task A-227-A227-1_S2/113 ip_recv_error+0x970/0xa0c inet_recv_error+0x94/0xdc tcp_recvmsg+0x378/0x408 ... The buggy address is located 149 bytes to the right of allocated 704-byte region
Zero the whole overlay rather than the two fields individually: the errqueue entry is handed to the receive side as a self-contained record, which is what every other producer in the tree already does (sch_etf was the only error-queue producer that cleared neither field). This does not change what the in-tree selftest observes -- so_txtime.c reads only ee_origin/ee_errno/ee_code/ee_data/ee_info, never msg_name or sin_port.
--- net/sched/sch_etf.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_etf.c +1 -0
@@ -147,6 +147,7 @@ static void report_sock_error(struct sk_buff *skb, u32 err, u8 code)return ; serr =SKB_EXT_ERR (clone); +memset (serr,0 ,sizeof (*serr)); serr->ee.ee_errno = err; serr->ee.ee_origin =SO_EE_ORIGIN_TXTIME ; serr->ee.ee_type =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1770/1848 bpf: Propagate btf_add_type() errors in btf_check_all_metas()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Yang <[email protected]>
[ Upstream commit fb2b27d214c3b88d926a303267dd83cfdb428b13 ]
btf_check_all_metas() ignores the return value of btf_add_type(), so a type that could not be registered is silently dropped while the loop keeps walking over the type section.
Both failure modes are reachable:
- -E2BIG. Once the types array reaches its capacity (BTF_MAX_TYPE), every following btf_add_type() fails the same way, so btf_check_all_metas() still returns 0 and the BTF object is created with btf->nr_types capped while hdr->type_len claims more records.
- -ENOMEM. btf->nr_types is not incremented and the array is not grown, so the next type is recorded at the slot of the dropped one and btf->types[] stays off by one with respect to the type ids for all remaining types. btf_type_by_id() then returns the wrong type for those ids for the whole lifetime of the object, and the last type is silently left unresolved.
Propagate the error so that the object is rejected instead.
--- kernel/bpf/btf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/bpf/btf.c +5 -1
@@ -3823,6 +3823,7 @@ static int btf_check_all_metas(struct btf_verifier_env *env)struct btf *btf = env->btf;struct btf_header *hdr;void *cur, *end; +int err; hdr = &btf->hdr; cur = btf->nohdr_data + hdr->type_off;
@@ -3837,7 +3838,10 @@ static int btf_check_all_metas(struct btf_verifier_env *env)if (meta_size <0 )return meta_size; -btf_add_type (env, t); + err =btf_add_type (env, t); +if (err) +return err; + cur += meta_size; env->log_type_id++; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1771/1848 kernel/reboot: avoid potential deadlocks during suspension
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit 66644b992f25f6a33775788c8b69a8bb3d41ad67 ]
Invoking reboot with LINUX_REBOOT_CMD_SW_SUSPEND causes kernel/reboot.c to acquire system_transition_mutex and invoke hibernate(). hibernate() calls lock_system_sleep(), which sets PF_NOFREEZE on current and attempts to acquire system_transition_mutex again, potentially hitting:
WARNING: possible recursive locking detected
--------------------------------------------
syz.3.5755/5950 is trying to acquire lock:ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: lock_system_sleep+0x49/0x70 kernel/power/main.c:71
but task is already holding lock:ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __do_sys_reboot kernel/reboot.c:774 [inline] ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __se_sys_reboot+0x223/0x460 kernel/reboot.c:738
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(system_transition_mutex);
lock(system_transition_mutex);
*** DEADLOCK ***
May be due to missing lock nesting notation
locks held by syz.3.5755/5950: 1, last CPU#0:
#0: ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __do_sys_reboot kernel/reboot.c:774 [inline] #0: ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __se_sys_reboot+0x223/0x460 kernel/reboot.c:738
Call Trace: lock_system_sleep+0x49/0x70 kernel/power/main.c:71 hibernate+0x162/0x680 kernel/power/hibernate.c:784 __do_sys_reboot kernel/reboot.c:816 [inline]
Move the suspension operation outside the scope protected by lock system_transition_mutex.
--- kernel/reboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/reboot.c +2 -2
@@ -385,8 +385,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,#ifdef CONFIG_HIBERNATION case LINUX_REBOOT_CMD_SW_SUSPEND : - ret =hibernate (); -break ; +mutex_unlock (&system_transition_mutex); +return hibernate ();#endif default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1772/1848 profiling: fix sampling step on 64-bit big-endian systems
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avi Weiss <[email protected]>
[ Upstream commit b1d68946a08313895f352af5336623d29739c299 ]
read_profile() stores the sampling step in an unsigned long but copies only four bytes to userspace. On 64-bit big-endian systems (not common obviously), this copies the upper 32 bits and discards the rest, causing /proc/profile to report zero for normal shift values.
Cast to unsigned int so we get the correct 4 bytes, while keeping the shift calculation in unsigned long.
A small C reproducer under qemu-s390x reproduced this and proved the fix works for prof_shift=2.
--- kernel/profile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/profile.c +1 -1
@@ -476,7 +476,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)unsigned long p = *ppos;ssize_t read;char *pnt; -unsigned long sample_step =1UL << prof_shift; +unsigned int sample_step = (unsigned int )(1UL << prof_shift);profile_flip_buffers ();if (p >= (prof_len+1 )*sizeof (unsigned int ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1773/1848 netlink: fix out-of-bounds bitmap access clearing stale mc groups
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 6430fb7f1cc4e329e386521b7b208df443de92f2 ]
netlink_realloc_groups() sizes nlk->groups to the number of groups that exist at bind/ADD_MEMBERSHIP time. When more multicast groups are registered later (e.g. a new genl family), existing sockets keep their smaller bitmap.
When clearing a multicast group of a departing family, __netlink_clear_multicast_users() runs netlink_update_socket_mc() on each socket on mc_list, which does test_bit()/__assign_bit() on group - 1 with no regard to nlk->ngroups. Skip sockets whose bitmap predates the group: such a socket can never have joined it.
The overflow windows differ per architecture, both needing privileged module (un)loading. On 32-bit kernels the ~54 dynamically allocated genl groups already exceed the initial 32-bit bitmap, so the table can grow there directly. On 64-bit kernels the same in-tree set fits the initial 64-bit bitmap only while allocation stays contiguous:genl_allocate_reserve_groups() takes the first free contiguous range and unregister does not compact, so an unload/reload sequence can fragment the ~59 free IDs until no fitting range remains, forcing the table past 64 bits and reaching the same stale-bitmap overflow on the next family teardown.
This issue was discovered by Tencent CodeBuddy Security.
--- net/netlink/af_netlink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/netlink/af_netlink.c +5 -1
@@ -2168,8 +2168,12 @@ void __netlink_clear_multicast_users(struct sock *ksk, unsigned int group)struct netlink_table *tbl = &nl_table[ksk->sk_protocol];struct hlist_node *tmp; -sk_for_each_bound_safe (sk, tmp, &tbl->mc_list) +sk_for_each_bound_safe (sk, tmp, &tbl->mc_list) { +/* bitmap predates the group, can't be a member */ +if (group -1 >=nlk_sk (sk)->ngroups) +continue ;netlink_update_socket_mc (nlk_sk (sk), group,0 ); + } } struct nlmsghdr *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1774/1848 ceph: remove unused field `i_cap_migration_resv`
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Kellermann <[email protected]>
[ Upstream commit a200e12135c96893f7c29bdf97f46868132f695d ]
This field was added 17 years ago by commit de57606c23afd ("ceph:
client types") but it was never used.
This reduces the size of struct ceph_inode_info by 8 bytes.
--- fs/ceph/super.h | 1 - 1 file changed, 1 deletion(-)
fs/ceph/super.h +0 -1
@@ -380,7 +380,6 @@ struct ceph_inode_info {wait_queue_head_t i_cap_wq;/* threads waiting on a capability */ unsigned long i_hold_caps_max;/* jiffies */ struct list_head i_cap_delay_list;/* for delayed cap release to mds */ -struct ceph_cap_reservation i_cap_migration_resv;struct list_head i_cap_snaps;/* snapped state pending flush to mds */ struct ceph_snap_context *i_head_snapc;/* set if wr_buffer_head > 0 or dirty|flushing caps */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1775/1848 ceph: mark the superblock active after mounting
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiubo Li <[email protected]>
[ Upstream commit 32eacfae3b16f6a9c0c20f946115abf5a091c922 ]
ceph_get_tree() calls sget_fc() directly and so never goes through vfs_get_super(), which is what sets SB_ACTIVE after fill_super for filesystems that use it. Before commit 82995cc6c5ae ("libceph, rbd,
ceph: convert to use the new mount API") the flag used to be set by get_sb_nodev(), which did this for ceph, but the conversion dropped it.
SB_ACTIVE is required for iput_final() to retain an inode on the inode LRU instead of evicting it once its last reference goes away. This has gone unnoticed because ceph sets inode_just_drop() for ->drop_inode, which always asks for eviction, so the retain branch in iput_final() was never reachable. The next patch makes ->drop_inode() able to retain inodes, and that needs the flag to actually work.
Set it once the mount is up, like nfs_get_tree() does.
--- fs/ceph/super.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/ceph/super.c +9 -0
@@ -1113,6 +1113,15 @@ static int ceph_get_tree(struct fs_context *fc)dout ("root %p inode %p ino %llx.%llx\n" , res,d_inode (res),ceph_vinop (d_inode (res))); fc->root = fsc->sb->s_root; + +/* +* The mount is up. sget_fc() leaves SB_ACTIVE unset, and, unlike +* filesystems that go through vfs_get_super(), nothing else sets +* it here, so iput_final() would always evict an inode whose +* ->drop_inode() asks to retain it. Set it like nfs_get_tree() +* does. +*/ + sb->s_flags |=SB_ACTIVE ;return 0 ; out_splat:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1776/1848 thermal: Fix CPU mask truncation in power limit trace event
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <[email protected]>
[ Upstream commit 82c9c94f54a444a686e926c872dae4b198d1036f ]
num_possible_cpus() counts CPUs, but CPU IDs need not be contiguous. Using it to size the thermal_power_cpu_limit bitmap can omit CPUs with higher IDs. For example, possible CPUs 0 and 64 produce an eight-byte bitmap on a 64-bit system, dropping CPU 64.
Use nr_cpumask_bits for both sizing and copying the bitmap.
--- include/trace/events/thermal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/trace/events/thermal.h +2 -2
@@ -129,7 +129,7 @@ TRACE_EVENT(thermal_power_cpu_limit,TP_ARGS (cpus, freq, cdev_state, power),TP_STRUCT__entry ( - __bitmask(cpumask, num_possible_cpus()) + __bitmask(cpumask, nr_cpumask_bits) __field(unsigned int, freq ) __field(unsigned long, cdev_state) __field(u32, power )
@@ -137,7 +137,7 @@ TRACE_EVENT(thermal_power_cpu_limit,TP_fast_assign (__assign_bitmask (cpumask,cpumask_bits (cpus), - num_possible_cpus()); + nr_cpumask_bits); __entry->freq = freq; __entry->cdev_state = cdev_state; __entry->power = power;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1777/1848 net/sched: gred: keep the qdisc lock while updating the table
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
[ Upstream commit 306f788134a21a3d60c1eb872d0ec0ce7c7e09bc ]
gred_change_table_def() publishes table->DPs/def/red_flags under sch_tree_lock(), drops the lock, and then keeps writing state the datapath reads without it:
- gred_enable_rio_mode()/gred_disable_rio_mode()/gred_disable_wred_mode()
set/clear table->flags;
- the red_flags_changed loop writes table->tab[i]->red_flags;
- the shadowed-VQ loop frees table->tab[i] and clears the slot.
gred_enqueue() and gred_dequeue() read those same fields (test_bit on table->flags, q->red_flags, t->tab[]/t->DPs) under the same root lock on another CPU, so the post-unlock writes race with the enqueue path:
BUG: KCSAN: data-race in gred_change_table_def [sch_gred] / gred_enqueue [sch_gred] read (marked) to 0xffff000007ad3b00 of 8 bytes by task 110 on cpu 0: gred_enqueue+0x88/0xc60 [sch_gred] dev_qdisc_enqueue+0x4c/0x19c __dev_queue_xmit+0x10a4/0x1ea4
The comment justifying the early unlock only covers the DP-vs-DPs check, which the shadowed-VQ free loop relies on; it does not cover the scalar mode bits and per-VQ red_flags written afterwards. Move the unlock below those updates so everything the datapath reads is published under the lock that protects it.
--- net/sched/sch_gred.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
net/sched/sch_gred.c +9 -7
@@ -435,13 +435,6 @@ static int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps, red_flags_changed = table->red_flags != sopt->flags; table->red_flags = sopt->flags; -/* -* Every entry point to GRED is synchronized with the above code -* and the DP is checked against DPs, i.e. shadowed VQs can no -* longer be found so we can unlock right here. -*/ -sch_tree_unlock (sch); -if (sopt->grio) {gred_enable_rio_mode (table);gred_disable_wred_mode (table);
@@ -467,6 +460,15 @@ static int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps, } } +/* +* Keep the lock until every field the datapath reads (the +* RIO/WRED mode bits, the per-VQ red_flags and the tab[] slots) +* has been updated: gred_enqueue()/gred_dequeue() read them under +* the same lock, so publishing them after the unlock races with +* the enqueue path. +*/ +sch_tree_unlock (sch); +gred_offload (sch,TC_GRED_REPLACE );return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1778/1848 net/sched: taprio: unwind the netdevice notifier if register_qdisc() fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
[ Upstream commit c5234f89d7cb311880ef218cb7a969794a106678 ]
taprio_module_init() registers taprio_device_notifier and then returns register_qdisc()'s error directly. When register_qdisc() fails the notifier stays registered, but the loader's failure path frees the module image without ever calling the __exit function, so netdev_chain is left pointing at taprio_device_notifier.notifier_call -- a function pointer that lives in text that has just been freed.
register_qdisc() has two failure returns: -EEXIST (duplicate .id) and -EINVAL (malformed cl_ops). taprio_class_ops satisfies every checked implication, so -EINVAL is unreachable and -EEXIST is the only reachable failure; it needs a pre-existing "taprio" entry in qdisc_base. In-tree that is reachable only through bpf_qdisc_reg() (CONFIG_NET_SCH_BPF); a module calling the exported register_qdisc() reaches it as well.
Once the notifier is left dangling, the next netdevice event that walks netdev_chain calls through the stale pointer:
BUG: KASAN: vmalloc-out-of-bounds in notifier_call_chain+0x650/0xb5c Read of size 8 at addr ffff80001fc5ab08 by task ip/110 notifier_call_chain+0x650/0xb5c raw_notifier_call_chain+0x34/0x64 call_netdevice_notifiers_info+0xa8/0x198 __dev_close_many+0xe0/0x800 ... >ffff80001fc5ab00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
The shadow row is all f8 (KASAN_VMALLOC_INVALID): the read lands in vmalloc memory that was poisoned when the module image was freed, and the indirect call is unguarded because the only check, func_ptr_is_kernel_text(), is compiled out unless CONFIG_DEBUG_NOTIFIERS.
Mirror the sibling sch_cbs.c and act_mirred.c, which unwind the notifier on this failure path.
--- net/sched/sch_taprio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sched/sch_taprio.c +5 -1
@@ -2023,7 +2023,11 @@ static int __init taprio_module_init(void)if (err)return err; -return register_qdisc (&taprio_qdisc_ops); + err =register_qdisc (&taprio_qdisc_ops); +if (err) +unregister_netdevice_notifier (&taprio_device_notifier); + +return err; } static void __exit taprio_module_exit(void)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1779/1848 clk: cdce925: Size the PLL child name buffer for any int
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Brunet <[email protected]>
[ Upstream commit e9e6b4dc303dff637ef725aca4f4968d7600798b ]
The PLL child node name is built from "PLL%d" in a 6 byte stack buffer. The PLL index is bounded by the chip's num_plls, at most 4, but GCC cannot see that bound and, with W=1, warns that the formatted string may not fit.
Make the buffer large enough to hold any int and use snprintf() with sizeof() so the size stays tied to the declaration.
--- drivers/clk/clk-cdce925.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/clk/clk-cdce925.c +7 -2
@@ -646,7 +646,12 @@ static int cdce925_probe(struct i2c_client *client,int i;int err;struct device_node *np_output; -char child_name[6 ]; +/* +* The PLL number isn't a compile time constant so GCC can't infer +* the number. Make the stack buffer large enough to hold any int +* so Wformat-truncation does not complain. +*/ +char child_name[15 ];struct regmap_config config = { .name ="configuration0" , .reg_bits =8 ,
@@ -718,7 +723,7 @@ static int cdce925_probe(struct i2c_client *client,dev_err (&client->dev,"Failed register PLL %d\n" , i); goto error; } -sprintf (child_name,"PLL%d" , i+1 ); +snprintf (child_name,sizeof (child_name),"PLL%d" , i +1 ); np_output =of_get_child_by_name (node, child_name);if (!np_output)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1780/1848 tipc: fix refcount panic in tipc_rcv() when receiving shared skb
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tung Nguyen <[email protected]>
[ Upstream commit 5308a2049b764aa55513c90c68933abf596c51d2 ]
TIPC assumes that the received skb is not shared with other users. However, syzbot reports a bug triggered by receiving a shared skb:
...
RIP: 0010:pskb_expand_head+0x135a/0x13a0 net/core/skbuff.c:2308 __pskb_pull_tail+0x111/0x1870 net/core/skbuff.c:2890 skb_cow_data+0x2ed/0xc50 net/core/skbuff.c:5398 tipc_aead_decrypt net/tipc/crypto.c:892 [inline] tipc_crypto_rcv+0x346/0x23d0 net/tipc/crypto.c:1843 tipc_rcv+0x4b7/0x1040 net/tipc/node.c:2119 tipc_l2_rcv_msg+0x2d9/0x470 net/tipc/bearer.c:669 deliver_ptype_list_skb net/core/dev.c:2533 [inline]
...
The root cause is that local delivery hooks in the kernel (e.g., deliver_skb()) may increment the skb's reference count (users) before TIPC processes it on ingress.
Fix this by calling skb_share_check() to ensure exclusive ownership before passing the skb to tipc_rcv(). As TIPC needs to modify the skb's data, the cloned skb needs to be uncloned when needed. This can be addressed in separate patch.
--- net/tipc/bearer.c | 4 ++++ 1 file changed, 4 insertions(+)
net/tipc/bearer.c +4 -0
@@ -645,6 +645,10 @@ static int tipc_l2_rcv_msg(struct sk_buff *skb, struct net_device *dev, {struct tipc_bearer *b; + skb =skb_share_check (skb,GFP_ATOMIC ); +if (!skb) +return NET_RX_DROP ; +rcu_read_lock (); b =rcu_dereference (dev->tipc_ptr) ?:rcu_dereference (orig_dev->tipc_ptr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1781/1848 pppoe: drop discovery frames with no MAC header
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 406bf2dc8d6d3e93fdae0b66d2ae99b6b62e479c ]
Commit 8540827ebac6 ("pppoe: fix reception of frames with no mac header") drops PPPoE session frames with no MAC header to avoid reading uninitialized memory.
Apply the same to PPPoE discovery frames, as both functions read eth_hdr(skb)->h_source.
Found by LLM static analysis, and reproduced using the same TUN injection as described in the mentioned commit.
--- drivers/net/ppp/pppoe.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ppp/pppoe.c +3 -0
@@ -496,6 +496,9 @@ static int pppoe_disc_rcv(struct sk_buff *skb, struct net_device *dev,if (skb->pkt_type !=PACKET_HOST ) goto abort; +if (skb_mac_header_len (skb) <ETH_HLEN ) + goto abort; +if (!pskb_may_pull (skb,sizeof (struct pppoe_hdr ))) goto abort;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1782/1848 net: atlantic: Unregister before clearing RXNFC rules
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <[email protected]>
[ Upstream commit 13b364c765e69db1f8446399d8db0b331c23b50c ]
aq_pci_remove() clears the driver's RXNFC rule list before unregistering the netdevice. Until unregister_netdev() returns, ethtool operations can still call aq_get_rxnfc_rule(), aq_get_rxnfc_all_rules(), aq_add_rxnfc_rule(), or aq_del_rxnfc_rule(). Those paths traverse the same unlocked hlist that aq_clear_rxnfc_all_rules() is mutating and freeing.
The race is reachable by issuing RXNFC ethtool commands concurrently with PCI device removal or driver unbind. A reader can dereference a node that has just been freed, and two writers can corrupt the list or free the same rule more than once, causing KASAN reports, list corruption, or a kernel panic.
Reverse the removal order: unregister the netdevice first, then clear the RXNFC rules. After unregister_netdev() returns, ethtool can no longer enter the driver, while the PCI device is still available for the rule-clearing routine to issue hardware commands.
Found during a static-analysis-assisted audit: candidate sites were surfaced by a Coccinelle rule, and the reader/writer paths were confirmed by LLM-assisted (GLM-5.3) code inspection. The issue was not observed at runtime; it is identified by code inspection only.
--- drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +1 -1
@@ -352,9 +352,9 @@ static void aq_pci_remove(struct pci_dev *pdev)struct aq_nic_s *self =pci_get_drvdata (pdev);if (self->ndev) { -aq_clear_rxnfc_all_rules (self);if (self->ndev->reg_state ==NETREG_REGISTERED )unregister_netdev (self->ndev); +aq_clear_rxnfc_all_rules (self);#if IS_ENABLED (CONFIG_MACSEC )aq_macsec_free (self);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1783/1848 net: usb: cdc_ncm: dont enable BHs in tx_fixup under netpoll
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit 108ca34cf4b453f6375a70079e32b11866b02601 ]
netpoll holds the txq lock and calls ndo_start_xmit() with IRQs off but BHs on. The spin_unlock_bh() in cdc_ncm_tx_fixup() then runs pending softirqs. If one of them transmits, it spins on the txq lock that netpoll holds. With netconsole on a cdc_ncm device this ends in a soft or hard lockup.
Every caller of cdc_ncm_tx_fixup() holds the txq lock with BHs or IRQs off, so the softirq user of ctx->mtx cannot interrupt it. Use plain spin_lock().
--- drivers/net/usb/cdc_ncm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/usb/cdc_ncm.c +5 -2
@@ -1517,14 +1517,17 @@ cdc_ncm_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)if (ctx ==NULL ) goto error; -spin_lock_bh (&ctx->mtx); +/* BHs or IRQs are always off here. netpoll only disables IRQs, and +* spin_unlock_bh() would then run softirqs with the txq lock held. +*/ +spin_lock (&ctx->mtx);if (ctx->is_ndp16) skb_out =cdc_ncm_fill_tx_frame (dev, skb,cpu_to_le32 (USB_CDC_NCM_NDP16_NOCRC_SIGN ));else skb_out =cdc_ncm_fill_tx_frame (dev, skb,cpu_to_le32 (USB_CDC_NCM_NDP32_NOCRC_SIGN )); -spin_unlock_bh (&ctx->mtx); +spin_unlock (&ctx->mtx);return skb_out; error:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1784/1848 net: usb: cdc_mbim: dont enable BHs in tx_fixup under netpoll
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <[email protected]>
[ Upstream commit bfd7ced012c7857b5ab5edf7e416c2789b652702 ]
cdc_mbim_tx_fixup() has the same spin_unlock_bh() as cdc_ncm_tx_fixup(). Under netpoll it runs pending softirqs while the txq lock is held, and a transmit from one of them spins on that lock.
Use plain spin_lock() as in cdc_ncm.
--- drivers/net/usb/cdc_mbim.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/usb/cdc_mbim.c +3 -2
@@ -288,9 +288,10 @@ static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb } } -spin_lock_bh (&ctx->mtx); +/* BHs or IRQs are always off here, see cdc_ncm_tx_fixup() */ +spin_lock (&ctx->mtx); skb_out =cdc_ncm_fill_tx_frame (dev, skb, sign); -spin_unlock_bh (&ctx->mtx); +spin_unlock (&ctx->mtx);return skb_out; error:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1785/1848 ALSA: usb-audio: Add correct datainterval in the quirks-table for Microbook II
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sally Marcher <[email protected]>
[ Upstream commit a09c2f3b267e47767b8937f65930567edbb88d44 ]
This patch fixes playback issues on the Microbook II. The correct value was in the older driver for this device
(https://github.com/manuel-rhdt/snd-microbookii/blob/dd304c097bb6a9d52276ac29c6969fa02bc7674a/audio.c#L914).
Datainterval needs to be set explicitly.
--- sound/usb/quirks-table.h | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/quirks-table.h +2 -0
@@ -3496,6 +3496,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), .rates = SNDRV_PCM_RATE_96000, .ep_attr =USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, .rate_min = 96000, .rate_max = 96000, .nr_rates = 1,
@@ -3519,6 +3520,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), .rates = SNDRV_PCM_RATE_96000, .ep_attr =USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, + .datainterval = 1, .rate_min = 96000, .rate_max = 96000, .nr_rates = 1,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1786/1848 net: tun: hold napi_mutex when deleting NAPI in tun_detach_all()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheng Yongkang <[email protected]>
[ Upstream commit 6c799b4998c87bb44574bb090b8728bb3b3dbc47 ]
With IFF_NAPI_FRAGS, tun_get_user() takes tfile->napi_mutex, gets the skb from napi_get_frags() and copies the user data into it before it enters the RCU read-side section around napi_gro_frags().
tun_detach_all() waits with synchronize_net() and then calls tun_napi_del() without napi_mutex. netif_napi_del() frees napi->skb through napi_free_frags(). A writer that is still copying has not yet entered its RCU section, so synchronize_net() does not wait for it, and deleting the device frees the skb while the writer is using it:
BUG: KASAN: slab-use-after-free in skb_copy_datagram_from_iter+0x175/0x720 Read of size 8 at addr ffff888077def990 by task br029-poc/9406 Call Trace: skb_copy_datagram_from_iter+0x175/0x720 tun_get_user+0xb42/0x3d00 tun_chr_write_iter+0x113/0x200 ... Freed by task 9405: kmem_cache_free+0x184/0x670 __netif_napi_del_locked+0x2bb/0x3c0 tun_net_uninit+0x566/0xa70 unregister_netdevice_many_notify+0x1a26/0x2090 rtnl_dellink+0x514/0x710
__tun_detach() also calls tun_napi_del() without the mutex, but only from tun_chr_close(), when no write on that file can be in flight.
Take napi_mutex around tun_napi_del() in tun_detach_all() for both attached and disabled queues.
--- drivers/net/tun.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/tun.c +4 -0
@@ -748,14 +748,18 @@ static void tun_detach_all(struct net_device *dev)synchronize_net ();for (i =0 ; i < n; i++) { tfile =rtnl_dereference (tun->tfiles[i]); +mutex_lock (&tfile->napi_mutex);tun_napi_del (tfile); +mutex_unlock (&tfile->napi_mutex);/* Drop read queue */ tun_queue_purge (tfile);xdp_rxq_info_unreg (&tfile->xdp_rxq);sock_put (&tfile->sk); }list_for_each_entry_safe (tfile, tmp, &tun->disabled, next) { +mutex_lock (&tfile->napi_mutex);tun_napi_del (tfile); +mutex_unlock (&tfile->napi_mutex);tun_enable_queue (tfile);tun_queue_purge (tfile);xdp_rxq_info_unreg (&tfile->xdp_rxq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1787/1848 net: rds: add missing __init/__exit annotations to module init/exit funcs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiu Jianfeng <[email protected]>
[ Upstream commit f0bd32c833826ba666c30af0bae78fc5ca598138 ]
Add missing __init/__exit annotations to module init/exit funcs.
Stable-dep-of: ffbbc315b8b8 ("net/rds: do not initialize transports after rds_init() failed")
--- net/rds/af_rds.c | 2 +- net/rds/rdma_transport.c | 4 ++-- net/rds/tcp.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
net/rds/af_rds.c +1 -1
@@ -944,7 +944,7 @@ module_exit(rds_exit);u32 rds_gen_num; -static int rds_init (void ) +static int __init rds_init (void ) {int ret;
net/rds/rdma_transport.c +2 -2
@@ -310,7 +310,7 @@ static void rds_rdma_listen_stop(void)#endif } -static int rds_rdma_init (void ) +static int __init rds_rdma_init (void ) {int ret;
@@ -326,7 +326,7 @@ static int rds_rdma_init(void) }module_init (rds_rdma_init); -static void rds_rdma_exit (void ) +static void __exit rds_rdma_exit(void) {/* stop listening first to ensure no new connections are attempted */ rds_rdma_listen_stop ();
net/rds/tcp.c +1 -1
@@ -771,7 +771,7 @@ static void rds_tcp_exit(void) }module_exit (rds_tcp_exit); -static int rds_tcp_init (void ) +static int __init rds_tcp_init (void ) {int ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1788/1848 rds:Simplify the allocation of slab caches
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongfu Li <[email protected]>
[ Upstream commit 9f1f70dd850038b37e8b103ef0cc6f5eaeb6a8fc ]
Use the new KMEM_CACHE() macro instead of direct kmem_cache_create to simplify the creation of SLAB caches.
Stable-dep-of: ffbbc315b8b8 ("net/rds: do not initialize transports after rds_init() failed")
--- net/rds/tcp.c | 4 +--- net/rds/tcp_recv.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-)
net/rds/tcp.c +1 -3
@@ -775,9 +775,7 @@ static int __init rds_tcp_init(void) {int ret; - rds_tcp_conn_slab =kmem_cache_create ("rds_tcp_connection" , -sizeof (struct rds_tcp_connection ), -0 ,0 ,NULL ); + rds_tcp_conn_slab =KMEM_CACHE (rds_tcp_connection,0 );if (!rds_tcp_conn_slab) { ret = -ENOMEM ; goto out;
net/rds/tcp_recv.c +1 -3
@@ -335,9 +335,7 @@ void rds_tcp_data_ready(struct sock *sk)int rds_tcp_recv_init (void ) { - rds_tcp_incoming_slab =kmem_cache_create ("rds_tcp_incoming" , -sizeof (struct rds_tcp_incoming ), -0 ,0 ,NULL ); + rds_tcp_incoming_slab =KMEM_CACHE (rds_tcp_incoming,0 );if (!rds_tcp_incoming_slab)return -ENOMEM ;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1789/1848 net/rds: do not initialize transports after rds_init() failed
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit ffbbc315b8b883a1c0e131fb3186b9428d2812aa ]
rds, rds_rdma and rds_tcp each have their own module_init(). When they are built in, those run in link order, so rds_init() goes first, but do_initcalls() does not stop when it fails. The transports then initialize against a core that has already been torn down: rds_wq has been destroyed, yet rds_ib_dev_put(), rds_ib_unregister_client() and rds_tcp_accept_work() still queue onto or flush it, and rds_trans_register() hands the transports to a core whose socket family may never have been registered.
This was seen with CONFIG_SYSCTL=n, where rds_sysctl_init() failed and rds_ib_init()'s error path then flushed the freed rds_wq [1], but any rds_init() failure after rds_threads_init() has the same effect.
Record whether rds_init() succeeded and have rds_rdma_init() and rds_tcp_init() bail out with -ENODEV otherwise. Modular builds are
unaffected: the transports need symbols exported by rds.ko, so they cannot be loaded unless rds_init() succeeded.
[1] https://lore.kernel.org/oe-lkp/[email protected]
--- net/rds/af_rds.c | 14 ++++++++++++++ net/rds/rdma_transport.c | 3 +++ net/rds/rds.h | 1 + net/rds/tcp.c | 3 +++ 4 files changed, 21 insertions(+)
net/rds/af_rds.c +14 -0
@@ -922,8 +922,11 @@ static void rds6_sock_info(struct socket *sock, unsigned int len, }#endif +static bool rds_initialized; +static void rds_exit (void ) { + rds_initialized = false;sock_unregister (rds_family_ops.family);proto_unregister (&rds_proto);rds_conn_exit ();
@@ -944,6 +947,16 @@ module_exit(rds_exit);u32 rds_gen_num; +/* When RDS is built in, a failed rds_init() does not stop the rds_rdma +* and rds_tcp initcalls from running against a core that has already +* been torn down (rds_wq in particular). Let them bail out early. +*/ +bool rds_is_initialized (void ) +{ +return rds_initialized; +} +EXPORT_SYMBOL_GPL (rds_is_initialized); +static int __init rds_init (void ) {int ret;
@@ -980,6 +993,7 @@ static int __init rds_init(void)rds_info_register_func (RDS6_INFO_SOCKETS , rds6_sock_info);rds_info_register_func (RDS6_INFO_RECV_MESSAGES , rds6_sock_inc_info);#endif + rds_initialized = true; goto out;
net/rds/rdma_transport.c +3 -0
@@ -314,6 +314,9 @@ static int __init rds_rdma_init(void) {int ret; +if (!rds_is_initialized ()) +return -ENODEV ; + ret =rds_ib_init ();if (ret) goto out;
net/rds/rds.h +1 -0
@@ -1009,6 +1009,7 @@ extern unsigned int rds_sysctl_trace_level;int rds_threads_init (void );void rds_threads_exit (void );extern struct workqueue_struct *rds_wq; +bool rds_is_initialized (void );void rds_queue_reconnect (struct rds_conn_path *cp);void rds_connect_worker (struct work_struct *);void rds_shutdown_worker (struct work_struct *);
net/rds/tcp.c +3 -0
@@ -775,6 +775,9 @@ static int __init rds_tcp_init(void) {int ret; +if (!rds_is_initialized ()) +return -ENODEV ; + rds_tcp_conn_slab =KMEM_CACHE (rds_tcp_connection,0 );if (!rds_tcp_conn_slab) { ret = -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1790/1848 x86_energy_perf_policy: Fix optarg keyword matching
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit 0177067d195a4757149f6702af191987377c71c3 ]
Replace strncmp() with strcmp() for exact string matching in parse_optarg_string(). Exact keyword matching is safer and clearer. This prevents accidental matches with longer strings
like "performance-foo".
--- .../x86_energy_perf_policy/x86_energy_perf_policy.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +6 -6
@@ -309,22 +309,22 @@ int parse_optarg_string(char *s)int i;char *endptr; -if (!strncmp (s,"default" ,7 )) +if (strcmp (s,"default" ) ==0 )return OPTARG_NORMAL ; -if (!strncmp (s,"normal" ,6 )) +if (strcmp (s,"normal" ) ==0 )return OPTARG_NORMAL ; -if (!strncmp (s,"power" ,9 )) +if (strcmp (s,"power" ) ==0 )return OPTARG_POWER ; -if (!strncmp (s,"balance-power" ,17 )) +if (strcmp (s,"balance-power" ) ==0 )return OPTARG_BALANCE_POWER ; -if (!strncmp (s,"balance-performance" ,19 )) +if (strcmp (s,"balance-performance" ) ==0 )return OPTARG_BALANCE_PERFORMANCE ; -if (!strncmp (s,"performance" ,11 )) +if (strcmp (s,"performance" ) ==0 )return OPTARG_PERFORMANCE ; i =strtol (s, &endptr,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1791/1848 x86_energy_perf_policy: Cleanup: Check fseek() in VM path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Len Brown <[email protected]>
[ Upstream commit 2778dc35d40e7e84c134ca4cab1376fa58208f80 ]
Add return value validation for fseek() and ensure consistent resource cleanup on all error paths in err_on_hypervisor().
--- .../x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +5 -1
@@ -658,7 +658,11 @@ void err_on_hypervisor(void) flags =strstr (buffer,"flags" );rewind (cpuinfo); -fseek (cpuinfo, flags - buffer,SEEK_SET ); +if (fseek (cpuinfo, flags - buffer,SEEK_SET ) !=0 ) { +fclose (cpuinfo); +free (buffer); +err (1 ,"Failed to seek in /proc/cpuinfo" ); + }if (!fgets (buffer,4096 , cpuinfo)) {fclose (cpuinfo);free (buffer);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1792/1848 perf mmap: Use the head selected by read_init
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moses <[email protected]>
[ Upstream commit 022c64992af554cfd8c564bff86100fb5ed98678 ]
perf_mmap__push() reads the producer head before calling perf_mmap__read_init(), which reads it again to select the range to copy.
If the producer advances between those reads, push() copies through the newer head but stores the earlier head in prev. The next drain starts at that earlier position and can write the same records to perf.data again.
Use the head selected by read_init(): end for forward buffers and start for overwrite buffers. Save it before the copy loop advances start so prev matches the range that was copied.
--- tools/perf/util/mmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/mmap.c +2 -1
@@ -313,7 +313,7 @@ int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu)int perf_mmap__push (struct mmap *md,void *to,int push (struct mmap *map,void *to,void *buf,size_t size)) { -u64 head =perf_mmap__read_head (&md->core); +u64 head;unsigned char *data = md->core.base + page_size;unsigned long size;void *buf;
@@ -323,6 +323,7 @@ int perf_mmap__push(struct mmap *md, void *to,if (rc <0 )return (rc == -EAGAIN ) ?1 :-1 ; + head = md->core.overwrite ? md->core.start : md->core.end; size = md->core.end - md->core.start;if ((md->core.start & md->core.mask) + size != (md->core.end & md->core.mask)) {
Signature · 1 line
2.53.0