6.12.101-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 108/602 ksmbd: validate compound request size before reading StructureSize2
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei (Microsoft) <[email protected]>
[ Upstream commit 15b38176fd1530372905c602fde51fe89ec8c877 ]
When ksmbd validates a compound (chained) SMB2 request, ksmbd_smb2_check_message() reads pdu->StructureSize2 without first checking that the compound element is large enough to contain it. StructureSize2 is a 2-byte field at offset 64 (__SMB2_HEADER_STRUCTURE_SIZE) from the start of each element.
The compound-walking logic only guarantees that a full 64-byte SMB2 header is present for the trailing element: when NextCommand is 0, len is reduced to the number of bytes remaining after next_smb2_rcv_hdr_off. A remote client can craft a compound request whose last element has exactly 64 bytes, so the 2-byte StructureSize2 read at offset 64 extends one byte past the receive buffer, producing a slab-out-of-bounds read.
BUG: KASAN: slab-out-of-bounds in ksmbd_smb2_check_message (fs/smb/server/smb2misc.c:402) Read of size 2 at addr ffff888012ae31ac by task kworker/0:1/14 The buggy address is located 172 bytes inside of allocated 173-byte region Workqueue: ksmbd-io handle_ksmbd_work Call Trace: ... kasan_report (mm/kasan/report.c:595) ksmbd_smb2_check_message (fs/smb/server/smb2misc.c:402) handle_ksmbd_work (fs/smb/server/server.c:119) process_one_work (kernel/workqueue.c:3314) worker_thread (kernel/workqueue.c:3397) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245)
Reject any compound element that is too small to hold StructureSize2 before dereferencing it.
--- fs/smb/server/smb2misc.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/smb/server/smb2misc.c +5 -0
@@ -400,6 +400,11 @@ int ksmbd_smb2_check_message(struct ksmbd_work *work)return 1 ; } +if (len < __SMB2_HEADER_STRUCTURE_SIZE +sizeof (__le16)) { +ksmbd_debug (SMB ,"Message is too small for StructureSize2\n" ); +return 1 ; + } +if (smb2_req_struct_sizes[command] != pdu->StructureSize2) { if (!(command == SMB2_OPLOCK_BREAK_HE && (le16_to_cpu(pdu->StructureSize2) == OP_BREAK_STRUCT_SIZE_20 ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 109/602 drm/i915/selftests: Fix GT PM sort comparators
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emre Cecanpunar <[email protected]>
[ Upstream commit 612978b83f45bf7018815209db5395d759db6f26 ]
Compare the sampled clock values instead of their addresses. Comparing addresses leaves the samples unsorted, preventing the code from discarding the minimum and maximum samples.
--- drivers/gpu/drm/i915/gt/selftest_gt_pm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/gt/selftest_gt_pm.c +4 -4
@@ -16,9 +16,9 @@ static int cmp_u64(const void *A, const void *B) {const u64 *a =A , *b =B ; -if (a < b) +if (*a < *b)return -1 ; -else if (a > b) +else if (*a > *b)return 1 ;else return 0 ;
@@ -28,9 +28,9 @@ static int cmp_u32(const void *A, const void *B) {const u32 *a =A , *b =B ; -if (a < b) +if (*a < *b)return -1 ; -else if (a > b) +else if (*a > *b)return 1 ;else return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 110/602 net/sched: act_tunnel_key: Defer dst_release to RCU callback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit f1f5c8a3955f8fda3f84ed883ac8daa1847e724c ]
Fix a race-condition use-after-free in tunnel_key_release_params().
The function releases the metadata_dst of the old params synchronously via dst_release() while deferring the params struct free with kfree_rcu(). A concurrent tunnel_key_act() reader on the datapath may still hold the old params pointer (under rcu_read_lock_bh) and proceed to call dst_clone(¶ms->tcft_enc_metadata->dst) after the writer's dst_release has already pushed the dst's rcuref to RCUREF_DEAD.
[email protected] produced a poc which i (and Victor) verified that KASAN reports:
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:112 BUG: KASAN: slab-use-after-free in atomic_sub_return_release include/linux/atomic/atomic-instrumented.h:326 BUG: KASAN: slab-use-after-free in __rcuref_put include/linux/rcuref.h:109 BUG: KASAN: slab-use-after-free in rcuref_put include/linux/rcuref.h:173 BUG: KASAN: slab-use-after-free in dst_release+0x5b/0x370 net/core/dst.c:168 Write of size 4 at addr ffff88806158de40 by task poc/9388 CPU: 0 UID: 0 PID: 9388 Comm: poc Tainted: G W 7.1.0-rc7 #7 PREEMPT(lazy) Tainted: [W]=WARN Hardware name: QEMU Ubuntu 25.10 PC v2 (i440FX + PIIX, + 10.1 machine, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 print_report+0x139/0x4ad mm/kasan/report.c:482 kasan_report+0xe4/0x1d0 mm/kasan/report.c:595 check_region_inline mm/kasan/generic.c:186 kasan_check_range+0x125/0x200 mm/kasan/generic.c:200 instrument_atomic_read_write include/linux/instrumented.h:112 atomic_sub_return_release include/linux/atomic/atomic-instrumented.h:326 __rcuref_put include/linux/rcuref.h:109 rcuref_put include/linux/rcuref.h:173 dst_release+0x5b/0x370 net/core/dst.c:168 refdst_drop include/net/dst.h:272 skb_dst_drop include/net/dst.h:284 skb_release_head_state+0x293/0x400 net/core/skbuff.c:1163 skb_release_all net/core/skbuff.c:1187 [..] Allocated by task 9391: kasan_save_stack+0x30/0x50 mm/kasan/common.c:57 kasan_save_track+0x14/0x30 mm/kasan/common.c:78 poison_kmalloc_redzone mm/kasan/common.c:398 __kasan_kmalloc+0x9a/0xb0 mm/kasan/common.c:415 kasan_kmalloc include/linux/kasan.h:263 __do_kmalloc_node mm/slub.c:5296 __kmalloc_noprof+0x2f1/0x830 mm/slub.c:5308 kmalloc_noprof include/linux/slab.h:954 kzalloc_noprof include/linux/slab.h:1188 offload_action_alloc+0x2f/0x130 net/core/flow_offload.c:35 tcf_action_offload_add_ex+0x1ba/0x880 net/sched/act_api.c:258 tcf_action_offload_add net/sched/act_api.c:293 tcf_action_init+0x66e/0xa20 net/sched/act_api.c:1547 tcf_action_add+0xf6/0x5d0 net/sched/act_api.c:2101 [..] Freed by task 9391: kasan_save_stack+0x30/0x50 mm/kasan/common.c:57 kasan_save_track+0x14/0x30 mm/kasan/common.c:78 kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584 poison_slab_object mm/kasan/common.c:253 __kasan_slab_free+0x6b/0x90 mm/kasan/common.c:285 kasan_slab_free include/linux/kasan.h:235 slab_free_hook mm/slub.c:2689 slab_free mm/slub.c:6251 kfree+0x21f/0x6b0 mm/slub.c:6566 tcf_action_offload_add_ex+0x4ad/0x880 net/sched/act_api.c:284 tcf_action_offload_add net/sched/act_api.c:293 tcf_action_init+0x66e/0xa20 net/sched/act_api.c:1547 tcf_action_add+0xf6/0x5d0 net/sched/act_api.c:2101 The buggy address belongs to the object at ffff88806158de00 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 64 bytes inside of
freed 256-byte region [ffff88806158de00, ffff88806158df00)
The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88806158d600 pfn:0x6158c head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x4fff00000000240(workingset|head|node=1|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 04fff00000000240 ffff88801c841b40 ffffea0001856290 ffffea0001856190 raw: ffff88806158d600 0000000800100009 00000000f5000000 0000000000000000
head: 04fff00000000240 ffff88801c841b40 ffffea0001856290 ffffea0001856190
head: ffff88806158d600 0000000800100009 00000000f5000000 0000000000000000
head: 04fff00000000001 ffffffffffffff81 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000002
page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 9391, tgid 9378 (poc), ts 123227323196, free_ts 0 set_page_owner include/linux/page_owner.h:32 post_alloc_hook+0xfe/0x140 mm/page_alloc.c:1853 prep_new_page mm/page_alloc.c:1861 get_page_from_freelist+0x110c/0x2fc0 mm/page_alloc.c:3941 __alloc_frozen_pages_noprof+0x263/0x2bc0 mm/page_alloc.c:5221 alloc_slab_page mm/slub.c:3278 allocate_slab mm/slub.c:3467 new_slab+0xa6/0x690 mm/slub.c:3525 refill_objects+0x271/0x420 mm/slub.c:7272 refill_sheaf mm/slub.c:2816 __pcs_replace_empty_main+0x373/0x630 mm/slub.c:4652 alloc_from_pcs mm/slub.c:4750 slab_alloc_node mm/slub.c:4884 __do_kmalloc_node mm/slub.c:5295 __kmalloc_noprof+0x66d/0x830 mm/slub.c:5308 kmalloc_noprof include/linux/slab.h:954 metadata_dst_alloc+0x26/0x90 net/core/dst.c:298 tun_rx_dst include/net/dst_metadata.h:144 __ip_tun_set_dst include/net/dst_metadata.h:208 tunnel_key_init+0xb01/0x1b90 net/sched/act_tunnel_key.c:451 tcf_action_init_1+0x46b/0x6c0 net/sched/act_api.c:1428 tcf_action_init+0x448/0xa20 net/sched/act_api.c:1503 tcf_action_add+0xf6/0x5d0 net/sched/act_api.c:2101
[..]
==================================================================
Fix by moving dst_release() into a custom RCU callback that runs after the grace period, matching the lifetime of the containing params struct. Readers in the datapath therefore always find a live rcuref when calling dst_clone().
--- net/sched/act_tunnel_key.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/sched/act_tunnel_key.c +10 -4
@@ -344,14 +344,20 @@ static const struct nla_policy tunnel_key_policy[TCA_TUNNEL_KEY_MAX + 1] = { [TCA_TUNNEL_KEY_ENC_TTL] = { .type = NLA_U8 }, }; -static void tunnel_key_release_params (struct tcf_tunnel_key_params *p) +static void tunnel_key_release_params_rcu (struct rcu_head *head) { -if (!p) -return ; +struct tcf_tunnel_key_params *p =container_of (head,typeof (*p), rcu); +if (p->tcft_action ==TCA_TUNNEL_KEY_ACT_SET )dst_release (&p->tcft_enc_metadata->dst); +kfree (p); +} -kfree_rcu (p, rcu); +static void tunnel_key_release_params (struct tcf_tunnel_key_params *p) +{ +if (!p) +return ; +call_rcu (&p->rcu, tunnel_key_release_params_rcu); } static int tunnel_key_init(struct net *net, struct nlattr *nla,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 111/602 sctp: fix auth_hmacs array size in struct sctp_cookie
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit e0b5252a59383b77d1b8dbeda00b7184dd95f4d3 ]
The auth_hmacs array in struct sctp_cookie is supposed to store a complete SCTP_AUTH_HMAC_ALGO parameter, which consists of a struct sctp_paramhdr followed by N HMAC identifiers.
However, the array size was calculated using an extra 2 bytes instead of sizeof(struct sctp_paramhdr), which is 4 bytes. When four HMAC identifiers are configured, the HMAC-ALGO parameter stored in the endpoint is larger than the auth_hmacs buffer in the cookie.
As a result, sctp_association_init() copies beyond the end of auth_hmacs when initializing the association, corrupting the adjacent auth_chunks field. This can lead to an invalid HMAC identifier being accepted and later cause an out-of-bounds read in sctp_auth_get_hmac().
Fix the array size calculation by including the full SCTP parameter header size.
--- include/net/sctp/structs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/net/sctp/structs.h +2 -1
@@ -319,7 +319,8 @@ struct sctp_cookie {__u8 auth_random[sizeof (struct sctp_paramhdr ) +SCTP_AUTH_RANDOM_LENGTH ]; -__u8 auth_hmacs[SCTP_AUTH_NUM_HMACS *sizeof (__u16) +2 ]; +__u8 auth_hmacs[sizeof (struct sctp_paramhdr ) + +SCTP_AUTH_NUM_HMACS *sizeof (__u16)];__u8 auth_chunks[sizeof (struct sctp_paramhdr ) +SCTP_AUTH_MAX_CHUNKS ];/* This is a shim for my peer's INIT packet, followed by
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 112/602 mpls: fix NULL deref in mpls_valid_fib_dump_req() on CONFIG_INET=n
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 56d96fededd61192cd7cc8d2b0f36adfd59036c3 ]
On CONFIG_INET=n builds, mpls_valid_fib_dump_req() walks the parsed attribute table itself instead of calling ip_valid_fib_dump_req(). The RTA_OIF arm passes tb[RTA_OIF] to nla_get_u32() without checking it is present, so an RTM_GETROUTE dump for AF_MPLS with strict checking and no RTA_OIF hits a NULL dereference.
RTM_GETROUTE is RTNL_KIND_GET, which rtnetlink_rcv_msg() permits without CAP_NET_ADMIN, so an unprivileged user can trigger it.
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:mpls_valid_fib_dump_req (net/mpls/af_mpls.c:2189)
Call Trace:
mpls_dump_routes (net/mpls/af_mpls.c:2236)
netlink_dump (net/netlink/af_netlink.c:2331)
__netlink_dump_start (net/netlink/af_netlink.c:2446)
rtnetlink_rcv_msg (net/core/rtnetlink.c:7033)
netlink_rcv_skb (net/netlink/af_netlink.c:2556)
netlink_unicast (net/netlink/af_netlink.c:1345)
netlink_sendmsg (net/netlink/af_netlink.c:1900)
__sock_sendmsg (net/socket.c:790)
____sys_sendmsg (net/socket.c:2684)
___sys_sendmsg (net/socket.c:2738)
__sys_sendmsg (net/socket.c:2770)
do_syscall_64 (arch/x86/entry/syscall_64.c:94)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)Skip unset attributes, as ip_valid_fib_dump_req() does.
--- net/mpls/af_mpls.c | 3 +++ 1 file changed, 3 insertions(+)
net/mpls/af_mpls.c +3 -0
@@ -2123,6 +2123,9 @@ static int mpls_valid_fib_dump_req(struct net *net, const struct nlmsghdr *nlh,int ifindex;if (i ==RTA_OIF ) { +if (!tb[i]) +continue ; + ifindex =nla_get_u32 (tb[i]); filter->dev =__dev_get_by_index (net, ifindex);if (!filter->dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 113/602 usb: core: sysfs: add lock to bos_descriptors_read()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Griffin Kroah-Hartman <[email protected]>
commit 4e0197fbb0eec588795d5431716a244d9ac8fa93 upstream.
Add a lock to the function bos_descriptors_read().
This function accesses udev->bos, which could be simultaneously freed in usb_reset_and_verify_device(), a function that is commonly called in drivers all over the kernel.
--- drivers/usb/core/sysfs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/core/sysfs.c +7 -1
@@ -899,10 +899,15 @@ bos_descriptors_read(struct file *filp, {struct device *dev =kobj_to_dev (kobj);struct usb_device *udev =to_usb_device (dev); -struct usb_host_bos *bos = udev->bos; +struct usb_host_bos *bos;struct usb_bos_descriptor *desc;size_t desclen, n =0 ; +int rc; + rc =usb_lock_device_interruptible (udev); +if (rc <0 ) +return -EINTR ; + bos = udev->bos;if (bos) { desc = bos->desc; desclen =le16_to_cpu (desc->wTotalLength);
@@ -911,6 +916,7 @@ bos_descriptors_read(struct file *filp,memcpy (buf, (void *) desc + off, n); } } +usb_unlock_device (udev);return n; } static BIN_ATTR_RO(bos_descriptors, 65535); /* max-size BOS */
Greg Kroah-Hartman
maintainerPATCH 114/602 wifi: at76c50x-usb: avoid length underflow in at76_guess_freq()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huihui Huang <[email protected]>
commit 61a799ffd1e5a4fd3702d547828b7ff3d161468e upstream.
at76_guess_freq() checks only that the received frame is at least a bare 802.11 header (24 bytes) before subtracting the fixed management-body offset:
len -= el_off;
For both beacon and probe response frames, el_off is 36. If the frame is shorter than el_off, subtracting it causes the calculated IE length to wrap. The length is eventually passed to cfg80211_find_elem_match() as a very large unsigned value, so the element walk runs beyond the RX skb.
This path is reached from at76_rx_tasklet() while scanning. If the device delivers a truncated beacon or probe response, the oversized IE length causes an out-of-bounds read during scanning.
Skip the IE lookup if the frame does not reach the variable elements, before subtracting el_off.
--- drivers/net/wireless/atmel/at76c50x-usb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/wireless/atmel/at76c50x-usb.c +5 -2
@@ -1521,13 +1521,16 @@ static inline int at76_guess_freq(structif (ieee80211_is_probe_resp (hdr->frame_control)) { el_off = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); - el = ((struct ieee80211_mgmt *)hdr)->u.probe_resp.variable; }else if (ieee80211_is_beacon (hdr->frame_control)) { el_off = offsetof(struct ieee80211_mgmt, u.beacon.variable); - el = ((struct ieee80211_mgmt *)hdr)->u.beacon.variable; }else { goto exit; } + +if (len < el_off) + goto exit; + + el = priv->rx_skb->data + el_off; len -= el_off; el =cfg80211_find_ie (WLAN_EID_DS_PARAMS , el, len);
Greg Kroah-Hartman
maintainerPATCH 115/602 usb: core: port: Deattach Type-C connector on component unbind
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chia-Lin Kao (AceLan) <[email protected]>
commit e0b291fe117964037e0ba382eff4bb365d531c3a upstream.
connector_unbind() is the mirror of connector_bind(), but it is missing the symmetric call to typec_deattach() that connector_bind() makes via:
if (port_dev->child)
typec_attach(port_dev->connector, &port_dev->child->dev);When a Thunderbolt dock is unplugged, two teardown paths race:
1. The component framework calls connector_unbind() first, which sets port_dev->connector = NULL without calling typec_deattach(). This leaves port->usb2_dev/port->usb3_dev in struct typec_port pointing at the USB device that is about to be freed.
2. usb_disconnect() then calls typec_deattach(port_dev->connector, ...), but port_dev->connector is already NULL, so the call is a no-op and port->usb2_dev is never cleared.
3. Concurrently, UCSI detects a PD partner-disconnect event and calls typec_unregister_partner(), which reads port->usb2_dev (now a dangling pointer to freed memory) and passes it to typec_partner_unlink_device() -> sysfs_remove_link() -> dev_name() on the freed device, corrupting the typec/UCSI partner state.
This corruption leaves the Thunderbolt tunnel in an inconsistent state on the next dock hot-plug. On affected hardware the dock's I225/igc NIC fails to enumerate: AER fires a slot reset while the igc driver is still initialising ("PCIe link lost"), and the subsequent igc_reset attempt hits igc_rd32 on an already-detached device:
igc 0000:2e:00.0 eth0: PCIe link lost, device now detached
igc: Failed to read reg 0x0!
WARNING: CPU: 9 PID: 129 at drivers/net/ethernet/intel/igc/igc_main.c:7005
igc_rd32+0xa4/0xc0 [igc]
Call Trace:
igc_disable_pcie_master+0x16/0xa0 [igc]
igc_reset_hw_base+0x14/0x170 [igc]
igc_reset+0x63/0x110 [igc]
igc_io_slot_reset+0x9e/0xd0 [igc]
report_slot_reset+0x5d/0xc0
pcie_do_recovery+0x209/0x400
aer_isr_one_error_type+0x235/0x430
aer_isr+0x4e/0x80
irq_thread+0xf4/0x1f04. UCSI later handles the PD partner-disconnect and calls typec_unregister_partner(), which still sees the stale port->usb2_dev and tries to remove its sysfs link a second time:
kernfs: can not remove 'typec', no directory
WARNING: CPU: 6 PID: 55 at fs/kernfs/dir.c:1706 kernfs_remove_by_name_ns+0xe9/0xf0
Workqueue: events ucsi_handle_connector_change [typec_ucsi]
Call Trace:
sysfs_remove_link+0x19/0x50
typec_unregister_partner+0x6e/0x120 [typec]
ucsi_unregister_partner+0x107/0x150 [typec_ucsi]
ucsi_handle_connector_change+0x3ec/0x490 [typec_ucsi]
process_one_work+0x18e/0x3e0
worker_thread+0x2e3/0x420
kthread+0x10a/0x230
ret_from_fork+0x121/0x140
ret_from_fork_asm+0x1a/0x30With worse timing the same stale pointer is dereferenced after the backing memory is freed, turning the warning into a use-after-free.
Fix the asymmetry: call typec_deattach() before clearing port_dev->connector, matching what connector_bind() does on the bind side. typec_partner_deattach() is already protected by port->partner_link_lock, so it serialises safely with the concurrent typec_unregister_partner() path.
--- drivers/usb/core/port.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/core/port.c +2 -0
@@ -724,6 +724,8 @@ static void connector_unbind(struct devisysfs_remove_link (&connector->kobj,dev_name (dev));sysfs_remove_link (&dev->kobj,"connector" ); +if (port_dev->child) +typec_deattach (port_dev->connector, &port_dev->child->dev); port_dev->connector =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 116/602 USB: storage: add NO_ATA_1X quirk for Longmai USB Key
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huang Wei <[email protected]>
commit 3b4ca2e01c1dd8c00b675b794732945f460a471b upstream.
The Longmai Technologies USB Key (0x04b4:0xb708) advertises itself as a SCSI/Bulk-only mass storage device but does not correctly handle ATA pass-through commands. When such a command (ATA_12 or ATA_16) is sent to the device it fails to respond and the transfer eventually times out, leaving the device unusable.
Add an unusual_devs entry for this device that sets the US_FL_NO_ATA_1X flag, so usb-storage short-circuits ATA pass-through commands and returns INVALID COMMAND OPERATION CODE (0x20 0x05 0x24 0x00) instead of forwarding them to the device.
Information about the device in /sys/kernel/debug/usb/devices:
T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 12 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=06 Prot=50 MxPS=64 #Cfgs= 1 P: Vendor=04b4 ProdID=b708 Rev= 1.00 S: Manufacturer=Longmai Technologies S: Product=USB Key C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/storage/unusual_devs.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_devs.h +7 -0
@@ -395,6 +395,13 @@ UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x USB_SC_DEVICE, USB_PR_CB, NULL, US_FL_MAX_SECTORS_MIN), +/* Reported by Ai Chao <[email protected]> */ +UNUSUAL_DEV (0x04b4 ,0xb708 ,0x0000 ,0xffff , +"Longmai Technologies" , +"USB Key" , +USB_SC_SCSI ,USB_PR_BULK ,NULL , + US_FL_NO_ATA_1X), +/* * Reported by Simon Levitt <[email protected]> * This entry needs Sub and Proto fields
Greg Kroah-Hartman
maintainerPATCH 117/602 usb: chipidea: fix usage_count leak when autosuspend_delay is negative
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yang <[email protected]>
commit fc3afb5728e297994863f8a2a01b88a920bbf53e upstream.
The probe() calls pm_runtime_use_autosuspend(), but remove() does not call pm_runtime_dont_use_autosuspend(). This can lead to a usage_count leak if autosuspend_delay is set to a negative value.
The pm_runtime_use_autosuspend() also notes that it's important to undo this with pm_runtime_dont_use_autosuspend() at driver exit time.
--- drivers/usb/chipidea/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/chipidea/core.c +1 -0
@@ -1265,6 +1265,7 @@ static void ci_hdrc_remove(struct platfousb_role_switch_unregister (ci->role_switch);if (ci->supports_runtime_pm) { +pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_get_sync (&pdev->dev);pm_runtime_disable (&pdev->dev);pm_runtime_put_noidle (&pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 118/602 usb: gadget: dummy_hcd: prevent fifo_req reuse during giveback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinchao Wang <[email protected]>
commit d5e5cd3654d2b5359a12ea6586120f05b28634ee upstream.
dummy_hcd embeds a single shared usb_request (dum->fifo_req) that the "emulated single-request FIFO" fast-path in dummy_queue() reuses for small IN transfers: it copies the caller's request into it (req->req = *_req) and queues it, treating list_empty(&fifo_req.queue) as "the slot is free".
The completion side (dummy_timer/transfer/nuke/dummy_dequeue) follows the standard pattern: list_del_init(&req->queue) unlinks the request, then the lock is dropped and usb_gadget_giveback_request() invokes req->complete(). But list_del_init() makes fifo_req.queue look empty *before* the completion callback returns, so a concurrent dummy_queue() on another CPU sees the slot as free, reuses fifo_req and runs req->req = *_req -- overwriting req->complete while dummy_timer is mid-calling it. The indirect call then jumps to a clobbered pointer, causing a general protection fault / page fault in dummy_timer (syzkaller extid faf3a6cf579fc65591ca). The clobbering write is an in-bounds memcpy on a live shared object, so KASAN cannot flag it.
Add a fifo_req_busy bit covering the shared request's whole lifetime:
set it in dummy_queue() when the FIFO fast-path takes fifo_req (making it the fast-path guard, replacing the list_empty(&fifo_req.queue) test), and clear it after the completion callback has returned, via a dummy_giveback() helper used at all four gadget-request giveback sites. The shared slot can no longer be reused until its completion callback has finished.
--- drivers/usb/gadget/udc/dummy_hcd.c | 40 ++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-)
drivers/usb/gadget/udc/dummy_hcd.c +27 -13
@@ -277,6 +277,7 @@ struct dummy { unsigned ints_enabled:1; unsigned udc_suspended:1; unsigned pullup:1; + unsigned fifo_req_busy:1;/* * HOST side support
@@ -328,6 +329,26 @@ static inline struct dummy *gadget_dev_t/* DEVICE/GADGET SIDE UTILITY ROUTINES */ +/* +* Give back a gadget request with dum->lock dropped around the callback. +* If @req is the shared fifo_req, clear fifo_req_busy afterward: the flag +* was set in dummy_queue() when the shared request was taken and must stay +* set until its completion callback has returned; list_del_init() alone +* makes the request look idle while the callback is still running. +* Caller holds dum->lock and has already done list_del_init() + status. +*/ +static void dummy_giveback (struct dummy *dum,struct usb_ep *_ep, +struct dummy_request *req) +{ +bool fifo = req == &dum->fifo_req; + +spin_unlock (&dum->lock); +usb_gadget_giveback_request (_ep, &req->req); +spin_lock (&dum->lock); +if (fifo) + dum->fifo_req_busy =0 ; +} +/* called with spinlock held */ static void nuke (struct dummy *dum,struct dummy_ep *ep) {
@@ -338,9 +359,7 @@ static void nuke(struct dummy *dum, strulist_del_init (&req->queue); req->req.status = -ESHUTDOWN ; -spin_unlock (&dum->lock); -usb_gadget_giveback_request (&ep->ep, &req->req); -spin_lock (&dum->lock); +dummy_giveback (dum, &ep->ep, req); } }
@@ -727,10 +746,11 @@ static int dummy_queue(struct usb_ep *_e/* implement an emulated single-request FIFO */ if (ep->desc && (ep->desc->bEndpointAddress &USB_DIR_IN ) && -list_empty (&dum->fifo_req.queue) && + !dum->fifo_req_busy &&list_empty (&ep->queue) && _req->length <=FIFO_SIZE ) { req = &dum->fifo_req; + dum->fifo_req_busy =1 ; req->req = *_req; req->req.buf = dum->fifo_buf;memcpy (dum->fifo_buf, _req->buf, _req->length);
@@ -784,9 +804,7 @@ static int dummy_dequeue(struct usb_ep *dev_dbg (udc_dev (dum),"dequeued req %p from %s, len %d buf %p\n" , req, _ep->name, _req->length, _req->buf); -spin_unlock (&dum->lock); -usb_gadget_giveback_request (_ep, _req); -spin_lock (&dum->lock); +dummy_giveback (dum, _ep, req); }spin_unlock_irqrestore (&dum->lock, flags);return retval;
@@ -1522,9 +1540,7 @@ top:if (req->req.status != -EINPROGRESS ) {list_del_init (&req->queue); -spin_unlock (&dum->lock); -usb_gadget_giveback_request (&ep->ep, &req->req); -spin_lock (&dum->lock); +dummy_giveback (dum, &ep->ep, req);/* requests might have been unlinked... */ rescan =1 ;
@@ -1908,9 +1924,7 @@ restart:dev_dbg (udc_dev (dum),"stale req = %p\n" , req); -spin_unlock (&dum->lock); -usb_gadget_giveback_request (&ep->ep, &req->req); -spin_lock (&dum->lock); +dummy_giveback (dum, &ep->ep, req); ep->already_seen =0 ; goto restart; }
Greg Kroah-Hartman
maintainerPATCH 119/602 usb: gadget: f_midi: cancel pending IN work before freeing the midi object
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 5650c18d93a1db7e27cb5a40b394747eb4686d5b upstream.
The f_midi driver embeds a work item (midi->work) whose handler, f_midi_in_work(), dereferences the enclosing struct f_midi through container_of(). This work is armed from two sites: f_midi_complete(), on a normal IN-endpoint completion, and f_midi_in_trigger(), on an ALSA rawmidi output-stream start.
Neither f_midi_disable() nor f_midi_unbind() cancels midi->work. f_midi_disable() only disables the endpoints and drains the in_req_fifo; it does not synchronize the work item, and the sound card is released asynchronously to the final free of the midi object.
The midi object is reference-counted (midi->free_ref) and is freed in f_midi_free() only once both the usb_function reference and the rawmidi private_data reference have been dropped. In f_midi_unbind(), f_midi_disable() runs before the sound card is released, so while the USB endpoints are already disabled the rawmidi device is still usable by an open substream. A concurrent userspace write on such a substream can reach f_midi_in_trigger() and queue midi->work again after f_midi_disable() has returned. A work item armed this way may still be pending when the last reference drops and f_midi_free() proceeds to kfree(midi), letting f_midi_in_work() dereference the struct after it has been freed, a use-after-free.
For this reason cancelling midi->work in f_midi_disable() would not be
sufficient: the ALSA trigger path can rearm the work after disable() returns. Cancelling at the refcount-zero free site is the boundary after which neither arming source can survive, because by then both references that keep the midi object alive have been dropped: the USB endpoints are already disabled and the rawmidi device has been released.
Fix this by calling cancel_work_sync(&midi->work) in the refcount-zero block of f_midi_free(), before the embedded work_struct is freed along with the rest of the structure. opts->lock is a sleeping mutex, so calling cancel_work_sync() under it is permitted, and the handler takes midi->transmit_lock rather than opts->lock, so no self-deadlock can occur while it waits for a running instance of the work to finish.
This issue was found by an in-house static analysis tool.
--- drivers/usb/gadget/function/f_midi.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/function/f_midi.c +1 -0
@@ -1302,6 +1302,7 @@ static void f_midi_free(struct usb_funct opts = container_of(f->fi, struct f_midi_opts, func_inst);mutex_lock (&opts->lock);if (!--midi->free_ref) { +cancel_work_sync (&midi->work);kfree (midi->id);kfifo_free (&midi->in_req_fifo);kfree (midi);
Greg Kroah-Hartman
maintainerPATCH 120/602 usb: gadget: printer: fix infinite loop in printer_read()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Melbin K Mathew <[email protected]>
commit c2e819be6a5c7f34344926b4bd7e3dfca58cf48a upstream.
printer_read() uses the same variable for the requested copy size and the number of bytes actually copied to user space. copy_to_user() returns the number of bytes not copied, so when it fails to copy anything, the computed copied length becomes zero.
In that case len, buf, current_rx_bytes and current_rx_buf are left unchanged. If RX data is available and the user buffer remains unwritable, the read loop can repeat indefinitely.
Track the copied length separately and return -EFAULT, or the number of bytes already copied, if an iteration makes no progress.
--- drivers/usb/gadget/function/f_printer.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/usb/gadget/function/f_printer.c +18 -5
@@ -431,7 +431,7 @@ printer_read(struct file *fd, char __use {struct printer_dev *dev = fd->private_data;unsigned long flags; -size_t size; +size_t size, not_copied, copied;size_t bytes_copied;struct usb_request *req;/* This is a pointer to the current USB rx request. */
@@ -524,10 +524,12 @@ printer_read(struct file *fd, char __useelse size = len; - size -=copy_to_user (buf, current_rx_buf, size); - bytes_copied += size; - len -= size; - buf += size; + not_copied =copy_to_user (buf, current_rx_buf, size); + copied = size - not_copied; + + bytes_copied += copied; + len -= copied; + buf += copied;spin_lock_irqsave (&dev->lock, flags);
@@ -542,6 +544,17 @@ printer_read(struct file *fd, char __useif (dev->interface <0 ) goto out_disabled; +if (!copied) { + dev->current_rx_req = current_rx_req; + dev->current_rx_bytes = current_rx_bytes; + dev->current_rx_buf = current_rx_buf; +spin_unlock_irqrestore (&dev->lock, flags); +mutex_unlock (&dev->lock_printer_io); +return bytes_copied ? bytes_copied : -EFAULT ; + } + + size = copied; +/* If we not returning all the data left in this RX request * buffer then adjust the amount of data left in the buffer. * Othewise if we are done with this RX request buffer then
Greg Kroah-Hartman
maintainerPATCH 121/602 USB: gadget: snps-udc: fix device name leak on probe failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 29a142d3e8b35ebc9e0bcc78f4bc26c9b6a9ac0b upstream.
The gadget device name is set by UDC core when registering the gadget and must not be set before to avoid leaking the name in intermediate error paths (e.g. when detecting an older chip revision).
--- drivers/usb/gadget/udc/snps_udc_core.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/gadget/udc/snps_udc_core.c +0 -1
@@ -3133,7 +3133,6 @@ int udc_probe(struct udc *dev)/* device struct setup */ dev->gadget.ops = &udc_ops; -dev_set_name (&dev->gadget.dev,"gadget" ); dev->gadget.name = name; dev->gadget.max_speed =USB_SPEED_HIGH ;
Greg Kroah-Hartman
maintainerPATCH 122/602 USB: gadget: fsl-udc: fix device name leak on probe failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 6b874d00c466e73c6448a89856407fe46b2f50e4 upstream.
The gadget device name is set by UDC core when registering the gadget and must not be set before to avoid leaking the name in intermediate error paths (e.g. on dma pool creation failure).
--- drivers/usb/gadget/udc/fsl_udc_core.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/gadget/udc/fsl_udc_core.c +0 -1
@@ -2473,7 +2473,6 @@ static int fsl_udc_probe(struct platform udc_controller->gadget.name = driver_name;/* Setup gadget.dev and register with kernel */ -dev_set_name (&udc_controller->gadget.dev,"gadget" ); udc_controller->gadget.dev.of_node = pdev->dev.of_node;if (!IS_ERR_OR_NULL (udc_controller->transceiver))
Greg Kroah-Hartman
maintainerPATCH 123/602 usb: gadget: f_ncm: validate datagram bounds in ncm_unwrap_ntb()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sonali Pradhan <[email protected]>
commit 1febec7e47cdcd01f43fb0211094e3010474666e upstream.
When unpacking host-supplied NTBs, ncm_unwrap_ntb() checks datagram length against frame_max but does not verify that the datagram fits within the declared block length. Additionally, when decoding multiple NTBs from a single socket buffer, subsequent block lengths are not checked against the actual remaining buffer data.
With these checks missing, a malicious USB host can specify datagram offsets and lengths that point beyond the block, or supply secondary NTB headers declaring lengths larger than the buffer. skb_put_data() then copies adjacent kernel memory from skb_shared_info into the network skb.
Fix this by verifying that sufficient buffer space remains for the NTB header before parsing, handling zero-length block declarations, ensuring that block lengths never exceed the remaining buffer space, and verifying that each datagram payload stays strictly within the block boundary.
--- drivers/usb/gadget/function/f_ncm.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/usb/gadget/function/f_ncm.c +13 -4
@@ -1188,6 +1188,10 @@ static int ncm_unwrap_ntb(struct gether frame_max = ncm_opts->max_segment_size; parse_ntb: +if (to_process < (int )opts->nth_size) { +INFO (port->func.config->cdev,"Packet too small for headers\n" ); + goto err; + } tmp = (__le16 *)ntb_ptr;/* dwSignature */
@@ -1208,8 +1212,12 @@ parse_ntb: tmp++;/* skip wSequence */ block_len =get_ncm (&tmp, opts->block_length); +if (block_len ==0 ) + block_len = to_process; +/* (d)wBlockLength */ -if ((block_len < opts->nth_size + opts->ndp_size) || (block_len > ntb_max)) { +if ((block_len < opts->nth_size + opts->ndp_size) || (block_len > ntb_max) || + (block_len > to_process)) {INFO (port->func.config->cdev,"Bad block length: %#X\n" , block_len); goto err; }
@@ -1272,7 +1280,7 @@ parse_ntb: index = index2;/* wDatagramIndex[0] */ if ((index < opts->nth_size) || - (index > block_len - opts->dpe_size)) { + (index > block_len)) {INFO (port->func.config->cdev,"Bad index: %#X\n" , index); goto err;
@@ -1284,7 +1292,8 @@ parse_ntb:* ethernet hdr + crc or larger than max frame size */ if ((dg_len <14 + crc_len) || - (dg_len > frame_max)) { + (dg_len > frame_max) || + (dg_len > block_len - index)) {INFO (port->func.config->cdev,"Bad dgram length: %#X\n" , dg_len); goto err;
@@ -1309,7 +1318,7 @@ parse_ntb: dg_len2 =get_ncm (&tmp, opts->dgram_item_len);/* wDatagramIndex[1] */ -if (index2 > block_len - opts->dpe_size) { +if (index2 > block_len) {INFO (port->func.config->cdev,"Bad index: %#X\n" , index2); goto err;
Greg Kroah-Hartman
maintainerPATCH 124/602 usb: gadget: udc: bdc: free IRQ and drain func_wake_notify before teardown
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
commit 0583f2fbf8f86ae3a0ce054f96783dd83e65d9bb upstream.
The Broadcom BDC UDC driver registers its IRQ handler with devm_request_irq() in bdc_udc_init(), so the IRQ is released by devm only after bdc_remove() returns. devm releases resources in reverse LIFO order, but bdc_remove() runs bdc_udc_exit() and bdc_hw_exit() -> bdc_mem_free() manually before returning: bdc_udc_exit() tears down individual endpoint objects via bdc_free_ep(), while bdc_hw_exit() -> bdc_mem_free() frees and NULLs the DMA-coherent status-report ring (bdc->srr.sr_bds) and kfree()s bdc->bdc_ep_array. Both happen while the IRQ handler (bdc_udc_interrupt, requested with IRQF_SHARED) remains deliverable in the window up to the post-remove devm free_irq().
On receipt of a shared interrupt in that window, bdc_udc_interrupt() dereferences bdc->srr.sr_bds[bdc->srr.dqp_index] (NULL or freed DMA) and dispatches sr_handler callbacks that index into bdc_ep_array, causing a NULL-deref or use-after-free.
The same window affects the delayed_work bdc->func_wake_notify, which is armed from the IRQ handler via bdc_sr_uspc() -> handle_link_state_change() -> schedule_delayed_work() and may self-rearm from its own callback bdc_func_wake_timer(). No cancel exists anywhere in the driver, so a queued work item that fires after bdc_remove() returns and the bdc structure is devm-freed dereferences freed memory.
Replace devm_request_irq() with request_irq() and add an explicit free_irq(bdc->irq, bdc) in bdc_remove(). Clear BDC_GIE before free_irq() to stop the device from asserting interrupts, then free_irq() drains any in-flight handler, then cancel_delayed_work_sync() drains the func_wake_notify delayed work. This ordering ensures the IRQ handler and delayed work cannot interfere with the subsequent endpoint and DMA teardown in bdc_udc_exit() and bdc_hw_exit(). Wire the matching free_irq() into the bdc_udc_init() error path so the IRQ is released on probe failure, and route the bdc_init_ep() failure through err0 instead of returning directly.
This issue was found by an in-house static analysis tool.
--- drivers/usb/gadget/udc/bdc/bdc_core.c | 20 ++++++++++++++++++++ drivers/usb/gadget/udc/bdc/bdc_udc.c | 7 ++++--- 2 files changed, 24 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/bdc/bdc_core.c +20 -0
@@ -586,9 +586,29 @@ disable_clk:static void bdc_remove (struct platform_device *pdev) {struct bdc *bdc; +unsigned long flags; +u32 temp; bdc =platform_get_drvdata (pdev);dev_dbg (bdc->dev,"%s ()\n" , __func__); +/* +* Disable the device interrupt source before freeing the IRQ: +* clear BDC_GIE so the controller stops asserting interrupts, +* then free_irq drains any in-flight handler. +*/ +spin_lock_irqsave (&bdc->lock, flags); + temp =bdc_readl (bdc->regs,BDC_BDCSC ); + temp &= ~BDC_GIE ; +bdc_writel (bdc->regs,BDC_BDCSC , temp); +spin_unlock_irqrestore (&bdc->lock, flags); +free_irq (bdc->irq, bdc); +/* +* Drain func_wake_notify after free_irq: the IRQ handler arms this +* delayed_work via bdc_sr_uspc -> handle_link_state_change -> +* schedule_delayed_work (self-rearmed in bdc_func_wake_timer), so +* the IRQ must be released first to prevent re-arm after cancel. +*/ +cancel_delayed_work_sync (&bdc->func_wake_notify);bdc_udc_exit (bdc);bdc_hw_exit (bdc);bdc_phy_exit (bdc);
drivers/usb/gadget/udc/bdc/bdc_udc.c +4 -3
@@ -530,8 +530,8 @@ int bdc_udc_init(struct bdc *bdc) bdc->gadget.name =BRCM_BDC_NAME ; - ret =devm_request_irq (bdc->dev, bdc->irq, bdc_udc_interrupt, -IRQF_SHARED ,BRCM_BDC_NAME , bdc); + ret =request_irq (bdc->irq, bdc_udc_interrupt,IRQF_SHARED , +BRCM_BDC_NAME , bdc);if (ret) { dev_err(bdc->dev, "failed to request irq #%d %d\n",
@@ -542,7 +542,7 @@ int bdc_udc_init(struct bdc *bdc) ret =bdc_init_ep (bdc);if (ret) {dev_err (bdc->dev,"bdc init ep fail: %d\n" , ret); -return ret; + goto err0; } ret =usb_add_gadget_udc (bdc->dev, &bdc->gadget);
@@ -571,6 +571,7 @@ int bdc_udc_init(struct bdc *bdc) err1:usb_del_gadget_udc (&bdc->gadget); err0: +free_irq (bdc->irq, bdc);bdc_free_ep (bdc);return ret;
Greg Kroah-Hartman
maintainerPATCH 125/602 usb: gadget: uvc: clamp SEND_RESPONSE length to the response buffer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
commit b70dc75e85ba968b7b76eebfe5d63000080b875b upstream.
uvc_send_response() builds the UVC control response from a user-supplied struct uvc_request_data:
req->length = min_t(unsigned int, uvc->event_length, data->length); ... memcpy(req->buf, data->data, req->length);
req->length is clamped to uvc->event_length, which is taken from the host control request wLength (up to UVC_MAX_REQUEST_SIZE, 64), and to data->length, which comes from the UVCIOC_SEND_RESPONSE ioctl and is only checked for being negative. The source buffer data->data is only 60 bytes, so a response with uvc->event_length and data->length both greater than 60 makes memcpy() read past the end of data->data.
Clamp req->length to sizeof(data->data) as well.
--- drivers/usb/gadget/function/uvc_v4l2.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/gadget/function/uvc_v4l2.c +2 -0
@@ -191,6 +191,8 @@ uvc_send_response(struct uvc_device *uvcreturn usb_ep_set_halt (cdev->gadget->ep0); req->length = min_t(unsigned int, uvc->event_length, data->length); +if (req->length >sizeof (data->data)) + req->length =sizeof (data->data); req->zero = data->length < uvc->event_length;memcpy (req->buf, data->data, req->length);
Greg Kroah-Hartman
maintainerPATCH 126/602 USB: serial: ftdi_sio: add support for E+H FXA291
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tim Pambor <[email protected]>
commit fad0fd120e29041b3e6cdf41bb12e3184fb524a2 upstream.
The Commubox FXA291 by Endress+Hauser AG is a USB serial converter based on FT232B which is used to communicate with field devices.
It enumerates using the FTDI vendor ID and a custom PID.
usb 1-9: New USB device found, idVendor=0403, idProduct=e510, bcdDevice= 4.00 usb 1-9: New USB device strings: Mfr=1, Product=2, SerialNumber=0 usb 1-9: Product: FXA291
usb 1-9: Manufacturer: Endress+Hauser
usb 1-9: SerialNumber: 00000000ftdi_sio 1-9:1.0: FTDI USB Serial Device converter detected
usb 1-9: Detected FT232B
usb 1-9: FTDI USB Serial Device converter now attached to ttyUSB0
--- drivers/usb/serial/ftdi_sio.c | 2 ++ drivers/usb/serial/ftdi_sio_ids.h | 5 +++++ 2 files changed, 7 insertions(+)
drivers/usb/serial/ftdi_sio.c +2 -0
@@ -1075,6 +1075,8 @@ static const struct usb_device_id id_tab { USB_DEVICE_INTERFACE_NUMBER(ALTERA_VID, ALTERA_UB3_602E_PID, 3) },/* Abacus Electrics */ { USB_DEVICE(FTDI_VID, ABACUS_OPTICAL_PROBE_PID) }, +/* Endress+Hauser AG devices */ + { USB_DEVICE(FTDI_VID, FTDI_EH_FXA291_PID) }, { } /* Terminating entry */ };
drivers/usb/serial/ftdi_sio_ids.h +5 -0
@@ -314,6 +314,11 @@#define FTDI_ELV_UIO88_PID 0xFB5F/* USB-I/O Interface (UIO 88) */ /* +* Endress+Hauser AG product ids (FTDI_VID) +*/ +#define FTDI_EH_FXA291_PID 0xE510 + +/* * EVER Eco Pro UPS (http://www.ever.com.pl/) */
Greg Kroah-Hartman
maintainerPATCH 127/602 USB: serial: io_edgeport: cap received transmit credits
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sunho Park <[email protected]>
commit faaddd811c5099f11a5f52e68a6b31a5898cda4f upstream.
The interrupt-status packet reports transmit credits returned by the device. edge_interrupt_callback() adds the 16-bit value to txCredits without checking maxTxCredits.
edge_write() uses txCredits minus the software FIFO count as the amount of data that fits. Since the FIFO is allocated with maxTxCredits bytes, txCredits exceeding maxTxCredits can cause OOB write in ring buffer.
Cap accumulated credits at maxTxCredits. Conforming devices should never hit the cap.
--- drivers/usb/serial/io_edgeport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/serial/io_edgeport.c +2 -1
@@ -646,7 +646,8 @@ static void edge_interrupt_callback(struif (edge_port && edge_port->open) {spin_lock_irqsave (&edge_port->ep_lock, flags); - edge_port->txCredits += txCredits; + edge_port->txCredits =min (edge_port->txCredits + txCredits, + edge_port->maxTxCredits);spin_unlock_irqrestore (&edge_port->ep_lock, flags); dev_dbg(dev, "%s - txcredits for port%d = %d\n",
Greg Kroah-Hartman
maintainerPATCH 128/602 USB: serial: keyspan_pda: fix data loss on receive throttling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 42a97c0480f96a2977e6d51ce512adc780f1ef5d upstream.
Killing the interrupt-in urb when the line disciple requests throttling may lead to data loss if an ongoing transfer is cancelled.
Instead set a flag to prevent the completion handler from resubmitting the urb until the port is unthrottled.
--- drivers/usb/serial/keyspan_pda.c | 44 +++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-)
drivers/usb/serial/keyspan_pda.c +35 -9
@@ -35,6 +35,8 @@ struct keyspan_pda_private {struct work_struct unthrottle_work;struct usb_serial *serial;struct usb_serial_port *port; +bool throttled; +bool throttle_req; };static int keyspan_pda_write_start (struct usb_serial_port *port);
@@ -150,6 +152,7 @@ static void keyspan_pda_rx_interrupt(strint retval;int status = urb->status;struct keyspan_pda_private *priv; +bool throttled = false;unsigned long flags; priv =usb_get_serial_port_data (port);
@@ -211,16 +214,24 @@ static void keyspan_pda_rx_interrupt(str } exit: - retval =usb_submit_urb (urb,GFP_ATOMIC ); -if (retval) -dev_err (&port->dev, -"%s - usb_submit_urb failed with result %d\n" , - __func__, retval); +spin_lock_irqsave (&port->lock, flags); +if (priv->throttle_req) { + priv->throttled = true; + throttled = true; + } +spin_unlock_irqrestore (&port->lock, flags); + +if (!throttled) { + retval =usb_submit_urb (urb,GFP_ATOMIC ); +if (retval) +dev_err (&port->dev,"failed to resubmit in urb: %d\n" , retval); + } }static void keyspan_pda_rx_throttle (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data; +struct keyspan_pda_private *priv =usb_get_serial_port_data (port);/* * Stop receiving characters. We just turn off the URB request, and
@@ -230,16 +241,29 @@ static void keyspan_pda_rx_throttle(stru* send an XOFF, although it might make sense to foist that off upon * the device too. */ -usb_kill_urb (port->interrupt_in_urb); +spin_lock_irq (&port->lock); + priv->throttle_req = true; +spin_unlock_irq (&port->lock); }static void keyspan_pda_rx_unthrottle (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data; +struct keyspan_pda_private *priv =usb_get_serial_port_data (port); +bool throttled; +int ret; + +spin_lock_irq (&port->lock); + throttled = priv->throttled; + priv->throttled = false; + priv->throttle_req = false; +spin_unlock_irq (&port->lock); -/* just restart the receive interrupt URB */ -if (usb_submit_urb (port->interrupt_in_urb,GFP_KERNEL )) -dev_dbg (&port->dev,"usb_submit_urb(read urb) failed\n" ); +if (throttled) { + ret =usb_submit_urb (port->interrupt_in_urb,GFP_KERNEL ); +if (ret) +dev_err (&port->dev,"failed to submit in urb: %d\n" , ret); + } }static speed_t keyspan_pda_setbaud (struct usb_serial *serial,speed_t baud)
@@ -579,6 +603,8 @@ static int keyspan_pda_open(struct tty_sspin_lock_irq (&port->lock); priv->tx_room = rc; + priv->throttled = false; + priv->throttle_req = false;spin_unlock_irq (&port->lock); rc =usb_submit_urb (port->interrupt_in_urb,GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 129/602 USB: serial: option: add TDTECH MT5710-CN
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chukun Pan <[email protected]>
commit 55645e4f3c6022ffb160ad3617d2b624eaa38501 upstream.
Add support for the TDTECH MT5710-CN (5G redcap) module based on the Huawei HiSilicon Balong chip.
T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=3466 ProdID=3301 Rev=ff.ff S: Manufacturer=TD Tech Ltd. S: Product=TDTECH MT571X S: SerialNumber=0123456789ABCDEF C:* #Ifs= 6 Cfg#= 1 Atr=c0 MxPwr= 0mA A: FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=0d Prot=00 I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0d Prot=00 Driver=cdc_ncm E: Ad=82(I) Atr=03(Int.) MxPS= 16 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=01 Driver=cdc_ncm E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=13 Driver=option E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=12 Driver=option E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=1c Driver=option E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=14 Driver=option E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
Interface: ECM / NCM + DIAG + AT + SERIAL + GPS
--- drivers/usb/serial/option.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/option.c +1 -0
@@ -2497,6 +2497,7 @@ static const struct usb_device_id option .driver_info = RSVD(5) }, { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x1003, 0xff), /* Rolling RW135R-GL (laptop MBIM) */ .driver_info = RSVD(5) }, + { USB_DEVICE_INTERFACE_CLASS(0x3466, 0x3301, 0xff) }, /* TDTECH MT5710-CN */ { USB_DEVICE_AND_INTERFACE_INFO(0x3731, 0x0100, 0xff, 0xff, 0x30) }, /* NetPrisma LCUK54-WWD for Global */ { USB_DEVICE_AND_INTERFACE_INFO(0x3731, 0x0100, 0xff, 0x00, 0x40) }, { USB_DEVICE_AND_INTERFACE_INFO(0x3731, 0x0100, 0xff, 0xff, 0x40) },
Greg Kroah-Hartman
maintainerPATCH 130/602 crypto: rsa-pkcs1pad: Dont WARN on an empty digest
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Doruk Tan Ozturk <[email protected]>
KEYCTL_PKEY_VERIFY lets an unprivileged caller supply a zero-length digest (in_len == 0). keyctl_pkey_params_get_2() accepts the zero length and the request reaches pkcs1pad_verify(), where the empty digest is rejected but only after being passed through WARN_ON(!digest_size). The warning is therefore directly user-triggerable, and on kernels built with panic_on_warn=1 an unprivileged process can panic the machine -- a local denial of service. Reproduced as UID 65534 in a setuid sandbox.
Keep rejecting the invalid request with -EINVAL, but do not emit a warning for the user-controlled length.
Mainline does not contain this code path; commit 1e562deacecc ("crypto: rsassa-pkcs1 - Migrate to sig_alg backend") removed pkcs1pad_verify() in v6.13-rc1. This is a minimal fix for the affected stable branches. It applies as-is to 6.1.y, 6.6.y and 6.12.y (identical pkcs1pad_verify); the 5.10.y/5.15.y form is sent as a separate patch due to the older req->dst_len spelling.
Found by 0sec automated security-research tooling (https://0sec.ai).
--- crypto/rsa-pkcs1pad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/rsa-pkcs1pad.c +1 -1
@@ -557,7 +557,7 @@ static int pkcs1pad_verify(struct akcipher_request *req)const unsigned int digest_size = req->dst_len;int err; -if (WARN_ON (req->dst) ||WARN_ON (!digest_size) || +if (WARN_ON (req->dst) || !digest_size || !ctx->key_size || sig_size != ctx->key_size)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 131/602 Revert "drm/amd/display: Add missing kdoc for ALLM parameters"
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
This reverts commit 8fa292bd7ea0c19a6f87db967db823f48542e170.
--- drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c +0 -2
@@ -447,8 +447,6 @@ void mod_build_vsc_infopacket(const struct dc_stream_state *stream,* * @stream: contains data we may need to construct VSIF (i.e. timing_3d_format, etc.) * @info_packet: output structure where to store VSIF -* @ALLMEnabled: indicates whether ALLM HF-VSIF should be generated -* @ALLMValue: ALLM bit value to advertise in HF-VSIF */ void mod_build_hf_vsif_infopacket (const struct dc_stream_state *stream,struct dc_info_packet *info_packet)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 132/602 RISC-V: KVM: Serialize virtual interrupt pending state updates
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xie Bo <[email protected]>
commit d024a0a7879e6f37c0152aacf6d8e37b214a1738 upstream.
KVM RISC-V tracks guest local interrupt state with two bitmaps:
- irqs_pending: interrupts that should be visible to the guest
- irqs_pending_mask: interrupts whose pending state changed
The current code updates those bitmaps with independent atomic bitops and assumes a multiple-producer, single-consumer protocol. That model does not actually hold.
kvm_riscv_vcpu_sync_interrupts() is not a pure consumer. When the guest changes guest-visible HVIP state, sync_interrupts() writes both irqs_pending and irqs_pending_mask to reflect the new guest state back into KVM state. As a result, irqs_pending and irqs_pending_mask form a single logical state transition, but they are not updated atomically as a pair.
This allows a race where a newly injected interrupt is lost. For example:
CPU0 CPU1
---- ----
kvm_riscv_vcpu_set_interrupt(VS_SOFT)
set_bit(VS_SOFT, irqs_pending)
kvm_riscv_vcpu_sync_interrupts()
sees guest-cleared HVIP.VSSIP sets irqs_pending_mask clear_bit(IRQ_VS_SOFT, irqs_pending)
set_bit(VS_SOFT, irqs_pending_mask)
kvm_vcpu_kick()
After that interleaving, a later flush can update HVIP without VSSIP even though a new virtual interrupt was injected. In practice, the guest can remain blocked in WFI with work pending.
The same pending/mask protocol is shared by VS soft interrupts, PMU overflow delivery, and AIA high interrupt synchronization, so the race is not limited to one interrupt source.
Fix this by serializing all updates to irqs_pending and irqs_pending_mask with a per-vCPU raw spinlock. This keeps the pending bit and the dirty mask as one state transition across:
- set/unset interrupt
- guest HVIP sync
- interrupt flush to guest CSR state
- vCPU reset
- AIA CSR writes that clear dirty state
Use non-atomic bitmap operations while holding the lock. Hold the lock across the AIA sync, flush, and pending checks as well, so both bitmap words share the same serialization domain.
This intentionally replaces the existing lockless protocol instead of trying to repair it with additional barriers. The problem is not memory ordering on a single field; it is that two separate bitmaps encode one shared state machine while both producers and sync paths can modify them. A per-vCPU raw spinlock keeps the fix small, local, and suitable for backporting.
[ bo: Adapt the reset and CSR helpers to their older signatures. ]
--- arch/riscv/include/asm/kvm_host.h | 10 ++--- arch/riscv/kvm/aia.c | 34 +++++++++++---- arch/riscv/kvm/vcpu.c | 69 ++++++++++++++++++++++--------- arch/riscv/kvm/vcpu_onereg.c | 8 +++- 4 files changed, 87 insertions(+), 34 deletions(-)
arch/riscv/include/asm/kvm_host.h +5 -5
@@ -232,13 +232,13 @@ struct kvm_vcpu_arch {/* * VCPU interrupts * -* We have a lockless approach for tracking pending VCPU interrupts -* implemented using atomic bitops. The irqs_pending bitmap represent -* pending interrupts whereas irqs_pending_mask represent bits changed -* in irqs_pending. Our approach is modeled around multiple producer -* and single consumer problem where the consumer is the VCPU itself. +* The irqs_pending bitmap represents pending interrupts whereas +* irqs_pending_mask represents bits changed in irqs_pending. Updates +* to these bitmaps are serialized so vcpu interrupt sync/flush cannot +* drop a newly injected interrupt while syncing guest-visible HVIP. */ #define KVM_RISCV_VCPU_NR_IRQS 64 +raw_spinlock_t irqs_pending_lock;DECLARE_BITMAP (irqs_pending,KVM_RISCV_VCPU_NR_IRQS );DECLARE_BITMAP (irqs_pending_mask,KVM_RISCV_VCPU_NR_IRQS );
arch/riscv/kvm/aia.c +27 -7
@@ -71,12 +71,15 @@ void kvm_riscv_vcpu_aia_flush_interrupts(struct kvm_vcpu *vcpu)struct kvm_vcpu_aia_csr *csr = &vcpu->arch.aia_context.guest_csr;unsigned long mask, val; +lockdep_assert_held (&vcpu->arch.irqs_pending_lock); +if (!kvm_riscv_aia_available ())return ; -if (READ_ONCE (vcpu->arch.irqs_pending_mask[1 ])) { - mask =xchg_acquire (&vcpu->arch.irqs_pending_mask[1 ],0 ); - val =READ_ONCE (vcpu->arch.irqs_pending[1 ]) & mask; + mask = vcpu->arch.irqs_pending_mask[1 ]; +if (mask) { + vcpu->arch.irqs_pending_mask[1 ] =0 ; + val = vcpu->arch.irqs_pending[1 ] & mask; csr->hviph &= ~mask; csr->hviph |= val;
@@ -87,6 +90,8 @@ void kvm_riscv_vcpu_aia_sync_interrupts(struct kvm_vcpu *vcpu) {struct kvm_vcpu_aia_csr *csr = &vcpu->arch.aia_context.guest_csr; +lockdep_assert_held (&vcpu->arch.irqs_pending_lock); +if (kvm_riscv_aia_available ()) csr->vsieh =csr_read (CSR_VSIEH ); }
@@ -96,13 +101,21 @@ bool kvm_riscv_vcpu_aia_has_interrupts(struct kvm_vcpu *vcpu, u64 mask) {int hgei;unsigned long seip; +#ifdef CONFIG_32BIT +unsigned long flags; +bool pending; +#endif if (!kvm_riscv_aia_available ())return false;#ifdef CONFIG_32BIT -if (READ_ONCE (vcpu->arch.irqs_pending[1 ]) & - (vcpu->arch.aia_context.guest_csr.vsieh &upper_32_bits (mask))) +raw_spin_lock_irqsave (&vcpu->arch.irqs_pending_lock, flags); + pending = vcpu->arch.irqs_pending[1 ] & + (vcpu->arch.aia_context.guest_csr.vsieh & +upper_32_bits (mask)); +raw_spin_unlock_irqrestore (&vcpu->arch.irqs_pending_lock, flags); +if (pending)return true;#endif
@@ -190,6 +203,9 @@ int kvm_riscv_vcpu_aia_set_csr(struct kvm_vcpu *vcpu, unsigned long val) {struct kvm_vcpu_aia_csr *csr = &vcpu->arch.aia_context.guest_csr; +#ifdef CONFIG_32BIT +unsigned long flags; +#endif if (reg_num >=sizeof (struct kvm_riscv_aia_csr ) /sizeof (unsigned long ))return -ENOENT ;
@@ -198,8 +214,12 @@ int kvm_riscv_vcpu_aia_set_csr(struct kvm_vcpu *vcpu, ((unsigned long *)csr)[reg_num] = val;#ifdef CONFIG_32BIT -if (reg_num ==KVM_REG_RISCV_CSR_AIA_REG (siph)) -WRITE_ONCE (vcpu->arch.irqs_pending_mask[1 ],0 ); +if (reg_num ==KVM_REG_RISCV_CSR_AIA_REG (siph)) { +raw_spin_lock_irqsave (&vcpu->arch.irqs_pending_lock, flags); + vcpu->arch.irqs_pending_mask[1 ] =0 ; +raw_spin_unlock_irqrestore (&vcpu->arch.irqs_pending_lock, + flags); + }#endif }
arch/riscv/kvm/vcpu.c +49 -20
165 lines not on this page · raw message
arch/riscv/kvm/vcpu_onereg.c +6 -2
@@ -445,6 +445,7 @@ static int kvm_riscv_vcpu_general_set_csr(struct kvm_vcpu *vcpu, unsigned long reg_val) {struct kvm_vcpu_csr *csr = &vcpu->arch.guest_csr; +unsigned long flags;if (reg_num >=sizeof (struct kvm_riscv_csr ) /sizeof (unsigned long ))return -ENOENT ;
@@ -456,8 +457,11 @@ static int kvm_riscv_vcpu_general_set_csr(struct kvm_vcpu *vcpu, ((unsigned long *)csr)[reg_num] = reg_val; -if (reg_num ==KVM_REG_RISCV_CSR_REG (sip)) -WRITE_ONCE (vcpu->arch.irqs_pending_mask[0 ],0 ); +if (reg_num ==KVM_REG_RISCV_CSR_REG (sip)) { +raw_spin_lock_irqsave (&vcpu->arch.irqs_pending_lock, flags); + vcpu->arch.irqs_pending_mask[0 ] =0 ; +raw_spin_unlock_irqrestore (&vcpu->arch.irqs_pending_lock, flags); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 133/602 usb: xhci-pci: Limit VIA VL805 DMA addressing to 36 bits
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xincheng Zhang <[email protected]>
commit 1fc50f1ecde39feb4fccdaf4bc71aa6c0eb25c49 upstream.
The VIA VL805/806 xHCI controller advertises AC64, but fails to handle DMA addresses at or above 0x1000000000. On systems with large amounts of RAM, this can cause USB device failures when the controller is given DMA addresses beyond its usable address width.
Do not use XHCI_NO_64BIT_SUPPORT for this controller. That quirk clears the cached AC64 capability and limits DMA to 32 bits, causing unnecessary bouncing for addresses between 4GiB and 64GiB and hiding the controller's real AC64 capability from code that may need to distinguish register access width from usable DMA address width.
Track the usable DMA address width separately from the AC64 capability. Initialize the generic xhci->dma_mask_bits field to 64 and let PCI quirks reduce it for controllers with narrower DMA support. Set VIA VL805/806 to 36 bits so the DMA API only hands it addresses in the range it can handle while keeping HCCPARAMS1.AC64 visible.
--- drivers/usb/host/xhci-pci.c | 1 + drivers/usb/host/xhci.c | 15 ++++++++++----- drivers/usb/host/xhci.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-)
drivers/usb/host/xhci-pci.c +1 -0
@@ -454,6 +454,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)if (pdev->vendor ==PCI_VENDOR_ID_VIA && pdev->device ==PCI_DEVICE_ID_VIA_VL805 ) { xhci->quirks |=XHCI_LPM_SUPPORT ; xhci->quirks |=XHCI_TRB_OVERFETCH ; + xhci->dma_mask_bits =36 ; } if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
drivers/usb/host/xhci.c +10 -5
@@ -5259,6 +5259,7 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)if (xhci->hci_version >0x100 ) xhci->hcc_params2 =readl (&xhci->cap_regs->hcc_params2); + xhci->dma_mask_bits =64 ;/* xhci-plat or xhci-pci might have set max_interrupters already */ if ((!xhci->max_interrupters) || xhci->max_interrupters >HCS_MAX_INTRS (xhci->hcs_params1))
@@ -5300,12 +5301,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)if (xhci->quirks &XHCI_NO_64BIT_SUPPORT ) xhci->hcc_params &= ~BIT (0 ); -/* Set dma_mask and coherent_dma_mask to 64-bits, -* if xHC supports 64-bit addressing */ +/* +* Set dma_mask and coherent_dma_mask to 64-bits if xHC supports +* 64-bit addressing, unless a controller-specific quirk callback +* limits the usable address width. +*/ if (HCC_64BIT_ADDR (xhci->hcc_params) && - !dma_set_mask (dev,DMA_BIT_MASK (64 ))) { -xhci_dbg (xhci,"Enabling 64-bit DMA addresses.\n" ); -dma_set_coherent_mask (dev,DMA_BIT_MASK (64 )); + !dma_set_mask (dev,DMA_BIT_MASK (xhci->dma_mask_bits))) { +xhci_dbg (xhci,"Enabling %u-bit DMA addresses.\n" , + xhci->dma_mask_bits); +dma_set_coherent_mask (dev,DMA_BIT_MASK (xhci->dma_mask_bits)); }else {/* * This is to avoid error in cases where a 32-bit USB
drivers/usb/host/xhci.h +1 -0
@@ -1510,6 +1510,7 @@ struct xhci_hcd {/* imod_interval in ns (I * 250ns) */ u32 imod_interval;u32 page_size; +unsigned int dma_mask_bits;/* MSI-X/MSI vectors */ int nvecs;/* optional clocks */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 134/602 wifi: ath9k: hif_usb: dont dereference hif_dev after re-arming firmware request
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheng Yongkang <[email protected]>
[ Upstream commit dad9f96945d77ecd4708f730c06ef54dcd8cc057 ]
ath9k_hif_request_firmware() re-arms an asynchronous firmware load via request_firmware_nowait(), passing hif_dev as the completion context, and then still dereferences hif_dev:
dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n", hif_dev->fw_name);
The re-armed callback ath9k_hif_usb_firmware_cb() runs on the "events" workqueue and, when the firmware is missing, walks the retry chain into ath9k_hif_usb_firmware_fail() -> complete_all(&hif_dev->fw_done). That releases the wait_for_completion(&hif_dev->fw_done) in a concurrent ath9k_hif_usb_disconnect(), which then kfree()s hif_dev. The trailing dev_info() in the frame that re-armed the request can therefore read freed memory (hif_dev->udev, the first field of struct hif_device_usb):
BUG: KASAN: slab-use-after-free in ath9k_hif_request_firmware Read of size 8 ... by task kworker/... ath9k_hif_request_firmware ath9k_hif_usb_firmware_cb drivers/net/wireless/ath/ath9k/hif_usb.c:1247 request_firmware_work_func Allocated by ...: ath9k_hif_usb_probe drivers/net/wireless/ath/ath9k/hif_usb.c Freed by ...: ath9k_hif_usb_disconnect -> kfree drivers/net/wireless/ath/ath9k/hif_usb.c
The fw_done barrier only makes disconnect wait for the firmware chain to *terminate*; it does not protect the outer ath9k_hif_request_firmware() frame that re-armed the request and keeps touching hif_dev afterwards.
Drop the post-request dev_info(): it is the only use of hif_dev after the async request is armed, and it is purely informational (the dev_err() on the failure path runs only when request_firmware_nowait() did not arm a callback, so hif_dev is still alive there).
This was first reported by syzbot as a single, non-reproduced crash that was later auto-obsoleted, and was independently rediscovered by the reFuzz fuzzer, which produced a C reproducer (USB-gadget connect/disconnect of an ath9k_htc device whose firmware download fails). The vulnerable code is unchanged and still present in v7.1-rc6, where the slab-use-after-free reproduces under KASAN once the (sub-microsecond) race window is widened.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +1 -6
@@ -1225,15 +1225,10 @@ static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev, ret =request_firmware_nowait (THIS_MODULE , true, hif_dev->fw_name, &hif_dev->udev->dev,GFP_KERNEL , hif_dev, ath9k_hif_usb_firmware_cb); -if (ret) { +if (ret)dev_err (&hif_dev->udev->dev,"ath9k_htc: Async request for firmware %s failed\n" , hif_dev->fw_name); -return ret; - } - -dev_info (&hif_dev->udev->dev,"ath9k_htc: Firmware %s requested\n" , - hif_dev->fw_name);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 135/602 wifi: ath11k: fix NULL pointer dereference in ath11k_hal_srng_access_begin
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gaole Zhang <[email protected]>
[ Upstream commit e8d85672dd7e2523f774caafba8f858384e18df7 ]
In ATH11K_QMI_EVENT_FW_READY, ATH11K_FLAG_REGISTERED is set unconditionally even when ath11k_core_qmi_firmware_ready() fails. This leaves the driver in an inconsistent state where initialization is considered complete although the firmware ready handling did not finish successfully. During the subsequent SSR, the driver enters the restart path based on this incorrect state and dereferences uninitialized srng members, resulting in a NULL pointer dereference.
Call trace: ath11k_hal_srng_access_begin+0xc/0x60 [ath11k] (P) ath11k_ce_cleanup_pipes+0x17c/0x180 [ath11k] ath11k_core_restart+0x40/0x168 [ath11k]
Fix this by:
- skipping firmware_ready if ATH11K_FLAG_REGISTERED is already set
- setting ATH11K_FLAG_REGISTERED only when firmware_ready succeeds
- setting ATH11K_FLAG_QMI_FAIL and aborting the FW_READY handling on error
Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.2.0.c2-00204-QCAMSLSWPLZ-1
--- drivers/net/wireless/ath/ath11k/qmi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath11k/qmi.c +8 -3
@@ -3295,9 +3295,14 @@ static void ath11k_qmi_driver_event_work(struct work_struct *work)clear_bit (ATH11K_FLAG_CRASH_FLUSH , &ab->dev_flags);clear_bit (ATH11K_FLAG_RECOVERY , &ab->dev_flags); -ath11k_core_qmi_firmware_ready (ab); -set_bit (ATH11K_FLAG_REGISTERED , &ab->dev_flags); - +if (!test_bit (ATH11K_FLAG_REGISTERED , &ab->dev_flags)) { + ret =ath11k_core_qmi_firmware_ready (ab); +if (ret) { +set_bit (ATH11K_FLAG_QMI_FAIL , &ab->dev_flags); +break ; + } +set_bit (ATH11K_FLAG_REGISTERED , &ab->dev_flags); + }break ;case ATH11K_QMI_EVENT_COLD_BOOT_CAL_DONE :break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 136/602 hwmon: (corsair-psu) Stop device IO before calling hid_hw_stop
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit 9ab8656548cd737b98d0b19c4253aff8d68e97f4 ]
hid_hw_stop() does not stop the device IO.
This results in a race condition between hid_input_report() and the point immediately following the execution of hid_device_io_start() within corsairpsu_probe(). If the probe operation fails after "io start" has been initiated, this race condition will result in a uaf vulnerability [1].
CPU0 CPU1
==== ====corsairpsu_probe()
hid_device_io_start()
... unlock driver_input_lock
hid_hw_stop()
kfree(hidraw) __hid_input_report()
... acquire driver_input_lock hid_report_raw_event()
hidraw_report_event()
... access hidraw's list_lock // trigger uaf
Consequently, when corsairpsu_probe() fails and hid_hw_stop() needs to be executed, the io_started flag is first cleared while holding the driver_input_lock to prevent potential race conditions involving input reports.
[1]
BUG: KASAN: slab-use-after-free in rt_spin_lock+0x83/0x400 kernel/locking/spinlock_rt.c:56 Call Trace: hidraw_report_event+0x5d/0x3a0 drivers/hid/hidraw.c:577 hid_report_raw_event+0x311/0x1730 drivers/hid/hid-core.c:2076 __hid_input_report drivers/hid/hid-core.c:2152 [inline] hid_input_report+0x44e/0x580 drivers/hid/hid-core.c:2174 hid_irq_in+0x47e/0x6d0 drivers/hid/usbhid/hid-core.c:286 __usb_hcd_giveback_urb+0x3b3/0x5e0 drivers/usb/core/hcd.c:1657 dummy_timer+0x8a9/0x47d0 drivers/usb/gadget/udc/dummy_hcd.c:2005 Allocated by task 10: hidraw_connect+0x57/0x430 drivers/hid/hidraw.c:606 hid_connect+0x5bf/0x19d0 drivers/hid/hid-core.c:2277 hid_hw_start+0xa8/0x120 drivers/hid/hid-core.c:2387 corsairpsu_probe+0xd9/0x3c0 drivers/hwmon/corsair-psu.c:782 Freed by task 10: hidraw_disconnect+0x4f/0x60 drivers/hid/hidraw.c:662 hid_disconnect drivers/hid/hid-core.c:2362 [inline] hid_hw_stop+0x101/0x1e0 drivers/hid/hid-core.c:2407 corsairpsu_probe+0x327/0x3c0 drivers/hwmon/corsair-psu.c:826
Fix the problem by calling hid_device_io_stop() before calling hid_hw_stop().
[groeck: Updated subject and description;
call hid_device_io_stop() only if IO has been started]
--- drivers/hwmon/corsair-psu.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/corsair-psu.c +1 -0
@@ -831,6 +831,7 @@ static int corsairpsu_probe(struct hid_device *hdev, const struct hid_device_id fail_and_close:hid_hw_close (hdev); +hid_device_io_stop (hdev); fail_and_stop:hid_hw_stop (hdev);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 137/602 hwmon: (corsair-cpro) Stop device IO before calling hid_hw_stop
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 94c87871b051d7ad758828a805215a2ec194512a ]
Calling hid_hw_stop() does not stop the device IO.
This results in a race condition between hid_input_report() and the point immediately following the execution of hid_device_io_start() within the driver probe function. If the probe operation fails after "io start" has been initiated, this race condition will result in a UAF vulnerability.
Fix the problem by calling hid_device_io_stop() before calling hid_hw_stop().
--- drivers/hwmon/corsair-cpro.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/corsair-cpro.c +1 -0
@@ -645,6 +645,7 @@ static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id) out_hw_close:hid_hw_close (hdev); +hid_device_io_stop (hdev); out_hw_stop:hid_hw_stop (hdev);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 138/602 hwmon: (gigabyte_waterforce) Stop device IO before calling hid_hw_stop
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit ff0c5c53d08274e200b48a4d53aa078265e873cb ]
Calling hid_hw_stop() does not stop the device IO.
This results in a race condition between hid_input_report() and the point immediately following the execution of hid_device_io_start() within the driver probe function. If the probe operation fails after "io start" has been initiated, this race condition will result in a UAF vulnerability.
Fix the problem by calling hid_device_io_stop() before calling hid_hw_stop().
--- drivers/hwmon/gigabyte_waterforce.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/gigabyte_waterforce.c +3 -1
@@ -371,13 +371,15 @@ static int waterforce_probe(struct hid_device *hdev, const struct hid_device_idif (IS_ERR (priv->hwmon_dev)) { ret =PTR_ERR (priv->hwmon_dev);hid_err (hdev,"hwmon registration failed with %d\n" , ret); - goto fail_and_close; + goto fail_and_io_stop; }waterforce_debugfs_init (priv);return 0 ; +fail_and_io_stop: +hid_device_io_stop (hdev); fail_and_close:hid_hw_close (hdev); fail_and_stop:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 139/602 hwmon: (nzxt-smart2) Stop device IO before calling hid_hw_stop
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 59d104b54b0b42e30fd2a68d24ee5c49dcc54d1e ]
Calling hid_hw_stop() does not stop the device IO.
This results in a race condition between hid_input_report() and the point immediately following the execution of hid_device_io_start() within the driver probe function. If the probe operation fails after "io start" has been initiated, this race condition will result in a UAF vulnerability.
Fix the problem by calling hid_device_io_stop() before calling hid_hw_stop().
--- drivers/hwmon/nzxt-smart2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/nzxt-smart2.c +1 -1
@@ -774,7 +774,7 @@ static int nzxt_smart2_hid_probe(struct hid_device *hdev, out_hw_close:hid_hw_close (hdev); - +hid_device_io_stop (hdev); out_hw_stop:hid_hw_stop (hdev);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 140/602 hwmon: (nzxt-kraken3) Stop device IO before calling hid_hw_stop
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit f151d0143ac4e086f92f52328ebdbdc50933d8ef ]
Calling hid_hw_stop() does not stop the device IO.
This results in a race condition between hid_input_report() and the point immediately following the execution of hid_device_io_start() within the driver probe function. If the probe operation fails after "io start" has been initiated, this race condition will result in a UAF vulnerability.
Fix the problem by calling hid_device_io_stop() before calling hid_hw_stop().
--- drivers/hwmon/nzxt-kraken3.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/nzxt-kraken3.c +4 -2
@@ -948,7 +948,7 @@ static int kraken3_probe(struct hid_device *hdev, const struct hid_device_id *id ret =kraken3_init_device (hdev);if (ret <0 ) {hid_err (hdev,"device init failed with %d\n" , ret); - goto fail_and_close; + goto fail_and_stop_io; } ret =kraken3_get_fw_ver (hdev);
@@ -960,13 +960,15 @@ static int kraken3_probe(struct hid_device *hdev, const struct hid_device_id *idif (IS_ERR (priv->hwmon_dev)) { ret =PTR_ERR (priv->hwmon_dev);hid_err (hdev,"hwmon registration failed with %d\n" , ret); - goto fail_and_close; + goto fail_and_stop_io; }kraken3_debugfs_init (priv, device_name);return 0 ; +fail_and_stop_io: +hid_device_io_stop (hdev); fail_and_close:hid_hw_close (hdev); fail_and_stop:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 141/602 watchdog: pretimeout: Fix UAF in watchdog_unregister_governor()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tzung-Bi Shih <[email protected]>
[ Upstream commit 7362ba0f9c96ac3ad6a2ca3995bd9fc9a28a8661 ]
When a watchdog governor is unregistered, it updates existing watchdog devices that were using this governor by falling back to default_gov.
If the governor being unregistered is currently set as default_gov, the default_gov is never cleared. This leads to 2 use-after-free issues:
1. New watchdog devices registered after this point will inherit the dangling default_gov.
2. Existing watchdog devices using the unregistered governor will have their wdd->gov reassigned to the dangling default_gov.
Fix the UAF by clearing default_gov if it matches the governor being unregistered.
--- drivers/watchdog/watchdog_pretimeout.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/watchdog/watchdog_pretimeout.c +2 -0
@@ -165,6 +165,8 @@ void watchdog_unregister_governor(struct watchdog_governor *gov) }spin_lock_irq (&pretimeout_lock); +if (default_gov == gov) + default_gov =NULL ;list_for_each_entry (p, &pretimeout_list, entry)if (p->wdd->gov == gov) p->wdd->gov = default_gov;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 142/602 wifi: ath11k: fix potential buffer underflow in ath11k_hal_rx_msdu_list_get()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Morgun <[email protected]>
[ Upstream commit 7f11e70629650ff6ea140984e5ce188b775b2683 ]
When the first entry in msdu_details has a zero buffer address, the code accesses msdu_details[i - 1] with i == 0, causing a buffer underflow.
Fix similarly to ath12k_wifi7_hal_rx_msdu_list_get() by adding a separate check for i == 0 before the main condition to prevent the out-of-bounds access.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/ath/ath11k/dp_rx.c +3 -0
@@ -4614,6 +4614,9 @@ static void ath11k_hal_rx_msdu_list_get(struct ath11k *ar, msdu_details = &msdu_link->msdu_link[0 ];for (i =0 ; i <HAL_RX_NUM_MSDU_DESC ; i++) { +if (!i &&FIELD_GET (BUFFER_ADDR_INFO0_ADDR , + msdu_details[i].buf_addr_info.info0) ==0 ) +break ;if (FIELD_GET (BUFFER_ADDR_INFO0_ADDR , msdu_details[i].buf_addr_info.info0) ==0 ) { msdu_desc_info = &msdu_details[i -1 ].rx_msdu_info;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 143/602 wifi: ath11k: Flush the posted write after writing to PCIE_SOC_GLOBAL_RESET
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 0fe8010fc5b147607fc19ba010ba469afc95f35f ]
ath11k_pci_soc_global_reset() tries to reset the device by writing to the PCIE_SOC_GLOBAL_RESET register. But it doesn't do a read-back to ensure that the write gets flushed to the device before the delay.
This may lead to the delay on the host to be insufficient, if the posted write doesn't reach the device before the delay.
So add a read-back after writing to the PCIE_SOC_GLOBAL_RESET register and before the delay.
Compile tested only.
--- drivers/net/wireless/ath/ath11k/pci.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath11k/pci.c +4 -0
@@ -197,6 +197,8 @@ static void ath11k_pci_soc_global_reset(struct ath11k_base *ab) val |=PCIE_SOC_GLOBAL_RESET_V ;ath11k_pcic_write32 (ab,PCIE_SOC_GLOBAL_RESET , val); +/* Flush the posted write to the device */ +ath11k_pcic_read32 (ab,PCIE_SOC_GLOBAL_RESET );/* TODO: exact time to sleep is uncertain */ delay =10 ;
@@ -206,6 +208,8 @@ static void ath11k_pci_soc_global_reset(struct ath11k_base *ab) val &= ~PCIE_SOC_GLOBAL_RESET_V ;ath11k_pcic_write32 (ab,PCIE_SOC_GLOBAL_RESET , val); +/* Flush the posted write to the device */ +ath11k_pcic_read32 (ab,PCIE_SOC_GLOBAL_RESET );mdelay (delay);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 144/602 wifi: ath12k: Flush the posted write after writing to PCIE_SOC_GLOBAL_RESET
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 55f3aa06951cac78b0206bde961c8cf11929a27a ]
ath12k_pci_soc_global_reset() tries to reset the device by writing to the PCIE_SOC_GLOBAL_RESET register. But it doesn't do a read-back to ensure that the write gets flushed to the device before the delay.
This may lead to the delay on the host to be insufficient, if the posted write doesn't reach the device before the delay.
So add a read-back after writing to the PCIE_SOC_GLOBAL_RESET register and before the delay.
Compile tested only.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/pci.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath12k/pci.c +4 -0
@@ -225,6 +225,8 @@ static void ath12k_pci_soc_global_reset(struct ath12k_base *ab) val |=PCIE_SOC_GLOBAL_RESET_V ;ath12k_pci_write32 (ab,PCIE_SOC_GLOBAL_RESET , val); +/* Flush the posted write to the device */ +ath12k_pci_read32 (ab,PCIE_SOC_GLOBAL_RESET );/* TODO: exact time to sleep is uncertain */ delay =10 ;
@@ -234,6 +236,8 @@ static void ath12k_pci_soc_global_reset(struct ath12k_base *ab) val &= ~PCIE_SOC_GLOBAL_RESET_V ;ath12k_pci_write32 (ab,PCIE_SOC_GLOBAL_RESET , val); +/* Flush the posted write to the device */ +ath12k_pci_read32 (ab,PCIE_SOC_GLOBAL_RESET );mdelay (delay);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 145/602 firewire: net: Fix fragmented datagram reassembly
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit d52a13adbb8ccbab99cd3bad36804e87d8b5c052 ]
fwnet_frag_new() keeps a sorted list of received fragments for a partial datagram. When a new fragment is adjacent to an existing fragment, the code checks whether the new fragment also closes the gap to the next or previous list entry.
Those neighbor lookups currently assume that the current fragment always has a real next or previous fragment. At a list edge, the next or previous entry is the list head, not a struct fwnet_fragment_info.
The gap checks also compare against the old edge of the current fragment instead of the edge after adding the new fragment. As a result, a fragment that bridges two existing ranges may leave two adjacent ranges unmerged, so fwnet_pd_is_complete() can miss a complete datagram.
Check for the list head before looking up the neighboring fragment, and compare the neighbor against the new fragment's far edge when deciding whether to merge all three ranges.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/firewire/net.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-)
drivers/firewire/net.c +21 -18
@@ -298,31 +298,34 @@ static struct fwnet_fragment_info *fwnet_frag_new(if (fi->offset + fi->len == offset) {/* The new fragment can be tacked on to the end */ /* Did the new fragment plug a hole? */ - fi2 =list_entry (fi->fi_link.next, - struct fwnet_fragment_info, fi_link); -if (fi->offset + fi->len == fi2->offset) { -/* glue fragments together */ - fi->len += len + fi2->len; -list_del (&fi2->fi_link); -kfree (fi2); - }else { - fi->len += len; +if (!list_is_last (&fi->fi_link, &pd->fi_list)) { + fi2 =list_next_entry (fi, fi_link); +if (offset + len == fi2->offset) { +/* glue fragments together */ + fi->len += len + fi2->len; +list_del (&fi2->fi_link); +kfree (fi2); + +return fi; + } } + fi->len += len;return fi; }if (offset + len == fi->offset) {/* The new fragment can be tacked on to the beginning */ /* Did the new fragment plug a hole? */ - fi2 =list_entry (fi->fi_link.prev, - struct fwnet_fragment_info, fi_link); -if (fi2->offset + fi2->len == fi->offset) { -/* glue fragments together */ - fi2->len += fi->len + len; -list_del (&fi->fi_link); -kfree (fi); - -return fi2; +if (!list_is_first (&fi->fi_link, &pd->fi_list)) { + fi2 =list_prev_entry (fi, fi_link); +if (fi2->offset + fi2->len == offset) { +/* glue fragments together */ + fi2->len += fi->len + len; +list_del (&fi->fi_link); +kfree (fi); + +return fi2; + } } fi->offset = offset; fi->len += len;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 146/602 wifi: ath6kl: fix OOB read from firmware num_msg in TX complete handler
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
[ Upstream commit 3a21c89215cc18f1a97c5e5bfd1da6d4f3d44495 ]
The firmware-controlled num_msg field (u8, 0-255) drives the loop in ath6kl_wmi_tx_complete_event_rx() without validation against the buffer length. This allows out-of-bounds reads of up to 1020 bytes past the WMI event buffer when the firmware sends an inflated num_msg.
Add a check that the buffer is large enough to hold the fixed struct and the num_msg variable-length entries.
--- drivers/net/wireless/ath/ath6kl/wmi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/wireless/ath/ath6kl/wmi.c +12 -0
@@ -484,6 +484,18 @@ static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) evt = (struct wmi_tx_complete_event *) datap; +if (len <sizeof (*evt)) { +ath6kl_dbg (ATH6KL_DBG_WMI ,"tx complete: invalid len %d\n" , + len); +return -EINVAL ; + } + +if (len <sizeof (*evt) + evt->num_msg *sizeof (struct tx_complete_msg_v1 )) { +ath6kl_dbg (ATH6KL_DBG_WMI ,"tx complete: invalid len %d for %u msgs\n" , + len, evt->num_msg); +return -EINVAL ; + } +ath6kl_dbg (ATH6KL_DBG_WMI ,"comp: %d %d %d\n" , evt->num_msg, evt->msg_len, evt->msg_type);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 147/602 wifi: ath6kl: fix OOB read from firmware IE lengths in connect event
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
[ Upstream commit 6b47b29730de3232b919d8362749f6814c5f2a33 ]
The firmware-controlled beacon_ie_len, assoc_req_len, and assoc_resp_len fields in ath6kl_wmi_connect_event_rx() are not validated against the buffer length. Their sum (up to 765) can exceed the actual WMI event data, causing out-of-bounds reads during IE parsing and state corruption of wmi->is_wmm_enabled.
Add a check that the total IE length fits within the buffer.
--- drivers/net/wireless/ath/ath6kl/wmi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/wireless/ath/ath6kl/wmi.c +8 -0
@@ -874,6 +874,14 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, ev = (struct wmi_connect_event *) datap; +if (len <sizeof (*ev) + ev->beacon_ie_len + + ev->assoc_req_len + ev->assoc_resp_len) { +ath6kl_dbg (ATH6KL_DBG_WMI , +"connect event: IE lengths %u+%u+%u exceed buffer %d\n" , + ev->beacon_ie_len, ev->assoc_req_len, + ev->assoc_resp_len, len); +return -EINVAL ; + }if (vif->nw_type ==AP_NETWORK ) {/* AP mode start/STA connected event */ struct net_device *dev = vif->ndev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 148/602 wifi: carl9170: bound memcpy length in cmd callback to prevent OOB read
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
[ Upstream commit 4cde55b2feff9504d1f993ab80e84e7ccb62791c ]
When the firmware sends a command response with a length mismatch, carl9170_cmd_callback() logs the mismatch and calls carl9170_restart() but then falls through to memcpy(ar->readbuf, buffer + 4, len - 4). Since len comes from the firmware and can exceed ar->readlen, this copies more data than the readbuf was allocated for.
Bound the memcpy to min(len - 4, ar->readlen) so that the response is still completed -- avoiding repeated restarts from queued garbage -- while preventing an overread past the response buffer.
--- drivers/net/wireless/ath/carl9170/rx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/carl9170/rx.c +2 -1
@@ -150,7 +150,8 @@ static void carl9170_cmd_callback(struct ar9170 *ar, u32 len, void *buffer)spin_lock (&ar->cmd_lock);if (ar->readbuf) {if (len >=4 ) -memcpy (ar->readbuf, buffer +4 , len -4 ); +memcpy (ar->readbuf, buffer +4 , +min_t (u32, len -4 , ar->readlen)); ar->readbuf =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 149/602 wifi: carl9170: fix OOB read from off-by-two in TX status handler
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
[ Upstream commit a3f42f1049ad80c65560d2b078ad426c3134f78d ]
The bounds check in carl9170_tx_process_status() usesi > ((cmd->hdr.len / 2) + 1) which is off by two, allowing 2 extra iterations past valid _tx_status entries when the firmware- controlled hdr.ext exceeds hdr.len/2. Fix by using the correct comparison i >= (cmd->hdr.len / 2).
--- drivers/net/wireless/ath/carl9170/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/carl9170/tx.c +1 -1
@@ -693,7 +693,7 @@ void carl9170_tx_process_status(struct ar9170 *ar,unsigned int i;for (i =0 ; i < cmd->hdr.ext; i++) { -if (WARN_ON (i > ((cmd->hdr.len /2 ) +1 ))) { +if (WARN_ON (i >= (cmd->hdr.len /2 ))) {print_hex_dump_bytes ("UU:" ,DUMP_PREFIX_NONE , (void *) cmd, cmd->hdr.len +4 );break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 150/602 wifi: carl9170: fix buffer overflow in rx_stream failover path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristan Madani <[email protected]>
[ Upstream commit a1a21995c2e1cc2ca6b2226cfe4f5f018370182a ]
The failover continuation in carl9170_rx_stream() copies the full tlen from the second USB transfer instead of capping at rx_failover_missing bytes. When both transfers are near maximum size, the total exceeds the 65535-byte failover SKB, triggering skb_over_panic.
Limit the copy size to the missing byte count.
--- drivers/net/wireless/ath/carl9170/rx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/carl9170/rx.c +3 -1
@@ -918,7 +918,9 @@ static void carl9170_rx_stream(struct ar9170 *ar, void *buf, unsigned int len) } } -skb_put_data (ar->rx_failover, tbuf, tlen); +skb_put_data (ar->rx_failover, tbuf, + min_t(unsigned int, tlen, + ar->rx_failover_missing)); ar->rx_failover_missing -= tlen;if (ar->rx_failover_missing <=0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 151/602 btrfs: declare btrfs_ioctl_search_args_v2::buf as __u8
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: You-Kai Zheng <[email protected]>
[ Upstream commit b95181f3929ff98949fa9460ca93eccebbf2d7fc ]
The variable-sized buffer buf in struct btrfs_ioctl_search_args_v2 is declared as __u64[], but it holds a packed byte stream of search results, where all offsets into the buffer are in bytes.
Declaring buf as __u64[] makes it easy for user space to write incorrect pointer arithmetic: adding a byte offset directly to a __u64 pointer scales the offset by 8, landing at byte position offset*8 instead of offset.
This recently caused an infinite loop in btrfs-progs: the accessor read all-zero data from misaddressed items, which fed zeroed search keys back into the ioctl loop and spun forever. The issue was worked around at the time by disabling TREE_SEARCH_V2 entirely in btrfs-progs (d73e69824854:
"btrfs-progs: temporarily disable usage of v2 of search tree ioctl").
The kernel side already treats buf as a byte buffer, so change the declaration to __u8[] to match the actual semantics and prevent similar misuse in user space. The change is ABI compatible: both the structure size and alignment are unchanged.
--- include/uapi/linux/btrfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/btrfs.h +1 -1
@@ -597,7 +597,7 @@ struct btrfs_ioctl_search_args_v2 {__u64 buf_size;/* in - size of buffer * out - on EOVERFLOW: needed size * to store item */ -__u64 buf[];/* out - found items */ +__u8 buf[];/* out - found items */ };/* With a @src_length of zero, the range from @src_offset->EOF is cloned! */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 152/602 btrfs: dont propagate EXTENT_FLAG_LOGGING to split extent maps
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Martins <[email protected]>
[ Upstream commit 5eff4d5b17fa1950e80bfd1ba43dc0699e61a644 ]
When btrfs_drop_extent_map_range() splits an extent map, the new split maps inherit the original map's flags through a local 'flags' variable. Commit f86f7a75e2fb ("btrfs: use the flags of an extent map to identify the compression type") changed the EXTENT_FLAG_LOGGING clearing to operate on em->flags instead of that local 'flags' copy, so a split of an extent map that is currently being logged wrongly inherits EXTENT_FLAG_LOGGING.
The flag is then never cleared on the split, and when it is freed while still on the inode's modified_extents list (for example by the extent map shrinker) it trips the WARN_ON(!list_empty(&em->list)) in btrfs_free_extent_map() and leads to a use-after-free.
Clear EXTENT_FLAG_LOGGING from the local 'flags' copy used for the splits and only clear EXTENT_FLAG_PINNED from em->flags, restoring the behaviour prior to f86f7a75e2fb.
--- fs/btrfs/extent_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/extent_map.c +2 -2
@@ -859,13 +859,13 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end, goto next; } - flags = em->flags;/* * In case we split the extent map, we want to preserve the * EXTENT_FLAG_LOGGING flag on our extent map, but we don't want * it on the new extent maps. */ - em->flags &= ~(EXTENT_FLAG_PINNED |EXTENT_FLAG_LOGGING ); + flags = em->flags & ~EXTENT_FLAG_LOGGING ; + em->flags &= ~EXTENT_FLAG_PINNED ; modified = !list_empty (&em->list);/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 153/602 btrfs: free mapping node on duplicate reloc root insert
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanghui Yang <[email protected]>
[ Upstream commit 6a8269b6459ed870a8156c106a0f597383907872 ]
__add_reloc_root() allocates a mapping_node before inserting it into rc->reloc_root_tree. If rb_simple_insert() finds an existing entry, it returns the existing rb_node and leaves the newly allocated node unlinked.
The error path then returns -EEXIST without freeing the new node. Since the node was never inserted into reloc_root_tree, the later cleanup in put_reloc_control() cannot find it either.
Free the newly allocated node before returning -EEXIST.
The callers currently assert that -EEXIST should not happen, so this is a defensive cleanup for an unexpected duplicate insert path. If the path is ever reached, the local allocation should still be released.
--- fs/btrfs/relocation.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/relocation.c +1 -0
@@ -580,6 +580,7 @@ static int __add_reloc_root(struct btrfs_root *root)btrfs_err (fs_info,"Duplicate root found for start=%llu while inserting into relocation tree" , node->bytenr); +kfree (node);return -EEXIST ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 154/602 ASoC: tas2781: bound firmware description string parsing
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit bc889dfcea9294a1eae7f8e2f3573a90764ae4d0 ]
The TAS2781 firmware parser reads several variable-length description strings with strlen() before checking that the string terminator is present inside the firmware blob. A malformed firmware image without a NUL terminator can therefore make the parser walk past the end of the firmware buffer before the later size checks run.
Add a small bounded string-length helper and use it for all description fields that are parsed from the firmware buffer. Keep the existing size checks for the fixed bytes that follow each string.
--- sound/soc/codecs/tas2781-fmwlib.c | 63 ++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 6 deletions(-)
sound/soc/codecs/tas2781-fmwlib.c +57 -6
@@ -11,6 +11,7 @@#include <linux/i2c.h> #include <linux/init.h> #include <linux/interrupt.h> +#include <linux/limits.h> #include <linux/module.h> #include <linux/of.h> #include <linux/of_irq.h>
@@ -891,13 +892,42 @@ static int tasdevice_load_block_kernel(return 0 ; } +static int tasdevice_fw_strnlen (const struct firmware *fmw,int offset) +{ +const u8 *start; +const u8 *nul; +size_t remaining; +size_t len; + +if (offset <0 || offset >= fmw->size) +return -EINVAL ; + + start = fmw->data + offset; + remaining = fmw->size - offset; + nul =memchr (start,'\0' , remaining); +if (!nul) +return -EINVAL ; + + len = nul - start; +if (len >INT_MAX ) +return -EOVERFLOW ; + +return len; +} +static int fw_parse_variable_hdr (struct tasdevice_priv *tas_priv,struct tasdevice_dspfw_hdr *fw_hdr,const struct firmware *fmw,int offset) {const unsigned char *buf = fmw->data; -int len =strlen ((char *)&buf[offset]); +int len; + len =tasdevice_fw_strnlen (fmw, offset); +if (len <0 ) { +dev_err (tas_priv->dev,"%s: Description error\n" , __func__); + offset = len; + goto out; + } len++;if (offset + len +8 > fmw->size) {
@@ -1029,7 +1059,12 @@ static int fw_parse_data(struct tasdevice_fw *tas_fmw,memcpy (img_data->name, &data[offset],64 ); offset +=64 ; - n =strlen ((char *)&data[offset]); + n =tasdevice_fw_strnlen (fmw, offset); +if (n <0 ) { +dev_err (tas_fmw->dev,"%s: Description error\n" , __func__); + offset = n; + goto out; + } n++;if (offset + n +2 > fmw->size) {dev_err (tas_fmw->dev,"%s: Description error\n" , __func__);
@@ -1102,7 +1137,12 @@ static int fw_parse_program_data(struct tasdevice_priv *tas_priv, } offset +=64 ; - n =strlen ((char *)&buf[offset]); + n =tasdevice_fw_strnlen (fmw, offset); +if (n <0 ) { +dev_err (tas_priv->dev,"Description err\n" ); + offset = n; + goto out; + }/* skip '\0' and 5 unused bytes */ n +=6 ;if (offset + n > fmw->size) {
@@ -1165,7 +1205,12 @@ static int fw_parse_configuration_data(memcpy (config->name, &data[offset],64 ); offset +=64 ; - n =strlen ((char *)&data[offset]); + n =tasdevice_fw_strnlen (fmw, offset); +if (n <0 ) { +dev_err (tas_priv->dev,"Description err\n" ); + offset = n; + goto out; + } n +=15 ;if (offset + n > fmw->size) {dev_err (tas_priv->dev,"Description err\n" );
@@ -1819,7 +1864,8 @@ static int fw_parse_calibration_data(struct tasdevice_priv *tas_priv, {struct tasdevice_calibration *calibration;unsigned char *data = (unsigned char *)fmw->data; -unsigned int i, n; +unsigned int i; +int n;if (offset +2 > fmw->size) {dev_err (tas_priv->dev,"%s: Calibrations error\n" , __func__);
@@ -1851,7 +1897,12 @@ static int fw_parse_calibration_data(struct tasdevice_priv *tas_priv, calibration = &(tas_fmw->calibrations[i]); offset +=64 ; - n =strlen ((char *)&data[offset]); + n =tasdevice_fw_strnlen (fmw, offset); +if (n <0 ) { +dev_err (tas_priv->dev,"Description err\n" ); + offset = n; + goto out; + }/* skip '\0' and 2 unused bytes */ n +=3 ;if (offset + n > fmw->size) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 155/602 ALSA: hda: cs35l41: Fix NULL pointer dereference in cs35l41_get_acpi_mute_state()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
[ Upstream commit 8527bbb33936340525a3504a00932b2f8fd75754 ]
Return value of a function acpi_evaluate_dsm() is dereferenced without checking for NULL, but it is usually checked for this function.
acpi_evaluate_dsm() may return NULL, when acpi_evaluate_object() returns acpi_status other than ACPI_SUCCESS, so add a check to prevent the crach.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Stable-dep-of: 3b597d24dc04 ("ALSA: hda: cs35l41: validate and free ACPI mute object")
--- sound/pci/hda/cs35l41_hda.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/cs35l41_hda.c +2 -0
@@ -1403,6 +1403,8 @@ static int cs35l41_get_acpi_mute_state(struct cs35l41_hda *cs35l41, acpi_handleif (cs35l41_dsm_supported (handle,CS35L41_DSM_GET_MUTE )) { ret =acpi_evaluate_dsm (handle, &guid,0 ,CS35L41_DSM_GET_MUTE ,NULL ); +if (!ret) +return -EINVAL ; mute = *ret->buffer.pointer;dev_dbg (cs35l41->dev,"CS35L41_DSM_GET_MUTE: %d\n" , mute); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 156/602 ALSA: hda: cs35l41: validate and free ACPI mute object
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 3b597d24dc0455ae926f1053f97c2725038fc3cd ]
cs35l41_get_acpi_mute_state() evaluates a _DSM method to get the ACPI mute state and reads the first byte from the returned object.
However, the returned ACPI object is owned by the caller and is never freed after use, so each successful query leaks the _DSM result object.
The code also assumes that the returned object is a buffer with at least one byte. A malformed firmware response can return a different object type or an empty buffer, and the direct ret->buffer.pointer dereference can then access an invalid pointer.
Use the typed _DSM helper, validate that the returned buffer contains at least one byte, and free the ACPI object after reading it.
--- sound/pci/hda/cs35l41_hda.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
sound/pci/hda/cs35l41_hda.c +10 -1
@@ -1402,10 +1402,19 @@ static int cs35l41_get_acpi_mute_state(struct cs35l41_hda *cs35l41, acpi_handleguid_parse (CS35L41_UUID , &guid);if (cs35l41_dsm_supported (handle,CS35L41_DSM_GET_MUTE )) { - ret =acpi_evaluate_dsm (handle, &guid,0 ,CS35L41_DSM_GET_MUTE ,NULL ); + ret =acpi_evaluate_dsm_typed (handle, &guid,0 , +CS35L41_DSM_GET_MUTE ,NULL , +ACPI_TYPE_BUFFER ); +if (!ret)return -EINVAL ; +if (!ret->buffer.length || !ret->buffer.pointer) { +ACPI_FREE (ret); +return -EINVAL ; + } + mute = *ret->buffer.pointer; +ACPI_FREE (ret);dev_dbg (cs35l41->dev,"CS35L41_DSM_GET_MUTE: %d\n" , mute); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 157/602 ASoC: bt-sco: fix duplicate DAPM widget names for wideband DAI
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit 0b604e886ece11b71c4daaeccc512c784b89b014 ]
The bt-sco-pcm-wb DAI uses the same stream_name strings as bt-sco-pcm ("Playback" and "Capture"). This causes duplicate DAPM AIF widget names within the same component, leading to debugfs warnings:
debugfs: 'Playback' already exists in 'dapm'
debugfs: 'Capture' already exists in 'dapm'
Give the wideband DAI distinct stream names ("WB Playback" and "WB Capture") and add corresponding DAPM AIF widgets and routes for them.
--- sound/soc/codecs/bt-sco.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
sound/soc/codecs/bt-sco.c +8 -2
@@ -17,11 +17,17 @@ static const struct snd_soc_dapm_widget bt_sco_widgets[] = { SND_SOC_NOPM, 0, 0),SND_SOC_DAPM_AIF_OUT ("BT_SCO_TX" ,"Capture" ,0 ,SND_SOC_NOPM ,0 ,0 ), +SND_SOC_DAPM_AIF_IN ("BT_SCO_RX_WB" ,"WB Playback" ,0 , +SND_SOC_NOPM ,0 ,0 ), +SND_SOC_DAPM_AIF_OUT ("BT_SCO_TX_WB" ,"WB Capture" ,0 , + SND_SOC_NOPM, 0, 0), };static const struct snd_soc_dapm_route bt_sco_routes[] = { {"BT_SCO_TX" ,NULL ,"RX" }, {"TX" ,NULL ,"BT_SCO_RX" }, + {"BT_SCO_TX_WB" ,NULL ,"RX" }, + {"TX" ,NULL ,"BT_SCO_RX_WB" }, }; static struct snd_soc_dai_driver bt_sco_dai[] = {
@@ -45,14 +51,14 @@ static struct snd_soc_dai_driver bt_sco_dai[] = { { .name = "bt-sco-pcm-wb", .playback = { - .stream_name = "Playback", + .stream_name = "WB Playback", .channels_min = 1, .channels_max = 1, .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, .capture = { - .stream_name = "Capture", + .stream_name = "WB Capture", .channels_min = 1, .channels_max = 1, .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 158/602 ASoC: cs35l56: Dont use devres to unregister component
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit bee87cf0f1248c0f20710d7a79df41fe892d9f88 ]
Manually call snd_soc_unregister_component() from cs35l56_remove() instead of using devres cleanup. This ensures that the component is destroyed before cs35l56_remove() starts cleanup of anything the component code could be using.
Devres cleanup happens after the driver remove() callback, so if snd_soc_register_component() is used, it will not be destroyed until after cs35l56_remove() has returned. But there is some cleanup that must be done in cs35l56_remove(), or wrapped in a custom devres cleanup handler to ensure correct ordering. The simplest option is to call snd_soc_unregister_component() at the start of cs35l56_remove().
Stable-dep-of: 93c2a8ea2454 ("ASoC: cs35l56: Fix potential probe() deadlock")
--- sound/soc/codecs/cs35l56.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/soc/codecs/cs35l56.c +5 -3
@@ -1330,9 +1330,9 @@ int cs35l56_common_probe(struct cs35l56_private *cs35l56) goto err; } - ret =devm_snd_soc_register_component (cs35l56->base.dev, - &soc_component_dev_cs35l56, - cs35l56_dai,ARRAY_SIZE (cs35l56_dai)); + ret =snd_soc_register_component (cs35l56->base.dev, + &soc_component_dev_cs35l56, + cs35l56_dai,ARRAY_SIZE (cs35l56_dai));if (ret <0 ) {dev_err_probe (cs35l56->base.dev, ret,"Register codec failed\n" ); goto err_remove_wm_adsp;
@@ -1434,6 +1434,8 @@ EXPORT_SYMBOL_NS_GPL(cs35l56_init, SND_SOC_CS35L56_CORE);void cs35l56_remove (struct cs35l56_private *cs35l56) { +snd_soc_unregister_component (cs35l56->base.dev); + cs35l56->base.init_done = false;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 159/602 ASoC: cs35l56: Fix potential probe() deadlock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 93c2a8ea2454b7b14eb378a58cad8a83c0ffc903 ]
On I2C/SPI call cs35l56_init() before calling snd_soc_register_component() to prevent the potential for a deadlock on init_completion.
For most buses all the hardware would be ready when probe() returns, but on SoundWire, probe() must return before the SoundWire bus driver will enumerate the device. All access to the registers must be deferred until the driver receives an ATTACHED notification. But anything that could return -EPROBE_DEFER must be called during probe, and that includes snd_soc_register_component(). Because of that, on SoundWire the ASoC component can be created before the registers are accssible, so cs35l56_component_probe() waits for init_completion to signal that the registers are accessible.
On I2C/SPI this 2-stage startup isn't required so their probe() functions simply called cs35l56_common_probe() and then cs35l56_init(). The problem with this was that snd_soc_register_component() was still called early. If this triggered ASoC to create the card, ASoC would call cs35l56_component_probe() which waits on init_completion - but this would be running inside the cs35l56 driver probe() so blocking it from reaching the code that signals init_completion, causing a deadlock.
--- sound/soc/codecs/cs35l56-i2c.c | 4 +--- sound/soc/codecs/cs35l56-spi.c | 4 +--- sound/soc/codecs/cs35l56.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-)
sound/soc/codecs/cs35l56-i2c.c +1 -3
@@ -40,9 +40,7 @@ static int cs35l56_i2c_probe(struct i2c_client *client)if (ret !=0 )return ret; - ret =cs35l56_init (cs35l56); -if (ret ==0 ) - ret =cs35l56_irq_request (&cs35l56->base, client->irq); + ret =cs35l56_irq_request (&cs35l56->base, client->irq);if (ret <0 )cs35l56_remove (cs35l56);
sound/soc/codecs/cs35l56-spi.c +1 -3
@@ -41,9 +41,7 @@ static int cs35l56_spi_probe(struct spi_device *spi)if (ret !=0 )return ret; - ret =cs35l56_init (cs35l56); -if (ret ==0 ) - ret =cs35l56_irq_request (&cs35l56->base, spi->irq); + ret =cs35l56_irq_request (&cs35l56->base, spi->irq);if (ret <0 )cs35l56_remove (cs35l56);
sound/soc/codecs/cs35l56.c +15 -0
@@ -1330,6 +1330,16 @@ int cs35l56_common_probe(struct cs35l56_private *cs35l56) goto err; } +/* +* On SoundWire the cs35l56_init() cannot be run until after the +* device has been enumerated by the SoundWire core. +*/ +if (!cs35l56->sdw_peripheral) { + ret =cs35l56_init (cs35l56); +if (ret) + goto err_remove_wm_adsp; + } + ret =snd_soc_register_component (cs35l56->base.dev, &soc_component_dev_cs35l56, cs35l56_dai,ARRAY_SIZE (cs35l56_dai));
@@ -1344,6 +1354,11 @@ int cs35l56_common_probe(struct cs35l56_private *cs35l56)wm_adsp2_remove (&cs35l56->dsp); err: +if (pm_runtime_enabled (cs35l56->base.dev)) { +pm_runtime_dont_use_autosuspend (cs35l56->base.dev); +pm_runtime_disable (cs35l56->base.dev); + } +gpiod_set_value_cansleep (cs35l56->base.reset_gpio,0 );regulator_bulk_disable (ARRAY_SIZE (cs35l56->supplies), cs35l56->supplies);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 160/602 ASoC: cs35l56: Use complete_all() to signal init_completion
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit e0bffb63a2eda0af82ed7e6357ac67c2db990c21 ]
In cs35l56_init() use complete_all() to signal init_completion instead of complete().
cs35l56_init() was signaling init_completion using the complete() function. This only releases ONE waiter.
If cs35l56_component_probe() was called multiple times the first time would consume that one signal, then future calls would timeout waiting for the completion. This could happen if:
- The component is probed, removed, then probed again without the cs35l56 module being removed.
- A call to component_probe() returns an error and ASoC calls it again later.
It should use complete_all() so that after it has been signaled it will allow any code that waits on it to continue immediately.
The one case where the driver must wait for initialization to run again is when waiting for a reboot after firmware download, and here the code correctly calls reinit_completion() first.
--- sound/soc/codecs/cs35l56.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cs35l56.c +1 -1
@@ -1441,7 +1441,7 @@ int cs35l56_init(struct cs35l56_private *cs35l56)return dev_err_probe (cs35l56->base.dev, ret,"Failed to write ASP1_CONTROL3\n" ); cs35l56->base.init_done = true; -complete (&cs35l56->init_completion); +complete_all (&cs35l56->init_completion);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 161/602 wifi: iwlwifi: mvm: validate SAR GEO response payload size
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pagadala Yesu Anjaneyulu <[email protected]>
[ Upstream commit 408d7da38272ce48e2db79b8a9895999f94d7655 ]
The SAR GEO command response is cast to iwl_geo_tx_power_profiles_resp without verifying the payload length. A malformed or unexpected firmware response can lead to reading an invalid structure layout.
Add an explicit size check before accessing the response data and return -EIO when the payload size is wrong.
--- drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/fw.c +10 -0
@@ -976,12 +976,22 @@ int iwl_mvm_get_sar_geo_profile(struct iwl_mvm *mvm)return ret; } +if (IWL_FW_CHECK (mvm, +iwl_rx_packet_payload_len (cmd.resp_pkt) != +sizeof (*resp), +"Wrong size for iwl_geo_tx_power_profiles_resp: %d\n" , +iwl_rx_packet_payload_len (cmd.resp_pkt))) { + ret = -EIO ; + goto out; + } + resp = (void *)cmd.resp_pkt->data; ret =le32_to_cpu (resp->profile_idx);if (WARN_ON (ret >BIOS_GEO_MAX_PROFILE_NUM )) ret = -EIO ; +out:iwl_free_resp (&cmd);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 162/602 wifi: iwlwifi: mvm: fix read in wake packet notification handler
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shahar Tzarfati <[email protected]>
[ Upstream commit 9d7657aae8c1579584c67b0b66114a6a98db8b2f ]
In iwl_mvm_wowlan_store_wake_pkt(), packet_len was initialized from notif->wake_packet_length before the explicit check that len >= sizeof(*notif).
Move the assignment of packet_len to after the size check so that notif->wake_packet_length is only accessed once the payload length has been validated.
--- drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/d3.c +2 -1
@@ -3144,7 +3144,7 @@ static int iwl_mvm_wowlan_store_wake_pkt(struct iwl_mvm *mvm, struct iwl_wowlan_status_data *status, u32 len) { -u32 data_size, packet_len =le32_to_cpu (notif->wake_packet_length); +u32 data_size, packet_len;if (len <sizeof (*notif)) {IWL_ERR (mvm,"Invalid WoWLAN wake packet notification!\n" );
@@ -3163,6 +3163,7 @@ static int iwl_mvm_wowlan_store_wake_pkt(struct iwl_mvm *mvm,return -EIO ; } + packet_len =le32_to_cpu (notif->wake_packet_length); data_size = len - offsetof(struct iwl_wowlan_wake_pkt_notif , wake_packet);/* data_size got the padding from the notification, remove it. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 163/602 usb: atm: ueagle-atm: reject descriptors that confuse probe and disconnect
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Diego Fernando Mancera Gomez <[email protected]>
[ Upstream commit 71132cedd1ecbc4032d76e9928c18a10f7e39b80 ]
uea_probe() distinguishes a pre-firmware device from a post-firmware one using the USB id (UEA_IS_PREFIRM()), and stores a different object as the interface data in each case: a 'struct completion' for a pre-firmware device (to be waited on in .disconnect()), or a 'struct usbatm_data' for a post-firmware one.
uea_disconnect() instead tells the two apart by the number of interfaces of the active configuration (a pre-firmware device exposes a single interface, ADI930 has 2 and eagle has 3), and casts the interface data accordingly.
Because the two handlers use different criteria, a crafted device that advertises a pre-firmware id together with a multi-interface descriptor (or a post-firmware id with a single interface) makes them disagree: the small 'struct completion' stored by uea_probe() is then passed to usbatm_usb_disconnect(), which casts it to 'struct usbatm_data' and takes instance->serialize, reading past the end of the allocation:
BUG: KASAN: slab-out-of-bounds in __mutex_lock+0x152a/0x1b80 Read of size 8 at addr ffff8880470e2c60 by task kworker/1:2/982 ... __mutex_lock+0x152a/0x1b80 usbatm_usb_disconnect+0x70/0x820 uea_disconnect+0x133/0x2c0 usb_unbind_interface+0x1dd/0x9e0 ... which belongs to the cache kmalloc-96 of size 96 The buggy address is located 0 bytes to the right of allocated 96-byte region [ffff8880470e2c00, ffff8880470e2c60)
Reject such inconsistent descriptors in uea_probe() so that both handlers always make the same pre/post-firmware decision.
--- drivers/usb/atm/ueagle-atm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/usb/atm/ueagle-atm.c +17 -0
@@ -2590,6 +2590,7 @@ static struct usbatm_driver uea_usbatm_driver = {static int uea_probe (struct usb_interface *intf,const struct usb_device_id *id) {struct usb_device *usb =interface_to_usbdev (intf); +bool single_iface = usb->config->desc.bNumInterfaces ==1 ;int ret;uea_enters (usb);
@@ -2599,6 +2600,22 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)le16_to_cpu (usb->descriptor.bcdDevice), chip_name[UEA_CHIP_VERSION(id)]); +/* +* uea_probe() decides between the pre-firmware and post-firmware case +* from the USB id and stores a different object as interface data in +* each case: a struct completion for a pre-firmware device, a struct +* usbatm_data for a post-firmware one. uea_disconnect() instead tells +* the two apart by the number of interfaces (a pre-firmware device +* exposes a single interface, ADI930 has 2 and eagle has 3). A crafted +* device advertising a pre-firmware id together with a multi-interface +* descriptor (or the other way around) makes the two disagree, so that +* usbatm_usb_disconnect() treats the small completion object as a +* struct usbatm_data and reads out of bounds. Reject such inconsistent +* descriptors so both paths make the same decision. +*/ +if (UEA_IS_PREFIRM (id) != single_iface) +return -ENODEV ; +usb_reset_device (usb);if (UEA_IS_PREFIRM (id)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 164/602 drivers/virt: pkvm: Fix end calculation in mmio_guard_ioremap_hook()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mostafa Saleh <[email protected]>
[ Upstream commit 62c740f823a8e47ffe56e45a7472c27cf988e2f6 ]
Sashiko (locally) reports a logical issues in mmio_guard_ioremap_hook()
mmio_guard_ioremap_hook() attempts to handle unaligned addresses and sizes. However, aligning the start address before adding the size, might shift the end to the page before.
--- drivers/virt/coco/pkvm-guest/arm-pkvm-guest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virt/coco/pkvm-guest/arm-pkvm-guest.c +1 -1
@@ -82,8 +82,8 @@ static int mmio_guard_ioremap_hook(phys_addr_t phys, size_t size,if (protval != PROT_DEVICE_nGnRE && protval != PROT_DEVICE_nGnRnE)return 0 ; + end =PAGE_ALIGN (phys + size); phys =PAGE_ALIGN_DOWN (phys); - end = phys +PAGE_ALIGN (size);while (phys < end) {const int func_id =ARM_SMCCC_VENDOR_HYP_KVM_MMIO_GUARD_FUNC_ID ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 165/602 hwmon: (asus-ec-sensors) fix looping over banks while reading from EC
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugene Shalygin <[email protected]>
[ Upstream commit e741d13cc2abfc6fccebe2008057aa52e285223e ]
Do not assume there are only bank 0 and bank 1 available, just use '!=' for bank comparison.
--- drivers/hwmon/asus-ec-sensors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/asus-ec-sensors.c +1 -1
@@ -776,7 +776,7 @@ static int asus_ec_block_read(const struct device *dev, }for (ireg =0 ; ireg < ec->nr_registers; ireg++) { reg_bank =register_bank (ec->registers[ireg]); -if (reg_bank < bank) { +if (reg_bank != bank) {continue ; } ec_read(register_index(ec->registers[ireg]),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 166/602 hwmon: (asus-ec-sensors) fix EC read intervals
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugene Shalygin <[email protected]>
[ Upstream commit 60710b2af13b81da71b429d3f8b19dd70310729d ]
Take INITIAL_JIFFIES into account when setting up next update time.
--- drivers/hwmon/asus-ec-sensors.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/asus-ec-sensors.c +4 -4
@@ -596,7 +596,7 @@ struct ec_sensors_data {/* sorted list of unique register banks */ u8 banks[ASUS_EC_MAX_BANK +1 ];/* in jiffies */ -unsigned long last_updated; +u64 next_update;struct lock_data lock_data;/* number of board EC sensors */ u8 nr_sensors;
@@ -865,13 +865,12 @@ static int get_cached_value_or_update(const struct device *dev,int sensor_index, struct ec_sensors_data *state, s32 *value) { - if (time_after(jiffies, state->last_updated + HZ)) { + if (time_after64(get_jiffies_64(), state->next_update)) { if (update_ec_sensors(dev, state)) { dev_err(dev, "update_ec_sensors() failure\n");return -EIO ; } - - state->last_updated = jiffies; + state->next_update =get_jiffies_64 () +HZ ; } *value = state->sensors[sensor_index].cached_value;
@@ -989,6 +988,7 @@ static int asus_ec_probe(struct platform_device *pdev)if (!ec_data)return -ENOMEM ; + ec_data->next_update =INITIAL_JIFFIES ;dev_set_drvdata (dev, ec_data); ec_data->board_info = pboard_info;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 167/602 hwmon: (asus-ec-sensors) add missed handle for ENOMEM
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugene Shalygin <[email protected]>
[ Upstream commit 9813c1f49efeadbcb17e4a41972350ac783f9cac ]
Add missing return value check in the setup function.
--- drivers/hwmon/asus-ec-sensors.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/hwmon/asus-ec-sensors.c +5 -3
@@ -1064,9 +1064,11 @@ static int asus_ec_probe(struct platform_device *pdev)if (!nr_count[type])continue ; -asus_ec_hwmon_add_chan_info (asus_ec_hwmon_chan, dev, - nr_count[type], type, - hwmon_attributes[type]); + status =asus_ec_hwmon_add_chan_info (asus_ec_hwmon_chan, dev, + nr_count[type], type, + hwmon_attributes[type]); +if (status) +return status; *ptr_asus_ec_ci++ = asus_ec_hwmon_chan++; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 168/602 smb: client: validate DFS referral PathConsumed
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit f6f5ee2aa33b350c671721b965251c42cebb962e ]
parse_dfs_referrals() validates that the response contains the fixed referral entry array and, on for-next, the per-referral string offsets. However, the response also contains a PathConsumed value that is later used for DFS path parsing.
If a malformed response provides a PathConsumed value larger than the search name, later DFS parsing can advance beyond the end of the path.
Validate PathConsumed against the search name length before storing it in the parsed referral.
--- fs/smb/client/misc.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
fs/smb/client/misc.c +25 -9
@@ -954,6 +954,8 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,int i, rc =0 ;char *data_end;struct dfs_referral_level_3 *ref; +unsigned int path_consumed; +size_t search_name_len;if (rsp_size <sizeof (*rsp)) { cifs_dbg(VFS | ONCE,
@@ -1001,6 +1003,7 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, rc = -ENOMEM ; goto parse_DFS_referrals_exit; } + search_name_len =strlen (searchName);/* collect necessary data from referrals */ for (i =0 ; i < *num_of_nodes; i++) {
@@ -1009,21 +1012,34 @@ parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,struct dfs_info3_param *node = (*target_nodes)+i; node->flags =le32_to_cpu (rsp->DFSFlags); + path_consumed =le16_to_cpu (rsp->PathConsumed);if (is_unicode) { -__le16 *tmp =kmalloc (strlen (searchName)*2 +2 , -GFP_KERNEL ); -if (tmp ==NULL ) { +size_t search_name_utf16_len = search_name_len *2 +2 ; +__le16 *tmp; + +if (path_consumed > search_name_utf16_len) { + rc = -EINVAL ; + goto parse_DFS_referrals_exit; + } + + tmp =kmalloc (search_name_utf16_len,GFP_KERNEL ); +if (!tmp) { rc = -ENOMEM ; goto parse_DFS_referrals_exit; } -cifsConvertToUTF16 ((__le16 *) tmp, searchName, +cifsConvertToUTF16 ((__le16 *)tmp, searchName,PATH_MAX , nls_codepage, remap); - node->path_consumed =cifs_utf16_bytes (tmp, -le16_to_cpu (rsp->PathConsumed), - nls_codepage); + node->path_consumed =cifs_utf16_bytes (tmp, path_consumed, + nls_codepage);kfree (tmp); - }else - node->path_consumed =le16_to_cpu (rsp->PathConsumed); + }else { +if (path_consumed > search_name_len) { + rc = -EINVAL ; + goto parse_DFS_referrals_exit; + } + + node->path_consumed = path_consumed; + } node->server_type =le16_to_cpu (ref->ServerType); node->ref_flag =le16_to_cpu (ref->ReferralEntryFlags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 169/602 hwmon: occ: validate poll response sensor blocks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 70e76e700fc6c46afb4e17aec099a1ea089b4a22 ]
The OCC poll response parser walks a counted list of sensor data blocks. It used the static backing-array capacity as the parse boundary, but a transport response makes only data_length bytes current and valid. A truncated response can therefore make the parser consume a block header or block extent outside the current response.
Use data_length as the parent boundary, prove the fixed poll header and each current block header before reading them, and prove the complete block before advancing. Keep parsed sensor metadata local until the complete response has passed validation, then publish it. Propagate malformed-response errors before publishing the OCC as active.
--- drivers/hwmon/occ/common.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)
drivers/hwmon/occ/common.c +30 -8
@@ -1052,32 +1052,49 @@ static int occ_setup_sensor_attrs(struct occ *occ) }/* only need to do this once at startup, as OCC won't change sensors on us */ -static void occ_parse_poll_response (struct occ *occ) +static int occ_parse_poll_response (struct occ *occ) {unsigned int i, old_offset, offset =0 , size =0 ; +u16 data_length;struct occ_sensor *sensor; -struct occ_sensors *sensors = &occ->sensors; +struct occ_sensors parsed = {}; +struct occ_sensors *sensors = &parsed;struct occ_response *resp = &occ->resp;struct occ_poll_response *poll = (struct occ_poll_response *)&resp->data[0 ];struct occ_poll_response_header *header = &poll->header;struct occ_sensor_data_block *block = &poll->block; + data_length =get_unaligned_be16 (&resp->data_length); +if (data_length <sizeof (*header) || data_length >OCC_RESP_DATA_BYTES ) { +dev_err (occ->bus_dev,"invalid OCC poll response length %u\n" , + data_length); +return -EMSGSIZE ; + } +dev_info (occ->bus_dev,"OCC found, code level: %.16s\n" , header->occ_code_level);for (i =0 ; i < header->num_sensor_data_blocks; ++i) { block = (struct occ_sensor_data_block *)((u8 *)block + offset); +if (size +sizeof (*header) +sizeof (block->header) > + data_length) { +dev_err (occ->bus_dev, +"truncated OCC sensor block header\n" ); +return -EMSGSIZE ; + } + old_offset = offset; offset = (block->header.num_sensors * block->header.sensor_length) +sizeof (block->header); - size += offset;/* validate all the length/size fields */ -if ((size +sizeof (*header)) >=OCC_RESP_DATA_BYTES ) { -dev_warn (occ->bus_dev,"exceeded response buffer\n" ); -return ; +if (size +sizeof (*header) + offset > data_length) { +dev_err (occ->bus_dev, +"exceeded OCC poll response length\n" ); +return -EMSGSIZE ; } + size += offset; dev_dbg(occ->bus_dev, " %04x..%04x: %.4s (%d sensors)\n", old_offset, offset - 1, block->header.eye_catcher,
@@ -1107,6 +1124,9 @@ static void occ_parse_poll_response(struct occ *occ)dev_dbg (occ->bus_dev,"Max resp size: %u+%zd=%zd\n" , size,sizeof (*header), size +sizeof (*header)); + occ->sensors = parsed; + +return 0 ; }int occ_active (struct occ *occ,bool active)
@@ -1138,10 +1158,12 @@ int occ_active(struct occ *occ, bool active) goto unlock; } - occ->active = true; occ->next_update = jiffies +OCC_UPDATE_FREQUENCY ; -occ_parse_poll_response (occ); + rc =occ_parse_poll_response (occ); +if (rc) + goto unlock; + occ->active = true; rc =occ_setup_sensor_attrs (occ);if (rc) { dev_err(occ->bus_dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 170/602 regulator: mt6358: use regmap helper to read fixed LDO calibration
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Golle <[email protected]>
[ Upstream commit 1d26f125501f3fbe6c259ab75bf6516299a0bf0e ]
The "fixed" LDOs with output voltage calibration use mt6358_get_buck_voltage_sel as their get_voltage_sel op, but the MT6358_REG_FIXED and MT6366_REG_FIXED entries do not populate da_vsel_reg/da_vsel_mask. The op therefore reads register 0x0 with a zero mask and shifts the result by ffs(0) - 1 = -1, which is undefined behaviour and gets flagged by UBSAN on every boot on MT6366 boards:
UBSAN: shift-out-of-bounds in drivers/regulator/mt6358-regulator.c:384:38 shift exponent -1 is negative Call trace: mt6358_get_buck_voltage_sel+0xc8/0x120 regulator_get_voltage_rdev+0x70/0x170 set_machine_constraints+0x504/0xc38 regulator_register+0x324/0xc68
Besides the undefined shift, the returned selector is always 0, so the actual calibration offset programmed in <reg>_ANA_CON0 is never reported.
The descriptor already carries the correct vsel_reg/vsel_mask (the ANA_CON0 calibration field), matching the regulator_set_voltage_sel_regmap op already in use. Read the selector back through regulator_get_voltage_sel_regmap instead.
--- drivers/regulator/mt6358-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/mt6358-regulator.c +1 -1
@@ -492,7 +492,7 @@ static const struct regulator_ops mt6358_volt_fixed_ops = { .list_voltage = regulator_list_voltage_linear, .map_voltage = regulator_map_voltage_linear, .set_voltage_sel = regulator_set_voltage_sel_regmap, - .get_voltage_sel = mt6358_get_buck_voltage_sel, + .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, .enable = regulator_enable_regmap, .disable = regulator_disable_regmap,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 171/602 Bluetooth: btusb: validate Realtek vendor event length
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit df541cd485ff80a5ddc579d99687bc7506df9851 ]
btusb_recv_event_realtek() reads the event code at data[0] and the Realtek subevent code at data[2] before deciding whether to consume a vendor event as a coredump.
For example, the two-byte event ff 00 contains a complete vendor-event header declaring zero parameters. The old classifier still reads a nonexistent third byte and can misclassify the event as a coredump if the adjacent byte is 0x34.
Require the HCI event header and first parameter to be present before inspecting the Realtek subevent code. Short events continue through the normal HCI receive path, which owns their protocol validation.
--- drivers/bluetooth/btusb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/btusb.c +3 -1
@@ -2707,7 +2707,9 @@ static int btusb_setup_realtek(struct hci_dev *hdev)static int btusb_recv_event_realtek (struct hci_dev *hdev,struct sk_buff *skb) { -if (skb->data[0 ] ==HCI_VENDOR_PKT && skb->data[2 ] ==RTK_SUB_EVENT_CODE_COREDUMP ) { +if (skb->len >=HCI_EVENT_HDR_SIZE +1 && + skb->data[0 ] ==HCI_VENDOR_PKT && + skb->data[2 ] ==RTK_SUB_EVENT_CODE_COREDUMP ) {struct rtk_dev_coredump_hdr hdr = { .code =RTK_DEVCOREDUMP_CODE_MEMDUMP , };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 172/602 netlink: specs: rt-link: convert bridge port flag attributes to u8
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danielle Ratson <[email protected]>
[ Upstream commit f6e3b21608e974c4aaa4cfd73a239dacf1d8a9a3 ]
A number of IFLA_BRPORT_* attributes are documented in the rt-link spec as having the "flag" type, i.e. a payload-less NLA_FLAG attribute whose meaning is presence-only. This does not match the kernel, which emits these attributes with nla_put_u8() and validates them as NLA_U8 in br_port_policy[]. The values are not mere presence flags but carry a u8 payload (0/1).
Convert these bridge port attributes from "flag" to "u8" so the spec reflects the actual wire format.
--- Documentation/netlink/specs/rt_link.yaml | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-)
Documentation/netlink/specs/rt_link.yaml +20 -20
@@ -1619,31 +1619,31 @@ attribute-sets: type: u32 - name: mode - type: flag + type: u8 - name: guard - type: flag + type: u8 - name: protect - type: flag + type: u8 - name: fast-leave - type: flag + type: u8 - name: learning - type: flag + type: u8 - name: unicast-flood - type: flag + type: u8 - name: proxyarp - type: flag + type: u8 - name: learning-sync - type: flag + type: u8 - name: proxyarp-wifi - type: flag + type: u8 - name: root-id type: binary
@@ -1690,34 +1690,34 @@ attribute-sets: type: pad - name: mcast-flood - type: flag + type: u8 - name: mcast-to-ucast - type: flag + type: u8 - name: vlan-tunnel - type: flag + type: u8 - name: bcast-flood - type: flag + type: u8 - name: group-fwd-mask type: u16 - name: neigh-suppress - type: flag + type: u8 - name: isolated - type: flag + type: u8 - name: backup-port type: u32 - name: mrp-ring-open - type: flag + type: u8 - name: mrp-in-open - type: flag + type: u8 - name: mcast-eht-hosts-limit type: u32
@@ -1726,10 +1726,10 @@ attribute-sets: type: u32 - name: locked - type: flag + type: u8 - name: mab - type: flag + type: u8 - name: mcast-n-groups type: u32
@@ -1738,7 +1738,7 @@ attribute-sets: type: u32 - name: neigh-vlan-suppress - type: flag + type: u8 - name: backup-nhid type: u32
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 173/602 net/packet: avoid fanout hook re-registration after unregister
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lee <[email protected]>
[ Upstream commit 50aff80475abd3533eef4320477037e6fcc6b56e ]
packet_set_ring() temporarily detaches a socket from packet delivery while reconfiguring its ring. It records the previous running state, clears po->num, unregisters the protocol hook when needed, drops po->bind_lock, and later restores po->num and re-registers the hook from the saved was_running value.
That unlocked window can race with NETDEV_UNREGISTER. The notifier can observe the socket as not running, skip __unregister_prot_hook(), and invalidate the per-socket binding by setting po->ifindex to -1 and clearing po->prot_hook.dev. A one-member fanout group can still retain its shared fanout hook device pointer. When packet_set_ring() resumes, re-registering solely from the stale was_running state can re-add the fanout hook after the device has been unregistered.
Treat po->ifindex == -1 as an invalidated binding after reacquiring po->bind_lock. This is distinct from ifindex 0, the normal unbound/wildcard state: ifindex -1 marks an existing device binding that was invalidated when the device was unregistered. Restore po->num as before, but do not re-register the hook if device unregister already detached the socket.
--- net/packet/af_packet.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/packet/af_packet.c +5 -1
@@ -4604,7 +4604,11 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,spin_lock (&po->bind_lock);WRITE_ONCE (po->num, num); -if (was_running) +/* +* NETDEV_UNREGISTER may have invalidated the binding while bind_lock +* was dropped above. Do not re-add a fanout hook to a dead device. +*/ +if (was_running &&READ_ONCE (po->ifindex) !=-1 )register_prot_hook (sk);spin_unlock (&po->bind_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 174/602 bonding: fix devconf_all NULL dereference when IPv6 is disabled
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhaolong Zhang <[email protected]>
[ Upstream commit 1c975de3343cdef506f2eecc833cc1f14b0401c4 ]
When booting with the 'ipv6.disable=1' parameter, the devconf_all is never initialized because inet6_init() exits before addrconf_init() is called which initializes it. bond_send_validate(), however, will still call bond_ns_send_all() even ipv6 is indeed disabled. It will lead to NULL derefence of net->ipv6.devconf_all in ip6_pol_route().
BUG: kernel NULL pointer dereference, address: 000000000000000c [...] Workqueue: bond0 bond_arp_monitor [bonding] RIP: 0010:ip6_pol_route+0x69/0x480 [...] Call Trace: <TASK> ? srso_return_thunk+0x5/0x5f ? __pfx_ip6_pol_route_output+0x10/0x10 fib6_rule_lookup+0xfe/0x260 ? wakeup_preempt+0x8a/0x90 ? srso_return_thunk+0x5/0x5f ? srso_return_thunk+0x5/0x5f ? sched_balance_rq+0x369/0x810 ip6_route_output_flags+0xd7/0x170 bond_ns_send_all+0xde/0x280 [bonding] bond_ab_arp_probe+0x296/0x320 [bonding] ? srso_return_thunk+0x5/0x5f bond_activebackup_arp_mon+0xb4/0x2c0 [bonding] process_one_work+0x196/0x370 worker_thread+0x1af/0x320 ? srso_return_thunk+0x5/0x5f ? __pfx_worker_thread+0x10/0x10 kthread+0xe3/0x120 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x199/0x260 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK>
Fix this by adding ipv6_mod_enabled() condition check in the caller.
--- drivers/net/bonding/bond_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +2 -1
@@ -3512,7 +3512,8 @@ static void bond_send_validate(struct bonding *bond, struct slave *slave) {bond_arp_send_all (bond, slave);#if IS_ENABLED (CONFIG_IPV6 ) -bond_ns_send_all (bond, slave); +if (likely (ipv6_mod_enabled ())) +bond_ns_send_all (bond, slave);#endif }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 175/602 rds: drop incoming messages that cross network namespace boundaries
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
[ Upstream commit 5521ae71e32a8069ed4ca6e792179dc57bc43ab2 ]
rds_find_bound() looks up the destination socket using a global rhashtable keyed solely on (addr, port, scope_id). Network namespaces are not part of the key, so a sender in netns A can deliver an incoming message (inc) to a socket that lives in a different netns B.
When this happens, inc->i_conn points to an rds_connection whose c_net is netns A, but the receiving rs lives in netns B. Once the child process that created netns A exits, cleanup_net() calls rds_loop_exit_net() -> rds_loop_kill_conns() -> rds_conn_destroy(), freeing that connection. If the survivor socket in netns B still holds the inc, any subsequent dereference of inc->i_conn is a use-after-free.
There are two dangerous sites in rds_clear_recv_queue():
1. inc->i_conn->c_lcong (offset 88 of freed rds_connection, size 200) read via rds_recv_rcvbuf_delta() -- confirmed by KASAN.
2. inc->i_conn->c_trans->inc_free(inc) (function pointer at offset 80) called via rds_inc_put() when the inc refcount reaches zero -- same race window, potential call-through-freed-object primitive.
The bug is reachable from unprivileged user namespaces (CLONE_NEWUSER + CLONE_NEWNET), available since Linux 3.8.
Fix this by rejecting the delivery in rds_recv_incoming() when the socket returned by rds_find_bound() belongs to a different network namespace than the connection that carried the message. Use the existing rds_conn_net() / sock_net() helpers and net_eq() for the comparison.
--- net/rds/recv.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
net/rds/recv.c +15 -0
@@ -366,6 +366,21 @@ void rds_recv_incoming(struct rds_connection *conn, struct in6_addr *saddr, goto out; } +/* +* rds_find_bound() uses a global (netns-agnostic) hash table. +* An RDS connection created in netns A can match a socket bound +* in the init netns, delivering inc cross-netns with inc->i_conn +* pointing into netns A. When cleanup_net() then frees that conn, +* any subsequent dereference of inc->i_conn is a use-after-free. +* Drop the inc if the receiving socket lives in a different netns. +*/ +if (!net_eq (sock_net (rds_rs_to_sk (rs)),rds_conn_net (conn))) { +rds_stats_inc (s_recv_drop_no_sock); +rds_sock_put (rs); + rs =NULL ; + goto out; + } +/* Process extension headers */ rds_recv_incoming_exthdrs (inc, rs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 176/602 gtp: parse extension headers before reading inner protocol
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhixing Chen <[email protected]>
[ Upstream commit 96e37e2f618e931aa97af95e707dcdfb1ec41264 ]
GTPv1-U packets may carry a chain of extension headers before the inner IP packet. The receive path already parses and skips these extension headers, but it currently reads the inner protocol before doing so.
As a result, the first extension header byte is interpreted as the inner IP version. Packets with extension headers are then dropped before PDP lookup.
Parse the extension header chain before calling gtp_inner_proto(), so the inner protocol is read from the actual inner IP header.
--- drivers/net/gtp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/gtp.c +6 -6
@@ -821,13 +821,17 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb)if (!pskb_may_pull (skb, hdrlen))return -1 ; + gtp1 = (struct gtp1_header *)(skb->data +sizeof (struct udphdr )); + +if (gtp1->flags >P1_F_EXTHDR && +gtp_parse_exthdrs (skb, &hdrlen) <0 ) +return -1 ; +if (gtp_inner_proto (skb, hdrlen, &inner_proto) <0 ) {netdev_dbg (gtp->dev,"GTP packet does not encapsulate an IP packet\n" );return -1 ; } - gtp1 = (struct gtp1_header *)(skb->data +sizeof (struct udphdr )); - pctx =gtp1_pdp_find (gtp,ntohl (gtp1->tid),gtp_proto_to_family (inner_proto));if (!pctx) {
@@ -835,10 +839,6 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb)return 1 ; } -if (gtp1->flags >P1_F_EXTHDR && -gtp_parse_exthdrs (skb, &hdrlen) <0 ) -return -1 ; -return gtp_rx (pctx, skb, hdrlen, gtp->role, inner_proto); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 177/602 dpaa2-switch: put MAC endpoint device on disconnect
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 4c1eabbef7a1707635652e956e39db1269c3af2b ]
fsl_mc_get_endpoint() returns the MAC endpoint device with a reference taken through device_find_child(). The switch port connect path stores that device in mac->mc_dev and keeps it for the lifetime of the connected MAC object.
However, the disconnect path only closes the MAC and frees the dpaa2_mac object. It does not drop the endpoint device reference stored in mac->mc_dev, so every successful connect leaks that device reference when the MAC is later disconnected.
Drop the endpoint device reference before freeing the dpaa2_mac object.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +1 -0
@@ -1510,6 +1510,7 @@ static void dpaa2_switch_port_disconnect_mac(struct ethsw_port_priv *port_priv)dpaa2_mac_disconnect (mac);dpaa2_mac_close (mac); +put_device (&mac->mc_dev->dev);kfree (mac); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 178/602 dpaa2-eth: put MAC endpoint device on disconnect
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit b4b201cc93ff70150853aba03e14d314d1980ca0 ]
fsl_mc_get_endpoint() returns the MAC endpoint device with a reference taken through device_find_child(). The Ethernet connect path stores that device in mac->mc_dev and keeps it for the lifetime of the connected MAC object.
However, the disconnect path only disconnects and closes the MAC before freeing the dpaa2_mac object. It does not drop the endpoint device reference stored in mac->mc_dev, so every successful connect leaks that device reference when the MAC is later disconnected.
Drop the endpoint device reference after closing the MAC and before freeing the dpaa2_mac object.
--- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +1 -0
@@ -4721,6 +4721,7 @@ static void dpaa2_eth_disconnect_mac(struct dpaa2_eth_priv *priv)dpaa2_mac_disconnect (mac);dpaa2_mac_close (mac); +put_device (&mac->mc_dev->dev);kfree (mac); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 179/602 iommu/amd: Wait for completion instead of returning early in iommu_completion_wait()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanghui Feng <[email protected]>
[ Upstream commit 1e75a8255f11c81fb07e81e5029cfd75804350a0 ]
need_sync is a per-IOMMU flag shared by all domains and devices behind that IOMMU. It is set whenever a command is queued with sync == true and cleared when a completion-wait (CWAIT) command is queued. However, a cleared need_sync only means that a covering CWAIT has been queued, not that all previously queued commands have actually completed in hardware.
iommu_completion_wait() read need_sync locklessly and returned early when it was false. This breaks the "block until all previously queued commands have completed" contract in a multi-CPU scenario:
CPU2: queue inv-B => need_sync = true
CPU1: queue CWAIT(N); need_sync = false; then wait_on_sem(N)
CPU2: read need_sync == false => return 0 (no wait!)
CPU2 returns without waiting for any sequence number even though its inv-B may not have completed yet (CWAIT(N), queued after inv-B, has not been signaled). CPU2 then proceeds to, for example, free page-table pages while the IOMMU can still walk stale translations, opening a use-after-free window. This is a logical race in the meaning of the flag, not a memory-visibility issue, so barriers alone do not help.
Fix it without losing the optimization of avoiding redundant CWAIT
commands: take iommu->lock before testing need_sync, and when it is false do not return early but wait for the last allocated sequence number (cmd_sem_val). Since need_sync == false implies no sync command was queued after the last CWAIT, that CWAIT is FIFO-ordered after every not-yet-completed command, so waiting for its sequence number guarantees all prior commands (possibly queued by another CPU) have completed. The common path with pending work is unchanged and no extra hardware command is issued.
--- drivers/iommu/amd/iommu.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/iommu/amd/iommu.c +16 -6
@@ -1424,11 +1424,23 @@ static int iommu_completion_wait(struct amd_iommu *iommu)int ret;u64 data; -if (!iommu->need_sync) -return 0 ; -raw_spin_lock_irqsave (&iommu->lock, flags); +if (!iommu->need_sync) { +/* +* No command has been queued since the last completion-wait. +* A concurrent CPU may have already queued that CWAIT and +* cleared need_sync; need_sync == false only means a covering +* CWAIT is queued, not that all prior commands have completed. +* Wait for the last allocated sequence number so that any +* command queued before this call (possibly on another CPU) +* is guaranteed to have completed before returning. +*/ + data = iommu->cmd_sem_val; +raw_spin_unlock_irqrestore (&iommu->lock, flags); +return wait_on_sem (iommu, data); + } + data =get_cmdsem_val (iommu);build_completion_wait (&cmd, iommu, data);
@@ -1438,9 +1450,7 @@ static int iommu_completion_wait(struct amd_iommu *iommu)if (ret)return ret; - ret =wait_on_sem (iommu, data); - -return ret; +return wait_on_sem (iommu, data); }static void domain_flush_complete (struct protection_domain *domain)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 180/602 wifi: mac80211: tear down new links on vif update error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 952c02b33f56207a160421bcd61e7ac53c9c59ae ]
When ieee80211_vif_update_links() adds new links it allocates a link container for each and calls ieee80211_link_init() (which registers the per-link debugfs files with file->private_data pointing into the container) and ieee80211_link_setup(). If the subsequent drv_change_vif_links() fails, the error path restores the old pointers and jumps to 'free', which frees the new containers but never removes their debugfs entries or stops the links. The debugfs files survive with file->private_data dangling at the freed container, so a later open()+read() (e.g. link-1/txpower) dereferences freed memory in ieee80211_if_read_link(), a use-after-free.
The removal path already dismantles links correctly via ieee80211_tear_down_links(), which removes each link's keys and debugfs entries and calls ieee80211_link_stop(); the add path on the error branch does not. Commit be1ba9ed221f ("wifi: mac80211: avoid weird state in error path") hardened this same error path for the link-removal case (new_links == 0) but left the newly-added links' teardown unaddressed.
drv_change_vif_links() can fail at runtime on MLO drivers (internal allocation / queue / firmware command failures).
Remove the new links' debugfs entries and stop them before freeing.
BUG: KASAN: slab-use-after-free in ieee80211_if_read_link (net/mac80211/debugfs_netdev.c:127) Read of size 8 at addr ffff888011290000 by task exploit/145 Call Trace: ... ieee80211_if_read_link (net/mac80211/debugfs_netdev.c:127) short_proxy_read (fs/debugfs/file.c:373) vfs_read (fs/read_write.c:572) ksys_read (fs/read_write.c:716) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) ... Oops: general protection fault, probably for non-canonical address 0xdffffc000000000a RIP: 0010:ieee80211_if_read_link (net/mac80211/debugfs_netdev.c:127) Kernel panic - not syncing: Fatal exception
--- net/mac80211/link.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mac80211/link.c +4 -0
@@ -379,6 +379,10 @@ static int ieee80211_vif_update_links(struct ieee80211_sub_if_data *sdata,memcpy (sdata->link, old_data,sizeof (old_data));memcpy (sdata->vif.link_conf, old,sizeof (old));ieee80211_set_vif_links_bitmaps (sdata, old_links, dormant_links); +for_each_set_bit (link_id, &add,IEEE80211_MLD_MAX_NUM_LINKS ) { +ieee80211_link_debugfs_remove (&links[link_id]->data); +ieee80211_link_stop (&links[link_id]->data); + }/* and free (only) the newly allocated links */ memset (to_free,0 ,sizeof (links)); goto free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 181/602 nfp: Check resource mutex allocation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit a61b4db34a753bdf5c9e77a7f3d3dddd41dcfacc ]
nfp_cpp_resource_find() allocates a CPP mutex handle for the matching resource-table entry and then reports success. nfp_resource_try_acquire() immediately passes that handle to nfp_cpp_mutex_trylock().
However, nfp_cpp_mutex_alloc() returns NULL on failure. If that happens for a matching table entry, the resource lookup still returns success and the following trylock dereferences a NULL mutex pointer while opening the resource.
nfp_resource_acquire() already treats failure to allocate the table mutex as -ENOMEM. Do the same for the resource mutex and fail the lookup before publishing the rest of the resource handle.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c +3 -0
@@ -96,6 +96,9 @@ static int nfp_cpp_resource_find(struct nfp_cpp *cpp, struct nfp_resource *res) res->mutex =nfp_cpp_mutex_alloc (cpp,NFP_RESOURCE_TBL_TARGET , addr, key); +if (!res->mutex) +return -ENOMEM ; + res->cpp_id =NFP_CPP_ID (entry.region.cpp_target, entry.region.cpp_action, entry.region.cpp_token);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 182/602 wan: wanxl: Only reset hardware after BAR mapping
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 91957b89da995607cb654b1f9a3c126ddbaee10f ]
wanxl_pci_init_one() stores the freshly allocated card in driver data before the PLX BAR is mapped. Several early probe failures then unwind through wanxl_pci_remove_one(), including failure to allocate the coherent status area or to restore the DMA mask.
wanxl_pci_remove_one() unconditionally calls wanxl_reset(), and wanxl_reset() dereferences card->plx. On those early failures card->plx is still NULL, so the error path can dereference a NULL MMIO pointer.
Only issue the hardware reset once the BAR mapping exists. The remaining cleanup in wanxl_pci_remove_one() already checks whether later resources were allocated.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/net/wan/wanxl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wan/wanxl.c +2 -1
@@ -514,7 +514,8 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev)if (card->irq)free_irq (card->irq, card); -wanxl_reset (card); +if (card->plx) +wanxl_reset (card);for (i =0 ; i <RX_QUEUE_LENGTH ; i++)if (card->rx_skbs[i]) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 183/602 wifi: mwifiex: bound uAP association event IEs to the event buffer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HE WEI (ギカク) <[email protected]>
[ Upstream commit f0858bfc7d3cab411a447b88e3ef970e575032c9 ]
mwifiex_process_uap_event() handles EVENT_UAP_STA_ASSOC by exposing the (re)association request IEs that the firmware copies into the event:
sinfo->assoc_req_ies = &event->data[len]; len = (u8 *)sinfo->assoc_req_ies - (u8 *)&event->frame_control; sinfo->assoc_req_ies_len = le16_to_cpu(event->len) - (u16)len;
event->len is supplied by the device firmware and is never validated, and the subtraction is unchecked. assoc_req_ies points into adapter->event_body[MAX_EVENT_SIZE], a fixed-size array embedded in the kmalloc()'d struct mwifiex_adapter.
On the ap_11n_enabled path mwifiex_set_sta_ht_cap() walks these IEs with cfg80211_find_ie(), whose for_each_element() loop dereferences each element header. A firmware-reported event->len larger than the bytes actually received makes assoc_req_ies_len describe IEs that extend past event_body, so the walk reads out of the adapter slab object, a slab-out-of-bounds read (KASAN: slab-out-of-bounds in cfg80211_find_ie). An event->len smaller than the header instead makes the int subtraction negative, which wraps to a huge size_t when stored in assoc_req_ies_len. The same length is handed to cfg80211_new_sta(), so a more modest over-claim can also copy stale event_body bytes into the NL80211_CMD_NEW_STATION notification.
A malicious or malfunctioning mwifiex device (USB/SDIO/PCIe) can deliver such an event while the interface is in AP/uAP mode.
Validate event->len before use: reject a length that underflows the header or that would place the IEs outside the event_body[] buffer the event was copied into. event->len here is struct mwifiex_assoc_event.len, a payload field internal to this event, not the transport frame length, so it is validated in this handler rather than at the generic MWIFIEX_TYPE_EVENT receive path, which only sees the event cause and the transport frame length. The bound is against event_body[MAX_EVENT_SIZE] rather than the actually-received length because the transports store the event differently (USB and SDIO leave the 4-byte event header in event_skb, PCIe strips it via skb_pull), whereas event_body is the single fixed buffer all of them copy the event into. This is the event-path analogue of the receive-path bounds checks added in commit 119585281617 ("wifi: mwifiex: Fix OOB and integer underflow when rx packets").
--- .../net/wireless/marvell/mwifiex/uap_event.c | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/net/wireless/marvell/mwifiex/uap_event.c +22 -2
@@ -123,11 +123,31 @@ int mwifiex_process_uap_event(struct mwifiex_private *priv) len =ETH_ALEN ;if (len !=-1 ) { +u16 evt_len =le16_to_cpu (event->len); + sinfo->assoc_req_ies = &event->data[len]; len = (u8 *)sinfo->assoc_req_ies - (u8 *)&event->frame_control; - sinfo->assoc_req_ies_len = -le16_to_cpu (event->len) - (u16 )len; + +/* +* event->len is reported by the device firmware +* and is not otherwise validated. Reject a +* length that underflows the header, or that +* would place the association request IEs +* outside the fixed-size event_body[] buffer the +* event was copied into; otherwise the IE walk +* in mwifiex_set_sta_ht_cap() reads past +* event_body and out of the adapter slab object. +*/ +if (evt_len < len || + (u8 *)&event->frame_control + evt_len > + adapter->event_body +MAX_EVENT_SIZE ) { +mwifiex_dbg (adapter,ERROR , +"invalid STA assoc event length\n" ); +kfree (sinfo); +return -1 ; + } + sinfo->assoc_req_ies_len = evt_len - (u16 )len; } } cfg80211_new_sta(priv->netdev, event->sta_addr, sinfo,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 184/602 iommu/amd: Bound the early ACPI HID map
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit fb80117fddb5b477218dc99bb53911b72c3847f8 ]
The ivrs_acpihid command-line parser appends entries to a fixed four-element early_acpihid_map array. Unlike the sibling IOAPIC and HPET parsers, it does not reject a fifth entry before incrementing the map size.
Check the capacity at the common found label before parsing the HID and UID or writing the entry.
--- drivers/iommu/amd/init.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/iommu/amd/init.c +6 -0
@@ -3696,6 +3696,12 @@ static int __init parse_ivrs_acpihid(char *str)return 1 ; found: +if (early_acpihid_map_size ==EARLY_MAP_SIZE ) { +pr_err ("Early ACPI HID map overflow - ignoring ivrs_acpihid%s\n" , + str); +return 1 ; + } + p = acpiid; hid =strsep (&p,":" ); uid = p;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 185/602 iommu/intel: Fix out-of-bounds memset in dmar_latency_disable()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 754f8efe45f87e3a9c6871b645b2f9d46d1b407b ]
dmar_latency_disable() intends to zero out only the single latency_statistic entry for the given type, but the memset size was computed as sizeof(*lstat) * DMAR_LATENCY_NUM, which clears the entire array starting from &lstat[type].
When type > 0, this writes beyond the end of the allocated array, corrupting adjacent memory.
Fix by using sizeof(*lstat) to clear only the target entry.
--- drivers/iommu/intel/perf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel/perf.c +1 -1
@@ -63,7 +63,7 @@ void dmar_latency_disable(struct intel_iommu *iommu, enum latency_type type)return ;spin_lock_irqsave (&latency_lock, flags); -memset (&lstat[type],0 ,sizeof (*lstat) *DMAR_LATENCY_NUM ); +memset (&lstat[type],0 ,sizeof (*lstat));spin_unlock_irqrestore (&latency_lock, flags); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 186/602 wifi: mac80211: recalculate TIM when a station enters power save
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Pope <[email protected]>
[ Upstream commit a007a384c9eb17610f53a53e2f59944c31f1565a ]
When an AP buffers frames for a station on its per-station TXQs and the station subsequently enters power save, sta_ps_start() records the buffered TIDs in txq_buffered_tids but does not update the TIM. The station's TIM bit is only ever set when a further frame is buffered while the station is already asleep (ieee80211_tx_h_unicast_ps_buf() -> sta_info_recalc_tim()).
If no further downlink frame arrives for that station the beacon TIM never advertises the buffered traffic. A station relying on the TIM then remains in doze indefinitely on top of a non-empty queue. Its TXQs were removed from the scheduler's active list at PS entry, nothing pages it, and the flow deadlocks until an unrelated event wakes the station.
Recalculate the TIM at the end of sta_ps_start(), so traffic already buffered at PS entry is advertised immediately. sta_info_recalc_tim() already consults txq_buffered_tids, which is updated above, and is safe in this context (it is already called from equivalent paths such as the tx handlers and ieee80211_handle_filtered_frame()).
--- net/mac80211/rx.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac80211/rx.c +2 -0
@@ -1595,6 +1595,8 @@ static void sta_ps_start(struct sta_info *sta)else clear_bit (tid, &sta->txq_buffered_tids); } + +sta_info_recalc_tim (sta); }static void sta_ps_end (struct sta_info *sta)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 187/602 pds_core: reject component parameter in legacy firmware update
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit 7be2552e601c247a328a5aba6fc06ac844b94a16 ]
The legacy firmware update path does not support per-component updates. If a user specifies a component parameter with devlink flash, reject the request with -EOPNOTSUPP rather than silently ignoring the component parameter and flashing the entire firmware image.
--- drivers/net/ethernet/amd/pds_core/devlink.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/amd/pds_core/devlink.c +6 -0
@@ -89,6 +89,12 @@ int pdsc_dl_flash_update(struct devlink *dl, {struct pdsc *pdsc =devlink_priv (dl); +if (params->component) { +NL_SET_ERR_MSG_MOD (extack, +"Component update not supported by this device" ); +return -EOPNOTSUPP ; + } +return pdsc_firmware_update (pdsc, params->fw, extack); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 188/602 amd-xgbe: fix MAC_AUTO_SW handling in CL37 AN
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prashanth Kumar KR <[email protected]>
[ Upstream commit 4bf22afe53a1de4b44b04cf677fd5199089cbdff ]
MAC_AUTO_SW (VR_MII_DIG_CTRL1 bit 9) enables automatic XPCS speed mode switching after CL37 auto-negotiation and is only meaningful in SGMII MAC mode. The original code unconditionally set this bit on every call to xgbe_an37_set(), including when called from xgbe_an37_disable() with enable=false. This left MAC_AUTO_SW=1 after AN was disabled, causing the XPCS to autonomously switch speed from stale AN state during subsequent mode changes, breaking SGMII speed negotiation on 1G copper SFP modules.
Patrick: This was breaking negotiation for all 1G SFP modules, not just copper modules.
--- drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +8 -3
@@ -376,9 +376,14 @@ static void xgbe_an37_set(struct xgbe_prv_data *pdata, bool enable,XMDIO_WRITE (pdata,MDIO_MMD_VEND2 ,MDIO_CTRL1 , reg); - reg =XMDIO_READ (pdata,MDIO_MMD_VEND2 ,MDIO_PCS_DIG_CTRL ); - reg |=XGBE_VEND2_MAC_AUTO_SW ; -XMDIO_WRITE (pdata,MDIO_MMD_VEND2 ,MDIO_PCS_DIG_CTRL , reg); +if (pdata->an_mode ==XGBE_AN_MODE_CL37_SGMII ) { + reg =XMDIO_READ (pdata,MDIO_MMD_VEND2 ,MDIO_PCS_DIG_CTRL ); +if (enable) + reg |=XGBE_VEND2_MAC_AUTO_SW ; +else + reg &= ~XGBE_VEND2_MAC_AUTO_SW ; +XMDIO_WRITE (pdata,MDIO_MMD_VEND2 ,MDIO_PCS_DIG_CTRL , reg); + } }static void xgbe_an37_restart (struct xgbe_prv_data *pdata)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 189/602 net: txgbe: fix FDIR filter leak on remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenguang Zhao <[email protected]>
[ Upstream commit ecaa37826340520664a4e5522f803ff48fc3f564 ]
Perfect FDIR filters can be added while the interface is down and are kept on the software list for later restore. unregister_netdev() only calls ndo_stop when the device is up, so txgbe_fdir_filter_exit() in txgbe_close() is skipped in that case and the filters are leaked on driver remove. Free the filter list from txgbe_remove() as well.
--- drivers/net/ethernet/wangxun/txgbe/txgbe_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c +1 -0
@@ -744,6 +744,7 @@ static void txgbe_remove(struct pci_dev *pdev) netdev = wx->netdev;unregister_netdev (netdev); +txgbe_fdir_filter_exit (wx);txgbe_remove_phy (txgbe);wx_free_isb_resources (wx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 190/602 sctp: fix auth_chunk_list capacity check in sctp_auth_ep_add_chunkid
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: HanQuan <[email protected]>
[ Upstream commit ff04b26794a16a8a879eb4fd2c02c2d6b03850e9 ]
sctp_auth_ep_add_chunkid() uses SCTP_NUM_CHUNK_TYPES (20) as the capacity limit for ep->auth_chunk_list, allowing it to hold up to 20 chunk entries (param_hdr.length up to 24). However, the copy destination asoc->c.auth_chunks in struct sctp_cookie is only SCTP_AUTH_MAX_CHUNKS (16) entries (20 bytes). When more than 16 chunks are added, sctp_association_init() memcpy overflows the destination by up to 4 bytes.
Fix by using SCTP_AUTH_MAX_CHUNKS as the capacity limit, matching the destination capacity.
--- net/sctp/auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/auth.c +1 -1
@@ -766,7 +766,7 @@ int sctp_auth_ep_add_chunkid(struct sctp_endpoint *ep, __u8 chunk_id)/* Check if we can add this chunk to the array */ param_len =ntohs (p->param_hdr.length); nchunks = param_len -sizeof (struct sctp_paramhdr ); -if (nchunks ==SCTP_NUM_CHUNK_TYPES ) +if (nchunks ==SCTP_AUTH_MAX_CHUNKS )return -EINVAL ; p->chunks[nchunks] = chunk_id;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 191/602 pds_core: fix deadlock between reset thread and remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit ab0eec0ff0a421737a37f510ceab5c6ea59cd05a ]
pci_reset_function() acquires device_lock before performing the reset. pdsc_remove() is called by the PCI core with device_lock already held. If pdsc_pci_reset_thread() is running when pdsc_remove() is called, destroy_workqueue() will block waiting for the work to complete, while the work is blocked waiting for device_lock - deadlock.
Use pci_try_reset_function() which uses pci_dev_trylock() internally. This acquires both the device lock and the PCI config access lock without blocking - if either lock is contended, it returns -EAGAIN immediately. This avoids the deadlock while also ensuring proper config space access serialization during the reset.
The pci_dev_get/put calls are also removed as they were unnecessary - the driver-owned workqueue is destroyed in pdsc_remove(), guaranteeing the work completes before remove returns. The PCI core holds its reference to pci_dev throughout the entire unbind sequence.
--- drivers/net/ethernet/amd/pds_core/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/pds_core/core.c +4 -3
@@ -597,9 +597,10 @@ void pdsc_pci_reset_thread(struct work_struct *work) struct pdsc *pdsc = container_of(work, struct pdsc, pci_reset_work);struct pci_dev *pdev = pdsc->pdev; -pci_dev_get (pdev); -pci_reset_function (pdev); -pci_dev_put (pdev); +/* Use try variant to avoid deadlock with pdsc_remove(). +* If lock is contended, the watchdog timer will retry. +*/ +pci_try_reset_function (pdev); }static void pdsc_check_pci_health (struct pdsc *pdsc)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 192/602 pds_core: fix use-after-free on workqueue during remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit 0ad134881508c36b65c1a8864f8bec53adbd3327 ]
In pdsc_remove(), the workqueue is destroyed before pdsc_teardown() is called. This ordering allows two paths to queue work on the destroyed workqueue:
1. If pdsc_teardown() -> pdsc_devcmd_reset() times out, the error path in pdsc_devcmd_locked() queues health_work.
2. A NotifyQ event can trigger the ISR and queue work before free_irq() is called in pdsc_teardown().
Fix by moving destroy_workqueue() after pdsc_teardown() so the workqueue outlives every queuer; destroy_workqueue() then flushes any work still pending.
Draining the queued work also requires ordering the teardown so the resources that work touches are freed last:
- In pdsc_qcq_free(), after freeing the interrupt, cancel_work_sync()
the queue's work and only then clear qcq->intx, so
pdsc_process_adminq()'s read of qcq->intx for interrupt-credit
return cannot race with the clear.- Free adminqcq before notifyqcq: the shared adminq ISR is released when adminqcq is freed, and the adminq work accesses notifyqcq, so both must be stopped before notifyqcq is freed.
--- drivers/net/ethernet/amd/pds_core/core.c | 14 ++++++++++---- drivers/net/ethernet/amd/pds_core/main.c | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/net/ethernet/amd/pds_core/core.c +10 -4
@@ -110,7 +110,6 @@ static void pdsc_qcq_intr_free(struct pdsc *pdsc, struct pdsc_qcq *qcq)return ;pdsc_intr_free (pdsc, qcq->intx); - qcq->intx =PDS_CORE_INTR_INDEX_NOT_ASSIGNED ; }static int pdsc_qcq_intr_alloc (struct pdsc *pdsc,struct pdsc_qcq *qcq)
@@ -145,6 +144,12 @@ void pdsc_qcq_free(struct pdsc *pdsc, struct pdsc_qcq *qcq)pdsc_qcq_intr_free (pdsc, qcq); +/* Drain any work queued by ISR before it was freed above */ +if (qcq->work.func) +cancel_work_sync (&qcq->work); + + qcq->intx =PDS_CORE_INTR_INDEX_NOT_ASSIGNED ; +if (qcq->q_base)dma_free_coherent (dev, qcq->q_size, qcq->q_base, qcq->q_base_pa);
@@ -304,8 +309,11 @@ int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type, unsigned int index,static void pdsc_core_uninit (struct pdsc *pdsc) { -pdsc_qcq_free (pdsc, &pdsc->notifyqcq); +/* Free adminqcq first: its work accesses notifyqcq, so we must +* disable its IRQ and drain its work before freeing notifyqcq. +*/ pdsc_qcq_free (pdsc, &pdsc->adminqcq); +pdsc_qcq_free (pdsc, &pdsc->notifyqcq);if (pdsc->kern_dbpage) {iounmap (pdsc->kern_dbpage);
@@ -472,8 +480,6 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing) {if (!pdsc->pdev->is_virtfn)pdsc_devcmd_reset (pdsc); -if (pdsc->adminqcq.work.func) -cancel_work_sync (&pdsc->adminqcq.work);pdsc_core_uninit (pdsc);
drivers/net/ethernet/amd/pds_core/main.c +3 -2
@@ -429,8 +429,6 @@ static void pdsc_remove(struct pci_dev *pdev)pdsc_sriov_configure (pdev,0 );timer_shutdown_sync (&pdsc->wdtimer); -if (pdsc->wq) -destroy_workqueue (pdsc->wq);mutex_lock (&pdsc->config_lock);set_bit (PDSC_S_STOPPING_DRIVER , &pdsc->state);
@@ -438,6 +436,9 @@ static void pdsc_remove(struct pci_dev *pdev)pdsc_stop (pdsc);pdsc_teardown (pdsc,PDSC_TEARDOWN_REMOVING );mutex_unlock (&pdsc->config_lock); + +if (pdsc->wq) +destroy_workqueue (pdsc->wq);mutex_destroy (&pdsc->config_lock);mutex_destroy (&pdsc->devcmd_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 193/602 pds_core: yield the CPU while waiting for the adminq to drain
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit a11f0b8a204296fe7db9eaec53441012222cb004 ]
pdsc_adminq_wait_and_dec_once_unused() busy-waits for adminq_refcnt to drop to one:
while (!refcount_dec_if_one(&pdsc->adminq_refcnt)) cpu_relax();
The refcount is held by pdsc_adminq_post() for the duration of an in-flight command, which can wait up to devcmd_timeout seconds (PDS_CORE_DEVCMD_TIMEOUT is 5) for the hardware to complete. cpu_relax() is not a reschedule point, so on a non-preemptible kernel this loop can spin on the CPU for several seconds, starving other tasks on that core.
Add cond_resched() to the loop so the waiter yields to other runnable tasks while it polls, keeping cpu_relax() as the busy-wait hint between checks.
--- drivers/net/ethernet/amd/pds_core/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/amd/pds_core/core.c +1 -0
@@ -530,6 +530,7 @@ static void pdsc_adminq_wait_and_dec_once_unused(struct pdsc *pdsc)dev_dbg_ratelimited (pdsc->dev,"%s: adminq in use\n" , __func__);cpu_relax (); +cond_resched (); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 194/602 pds_core: order completion reads after the ownership check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit dd6b1cc748cd28147c113f9daa76393916ad9494 ]
pdsc_process_adminq() and pdsc_process_notifyq() decide a completion is valid from its ownership field - the color bit for the adminq, the event id for the notifyq - then read the rest of the descriptor, with no barrier in between.
On a weakly ordered architecture the CPU may read the payload first. Add dma_rmb() between the ownership read and the payload reads.
--- drivers/net/ethernet/amd/pds_core/adminq.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/ethernet/amd/pds_core/adminq.c +11 -1
@@ -18,7 +18,13 @@ static int pdsc_process_notifyq(struct pdsc_qcq *qcq) comp = cq_info->comp; eid =le64_to_cpu (comp->event.eid);while (eid > pdsc->last_eid) { -u16 ecode =le16_to_cpu (comp->event.ecode); +u16 ecode; + +/* Order the payload read after the event id, the field the +* driver uses to detect a new completion. +*/ +dma_rmb (); + ecode =le16_to_cpu (comp->event.ecode);switch (ecode) {case PDS_EVENT_LINK_CHANGE :
@@ -101,6 +107,10 @@ void pdsc_process_adminq(struct pdsc_qcq *qcq)spin_lock_irqsave (&pdsc->adminq_lock, irqflags); comp = cq->info[cq->tail_idx].comp;while (pdsc_color_match (comp->color, cq->done_color)) { +/* Order the payload reads after the color bit, the field the +* driver uses to detect a new completion. +*/ +dma_rmb (); q_info = &q->info[q->tail_idx]; q->tail_idx = (q->tail_idx +1 ) & (q->num_descs -1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 195/602 pds_core: fix auxiliary device add/del races
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit bfa33cd513c7ceb93c5a4c30e5662acd73c0a916 ]
Two paths add or delete the same slot (pf->vfs[vf_id].padev): a VF's pdsc_reset_done() and the PF's devlink enable_vnet/disable_vnet handler. They serialize on config_lock, but neither guards the slot under it correctly.
add() registers and stores a new auxiliary device without first checking the slot, so a second add of an already-populated slot leaks the first device. del() makes that check outside config_lock, so two concurrent dels can both pass it; the first clears the slot, and the second dereferences a NULL pointer.
Check and update the slot under config_lock in both paths.
--- drivers/net/ethernet/amd/pds_core/auxbus.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/pds_core/auxbus.c +14 -3
@@ -177,17 +177,21 @@ void pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf, {struct pds_auxiliary_dev *padev; -if (!*pd_ptr) -return ; -mutex_lock (&pf->config_lock); +/* A concurrent del may have already torn this device down and +* cleared it. +*/ padev = *pd_ptr; +if (!padev) + goto out_unlock; +pds_client_unregister (pf, padev->client_id);auxiliary_device_delete (&padev->aux_dev);auxiliary_device_uninit (&padev->aux_dev); *pd_ptr =NULL ; +out_unlock:mutex_unlock (&pf->config_lock); }
@@ -210,6 +214,13 @@ int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf,mutex_lock (&pf->config_lock); +/* Nothing to do if the aux device is already present. This also +* guards against a second add overwriting *pd_ptr and leaking the +* first, symmetric with the check in pdsc_auxbus_dev_del(). +*/ +if (*pd_ptr) + goto out_unlock; + mask =BIT_ULL (PDSC_S_FW_DEAD ) |BIT_ULL (PDSC_S_STOPPING_DRIVER );if (cf->state & mask) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 196/602 pds_core: check for workqueue allocation failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit 3a660ca49e2c3807bffe0519db3cff677a5906e0 ]
pdsc_init_pf() does not check whether create_singlethread_workqueue() succeeded.
Fail probe on failure. The workqueue is set up before the timer and mutexes, so its failure path must unwind only the earlier setup.
--- drivers/net/ethernet/amd/pds_core/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/amd/pds_core/main.c +7 -2
@@ -239,6 +239,10 @@ static int pdsc_init_pf(struct pdsc *pdsc)/* General workqueue and timer, but don't start timer yet */ snprintf (wq_name,sizeof (wq_name),"%s.%d" ,PDS_CORE_DRV_NAME , pdsc->uid); pdsc->wq =create_singlethread_workqueue (wq_name); +if (!pdsc->wq) { + err = -ENOMEM ; + goto err_out_unmap_bars; + }INIT_WORK (&pdsc->health_work, pdsc_health_thread);INIT_WORK (&pdsc->pci_reset_work, pdsc_pci_reset_thread);timer_setup (&pdsc->wdtimer, pdsc_wdtimer_cb,0 );
@@ -254,7 +258,7 @@ static int pdsc_init_pf(struct pdsc *pdsc) err =pdsc_setup (pdsc,PDSC_SETUP_INIT );if (err) {mutex_unlock (&pdsc->config_lock); - goto err_out_unmap_bars; + goto err_out_shutdown_timer; } err =pdsc_start (pdsc);
@@ -300,13 +304,14 @@ static int pdsc_init_pf(struct pdsc *pdsc)pdsc_stop (pdsc); err_out_teardown:pdsc_teardown (pdsc,PDSC_TEARDOWN_REMOVING ); -err_out_unmap_bars: +err_out_shutdown_timer:timer_shutdown_sync (&pdsc->wdtimer);if (pdsc->wq)destroy_workqueue (pdsc->wq);mutex_destroy (&pdsc->config_lock);mutex_destroy (&pdsc->devcmd_lock);pci_free_irq_vectors (pdsc->pdev); +err_out_unmap_bars:pdsc_unmap_bars (pdsc); err_out_release_regions:pci_release_regions (pdsc->pdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 197/602 sctp: validate stream count in sctp_process_strreset_inreq()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang (Microsoft) <[email protected]>
[ Upstream commit 18ae07691d43183d270de8be9dc8e027906015d9 ]
When processing a RESET_IN_REQUEST from a peer, sctp_process_strreset_inreq() derives the stream count from the parameter length but does not check whether the resulting RESET_OUT_REQUEST would exceed SCTP_MAX_CHUNK_LEN.
The OUT request header (sctp_strreset_outreq, 16 bytes) is 8 bytes larger than the IN request header (sctp_strreset_inreq, 8 bytes). Generally, the IP payload is bounded to 65535 bytes, so the stream list cannot be large enough to trigger the overflow. However, on interfaces with MTU > 65535 (e.g., loopback with IPv6 jumbograms), a stream list that fits within the incoming IN parameter can cause a __u16 overflow in sctp_make_strreset_req() when computing the OUT request size, leading to an undersized skb allocation and a kernel BUG:
net/core/skbuff.c:207 skb_panic
net/core/skbuff.c:2625 skb_put
net/sctp/sm_make_chunk.c:1535 sctp_addto_chunk net/sctp/sm_make_chunk.c:3695 sctp_make_strreset_req
net/sctp/stream.c:655 sctp_process_strreset_inreq
The local setsockopt path validates the generated reset request size. However, for an incoming-only reset, it accounts for the smaller IN request even though the peer must generate an OUT request with the same stream list. Such a request cannot be completed successfully by the peer.
Reject peer IN requests whose corresponding OUT request would exceed SCTP_MAX_CHUNK_LEN. Also tighten the local check so it does not send an IN request that would require an oversized OUT request from the peer.
--- net/sctp/stream.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sctp/stream.c +5 -1
@@ -308,7 +308,8 @@ int sctp_send_reset_streams(struct sctp_association *asoc, goto out; param_len += str_nums *sizeof (__u16) + -sizeof (struct sctp_strreset_inreq ); + (out ?sizeof (struct sctp_strreset_inreq ) + :sizeof (struct sctp_strreset_outreq )); } if (param_len > SCTP_MAX_CHUNK_LEN -
@@ -639,6 +640,9 @@ struct sctp_chunk *sctp_process_strreset_inreq( nums = (ntohs (param.p->length) -sizeof (*inreq)) /sizeof (__u16); str_p = inreq->list_of_streams; +if (nums *sizeof (__u16) +sizeof (struct sctp_strreset_outreq ) > +SCTP_MAX_CHUNK_LEN -sizeof (struct sctp_reconf_chunk )) + goto out;for (i =0 ; i < nums; i++) {if (ntohs (str_p[i]) >= stream->outcnt) { result =SCTP_STRRESET_ERR_WRONG_SSN ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 198/602 net: mctp i3c: clean up notifier and buses if driver register fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 03d1057305ef17ac3f5936ac1580bc9a1a826e14 ]
mctp_i3c_mod_init() registers the I3C bus notifier and then walks the existing buses with i3c_for_each_bus_locked(mctp_i3c_bus_add_new, NULL) before registering the I3C device driver. If i3c_driver_register() fails, the function returns the error directly, leaving the notifier registered and every mctp_i3c_bus object created for the existing buses allocated. The notifier is left pointing into the module that failed to load and the bus list is leaked.
Mirror the module exit path on this failure: unregister the notifier and tear down the buses that were added before returning the error.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/net/mctp/mctp-i3c.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/mctp/mctp-i3c.c +7 -4
@@ -731,18 +731,21 @@ static __init int mctp_i3c_mod_init(void)int rc; rc =i3c_register_notifier (&mctp_i3c_notifier); -if (rc <0 ) { -i3c_driver_unregister (&mctp_i3c_driver); +if (rc <0 )return rc; - }i3c_for_each_bus_locked (mctp_i3c_bus_add_new,NULL ); rc =i3c_driver_register (&mctp_i3c_driver);if (rc <0 ) -return rc; + goto err_unregister_notifier;return 0 ; + +err_unregister_notifier: +i3c_unregister_notifier (&mctp_i3c_notifier); +mctp_i3c_bus_remove_all (); +return rc; } static __exit void mctp_i3c_mod_exit(void)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 199/602 tls: device: push pending open record on splice EOF
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rishikesh Jethwani <[email protected]>
[ Upstream commit eaa39f9f8ac8c1d032cd26b9cd572804e9d7683f ]
On kTLS device-offload sockets, sendfile() with count > EOF can reach ->splice_eof() with a fully assembled but still-open TLS record left pending. tls_device_splice_eof() only flushes partially sent records, so an abrupt close() can drop the final record and the peer receives a short file.
Fix tls_device_splice_eof() to also push pending open records. This matches the software path, where splice EOF already flushes pending open records.
--- net/tls/tls_device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/tls/tls_device.c +4 -2
@@ -594,13 +594,15 @@ void tls_device_splice_eof(struct socket *sock)struct tls_context *tls_ctx =tls_get_ctx (sk);struct iov_iter iter = {}; -if (!tls_is_partially_sent_record (tls_ctx)) +if (!tls_is_partially_sent_record (tls_ctx) && + !tls_is_pending_open_record (tls_ctx))return ;mutex_lock (&tls_ctx->tx_lock);lock_sock (sk); -if (tls_is_partially_sent_record (tls_ctx)) { +if (tls_is_partially_sent_record (tls_ctx) || +tls_is_pending_open_record (tls_ctx)) {iov_iter_bvec (&iter,ITER_SOURCE ,NULL ,0 ,0 );tls_push_data (sk, &iter,0 ,0 ,TLS_RECORD_TYPE_DATA ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 200/602 selftests: af_unix: add USER_NS config
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
[ Upstream commit f8b1abed736111f914b2c567d9a3db1f71e788e8 ]
This is required to use unshare(CLONE_NEWUSER).
This has not been seen on NIPA before, because the 'af_unix' tests are executed with the 'net' ones, merging their config files. USER_NS is present in tools/testing/selftests/net/config.
This issue is visible when only the af_unix config is used on top of the default one. This is the recommended way to execute selftest targets.
--- tools/testing/selftests/net/af_unix/config | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/net/af_unix/config +1 -0
@@ -1,3 +1,4 @@ CONFIG_UNIX=y CONFIG_AF_UNIX_OOB=y CONFIG_UNIX_DIAG=m +CONFIG_USER_NS=y
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 201/602 selftests: openvswitch: add config file
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
[ Upstream commit 441a820ccef9af80a9ac5a4c85b9c396e595967c ]
The kselftests doc mentions that a config file should be present "if a test needs specific kernel config options enabled". This selftest requires some kernel config, but no config file was provided.
We could say that a sub-target could use the parent's config file, but the kselftests doc doesn't mention anything about that. Plus the net/openvswitch target is the only net target without a config file.
Here is a new config file, which is a trimmed version of the net one, with hopefully the minimal required kconfig on top of 'make defconfig'.
The Fixes tag points to the introduction of the net/openvswitch target, just to help validating this target on stable kernels.
--- tools/testing/selftests/net/openvswitch/config | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tools/testing/selftests/net/openvswitch/config
tools/testing/selftests/net/openvswitch/config new file +16 -0
@@ -0,0 +1,16 @@ +CONFIG_GENEVE=m +CONFIG_INET_DIAG=y +CONFIG_IPV6=y +CONFIG_NETFILTER=y +CONFIG_NET_IPGRE=m +CONFIG_NET_IPGRE_DEMUX=m +CONFIG_NF_CONNTRACK=m +CONFIG_NF_CONNTRACK_OVS=y +CONFIG_OPENVSWITCH=m +CONFIG_OPENVSWITCH_GENEVE=m +CONFIG_OPENVSWITCH_GRE=m +CONFIG_OPENVSWITCH_VXLAN=m +CONFIG_PSAMPLE=m +CONFIG_VETH=y +CONFIG_VLAN_8021Q=y +CONFIG_VXLAN=m
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 202/602 gtp: check skb_pull_data() return in gtp1u_send_echo_resp()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei (Microsoft) <[email protected]>
[ Upstream commit cd170f051dba9ac146fabcd1b91726487c0cb9fa ]
gtp1u_send_echo_resp() ignores skb_pull_data()'s return value. Its caller gtp1u_udp_encap_recv() only guarantees 16 bytes (udphdr + gtp1_header), but the pull requests 20 (gtp1_header_long + udphdr). For a 16-19 byte echo request the pull fails and returns NULL without advancing skb->data; execution continues, and the following skb_push() plus the IP header pushed by iptunnel_xmit() move skb->data below skb->head, tripping skb_under_panic().
Fix it by dropping the packet when skb_pull_data() fails.
skbuff: skb_under_panic: ...
kernel BUG at net/core/skbuff.c:214!
Call Trace: skb_push (net/core/skbuff.c:2648) iptunnel_xmit (net/ipv4/ip_tunnel_core.c:82) gtp_encap_recv (drivers/net/gtp.c:701 drivers/net/gtp.c:808 drivers/net/gtp.c:920) udp_queue_rcv_one_skb (net/ipv4/udp.c:2388) ... Kernel panic - not syncing: Fatal exception in interrupt
--- drivers/net/gtp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/gtp.c +3 -2
@@ -665,8 +665,9 @@ static int gtp1u_send_echo_resp(struct gtp_dev *gtp, struct sk_buff *skb)return -1 ;/* pull GTP and UDP headers */ -skb_pull_data (skb, -sizeof (struct gtp1_header_long ) +sizeof (struct udphdr )); +if (!skb_pull_data (skb,sizeof (struct gtp1_header_long ) + +sizeof (struct udphdr ))) +return -1 ; gtp_pkt =skb_push (skb,sizeof (struct gtp1u_packet ));memset (gtp_pkt,0 ,sizeof (struct gtp1u_packet ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 203/602 nexthop: initialize extack in nh_res_bucket_migrate()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei (Microsoft) <[email protected]>
[ Upstream commit 6347c5314cee49f364aaf2e40ff15415a57a116e ]
nh_res_bucket_migrate() passes an uninitialized netlink_ext_ack to call_nexthop_res_bucket_notifiers(). When nh_notifier_res_bucket_info_init() fails (e.g. the kzalloc returns -ENOMEM), the error is propagated back before any notifier sets extack._msg, and the error path formats the stale pointer with pr_err_ratelimited("%s\n", extack._msg). With CONFIG_INIT_STACK_NONE this dereferences uninitialized stack memory:
Oops: general protection fault, probably for non-canonical address ... KASAN: maybe wild-memory-access in range [...] RIP: 0010:string (lib/vsprintf.c:730) vsnprintf (lib/vsprintf.c:2945) _printk (kernel/printk/printk.c:2504) nh_res_bucket_migrate (net/ipv4/nexthop.c:1816) nh_res_table_upkeep (net/ipv4/nexthop.c:1866) rtm_new_nexthop (net/ipv4/nexthop.c:3323) rtnetlink_rcv_msg (net/core/rtnetlink.c:7076) netlink_sendmsg (net/netlink/af_netlink.c:1900) Kernel panic - not syncing: Fatal exception
Zero-initialize extack so _msg is NULL on error paths that never set it.
--- net/ipv4/nexthop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/nexthop.c +1 -1
@@ -1778,8 +1778,8 @@ static bool nh_res_bucket_migrate(struct nh_res_table *res_table, bool notify_nl, bool force) {struct nh_res_bucket *bucket = &res_table->nh_buckets[bucket_index]; +struct netlink_ext_ack extack = {};struct nh_grp_entry *new_nhge; -struct netlink_ext_ack extack;int err; new_nhge = list_first_entry_or_null(&res_table->uw_nh_entries,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 204/602 tipc: fix infinite loop in __tipc_nl_compat_dumpit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helen Koike <[email protected]>
[ Upstream commit 22f8aa35964e8f2ab026578f45befc9605fd1b28 ]
cmd->dumpit callback can return a negative errno, causing an infinite loop due to the while(len) condition. As the loop never terminates, genl_mutex is never released, and other tasks waiting on it starve in D state.
Check dumpit's return value, propagate it and jump to err_out on error.
--- net/tipc/netlink_compat.c | 4 ++++ 1 file changed, 4 insertions(+)
net/tipc/netlink_compat.c +4 -0
@@ -222,6 +222,10 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,int rem; len = (*cmd->dumpit)(buf, &cb); +if (len <0 ) { + err = len; + goto err_out; + }nlmsg_for_each_msg (nlmsg,nlmsg_hdr (buf), len, rem) { err = nlmsg_parse_deprecated(nlmsg, GENL_HDRLEN,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 205/602 wifi: mt76: mt7925: guard link STA in decap offload
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 96ea44f2269f30364cffa054ee3a87e595bef0d4 ]
mt7925_sta_set_decap_offload() iterates over the vif valid_links mask when updating decap offload state for an MLO station. The station may not have a link STA for every valid link of the vif, so mt792x_sta_to_link() can return NULL for a link that belongs to the vif but not to the station.
The function currently dereferences mlink before checking whether the link WCID is ready. If mlink is NULL, setting or clearing MT_WCID_FLAG_HDR_TRANS dereferences a NULL pointer.
Skip links without a station link before touching mlink->wcid.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +3 -0
@@ -1583,6 +1583,9 @@ static void mt7925_sta_set_decap_offload(struct ieee80211_hw *hw, mlink =mt792x_sta_to_link (msta, i); +if (!mlink) +continue ; +if (enabled)set_bit (MT_WCID_FLAG_HDR_TRANS , &mlink->wcid.flags);else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 206/602 wifi: mt76: mt7915: guard HE capability lookups
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 8e9db062654a388d0fa587acbeeae68dd33eba41 ]
mt7915_mcu_bss_he_tlv() and mt7915_mcu_sta_bfer_tlv() both run after checking HE support, then dereference the HE PHY capability returned by mt76_connac_get_he_phy_cap(). That helper can return NULL when no capability entry matches the vif type.
Fetch the capability before appending the TLV and skip the HE-specific setup when no matching capability is available.
--- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +13 -5
@@ -551,6 +551,8 @@ mt7915_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,struct tlv *tlv; cap =mt76_connac_get_he_phy_cap (phy->mt76, vif); +if (!cap) +return ; tlv =mt76_connac_mcu_add_tlv (skb,BSS_INFO_HE_BASIC ,sizeof (*he));
@@ -1133,13 +1135,12 @@ mt7915_mcu_sta_bfer_vht(struct ieee80211_sta *sta, struct mt7915_phy *phy, }static void -mt7915_mcu_sta_bfer_he (struct ieee80211_sta *sta,struct ieee80211_vif *vif, -struct mt7915_phy *phy,struct sta_rec_bf *bf) +mt7915_mcu_sta_bfer_he (struct ieee80211_sta *sta, +const struct ieee80211_sta_he_cap *vc, +struct sta_rec_bf *bf) {struct ieee80211_sta_he_cap *pc = &sta->deflink.he_cap;struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem; -const struct ieee80211_sta_he_cap *vc = -mt76_connac_get_he_phy_cap (phy->mt76, vif);const struct ieee80211_he_cap_elem *ve = &vc->he_cap_elem;u16 mcs_map =le16_to_cpu (pc->he_mcs_nss_supp.rx_mcs_80);u8 nss_mcs =mt7915_mcu_get_sta_nss (mcs_map);
@@ -1198,6 +1199,7 @@ mt7915_mcu_sta_bfer_tlv(struct mt7915_dev *dev, struct sk_buff *skb, {struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv;struct mt7915_phy *phy = mvif->phy; +const struct ieee80211_sta_he_cap *vc =NULL ;int tx_ant =hweight8 (phy->mt76->chainmask) -1 ;struct sta_rec_bf *bf;struct tlv *tlv;
@@ -1216,6 +1218,12 @@ mt7915_mcu_sta_bfer_tlv(struct mt7915_dev *dev, struct sk_buff *skb,if (!ebf && !dev->ibf)return ; +if (sta->deflink.he_cap.has_he && ebf) { + vc =mt76_connac_get_he_phy_cap (phy->mt76, vif); +if (!vc) +return ; + } + tlv =mt76_connac_mcu_add_tlv (skb,STA_REC_BF ,sizeof (*bf)); bf = (struct sta_rec_bf *)tlv;
@@ -1224,7 +1232,7 @@ mt7915_mcu_sta_bfer_tlv(struct mt7915_dev *dev, struct sk_buff *skb,* ht: iBF only, since mac80211 lacks of eBF support */ if (sta->deflink.he_cap.has_he && ebf) -mt7915_mcu_sta_bfer_he (sta, vif, phy, bf); +mt7915_mcu_sta_bfer_he (sta, vc, bf);else if (sta->deflink.vht_cap.vht_supported)mt7915_mcu_sta_bfer_vht (sta, phy, bf, ebf);else if (sta->deflink.ht_cap.ht_supported)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 207/602 wifi: mt76: connac: fix possible NULL-pointer deref in mt76_connac_mcu_uni_bss_he_tlv()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 2c1fb2335f5e3afb34f91bc07ecb63517c328090 ]
mt76_connac_get_he_phy_cap routine can theoretically return NULL so check cap pointer before dereferencing it.
--- drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +2 -0
@@ -1435,6 +1435,8 @@ mt76_connac_mcu_uni_bss_he_tlv(struct mt76_phy *phy, struct ieee80211_vif *vif,struct bss_info_uni_he *he; cap =mt76_connac_get_he_phy_cap (phy, vif); +if (!cap) +return ; he = (struct bss_info_uni_he *)tlv; he->he_pe_duration = vif->bss_conf.htc_trig_based_pkt_ext;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 208/602 wifi: mt76: mt7925: fix possible NULL-pointer deref in mt7925_mcu_bss_he_tlv()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 8d1b6738c1ab48c086b17e7994034aca94258931 ]
mt76_connac_get_he_phy_cap routine can theoretically return NULL so check cap pointer before dereferencing it.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +2 -0
@@ -2646,6 +2646,8 @@ mt7925_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_bss_conf *link_conf,struct tlv *tlv; cap =mt76_connac_get_he_phy_cap (phy->mt76, link_conf->vif); +if (!cap) +return ; tlv =mt76_connac_mcu_add_tlv (skb,UNI_BSS_INFO_HE_BASIC ,sizeof (*he));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 209/602 wifi: mt76: mt7996: check pointer returned by mt76_connac_get_he_phy_cap()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit e858cf6bf99880343348ff1e8c942aaff1d9d592 ]
mt76_connac_get_he_phy_cap routine can theoretically return NULL so check cap pointer before dereferencing it.
--- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +6 -3
@@ -798,6 +798,8 @@ mt7996_mcu_bss_he_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,struct tlv *tlv; cap =mt76_connac_get_he_phy_cap (phy->mt76, vif); +if (!cap) +return ; tlv =mt7996_mcu_add_uni_tlv (skb,UNI_BSS_INFO_HE_BASIC ,sizeof (*he));
@@ -1537,17 +1539,18 @@ mt7996_mcu_sta_bfer_he(struct ieee80211_sta *sta, struct ieee80211_vif *vif, {struct ieee80211_sta_he_cap *pc = &sta->deflink.he_cap;struct ieee80211_he_cap_elem *pe = &pc->he_cap_elem; -const struct ieee80211_sta_he_cap *vc = -mt76_connac_get_he_phy_cap (phy->mt76, vif); -const struct ieee80211_he_cap_elem *ve = &vc->he_cap_elem;u16 mcs_map =le16_to_cpu (pc->he_mcs_nss_supp.rx_mcs_80);u8 nss_mcs =mt7996_mcu_get_sta_nss (mcs_map); +const struct ieee80211_he_cap_elem *ve; +const struct ieee80211_sta_he_cap *vc;u8 snd_dim, sts; + vc =mt76_connac_get_he_phy_cap (phy->mt76, vif);if (!vc)return ; bf->tx_mode =MT_PHY_TYPE_HE_SU ; + ve = &vc->he_cap_elem;mt7996_mcu_sta_sounding_rate (bf);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 210/602 wifi: mt76: mt7925: fix crash in reset link replay
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Wang <[email protected]>
[ Upstream commit bd8b2ec838184236c3fcbf738a926328836adf12 ]
During reset recovery, mt7925_vif_connect_iter() replays firmware state for links tracked in mvif->valid_links. After MLO link changes or MCU timeout recovery, the driver bitmap can temporarily contain a link whose mac80211 bss_conf has already gone away.
This can pass a NULL bss_conf to mt76_connac_mcu_uni_add_dev(), matching the crash where x1, the second argument, is NULL:
pc : mt76_connac_mcu_uni_add_dev+0x8c/0x1f8 [mt76_connac_lib] lr : mt7925_vif_connect_iter+0x9c/0x168 [mt7925_common] x2 : ffffff80a77f6018 x1 : 0000000000000000 x0 : ffffff8099402080 Call trace: mt76_connac_mcu_uni_add_dev+0x8c/0x1f8 [mt76_connac_lib] mt7925_vif_connect_iter+0x9c/0x168 [mt7925_common] mt7925_mac_reset_work+0x264/0x2f8 [mt7925_common]
Skip missing bss_conf entries before replaying the link. Non-MLO AP/STA reset replay is unchanged because the helper still returns &vif->bss_conf for the legacy link.
--- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +3 -0
@@ -1285,6 +1285,9 @@ mt7925_vif_connect_iter(void *priv, u8 *mac,for_each_set_bit (i, &valid,IEEE80211_MLD_MAX_NUM_LINKS ) { bss_conf =mt792x_vif_to_bss_conf (vif, i); +if (!bss_conf) +continue ; + mconf =mt792x_vif_to_link (mvif, i); mt76_connac_mcu_uni_add_dev(&dev->mphy, bss_conf, &mconf->mt76,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 211/602 wifi: mt76: mt7996: fix possible NULL-pointer deref in mt7996_mcu_sta_bfer_eht()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 2fffc472bec490c8357defcee9c075ca74467352 ]
mt76_connac_get_eht_phy_cap routine can theoretically return NULL so check cap pointer before dereferencing it.
--- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +7 -3
@@ -1604,14 +1604,18 @@ mt7996_mcu_sta_bfer_eht(struct ieee80211_sta *sta, struct ieee80211_vif *vif,struct ieee80211_sta_eht_cap *pc = &sta->deflink.eht_cap;struct ieee80211_eht_cap_elem_fixed *pe = &pc->eht_cap_elem;struct ieee80211_eht_mcs_nss_supp *eht_nss = &pc->eht_mcs_nss_supp; -const struct ieee80211_sta_eht_cap *vc = -mt76_connac_get_eht_phy_cap (phy->mt76, vif); -const struct ieee80211_eht_cap_elem_fixed *ve = &vc->eht_cap_elem;u8 nss_mcs =u8_get_bits (eht_nss->bw._80.rx_tx_mcs9_max_nss,IEEE80211_EHT_MCS_NSS_RX ) -1 ; +const struct ieee80211_eht_cap_elem_fixed *ve; +const struct ieee80211_sta_eht_cap *vc;u8 snd_dim, sts; + vc =mt76_connac_get_eht_phy_cap (phy->mt76, vif); +if (!vc) +return ; + bf->tx_mode =MT_PHY_TYPE_EHT_MU ; + ve = &vc->eht_cap_elem;mt7996_mcu_sta_sounding_rate (bf);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 212/602 wifi: brcmfmac: fix 802.1X-SHA256 call trace warning
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shelley Yang <[email protected]>
[ Upstream commit 7cb34f6c4fe8a68af621d870abe63bfca2275dd6 ]
Based on wpa_auth as 1x_256 mode, need to set up "use_fwsup" with BRCMF_PROFILE_FWSUP_1X.
Or it will happen trace warning when call brcmf_cfg80211_set_pmk().
[ 4481.831101] ------------[ cut here ]------------ [ 4481.831102] WARNING: CPU: 1 PID: 2997 at drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:7242 brcmf_cfg80211_set_pmk+0x77/0xd0 [brcmfmac] [...] [ 4481.831202] Call Trace: [ 4481.831204] <TASK> [ 4481.831205] nl80211_set_pmk+0x183/0x250 [cfg80211] [ 4481.831233] genl_family_rcv_msg_doit+0xea/0x150 [ 4481.831237] genl_rcv_msg+0x104/0x240 [ 4481.831239] ? cfg80211_probe_status+0x2c0/0x2c0 [cfg80211] [ 4481.831257] ? genl_family_rcv_msg_doit+0x150/0x150 [ 4481.831259] netlink_rcv_skb+0x4e/0x100 [ 4481.831261] genl_rcv+0x24/0x40 [ 4481.831262] netlink_unicast+0x236/0x380 [ 4481.831264] netlink_sendmsg+0x250/0x4b0 [ 4481.831266] sock_sendmsg+0x5c/0x70 [ 4481.831269] ____sys_sendmsg+0x236/0x2b0 [ 4481.831271] ? copy_msghdr_from_user+0x6d/0xa0 [ 4481.831272] ___sys_sendmsg+0x86/0xd0 [ 4481.831274] ? avc_has_perm+0x8c/0x1a0 [ 4481.831276] ? preempt_count_add+0x6a/0xa0 [ 4481.831279] ? sock_has_perm+0x82/0xa0 [ 4481.831280] __sys_sendmsg+0x57/0xa0 [ 4481.831282] do_syscall_64+0x38/0x90 [ 4481.831284] entry_SYSCALL_64_after_hwframe+0x63/0xcd [ 4481.831286] RIP: 0033:0x7fd270d369b4
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +1 -1
@@ -2122,7 +2122,7 @@ brcmf_set_key_mgmt(struct net_device *ndev, struct cfg80211_connect_params *sme) sme->crypto.akm_suites[0]);return -EINVAL ; } - }else if (val & (WPA2_AUTH_PSK |WPA2_AUTH_UNSPECIFIED )) { + }else if (val & (WPA2_AUTH_PSK |WPA2_AUTH_UNSPECIFIED |WPA2_AUTH_1X_SHA256 )) {switch (sme->crypto.akm_suites[0 ]) {case WLAN_AKM_SUITE_8021X : val =WPA2_AUTH_UNSPECIFIED ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 213/602 ovl: fix trusted xattr escape prefix matching
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yichong Chen <[email protected]>
[ Upstream commit a8e72879cd0d8422c0b47d6d3c1802274fe73b98 ]
In the trusted.* xattr namespace, ovl_is_escaped_xattr() compares one byte less than the escaped overlay xattr prefix length. This makes it match "trusted.overlay.overlay" without requiring the trailing dot.
As a result, an xattr such as "trusted.overlay.overlayfoo" is incorrectly treated as an escaped overlay xattr. This can be reproduced by setting "trusted.overlay.overlayfoo" on a lower file and listing xattrs through an overlay mount. listxattr() then exposes it as "trusted.overlay.oo", and a following getxattr() on that listed name fails with ENODATA.
Compare the full escaped prefix, including the trailing dot, so similarly-prefixed private xattrs are not misclassified.
--- fs/overlayfs/xattrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/xattrs.c +1 -1
@@ -13,7 +13,7 @@ static bool ovl_is_escaped_xattr(struct super_block *sb, const char *name) OVL_XATTR_ESCAPE_USER_PREFIX_LEN) == 0; else return strncmp(name, OVL_XATTR_ESCAPE_TRUSTED_PREFIX, -OVL_XATTR_ESCAPE_TRUSTED_PREFIX_LEN -1 ) ==0 ; +OVL_XATTR_ESCAPE_TRUSTED_PREFIX_LEN ) ==0 ; }static bool ovl_is_own_xattr (struct super_block *sb,const char *name)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 214/602 amt: re-read skb header pointers after every pull
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 3656a79f94c471827a08f2cacce5f94ad5e52c24 ]
Several AMT receive and transmit paths cache a pointer into the skb head (ip_hdr(), ipv6_hdr(), eth_hdr() or the AMT message header) and then call a helper that can reallocate that head before the cached pointer is used again. pskb_may_pull(), ip_mc_may_pull(), ipv6_mc_may_pull(), iptunnel_pull_header(), ip_mc_check_igmp() and ipv6_mc_check_mld() can all free the old head and move the data, so a pointer taken before the call dangles afterwards and the later access is a use-after-free of the freed head.
The affected sites are:
amt_rcv() caches ip_hdr() before amt_parse_type() pulls, then reads iph->saddr.
amt_dev_xmit() caches ip_hdr()/ipv6_hdr() before ip_mc_check_igmp()/ ipv6_mc_check_mld() and pskb_may_pull(), then reads the group address.
amt_multicast_data_handler() caches eth_hdr() before pskb_may_pull(), then writes the L2 header.
amt_membership_query_handler() caches the AMT header, the outer and inner eth_hdr() and ip_hdr() before iptunnel_pull_header() and several pulls, then reads and writes them.
amt_igmpv3_report_handler() and amt_mldv2_report_handler() cache ip_hdr()/ipv6_hdr() and the current group record and read the record count from the report header inside the record loop, across the *_mc_may_pull() calls.
amt_update_handler() caches ip_hdr() and the AMT membership-update header before pskb_may_pull(), iptunnel_pull_header(), ip_mc_check_igmp() and the report handler, then reads iph->daddr and amtmu->nonce / amtmu->response_mac.
Fix each site by either snapshotting the scalar that is used after the pull before the first pull runs, or re-deriving the header pointer from the skb after the last pull that can move the head. Values that are stable across the pull (source and group address, the response MAC and nonce, the record count, the outer source MAC) are snapshotted; pointers that are written through or read repeatedly are re-derived.
--- drivers/net/amt.c | 79 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 24 deletions(-)
drivers/net/amt.c +55 -24
@@ -1206,7 +1206,7 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) data = true; } v6 = false; - group.ip4 = iph->daddr; + group.ip4 =ip_hdr (skb)->daddr;#if IS_ENABLED (CONFIG_IPV6 ) } else if (iph->version == 6) { ip6h =ipv6_hdr (skb);
@@ -1230,7 +1230,7 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) data = true; } v6 = true; - group.ip6 = ip6h->daddr; + group.ip6 =ipv6_hdr (skb)->daddr;#endif }else { dev->stats.tx_errors++;
@@ -1273,12 +1273,12 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)hlist_for_each_entry_rcu (gnode, &tunnel->groups[hash], node) {if (!v6) { -if (gnode->group_addr.ip4 == iph->daddr) +if (gnode->group_addr.ip4 == group.ip4) goto found;#if IS_ENABLED (CONFIG_IPV6 ) } else {if (ipv6_addr_equal (&gnode->group_addr.ip6, - &ip6h->daddr)) + &group.ip6)) goto found;#endif }
@@ -1995,14 +1995,18 @@ static void amt_igmpv3_report_handler(struct amt_dev *amt, struct sk_buff *skb,struct igmpv3_report *ihrv3 =igmpv3_report_hdr (skb);int len =skb_transport_offset (skb) +sizeof (*ihrv3);void *zero_grec = (void *)&igmpv3_zero_grec; -struct iphdr *iph =ip_hdr (skb);struct amt_group_node *gnode;union amt_addr group, host;struct igmpv3_grec *grec; +__be32 saddr;u16 nsrcs; +u16 ngrec;int i; -for (i =0 ; i <ntohs (ihrv3->ngrec); i++) { + saddr =ip_hdr (skb)->saddr; + ngrec =ntohs (ihrv3->ngrec); + +for (i =0 ; i < ngrec; i++) { len +=sizeof (*grec);if (!ip_mc_may_pull (skb, len))break ;
@@ -2014,10 +2018,13 @@ static void amt_igmpv3_report_handler(struct amt_dev *amt, struct sk_buff *skb,if (!ip_mc_may_pull (skb, len))break ; + grec = (void *)(skb->data + len -sizeof (*grec) - + nsrcs *sizeof (__be32)); +memset (&group,0 ,sizeof (union amt_addr )); group.ip4 = grec->grec_mca;memset (&host,0 ,sizeof (union amt_addr )); - host.ip4 = iph->saddr; + host.ip4 = saddr; gnode =amt_lookup_group (tunnel, &group, &host, false);if (!gnode) { gnode = amt_add_group(amt, tunnel, &group, &host,
@@ -2157,14 +2164,18 @@ static void amt_mldv2_report_handler(struct amt_dev *amt, struct sk_buff *skb,struct mld2_report *mld2r = (struct mld2_report *)icmp6_hdr (skb);int len =skb_transport_offset (skb) +sizeof (*mld2r);void *zero_grec = (void *)&mldv2_zero_grec; -struct ipv6hdr *ip6h =ipv6_hdr (skb);struct amt_group_node *gnode;union amt_addr group, host;struct mld2_grec *grec; +struct in6_addr saddr;u16 nsrcs; +u16 ngrec;int i; -for (i =0 ; i <ntohs (mld2r->mld2r_ngrec); i++) { + saddr =ipv6_hdr (skb)->saddr; + ngrec =ntohs (mld2r->mld2r_ngrec); + +for (i =0 ; i < ngrec; i++) { len +=sizeof (*grec);if (!ipv6_mc_may_pull (skb, len))break ;
@@ -2176,10 +2187,13 @@ static void amt_mldv2_report_handler(struct amt_dev *amt, struct sk_buff *skb,if (!ipv6_mc_may_pull (skb, len))break ; + grec = (void *)(skb->data + len -sizeof (*grec) - + nsrcs *sizeof (struct in6_addr )); +memset (&group,0 ,sizeof (union amt_addr )); group.ip6 = grec->grec_mca;memset (&host,0 ,sizeof (union amt_addr )); - host.ip6 = ip6h->saddr; + host.ip6 = saddr; gnode =amt_lookup_group (tunnel, &group, &host, true);if (!gnode) { gnode = amt_add_group(amt, tunnel, &group, &host,
@@ -2300,7 +2314,6 @@ static bool amt_multicast_data_handler(struct amt_dev *amt, struct sk_buff *skb)skb_push (skb,sizeof (*eth));skb_reset_mac_header (skb);skb_pull (skb,sizeof (*eth)); - eth =eth_hdr (skb);if (!pskb_may_pull (skb,sizeof (*iph)))return true;
@@ -2310,6 +2323,7 @@ static bool amt_multicast_data_handler(struct amt_dev *amt, struct sk_buff *skb)if (!ipv4_is_multicast (iph->daddr))return true; skb->protocol =htons (ETH_P_IP ); + eth =eth_hdr (skb); eth->h_proto =htons (ETH_P_IP );ip_eth_mc_map (iph->daddr, eth->h_dest);#if IS_ENABLED (CONFIG_IPV6 )
@@ -2323,6 +2337,7 @@ static bool amt_multicast_data_handler(struct amt_dev *amt, struct sk_buff *skb)if (!ipv6_addr_is_multicast (&ip6h->daddr))return true; skb->protocol =htons (ETH_P_IPV6 ); + eth =eth_hdr (skb); eth->h_proto =htons (ETH_P_IPV6 );ipv6_eth_mc_map (&ip6h->daddr, eth->h_dest);#endif
@@ -2346,10 +2361,12 @@ static bool amt_membership_query_handler(struct amt_dev *amt, struct sk_buff *skb) {struct amt_header_membership_query *amtmq; -struct igmpv3_query *ihv3;struct ethhdr *eth, *oeth; +struct igmpv3_query *ihv3; +u8 h_source[ETH_ALEN ];struct iphdr *iph;int hdr_size, len; +u64 response_mac; hdr_size =sizeof (*amtmq) +sizeof (struct udphdr );if (!pskb_may_pull (skb, hdr_size))
@@ -2362,6 +2379,8 @@ static bool amt_membership_query_handler(struct amt_dev *amt,if (amtmq->nonce != amt->nonce)return true; + response_mac = amtmq->response_mac; + hdr_size -=sizeof (*eth);if (iptunnel_pull_header (skb, hdr_size,htons (ETH_P_TEB ), false))return true;
@@ -2371,6 +2390,7 @@ static bool amt_membership_query_handler(struct amt_dev *amt,skb_pull (skb,sizeof (*eth));skb_reset_network_header (skb); eth =eth_hdr (skb); +ether_addr_copy (h_source, oeth->h_source);if (!pskb_may_pull (skb,sizeof (*iph)))return true;
@@ -2383,6 +2403,7 @@ static bool amt_membership_query_handler(struct amt_dev *amt, sizeof(*ihv3)))return true; + iph =ip_hdr (skb);if (!ipv4_is_multicast (iph->daddr))return true;
@@ -2390,10 +2411,11 @@ static bool amt_membership_query_handler(struct amt_dev *amt,skb_reset_transport_header (skb);skb_push (skb,sizeof (*iph) +AMT_IPHDR_OPTS );WRITE_ONCE (amt->ready4, true); - amt->mac = amtmq->response_mac; + amt->mac = response_mac; amt->req_cnt =0 ; amt->qi = ihv3->qqic; skb->protocol =htons (ETH_P_IP ); + eth =eth_hdr (skb); eth->h_proto =htons (ETH_P_IP );ip_eth_mc_map (iph->daddr, eth->h_dest);#if IS_ENABLED (CONFIG_IPV6 )
@@ -2416,10 +2438,11 @@ static bool amt_membership_query_handler(struct amt_dev *amt,skb_reset_transport_header (skb);skb_push (skb,sizeof (*ip6h) +AMT_IP6HDR_OPTS );WRITE_ONCE (amt->ready6, true); - amt->mac = amtmq->response_mac; + amt->mac = response_mac; amt->req_cnt =0 ; amt->qi = mld2q->mld2q_qqic; skb->protocol =htons (ETH_P_IPV6 ); + eth =eth_hdr (skb); eth->h_proto =htons (ETH_P_IPV6 );ipv6_eth_mc_map (&ip6h->daddr, eth->h_dest);#endif
@@ -2427,7 +2450,7 @@ static bool amt_membership_query_handler(struct amt_dev *amt,return true; } -ether_addr_copy (eth->h_source, oeth->h_source); +ether_addr_copy (eth->h_source, h_source); skb->pkt_type =PACKET_MULTICAST ; skb->ip_summed =CHECKSUM_NONE ; len = skb->len;
@@ -2450,8 +2473,11 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb)struct ethhdr *eth;struct iphdr *iph;int len, hdr_size; +u64 response_mac; +__be32 saddr; +__be32 nonce; - iph =ip_hdr (skb); + saddr =ip_hdr (skb)->saddr; hdr_size =sizeof (*amtmu) +sizeof (struct udphdr );if (!pskb_may_pull (skb, hdr_size))
@@ -2461,15 +2487,18 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb)if (amtmu->reserved || amtmu->version)return true; + nonce = amtmu->nonce; + response_mac = amtmu->response_mac; +if (iptunnel_pull_header (skb, hdr_size, skb->protocol, false))return true;skb_reset_network_header (skb);list_for_each_entry_rcu (tunnel, &amt->tunnel_list, list) { -if (tunnel->ip4 == iph->saddr) { -if ((amtmu->nonce == tunnel->nonce && - amtmu->response_mac == tunnel->mac)) { +if (tunnel->ip4 == saddr) { +if ((nonce == tunnel->nonce && + response_mac == tunnel->mac)) {mod_delayed_work (amt_wq, &tunnel->gc_wq,msecs_to_jiffies (amt_gmi (amt)) *3 );
@@ -2503,6 +2532,7 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb) eth =eth_hdr (skb); skb->protocol =htons (ETH_P_IP ); eth->h_proto =htons (ETH_P_IP ); + iph =ip_hdr (skb);ip_eth_mc_map (iph->daddr, eth->h_dest);#if IS_ENABLED (CONFIG_IPV6 ) } else if (iph->version == 6) {
@@ -2522,6 +2552,7 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb) eth =eth_hdr (skb); skb->protocol =htons (ETH_P_IPV6 ); eth->h_proto =htons (ETH_P_IPV6 ); + ip6h =ipv6_hdr (skb);ipv6_eth_mc_map (&ip6h->daddr, eth->h_dest);#endif }else {
@@ -2767,7 +2798,7 @@ static void amt_gw_rcv(struct amt_dev *amt, struct sk_buff *skb)static int amt_rcv (struct sock *sk,struct sk_buff *skb) {struct amt_dev *amt; -struct iphdr *iph; +__be32 saddr;int type;bool err;
@@ -2780,7 +2811,7 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) } skb->dev = amt->dev; - iph =ip_hdr (skb); + saddr =ip_hdr (skb)->saddr; type =amt_parse_type (skb);if (type ==-1 ) { err = true;
@@ -2790,7 +2821,7 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb)if (amt->mode ==AMT_MODE_GATEWAY ) {switch (type) {case AMT_MSG_ADVERTISEMENT : -if (iph->saddr != amt->discovery_ip) { +if (saddr != amt->discovery_ip) {netdev_dbg (amt->dev,"Invalid Relay IP\n" ); err = true; goto drop;
@@ -2802,7 +2833,7 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb) } goto out;case AMT_MSG_MULTICAST_DATA : -if (iph->saddr != amt->remote_ip) { +if (saddr != amt->remote_ip) {netdev_dbg (amt->dev,"Invalid Relay IP\n" ); err = true; goto drop;
@@ -2813,7 +2844,7 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb)else goto out;case AMT_MSG_MEMBERSHIP_QUERY : -if (iph->saddr != amt->remote_ip) { +if (saddr != amt->remote_ip) {netdev_dbg (amt->dev,"Invalid Relay IP\n" ); err = true; goto drop;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 215/602 amt: make the head writable before rewriting the L2 header
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 53969d704fa5b7c1751e277fac96bfc22b435eac ]
amt_multicast_data_handler(), amt_membership_query_handler() and amt_update_handler() rewrite the ethernet header of the decapsulated skb in place (eth->h_proto, eth->h_dest and, for the query, also eth->h_source) before handing it up the stack. The skb head may be shared, for example when a packet tap has cloned it on the underlay interface, so writing through it corrupts the other reader's copy.
Call skb_cow_head() before the rewrite so the head is private. It is placed before the pointers into the head are (re-)derived, so a reallocation caused by the copy is picked up by those derivations.
--- drivers/net/amt.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/amt.c +8 -0
@@ -2315,6 +2315,9 @@ static bool amt_multicast_data_handler(struct amt_dev *amt, struct sk_buff *skb)skb_reset_mac_header (skb);skb_pull (skb,sizeof (*eth)); +if (skb_cow_head (skb,0 )) +return true; +if (!pskb_may_pull (skb,sizeof (*iph)))return true; iph =ip_hdr (skb);
@@ -2391,6 +2394,8 @@ static bool amt_membership_query_handler(struct amt_dev *amt,skb_reset_network_header (skb); eth =eth_hdr (skb);ether_addr_copy (h_source, oeth->h_source); +if (skb_cow_head (skb,0 )) +return true;if (!pskb_may_pull (skb,sizeof (*iph)))return true;
@@ -2516,6 +2521,9 @@ static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb)if (!pskb_may_pull (skb,sizeof (*iph)))return true; +if (skb_cow_head (skb,0 )) +return true; + iph =ip_hdr (skb);if (iph->version ==4 ) {if (ip_mc_check_igmp (skb)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 216/602 net: bridge: vlan: fix vlan range dumps starting with pvid
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikolay Aleksandrov <[email protected]>
[ Upstream commit 43171c97e4714bf601b468401b37732244639c21 ]
There is a bug in all range dumps that rely on br_vlan_can_enter_range() when the PVID is a range starting VLAN, all following VLANs that match its flags can enter the range, but when the range is filled in only the PVID VLAN is dumped and the rest of the range is discarded because br_vlan_fill_vids() checks for the PVID flag. Since the PVID VLAN can be only one, we need to break ranges around it, the best way to do that consistently for all is to alter br_vlan_can_enter_range() to take into account the PVID and return false to break the range when it's matched.
Before the fix:
$ ip l add br0 type bridge vlan_filtering 1
$ ip l add dumdum type dummy
$ ip l set dumdum master br0
$ ip l set br0 up
$ ip l set dumdum up
$ bridge vlan add dev dumdum vid 1 pvid untagged master
$ bridge vlan add dev dumdum vid 2 untagged master
$ bridge vlan show dev dumdum # use legacy dump to show all vlans
port vlan-id
dumdum 1 PVID Egress Untagged
2 Egress Untagged$ bridge -d vlan show dev dumdum # use the new dump (RTM_GETVLAN)
port vlan-id
dumdum 1 PVID Egress Untagged
state forwarding mcast_router 1VLAN 2 is missing, and if there are more matching VLANs afterwards they'd be missing too.
After the fix:
[ same setup steps ]
$ bridge vlan show dev dumdum
port vlan-id
dumdum 1 PVID Egress Untagged
2 Egress Untagged
$ bridge -d vlan show dev dumdum # use the new dump (RTM_GETVLAN)
port vlan-id
dumdum 1 PVID Egress Untagged
state forwarding mcast_router 1
2 Egress Untagged
state forwarding mcast_router 1--- net/bridge/br_netlink_tunnel.c | 3 ++- net/bridge/br_private.h | 6 ++++-- net/bridge/br_vlan.c | 10 ++++++---- net/bridge/br_vlan_options.c | 3 +-- 4 files changed, 13 insertions(+), 9 deletions(-)
net/bridge/br_netlink_tunnel.c +2 -1
@@ -271,7 +271,8 @@ static void __vlan_tunnel_handle_range(const struct net_bridge_port *p,if (!*v_start) goto out_init; -if (v && curr_change &&br_vlan_can_enter_range (v, *v_end)) { +if (v && curr_change && +br_vlan_can_enter_range (v, *v_end,br_get_pvid (vg))) { *v_end = v;return ; }
net/bridge/br_private.h +4 -2
@@ -1587,7 +1587,8 @@ void br_vlan_notify(const struct net_bridge *br, u16 vid, u16 vid_range, int cmd);bool br_vlan_can_enter_range (const struct net_bridge_vlan *v_curr, -const struct net_bridge_vlan *range_end); +const struct net_bridge_vlan *range_end, +u16 pvid); void br_vlan_fill_forward_path_pvid(struct net_bridge *br, struct net_device_path_ctx *ctx,
@@ -1828,7 +1829,8 @@ static inline void br_vlan_notify(const struct net_bridge *br, }static inline bool br_vlan_can_enter_range (const struct net_bridge_vlan *v_curr, -const struct net_bridge_vlan *range_end) +const struct net_bridge_vlan *range_end, +u16 pvid) {return true; }
net/bridge/br_vlan.c +6 -4
@@ -1943,9 +1943,11 @@ void br_vlan_notify(const struct net_bridge *br,/* check if v_curr can enter a range ending in range_end */ bool br_vlan_can_enter_range (const struct net_bridge_vlan *v_curr, -const struct net_bridge_vlan *range_end) +const struct net_bridge_vlan *range_end, +u16 pvid) { -return v_curr->vid - range_end->vid ==1 && +return v_curr->vid != pvid && range_end->vid != pvid && + v_curr->vid - range_end->vid ==1 && range_end->flags == v_curr->flags &&br_vlan_opts_eq_range (v_curr, range_end); }
@@ -2027,8 +2029,8 @@ static int br_vlan_dump_dev(const struct net_device *dev, idx += range_end->vid - range_start->vid +1 ; range_start = v; - } else if (dump_stats || v->vid == pvid || - !br_vlan_can_enter_range(v, range_end)) { + } else if (dump_stats || + !br_vlan_can_enter_range(v, range_end, pvid)) { u16 vlan_flags = br_vlan_flags(range_start, pvid); if (!br_vlan_fill_vids(skb, range_start->vid,
net/bridge/br_vlan_options.c +1 -2
@@ -310,8 +310,7 @@ int br_vlan_process_options(const struct net_bridge *br,continue ; } -if (v->vid == pvid || - !br_vlan_can_enter_range (v, curr_end)) { +if (!br_vlan_can_enter_range (v, curr_end, pvid)) {br_vlan_notify (br, p, curr_start->vid, curr_end->vid,RTM_NEWVLAN ); curr_start = v;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 217/602 net: hsr: fix memory leak on slave unregistration by removing synced VLANs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit dcf15eaf5641812f1cfc5e96537380132a7da89d ]
When an HSR master device is brought UP, it auto-adds VLAN 0 via vlan_vid0_add(), which propagates VID 0 to its slave devices (slave A and B).
If a slave device is later unregistered while HSR is active (e.g., during netns cleanup or interface destruction), hsr_del_port() is called to detach the slave port from the HSR master. However, hsr_del_port() currently does not delete the VLAN IDs that were synced to the slave device by HSR.
As a result, the slave device retains a refcount on VID 0 (and any other synced VLANs). When the slave device is destroyed, its vlan_info / vlan_vid_info structure remains allocated, leading to a memory leak.
Fix this by calling vlan_vids_del_by_dev(port->dev, master->dev) in hsr_del_port() before unlinking slave A or slave B ports, matching the propagation logic in hsr_ndo_vlan_rx_add_vid() / hsr_ndo_vlan_rx_kill_vid() and the cleanup behavior in bonding and team drivers.
--- net/hsr/hsr_slave.c | 2 ++ 1 file changed, 2 insertions(+)
net/hsr/hsr_slave.c +2 -0
@@ -238,6 +238,8 @@ void hsr_del_port(struct hsr_port *port)netdev_rx_handler_unregister (port->dev);if (!port->hsr->fwd_offloaded)dev_set_promiscuity (port->dev,-1 ); +if (port->type ==HSR_PT_SLAVE_A || port->type ==HSR_PT_SLAVE_B ) +vlan_vids_del_by_dev (port->dev, master->dev);netdev_upper_dev_unlink (port->dev, master->dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 218/602 net: dpaa: fix mode setting
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Walle <[email protected]>
[ Upstream commit da2c6bcc5e30b1496ac587785dcacf6e849eb6ef ]
Before converting to the phylink interface, the init function would have set a non-reserved I/F mode in the maccfg2 register. After converting to phylink, 0 is written as mode, which is a reserved value (although it's the hardware default). Without a valid mode, a SGMII link is never established between the MAC and the PHY and thus .link_up() is never called which could set the correct mode according to the actual speed.
Fix it by setting the maximum speed of the phy_interface_t in use in .mac_config() - just like the driver did before the phylink conversion.
--- .../net/ethernet/freescale/fman/fman_dtsec.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/net/ethernet/freescale/fman/fman_dtsec.c +12 -5
@@ -900,22 +900,28 @@ static void dtsec_mac_config(struct phylink_config *config, unsigned int mode, {struct mac_device *mac_dev =fman_config_to_mac (config);struct dtsec_regs __iomem *regs = mac_dev->fman_mac->regs; -u32 tmp; +u32 ecntrl, maccfg2; + + maccfg2 =ioread32be (®s->maccfg2); + maccfg2 &= ~(MACCFG2_NIBBLE_MODE |MACCFG2_BYTE_MODE );switch (state->interface) {case PHY_INTERFACE_MODE_RMII : - tmp =DTSEC_ECNTRL_RMM ; + ecntrl =DTSEC_ECNTRL_RMM ; + maccfg2 |=MACCFG2_NIBBLE_MODE ;break ;case PHY_INTERFACE_MODE_RGMII :case PHY_INTERFACE_MODE_RGMII_ID :case PHY_INTERFACE_MODE_RGMII_RXID :case PHY_INTERFACE_MODE_RGMII_TXID : - tmp =DTSEC_ECNTRL_GMIIM |DTSEC_ECNTRL_RPM ; + ecntrl =DTSEC_ECNTRL_GMIIM |DTSEC_ECNTRL_RPM ; + maccfg2 |=MACCFG2_BYTE_MODE ;break ;case PHY_INTERFACE_MODE_SGMII :case PHY_INTERFACE_MODE_1000BASEX :case PHY_INTERFACE_MODE_2500BASEX : - tmp =DTSEC_ECNTRL_TBIM |DTSEC_ECNTRL_SGMIIM ; + ecntrl =DTSEC_ECNTRL_TBIM |DTSEC_ECNTRL_SGMIIM ; + maccfg2 |=MACCFG2_BYTE_MODE ;break ;default : dev_warn(mac_dev->dev, "cannot configure dTSEC for %s\n",
@@ -923,7 +929,8 @@ static void dtsec_mac_config(struct phylink_config *config, unsigned int mode,return ; } -iowrite32be (tmp, ®s->ecntrl); +iowrite32be (ecntrl, ®s->ecntrl); +iowrite32be (maccfg2, ®s->maccfg2); } static void dtsec_link_up(struct phylink_config *config, struct phy_device *phy,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 219/602 sctp: auth: verify auth requirement when auth_chunk is NULL
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qing Luo <[email protected]>
[ Upstream commit 8e04823c120b376ef7dab14b60ebf6823aa16c14 ]
sctp_auth_chunk_verify() returns true unconditionally when chunk->auth_chunk is NULL, silently skipping authentication. This is incorrect when:
1. skb_clone() failed in the BH receive path, leaving auth_chunk NULL. In sctp_endpoint_bh_rcv() asoc is NULL for new connections, so the early sctp_auth_recv_cid() check cannot catch this.
2. No AUTH chunk precedes COOKIE-ECHO, so skb_clone() is never called and auth_chunk remains NULL.
Fix by checking sctp_auth_recv_cid() when auth_chunk is NULL:
if authentication is required, return false to drop the chunk; otherwise continue normally.
--- net/sctp/sm_statefuns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/sm_statefuns.c +1 -1
@@ -641,7 +641,7 @@ static bool sctp_auth_chunk_verify(struct net *net, struct sctp_chunk *chunk,struct sctp_chunk auth;if (!chunk->auth_chunk) -return true; +return !sctp_auth_recv_cid (chunk->chunk_hdr->type, asoc);/* SCTP-AUTH: auth_chunk pointer is only set when the cookie-echo * is supposed to be authenticated and we have to do delayed
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 220/602 vmxnet3: fix BUG_ON in vmxnet3_get_hdr_len() for Geneve packets
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harshaka Narayana <[email protected]>
[ Upstream commit 34a71f5361fc3adb5b7138da78750b0d535a8252 ]
vmxnet3_get_hdr_len() assumes gdesc->rcd.v4/v6/tcp always describe the outer header, but for a Geneve-encapsulated packet the device can set them based on the inner header instead, signalled by the VMXNET3_RCD_HDR_INNER_SHIFT bit in the completion descriptor. Since the function never skips the outer encapsulation, this mismatch triggers:
- BUG_ON(hdr.ipv4->protocol != IPPROTO_TCP), because the outer protocol is UDP (Geneve), not TCP.
- BUG_ON(hdr.eth->h_proto != ...), when the tunnel's outer and inner IP versions differ (e.g. outer IPv6/inner IPv4 or vice versa).
Check VMXNET3_RCD_HDR_INNER_SHIFT up front and bail out, since the function cannot locate the inner header it would need to parse. Also convert the remaining BUG_ON()s in this function to return 0 defensively.
--- drivers/net/vmxnet3/vmxnet3_drv.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/net/vmxnet3/vmxnet3_drv.c +16 -6
@@ -1518,7 +1518,11 @@ vmxnet3_get_hdr_len(struct vmxnet3_adapter *adapter, struct sk_buff *skb,struct ipv6hdr *ipv6;struct tcphdr *tcp; } hdr; -BUG_ON (gdesc->rcd.tcp ==0 ); + +/* v4/v6/tcp then describe the inner header, which we can't locate. */ +if ((le32_to_cpu (gdesc->dword[0 ]) & (1UL <<VMXNET3_RCD_HDR_INNER_SHIFT )) || + gdesc->rcd.tcp ==0 ) +return 0 ; maplen =skb_headlen (skb);if (unlikely (sizeof (struct iphdr ) +sizeof (struct tcphdr ) > maplen))
@@ -1532,15 +1536,21 @@ vmxnet3_get_hdr_len(struct vmxnet3_adapter *adapter, struct sk_buff *skb, hdr.eth =eth_hdr (skb);if (gdesc->rcd.v4) { -BUG_ON (hdr.eth->h_proto !=htons (ETH_P_IP ) && - hdr.veth->h_vlan_encapsulated_proto !=htons (ETH_P_IP )); +if (hdr.eth->h_proto !=htons (ETH_P_IP ) && + hdr.veth->h_vlan_encapsulated_proto !=htons (ETH_P_IP )) +return 0 ; + hdr.ptr += hlen; -BUG_ON (hdr.ipv4->protocol !=IPPROTO_TCP ); +if (hdr.ipv4->protocol !=IPPROTO_TCP ) +return 0 ; + hlen = hdr.ipv4->ihl <<2 ; hdr.ptr += hdr.ipv4->ihl <<2 ; }else if (gdesc->rcd.v6) { -BUG_ON (hdr.eth->h_proto !=htons (ETH_P_IPV6 ) && - hdr.veth->h_vlan_encapsulated_proto !=htons (ETH_P_IPV6 )); +if (hdr.eth->h_proto !=htons (ETH_P_IPV6 ) && + hdr.veth->h_vlan_encapsulated_proto !=htons (ETH_P_IPV6 )) +return 0 ; + hdr.ptr += hlen;/* Use an estimated value, since we also need to handle * TSO case.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 221/602 iomap: correct the range of a partial dirty clear
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit 88c26515313169806a412a362b32a1eca53d21bd ]
The block range calculation in ifs_clear_range_dirty() is incorrect when partially clearing a range in a folio. We cannot clear the dirty bit of the first block or the last block if the start or end offset is not blocksize-aligned. This has not yet caused any issues since we always clear a whole folio in iomap_writeback_folio().
Fix this by rounding up the first block to blocksize alignment, and calculate the last block by rounding down (using truncation). Correct the nr_blks calculation accordingly.
--- fs/iomap/buffered-io.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/iomap/buffered-io.c +8 -4
@@ -137,13 +137,17 @@ static void ifs_clear_range_dirty(struct folio *folio, {struct inode *inode = folio->mapping->host;unsigned int blks_per_folio =i_blocks_per_folio (inode, folio); -unsigned int first_blk = (off >> inode->i_blkbits); -unsigned int last_blk = (off + len -1 ) >> inode->i_blkbits; -unsigned int nr_blks = last_blk - first_blk +1 ; +unsigned int first_blk =round_up (off,i_blocksize (inode)) >> + inode->i_blkbits; +unsigned int last_blk = (off + len) >> inode->i_blkbits;unsigned long flags; +if (first_blk >= last_blk) +return ; +spin_lock_irqsave (&ifs->state_lock, flags); -bitmap_clear (ifs->state, first_blk + blks_per_folio, nr_blks); +bitmap_clear (ifs->state, first_blk + blks_per_folio, + last_blk - first_blk);spin_unlock_irqrestore (&ifs->state_lock, flags); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 222/602 tipc: fix u16 MTU truncation in media and bearer MTU validation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang (Microsoft) <[email protected]>
[ Upstream commit 9f29cd8a8e7901a2617c8064ce9f50fc67b97cb8 ]
Both TIPC_NL_MEDIA_SET and TIPC_NL_BEARER_SET accept user-supplied MTU values but only enforce a minimum bound, not a maximum. When a user sets the MTU to a value exceeding U16_MAX (65535), it passes validation but is silently truncated when assigned to u16 fields l->mtu and l->advertised_mtu in tipc_link_create(). Values like 65536 (0x10000) truncate to 0, causing a division by zero in tipc_link_set_queue_limits() which computes TIPC_MAX_PUBL / (l->mtu / ITEM_SIZE). Other overflowing values (e.g. 65537-131071) produce small incorrect MTU values, resulting in link malfunction behaviors.
Crash stack (triggered as unprivileged user via user namespace):
tipc_link_set_queue_limits net/tipc/link.c:2531 tipc_link_create net/tipc/link.c:520 tipc_node_check_dest net/tipc/node.c:1279 tipc_disc_rcv net/tipc/discover.c:252 tipc_rcv net/tipc/node.c:2129 tipc_udp_recv net/tipc/udp_media.c:392
Two independent paths lack the upper bound check:
1. tipc_udp_mtu_bad() -- called from __tipc_nl_media_set() (MEDIA_SET)
2. inline check in __tipc_nl_bearer_set() at bearer.c:1160 (BEARER_SET)
Fix both by rejecting MTU values above U16_MAX.
--- net/tipc/netlink.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/tipc/netlink.c +5 -1
@@ -113,12 +113,16 @@ const struct nla_policy tipc_nl_node_policy[TIPC_NLA_NODE_MAX + 1] = { };/* Properties valid for media, bearer and link */ +static const struct netlink_range_validation tipc_nl_mtu_range = { + .max =U16_MAX , +}; +const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX +1 ] = { [TIPC_NLA_PROP_UNSPEC ] = { .type =NLA_UNSPEC }, [TIPC_NLA_PROP_PRIO ] = { .type =NLA_U32 }, [TIPC_NLA_PROP_TOL ] = { .type =NLA_U32 }, [TIPC_NLA_PROP_WIN ] = { .type =NLA_U32 }, - [TIPC_NLA_PROP_MTU ] = { .type =NLA_U32 }, + [TIPC_NLA_PROP_MTU ] =NLA_POLICY_FULL_RANGE (NLA_U32 , &tipc_nl_mtu_range), [TIPC_NLA_PROP_BROADCAST ] = { .type =NLA_U32 }, [TIPC_NLA_PROP_BROADCAST_RATIO ] = { .type =NLA_U32 } };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 223/602 drm/tests: shmem: Set DMA mask to 64-bit in drm_gem_shmem
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: José Expósito <[email protected]>
[ Upstream commit b04a248cfa6cfa1e7dc9ce91cb1eb88b1a70dd69 ]
drm_gem_shmem_test_purge [1] and drm_gem_shmem_test_get_pages_sgt [2] intermittently fail on ppc64le and s390x CI systems with a DMA address overflow:
DMA addr 0x0000000100307000+4096 overflow (mask ffffffff, bus limit 0)
WARNING: kernel/dma/direct.h:114 dma_direct_map_sg+0x778/0x920
drm_gem_shmem_test_purge: ASSERTION FAILED at
drivers/gpu/drm/tests/drm_gem_shmem_test.c:330 Expected sgt is not error, but is: -5
The call chain leading to the failure is:
drm_gem_shmem_test_purge() / drm_gem_shmem_test_get_pages_sgt()
drm_gem_shmem_get_pages_sgt()
drm_gem_shmem_get_pages_sgt_locked() [drm_gem_shmem_helper.c]
dma_map_sgtable() [mapping.c]
__dma_map_sg_attrs()
dma_direct_map_sg() [direct.c]
dma_direct_map_phys() [kernel/dma/direct.h]
dma_capable() Checks addr against DMA mask
-> FAILS: addr > 0xFFFFFFFFThe root cause is that KUnit devices are initialized with a 32-bit DMA mask (DMA_BIT_MASK(32)) in lib/kunit/device.c. On ppc64le and s390x systems with physical memory above 4GB, page allocations can land at addresses that exceed this mask. When drm_gem_shmem_get_pages_sgt() attempts to DMA-map these pages via dma_map_sgtable(), the DMA layer rejects the mapping because the physical address overflows the 32-bit mask.
The failure is intermittent because pages may or may not be allocated above 4GB on any given run depend on memory pressure.
Fix by setting a 64-bit DMA mask on the device before calling drm_gem_shmem_get_pages_sgt() for all tests, following the same pattern already used in drm_gem_shmem_test_obj_create_private().
[1] https://s3.amazonaws.com/arr-cki-prod-trusted-artifacts/trusted-artifacts/2643976103/test_s390x/15128551935/artifacts/jobwatch/logs/recipes/21561049/tasks/220716793/results/1014626315/logs/dmesg.log
[2] https://s3.amazonaws.com/arr-cki-prod-trusted-artifacts/trusted-artifacts/2643976103/test_ppc64le/15128551933/artifacts/jobwatch/logs/recipes/21561041/tasks/220716705/results/1014628163/logs/dmesg.log
--- drivers/gpu/drm/tests/drm_gem_shmem_test.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/tests/drm_gem_shmem_test.c +10 -6
@@ -90,13 +90,9 @@ static void drm_gem_shmem_test_obj_create_private(struct kunit *test)sg_init_one (sgt->sgl, buf,TEST_SIZE );/* -* Set the DMA mask to 64-bits and map the sgtables -* otherwise drm_gem_shmem_free will cause a warning -* on debug kernels. +* Map the sgtables otherwise drm_gem_shmem_free will cause a warning on +* debug kernels. */ - ret =dma_set_mask (drm_dev->dev,DMA_BIT_MASK (64 )); -KUNIT_ASSERT_EQ (test, ret,0 ); - ret =dma_map_sgtable (drm_dev->dev, sgt,DMA_BIDIRECTIONAL ,0 );KUNIT_ASSERT_EQ (test, ret,0 );
@@ -342,11 +338,19 @@ static int drm_gem_shmem_test_init(struct kunit *test) {struct device *dev;struct drm_device *drm_dev; +int ret;/* Allocate a parent device */ dev =drm_kunit_helper_alloc_device (test);KUNIT_ASSERT_NOT_ERR_OR_NULL (test, dev); +/* +* Set the DMA mask to 64-bits to avoid intermittent failures calling +* drm_gem_shmem_get_pages_sgt(). +*/ + ret =dma_set_mask (dev,DMA_BIT_MASK (64 )); +KUNIT_ASSERT_EQ (test, ret,0 ); +/* * The DRM core will automatically initialize the GEM core and create * a DRM Memory Manager object which provides an address space pool
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 224/602 net: stmmac: fix l3l4 filter rejecting unsupported offload requests
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nazim Amirul <[email protected]>
[ Upstream commit 5536d7c843637e9430279b94935fcf7df98babb3 ]
The basic flow parser in tc_add_basic_flow() does not validate match keys before proceeding. Unsupported offload configurations such as partial protocol masks, non-IPv4 network proto, or non-TCP/UDP transport proto are silently accepted instead of returning -EOPNOTSUPP.
Add validation to return -EOPNOTSUPP early for:
- No network or transport proto present in the key
- Partial protocol mask (only full mask supported)
- Network proto is not IPv4
- Transport proto is not TCP or UDP
Each rejection includes an extack message so the user knows which part of the match is unsupported.
Also propagate -EOPNOTSUPP from tc_add_basic_flow() in tc_add_flow() by returning it directly rather than using break. The break was silently discarding the error for FLOW_CLS_REPLACE operations where entry->in_use is already true, causing tc_add_flow() to return 0 (success) for unsupported replace requests.
--- .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +34 -0
@@ -446,6 +446,7 @@ static int tc_parse_flow_actions(struct stmmac_priv *priv, }#define ETHER_TYPE_FULL_MASK cpu_to_be16(~0) +#define IP_PROTO_FULL_MASK 0xFF static int tc_add_basic_flow(struct stmmac_priv *priv, struct flow_cls_offload *cls,
@@ -461,6 +462,37 @@ static int tc_add_basic_flow(struct stmmac_priv *priv,flow_rule_match_basic (rule, &match); +/* Both network proto and transport proto not present in the key */ +if (!match.mask || !(match.mask->n_proto || match.mask->ip_proto)) { +NL_SET_ERR_MSG_MOD (cls->common.extack, +"filter must specify network or transport protocol" ); +return -EOPNOTSUPP ; + } + +/* If the proto is present in the key and is not full mask */ +if ((match.mask->n_proto && match.mask->n_proto !=ETHER_TYPE_FULL_MASK ) || + (match.mask->ip_proto && match.mask->ip_proto !=IP_PROTO_FULL_MASK )) { +NL_SET_ERR_MSG_MOD (cls->common.extack, +"only full protocol mask is supported" ); +return -EOPNOTSUPP ; + } + +/* Network proto is present in the key and is not IPv4 */ +if (match.mask->n_proto && match.key->n_proto !=cpu_to_be16 (ETH_P_IP )) { +NL_SET_ERR_MSG_MOD (cls->common.extack, +"only IPv4 network protocol is supported" ); +return -EOPNOTSUPP ; + } + +/* Transport proto is present in the key and is not TCP or UDP */ +if (match.mask->ip_proto && + match.key->ip_proto !=IPPROTO_TCP && + match.key->ip_proto !=IPPROTO_UDP ) { +NL_SET_ERR_MSG_MOD (cls->common.extack, +"only TCP and UDP transport protocols are supported" ); +return -EOPNOTSUPP ; + } + entry->ip_proto = match.key->ip_proto;return 0 ; }
@@ -598,6 +630,8 @@ static int tc_add_flow(struct stmmac_priv *priv, ret = tc_flow_parsers[i].fn (priv, cls, entry);if (!ret) entry->in_use = true; +else if (ret == -EOPNOTSUPP ) +return ret; }if (!entry->in_use)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 225/602 net: stmmac: reset residual action in L3L4 filters on delete
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nazim Amirul <[email protected]>
[ Upstream commit a448f821289934b961dd9d8d0beb006cc8937ba2 ]
When deleting an L3/L4 flower filter entry, the action field is not reset. If a filter was previously configured with a drop action, that action may persist and affect subsequent filter configurations unintentionally.
Clear the action field when the filter entry is deleted.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +1 -0
@@ -661,6 +661,7 @@ static int tc_del_flow(struct stmmac_priv *priv, entry->in_use = false; entry->cookie =0 ; entry->is_l4 = false; + entry->action =0 ;return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 226/602 net: stmmac: enable the MAC on link up for all supported speeds
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: vadik likholetov <[email protected]>
[ Upstream commit 9c99db3a2080b8c2cbbb1100369586a9bea43321 ]
stmmac_mac_link_down() clears the MAC's transmit and receive enable bits. stmmac_mac_link_up() is expected to set them again through stmmac_mac_set(..., true), but it first switches on the negotiated speed and returns early for a speed the switch does not list. The MAC is then left gated off.
The speed selection is split into three switches, keyed on the interface. The generic branch -- taken for everything that is neither USXGMII nor XLGMII, so including PHY_INTERFACE_MODE_10GBASER -- lists only SPEED_2500, SPEED_1000, SPEED_100 and SPEED_10.
MGBE on Tegra234 runs 10GBASE-R into an Aquantia AQR113C. That PHY does rate matching, so phylink_link_up() replaces the media speed with the MAC-side interface speed before calling into the MAC:
case RATE_MATCH_PAUSE: speed = phylink_interface_max_speed(link_state.interface); duplex = DUPLEX_FULL;
The driver is therefore called as
stmmac_mac_link_up(interface=10GBASER, speed=10000, duplex=1)
which falls through to "default: return;". The interface stops passing traffic after the first link flap.
The failure is easy to misread. The link still comes up, because the PHY is polled over MDIO and needs no MAC, so the interface reports carrier 1 at the media speed. The DMA is untouched, so its start bits stay set and descriptors are still consumed. Only the MAC itself is gated off: the receiver counts nothing (mmc_rx_framecount_gb stops advancing, RE is 0) and nothing reaches the wire (TE is 0). The interface survives boot only because stmmac_hw_setup(), called from ndo_open, enables the MAC unconditionally -- so the problem appears only once the cable has been unplugged and plugged back in, and "ip link set dev <ethX> down && ip link set dev <ethX> up" appears to fix it.
The interface is not what the speed bits depend on: with the single exception of 2.5G, which is selected through the XGMII block on USXGMII and through the regular speed bits otherwise, each speed maps to one field of struct mac_link. The per-interface switches are speed validation, and phylink already validates the speed against priv->hw->link.caps. So collapse the three switches into one keyed on the speed alone, keeping the interface test only for the 2.5G case. This covers 10G on 10GBASE-R, and equally 5G, and 1G/100/10 on USXGMII, all of which hit "default: return;" today.
A core that does not support a speed leaves the corresponding mac_link field at 0, and phylink will not offer it that speed in the first place. For dwxgmac2 at 10G, link.xgmii.speed10000 is XGMAC_CONFIG_SS_10000, which is 0 and is the correct speed selection for a 10GBASE-R MAC: ctrl then equals old_ctrl, the register write is skipped, and execution reaches stmmac_mac_set(..., true).
Log an error in the default case, since a speed with no entry here leaves the MAC disabled and the symptom does not point at the cause.
--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 92 ++++++++----------- 1 file changed, 37 insertions(+), 55 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +37 -55
@@ -1032,63 +1032,45 @@ static void stmmac_mac_link_up(struct phylink_config *config, old_ctrl =readl (priv->ioaddr +MAC_CTRL_REG ); ctrl = old_ctrl & ~priv->hw->link.speed_mask; -if (interface ==PHY_INTERFACE_MODE_USXGMII ) { -switch (speed) { -case SPEED_10000 : - ctrl |= priv->hw->link.xgmii.speed10000; -break ; -case SPEED_5000 : - ctrl |= priv->hw->link.xgmii.speed5000; -break ; -case SPEED_2500 : +switch (speed) { +case SPEED_100000 : + ctrl |= priv->hw->link.xlgmii.speed100000; +break ; +case SPEED_50000 : + ctrl |= priv->hw->link.xlgmii.speed50000; +break ; +case SPEED_40000 : + ctrl |= priv->hw->link.xlgmii.speed40000; +break ; +case SPEED_25000 : + ctrl |= priv->hw->link.xlgmii.speed25000; +break ; +case SPEED_10000 : + ctrl |= priv->hw->link.xgmii.speed10000; +break ; +case SPEED_5000 : + ctrl |= priv->hw->link.xgmii.speed5000; +break ; +case SPEED_2500 : +if (interface ==PHY_INTERFACE_MODE_USXGMII ) ctrl |= priv->hw->link.xgmii.speed2500; -break ; -default : -return ; - } - }else if (interface ==PHY_INTERFACE_MODE_XLGMII ) { -switch (speed) { -case SPEED_100000 : - ctrl |= priv->hw->link.xlgmii.speed100000; -break ; -case SPEED_50000 : - ctrl |= priv->hw->link.xlgmii.speed50000; -break ; -case SPEED_40000 : - ctrl |= priv->hw->link.xlgmii.speed40000; -break ; -case SPEED_25000 : - ctrl |= priv->hw->link.xlgmii.speed25000; -break ; -case SPEED_10000 : - ctrl |= priv->hw->link.xgmii.speed10000; -break ; -case SPEED_2500 : - ctrl |= priv->hw->link.speed2500; -break ; -case SPEED_1000 : - ctrl |= priv->hw->link.speed1000; -break ; -default : -return ; - } - }else { -switch (speed) { -case SPEED_2500 : +else ctrl |= priv->hw->link.speed2500; -break ; -case SPEED_1000 : - ctrl |= priv->hw->link.speed1000; -break ; -case SPEED_100 : - ctrl |= priv->hw->link.speed100; -break ; -case SPEED_10 : - ctrl |= priv->hw->link.speed10; -break ; -default : -return ; - } +break ; +case SPEED_1000 : + ctrl |= priv->hw->link.speed1000; +break ; +case SPEED_100 : + ctrl |= priv->hw->link.speed100; +break ; +case SPEED_10 : + ctrl |= priv->hw->link.speed10; +break ; +default : +netdev_err (priv->dev, +"unsupported speed %s on %s, leaving the MAC disabled\n" , +phy_speed_to_str (speed),phy_modes (interface)); +return ; } priv->speed = speed;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 227/602 net: gre: fix lltx regression for GRE tunnels with SEQ/CSUM
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yun Zhou <[email protected]>
[ Upstream commit 675ed582c1aa4d919dd535490de08c015005c653 ]
Before commit 00d066a4d4ed ("netdev_features: convert NETIF_F_LLTX to dev->lltx"), NETIF_F_LLTX was set unconditionally in both __gre_tunnel_init() and ip6gre_tnl_init_features() alongside GRE_FEATURES:
dev->features |= GRE_FEATURES | NETIF_F_LLTX;
When that commit converted NETIF_F_LLTX to the dev->lltx flag, it placed 'dev->lltx = true' after the SEQ/CSUM early returns instead of before them. This causes GRE/GRETAP/ip6gre tunnels with SEQ or CSUM+encap to lose lockless TX, reintroducing _xmit_lock acquisition around their ndo_start_xmit. Since GRE xmit re-enters the stack via ip_tunnel_xmit(), holding _xmit_lock risks ABBA deadlock with the underlay device.
CPU0 CPU1
---- ----
lock(&qdisc_xmit_lock_key#6);
lock(&qdisc_xmit_lock_key#3);
lock(&qdisc_xmit_lock_key#6);
lock(&qdisc_xmit_lock_key#3);Fix by moving dev->lltx = true before the early returns in both functions, restoring the original unconditional behavior.
--- net/ipv4/ip_gre.c | 4 ++-- net/ipv6/ip6_gre.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
net/ipv4/ip_gre.c +2 -2
@@ -1012,6 +1012,8 @@ static void __gre_tunnel_init(struct net_device *dev) dev->features |=GRE_FEATURES ; dev->hw_features |=GRE_FEATURES ; + dev->lltx = true; +/* TCP offload with GRE SEQ is not supported, nor can we support 2 * levels of outer headers requiring an update. */
@@ -1023,8 +1025,6 @@ static void __gre_tunnel_init(struct net_device *dev) dev->features |=NETIF_F_GSO_SOFTWARE ; dev->hw_features |=NETIF_F_GSO_SOFTWARE ; - - dev->lltx = true; }static int ipgre_tunnel_init (struct net_device *dev)
net/ipv6/ip6_gre.c +2 -2
@@ -1483,6 +1483,8 @@ static void ip6gre_tnl_init_features(struct net_device *dev) dev->features |=GRE6_FEATURES ; dev->hw_features |=GRE6_FEATURES ; + dev->lltx = true; +/* TCP offload with GRE SEQ is not supported, nor can we support 2 * levels of outer headers requiring an update. */
@@ -1494,8 +1496,6 @@ static void ip6gre_tnl_init_features(struct net_device *dev) dev->features |=NETIF_F_GSO_SOFTWARE ; dev->hw_features |=NETIF_F_GSO_SOFTWARE ; - - dev->lltx = true; }static int ip6gre_tunnel_init_common (struct net_device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 228/602 octeontx2-vf: set TC flower flag on MCAM entry allocation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Ghosh <[email protected]>
[ Upstream commit 0d4d31e3cc5dd6204fa1495c4107f5075acce5ed ]
When MCAM entries are allocated for a VF netdev via the devlink mcam_count parameter, only OTX2_FLAG_NTUPLE_SUPPORT was set. That enabled ethtool ntuple filters but not tc flower offload. Also set OTX2_FLAG_TC_FLOWER_SUPPORT when entries are successfully allocated.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +1 -0
@@ -151,6 +151,7 @@ int otx2_alloc_mcam_entries(struct otx2_nic *pfvf, u16 count)if (allocated) { pfvf->flags |=OTX2_FLAG_MCAM_ENTRIES_ALLOC ; pfvf->flags |=OTX2_FLAG_NTUPLE_SUPPORT ; + pfvf->flags |=OTX2_FLAG_TC_FLOWER_SUPPORT ; }if (allocated != count)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 229/602 ipv4: icmp: fill flow parameters in icmp_route_lookup decoy lookup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 853e164c2b321f0711361bc23505aaeb7dc432c3 ]
When Linux forwards a packet and needs to generate an ICMP error, icmp_route_lookup() performs a reverse-path relookup. For non-local destinations, it performs a decoy lookup to find the expected egress interface (rt2->dst.dev) before validating the path with ip_route_input().
Currently, the decoy flow structure (fl4_2) only sets .daddr = fl4_dec.saddr, leaving .saddr, .flowi4_dscp, .flowi4_proto, .flowi4_mark, .flowi4_oif, .fl4_sport, .fl4_dport, and .flowi4_uid zeroed out.
When policy routing rules (such as ip rule add from $SRC lookup 100, or dscp/fwmark/ipproto/port rules, or VRF bindings) are configured:
1. The decoy lookup fails to match the policy rule because saddr and other key flow selectors are missing in fl4_2.
2. It resolves a route using the default table instead, returning an incorrect egress netdev.
3. Passing the wrong netdev to ip_route_input() causes strict reverse-path filtering (rp_filter=1) to fail, logging false-positive "martian source" warnings and causing the relookup to fail.
Fix this by initializing fl4_2 from fl4_dec and:
- Swapping source/destination IP addresses.
- Swapping L4 ports for transport protocols with ports (TCP, UDP, SCTP, DCCP) so port-based policy routing matches correctly. Non-port protocols (such as ICMP or GRE) leave the flowi_uli union fields intact to prevent corruption.
- Setting .flowi4_oif = l3mdev_master_ifindex(route_lookup_dev) to ensure VRF routing tables are respected.
- Setting .flowi4_flags |= FLOWI_FLAG_ANYSRC to allow output route lookups for non-local source IP addresses.
- Using __ip_route_output_key() instead of ip_route_output_key() for fl4_2 so that raw FIB routing is used without triggering spurious XFRM policy lookups on the decoy flow (the actual XFRM lookup is performed later using fl4_dec).
--- net/ipv4/icmp.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
net/ipv4/icmp.c +15 -3
@@ -540,11 +540,23 @@ static struct rtable *icmp_route_lookup(struct net *net, struct flowi4 *fl4,if (IS_ERR (rt2)) err =PTR_ERR (rt2); }else { -struct flowi4 fl4_2 = {}; +struct flowi4 fl4_2 = fl4_dec;unsigned long orefdst; - fl4_2.daddr = fl4_dec.saddr; - rt2 =ip_route_output_key (net, &fl4_2); +swap (fl4_2.daddr, fl4_2.saddr); +switch (fl4_2.flowi4_proto) { +case IPPROTO_TCP : +case IPPROTO_UDP : +case IPPROTO_SCTP : +case IPPROTO_DCCP : +swap (fl4_2.fl4_sport, fl4_2.fl4_dport); +break ; + } + + fl4_2.flowi4_oif =l3mdev_master_ifindex (route_lookup_dev); + fl4_2.flowi4_flags |=FLOWI_FLAG_ANYSRC ; + + rt2 =__ip_route_output_key (net, &fl4_2);if (IS_ERR (rt2)) { err =PTR_ERR (rt2); goto relookup_failed;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 230/602 ppp: use IFF_NO_QUEUE in virtual interfaces
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 95d0d094ba26432ec467e2260f4bf553053f1f8f ]
For PPPoE, PPTP, and PPPoL2TP, the start_xmit() function directly forwards packets to the underlying network stack and never returns anything other than 1. So these interfaces do not require a qdisc, and the IFF_NO_QUEUE flag should be set.
Introduces a direct_xmit flag in struct ppp_channel to indicate when IFF_NO_QUEUE should be applied. The flag is set in ppp_connect_channel() for relevant protocols.
While at it, remove the usused latency member from struct ppp_channel.
Stable-dep-of: 543adf072165 ("ppp: annotate data races in ppp_generic")
--- drivers/net/ppp/ppp_generic.c | 4 ++++ drivers/net/ppp/pppoe.c | 1 + drivers/net/ppp/pptp.c | 1 + include/linux/ppp_channel.h | 3 +-- net/l2tp/l2tp_ppp.c | 1 + 5 files changed, 8 insertions(+), 2 deletions(-)
drivers/net/ppp/ppp_generic.c +4 -0
@@ -3508,6 +3508,10 @@ ppp_connect_channel(struct channel *pch, int unit) ret = -ENOTCONN ; goto outl; } +if (pch->chan->direct_xmit) + ppp->dev->priv_flags |=IFF_NO_QUEUE ; +else + ppp->dev->priv_flags &= ~IFF_NO_QUEUE ;spin_unlock_bh (&pch->downl);if (pch->file.hdrlen > ppp->file.hdrlen) ppp->file.hdrlen = pch->file.hdrlen;
drivers/net/ppp/pppoe.c +1 -0
@@ -699,6 +699,7 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, po->chan.mtu = dev->mtu -sizeof (struct pppoe_hdr ) -2 ; po->chan.private = sk; po->chan.ops = &pppoe_chan_ops; + po->chan.direct_xmit = true; error =ppp_register_net_channel (dev_net (dev), &po->chan);if (error) {
drivers/net/ppp/pptp.c +1 -0
@@ -469,6 +469,7 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr, po->chan.mtu -=PPTP_HEADER_OVERHEAD ; po->chan.hdrlen =2 +sizeof (struct pptp_gre_header ); + po->chan.direct_xmit = true; error =ppp_register_channel (&po->chan);if (error) {pr_err ("PPTP: failed to register PPP channel (%d)\n" , error);
include/linux/ppp_channel.h +1 -2
@@ -42,8 +42,7 @@ struct ppp_channel {int hdrlen;/* amount of headroom channel needs */ void *ppp;/* opaque to channel */ int speed;/* transfer rate (bytes/second) */ -/* the following is not used at present */ -int latency;/* overhead time in milliseconds */ +bool direct_xmit;/* no qdisc, xmit directly */ };#ifdef __KERNEL__
net/l2tp/l2tp_ppp.c +1 -0
@@ -796,6 +796,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, po->chan.private = sk; po->chan.ops = &pppol2tp_chan_ops; po->chan.mtu =pppol2tp_tunnel_mtu (tunnel); + po->chan.direct_xmit = true; error =ppp_register_net_channel (sock_net (sk), &po->chan);if (error) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 231/602 ppp: convert to percpu netstats
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 1a3e9b7a6b09e8ab3d2af019e4a392622685855e ]
Convert to percpu netstats to avoid lock contention when reading them.
Stable-dep-of: 543adf072165 ("ppp: annotate data races in ppp_generic")
--- drivers/net/ppp/ppp_generic.c | 52 +++++++++++++---------------------- 1 file changed, 19 insertions(+), 33 deletions(-)
drivers/net/ppp/ppp_generic.c +19 -33
@@ -107,18 +107,6 @@ struct ppp_file {#define PF_TO_PPP (pf) PF_TO_X(pf, struct ppp)#define PF_TO_CHANNEL (pf) PF_TO_X(pf, struct channel) -/* -* Data structure to hold primary network stats for which -* we want to use 64 bit storage. Other network stats -* are stored in dev->stats of the ppp strucute. -*/ -struct ppp_link_stats { -u64 rx_packets; -u64 tx_packets; -u64 rx_bytes; -u64 tx_bytes; -}; -/* * Data structure describing one ppp unit. * A ppp unit corresponds to a ppp network interface device
@@ -162,7 +150,6 @@ struct ppp {struct bpf_prog *active_filter;/* filter for pkts to reset idle */ #endif /* CONFIG_PPP_FILTER */ struct net *ppp_net;/* the net we belong to */ -struct ppp_link_stats stats64;/* 64 bit network stats */ };/*
@@ -1545,23 +1532,12 @@ ppp_net_siocdevprivate(struct net_device *dev, struct ifreq *ifr,static void ppp_get_stats64 (struct net_device *dev,struct rtnl_link_stats64 *stats64) { -struct ppp *ppp =netdev_priv (dev); - -ppp_recv_lock (ppp); - stats64->rx_packets = ppp->stats64.rx_packets; - stats64->rx_bytes = ppp->stats64.rx_bytes; -ppp_recv_unlock (ppp); - -ppp_xmit_lock (ppp); - stats64->tx_packets = ppp->stats64.tx_packets; - stats64->tx_bytes = ppp->stats64.tx_bytes; -ppp_xmit_unlock (ppp); - stats64->rx_errors = dev->stats.rx_errors; stats64->tx_errors = dev->stats.tx_errors; stats64->rx_dropped = dev->stats.rx_dropped; stats64->tx_dropped = dev->stats.tx_dropped; stats64->rx_length_errors = dev->stats.rx_length_errors; +dev_fetch_sw_netstats (stats64, dev->tstats); }static int ppp_dev_init (struct net_device *dev)
@@ -1659,6 +1635,7 @@ static void ppp_setup(struct net_device *dev) dev->type =ARPHRD_PPP ; dev->flags =IFF_POINTOPOINT |IFF_NOARP |IFF_MULTICAST ; dev->priv_destructor = ppp_dev_priv_destructor; + dev->pcpu_stat_type =NETDEV_PCPU_STAT_TSTATS ;netif_keep_dst (dev); }
@@ -1804,8 +1781,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)#endif /* CONFIG_PPP_FILTER */ } - ++ppp->stats64.tx_packets; - ppp->stats64.tx_bytes += skb->len -PPP_PROTO_LEN ; +dev_sw_netstats_tx_add (ppp->dev,1 , skb->len -PPP_PROTO_LEN );switch (proto) {case PPP_IP :
@@ -2483,8 +2459,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)break ; } - ++ppp->stats64.rx_packets; - ppp->stats64.rx_bytes += skb->len -2 ; +dev_sw_netstats_rx_add (ppp->dev, skb->len -PPP_PROTO_LEN ); npi =proto_to_npindex (proto);if (npi <0 ) {
@@ -3312,14 +3287,25 @@ static void ppp_get_stats(struct ppp *ppp, struct ppp_stats *st) { struct slcompress *vj = ppp->vj; +int cpu;memset (st,0 ,sizeof (*st)); - st->p.ppp_ipackets = ppp->stats64.rx_packets; +for_each_possible_cpu (cpu) { +struct pcpu_sw_netstats *p =per_cpu_ptr (ppp->dev->tstats, cpu); +u64 rx_packets, rx_bytes, tx_packets, tx_bytes; + + rx_packets =u64_stats_read (&p->rx_packets); + rx_bytes =u64_stats_read (&p->rx_bytes); + tx_packets =u64_stats_read (&p->tx_packets); + tx_bytes =u64_stats_read (&p->tx_bytes); + + st->p.ppp_ipackets += rx_packets; + st->p.ppp_ibytes += rx_bytes; + st->p.ppp_opackets += tx_packets; + st->p.ppp_obytes += tx_bytes; + } st->p.ppp_ierrors = ppp->dev->stats.rx_errors; - st->p.ppp_ibytes = ppp->stats64.rx_bytes; - st->p.ppp_opackets = ppp->stats64.tx_packets; st->p.ppp_oerrors = ppp->dev->stats.tx_errors; - st->p.ppp_obytes = ppp->stats64.tx_bytes;if (!vj)return ; st->vj.vjs_packets = vj->sls_o_compressed + vj->sls_o_uncompressed;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 232/602 ppp: enable TX scatter-gather
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 42fcb213e58a7da33d5d2d7517b4e521025c68c3 ]
PPP channels using chan->direct_xmit prepend the PPP header to a skb and call dev_queue_xmit() directly. In this mode the skb does not need to be linear, but the PPP netdevice currently does not advertise scatter-gather features, causing unnecessary linearization and preventing GSO.
Enable NETIF_F_SG and NETIF_F_FRAGLIST on PPP devices. In case a linear buffer is required (PPP compression, multilink, and channels without direct_xmit), call skb_linearize() explicitly.
Stable-dep-of: 543adf072165 ("ppp: annotate data races in ppp_generic")
--- drivers/net/ppp/ppp_generic.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
drivers/net/ppp/ppp_generic.c +25 -5
@@ -1636,6 +1636,8 @@ static void ppp_setup(struct net_device *dev) dev->flags =IFF_POINTOPOINT |IFF_NOARP |IFF_MULTICAST ; dev->priv_destructor = ppp_dev_priv_destructor; dev->pcpu_stat_type =NETDEV_PCPU_STAT_TSTATS ; + dev->features =NETIF_F_SG |NETIF_F_FRAGLIST ; + dev->hw_features = dev->features;netif_keep_dst (dev); }
@@ -1700,6 +1702,10 @@ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb) ppp->xcomp->comp_extra + ppp->dev->hard_header_len;int compressor_skb_size = ppp->dev->mtu + ppp->xcomp->comp_extra +PPP_HDRLEN ; + +if (skb_linearize (skb)) +return NULL ; + new_skb =alloc_skb (new_skb_size,GFP_ATOMIC );if (!new_skb) {if (net_ratelimit ())
@@ -1787,6 +1793,10 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)case PPP_IP :if (!ppp->vj || (ppp->flags &SC_COMP_TCP ) ==0 )break ; + +if (skb_linearize (skb)) + goto drop; +/* try to do VJ TCP header compression */ new_skb =alloc_skb (skb->len + ppp->dev->hard_header_len -2 ,GFP_ATOMIC );
@@ -1884,19 +1894,26 @@ ppp_push(struct ppp *ppp) }if ((ppp->flags &SC_MULTILINK ) ==0 ) { +struct ppp_channel *chan;/* not doing multilink: send it down the first channel */ list = list->next; pch = list_entry(list, struct channel, clist);spin_lock (&pch->downl); -if (pch->chan) { -if (pch->chan->ops->start_xmit (pch->chan, skb)) - ppp->xmit_pending =NULL ; - }else { -/* channel got unregistered */ + chan = pch->chan; +if (unlikely (!chan || (!chan->direct_xmit &&skb_linearize (skb)))) { +/* channel got unregistered, or it requires a linear +* skb but linearization failed +*/ kfree_skb (skb); ppp->xmit_pending =NULL ; + goto out; } + +if (chan->ops->start_xmit (chan, skb)) + ppp->xmit_pending =NULL ; + +out:spin_unlock (&pch->downl);return ; }
@@ -1981,6 +1998,8 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)return 0 ;/* can't take now, leave it in xmit_pending */ /* Do protocol field compression */ +if (skb_linearize (skb)) + goto err_linearize; p = skb->data; len = skb->len;if (*p ==0 && mp_protocol_compress) {
@@ -2139,6 +2158,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb) noskb:spin_unlock (&pch->downl); + err_linearize:if (ppp->debug &1 )netdev_err (ppp->dev,"PPP: no memory (fragment)\n" ); ++ppp->dev->stats.tx_errors;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 233/602 ppp: annotate data races in ppp_generic
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 543adf072165aaf2e3b635c0476204f9658ed3bf ]
Several fields in struct ppp can be read or updated concurrently from multiple CPUs without synchronization, causing data races:
1. ppp->mru is read concurrently in ppp_receive_nonmp_frame() while being updated via PPPIOCSMRU ioctl. Protect ppp->mru updates in PPPIOCSMRU with ppp_recv_lock(ppp).
2. PPPIOCGFLAGS reads ppp->flags, ppp->xstate, and ppp->rstate unlocked. Wrap the read in ppp_lock(ppp) to get a consistent snapshot.
3. ppp->debug is updated via PPPIOCSDEBUG and read concurrently on fast paths. Annotate reads with READ_ONCE() and writes with WRITE_ONCE().
4. ppp->last_xmit and ppp->last_recv are updated on TX/RX data paths and read via PPPIOCGIDLE32 / PPPIOCGIDLE64 ioctls. Annotate with WRITE_ONCE() / READ_ONCE() and use max() to handle jiffies subtraction.
5. ppp->npmode[] is updated via PPPIOCSNPMODE and read on TX/RX paths. Annotate with WRITE_ONCE() / READ_ONCE().
--- drivers/net/ppp/ppp_generic.c | 50 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 22 deletions(-)
drivers/net/ppp/ppp_generic.c +28 -22
@@ -813,7 +813,9 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case PPPIOCSMRU :if (get_user (val, p))break ; +ppp_recv_lock (ppp); ppp->mru = val; +ppp_recv_unlock (ppp); err =0 ;break ;
@@ -834,7 +836,9 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)break ;case PPPIOCGFLAGS : +ppp_lock (ppp); val = ppp->flags | ppp->xstate | ppp->rstate; +ppp_unlock (ppp);if (put_user (val, p))break ; err =0 ;
@@ -858,7 +862,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case PPPIOCSDEBUG :if (get_user (val, p))break ; - ppp->debug = val; +WRITE_ONCE (ppp->debug, val); err =0 ;break ;
@@ -869,16 +873,16 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)break ;case PPPIOCGIDLE32 : - idle32.xmit_idle = (jiffies - ppp->last_xmit) /HZ ; - idle32.recv_idle = (jiffies - ppp->last_recv) /HZ ; -if (copy_to_user (argp, &idle32,sizeof (idle32))) + idle32.xmit_idle =max (0L , (long )(jiffies -READ_ONCE (ppp->last_xmit))) /HZ ; + idle32.recv_idle =max (0L , (long )(jiffies -READ_ONCE (ppp->last_recv))) /HZ ; +if (copy_to_user (argp, &idle32,sizeof (idle32)))break ; err =0 ;break ;case PPPIOCGIDLE64 : - idle64.xmit_idle = (jiffies - ppp->last_xmit) /HZ ; - idle64.recv_idle = (jiffies - ppp->last_recv) /HZ ; + idle64.xmit_idle =max (0L , (long )(jiffies -READ_ONCE (ppp->last_xmit))) /HZ ; + idle64.recv_idle =max (0L , (long )(jiffies -READ_ONCE (ppp->last_recv))) /HZ ;if (copy_to_user (argp, &idle64,sizeof (idle64)))break ; err =0 ;
@@ -919,7 +923,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)if (copy_to_user (argp, &npi,sizeof (npi)))break ; }else { - ppp->npmode[i] = npi.mode; +WRITE_ONCE (ppp->npmode[i], npi.mode);/* we may be able to transmit more packets now (??) */ netif_wake_queue (ppp->dev); }
@@ -1454,7 +1458,7 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev) goto outf;/* Drop, accept or reject the packet */ -switch (ppp->npmode[npi]) { +switch (READ_ONCE (ppp->npmode[npi])) {case NPMODE_PASS :break ;case NPMODE_QUEUE :
@@ -1769,7 +1773,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb) *(__be16 *)skb_push (skb,2 ) =htons (PPP_FILTER_OUTBOUND_TAG );if (ppp->pass_filter &&bpf_prog_run (ppp->pass_filter, skb) ==0 ) { -if (ppp->debug &1 ) +if (READ_ONCE (ppp->debug) &1 )netdev_printk (KERN_DEBUG , ppp->dev,"PPP: outbound frame " "not passed\n" );
@@ -1779,11 +1783,11 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)/* if this packet passes the active filter, record the time */ if (!(ppp->active_filter &&bpf_prog_run (ppp->active_filter, skb) ==0 )) - ppp->last_xmit = jiffies; +WRITE_ONCE (ppp->last_xmit, jiffies);skb_pull (skb,2 );#else /* for data packets, record the time */ - ppp->last_xmit = jiffies; +WRITE_ONCE (ppp->last_xmit, jiffies);#endif /* CONFIG_PPP_FILTER */ }
@@ -2159,7 +2163,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb) noskb:spin_unlock (&pch->downl); err_linearize: -if (ppp->debug &1 ) +if (READ_ONCE (ppp->debug) &1 )netdev_err (ppp->dev,"PPP: no memory (fragment)\n" ); ++ppp->dev->stats.tx_errors; ++ppp->nxseq;
@@ -2505,7 +2509,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) *(__be16 *)skb_push (skb,2 ) =htons (PPP_FILTER_INBOUND_TAG );if (ppp->pass_filter &&bpf_prog_run (ppp->pass_filter, skb) ==0 ) { -if (ppp->debug &1 ) +if (READ_ONCE (ppp->debug) &1 )netdev_printk (KERN_DEBUG , ppp->dev,"PPP: inbound frame " "not passed\n" );
@@ -2514,14 +2518,14 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) }if (!(ppp->active_filter &&bpf_prog_run (ppp->active_filter, skb) ==0 )) - ppp->last_recv = jiffies; +WRITE_ONCE (ppp->last_recv, jiffies);__skb_pull (skb,2 ); } else#endif /* CONFIG_PPP_FILTER */ - ppp->last_recv = jiffies; +WRITE_ONCE (ppp->last_recv, jiffies);if ((ppp->dev->flags &IFF_UP ) ==0 || - ppp->npmode[npi] !=NPMODE_PASS ) { +READ_ONCE (ppp->npmode[npi]) !=NPMODE_PASS ) {kfree_skb (skb); }else {/* chop off protocol */
@@ -2774,7 +2778,7 @@ ppp_mp_reconstruct(struct ppp *ppp) seq =seq_before (minseq,PPP_MP_CB (p)->sequence)? minseq +1 :PPP_MP_CB (p)->sequence; -if (ppp->debug &1 ) +if (READ_ONCE (ppp->debug) &1 )netdev_printk (KERN_DEBUG , ppp->dev,"lost frag %u..%u\n" , oldseq, seq-1 );
@@ -2823,7 +2827,7 @@ ppp_mp_reconstruct(struct ppp *ppp)struct sk_buff *tmp2; skb_queue_reverse_walk_from_safe(list, p, tmp2) { -if (ppp->debug &1 ) +if (READ_ONCE (ppp->debug) &1 )netdev_printk (KERN_DEBUG , ppp->dev,"discarding frag %u\n" ,PPP_MP_CB (p)->sequence);
@@ -2845,7 +2849,7 @@ ppp_mp_reconstruct(struct ppp *ppp) skb_queue_walk_safe(list, p, tmp) {if (p == head)break ; -if (ppp->debug &1 ) +if (READ_ONCE (ppp->debug) &1 )netdev_printk (KERN_DEBUG , ppp->dev,"discarding frag %u\n" ,PPP_MP_CB (p)->sequence);
@@ -2853,7 +2857,7 @@ ppp_mp_reconstruct(struct ppp *ppp)kfree_skb (p); } -if (ppp->debug &1 ) +if (READ_ONCE (ppp->debug) &1 ) netdev_printk(KERN_DEBUG, ppp->dev, " missed pkts %u..%u\n", ppp->nextseq,
@@ -3163,7 +3167,8 @@ ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound)if (!ppp->rc_state)break ;if (ppp->rcomp->decomp_init (ppp->rc_state, dp, len, - ppp->file.index,0 , ppp->mru, ppp->debug)) { + ppp->file.index,0 , ppp->mru, +READ_ONCE (ppp->debug))) { ppp->rstate |=SC_DECOMP_RUN ; ppp->rstate &= ~(SC_DC_ERROR |SC_DC_FERROR ); }
@@ -3172,7 +3177,8 @@ ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound)if (!ppp->xc_state)break ;if (ppp->xcomp->comp_init (ppp->xc_state, dp, len, - ppp->file.index,0 , ppp->debug)) + ppp->file.index,0 , +READ_ONCE (ppp->debug))) ppp->xstate |=SC_COMP_RUN ; }break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 234/602 hinic: remove unused ethtool RSS user configuration buffers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenguang Zhao <[email protected]>
[ Upstream commit fe0c002928c6749b7f4a726f6f600f6dd70280ea ]
rss_indir_user and rss_hkey_user are allocated and filled in __set_rss_rxfh() when the user configures RSS via ethtool, but nothing ever reads them. hinic_get_rxfh() fetches the state from the device, and the hardware is programmed from the original indir/key arguments. These buffers only leaked on driver unload.
Drop the unused allocations, memcpys, and struct fields.
--- drivers/net/ethernet/huawei/hinic/hinic_dev.h | 2 -- .../net/ethernet/huawei/hinic/hinic_ethtool.c | 21 ------------------- 2 files changed, 23 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_dev.h +0 -2
@@ -104,8 +104,6 @@ struct hinic_dev {u16 num_rss;u16 rss_limit;struct hinic_rss_type rss_type; -u8 *rss_hkey_user; -s32 *rss_indir_user;struct hinic_intr_coal_info *rx_intr_coalesce;struct hinic_intr_coal_info *tx_intr_coalesce;struct hinic_sriov_info sriov_info;
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +0 -21
@@ -1061,17 +1061,6 @@ static int __set_rss_rxfh(struct net_device *netdev,int err;if (indir) { -if (!nic_dev->rss_indir_user) { - nic_dev->rss_indir_user = -kzalloc (sizeof (u32) *HINIC_RSS_INDIR_SIZE , -GFP_KERNEL ); -if (!nic_dev->rss_indir_user) -return -ENOMEM ; - } - -memcpy (nic_dev->rss_indir_user, indir, -sizeof (u32) *HINIC_RSS_INDIR_SIZE ); - err =hinic_rss_set_indir_tbl (nic_dev, nic_dev->rss_tmpl_idx, indir);if (err)
@@ -1079,16 +1068,6 @@ static int __set_rss_rxfh(struct net_device *netdev, }if (key) { -if (!nic_dev->rss_hkey_user) { - nic_dev->rss_hkey_user = -kzalloc (HINIC_RSS_KEY_SIZE *2 ,GFP_KERNEL ); - -if (!nic_dev->rss_hkey_user) -return -ENOMEM ; - } - -memcpy (nic_dev->rss_hkey_user, key,HINIC_RSS_KEY_SIZE ); - err =hinic_rss_set_template_tbl (nic_dev, nic_dev->rss_tmpl_idx, key);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 235/602 net: qrtr: restrict socket creation to the initial network namespace
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
[ Upstream commit 3b536db8fb32da9e9c62f2bb45e2e319331f0426 ]
QRTR keeps its entire port and node state in module-global variables that are not partitioned per network namespace: qrtr_local_nid is a single global node id (always 1) and qrtr_ports is a single global xarray. qrtr_port_lookup() and qrtr_local_enqueue() operate on that global state with no network-namespace check, and qrtr_create() places no restriction on the namespace a socket is created in.
As a result an unprivileged process that creates an AF_QIPCRTR socket in a separate network namespace, e.g. via unshare(CLONE_NEWUSER | CLONE_NEWNET), can send QRTR datagrams - including control-plane messages such as QRTR_TYPE_NEW_SERVER - to QRTR sockets owned by another namespace, and vice versa. The receiving socket sees such a message as coming from node id 1, indistinguishable from a legitimate local client, breaking the isolation that network namespaces are expected to provide.
QRTR is a transport to global hardware endpoints (the modem and other remote processors) and has no per-namespace semantics; its in-kernel name service already creates its socket in init_net only. Confine the socket family to the initial network namespace, as other non-namespace-aware socket families do (see llc_ui_create() and the ieee802154 socket code).
--- net/qrtr/af_qrtr.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/qrtr/af_qrtr.c +8 -0
@@ -1261,6 +1261,14 @@ static int qrtr_create(struct net *net, struct socket *sock,if (sock->type !=SOCK_DGRAM )return -EPROTOTYPE ; +/* QRTR keeps its port and node state in module-global variables that +* are not partitioned per network namespace, and the in-kernel name +* service only operates in init_net. Confine the family to init_net so +* a socket in another namespace cannot reach the global control plane. +*/ +if (!net_eq (net, &init_net)) +return -EAFNOSUPPORT ; + sk =sk_alloc (net,AF_QIPCRTR ,GFP_KERNEL , &qrtr_proto, kern);if (!sk)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 236/602 dpll: add clock quality level attribute and op
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Pirko <[email protected]>
[ Upstream commit a1afb959add1fad43cb337448c244ed70bac3109 ]
In order to allow driver expose quality level of the clock it is running, introduce a new netlink attr with enum to carry it to the userspace. Also, introduce an op the dpll netlink code calls into the driver to obtain the value.
Stable-dep-of: 11c057d23465 ("net/mlx5: Fix MCIA register buffer overflow on 32 dword reads")
--- Documentation/netlink/specs/dpll.yaml | 41 +++++++++++++++++++++++++++ drivers/dpll/dpll_netlink.c | 24 ++++++++++++++++ include/linux/dpll.h | 4 +++ include/uapi/linux/dpll.h | 24 ++++++++++++++++ 4 files changed, 93 insertions(+)
Documentation/netlink/specs/dpll.yaml +41 -0
@@ -85,6 +85,36 @@ definitions: This may happen for example if dpll device was previously locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT. render-max: true + - + type: enum + name: clock-quality-level + doc: | + level of quality of a clock device. This mainly applies when + the dpll lock-status is DPLL_LOCK_STATUS_HOLDOVER. + The current list is defined according to the table 11-7 contained + in ITU-T G.8264/Y.1364 document. One may extend this list freely + by other ITU-T defined clock qualities, or different ones defined + by another standardization body (for those, please use + different prefix). + entries: + - + name: itu-opt1-prc + value: 1 + - + name: itu-opt1-ssu-a + - + name: itu-opt1-ssu-b + - + name: itu-opt1-eec1 + - + name: itu-opt1-prtc + - + name: itu-opt1-eprtc + - + name: itu-opt1-eeec + - + name: itu-opt1-eprc + render-max: true - type: const name: temp-divider
@@ -252,6 +282,17 @@ attribute-sets: name: lock-status-error type: u32 enum: lock-status-error + - + name: clock-quality-level + type: u32 + enum: clock-quality-level + multi-attr: true + doc: | + Level of quality of a clock device. This mainly applies when + the dpll lock-status is DPLL_LOCK_STATUS_HOLDOVER. This could + be put to message multiple times to indicate possible parallel + quality levels (e.g. one specified by ITU option 1 and another + one specified by option 2). - name: pin enum-name: dpll_a_pin
drivers/dpll/dpll_netlink.c +24 -0
@@ -187,6 +187,27 @@ dpll_msg_add_temp(struct sk_buff *msg, struct dpll_device *dpll,return 0 ; } +static int +dpll_msg_add_clock_quality_level (struct sk_buff *msg,struct dpll_device *dpll, +struct netlink_ext_ack *extack) +{ +const struct dpll_device_ops *ops =dpll_device_ops (dpll); + DECLARE_BITMAP(qls, DPLL_CLOCK_QUALITY_LEVEL_MAX) = { 0 }; +enum dpll_clock_quality_level ql; +int ret; + +if (!ops->clock_quality_level_get) +return 0 ; + ret = ops->clock_quality_level_get (dpll,dpll_priv (dpll), qls, extack); +if (ret) +return ret; +for_each_set_bit (ql, qls,DPLL_CLOCK_QUALITY_LEVEL_MAX ) +if (nla_put_u32 (msg,DPLL_A_CLOCK_QUALITY_LEVEL , ql)) +return -EMSGSIZE ; + +return 0 ; +} + static int dpll_msg_add_pin_prio(struct sk_buff *msg, struct dpll_pin *pin, struct dpll_pin_ref *ref,
@@ -623,6 +644,9 @@ dpll_device_get_one(struct dpll_device *dpll, struct sk_buff *msg,if (ret)return ret; ret =dpll_msg_add_lock_status (msg, dpll, extack); +if (ret) +return ret; + ret =dpll_msg_add_clock_quality_level (msg, dpll, extack);if (ret)return ret; ret =dpll_msg_add_mode (msg, dpll, extack);
include/linux/dpll.h +4 -0
@@ -28,6 +28,10 @@ struct dpll_device_ops { struct netlink_ext_ack *extack);int (*temp_get)(const struct dpll_device *dpll,void *dpll_priv,s32 *temp,struct netlink_ext_ack *extack); +int (*clock_quality_level_get)(const struct dpll_device *dpll, +void *dpll_priv, +unsigned long *qls, +struct netlink_ext_ack *extack); };struct dpll_pin_ops {
include/uapi/linux/dpll.h +24 -0
@@ -79,6 +79,29 @@ enum dpll_lock_status_error { DPLL_LOCK_STATUS_ERROR_MAX = (__DPLL_LOCK_STATUS_ERROR_MAX - 1) }; +/** +* enum dpll_clock_quality_level - level of quality of a clock device. This +* mainly applies when the dpll lock-status is DPLL_LOCK_STATUS_HOLDOVER. The +* current list is defined according to the table 11-7 contained in ITU-T +* G.8264/Y.1364 document. One may extend this list freely by other ITU-T +* defined clock qualities, or different ones defined by another +* standardization body (for those, please use different prefix). +*/ +enum dpll_clock_quality_level { +DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_PRC =1 , +DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_SSU_A , +DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_SSU_B , +DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EEC1 , +DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_PRTC , +DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRTC , +DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EEEC , +DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRC , + +/* private: */ + __DPLL_CLOCK_QUALITY_LEVEL_MAX, +DPLL_CLOCK_QUALITY_LEVEL_MAX = (__DPLL_CLOCK_QUALITY_LEVEL_MAX -1 ) +}; +#define DPLL_TEMP_DIVIDER 1000/**
@@ -180,6 +203,7 @@ enum dpll_a {DPLL_A_TEMP ,DPLL_A_TYPE ,DPLL_A_LOCK_STATUS_ERROR , +DPLL_A_CLOCK_QUALITY_LEVEL , __DPLL_A_MAX,DPLL_A_MAX = (__DPLL_A_MAX -1 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 237/602 net/mlx5: DPLL, Add clock quality level op implementation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Pirko <[email protected]>
[ Upstream commit e2017f27b6f888fb4ebc5c9a6d984bbf2f8b99ff ]
Use MSECQ register to query clock quality from firmware. Implement the dpll op and fill-up the quality level value properly.
Stable-dep-of: 11c057d23465 ("net/mlx5: Fix MCIA register buffer overflow on 32 dword reads")
--- .../net/ethernet/mellanox/mlx5/core/dpll.c | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/dpll.c +81 -0
@@ -166,9 +166,90 @@ static int mlx5_dpll_device_mode_get(const struct dpll_device *dpll,return 0 ; } +enum { +MLX5_DPLL_SSM_CODE_PRC =0b0010 , +MLX5_DPLL_SSM_CODE_SSU_A =0b0100 , +MLX5_DPLL_SSM_CODE_SSU_B =0b1000 , +MLX5_DPLL_SSM_CODE_EEC1 =0b1011 , +MLX5_DPLL_SSM_CODE_PRTC =0b0010 , +MLX5_DPLL_SSM_CODE_EPRTC =0b0010 , +MLX5_DPLL_SSM_CODE_EEEC =0b1011 , +MLX5_DPLL_SSM_CODE_EPRC =0b0010 , +}; + +enum { +MLX5_DPLL_ENHANCED_SSM_CODE_PRC =0xff , +MLX5_DPLL_ENHANCED_SSM_CODE_SSU_A =0xff , +MLX5_DPLL_ENHANCED_SSM_CODE_SSU_B =0xff , +MLX5_DPLL_ENHANCED_SSM_CODE_EEC1 =0xff , +MLX5_DPLL_ENHANCED_SSM_CODE_PRTC =0x20 , +MLX5_DPLL_ENHANCED_SSM_CODE_EPRTC =0x21 , +MLX5_DPLL_ENHANCED_SSM_CODE_EEEC =0x22 , +MLX5_DPLL_ENHANCED_SSM_CODE_EPRC =0x23 , +}; + +#define __MLX5_DPLL_SSM_COMBINED_CODE (ssm_code, enhanced_ssm_code) \ + ((ssm_code) | ((enhanced_ssm_code) << 8)) + +#define MLX5_DPLL_SSM_COMBINED_CODE (type) \ + __MLX5_DPLL_SSM_COMBINED_CODE(MLX5_DPLL_SSM_CODE_##type, \ + MLX5_DPLL_ENHANCED_SSM_CODE_##type) + +static int mlx5_dpll_clock_quality_level_get (const struct dpll_device *dpll, +void *priv,unsigned long *qls, +struct netlink_ext_ack *extack) +{ +u8 network_option, ssm_code, enhanced_ssm_code; +u32 out[MLX5_ST_SZ_DW (msecq_reg)] = {}; +u32 in[MLX5_ST_SZ_DW (msecq_reg)] = {}; +struct mlx5_dpll *mdpll = priv; +int err; + + err =mlx5_core_access_reg (mdpll->mdev, in,sizeof (in), + out,sizeof (out),MLX5_REG_MSECQ ,0 ,0 ); +if (err) +return err; + network_option =MLX5_GET (msecq_reg, out, network_option); +if (network_option !=1 ) + goto errout; + ssm_code =MLX5_GET (msecq_reg, out, local_ssm_code); + enhanced_ssm_code =MLX5_GET (msecq_reg, out, local_enhanced_ssm_code); + +switch (__MLX5_DPLL_SSM_COMBINED_CODE (ssm_code, enhanced_ssm_code)) { +case MLX5_DPLL_SSM_COMBINED_CODE (PRC ): +__set_bit (DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_PRC , qls); +return 0 ; +case MLX5_DPLL_SSM_COMBINED_CODE (SSU_A ): +__set_bit (DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_SSU_A , qls); +return 0 ; +case MLX5_DPLL_SSM_COMBINED_CODE (SSU_B ): +__set_bit (DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_SSU_B , qls); +return 0 ; +case MLX5_DPLL_SSM_COMBINED_CODE (EEC1 ): +__set_bit (DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EEC1 , qls); +return 0 ; +case MLX5_DPLL_SSM_COMBINED_CODE (PRTC ): +__set_bit (DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_PRTC , qls); +return 0 ; +case MLX5_DPLL_SSM_COMBINED_CODE (EPRTC ): +__set_bit (DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRTC , qls); +return 0 ; +case MLX5_DPLL_SSM_COMBINED_CODE (EEEC ): +__set_bit (DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EEEC , qls); +return 0 ; +case MLX5_DPLL_SSM_COMBINED_CODE (EPRC ): +__set_bit (DPLL_CLOCK_QUALITY_LEVEL_ITU_OPT1_EPRC , qls); +return 0 ; + } +errout: +NL_SET_ERR_MSG_MOD (extack,"Invalid clock quality level obtained from firmware\n" ); +return -EINVAL ; +} +static const struct dpll_device_ops mlx5_dpll_device_ops = { .lock_status_get = mlx5_dpll_device_lock_status_get, .mode_get = mlx5_dpll_device_mode_get, + .clock_quality_level_get = mlx5_dpll_clock_quality_level_get, }; static int mlx5_dpll_pin_direction_get(const struct dpll_pin *pin,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 238/602 net/mlx5: Remove newline at the end of a netlink error message
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <[email protected]>
[ Upstream commit 3a2295ff3f00d44c97baec37c43b6ede3eea9df9 ]
Netlink error messages should not have a newline at the end of the string.
Stable-dep-of: 11c057d23465 ("net/mlx5: Fix MCIA register buffer overflow on 32 dword reads")
--- drivers/net/ethernet/mellanox/mlx5/core/dpll.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/dpll.c +1 -1
@@ -242,7 +242,7 @@ static int mlx5_dpll_clock_quality_level_get(const struct dpll_device *dpll,return 0 ; } errout: -NL_SET_ERR_MSG_MOD (extack,"Invalid clock quality level obtained from firmware\n" ); +NL_SET_ERR_MSG_MOD (extack,"Invalid clock quality level obtained from firmware" );return -EINVAL ; }
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_vxlan.c +1 -1
@@ -140,7 +140,7 @@ static int mlx5e_tc_tun_parse_vxlan_gbp_option(struct mlx5e_priv *priv, gbp_mask = (u32 *)&enc_opts.mask->data[0 ];if (*gbp_mask & ~VXLAN_GBP_MASK ) { -NL_SET_ERR_MSG_FMT_MOD (extack,"Wrong VxLAN GBP mask(0x%08X)\n" , *gbp_mask); +NL_SET_ERR_MSG_FMT_MOD (extack,"Wrong VxLAN GBP mask(0x%08X)" , *gbp_mask);return -EINVAL ; }
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +1 -1
@@ -2013,7 +2013,7 @@ static int mlx5e_get_module_eeprom_by_page(struct net_device *netdev,if (size_read <0 ) {NL_SET_ERR_MSG_FMT_MOD ( extack, -"Query module eeprom by page failed, read %u bytes, err %d\n" , +"Query module eeprom by page failed, read %u bytes, err %d" , i, size_read);return size_read; }
drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.c +3 -3
@@ -1861,7 +1861,7 @@ int mlx5_esw_bridge_port_mdb_add(struct net_device *dev, u16 vport_num, u16 esw_"Failed to lookup bridge port to add MDB (MAC=%pM,vport=%u)\n" , addr, vport_num);NL_SET_ERR_MSG_FMT_MOD (extack, -"Failed to lookup bridge port to add MDB (MAC=%pM,vport=%u)\n" , +"Failed to lookup bridge port to add MDB (MAC=%pM,vport=%u)" , addr, vport_num);return -EINVAL ; }
@@ -1874,7 +1874,7 @@ int mlx5_esw_bridge_port_mdb_add(struct net_device *dev, u16 vport_num, u16 esw_"Failed to lookup bridge port vlan metadata to create MDB (MAC=%pM,vid=%u,vport=%u)\n" , addr, vid, vport_num);NL_SET_ERR_MSG_FMT_MOD (extack, -"Failed to lookup vlan metadata for MDB (MAC=%pM,vid=%u,vport=%u)\n" , +"Failed to lookup vlan metadata for MDB (MAC=%pM,vid=%u,vport=%u)" , addr, vid, vport_num);return -EINVAL ; }
@@ -1882,7 +1882,7 @@ int mlx5_esw_bridge_port_mdb_add(struct net_device *dev, u16 vport_num, u16 esw_ err =mlx5_esw_bridge_port_mdb_attach (dev, port, addr, vid);if (err) { -NL_SET_ERR_MSG_FMT_MOD (extack,"Failed to add MDB (MAC=%pM,vid=%u,vport=%u)\n" , +NL_SET_ERR_MSG_FMT_MOD (extack,"Failed to add MDB (MAC=%pM,vid=%u,vport=%u)" , addr, vid, vport_num);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 239/602 net/mlx5: Refactor EEPROM query error handling to return status separately
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <[email protected]>
[ Upstream commit 2e4c44b12f4da60d3e8dcbc1ccf38bb28a878050 ]
Matthew and Jakub reported [1] issues where inventory automation tools are calling EEPROM query repeatedly on a port that doesn't have an SFP connected, resulting in millions of error prints.
Move MCIA register status extraction from the query functions to the callers, allowing use of extack reporting instead of a dmesg print when using the netlink API.
[1] https://lore.kernel.org/netdev/[email protected]/
Stable-dep-of: 11c057d23465 ("net/mlx5: Fix MCIA register buffer overflow on 32 dword reads")
--- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 19 +++++----- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 4 +-- .../net/ethernet/mellanox/mlx5/core/port.c | 35 +++++++++---------- 3 files changed, 30 insertions(+), 28 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +11 -8
@@ -1912,7 +1912,7 @@ static int mlx5e_get_module_info(struct net_device *netdev,int size_read =0 ;u8 data[4 ] = {0 }; - size_read =mlx5_query_module_eeprom (dev,0 ,2 , data); + size_read =mlx5_query_module_eeprom (dev,0 ,2 , data,NULL );if (size_read <2 )return -EIO ;
@@ -1954,6 +1954,7 @@ static int mlx5e_get_module_eeprom(struct net_device *netdev,struct mlx5_core_dev *mdev = priv->mdev;int offset = ee->offset;int size_read; +u8 status =0 ;int i =0 ;if (!ee->len)
@@ -1963,15 +1964,15 @@ static int mlx5e_get_module_eeprom(struct net_device *netdev,while (i < ee->len) { size_read =mlx5_query_module_eeprom (mdev, offset, ee->len - i, - data + i); - + data + i, &status);if (!size_read)/* Done reading */ return 0 ;if (size_read <0 ) { -netdev_err (priv->netdev,"%s: mlx5_query_eeprom failed:0x%x\n" , - __func__, size_read); +netdev_err (netdev, +"%s: mlx5_query_eeprom failed:0x%x, status %u\n" , + __func__, size_read, status);return size_read; }
@@ -1991,6 +1992,7 @@ static int mlx5e_get_module_eeprom_by_page(struct net_device *netdev,struct mlx5_core_dev *mdev = priv->mdev;u8 *data = page_data->data;int size_read; +u8 status =0 ;int i =0 ;if (!page_data->length)
@@ -2004,7 +2006,8 @@ static int mlx5e_get_module_eeprom_by_page(struct net_device *netdev, query.page = page_data->page;while (i < page_data->length) { query.size = page_data->length - i; - size_read =mlx5_query_module_eeprom_by_page (mdev, &query, data + i); + size_read =mlx5_query_module_eeprom_by_page (mdev, &query, + data + i, &status);/* Done reading, return how many bytes was read */ if (!size_read)
@@ -2013,8 +2016,8 @@ static int mlx5e_get_module_eeprom_by_page(struct net_device *netdev,if (size_read <0 ) {NL_SET_ERR_MSG_FMT_MOD ( extack, -"Query module eeprom by page failed, read %u bytes, err %d" , - i, size_read); +"Query module eeprom by page failed, read %u bytes, err %d, status %u" , + i, size_read, status);return size_read; }
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +2 -2
@@ -342,11 +342,11 @@ int mlx5_set_port_fcs(struct mlx5_core_dev *mdev, u8 enable);void mlx5_query_port_fcs (struct mlx5_core_dev *mdev,bool *supported,bool *enabled);int mlx5_query_module_eeprom (struct mlx5_core_dev *dev, -u16 offset,u16 size,u8 *data); +u16 offset,u16 size,u8 *data,u8 *status);int mlx5_query_module_eeprom_by_page (struct mlx5_core_dev *dev,struct mlx5_module_eeprom_query_params *params, -u8 *data); +u8 *data,u8 *status);int mlx5_query_port_dcbx_param (struct mlx5_core_dev *mdev,u32 *out);int mlx5_set_port_dcbx_param (struct mlx5_core_dev *mdev,u32 *in);
drivers/net/ethernet/mellanox/mlx5/core/port.c +17 -18
@@ -289,11 +289,11 @@ int mlx5_query_module_num(struct mlx5_core_dev *dev, int *module_num) }static int mlx5_query_module_id (struct mlx5_core_dev *dev,int module_num, -u8 *module_id) +u8 *module_id,u8 *status) {u32 in[MLX5_ST_SZ_DW (mcia_reg)] = {};u32 out[MLX5_ST_SZ_DW (mcia_reg)]; -int err, status; +int err;u8 *ptr;MLX5_SET (mcia_reg, in, i2c_device_address,MLX5_I2C_ADDR_LOW );
@@ -308,12 +308,12 @@ static int mlx5_query_module_id(struct mlx5_core_dev *dev, int module_num,if (err)return err; - status =MLX5_GET (mcia_reg, out, status); -if (status) { -mlx5_core_err (dev,"query_mcia_reg failed: status: 0x%x\n" , - status); +if (MLX5_GET (mcia_reg, out, status)) { +if (status) + *status =MLX5_GET (mcia_reg, out, status);return -EIO ; } + ptr =MLX5_ADDR_OF (mcia_reg, out, dword_0); *module_id = ptr[0 ];
@@ -370,13 +370,14 @@ static int mlx5_mcia_max_bytes(struct mlx5_core_dev *dev) }static int mlx5_query_mcia (struct mlx5_core_dev *dev, -struct mlx5_module_eeprom_query_params *params,u8 *data) +struct mlx5_module_eeprom_query_params *params, +u8 *data,u8 *status) {u32 in[MLX5_ST_SZ_DW (mcia_reg)] = {};u32 out[MLX5_ST_SZ_DW (mcia_reg)]; -int status, err;void *ptr;u16 size; +int err; size =min_t (int, params->size,mlx5_mcia_max_bytes (dev));
@@ -392,12 +393,9 @@ static int mlx5_query_mcia(struct mlx5_core_dev *dev,if (err)return err; - status =MLX5_GET (mcia_reg, out, status); -if (status) { -mlx5_core_err (dev,"query_mcia_reg failed: status: 0x%x\n" , - status); + *status =MLX5_GET (mcia_reg, out, status); +if (*status)return -EIO ; - } ptr =MLX5_ADDR_OF (mcia_reg, out, dword_0);memcpy (data, ptr, size);
@@ -406,7 +404,7 @@ static int mlx5_query_mcia(struct mlx5_core_dev *dev, }int mlx5_query_module_eeprom (struct mlx5_core_dev *dev, -u16 offset,u16 size,u8 *data) +u16 offset,u16 size,u8 *data,u8 *status) {struct mlx5_module_eeprom_query_params query = {0 };u8 module_id;
@@ -416,7 +414,8 @@ int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,if (err)return err; - err =mlx5_query_module_id (dev, query.module_number, &module_id); + err =mlx5_query_module_id (dev, query.module_number, &module_id, + status);if (err)return err;
@@ -442,12 +441,12 @@ int mlx5_query_module_eeprom(struct mlx5_core_dev *dev, query.size = size; query.offset = offset; -return mlx5_query_mcia (dev, &query, data); +return mlx5_query_mcia (dev, &query, data, status); }int mlx5_query_module_eeprom_by_page (struct mlx5_core_dev *dev,struct mlx5_module_eeprom_query_params *params, -u8 *data) +u8 *data,u8 *status) {int err;
@@ -461,7 +460,7 @@ int mlx5_query_module_eeprom_by_page(struct mlx5_core_dev *dev,return -EINVAL ; } -return mlx5_query_mcia (dev, params, data); +return mlx5_query_mcia (dev, params, data, status); } static int mlx5_query_port_pvlc(struct mlx5_core_dev *dev, u32 *pvlc,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 240/602 net/mlx5: Fix MCIA register buffer overflow on 32 dword reads
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <[email protected]>
[ Upstream commit 11c057d23465c7a5817a7284c896d19d54c0b616 ]
The MCIA register can return up to 32 dwords (128 bytes) when the device advertises the mcia_32dwords capability, but struct mlx5_ifc_mcia_reg_bits only defines dword_0..11, leaving room for just 12 dwords (48 bytes) of data.
mlx5_query_mcia() clamps the read size to mlx5_mcia_max_bytes() and then memcpy()s that many bytes out of the register, potentially reading past the end of the 'out' buffer. On kernels built with FORTIFY_SOURCE this is caught as a buffer overflow while reading the module EEPROM via ethtool:
detected buffer overflow in memcpy
kernel BUG at lib/string_helpers.c:1048!
RIP: 0010:fortify_panic+0x13/0x20 Call Trace: mlx5_query_mcia.isra.0+0x200/0x210 [mlx5_core] mlx5_query_module_eeprom_by_page+0x4a/0xa0 [mlx5_core] mlx5e_get_module_eeprom_by_page+0xbb/0x120 [mlx5_core] eeprom_prepare_data+0xf3/0x170 ethnl_default_doit+0xf1/0x3b0
Extend the mcia_reg layout to 32 dwords.
--- drivers/net/ethernet/mellanox/mlx5/core/port.c | 4 ++-- include/linux/mlx5/mlx5_ifc.h | 13 +------------ 2 files changed, 3 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/port.c +2 -2
@@ -314,7 +314,7 @@ static int mlx5_query_module_id(struct mlx5_core_dev *dev, int module_num,return -EIO ; } - ptr =MLX5_ADDR_OF (mcia_reg, out, dword_0); + ptr =MLX5_ADDR_OF (mcia_reg, out, dwords); *module_id = ptr[0 ];
@@ -397,7 +397,7 @@ static int mlx5_query_mcia(struct mlx5_core_dev *dev,if (*status)return -EIO ; - ptr =MLX5_ADDR_OF (mcia_reg, out, dword_0); + ptr =MLX5_ADDR_OF (mcia_reg, out, dwords);memcpy (data, ptr, size);return size;
include/linux/mlx5/mlx5_ifc.h +1 -12
@@ -11803,18 +11803,7 @@ struct mlx5_ifc_mcia_reg_bits {u8 reserved_at_60[0x20 ]; -u8 dword_0[0x20 ]; -u8 dword_1[0x20 ]; -u8 dword_2[0x20 ]; -u8 dword_3[0x20 ]; -u8 dword_4[0x20 ]; -u8 dword_5[0x20 ]; -u8 dword_6[0x20 ]; -u8 dword_7[0x20 ]; -u8 dword_8[0x20 ]; -u8 dword_9[0x20 ]; -u8 dword_10[0x20 ]; -u8 dword_11[0x20 ]; +u8 dwords[0x400 ]; };struct mlx5_ifc_dcbx_param_bits {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 241/602 net/mlx5: E-Switch, fix zero num_dest in prio_tag egress vlan rule
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yael Chemla <[email protected]>
[ Upstream commit d12956d083eb70f2c6d72711aebaf8c2ce21e170 ]
esw_egress_acl_vlan_create() hardcodes num_dest=0 in its mlx5_add_flow_rules() call. When invoked from the non-bond path fwd_dest is NULL and num_dest=0 is correct. When invoked from esw_acl_egress_ofld_rules_create() during a bond event, fwd_dest is non-NULL and flow_act.action carries MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, but _mlx5_add_flow_rules() rejects a non-NULL dest pointer paired with dest_num<=0 and returns -EINVAL. The error propagates as "configure slave vport egress fwd, err(-22)". The passive vport's egress ACL table ends up with its flow groups allocated but no FTEs, so prio-tagged packets are not popped and bond failover is broken on prio_tag_required devices.
Fix by passing fwd_dest ? 1 : 0 as num_dest to match the actual number of destinations supplied.
--- drivers/net/ethernet/mellanox/mlx5/core/esw/acl/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/helper.c +1 -1
@@ -71,7 +71,7 @@ int esw_egress_acl_vlan_create(struct mlx5_eswitch *esw, flow_act.action = flow_action; vport->egress.allowed_vlan =mlx5_add_flow_rules (vport->egress.acl, spec, - &flow_act, fwd_dest,0 ); + &flow_act, fwd_dest, fwd_dest ?1 :0 );if (IS_ERR (vport->egress.allowed_vlan)) { err =PTR_ERR (vport->egress.allowed_vlan); esw_warn(esw->dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 242/602 net/mlx5e: Report zero bandwidth for non-ETS traffic classes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Lazar <[email protected]>
[ Upstream commit ffb1873b2df11945b8c395e859169248675c91c5 ]
The IEEE 802.1Qaz standard defines that bandwidth allocation percentages only apply to Enhanced Transmission Selection (ETS) traffic classes. For STRICT and VENDOR transmission selection algorithms, bandwidth percentage values are not applicable.
Currently for non-ETS 100 bandwidth is being reported for all traffic classes in the get operation due to hardware limitation, regardless of their TSA type.
Fix this by reporting 0 for non-ETS traffic classes.
--- drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +7 -0
@@ -158,6 +158,13 @@ static int mlx5e_dcbnl_ieee_getets(struct net_device *netdev, }memcpy (ets->tc_tsa, priv->dcbx.tc_tsa,sizeof (ets->tc_tsa)); +/* Report 0 for non ETS TSA */ +for (i =0 ; i < ets->ets_cap; i++) { +if (ets->tc_tx_bw[i] ==MLX5E_MAX_BW_ALLOC && + priv->dcbx.tc_tsa[i] !=IEEE_8021QAZ_TSA_ETS ) + ets->tc_tx_bw[i] =0 ; + } +return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 243/602 net/mlx5e: Reject unsupported CB Shaper TSA in ETS validation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Lazar <[email protected]>
[ Upstream commit 9173e1d3c7c7d49a71eee813091f9e834ec7cee5 ]
Credit Based (CB) TSA is not supported by the mlx5 driver, so reject any configurations that specify it.
--- drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +8 -0
@@ -309,6 +309,14 @@ static int mlx5e_dbcnl_validate_ets(struct net_device *netdev, } } +for (i =0 ; i <IEEE_8021QAZ_MAX_TCS ; i++) { +if (ets->tc_tsa[i] ==IEEE_8021QAZ_TSA_CB_SHAPER ) { +netdev_err (netdev, +"Failed to validate ETS: CB Shaper is not supported\n" ); +return -EOPNOTSUPP ; + } + } +/* Validate Bandwidth Sum */ for (i =0 ; i <IEEE_8021QAZ_MAX_TCS ; i++) {if (ets->tc_tsa[i] ==IEEE_8021QAZ_TSA_ETS ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 244/602 octeontx2-pf: tc: fix egress ratelimiting
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hariprasad Kelam <[email protected]>
[ Upstream commit bb0d96ebe5f4d1acccf4dc36ca7f01f9a8fa1ba1 ]
The egress rate calculation computes an incorrect mantissa and exponent, causing up to ~50% deviation from the configured rate at lower speeds.
Rework the computation to follow the hardware rate formula:
rate = 2 * (1 + mantissa/256) * 2^exp / (1 << div_exp)
Keep div_exp = 0 and derive exp and mantissa from half of the requested rate. Rates below 2 Mbps are floored to the smallest encodable step (exp = 0, mantissa = 0).
--- .../ethernet/marvell/octeontx2/nic/otx2_tc.c | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +16 -13
@@ -30,6 +30,7 @@#define OTX2_UNSUPP_LSE_DEPTH GENMASK(6, 4)#define MCAST_INVALID_GRP (-1U) +#define RATE_MANTISSA_BITS 8struct otx2_tc_flow_stats {u64 bytes;
@@ -90,28 +91,30 @@ static void otx2_get_egress_burst_cfg(struct otx2_nic *nic, u32 burst,static void otx2_get_egress_rate_cfg (u64 maxrate,u32 *exp,u32 *mantissa,u32 *div_exp) { -u64 tmp; -/* Rate calculation by hardware * * PIR_ADD = ((256 + mantissa) << exp) / 256 * rate = (2 * PIR_ADD) / ( 1 << div_exp) * The resultant rate is in Mbps. +* +* Use div_exp = 0 and compute exp/mantissa for maxrate / 2; the +* leading factor of two yields the full rate. Rates below 2 Mbps +* are floored to the smallest step (exp = 0, mantissa = 0). */ -/* 2Mbps to 100Gbps can be expressed with div_exp = 0. -* Setting this to '0' will ease the calculation of -* exponent and mantissa. -*/ *div_exp =0 ; -if (maxrate) { - *exp =ilog2 (maxrate) ?ilog2 (maxrate) -1 :0 ; - tmp = maxrate -rounddown_pow_of_two (maxrate); -if (maxrate <MAX_RATE_MANTISSA ) - *mantissa = tmp *2 ; -else - *mantissa = tmp / (1ULL << (*exp -7 )); + maxrate = maxrate /2 ; +if (!maxrate) { +/* Rates below 2 Mbps map to the smallest step */ + *exp =0 ; + *mantissa =0 ; + }else { + *exp =ilog2 (maxrate); +/* Clear MSB and derive fractional bits */ + maxrate &= ~BIT (*exp); + *mantissa = (maxrate <<RATE_MANTISSA_BITS ) >> *exp; + } }else {/* Instead of disabling rate limiting, set all values to max */ *exp =MAX_RATE_EXPONENT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 245/602 net: ipv6: fix dif and sdif mismatch in raw6_icmp_error
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 440e274da4d1b93c7df2cb0ce893c3009dd4db55 ]
In raw6_icmp_error(), raw_v6_match() is called with inet6_iif(skb) passed to both the 'dif' and 'sdif' arguments. This is a copy-paste or typo error, as the last argument should represent the secondary interface index (sdif).
This mismatch breaks ICMPv6 error handling for IPv6 raw sockets in VRF (Virtual Routing and Forwarding) environments. When a raw socket is bound to a VRF master device, raw_v6_match() fails to find a match because it is not given the correct sdif value, causing the socket to miss relevant ICMPv6 error notifications.
Fix this by properly passing inet6_sdif(skb) as the last argument to raw_v6_match().
--- net/ipv6/raw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/raw.c +1 -1
@@ -348,7 +348,7 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr,const struct ipv6hdr *ip6h = (const struct ipv6hdr *)skb->data;if (!raw_v6_match (net, sk, nexthdr, &ip6h->saddr, &ip6h->daddr, -inet6_iif (skb),inet6_iif (skb))) +inet6_iif (skb),inet6_sdif (skb)))continue ;rawv6_err (sk, skb, type, code, inner_offset, info); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 246/602 ice: allow creating VFs when !CONFIG_ICE_SWITCHDEV
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Chen <[email protected]>
[ Upstream commit 99d0f42b0e5c57e4c02070a908aaff082881293a ]
Currently ice_eswitch_attach_vf() is called unconditionally in ice_start_vfs(), which causes VF creation to fail when CONFIG_ICE_SWITCHDEV is not defined.
Fix this by adding switchdev mode checks at the call sites before calling ice_eswitch_attach_vf(), consistent with how ice_eswitch_attach_sf() is already handled in ice_devlink_port_new(). This is similar to commit aacca7a83b97 ("ice: allow creating VFs for !CONFIG_NET_SWITCHDEV") which fixed the same issue for the previous ice_eswitch_configure() API.
--- drivers/net/ethernet/intel/ice/ice_eswitch.c | 3 --- drivers/net/ethernet/intel/ice/ice_sriov.c | 14 ++++++++------ drivers/net/ethernet/intel/ice/ice_vf_lib.c | 3 ++- 3 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ice/ice_eswitch.c +0 -3
@@ -506,9 +506,6 @@ int ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf)struct ice_repr *repr;int err; -if (!ice_is_eswitch_mode_switchdev (pf)) -return 0 ; - repr =ice_repr_create_vf (vf);if (IS_ERR (repr))return PTR_ERR (repr);
drivers/net/ethernet/intel/ice/ice_sriov.c +8 -6
@@ -596,12 +596,14 @@ static int ice_start_vfs(struct ice_pf *pf) goto teardown; } - retval =ice_eswitch_attach_vf (pf, vf); -if (retval) { -dev_err (ice_pf_to_dev (pf),"Failed to attach VF %d to eswitch, error %d" , - vf->vf_id, retval); -ice_vf_vsi_release (vf); - goto teardown; +if (ice_is_eswitch_mode_switchdev (pf)) { + retval =ice_eswitch_attach_vf (pf, vf); +if (retval) { +dev_err (ice_pf_to_dev (pf),"Failed to attach VF %d to eswitch, error %d" , + vf->vf_id, retval); +ice_vf_vsi_release (vf); + goto teardown; + } }set_bit (ICE_VF_STATE_INIT , vf->vf_states);
drivers/net/ethernet/intel/ice/ice_vf_lib.c +2 -1
@@ -811,7 +811,8 @@ void ice_reset_all_vfs(struct ice_pf *pf) }ice_vf_post_vsi_rebuild (vf); -ice_eswitch_attach_vf (pf, vf); +if (ice_is_eswitch_mode_switchdev (pf)) +ice_eswitch_attach_vf (pf, vf);mutex_unlock (&vf->cfg_lock); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 247/602 ice: fix LAG recipe to profile association
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marcin Szycik <[email protected]>
[ Upstream commit d6da9b7d48599db078aea6144997a381f8d90d45 ]
ice_init_lag() associates recipes to profiles, assuming that Link Aggregation-related profiles will always have profile ID lower than 70 (ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER). This value seems arbitrary and might not always be valid for some versions of DDP package, i.e. LAG profiles may have profile ID greater than 70. This would lead to misconfigured switch and LAG not working properly.
Fix it by checking up to maximum profile ID.
--- drivers/net/ethernet/intel/ice/ice_lag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_lag.c +1 -1
@@ -2095,7 +2095,7 @@ int ice_init_lag(struct ice_pf *pf) goto free_rcp_res;/* associate recipes to profiles */ -for (n =0 ; n <ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER ; n++) { +for (n =0 ; n <ICE_MAX_NUM_PROFILES ; n++) { err =ice_aq_get_recipe_to_profile (&pf->hw, n, &recipe_bits,NULL );if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 248/602 rds: tcp: unregister sysctl before tearing down listen socket
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang (Microsoft) <[email protected]>
[ Upstream commit 167e54c703ccd4fa028feb568b0d1002020cff86 ]
rds_tcp_exit_net() frees the per-netns RDS TCP listen socket via rds_tcp_kill_sock() before unregistering the per-netns sysctl table. Since rds_tcp_skbuf_handler() derives the netns from rtn->rds_tcp_listen_sock->sk, a concurrent sysctl write can race with netns teardown and dereference the freed socket/sk.
KASAN reports the race as:
BUG: KASAN: slab-use-after-free in rds_tcp_skbuf_handler+0x2aa/0x2e0 rds_tcp_skbuf_handler net/rds/tcp.c:721 proc_sys_call_handler fs/proc/proc_sysctl.c vfs_write fs/read_write.c __x64_sys_pwrite64 fs/read_write.c
Fix this by unregistering the RDS TCP sysctl table before calling rds_tcp_kill_sock(). unregister_net_sysctl_table() prevents new sysctl handlers from starting and waits for in-flight handlers to finish, so the listen socket can then be released safely. The fix was tested against the linked reproducer.
--- net/rds/tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/rds/tcp.c +2 -2
@@ -637,13 +637,13 @@ static void __net_exit rds_tcp_exit_net(struct net *net) {struct rds_tcp_net *rtn =net_generic (net, rds_tcp_netid); -rds_tcp_kill_sock (net); -if (rtn->rds_tcp_sysctl)unregister_net_sysctl_table (rtn->rds_tcp_sysctl);if (net != &init_net)kfree (rtn->ctl_table); + +rds_tcp_kill_sock (net); }static struct pernet_operations rds_tcp_net_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 249/602 net: airoha: fix ETS channel derivation in airoha_tc_setup_qdisc_ets()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 649ea07fc25a17aa51bff710baac1ab161022a7c ]
Derive the hardware QoS channel from opt->parent instead of opt->handle in airoha_tc_setup_qdisc_ets(). The ETS qdisc handle is either user-specified or auto-allocated by qdisc_alloc_handle() and bears no relation to the HTB leaf classid that identifies the hardware channel. HTB derives the channel from TC_H_MIN(opt->classid), and ETS is always attached as a child of an HTB leaf, so its opt->parent matches that classid. Using opt->handle instead can cause two ETS qdiscs on different HTB leaves to collide on the same hardware channel, corrupting scheduler configuration and stats.
--- drivers/net/ethernet/airoha/airoha_eth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/airoha/airoha_eth.c +1 -2
@@ -2803,8 +2803,7 @@ static int airoha_tc_setup_qdisc_ets(struct airoha_gdm_port *port,if (opt->parent ==TC_H_ROOT )return -EINVAL ; - channel =TC_H_MAJ (opt->handle) >>16 ; - channel = channel %AIROHA_NUM_QOS_CHANNELS ; + channel =TC_H_MIN (opt->parent) %AIROHA_NUM_QOS_CHANNELS ;switch (opt->command) {case TC_ETS_REPLACE :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 250/602 bpf, sockmap: Fix cork use-after-free in tcp_bpf_sendmsg()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <[email protected]>
[ Upstream commit 2d66a033864e27ab8d5e44cb36f31d9d2413bee4 ]
tcp_bpf_sendmsg() keeps msg_tx across sk_stream_wait_memory(), which drops and reacquires the socket lock. Its error path tries to decide whether msg_tx names the local temporary message by comparing it with the current value of psock->cork.
This comparison is unsafe when two threads send on the same socket:
Thread A Thread B
msg_tx = psock->cork
sk_msg_alloc() fails sk_stream_wait_memory()
releases the socket lock acquires the socket lock
completes the cork psock->cork = NULL frees the cork
reacquires the socket lock
msg_tx != psock->cork
sk_msg_free(msg_tx)
The stale cork is therefore mistaken for the local temporary message and freed again. KASAN reported:
BUG: KASAN: slab-use-after-free in sk_msg_free+0x49/0x50 Read of size 4 at addr ffff88810c908800 by task poc/90 Call Trace: sk_msg_free+0x49/0x50 tcp_bpf_sendmsg+0x14f5/0x1cc0 __sys_sendto+0x32c/0x3a0 __x64_sys_sendto+0xdb/0x1b0 Allocated by task 89: __kasan_kmalloc+0x8f/0xa0 tcp_bpf_sendmsg+0x16b3/0x1cc0 Freed by task 91: __kasan_slab_free+0x43/0x70 kfree+0x131/0x3c0 tcp_bpf_sendmsg+0xec3/0x1cc0
msg_tx can only name the stack-local tmp or the shared cork. Check for tmp directly so a changed psock->cork cannot turn a shared message into an apparent local one.
--- net/ipv4/tcp_bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_bpf.c +1 -1
@@ -590,7 +590,7 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) wait_for_memory: err =sk_stream_wait_memory (sk, &timeo);if (err) { -if (msg_tx && msg_tx != psock->cork) +if (msg_tx == &tmp)sk_msg_free (sk, msg_tx); goto out_err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 251/602 drm: renesas: rzg2l_mipi_dsi: Increase reset deassertion delay
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
commit 7cbba8a8ba0219a267844d3116dbc77cecb4fcf8 upstream.
The RZ/G2L hardware manual (Rev. 1.50, May 2025), Section 34.4.2.1, requires waiting at least 1 msec after deasserting the CMN_RSTB signal before the DSI-Tx module is ready. Increase the delay from 1 usec to 1 msec by replacing udelay(1) with fsleep(1000) for RZ/G2L SoCs.
--- drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/renesas/rz-du/rzg2l_mipi_dsi.c +1 -1
@@ -238,7 +238,7 @@ static int rzg2l_mipi_dsi_dphy_init(struif (ret <0 )return ret; -udelay (1 ); +fsleep (1000 );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 252/602 drm/rockchip: cdn-dp: add missing check in cdn_dp_config_video()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Shtylyov <[email protected]>
commit 46c31e1604d121221167cb09380de8c7d53290b9 upstream.
The result of cdn_dp_reg_write() is checked everywhere (with the error being logged by the callers) except one place in cdn_dp_config_video(). Add the missing result check, bailing out early on error...
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
--- drivers/gpu/drm/rockchip/cdn-dp-reg.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/rockchip/cdn-dp-reg.c +2 -0
@@ -683,6 +683,8 @@ int cdn_dp_config_video(struct cdn_dp_de val =div_u64 (8 * (symbol +1 ), bit_per_pix) - val; val +=2 ; ret =cdn_dp_reg_write (dp,DP_VC_TABLE (15 ), val); +if (ret) + goto err_config_video;switch (video->color_depth) {case 6 :