6.18.35-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 193/307 ip6: vti: Use ip6_tnl.net in vti6_changelink().
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
commit 11b326fb0a374f4654f9be22d0f0f7abd9f7d3fe upstream.
ip netns add ns1
ip netns add ns2
ip -n ns1 link add vti6_test type vti6 remote ::1 local ::2 key 7 ip -n ns1 link set vti6_test netns ns2
ip -n ns2 link set vti6_test type vti6 remote ::3 local ::4 key 9 ip netns del ns2
ip netns del ns1
[ 132.495484] ------------[ cut here ]------------ [ 132.497609] kernel BUG at net/core/dev.c:12376!
Commit 61220ab34948 ("vti6: Enable namespace changing") dropped NETIF_F_NETNS_LOCAL from vti6 devices. A vti6 tunnel can then move through IFLA_NET_NS_FD. After the move dev_net(dev) points at the new netns while t->net stays at the creation netns.
vti6_changelink() and vti6_update() still use dev_net(dev) and dev_net(t->dev). They unlink from one per netns hash and relink into another. The creation netns is left with a stale entry. cleanup_net() of that netns later walks freed memory.
Reachable from an unprivileged user namespace (unshare --user --map-root-user --net). Cross tenant scope on container hosts.
--- net/ipv6/ip6_vti.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/ipv6/ip6_vti.c +7 -5
@@ -722,10 +722,11 @@ vti6_tnl_change(struct ip6_tnl *t, conststatic int vti6_update (struct ip6_tnl *t,struct __ip6_tnl_parm *p,bool keep_mtu) { -struct net *net =dev_net (t->dev); -struct vti6_net *ip6n =net_generic (net, vti6_net_id); +struct net *net = t->net; +struct vti6_net *ip6n;int err; + ip6n =net_generic (net, vti6_net_id);vti6_tnl_unlink (ip6n, t);synchronize_net (); err =vti6_tnl_change (t, p, keep_mtu);
@@ -1036,11 +1037,12 @@ static int vti6_changelink(struct net_destruct nlattr *data[], struct netlink_ext_ack *extack) { - struct ip6_tnl *t; + struct ip6_tnl *t = netdev_priv(dev); +struct net *net = t->net;struct __ip6_tnl_parm p; -struct net *net =dev_net (dev); -struct vti6_net *ip6n =net_generic (net, vti6_net_id); +struct vti6_net *ip6n; + ip6n =net_generic (net, vti6_net_id);if (dev == ip6n->fb_tnl_dev)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 194/307 net: skbuff: fix missing zerocopy reference in pskb_carve helpers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minh Nguyen <[email protected]>
commit 98d0912e9f841e5529a5b89a972805f34cb1c69d upstream.
pskb_carve_inside_header() and pskb_carve_inside_nonlinear() both copy the old skb_shared_info header into a new buffer via memcpy(), which includes the destructor_arg pointer (uarg) for MSG_ZEROCOPY skbs. Neither function calls net_zcopy_get() for the new shinfo, creating an unaccounted holder: every skb_shared_info with destructor_arg set will call skb_zcopy_clear() once when freed, but the corresponding net_zcopy_get() was never called for the new copy. Repeated calls drive uarg->refcnt to zero prematurely, freeing ubuf_info_msgzc while TX skbs still hold live destructor_arg pointers.
KASAN reports use-after-free on a freed ubuf_info_msgzc:
BUG: KASAN: slab-use-after-free in skb_release_data+0x77b/0x810 Read of size 8 at addr ffff88801574d3e8 by task poc/220 Call Trace: skb_release_data+0x77b/0x810 kfree_skb_list_reason+0x13e/0x610 skb_release_data+0x4cd/0x810 sk_skb_reason_drop+0xf3/0x340 skb_queue_purge_reason+0x282/0x440 rds_tcp_inc_free+0x1e/0x30 rds_recvmsg+0x354/0x1780 __sys_recvmsg+0xdf/0x180 Allocated by task 219: msg_zerocopy_realloc+0x157/0x7b0 tcp_sendmsg_locked+0x2892/0x3ba0 Freed by task 219: ip_recv_error+0x74a/0xb10 tcp_recvmsg+0x475/0x530
The skb consuming the late access still referenced the same uarg via shinfo->destructor_arg copied by pskb_carve_inside_nonlinear() without a refcount bump. This has been verified to be reliably exploitable: a working proof-of-concept achieves full root privilege escalation from an unprivileged local user on a default kernel configuration.
The fix follows the pattern of pskb_expand_head() which has the same memcpy/cloned structure. For pskb_carve_inside_header(), net_zcopy_get() is placed after skb_orphan_frags() succeeds, so the orphan error path needs no cleanup. For pskb_carve_inside_nonlinear(), net_zcopy_get() is placed after all failure points and just before skb_release_data(), so no error path needs cleanup at all -- matching pskb_expand_head() more closely and avoiding the need for a balancing net_zcopy_put().
--- net/core/skbuff.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/skbuff.c +4 -0
@@ -6704,6 +6704,8 @@ static int pskb_carve_inside_header(struskb_kfree_head (data, size);return -ENOMEM ; } +if (skb_zcopy (skb)) +net_zcopy_get (skb_zcopy (skb));for (i =0 ; i <skb_shinfo (skb)->nr_frags; i++)skb_frag_ref (skb, i);if (skb_has_frag_list (skb))
@@ -6853,6 +6855,8 @@ static int pskb_carve_inside_nonlinear(sskb_kfree_head (data, size);return -ENOMEM ; } +if (skb_zcopy (skb)) +net_zcopy_get (skb_zcopy (skb));skb_release_data (skb,SKB_CONSUMED ); skb->head = data;
Greg Kroah-Hartman
maintainerPATCH 195/307 HID: wacom: Fix OOB write in wacom_hid_set_device_mode()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lee Jones <[email protected]>
commit c0a8899e02ddebd51e2589835182c239c2e224ae upstream.
wacom_hid_set_device_mode() currently assumes that the HID_DG_INPUTMODE usage is always located in the first field (field[0]) of the feature report. However, a device can specify HID_DG_INPUTMODE in a different field.
If HID_DG_INPUTMODE is in a field other than the first one and the first field has a report_count smaller than the usage_index of HID_DG_INPUTMODE, this leads to an out-of-bounds write to r->field[0]->value.
Fix this by storing the field index of HID_DG_INPUTMODE in 'struct hid_data' during feature mapping. In wacom_hid_set_device_mode(), use this stored field index to access the correct field and add bounds checks to ensure both the field index and the value index are within valid ranges before writing.
--- drivers/hid/wacom_sys.c | 13 ++++++++++--- drivers/hid/wacom_wac.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/hid/wacom_sys.c +10 -3
@@ -341,6 +341,7 @@ static void wacom_feature_mapping(struct hid_data->inputmode = field->report->id; hid_data->inputmode_index = usage->usage_index; + hid_data->inputmode_field_index = field->index;break ;case HID_UP_DIGITIZER :
@@ -556,9 +557,14 @@ static int wacom_hid_set_device_mode(str re = &(hdev->report_enum[HID_FEATURE_REPORT ]); r = re->report_id_hash[hid_data->inputmode]; -if (r) { - r->field[0 ]->value[hid_data->inputmode_index] =2 ; -hid_hw_request (hdev, r,HID_REQ_SET_REPORT ); +if (r && hid_data->inputmode_field_index >=0 && + hid_data->inputmode_field_index < r->maxfield) { +struct hid_field *field = r->field[hid_data->inputmode_field_index]; + +if (field && hid_data->inputmode_index < field->report_count) { + field->value[hid_data->inputmode_index] =2 ; +hid_hw_request (hdev, r,HID_REQ_SET_REPORT ); + } }return 0 ; }
@@ -2819,6 +2825,7 @@ static int wacom_probe(struct hid_devicereturn error; wacom_wac->hid_data.inputmode =-1 ; + wacom_wac->hid_data.inputmode_field_index =-1 ; wacom_wac->mode_report =-1 ;if (hid_is_usb (hdev)) {
drivers/hid/wacom_wac.h +1 -0
@@ -298,6 +298,7 @@ struct wacom_shared {struct hid_data {__s16 inputmode;/* InputMode HID feature, -1 if non-existent */ __s16 inputmode_index;/* InputMode HID feature index in the report */ +__s16 inputmode_field_index;/* InputMode HID feature field index in the report */ bool sense_state;bool inrange_state;bool invert_state;
Greg Kroah-Hartman
maintainerPATCH 196/307 iommu, debugobjects: avoid gcc-16.1 section mismatch warnings
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 4c9ad387aa2d6785299722e54224d34764edaeb3 upstream.
gcc-16 has gained some more advanced inter-procedual optimization techniques that enable it to inline the dummy_tlb_add_page() and dummy_tlb_flush() function pointers into a specialized version of __arm_v7s_unmap:
WARNING: modpost: vmlinux: section mismatch in reference: __arm_v7s_unmap+0x2cc (section: .text) -> dummy_tlb_add_page (section: .init.text)
ERROR: modpost: Section mismatches detected.
Quoted 1 line
From what I can tell, the transformation is correct, as this is only
called when __arm_v7s_unmap() is called from arm_v7s_do_selftests(), which is also __init. Since __arm_v7s_unmap() however is not __init, gcc cannot inline the inner function calls directly.
In debug_objects_selftest(), the same thing happens. Both the caller and the leaf function are __init, but the IPA pulls it into a non-init one:
WARNING: modpost: vmlinux: section mismatch in reference: lookup_object_or_alloc+0x7c (section: .text.lookup_object_or_alloc) -> is_static_object (section: .init.text)
Marking the affected functions as not "__init" would reliably avoid this issue but is not a good solution because it removes an otherwise correct annotation. I tried marking the functions as 'noinline', but that ended up not covering all the affected configurations.
With some more experimenting, I found that marking these functions as __attribute__((noipa)) is both logical and reliable.
In order to keep the syntax readable, add a custom macro for this in include/linux/compiler_attributes.h next to other related macros and use it to annotate both files.
--- drivers/iommu/io-pgtable-arm-v7s.c | 18 ++++++++++++------ include/linux/compiler_attributes.h | 11 +++++++++++ lib/debugobjects.c | 2 +- 3 files changed, 24 insertions(+), 7 deletions(-)
drivers/iommu/io-pgtable-arm-v7s.c +12 -6
@@ -894,21 +894,27 @@ struct io_pgtable_init_fns io_pgtable_arstatic struct io_pgtable_cfg *cfg_cookie__initdata ; -static void __init dummy_tlb_flush_all (void *cookie) +/* +* __noipa prevents gcc from turning indirect iommu_flush_ops calls +* into direct calls from a specialized __arm_v7s_unmap() that triggers +* a build time section mismatch assertion. +*/ +static __noipa void __init dummy_tlb_flush_all(void *cookie) {WARN_ON (cookie != cfg_cookie); } -static void __init dummy_tlb_flush (unsigned long iova,size_t size, -size_t granule,void *cookie) +static __noipa void __init dummy_tlb_flush(unsigned long iova, size_t size, +size_t granule,void *cookie) {WARN_ON (cookie != cfg_cookie);WARN_ON (!(size & cfg_cookie->pgsize_bitmap)); } -static void __init dummy_tlb_add_page (struct iommu_iotlb_gather *gather, -unsigned long iova,size_t granule, -void *cookie) +static __noipa void __init dummy_tlb_add_page(struct iommu_iotlb_gather *gather, +unsigned long iova, +size_t granule, +void *cookie) {dummy_tlb_flush (iova, granule, granule, cookie); }
include/linux/compiler_attributes.h +11 -0
@@ -397,6 +397,17 @@#endif /* +* Optional: not supported by clang +* +* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-noipa +*/ +#if __has_attribute (noipa) +# define __noipa __attribute__((noipa)) +#else +# define __noipa +#endif + +/* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-weak-function-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-weak-variable-attribute */
lib/debugobjects.c +1 -1
@@ -1075,7 +1075,7 @@ struct self_test {static __initconst const struct debug_obj_descr descr_type_test; -static bool __init is_static_object (void *addr) +static __noipa bool __init is_static_object(void *addr) {struct self_test *obj = addr;
Greg Kroah-Hartman
maintainerPATCH 197/307 nfc: hci: fix out-of-bounds read in HCP header parsing
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ashutosh Desai <[email protected]>
commit f040e590c035bfd9553fe79ee9585caf1b14d67b upstream.
Both nfc_hci_recv_from_llc() and nci_hci_data_received_cb() read packet->header from skb->data at function entry without first checking that the buffer holds at least one byte. A malicious NFC peer can send a 0-byte HCP frame that passes through the SHDLC layer and reaches these functions, causing an out-of-bounds heap read of packet->header. The same 0-byte frame, if queued as a non-final fragment, also causes the reassembly loop to underflow msg_len to UINT_MAX, triggering skb_over_panic() when the reassembled skb is written.
Fix this by adding a pskb_may_pull() check at the entry of each function before packet->header is first accessed. The existing pskb_may_pull() checks before the reassembled hcp_skb is cast to struct hcp_packet remain in place to guard the 2-byte HCP message header.
--- net/nfc/hci/core.c | 10 ++++++++++ net/nfc/nci/hci.c | 10 ++++++++++ 2 files changed, 20 insertions(+)
net/nfc/hci/core.c +10 -0
@@ -861,6 +861,11 @@ static void nfc_hci_recv_from_llc(structstruct sk_buff *frag_skb;int msg_len; +if (!pskb_may_pull (skb,NFC_HCI_HCP_PACKET_HEADER_LEN )) { +kfree_skb (skb); +return ; + } + packet = (struct hcp_packet *)skb->data;if ((packet->header & ~NFC_HCI_FRAGMENT ) ==0 ) {skb_queue_tail (&hdev->rx_hcp_frags, skb);
@@ -904,6 +909,11 @@ static void nfc_hci_recv_from_llc(struct* unblock waiting cmd context. Otherwise, enqueue to dispatch * in separate context where handler can also execute command. */ +if (!pskb_may_pull (hcp_skb,NFC_HCI_HCP_HEADER_LEN )) { +kfree_skb (hcp_skb); +return ; + } + packet = (struct hcp_packet *)hcp_skb->data; type =HCP_MSG_GET_TYPE (packet->message.header);if (type ==NFC_HCI_HCP_RESPONSE ) {
net/nfc/nci/hci.c +10 -0
@@ -439,6 +439,11 @@ void nci_hci_data_received_cb(void *contreturn ; } +if (!pskb_may_pull (skb,NCI_HCI_HCP_PACKET_HEADER_LEN )) { +kfree_skb (skb); +return ; + } + packet = (struct nci_hcp_packet *)skb->data;if ((packet->header & ~NCI_HCI_FRAGMENT ) ==0 ) {skb_queue_tail (&ndev->hci_dev->rx_hcp_frags, skb);
@@ -482,6 +487,11 @@ void nci_hci_data_received_cb(void *cont* unblock waiting cmd context. Otherwise, enqueue to dispatch * in separate context where handler can also execute command. */ +if (!pskb_may_pull (hcp_skb,NCI_HCI_HCP_HEADER_LEN )) { +kfree_skb (hcp_skb); +return ; + } + packet = (struct nci_hcp_packet *)hcp_skb->data; type =NCI_HCP_MSG_GET_TYPE (packet->message.header);if (type ==NCI_HCI_HCP_RESPONSE ) {
Greg Kroah-Hartman
maintainerPATCH 198/307 xfrm: route MIGRATE notifications to callers netns
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maoyi Xie <[email protected]>
commit 7e2a4f7ca0952820731ef7bdadfc9a9e9d3571b4 upstream.
xfrm_send_migrate() in net/xfrm/xfrm_user.c and pfkey_send_migrate() in net/key/af_key.c both hardcode &init_net for the multicast that announces a successful XFRM_MSG_MIGRATE / SADB_X_MIGRATE.
XFRM_MSG_MIGRATE arrives on a per-netns NETLINK_XFRM socket, and the rest of the xfrm/af_key netlink path was made netns-aware in 2008. The other 14 multicast paths in xfrm_user.c route their event using xs_net(x), xp_net(xp) or sock_net(skb->sk); only the migrate path was missed.
Two consequences of the init_net hardcoding:
1. The notification (selector, old/new endpoint addresses, and the km_address) is delivered to listeners on init_net's XFRMNLGRP_MIGRATE / pfkey BROADCAST_ALL groups rather than on the issuing netns. An IKE daemon running in init_net therefore receives migration notifications originating from any other netns on the host.
2. An IKE daemon running inside a non-init netns and subscribed to its own XFRMNLGRP_MIGRATE / pfkey groups never receives the notification of its own migration. IKEv2 MOBIKE / address-update handling inside a netns is silently broken.
Thread struct net through km_migrate() and the xfrm_mgr.migrate function pointer, drop the &init_net override in xfrm_send_migrate() and pfkey_send_migrate(), and pass the caller's net (already in scope in xfrm_migrate() via sock_net(skb->sk)) all the way down. struct xfrm_mgr is in-tree only and not exported as a stable API, so the function-pointer signature change is internal.
pfkey_broadcast() is already netns-aware via net_generic(net, pfkey_net_id) since the pernet conversion. The five other pfkey_broadcast() callers in af_key.c already pass xs_net(x), sock_net(sk) or a per-netns net, so this only removes the &init_net outlier.
--- include/net/xfrm.h | 3 ++- net/key/af_key.c | 6 +++--- net/xfrm/xfrm_policy.c | 2 +- net/xfrm/xfrm_state.c | 4 ++-- net/xfrm/xfrm_user.c | 5 ++--- 5 files changed, 10 insertions(+), 10 deletions(-)
include/net/xfrm.h +2 -1
@@ -650,6 +650,7 @@ struct xfrm_mgr {const struct xfrm_migrate *m, int num_bundles, const struct xfrm_kmaddress *k, + struct net *net, const struct xfrm_encap_tmpl *encap);bool (*is_alive)(const struct km_event *c); };
@@ -1818,7 +1819,7 @@ int xfrm_sk_policy_insert(struct sock *s#ifdef CONFIG_XFRM_MIGRATE int km_migrate (const struct xfrm_selector *sel,u8 dir,u8 type,const struct xfrm_migrate *m,int num_bundles, -const struct xfrm_kmaddress *k, +const struct xfrm_kmaddress *k,struct net *net,const struct xfrm_encap_tmpl *encap);struct xfrm_state *xfrm_migrate_state_find (struct xfrm_migrate *m,struct net *net,u32 if_id);
net/key/af_key.c +3 -3
@@ -3564,7 +3564,7 @@ static int set_ipsecrequest(struct sk_bu#ifdef CONFIG_NET_KEY_MIGRATE static int pfkey_send_migrate (const struct xfrm_selector *sel,u8 dir,u8 type,const struct xfrm_migrate *m,int num_bundles, -const struct xfrm_kmaddress *k, +const struct xfrm_kmaddress *k,struct net *net,const struct xfrm_encap_tmpl *encap) {int i;
@@ -3669,7 +3669,7 @@ static int pfkey_send_migrate(const stru }/* broadcast migrate message to sockets */ -pfkey_broadcast (skb,GFP_ATOMIC ,BROADCAST_ALL ,NULL , &init_net); +pfkey_broadcast (skb,GFP_ATOMIC ,BROADCAST_ALL ,NULL , net);return 0 ;
@@ -3680,7 +3680,7 @@ err:#else static int pfkey_send_migrate (const struct xfrm_selector *sel,u8 dir,u8 type,const struct xfrm_migrate *m,int num_bundles, -const struct xfrm_kmaddress *k, +const struct xfrm_kmaddress *k,struct net *net,const struct xfrm_encap_tmpl *encap) {return -ENOPROTOOPT ;
net/xfrm/xfrm_policy.c +1 -1
@@ -4690,7 +4690,7 @@ int xfrm_migrate(const struct xfrm_selec }/* Stage 5 - announce */ -km_migrate (sel, dir, type, m, num_migrate, k, encap); +km_migrate (sel, dir, type, m, num_migrate, k, net, encap);xfrm_pol_put (pol);
net/xfrm/xfrm_state.c +2 -2
@@ -2745,7 +2745,7 @@ EXPORT_SYMBOL(km_policy_expired);#ifdef CONFIG_XFRM_MIGRATE int km_migrate (const struct xfrm_selector *sel,u8 dir,u8 type,const struct xfrm_migrate *m,int num_migrate, -const struct xfrm_kmaddress *k, +const struct xfrm_kmaddress *k,struct net *net,const struct xfrm_encap_tmpl *encap) {int err = -EINVAL ;
@@ -2756,7 +2756,7 @@ int km_migrate(const struct xfrm_selectolist_for_each_entry_rcu (km, &xfrm_km_list, list) {if (km->migrate) { ret = km->migrate (sel, dir, type, m, num_migrate, k, - encap); + net, encap);if (!ret) err = ret; }
net/xfrm/xfrm_user.c +2 -3
@@ -3183,10 +3183,9 @@ out_cancel:static int xfrm_send_migrate (const struct xfrm_selector *sel,u8 dir,u8 type,const struct xfrm_migrate *m,int num_migrate, -const struct xfrm_kmaddress *k, +const struct xfrm_kmaddress *k,struct net *net,const struct xfrm_encap_tmpl *encap) { -struct net *net = &init_net;struct sk_buff *skb;int err;
@@ -3204,7 +3203,7 @@ static int xfrm_send_migrate(const struc#else static int xfrm_send_migrate (const struct xfrm_selector *sel,u8 dir,u8 type,const struct xfrm_migrate *m,int num_migrate, -const struct xfrm_kmaddress *k, +const struct xfrm_kmaddress *k,struct net *net,const struct xfrm_encap_tmpl *encap) {return -ENOPROTOOPT ;
Greg Kroah-Hartman
maintainerPATCH 199/307 xfrm: ah: use skb_to_full_sk in async output callbacks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 79d8be262377f7112cfa3088dfc4142d5a2533f3 upstream.
When AH output is offloaded to an asynchronous crypto provider (hardware accelerators such as AMD CCP, or a forced-async software shim used for testing), the digest completion fires ah_output_done() / ah6_output_done() on a workqueue. The egress skb at that point may have been originated by a TCP listener sending a SYN-ACK, which sets skb->sk to a request_sock via skb_set_owner_edemux(); it may also have been originated by an inet_timewait_sock retransmit. Neither is a full struct sock, and passing the raw skb->sk to xfrm_output_resume() then forwards a non-full socket through the rest of the xfrm output chain.
xfrm_output_resume() and its downstream consumers expect a full sk where they dereference at all. The natural egress path through ah_output_done() does not crash today because the consumers that read past sock_common are either gated by sk_fullsock() or short-circuit on flags that are clear on a fresh request_sock; an exhaustive walk of the 50 most plausible consumers under sch_fq, dev_queue_xmit, netfilter, tc-egress and cgroup-egress BPF found no current unguarded deref. The bug is still a real type confusion that future consumer changes could turn into a memory-corruption primitive.
This is the same bug class fixed for ESP in commit 1620c88887b1 ("xfrm: Fix the usage of skb->sk"). Apply the analogous fix to
AH: convert skb->sk to a full socket pointer (or NULL) via skb_to_full_sk() before handing it to xfrm_output_resume().
The same async AH callbacks were touched recently for an independent ESN-related ICV layout bug in commit ec54093e6a8f ("xfrm: ah: account for ESN high bits in async callbacks"); the sk type-confusion addressed here is orthogonal. This patch is part of an ongoing audit of the AH callback paths; an ah_output ihl-validation hardening series is also currently under review on netdev.
Reproduced under UML + KASAN + lockdep with a forced-async hmac(sha1) shim that registers at priority 9999 and wraps the sync in-tree hmac-sha1-lib. With the shim loaded, ah_output_done runs on every SYN-ACK egress through a transport-mode AH SA and skb->sk arrives as a request_sock (TCP_NEW_SYN_RECV); after this patch, xfrm_output_resume() receives the listener (the result of sk_to_full_sk()) and consumer derefs land on full-sock fields as intended.
--- net/ipv4/ah4.c | 2 +- net/ipv6/ah6.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/ah4.c +1 -1
@@ -143,7 +143,7 @@ static void ah_output_done(void *data, i }kfree (AH_SKB_CB (skb)->tmp); -xfrm_output_resume (skb->sk, skb, err); +xfrm_output_resume (skb_to_full_sk (skb), skb, err); }static int ah_output (struct xfrm_state *x,struct sk_buff *skb)
net/ipv6/ah6.c +1 -1
@@ -337,7 +337,7 @@ static void ah6_output_done(void *data,ah6_restore_hdrs (top_iph, iph_ext, extlen);kfree (AH_SKB_CB (skb)->tmp); -xfrm_output_resume (skb->sk, skb, err); +xfrm_output_resume (skb_to_full_sk (skb), skb, err); }static int ah6_output (struct xfrm_state *x,struct sk_buff *skb)
Greg Kroah-Hartman
maintainerPATCH 200/307 ALSA: scarlett2: Fix 2i2 Gen 4 direct monitor gain on firmware 2417
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geoffrey D. Bennett <[email protected]>
commit db37cf47b67e38ade40de5cd74a4d4d772ff1416 upstream.
Firmware 2417 for the Scarlett 4th Gen 2i2 moved the direct monitor gain parameter by 4 bytes, from offset 0x2a0 to 0x2a4, breaking the "Direct Monitor X Mix Y" controls.
Special-case the offset in the get/set config helpers when the running firmware is 2417 or later.
--- sound/usb/mixer_scarlett2.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)
sound/usb/mixer_scarlett2.c +29 -4
@@ -2467,6 +2467,27 @@ static int scarlett2_has_config_item(return !!private->config_set->items[config_item_num].offset; } +/* Return the configuration item's offset, applying any per-firmware +* overrides. +* +* Firmware 2417 for the 2i2 Gen 4 moved DIRECT_MONITOR_GAIN by 4 +* bytes. Apply that shift here so that the rest of the driver can +* keep using the single config set. This override can be removed +* once the multi-config-set framework lands. +*/ +static int scarlett2_config_item_offset ( +struct scarlett2_data *private,int config_item_num) +{ +int offset = private->config_set->items[config_item_num].offset; + +if (config_item_num ==SCARLETT2_CONFIG_DIRECT_MONITOR_GAIN && + private->info == &s2i2_gen4_info && + private->firmware_version >=2417 ) + offset =0x2a4 ; + +return offset; +} +/* Send a USB message to get configuration parameters; result placed in *buf */ static int scarlett2_usb_get_config( struct usb_mixer_interface *mixer,
@@ -2476,6 +2497,7 @@ static int scarlett2_usb_get_config(const struct scarlett2_config *config_item = &private->config_set->items[config_item_num];int size, err, i; +int item_offset;u8 *buf_8;u8 value;
@@ -2485,13 +2507,15 @@ static int scarlett2_usb_get_config(if (!config_item->offset)return -EFAULT ; + item_offset =scarlett2_config_item_offset (private, config_item_num); +/* Writes to the parameter buffer are always 1 byte */ size = config_item->size ? config_item->size :8 ;/* For byte-sized parameters, retrieve directly into buf */ if (size >=8 ) { size = size /8 * count; - err =scarlett2_usb_get (mixer, config_item->offset, buf, size); + err =scarlett2_usb_get (mixer, item_offset, buf, size);if (err <0 )return err;if (config_item->size ==16 ) {
@@ -2509,7 +2533,7 @@ static int scarlett2_usb_get_config( }/* For bit-sized parameters, retrieve into value */ - err =scarlett2_usb_get (mixer, config_item->offset, &value,1 ); + err =scarlett2_usb_get (mixer, item_offset, &value,1 );if (err <0 )return err;
@@ -2659,7 +2683,8 @@ static int scarlett2_usb_set_config(*/ if (config_item->size >=8 ) { size = config_item->size /8 ; - offset = config_item->offset + index * size; + offset =scarlett2_config_item_offset (private, config_item_num) + + index * size;/* If updating a bit, retrieve the old value, set/clear the * bit as needed, and update value
@@ -2668,7 +2693,7 @@ static int scarlett2_usb_set_config(u8 tmp; size =1 ; - offset = config_item->offset; + offset =scarlett2_config_item_offset (private, config_item_num); err =scarlett2_usb_get (mixer, offset, &tmp,1 );if (err <0 )
Greg Kroah-Hartman
maintainerPATCH 201/307 netfilter: conntrack: tcp: do not force CLOSE on invalid-seq RST without direction check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hamza Mahfooz <[email protected]>
commit bed6e04be8e6b9133d8b16d5a42d0e0ce674fa9a upstream.
An unintended behavior in the TCP conntrack state machine allows a connection to be forced into the CLOSE state using an RST packet with an invalid sequence number.
Specifically, after a SYN packet is observed, an RST with an invalid SEQ can transition the conntrack entry to TCP_CONNTRACK_CLOSE, regardless of whether the RST corresponds to the expected reply direction. The relevant code path assumes the RST is a response to an outgoing SYN, but does not validate packet direction or ensure that a matching SYN was actually sent in the opposite direction.
As a result, a crafted packet sequence consisting of a SYN followed by an invalid-sequence RST can prematurely terminate an active NAT entry. This makes connection teardown easier than intended.
So, tighten the state transition logic to ensure that RST-triggered CLOSE transitions only occur when the RST is a valid response to a previously observed SYN in the correct direction.
--- net/netfilter/nf_conntrack_proto_tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nf_conntrack_proto_tcp.c +2 -1
@@ -1221,7 +1221,8 @@ int nf_conntrack_tcp_packet(struct nf_co new_state = old_state; }if (((test_bit (IPS_SEEN_REPLY_BIT , &ct->status) - && ct->proto.tcp.last_index ==TCP_SYN_SET ) + && ct->proto.tcp.last_index ==TCP_SYN_SET + && ct->proto.tcp.last_dir != dir) || (!test_bit (IPS_ASSURED_BIT , &ct->status) && ct->proto.tcp.last_index ==TCP_ACK_SET )) &&ntohl (th->ack_seq) == ct->proto.tcp.last_end) {
Greg Kroah-Hartman
maintainerPATCH 202/307 ASoC: qcom: q6asm-dai: close stream only when running
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 048c540ee76ded666bda74f9dae1ca3254e0633c upstream.
q6asm_dai_close() and q6asm_dai_compr_free() currently issue CMD_CLOSE whenever prtd->state is non-zero.
After prepare() closes an existing stream, the state is updated to Q6ASM_STREAM_STOPPED. Since this state is also non-zero, the close and free paths can send CMD_CLOSE again for a stream that has already been closed.
Restrict CMD_CLOSE to the Q6ASM_STREAM_RUNNING state so the command is sent only when the ASM stream is still active.
--- sound/soc/qcom/qdsp6/q6asm-dai.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
sound/soc/qcom/qdsp6/q6asm-dai.c +7 -7
@@ -446,12 +446,12 @@ static int q6asm_dai_close(struct snd_sostruct q6asm_dai_rtd *prtd = runtime->private_data;if (prtd->audio_client) { -if (prtd->state) +if (prtd->state ==Q6ASM_STREAM_RUNNING ) {q6asm_cmd (prtd->audio_client, prtd->stream_id,CMD_CLOSE ); - -q6asm_unmap_memory_regions (substream->stream, +q6asm_unmap_memory_regions (substream->stream, prtd->audio_client); + }q6asm_audio_client_free (prtd->audio_client); prtd->audio_client =NULL ; }
@@ -668,7 +668,7 @@ static int q6asm_dai_compr_free(struct sstruct snd_soc_pcm_runtime *rtd = stream->private_data;if (prtd->audio_client) { -if (prtd->state) { +if (prtd->state ==Q6ASM_STREAM_RUNNING ) {q6asm_cmd (prtd->audio_client, prtd->stream_id,CMD_CLOSE );if (prtd->next_track_stream_id) {
@@ -676,11 +676,11 @@ static int q6asm_dai_compr_free(struct s prtd->next_track_stream_id, CMD_CLOSE); } - } -snd_dma_free_pages (&prtd->dma_buffer); -q6asm_unmap_memory_regions (stream->direction, +q6asm_unmap_memory_regions (stream->direction, prtd->audio_client); + } +snd_dma_free_pages (&prtd->dma_buffer);q6asm_audio_client_free (prtd->audio_client); prtd->audio_client =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 203/307 ASoC: qcom: q6asm-dai: do not set stream state in event and trigger callbacks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit cee3e63e7106c3c81b2053371fdf14240bfba2fc upstream.
The q6asm-dai stream state is used by prepare() to decide whether an existing stream setup needs to be closed before opening/configuring a new one. Updating the state from trigger or asynchronous DSP callbacks can make that state stale or incorrect relative to the actual setup lifetime.
In particular, setting Q6ASM_STREAM_STOPPED on STOP or EOS completion can make prepare() believe there is no active setup to close, which can result in opening/configuring the same stream more than once.
Keep stream state updates tied to prepare(), where the stream is actually closed and reopened, and stop changing it from trigger and EOS callbacks.
--- sound/soc/qcom/qdsp6/q6asm-dai.c | 5 ----- 1 file changed, 5 deletions(-)
sound/soc/qcom/qdsp6/q6asm-dai.c +0 -5
@@ -186,7 +186,6 @@ static void event_handler(uint32_t opcod prtd->pcm_count, 0, 0, 0);break ;case ASM_CLIENT_EVENT_CMD_EOS_DONE : - prtd->state =Q6ASM_STREAM_STOPPED ;break ;case ASM_CLIENT_EVENT_DATA_WRITE_DONE : { prtd->pcm_irq_pos += prtd->pcm_count;
@@ -333,7 +332,6 @@ static int q6asm_dai_trigger(struct snd_ 0, 0, 0);break ;case SNDRV_PCM_TRIGGER_STOP : - prtd->state =Q6ASM_STREAM_STOPPED ; ret =q6asm_cmd_nowait (prtd->audio_client, prtd->stream_id,CMD_EOS );break ;
@@ -544,8 +542,6 @@ static void compress_event_handler(uint3snd_compr_drain_notify (prtd->cstream); prtd->notify_on_drain = false; - }else { - prtd->state =Q6ASM_STREAM_STOPPED ; }spin_unlock_irqrestore (&prtd->lock, flags);break ;
@@ -1008,7 +1004,6 @@ static int q6asm_dai_compr_trigger(struc 0, 0, 0);break ;case SNDRV_PCM_TRIGGER_STOP : - prtd->state =Q6ASM_STREAM_STOPPED ; ret =q6asm_cmd_nowait (prtd->audio_client, prtd->stream_id,CMD_EOS );break ;
Greg Kroah-Hartman
maintainerPATCH 204/307 xfrm: esp: restore combined single-frag length gate
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jingguo Tan <[email protected]>
commit dfa0d7b0ff1eb6b2c416b8fdb9b4f2cefba57a40 upstream.
The ESP out-of-place fast path appends the trailer in esp_output_head() before esp_output_tail() allocates the destination page frag. The head-side gate currently checks skb->data_len and tailen separately, but the tail code allocates a single destination frag from the combined post-trailer skb->data_len.
Reject the page-frag fast path when the combined aligned length exceeds a page. Otherwise skb_page_frag_refill() may fall back to a single page while the destination sg still spans the combined skb->data_len.
Restore this combined-length page gate for both IPv4 and IPv6.
--- net/ipv4/esp4.c | 4 ++-- net/ipv6/esp6.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
net/ipv4/esp4.c +2 -2
@@ -419,8 +419,8 @@ int esp_output_head(struct xfrm_state *xreturn err; } -if (ALIGN (tailen,L1_CACHE_BYTES ) >PAGE_SIZE || -ALIGN (skb->data_len,L1_CACHE_BYTES ) >PAGE_SIZE ) +if (ALIGN (skb->data_len + tailen,L1_CACHE_BYTES ) > +PAGE_SIZE ) goto cow;if (!skb_cloned (skb)) {
net/ipv6/esp6.c +2 -2
@@ -448,8 +448,8 @@ int esp6_output_head(struct xfrm_state *return err; } -if (ALIGN (tailen,L1_CACHE_BYTES ) >PAGE_SIZE || -ALIGN (skb->data_len,L1_CACHE_BYTES ) >PAGE_SIZE ) +if (ALIGN (skb->data_len + tailen,L1_CACHE_BYTES ) > +PAGE_SIZE ) goto cow;if (!skb_cloned (skb)) {
Greg Kroah-Hartman
maintainerPATCH 205/307 Input: xpad - add "Nova 2 Lite" from GameSir
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qbeliw Tanaka <[email protected]>
commit 1f6ac0f8441c48c4cc250141e1da8486c13512ba upstream.
Add support for the gamepad "Nova 2 Lite" from GameSir, compatible with the Xbox 360 gamepad.
--- drivers/input/joystick/xpad.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/joystick/xpad.c +1 -0
@@ -415,6 +415,7 @@ static const struct xpad_device { { 0x3285, 0x0662, "Nacon Revolution5 Pro", 0, XTYPE_XBOX360 }, { 0x3285, 0x0663, "Nacon Evol-X", 0, XTYPE_XBOXONE }, { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 }, + { 0x3537, 0x100f, "GameSir Nova 2 Lite", 0, XTYPE_XBOX360 }, { 0x3537, 0x1010, "GameSir G7 SE", 0, XTYPE_XBOXONE }, { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, { 0x413d, 0x2104, "Black Shark Green Ghost Gamepad", 0, XTYPE_XBOX360 },
Greg Kroah-Hartman
maintainerPATCH 206/307 Input: xpad - add support for ASUS ROG RAIKIRI II
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitriy Zharov <[email protected]>
commit c897cf120696b94f56ed0f3197ba9a77071a59ec upstream.
Add the VID/PIDs for the ASUS ROG RAIKIRI II controller to xpad_device and the VID to xpad_table. The controller has a physical PC/XBOX toggle which switches between XBOX360 and XBOXONE protocols.
--- drivers/input/joystick/xpad.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/input/joystick/xpad.c +5 -0
@@ -215,6 +215,10 @@ static const struct xpad_device { { 0x07ff, 0xffff, "Mad Catz GamePad", 0, XTYPE_XBOX360 }, { 0x0b05, 0x1a38, "ASUS ROG RAIKIRI", MAP_SHARE_BUTTON, XTYPE_XBOXONE }, { 0x0b05, 0x1abb, "ASUS ROG RAIKIRI PRO", 0, XTYPE_XBOXONE }, + { 0x0b05, 0x1c91, "ASUS ROG RAIKIRI II", 0, XTYPE_XBOX360 }, + { 0x0b05, 0x1c92, "ASUS ROG RAIKIRI II WIRELESS", 0, XTYPE_XBOX360 }, + { 0x0b05, 0x1c96, "ASUS ROG RAIKIRI II XBOX", MAP_SHARE_BUTTON, XTYPE_XBOXONE }, + { 0x0b05, 0x1d04, "ASUS ROG RAIKIRI II XBOX WIRELESS", MAP_SHARE_BUTTON, XTYPE_XBOXONE }, { 0x0c12, 0x0005, "Intec wireless", 0, XTYPE_XBOX }, { 0x0c12, 0x8801, "Nyko Xbox Controller", 0, XTYPE_XBOX }, { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
@@ -528,6 +532,7 @@ static const struct usb_device_id xpad_t { USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */XPAD_XBOXONE_VENDOR (0x0738 ),/* Mad Catz FightStick TE 2 */ XPAD_XBOX360_VENDOR (0x07ff ),/* Mad Catz Gamepad */ +XPAD_XBOX360_VENDOR (0x0b05 ),/* ASUS controllers */ XPAD_XBOXONE_VENDOR (0x0b05 ),/* ASUS controllers */ XPAD_XBOX360_VENDOR (0x0c12 ),/* Zeroplus X-Box 360 controllers */ XPAD_XBOX360_VENDOR(0x0db0), /* Micro Star International X-Box 360 controllers */
Greg Kroah-Hartman
maintainerPATCH 207/307 ksmbd: OOB read regression in smb_check_perm_dacl() ACE-walk loops
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ganiyev <[email protected]>
commit 0e60dafe97eca61721f3db456f97d97a80c6c8ae upstream.
Commit d07b26f39246 ("ksmbd: require minimum ACE size in smb_check_perm_dacl()") introduced a transposed bounds check:
if (offsetof(struct smb_ace, sid) + aces_size < CIFS_SID_BASE_SIZE)
Since offsetof(..sid) is 8 and CIFS_SID_BASE_SIZE is 8, this evaluates to aces_size < 0. Because aces_size is always non-negative, this check becomes dead code and never breaks the loop.
Worse, that commit removed the old 4-byte guard, meaning the loop now reads ace->size (offset 2) even when aces_size is 0-3 bytes. This re-opens a 2-byte heap out-of-bounds (OOB) read past the pntsd allocation during subsequent SMB2_CREATE operations.
Fix this by properly transposing the comparison to require at least 16 bytes (8-byte offset + 8-byte SID base), matching the correct form used in smb_inherit_dacl().
--- fs/smb/server/smbacl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/smb/server/smbacl.c +4 -4
@@ -1446,8 +1446,8 @@ int smb_check_perm_dacl(struct ksmbd_con ace = (struct smb_ace *)((char *)pdacl +sizeof (struct smb_acl )); aces_size = acl_size -sizeof (struct smb_acl );for (i =0 ; i <le16_to_cpu (pdacl->num_aces); i++) { -if (offsetof(struct smb_ace , sid) + - aces_size <CIFS_SID_BASE_SIZE ) +if (aces_size < offsetof(struct smb_ace , sid) + +CIFS_SID_BASE_SIZE )break ; ace_size =le16_to_cpu (ace->size); if (ace_size > aces_size ||
@@ -1470,8 +1470,8 @@ int smb_check_perm_dacl(struct ksmbd_con ace = (struct smb_ace *)((char *)pdacl +sizeof (struct smb_acl )); aces_size = acl_size -sizeof (struct smb_acl );for (i =0 ; i <le16_to_cpu (pdacl->num_aces); i++) { -if (offsetof(struct smb_ace , sid) + - aces_size <CIFS_SID_BASE_SIZE ) +if (aces_size < offsetof(struct smb_ace , sid) + +CIFS_SID_BASE_SIZE )break ; ace_size =le16_to_cpu (ace->size); if (ace_size > aces_size ||
Greg Kroah-Hartman
maintainerPATCH 208/307 Input: atmel_mxt_ts - fix boundary check in mxt_prepare_cfg_mem
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
commit baa0210fb6a9dc3882509a9411b6d284d88fe30e upstream.
When a configuration file provides an object size that is larger than the driver's known mxt_obj_size(object), the driver intends to discard the extra bytes.
The loop iterates using for (i = 0; i < size; i++). Inside the loop, the condition to skip processing extra bytes is:
if (i > mxt_obj_size(object))
continue;
Since i is a 0-based index, the valid indices for the object are 0 through mxt_obj_size(object) - 1.
When i == mxt_obj_size(object), the condition evaluates to false, and the code processes the byte instead of discarding it.
This causes the code to calculate byte_offset = reg + i - cfg->start_ofs and writes the byte there, overwriting exactly one byte of the adjacent instance or object.
Update the boundary check to skip extra bytes correctly by using >=.
--- drivers/input/touchscreen/atmel_mxt_ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/atmel_mxt_ts.c +1 -1
@@ -1476,7 +1476,7 @@ static int mxt_prepare_cfg_mem(struct mx } cfg->raw_pos += offset; -if (i >mxt_obj_size (object)) +if (i >=mxt_obj_size (object))continue ; byte_offset = reg + i - cfg->start_ofs;
Greg Kroah-Hartman
maintainerPATCH 209/307 Input: synaptics - add LEN2058 to SMBus passlist for ThinkPad E490
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolás Bazaes <[email protected]>
commit 16ca52bc209fa4bf9239cd9e5643e95533476b58 upstream.
The Lenovo ThinkPad E490 (PNP ID: LEN2058) has a Synaptics TM3471-020 touchpad that supports SMBus/RMI4 mode but is not listed in smbus_pnp_ids[]. Without this entry, RMI4 over SMBus is not enabled by default, and the touchpad falls back to PS/2 mode.
Adding LEN2058 to the passlist enables automatic RMI4 detection without requiring the psmouse.synaptics_intertouch parameter, and matches the behavior of similar ThinkPad models already in the list (E480/LEN2054, E580/LEN2055).
Tested on ThinkPad E490 with kernel 7.0.5-zen1 and Arch Linux. RMI4 over SMBus is confirmed working without any kernel parameters.
--- drivers/input/mouse/synaptics.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/mouse/synaptics.c +1 -0
@@ -189,6 +189,7 @@ static const char * const smbus_pnp_ids["LEN2044" ,/* L470 */ "LEN2054" ,/* E480 */ "LEN2055" ,/* E580 */ +"LEN2058" ,/* E490 */ "LEN2068" ,/* T14 Gen 1 */ "SYN1221" ,/* TUXEDO InfinityBook Pro 14 v5 */ "SYN3003", /* HP EliteBook 850 G1 */
Greg Kroah-Hartman
maintainerPATCH 210/307 comedi: comedi_test: fix check for valid scan_begin_src in waveform_ai_cmdtest()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit 542f5248cb481073203e0dadab5bcbd28aeae308 upstream.
Commit 783ddaebd397 ("staging: comedi: comedi_test: support scan_begin_src == TRIG_FOLLOW") neglected to add a test that scan_begin_src has only one bit set. The allowed values are TRIG_FOLLOW and TRIG_TIMER, but the code incorrectly also allows TRIG_FOLLOW | TRIG_TIMER. Add a call to comedi_check_trigger_is_unique() to check that only one trigger source bit is set.
--- drivers/comedi/drivers/comedi_test.c | 1 + 1 file changed, 1 insertion(+)
drivers/comedi/drivers/comedi_test.c +1 -0
@@ -273,6 +273,7 @@ static int waveform_ai_cmdtest(struct co/* Step 2a : make sure trigger sources are unique */ err |=comedi_check_trigger_is_unique (cmd->convert_src); + err |=comedi_check_trigger_is_unique (cmd->scan_begin_src); err |=comedi_check_trigger_is_unique (cmd->stop_src);/* Step 2b : and mutually compatible */
Greg Kroah-Hartman
maintainerPATCH 211/307 comedi: comedi_test: Fix limiting of convert_arg in waveform_ai_cmdtest()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit 8a3bee801d420be8a7a0bae4a26547b353b8fe22 upstream.
The function checks and possibly modifies the description of an asynchronous command to be run on the analog input subdevice of a comedi device attached to the "comedi_test" driver, returning 0 if no modifications were required, or a positive value that indicates which step of the checking process it failed on. Step 4 fixes up various argument values for various trigger sources.
There are two bugs in the fixing up of the convert_arg value to keep the scan_begin_arg value within the range of unsigned int when scan_begin_src and convert_src both have the value TRIG_TIMER, which indicates that the corresponding _arg values hold a time period in nanoseconds. The code also uses scan_end_arg which hold the number of "conversions" within each "scan". The goal is to end up with the scan period being less than or equal to the convert period multiplied by the number of conversions per scan. It intends to do that by clamping the convert_arg value to a maximum value of UINT_MAX / scan_end_arg rounded down to a multiple of 1000 (NSEC_PER_USEC).
(The rounding from nanoseconds to microseconds is because the driver is modelling a device that uses a 1 MHz clock for timing. This is partly because that is a more typical timing base for real hardware devices driven by comedi, and partly because the driver used to use struct timeval internally.)
The first bug is that the code checks if scan_begin_arg == TRIG_TIMER when it should be checking if scan_begin_src == TRIG_TIMER. The bugged check will always fail because if scan_begin_src == TRIG_TIMER, then scan_begin_arg will be at least 1000 (NSEC_PER_USEC), otherwise scan_begin_src == TRIG_FOLLOW and scan_begin_arg will be 0. (N.B TRIG_TIMER is defined as 0x10.) The second bug is that is rounding the maximum value down to a multiple of 1000000000 (NSEC_PER_SEC) instead of 1000 (NSEC_PER_USEC), however this bug is not reached due to the first bug. This patch fixes both bugs.
--- drivers/comedi/drivers/comedi_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/comedi/drivers/comedi_test.c +2 -2
@@ -324,10 +324,10 @@ static int waveform_ai_cmdtest(struct co arg =min (arg,rounddown (UINT_MAX , (unsigned int )NSEC_PER_USEC )); arg =NSEC_PER_USEC *DIV_ROUND_CLOSEST (arg,NSEC_PER_USEC ); -if (cmd->scan_begin_arg ==TRIG_TIMER ) { +if (cmd->scan_begin_src ==TRIG_TIMER ) {/* limit convert_arg to keep scan_begin_arg in range */ limit =UINT_MAX / cmd->scan_end_arg; - limit =rounddown (limit, (unsigned int )NSEC_PER_SEC ); + limit =rounddown (limit, (unsigned int )NSEC_PER_USEC ); arg =min (arg, limit); } err |=comedi_check_trigger_arg_is (&cmd->convert_arg, arg);
Greg Kroah-Hartman
maintainerPATCH 212/307 counter: Fix refcount leak in counter_alloc() error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit d9eeb0ea0d2de658663bfaa9c26eccdd8fd64440 upstream.
After device_initialize(), the lifetime of the embedded struct device is expected to be managed through the device core reference counting.
In counter_alloc(), if dev_set_name() fails after device_initialize(), the error path removes the chrdev, frees the ID, and frees the backing allocation directly instead of releasing the device reference with put_device(). This bypasses the normal device lifetime rules and may leave the reference count of the embedded struct device unbalanced, resulting in a refcount leak.
The issue was identified by a static analysis tool I developed and confirmed by manual review.
Fix this by using put_device() in the dev_set_name() failure path and let counter_device_release() handle the final cleanup.
--- drivers/counter/counter-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/counter/counter-core.c +2 -1
@@ -124,7 +124,8 @@ struct counter_device *counter_alloc(siz err_dev_set_name: -counter_chrdev_remove (counter); +put_device (dev); +return NULL ; err_chrdev_add:ida_free (&counter_ida, dev->id);
Greg Kroah-Hartman
maintainerPATCH 213/307 tty: serial: pch_uart: add check for dma_alloc_coherent()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhaoyang Yu <[email protected]>
commit 6fe472c1bbbe238e91141f7cabc1226e96a60d43 upstream.
Add a check for dma_alloc_coherent() failure to prevent a potential NULL pointer dereference in dma_handle_rx(). Properly release DMA channels and the PCI device reference using a goto ladder if the allocation fails.
--- drivers/tty/serial/pch_uart.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/tty/serial/pch_uart.c +13 -6
@@ -689,8 +689,7 @@ static void pch_request_dma(struct uart_if (!chan) {dev_err (priv->port.dev,"%s:dma_request_channel FAILS(Tx)\n" , __func__); -pci_dev_put (dma_dev); -return ; + goto err_pci_get; } priv->chan_tx = chan;
@@ -704,18 +703,26 @@ static void pch_request_dma(struct uart_if (!chan) {dev_err (priv->port.dev,"%s:dma_request_channel FAILS(Rx)\n" , __func__); -dma_release_channel (priv->chan_tx); - priv->chan_tx =NULL ; -pci_dev_put (dma_dev); -return ; + goto err_req_tx; }/* Get Consistent memory for DMA */ priv->rx_buf_virt =dma_alloc_coherent (port->dev, port->fifosize, &priv->rx_buf_dma,GFP_KERNEL ); +if (!priv->rx_buf_virt) + goto err_req_rx; priv->chan_rx = chan;pci_dev_put (dma_dev); +return ; + +err_req_rx: +dma_release_channel (chan); +err_req_tx: +dma_release_channel (priv->chan_tx); + priv->chan_tx =NULL ; +err_pci_get: +pci_dev_put (dma_dev); }static void pch_dma_rx_complete (void *arg)
Greg Kroah-Hartman
maintainerPATCH 215/307 usb: chipidea: core: convert ci_role_switch to local variable
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 8f6aa392653e52a45858cff5c063df550028836b upstream.
When a system contains multiple USB controllers, the global ci_role_switch variable may be overwritten by subsequent driver initialization code.
This can cause issues in the following cases:
- The 2nd ci_hdrc_probe() sees ci_role_switch.fwnode as non-NULL even though the "usb-role-switch" property is not present for the controller.
- When the ci_hdrc device is unbound and bound again, ci_role_switch fwnode will not be reassigned, and the old value will be used instead.
Convert ci_role_switch to a local variable to fix these issues.
--- drivers/usb/chipidea/core.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/usb/chipidea/core.c +6 -10
@@ -669,12 +669,6 @@ static enum ci_role ci_get_role(struct creturn role; } -static struct usb_role_switch_desc ci_role_switch = { - .set = ci_usb_role_switch_set, - .get = ci_usb_role_switch_get, - .allow_userspace_control = true, -}; -static int ci_get_platdata (struct device *dev,struct ci_hdrc_platform_data *platdata) {
@@ -801,9 +795,6 @@ static int ci_get_platdata(struct device cable->connected = false; } -if (device_property_read_bool (dev,"usb-role-switch" )) - ci_role_switch.fwnode = dev->fwnode; - platdata->pctl =devm_pinctrl_get (dev);if (!IS_ERR (platdata->pctl)) {struct pinctrl_state *p;
@@ -1045,6 +1036,7 @@ ATTRIBUTE_GROUPS(ci);static int ci_hdrc_probe (struct platform_device *pdev) { +struct usb_role_switch_desc ci_role_switch = {};struct device *dev = &pdev->dev;struct ci_hdrc *ci;struct resource *res;
@@ -1191,7 +1183,11 @@ static int ci_hdrc_probe(struct platform } } -if (ci_role_switch.fwnode) { +if (device_property_read_bool (dev,"usb-role-switch" )) { + ci_role_switch.set = ci_usb_role_switch_set; + ci_role_switch.get = ci_usb_role_switch_get; + ci_role_switch.allow_userspace_control = true; + ci_role_switch.fwnode =dev_fwnode (dev); ci_role_switch.driver_data = ci; ci->role_switch =usb_role_switch_register (dev, &ci_role_switch);
Greg Kroah-Hartman
maintainerPATCH 216/307 usb: core: Fix up Interrupt IN endpoints with bogus wBytesPerInterval
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
commit 727d045d064b7c9a24db3bce9c0485a382cb768b upstream.
Tao Xue found that some common devices violate USB 3.x section 9.6.7 by reporting wBytesPerInterval lower than the size of packets they actually send. I confirmed that AX88179 may set it to 0 and RTL8153 CDC configuration sets it to 8 but sends both 8 and 16 byte packets:
S Ii:11:007:3 -115:128 16 <
C Ii:11:007:3 0:128 8 = a1000000 01000000
S Ii:11:007:3 -115:128 16 <
C Ii:11:007:3 0:128 16 = a12a0000 01000800 00000000 00000000
Most xHCI host controllers neglect interrupt bandwidth reservations and let such devices exceed theirs, some fail the URB with EOVERFLOW.
Assume that wBytesPerInterval lower than wMaxPacketSize is bogus and increase it to the worst case maximum on interrupt IN endpoints. This solves xHCI problems and appears to have no other effect. Interrupt transfers are not limited to one interval and drivers submit URBs of class defined size without looking at wBytesPerInterval. Any multi- interval transfer is considered terminated by a packet shorter than wMaxPacketSize regardless of wBytesPerInterval - see USB3 8.10.3.
Stay in spec on OUT endpoints and isochronous. No buggy devices are known and we don't want to risk sending more data than the device is prepared to handle or confusing isoc drivers regarding altsetting capacities guaranteed by the device itself. And don't complain when wMaxPacketSize <= wBytesPerInterval < wMaxPacketSize * (bMaxBurst+1) because enabling this seems to be the exact goal of the spec.
--- drivers/usb/core/config.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/usb/core/config.c +8 -1
@@ -165,7 +165,14 @@ static void usb_parse_ss_endpoint_compan (desc->bMaxBurst +1 ); else max_tx =999999 ; -if (le16_to_cpu (desc->wBytesPerInterval) > max_tx) { +/* +* wBytesPerInterval > max_tx is bogus, but USB3 spec doesn't forbid the opposite. +* Experience shows that wBytesPerInterval < wMaxPacketSize on common interrupt IN +* endpoints is usually bogus too, and recent HCs enforce interrupt BW limits. +*/ +if (le16_to_cpu (desc->wBytesPerInterval) > max_tx || + (le16_to_cpu (desc->wBytesPerInterval) <usb_endpoint_maxp (&ep->desc) && +usb_endpoint_is_int_in (&ep->desc))) { dev_notice(ddev, "%s endpoint with wBytesPerInterval of %d in " "config %d interface %d altsetting %d ep %d: " "setting to %d\n",
Greg Kroah-Hartman
maintainerPATCH 217/307 USB: quirks: add NO_LPM for Lenovo ThinkPad USB-C Dock Gen2 hub controllers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen J. Fuhry <[email protected]>
commit 9ddb9c0deca48d2c2a22ebf4d2f35c925a520328 upstream.
The Lenovo ThinkPad USB-C Dock Gen2 (17ef:a391, 17ef:a392) hub controllers exhibit link instability when USB Link Power Management is enabled, similar to the dock's Ethernet adapter (17ef:a387) which already carries USB_QUIRK_NO_LPM.
When the dock reconnects after a transient disconnect, the hub controllers enter LPM states between re-enumeration retries, causing repeated disconnect/reconnect cycles lasting up to two minutes. Disabling LPM for these devices restores stable enumeration.
--- drivers/usb/core/quirks.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/core/quirks.c +4 -0
@@ -511,6 +511,10 @@ static const struct usb_device_id usb_qu/* Lenovo ThinkPad USB-C Dock Gen2 Ethernet (RTL8153 GigE) */ { USB_DEVICE(0x17ef, 0xa387), .driver_info = USB_QUIRK_NO_LPM }, + /* Lenovo ThinkPad USB-C Dock Gen2 USB 3.1 and USB 2.0 hub controllers */ + { USB_DEVICE(0x17ef, 0xa391), .driver_info = USB_QUIRK_NO_LPM }, + { USB_DEVICE(0x17ef, 0xa392), .driver_info = USB_QUIRK_NO_LPM }, + /* BUILDWIN Photo Frame */ { USB_DEVICE(0x1908, 0x1315), .driver_info = USB_QUIRK_HONOR_BNUMINTERFACES },
Greg Kroah-Hartman
maintainerPATCH 218/307 usb: storage: Add quirks for PNY Elite Portable SSD
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sam Burkels <[email protected]>
commit b53ebb811e00be50a779ce4e7aee604178b4a825 upstream.
The PNY Elite Portable SSD (USB ID 154b:f009) is a sibling of the already-quirked PNY Pro Elite SSDs (154b:f00b and 154b:f00d). Like its siblings, it uses a Phison-based USB-SATA bridge that exhibits firmware bugs when bound to the uas driver.
Without quirks, the device fails to complete READ CAPACITY commands when accessed over UAS on a SuperSpeed (USB 3) port. The device enumerates and reports as a SCSI direct-access device, but reports zero logical blocks and never finishes spin-up:
usb 2-3: new SuperSpeed USB device number 8 using xhci_hcd usb 2-3: New USB device found, idVendor=154b, idProduct=f009 usb 2-3: Product: PNY ELITE PSSD
usb 2-3: Manufacturer: PNY
scsi host0: uas
scsi 0:0:0:0: Direct-Access PNY PNY ELITE PSSD 0
sd 0:0:0:0: [sda] Spinning up disk...
[...10+ seconds of polling, no progress...]
sd 0:0:0:0: [sda] Read Capacity(16) failed: hostbyte=DID_ERROR sd 0:0:0:0: [sda] Read Capacity(10) failed: hostbyte=DID_ERROR sd 0:0:0:0: [sda] 0 512-byte logical blocks: (0 B/0 B)
Tested each individual quirk to find the minimum that fixes this:
- US_FL_NO_ATA_1X alone: device hangs on spin-up
- US_FL_NO_REPORT_OPCODES alone: works on USB 2.0, hangs on USB 3.0
- US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES: works on both
With both quirks the device enumerates correctly while still using the uas driver, and delivers full UAS throughput (~281 MB/s sequential read on a USB 3.0 Gen 1 port).
The existing PNY Pro Elite entries (f00b, f00d) only set NO_ATA_1X, but this device additionally chokes on REPORT OPCODES under SuperSpeed.
--- drivers/usb/storage/unusual_uas.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/storage/unusual_uas.h +7 -0
@@ -132,6 +132,13 @@ UNUSUAL_DEV(0x152d, 0x0583, 0x0000, 0x99 USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_REPORT_OPCODES), +/* Reported-by: Sam Burkels <[email protected]> */ +UNUSUAL_DEV (0x154b ,0xf009 ,0x0000 ,0x9999 , +"PNY" , +"PNY ELITE PSSD" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_NO_ATA_1X |US_FL_NO_REPORT_OPCODES ), +/* Reported-by: Thinh Nguyen <[email protected]> */ UNUSUAL_DEV(0x154b, 0xf00b, 0x0000, 0x9999, "PNY",
Greg Kroah-Hartman
maintainerPATCH 219/307 usbip: vudc: Fix use after free bug in vudc_remove due to race condition
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit d96209626a29ea64666be98c30b30ac82e5f1be6 upstream.
This patch follows up Zheng Wang's 2023 report of a use-after-free in vudc_remove(). The original thread stalled on Shuah Khan's request for runtime testing of the unplug/unbind path. This patch supplies that testing and keeps Zheng's original fix shape.
In vudc_probe(), v_init_timer() binds udc->tr_timer.timer to v_timer(). usbip_sockfd_store() starts the timer via v_start_timer()/v_kick_timer(). vudc_remove() can then free the containing struct vudc while the timer is still pending or executing.
KASAN confirms the race on an unpatched x86_64 QEMU guest with CONFIG_KASAN=y, CONFIG_USBIP_VUDC=y, CONFIG_USB_ZERO=y, and a tight loop that repeatedly writes a socket fd to usbip_sockfd, closes the socket pair, and unbinds/rebinds usbip-vudc.0:
BUG: KASAN: slab-use-after-free in __run_timer_base.part.0+0x8ba/0x8e0
Write of size 8 at addr ffff888001b80740 by task trigger_and_unb/239
Allocated by task 239:
vudc_probe+0x4d/0xaa0
Freed by task 239:
kfree+0x18f/0x520
device_release_driver_internal+0x388/0x540
unbind_store+0xd9/0x100This lands in the timer core rather than v_timer() itself because the embedded timer_list is being walked after its containing struct vudc has already been freed. The underlying lifetime bug is the same one Zheng reported.
With v_stop_timer() called from vudc_remove() and the timer deleted synchronously, the same harness completed 5000 bind/unbind iterations with no KASAN report.
--- drivers/usb/usbip/vudc_dev.c | 1 + drivers/usb/usbip/vudc_transfer.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/usb/usbip/vudc_dev.c +1 -0
@@ -632,6 +632,7 @@ void vudc_remove(struct platform_device {struct vudc *udc =platform_get_drvdata (pdev); +v_stop_timer (udc);usb_del_gadget_udc (&udc->gadget);cleanup_vudc_hw (udc);kfree (udc);
drivers/usb/usbip/vudc_transfer.c +2 -1
@@ -490,7 +490,8 @@ void v_stop_timer(struct vudc *udc) {struct transfer_timer *t = &udc->tr_timer; -/* timer itself will take care of stopping */ +/* Delete the timer synchronously before teardown frees udc. */ dev_dbg (&udc->pdev->dev,"timer stop" ); +timer_delete_sync (&t->timer); t->state =VUDC_TR_STOPPED ; }
Greg Kroah-Hartman
maintainerPATCH 220/307 usb: usbtmc: check URB actual_length for interrupt-IN notifications
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heitor Alves de Siqueira <[email protected]>
commit 52f2ad3f7e5eb3b5908e1d685d4342519dc9cfcd upstream.
USBTMC devices can use an optional interrupt endpoint for notification messages. These typically contain two-byte headers indicating the payload format, but the driver does not check if these headers are present before accessing the data buffers. In cases where the URB actual_length is not enough to fit these headers, the driver will either cause an out-of-bounds read, or consume stale leftover data from a previous notification.
Fix by checking if actual_data contains enough bytes for the headers, otherwise resubmit URB to the interrupt endpoint.
--- drivers/usb/class/usbtmc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/class/usbtmc.c +8 -0
@@ -2310,6 +2310,14 @@ static void usbtmc_interrupt(struct urbswitch (status) {case 0 :/* SUCCESS */ +/* ensure at least two bytes of headers were transferred */ +if (urb->actual_length <2 ) { +dev_warn (dev, +"actual length %d not sufficient for interrupt headers\n" , + urb->actual_length); + goto exit; + } +/* check for valid STB notification */ if (data->iin_buffer[0 ] >0x81 ) { data->bNotify1 = data->iin_buffer[0 ];
Greg Kroah-Hartman
maintainerPATCH 221/307 usb: usbtmc: reject interrupt endpoints with small wMaxPacketSize
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heitor Alves de Siqueira <[email protected]>
commit 121d2f682ba912b1427cddca7cf84840f41cc620 upstream.
The USB488 subclass specification requires interrupt wMaxPacketSize to be 0x02, unless the device sends vendor-specific notifications. Endpoints that advertise less than 2 bytes for wMaxPacketSize are unlikely to work with the current driver, as URBs will not have enough space for interrupt headers. Considering that any notification URBs will be ignored by the driver, reject these endpoints early during probe.
--- drivers/usb/class/usbtmc.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/class/usbtmc.c +6 -0
@@ -2444,6 +2444,12 @@ static int usbtmc_probe(struct usb_inter data->iin_ep = int_in->bEndpointAddress; data->iin_wMaxPacketSize =usb_endpoint_maxp (int_in); data->iin_interval = int_in->bInterval; +/* wMaxPacketSize should be 0x02 or more as per USB488 Table 22 */ +if (iface_desc->desc.bInterfaceProtocol ==1 && + data->iin_wMaxPacketSize <2 ) { + retcode = -EINVAL ; + goto err_put; + }dev_dbg (&intf->dev,"Found Int in endpoint at %u\n" , data->iin_ep); }
Greg Kroah-Hartman
maintainerPATCH 222/307 usb: typec: tcpm: improve handling of DISCOVER_MODES failures
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
commit c06e6cd488194e37ed4dc29d1488d1ffb760de60 upstream.
UGREEN USB-C Multifunction Adapter Model CM512 (AKA "Revodok 107") exposes two SVIDs: 0xff01 (DP Alt Mode) and 0x1d5c. The DISCOVER_MODES step succeeds for 0xff01 and gets a NAK for 0x1d5c. Currently this results in DP Alt Mode not being registered either, since the modes are only registered once all of them have been discovered. The NAK results in the processing being stopped and thus no Alt modes being registered.
Improve the situation by handling the NAK gracefully and continue processing the other modes.
Before this change, the TCPM log ends like this:
(more log entries before this)
[ 5.028287] AMS DISCOVER_SVIDS finished [ 5.028291] cc:=4 [ 5.040040] SVID 1: 0xff01 [ 5.040054] SVID 2: 0x1d5c [ 5.040082] AMS DISCOVER_MODES start [ 5.040096] PD TX, header: 0x1b6f [ 5.050946] PD TX complete, status: 0 [ 5.059609] PD RX, header: 0x264f [1] [ 5.059626] Rx VDM cmd 0xff018043 type 1 cmd 3 len 2 [ 5.059640] AMS DISCOVER_MODES finished [ 5.059644] cc:=4 [ 5.069994] Alternate mode 0: SVID 0xff01, VDO 1: 0x000c0045 [ 5.070029] AMS DISCOVER_MODES start [ 5.070043] PD TX, header: 0x1d6f [ 5.081139] PD TX complete, status: 0 [ 5.087498] PD RX, header: 0x184f [1] [ 5.087515] Rx VDM cmd 0x1d5c8083 type 2 cmd 3 len 1 [ 5.087529] AMS DISCOVER_MODES finished [ 5.087534] cc:=4
(no further log entries after this point)
After this patch the TCPM log looks exactly the same, but then continues like this:
[ 5.100222] Skip SVID 0x1d5c (failed to discover mode) [ 5.101699] AMS DFP_TO_UFP_ENTER_MODE start
(log goes on as the system initializes DP AltMode)
--- drivers/usb/typec/tcpm/tcpm.c | 97 ++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 36 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +61 -36
@@ -1933,6 +1933,55 @@ static bool tcpm_cable_vdm_supported(strtcpm_can_communicate_sop_prime (port); } +static int tcpm_handle_discover_mode (struct tcpm_port *port,u32 *response, +enum tcpm_transmit_type rx_sop_type, +enum tcpm_transmit_type *response_tx_sop_type) +{ +struct typec_port *typec = port->typec_port; +struct pd_mode_data *modep; + +if (rx_sop_type ==TCPC_TX_SOP ) { + modep = &port->mode_data; + modep->svid_index++; + +if (modep->svid_index < modep->nsvids) { +u16 svid = modep->svids[modep->svid_index]; + *response_tx_sop_type =TCPC_TX_SOP ; + response[0 ] =VDO (svid,1 , +typec_get_negotiated_svdm_version (typec), +CMD_DISCOVER_MODES ); +return 1 ; + } + +if (tcpm_cable_vdm_supported (port)) { + *response_tx_sop_type =TCPC_TX_SOP_PRIME ; + response[0 ] =VDO (USB_SID_PD ,1 , +typec_get_cable_svdm_version (typec), +CMD_DISCOVER_SVID ); +return 1 ; + } + +tcpm_register_partner_altmodes (port); + }else if (rx_sop_type ==TCPC_TX_SOP_PRIME ) { + modep = &port->mode_data_prime; + modep->svid_index++; + +if (modep->svid_index < modep->nsvids) { +u16 svid = modep->svids[modep->svid_index]; + *response_tx_sop_type =TCPC_TX_SOP_PRIME ; + response[0 ] =VDO (svid,1 , +typec_get_cable_svdm_version (typec), +CMD_DISCOVER_MODES ); +return 1 ; + } + +tcpm_register_plug_altmodes (port); +tcpm_register_partner_altmodes (port); + } + +return 0 ; +} + static int tcpm_pd_svdm(struct tcpm_port *port, struct typec_altmode *adev, const u32 *p, int cnt, u32 *response, enum adev_actions *adev_action,
@@ -2190,41 +2239,11 @@ static int tcpm_pd_svdm(struct tcpm_port }break ;case CMD_DISCOVER_MODES : -if (rx_sop_type ==TCPC_TX_SOP ) { -/* 6.4.4.3.3 */ -svdm_consume_modes (port, p, cnt, rx_sop_type); - modep->svid_index++; -if (modep->svid_index < modep->nsvids) { -u16 svid = modep->svids[modep->svid_index]; - *response_tx_sop_type =TCPC_TX_SOP ; - response[0 ] =VDO (svid,1 , svdm_version, -CMD_DISCOVER_MODES ); - rlen =1 ; - }else if (tcpm_cable_vdm_supported (port)) { - *response_tx_sop_type =TCPC_TX_SOP_PRIME ; - response[0 ] =VDO (USB_SID_PD ,1 , -typec_get_cable_svdm_version (typec), -CMD_DISCOVER_SVID ); - rlen =1 ; - }else { -tcpm_register_partner_altmodes (port); - } - }else if (rx_sop_type ==TCPC_TX_SOP_PRIME ) { -/* 6.4.4.3.3 */ -svdm_consume_modes (port, p, cnt, rx_sop_type); - modep_prime->svid_index++; -if (modep_prime->svid_index < modep_prime->nsvids) { -u16 svid = modep_prime->svids[modep_prime->svid_index]; - *response_tx_sop_type =TCPC_TX_SOP_PRIME ; - response[0 ] =VDO (svid,1 , -typec_get_cable_svdm_version (typec), -CMD_DISCOVER_MODES ); - rlen =1 ; - }else { -tcpm_register_plug_altmodes (port); -tcpm_register_partner_altmodes (port); - } - } +/* 6.4.4.3.3 */ +svdm_consume_modes (port, p, cnt, rx_sop_type); + rlen =tcpm_handle_discover_mode (port, response, + rx_sop_type, + response_tx_sop_type);break ;case CMD_ENTER_MODE : *response_tx_sop_type = rx_sop_type;
@@ -2267,9 +2286,15 @@ static int tcpm_pd_svdm(struct tcpm_portswitch (cmd) {case CMD_DISCOVER_IDENT :case CMD_DISCOVER_SVID : -case CMD_DISCOVER_MODES : case VDO_CMD_VENDOR(0) ... VDO_CMD_VENDOR(15):break ; +case CMD_DISCOVER_MODES : +tcpm_log (port,"Skip SVID 0x%04x (failed to discover mode)" , +PD_VDO_SVID_SVID0 (p[0 ])); + rlen =tcpm_handle_discover_mode (port, response, + rx_sop_type, + response_tx_sop_type); +break ;case CMD_ENTER_MODE :/* Back to USB Operation */ *adev_action =ADEV_NOTIFY_USB_AND_QUEUE_VDM ;
Greg Kroah-Hartman
maintainerPATCH 223/307 USB: serial: option: add MeiG SRM813Q
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Volckaert <[email protected]>
commit 7d2b37d3e42d19071b62f4ddbee6e16e905efbf1 upstream.
Add support for the Qualcomm Technology Snapdragon X35-based MeiG SRM813Q module.
The module can be put in different modes via AT commands to enable/disable GPS functionality:
MODEM - PPP mode(2dee:4d63): AT+SER=1,1
If#= 0: RMNET
If#= 1: DIAG/ADB
If#= 2: MODEM
If#= 3: AT
P: Vendor=2dee ProdID=4d63 Rev=05.15 S: Manufacturer=MEIG S: Product=LTE-A Module S: SerialNumber=1bd51f0e C: #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
NMEA mode(2dee:4d64): AT+SER=51,1
If#= 0: RMNET
If#= 1: DIAG/ADB
If#= 2: NMEA
If#= 3: AT
P: Vendor=2dee ProdID=4d64 Rev=05.15 S: Manufacturer=MEIG S: Product=LTE-A Module S: SerialNumber=1bd51f0e C: #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=500mA I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I: If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=60 Driver=option E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=85(I) Atr=03(Int.) MxPS= 10 Ivl=32ms I: If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=87(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
--- drivers/usb/serial/option.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/serial/option.c +6 -0
@@ -2450,6 +2450,12 @@ static const struct usb_device_id option { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d38, 0xff, 0xff, 0x30) }, /* MeiG Smart SRM825WN (Diag) */ { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d38, 0xff, 0xff, 0x40) }, /* MeiG Smart SRM825WN (AT) */ { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d38, 0xff, 0xff, 0x60) }, /* MeiG Smart SRM825WN (NMEA) */ + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d63, 0xff, 0xff, 0x30) }, /* MeiG SRM813Q (Diag) */ + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d63, 0xff, 0xff, 0x40) }, /* MeiG SRM813Q (AT) */ + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d64, 0xff, 0xff, 0x30) }, /* MeiG SRM813Q (Diag) */ + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d64, 0xff, 0xff, 0x40) }, /* MeiG SRM813Q (AT) */ + { USB_DEVICE_AND_INTERFACE_INFO(0x2dee, 0x4d64, 0xff, 0xff, 0x60) }, /* MeiG SRM813Q (NMEA) */ + { USB_DEVICE_INTERFACE_CLASS(0x2df3, 0x9d03, 0xff) }, /* LongSung M5710 */ { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1404, 0xff) }, /* GosunCn GM500 RNDIS */ { USB_DEVICE_INTERFACE_CLASS(0x305a, 0x1405, 0xff) }, /* GosunCn GM500 MBIM */
Greg Kroah-Hartman
maintainerPATCH 224/307 USB: serial: option: add missing RSVD(5) flag for Rolling RW135R-GL
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wanquan Zhong <[email protected]>
commit 689f2facc689c8add11d7ff69fbbad17d65ee596 upstream.
The RW135R-GL entry added in commit 01e8d0f74222 ("USB: serial: option:
add support for Rolling Wireless RW135R-GL") was missing the .driver_info = RSVD(5) flag used by other Rolling Wireless MBIM laptop modules (e.g. RW135-GL and RW350-GL).
Without this flag, the option driver incorrectly binds to the reserved ADB interface (If#5) in multi-interface USB modes, causing AT/MBIM communication failures after mode switching. This matches the handling of other Rolling Wireless MBIM devices.
- VID:PID 33f8:1003, RW135R-GL for laptop debug M.2 cards (with MBIM interface for Linux/Chrome OS)
0x1003: mbim, diag, AT, pipe
Here are the outputs of usb-devices:
T: Bus=03 Lev=01 Prnt=01 Port=04 Cnt=02 Dev#= 8 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=33f8 ProdID=1003 Rev= 5.15 S: Manufacturer=Rolling Wireless S.a.r.l. S: Product=Rolling RW135R-GL Module S: SerialNumber=12345678 C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA A: FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=0e Prot=00 I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=cdc_mbim E: Ad=82(I) Atr=03(Int.) MxPS= 64 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim 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=00 Prot=00 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=ff Prot=30 Driver=option E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
- VID:PID 33f8:1003, RW135R-GL for laptop debug M.2 cards (with MBIM interface for Linux/Chrome OS)
0x1003: mbim, diag, AT, ADB, pipe
Here are the outputs of usb-devices:
T: Bus=03 Lev=01 Prnt=01 Port=04 Cnt=02 Dev#= 7 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=33f8 ProdID=1003 Rev= 5.15 S: Manufacturer=Rolling Wireless S.a.r.l. S: Product=Rolling RW135R-GL Module S: SerialNumber=12345678 C:* #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA A: FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=0e Prot=00 I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=cdc_mbim E: Ad=82(I) Atr=03(Int.) MxPS= 64 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim 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=00 Prot=00 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=ff Prot=30 Driver=option E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms 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=42 Prot=01 Driver=(none) E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
- VID:PID 33f8:1003, RW135R-GL for laptop debug M.2 cards (with MBIM interface for Linux/Chrome OS)
0x1003: mbim, pipe
Here are the outputs of usb-devices:
T: Bus=03 Lev=01 Prnt=01 Port=04 Cnt=02 Dev#= 9 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=33f8 ProdID=1003 Rev= 5.15 S: Manufacturer=Rolling Wireless S.a.r.l. S: Product=Rolling RW135R-GL Module S: SerialNumber=12345678 C:* #Ifs= 3 Cfg#= 1 Atr=a0 MxPwr=500mA A: FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=0e Prot=00 I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=0e Prot=00 Driver=cdc_mbim E: Ad=82(I) Atr=03(Int.) MxPS= 64 Ivl=32ms I: If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim 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=00 Prot=00 Driver=option E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/serial/option.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/serial/option.c +2 -1
@@ -2476,7 +2476,8 @@ static const struct usb_device_id option { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x0302, 0xff) }, /* Rolling RW101R-GL (laptop MBIM) */ { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x0802, 0xff), /* Rolling RW350-GL (laptop MBIM) */ .driver_info = RSVD(5) }, - { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x1003, 0xff) }, /* Rolling RW135R-GL (laptop MBIM) */ + { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x1003, 0xff), /* Rolling RW135R-GL (laptop MBIM) */ + .driver_info = RSVD(5) }, { 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 225/307 USB: serial: belkin_sa: validate interrupt status length
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Cen <[email protected]>
commit 4ce058df2ee02cc2a0f0fd5cd64ce6f1482a0b65 upstream.
The Belkin interrupt callback treats interrupt data as a four-byte status report and reads LSR/MSR fields at offsets 2 and 3. The interrupt-in buffer length is derived from endpoint wMaxPacketSize, and short interrupt transfers may complete successfully with a smaller actual_length.
Check the completed interrupt packet length before parsing status fields so short interrupt endpoints and short successful packets are ignored instead of causing out-of-bounds or stale status-byte reads.
KASAN report as below:
BUG: KASAN: slab-out-of-bounds in belkin_sa_read_int_callback() Read of size 1 Call trace: belkin_sa_read_int_callback() (drivers/usb/serial/belkin_sa.c:202) __usb_hcd_giveback_urb() (drivers/usb/core/hcd.c:1630) dummy_timer() (?:?)
--- drivers/usb/serial/belkin_sa.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/serial/belkin_sa.c +3 -0
@@ -194,6 +194,9 @@ static void belkin_sa_read_int_callback(usb_serial_debug_data (&port->dev, __func__, urb->actual_length, data); +if (urb->actual_length <BELKIN_SA_MSR_INDEX +1 ) + goto exit; +/* Handle known interrupt data */ /* ignore data[0] and data[1] */
Greg Kroah-Hartman
maintainerPATCH 226/307 USB: serial: cypress_m8: validate interrupt packet headers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Cen <[email protected]>
commit 9f9bfc80c67f35a275820da7e83a35dface08281 upstream.
cypress_read_int_callback() parses the interrupt-in buffer according to the selected Cypress packet format. Format 1 has a two-byte status/count header and format 2 has a one-byte combined status/count header. The usb-serial core sizes the interrupt-in buffer from the endpoint descriptor's wMaxPacketSize, and successful interrupt transfers can complete short when URB_SHORT_NOT_OK is not set.
Check that the completed packet contains the selected header before reading it. Malformed short reports are ignored and the interrupt URB is resubmitted through the existing retry path, preventing out-of-bounds header-byte reads.
KASAN report as below:
KASAN slab-out-of-bounds in cypress_read_int_callback+0x240/0x7f0
Read of size 1 Call trace: cypress_read_int_callback() (drivers/usb/serial/cypress_m8.c:1009) __usb_hcd_giveback_urb() dummy_timer()
--- drivers/usb/serial/cypress_m8.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/usb/serial/cypress_m8.c +11 -1
@@ -1017,8 +1017,8 @@ static void cypress_read_int_callback(stchar tty_flag =TTY_NORMAL ;int bytes =0 ;int result; -int i =0 ;int status = urb->status; +int i;switch (status) {case 0 :/* success */
@@ -1056,22 +1056,32 @@ static void cypress_read_int_callback(stspin_lock_irqsave (&priv->lock, flags); result = urb->actual_length; + i =0 ;switch (priv->pkt_fmt) {default :case packet_format_1:/* This is for the CY7C64013... */ +if (result <2 ) +break ; priv->current_status = data[0 ] &0xF8 ; bytes = data[1 ] +2 ; i =2 ;break ;case packet_format_2:/* This is for the CY7C63743... */ +if (result <1 ) +break ; priv->current_status = data[0 ] &0xF8 ; bytes = (data[0 ] &0x07 ) +1 ; i =1 ;break ; }spin_unlock_irqrestore (&priv->lock, flags); +if (i ==0 ) { +dev_dbg (dev,"%s - short packet received: %d bytes\n" , + __func__, result); + goto continue_read; + }if (result < bytes) { dev_dbg(dev, "%s - wrong packet size - received %d bytes but packet said %d bytes\n",
Greg Kroah-Hartman
maintainerPATCH 227/307 USB: serial: keyspan: fix missing indat transfer sanity check
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 ab8336a7e414f018430aa1af3a46944032f7ff96 upstream.
Add the missing sanity check on the size of usa49wg indat transfers to avoid parsing stale or uninitialised slab data.
--- drivers/usb/serial/keyspan.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/serial/keyspan.c +4 -0
@@ -1187,6 +1187,10 @@ static void usa49wg_indat_callback(struc len =0 ;while (i < urb->actual_length) { +if (urb->actual_length - i <3 ) { +dev_warn_ratelimited (&urb->dev->dev,"malformed indat packet\n" ); +break ; + }/* Check port number from message */ if (data[i] >= serial->num_ports) {
Greg Kroah-Hartman
maintainerPATCH 228/307 USB: serial: mxuport: fix memory corruption with small endpoint
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 4085f0dbb1ce2251c9a5938d693de6593f0ab2bd upstream.
Make sure that the bulk-out endpoint max packet size is at least eight bytes to avoid user-controlled slab corruption should a malicious device report a smaller size.
--- drivers/usb/serial/mxuport.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/serial/mxuport.c +8 -0
@@ -962,6 +962,14 @@ static int mxuport_calc_num_ports(struct*/ BUILD_BUG_ON (ARRAY_SIZE (epds->bulk_out) <16 ); +/* +* The bulk-out buffers must be large enough for the four-byte header +* (and following data), but assume anything smaller than eight bytes +* is broken. +*/ +if (usb_endpoint_maxp (epds->bulk_out[0 ]) <8 ) +return -EINVAL ; +for (i =1 ; i < num_ports; ++i) epds->bulk_out[i] = epds->bulk_out[0 ];
Greg Kroah-Hartman
maintainerPATCH 229/307 USB: serial: mct_u232: fix missing interrupt-in transfer sanity check
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 245aba83e3c288e176ed037a1f6b618b09e92ed8 upstream.
Add the missing sanity check on the size of interrupt-in transfers to avoid parsing stale or uninitialised slab data (and leaking it to user space).
--- drivers/usb/serial/mct_u232.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/serial/mct_u232.c +5 -0
@@ -543,6 +543,11 @@ static void mct_u232_read_int_callback(s goto exit; } +if (urb->actual_length <2 ) { +dev_warn_ratelimited (&port->dev,"short interrupt-in packet\n" ); + goto exit; + } +/* * The interrupt-in pipe signals exceptional conditions (modem line * signal changes and errors). data[0] holds MSR, data[1] holds LSR.
Greg Kroah-Hartman
maintainerPATCH 230/307 usb: gadget: uvc: hold opts->lock across XU walks in uvc_function_bind
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Aizen <[email protected]>
commit 68aa70648b625fa684bc0b71bbfd905f4943ca20 upstream.
uvc_function_bind() walks &opts->extension_units twice without holding opts->lock:
- directly, for the iExtension string-descriptor fixup loop;
- indirectly, four times via uvc_copy_descriptors() (once per speed),
where the helper iterates uvc->desc.extension_units (which aliases
&opts->extension_units) to size and emit XU descriptors.The configfs side (uvcg_extension_make / uvcg_extension_drop, in drivers/usb/gadget/function/uvc_configfs.c) takes opts->lock around its list_add_tail / list_del operations. A privileged userspace process that holds the configfs subtree open and writes the gadget UDC name to bind the function while concurrently rmdir()'ing an extensions subdir can race uvcg_extension_drop() against the bind-time list walks and dereference a freed struct uvcg_extension.
Hold opts->lock from the start of the XU string-descriptor fixup through the last uvc_copy_descriptors() call, releasing on the descriptor-error path via a new error_unlock label that drops the lock before falling through to the existing error label. This matches the locking discipline of the configfs callbacks and removes the only remaining unsynchronised reader of the XU list during bind.
Reachability: only privileged processes that can mount configfs and write to gadget UDC files can trigger the race, so this is a correctness fix rather than a security boundary.
--- drivers/usb/gadget/function/f_uvc.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/usb/gadget/function/f_uvc.c +21 -7
@@ -765,6 +765,16 @@ uvc_function_bind(struct usb_configurati uvc_ss_streaming_ep.bEndpointAddress = uvc->video.ep->address;/* +* Hold opts->lock across both the XU string-descriptor fixup below and +* the descriptor-copy block further down. Without this, configfs +* uvcg_extension_drop() (which takes opts->lock) can race with the +* list_for_each_entry() walks here and inside uvc_copy_descriptors(), +* leading to a UAF on a freed struct uvcg_extension. See +* drivers/usb/gadget/function/uvc_configfs.c::uvcg_extension_drop(). +*/ +mutex_lock (&opts->lock); + +/* * XUs can have an arbitrary string descriptor describing them. If they * have one pick up the ID. */
@@ -781,7 +791,7 @@ uvc_function_bind(struct usb_configurati ARRAY_SIZE(uvc_en_us_strings));if (IS_ERR (us)) { ret =PTR_ERR (us); - goto error; + goto error_unlock; } uvc_iad.iFunction = opts->iad_index ? cdev->usb_strings[opts->iad_index].id :
@@ -795,14 +805,14 @@ uvc_function_bind(struct usb_configurati/* Allocate interface IDs. */ if ((ret =usb_interface_id (c, f)) <0 ) - goto error; + goto error_unlock; uvc_iad.bFirstInterface = ret; uvc_control_intf.bInterfaceNumber = ret; uvc->control_intf = ret; opts->control_interface = ret;if ((ret =usb_interface_id (c, f)) <0 ) - goto error; + goto error_unlock; uvc_streaming_intf_alt0.bInterfaceNumber = ret; uvc_streaming_intf_alt1.bInterfaceNumber = ret; uvc->streaming_intf = ret;
@@ -813,30 +823,32 @@ uvc_function_bind(struct usb_configuratiif (IS_ERR (f->fs_descriptors)) { ret =PTR_ERR (f->fs_descriptors); f->fs_descriptors =NULL ; - goto error; + goto error_unlock; } f->hs_descriptors =uvc_copy_descriptors (uvc,USB_SPEED_HIGH );if (IS_ERR (f->hs_descriptors)) { ret =PTR_ERR (f->hs_descriptors); f->hs_descriptors =NULL ; - goto error; + goto error_unlock; } f->ss_descriptors =uvc_copy_descriptors (uvc,USB_SPEED_SUPER );if (IS_ERR (f->ss_descriptors)) { ret =PTR_ERR (f->ss_descriptors); f->ss_descriptors =NULL ; - goto error; + goto error_unlock; } f->ssp_descriptors =uvc_copy_descriptors (uvc,USB_SPEED_SUPER_PLUS );if (IS_ERR (f->ssp_descriptors)) { ret =PTR_ERR (f->ssp_descriptors); f->ssp_descriptors =NULL ; - goto error; + goto error_unlock; } +mutex_unlock (&opts->lock); +/* Preallocate control endpoint request. */ uvc->control_req =usb_ep_alloc_request (cdev->gadget->ep0,GFP_KERNEL ); uvc->control_buf =kmalloc (UVC_MAX_REQUEST_SIZE ,GFP_KERNEL );
@@ -868,6 +880,8 @@ uvc_function_bind(struct usb_configuratireturn 0 ; +error_unlock: +mutex_unlock (&opts->lock); v4l2_error:v4l2_device_unregister (&uvc->v4l2_dev); error:
Greg Kroah-Hartman
maintainerPATCH 231/307 usb: gadget: net2280: Fix double free in probe error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit c8547c74988e0b5f4cbb1b895e2a57aae084f070 upstream.
usb_initialize_gadget() installs gadget_release() as the release callback for the embedded gadget device. The struct net2280 instance is therefore released through gadget_release() when the gadget device's last reference is dropped.
The probe error path calls net2280_remove(), which tears down the partially initialized device and drops the gadget reference with usb_put_gadget(). Calling kfree(dev) afterwards can free the same object again.
Drop the explicit kfree() and let the gadget device release callback handle the final free. This issue was found by a static analysis tool I am developing.
--- drivers/usb/gadget/udc/net2280.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/gadget/udc/net2280.c +1 -3
@@ -3790,10 +3790,8 @@ static int net2280_probe(struct pci_devreturn 0 ; done: -if (dev) { +if (dev)net2280_remove (pdev); -kfree (dev); - }return retval; }
Greg Kroah-Hartman
maintainerPATCH 232/307 usb: gadget: f_hid: fix device reference leak in hidg_alloc()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit 4f88d65def6f3c90121601b4f62a4c967f3063a6 upstream.
hidg_alloc() initializes hidg->dev with device_initialize() before calling dev_set_name(). If dev_set_name() fails, the function currently jumps to err_unlock and returns without calling put_device().
This leaves the device reference unbalanced and prevents hidg_release() from being called. Calling put_device() here is also safe, since hidg_release() only frees resources owned by hidg.
The issue was identified by a static analysis tool I developed and confirmed by manual review.
Route the dev_set_name() failure path through err_put_device so the device reference is dropped properly.
--- drivers/usb/gadget/function/f_hid.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/gadget/function/f_hid.c +1 -2
@@ -1562,7 +1562,7 @@ static struct usb_function *hidg_alloc(s hidg->dev.devt =MKDEV (major, opts->minor); ret =dev_set_name (&hidg->dev,"hidg%d" , opts->minor);if (ret) - goto err_unlock; + goto err_put_device; hidg->bInterfaceSubClass = opts->subclass; hidg->bInterfaceProtocol = opts->protocol;
@@ -1597,7 +1597,6 @@ static struct usb_function *hidg_alloc(s err_put_device:put_device (&hidg->dev); -err_unlock:mutex_unlock (&opts->lock);return ERR_PTR (ret); }
Greg Kroah-Hartman
maintainerPATCH 233/307 usb: gadget: composite: fix integer underflow in WebUSB GET_URL handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Erazo <[email protected]>
commit 6c5dbc104dadd79fc2923497c20bae759a18758c upstream.
The WebUSB GET_URL handler in composite_setup() narrows landing_page_length to fit the host-supplied wLength using
landing_page_length = w_length
- WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_offset;
If wLength is smaller than WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH the unsigned subtraction wraps, and the subsequent
memcpy(url_descriptor->URL, cdev->landing_page + landing_page_offset, landing_page_length - landing_page_offset);
ends up copying close to UINT_MAX bytes from cdev->landing_page into cdev->req->buf. KASAN reports a slab-out-of-bounds in composite_setup on the kmalloc-2k gadget_info allocation, and FORTIFY_SOURCE traps the memcpy as a 4294967293-byte field-spanning write into url_descriptor->URL (size 252).
A USB host can reach this from a single SETUP packet against any gadget that has webusb/use=1 and a landingPage configured.
Handle the small-wLength case before the math: when the host requested fewer bytes than the URL descriptor header, only the header is meaningful and no URL bytes need to be copied. Setting landing_page_length to landing_page_offset makes the existing memcpy a no-op and leaves the descriptor returned to the host unchanged for all larger wLength values.
--- drivers/usb/gadget/composite.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/gadget/composite.c +4 -1
@@ -2196,7 +2196,10 @@ unknown:sizeof (url_descriptor->URL) - WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_offset); -if (w_length <WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_length) +if (w_length <WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH ) + landing_page_length = landing_page_offset; +else if (w_length < +WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_length) landing_page_length = w_length -WEBUSB_URL_DESCRIPTOR_HEADER_LENGTH + landing_page_offset;
Greg Kroah-Hartman
maintainerPATCH 234/307 usb: gadget: dummy_hcd: Reject hub port requests for non-existent ports
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seungjin Bae <[email protected]>
commit 7d9633528dd40e33964d2dc74a5abbf5c4d116ce upstream.
The dummy_hub_control() function handles USB hub class requests to the virtual root hub. The GetPortStatus case returns -EPIPE for requests with wIndex != 1, since the virtual root hub has only a single port. However, the ClearPortFeature and SetPortFeature cases lack the same check.
Fix this by extending the wIndex != 1 rejection to both cases, matching the existing behavior of GetPortStatus.
--- drivers/usb/gadget/udc/dummy_hcd.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/gadget/udc/dummy_hcd.c +4 -0
@@ -2132,6 +2132,8 @@ static int dummy_hub_control(case ClearHubFeature:break ;case ClearPortFeature: +if (wIndex !=1 ) + goto error;switch (wValue) {case USB_PORT_FEAT_SUSPEND :if (hcd->speed ==HCD_USB3 ) {
@@ -2246,6 +2248,8 @@ static int dummy_hub_control( retval = -EPIPE ;break ;case SetPortFeature: +if (wIndex !=1 ) + goto error;switch (wValue) {case USB_PORT_FEAT_LINK_STATE :if (hcd->speed !=HCD_USB3 ) {
Greg Kroah-Hartman
maintainerPATCH 235/307 usb: gadget: f_fs: copy only received bytes on short ep0 read
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 4e036c10e7f4df5d951c69cc3697bc8e209c6d02 upstream.
ffs_ep0_read() allocates its control-OUT data buffer with kmalloc() (not kzalloc) at the Length value from the Setup packet, then copies that full len to userspace regardless of how many bytes were actually received:
data = kmalloc(len, GFP_KERNEL);
...
ret = __ffs_ep0_queue_wait(ffs, data, len);
if ((ret > 0) && (copy_to_user(buf, data, len)))
ret = -EFAULT;__ffs_ep0_queue_wait() returns req->actual, which on a short control OUT transfer is strictly less than len. The copy_to_user() call still copies len bytes, so on a short OUT the last (len - ret) bytes of the kmalloc() buffer -- uninitialised slab residue -- are delivered to the FunctionFS daemon.
Short ep0 OUT completions are specified USB control-transfer behavior and are produced by in-tree UDCs:
* dwc2 continues on req->actual < req->length for ep0 DATA OUT (short-not-ok is the only ep0-OUT stall path).
* aspeed_udc ends ep0 OUT on rx_len < ep->ep.maxpacket.
* renesas_usbf logs "ep0 short packet" and completes the request.
* dwc3 stalls on short IN but not on short OUT.
A short ep0 OUT is therefore not evidence of a broken UDC; it is a normal condition f_fs has to cope with. The sibling gadgetfs implementation in drivers/usb/gadget/legacy/inode.c already does this correctly via min(len, dev->req->actual) before copy_to_user(). This patch brings f_fs.c to the same safe pattern rather than trimming at a defensive layer.
The bug is reached from the FunctionFS device node, which in real deployments is owned by the privileged gadget daemon (adbd, UMS, composite gadget services, etc.); it is not reachable from unprivileged userspace. Linux host stacks normally reject short-wLength control OUTs before they reach the gadget, so reproducing this required a build that bypasses that host-side check. With the bypass in place, a 1-byte payload on a 64-byte Setup produces 63 bytes of non-canary slab residue in the daemon's read buffer.
Fix by copying only ret (actually received) bytes to userspace.
--- drivers/usb/gadget/function/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_fs.c +1 -1
@@ -622,7 +622,7 @@ static ssize_t ffs_ep0_read(struct file/* unlocks spinlock */ ret =__ffs_ep0_queue_wait (ffs, data, len); -if ((ret >0 ) && (copy_to_user (buf, data, len))) +if ((ret >0 ) && (copy_to_user (buf, data, ret))) ret = -EFAULT ; goto done_mutex;
Greg Kroah-Hartman
maintainerPATCH 236/307 usb: gadget: f_fs: serialize DMABUF cancel against request completion
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 2796646f6d892c1eb6818c7ca41fdfa12568e8d1 upstream.
ffs_epfile_dmabuf_io_complete() calls usb_ep_free_request() on the completed request but leaves priv->req, the back-pointer that ffs_dmabuf_transfer() set on submission, pointing at the freed memory. A later FUNCTIONFS_DMABUF_DETACH ioctl or ffs_epfile_release() on the close path still sees priv->req non-NULL under ffs->eps_lock:
if (priv->ep && priv->req)
usb_ep_dequeue(priv->ep, priv->req);so usb_ep_dequeue() is called on a freed usb_request.
On dummy_hcd the dequeue path only walks a live queue and pointer-compares, so the freed pointer reads without faulting and KASAN requires an explicit check at the FunctionFS call site to surface the use-after-free. On SG-capable in-tree UDCs the dequeue path dereferences the supplied request immediately:
* chipidea's ep_dequeue() does
container_of(req, struct ci_hw_req, req) and reads hwreq->req.status before acquiring its own lock.
* cdnsp's cdnsp_gadget_ep_dequeue() reads request->status first.
The narrower option of clearing priv->req via cmpxchg() in the completion does not close the race: the completion runs without eps_lock, so a cancel path holding eps_lock can still observe priv->req non-NULL, race a concurrent completion that clears and frees, and pass the freed pointer to usb_ep_dequeue(). A slightly longer fix that moves the free into the cleanup work is needed.
Same class of lifetime race as the recent usbip-vudc timer fix [1].
Take eps_lock in the sole place that mutates priv->req from the callback direction by moving usb_ep_free_request() out of the completion into ffs_dmabuf_cleanup(), the existing work handler scheduled by ffs_dmabuf_signal_done() on ffs->io_completion_wq. Clear priv->req there under eps_lock before freeing, and only clear if priv->req still names our request (a subsequent ffs_dmabuf_transfer() on the same attachment may have queued a new one).
This keeps the existing dummy_hcd sync-dequeue invariant: the completion callback is still invoked by the UDC without eps_lock held (dummy_hcd drops its own lock before calling the callback), and the callback now takes no f_fs lock at all. Serialization against the cancel path happens in cleanup, which runs from the workqueue with no f_fs lock held on entry.
The priv ref count protects the containing ffs_dmabuf_priv:ffs_dmabuf_transfer() takes a ref via ffs_dmabuf_get(), cleanup drops it via ffs_dmabuf_put(), so priv stays live for the cleanup even after the cancel path's list_del + ffs_dmabuf_put.
The ffs_dmabuf_transfer() error path no longer frees usb_req
inline: fence->req and fence->ep are set before usb_ep_queue(), so ffs_dmabuf_cleanup() (scheduled by the error-path ffs_dmabuf_signal_done()) owns the free regardless of whether the queue succeeded.
Reproduced under KASAN on both detach and close paths against dummy_hcd with an observability hook (kasan_check_byte(priv->req) immediately before usb_ep_dequeue) at the two FunctionFS cancel sites to surface the stale-pointer access; the hook is not part of this patch. The KASAN allocator / free stacks in the captured splats identify the same request: alloc in dummy_alloc_request, free in dummy_timer, fault reached from ffs_epfile_release (close) and from the FUNCTIONFS_DMABUF_DETACH ioctl (detach). With the patch applied, both paths are silent under the same hook.
The bug is reached from the FunctionFS device node, which in real deployments is owned by the privileged gadget daemon (adbd, UMS, composite gadget services, etc.); it is not reachable from unprivileged userspace or from a USB host on the cable. FunctionFS mounts default to GLOBAL_ROOT_UID, but the filesystem supports uid=, gid=, and fmode= delegation to a non-root gadget daemon, so on real deployments the attacker may be a less-privileged service rather than root.
--- drivers/usb/gadget/function/f_fs.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/usb/gadget/function/f_fs.c +22 -2
@@ -151,6 +151,8 @@ struct ffs_dma_fence {struct dma_fence base;struct ffs_dmabuf_priv *priv;struct work_struct work; +struct usb_ep *ep; +struct usb_request *req; };struct ffs_epfile {
@@ -1375,6 +1377,21 @@ static void ffs_dmabuf_cleanup(struct wostruct ffs_dmabuf_priv *priv = dma_fence->priv;struct dma_buf_attachment *attach = priv->attach;struct dma_fence *fence = &dma_fence->base; +struct usb_request *req = dma_fence->req; +struct usb_ep *ep = dma_fence->ep; + +/* +* eps_lock pairs with the cancel paths so they cannot pass a freed +* req to usb_ep_dequeue(). Only clear if priv->req still names ours; +* a re-queue on the same attachment may have taken that slot. +*/ +spin_lock_irq (&priv->ffs->eps_lock); +if (priv->req == req) + priv->req =NULL ; +spin_unlock_irq (&priv->ffs->eps_lock); + +if (ep && req) +usb_ep_free_request (ep, req);ffs_dmabuf_put (attach);dma_fence_put (fence);
@@ -1404,8 +1421,8 @@ static void ffs_epfile_dmabuf_io_complet struct usb_request *req) {pr_vdebug ("FFS: DMABUF transfer complete, status=%d\n" , req->status); +/* req is freed by ffs_dmabuf_cleanup() under eps_lock. */ ffs_dmabuf_signal_done (req->context, req->status); -usb_ep_free_request (ep, req); }static const char *ffs_dmabuf_get_driver_name (struct dma_fence *fence)
@@ -1689,6 +1706,10 @@ static int ffs_dmabuf_transfer(struct fi usb_req->context = fence; usb_req->complete = ffs_epfile_dmabuf_io_complete; +/* ffs_dmabuf_cleanup() frees usb_req via these two fields. */ + fence->req = usb_req; + fence->ep = ep->ep; + cookie =dma_fence_begin_signalling (); ret =usb_ep_queue (ep->ep, usb_req,GFP_ATOMIC );dma_fence_end_signalling (cookie);
@@ -1698,7 +1719,6 @@ static int ffs_dmabuf_transfer(struct fi }else {pr_warn ("FFS: Failed to queue DMABUF: %d\n" , ret);ffs_dmabuf_signal_done (fence, ret); -usb_ep_free_request (ep->ep, usb_req); }spin_unlock_irq (&epfile->ffs->eps_lock);
Greg Kroah-Hartman
maintainerPATCH 237/307 thunderbolt: property: Reject u32 wrap in tb_property_entry_valid()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 01deda0152066c6c955f0619114ea6afa070aaec upstream.
entry->value is u32 and entry->length is u16; the sum is performed in u32 and wraps. A malicious XDomain peer can pick
value = 0xffffff00, length = 0x100 so the sum 0x100000000 wraps to 0 and passes the > block_len check. tb_property_parse() then passes entry->value to parse_dwdata() as a dword offset into the property block, reading attacker-directed memory far past the allocation.
For TEXT-typed entries with the "deviceid" or "vendorid" keys this lands in xd->device_name / xd->vendor_name and is readable back via the per-XDomain device_name / vendor_name sysfs attributes; the leak is NUL-bounded (kstrdup() stops at the first zero byte) and untargeted (the attacker picks a delta, not an absolute address). DATA-typed entries are parsed into property->value.data but not generically surfaced to userspace.
Use check_add_overflow() so a wrapped sum is rejected.
--- drivers/thunderbolt/property.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/thunderbolt/property.c +5 -1
@@ -8,6 +8,7 @@*/ #include <linux/err.h> +#include <linux/overflow.h> #include <linux/slab.h> #include <linux/string.h> #include <linux/uuid.h>
@@ -52,13 +53,16 @@ static inline void format_dwdata(void *dstatic bool tb_property_entry_valid (const struct tb_property_entry *entry,size_t block_len) { +u32 end; +switch (entry->type) {case TB_PROPERTY_TYPE_DIRECTORY :case TB_PROPERTY_TYPE_DATA :case TB_PROPERTY_TYPE_TEXT :if (entry->length > block_len)return false; -if (entry->value + entry->length > block_len) +if (check_add_overflow (entry->value, entry->length, &end) || + end > block_len)return false;break ;
Greg Kroah-Hartman
maintainerPATCH 238/307 thunderbolt: property: Reject dir_len < 4 to prevent size_t underflow
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit de21b59c29e31c5108ddc04210631bbfab81b997 upstream.
On the non-root path, __tb_property_parse_dir() takes dir_len from entry->length (u16 widened to size_t). Two distinct OOB conditions follow when entry->length < 4:
1. The non-root path begins with kmemdup(&block[dir_offset], sizeof(*dir->uuid), ...) which always reads 4 dwords from dir_offset. tb_property_entry_valid() only enforces dir_offset + entry->length <= block_len, so a crafted entry with dir_offset close to the end of the property block and entry->length in 0..3 passes that gate but lets the UUID copy run off the block (e.g. dir_offset = 497, dir_len = 3 in a 500-dword block reads block[497..501]).
2. After the kmemdup, content_len = dir_len - 4 underflows size_t to ~SIZE_MAX, nentries becomes SIZE_MAX / 4, and the entry walk runs OOB on each iteration until an entry fails validation or the kernel oopses on an unmapped page.
Reject dir_len < 4 on the non-root path *before* the UUID kmemdup, which closes both holes.
Also move INIT_LIST_HEAD(&dir->properties) up to immediately after the dir allocation so the new error-return path (and the existing uuid-alloc failure path) calling tb_property_free_dir() sees a walkable list rather than the zero-initialized NULL next/prev that list_for_each_entry_safe() would oops on.
--- drivers/thunderbolt/property.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/thunderbolt/property.c +6 -2
@@ -174,10 +174,16 @@ static struct tb_property_dir *__tb_propif (!dir)return NULL ; +INIT_LIST_HEAD (&dir->properties); +if (is_root) { content_offset = dir_offset +2 ; content_len = dir_len; }else { +if (dir_len <4 ) { +tb_property_free_dir (dir); +return NULL ; + } dir->uuid =kmemdup (&block[dir_offset],sizeof (*dir->uuid),GFP_KERNEL );if (!dir->uuid) {
@@ -191,8 +197,6 @@ static struct tb_property_dir *__tb_prop entries = (const struct tb_property_entry *)&block[content_offset]; nentries = content_len / (sizeof (*entries) /4 ); -INIT_LIST_HEAD (&dir->properties); -for (i =0 ; i < nentries; i++) {struct tb_property *property;
Greg Kroah-Hartman
maintainerPATCH 239/307 scsi: fcoe: Reject FIP descriptors with zero fip_dlen in CVL walker
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit 9eed1bd59937e6828b00d2f2dfef631d964f3636 upstream.
drivers/scsi/fcoe/fcoe_ctlr.c::fcoe_ctlr_recv_clr_vlink() advanced the descriptor cursor by an attacker-supplied fip_dlen without ever requiring dlen >= sizeof(struct fip_desc) in the default branch. The named descriptor cases (FIP_DT_MAC, FIP_DT_NAME, FIP_DT_VN_ID) checked their per-type minimum lengths, but a FIP_DT_NON_CRITICAL descriptor (fip_dtype >= 128, which the standard requires receivers to silently ignore) skipped that check entirely.
An unauthenticated L2 peer on the FCoE control VLAN could hang fcoe_ctlr_recv_work on an fcoe, qedf, or bnx2fc initiator indefinitely by emitting one FIP CVL frame whose single descriptor had fip_dtype == FIP_DT_NON_CRITICAL and fip_dlen == 0: the cursor advanced zero bytes per iteration and the loop condition rlen >= sizeof(*desc) stayed true forever, blocking every subsequent FIP frame on that controller.
Tighten the outer dlen guard to also reject dlen < sizeof(struct fip_desc), so a malformed descriptor whose length cannot even cover the descriptor header is rejected before the switch. This is the same lower-bound the named cases already apply and is the minimum scope that closes the loop.
--- drivers/scsi/fcoe/fcoe_ctlr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/fcoe/fcoe_ctlr.c +1 -1
@@ -1386,7 +1386,7 @@ static void fcoe_ctlr_recv_clr_vlink(strwhile (rlen >=sizeof (*desc)) { dlen = desc->fip_dlen *FIP_BPW ; -if (dlen > rlen) +if (dlen <sizeof (*desc) || dlen > rlen) goto err;/* Drop CVL if there are duplicate critical descriptors */ if ((desc->fip_dtype < 32) &&
Greg Kroah-Hartman
maintainerPATCH 240/307 scsi: scsi_transport_fc: Widen FPIN pname walker counter to u32
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit a9a39233ec1fc9f97ea1340a4d09bb7ec2be5153 upstream.
An adjacent Fibre Channel fabric actor that can deliver an FPIN ELS frame to an lpfc or qla2xxx Linux initiator can trigger a non-return in the generic FC transport. This is not a local userspace or IP network path; the attacker must be able to inject fabric traffic, for example as a compromised switch or fabric controller, or as a same-zone N_Port on a fabric that permits source spoofing.
The Link-Integrity and Peer-Congestion FPIN walkers used a u8 loop counter against the 32-bit on-wire pname_count field, and did not bound pname_count by the descriptor body already validated by the TLV walker. A pname_count of 256 therefore wraps the counter and keeps the loop condition true indefinitely.
Factor the shared pname_list[] walk into one helper, widen the counter to u32, and clamp pname_count against the entries that fit in the descriptor body before iterating.
--- drivers/scsi/scsi_transport_fc.c | 77 ++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 36 deletions(-)
drivers/scsi/scsi_transport_fc.c +41 -36
@@ -742,6 +742,37 @@ fc_cn_stats_update(u16 event_type, struc } } +static void +fc_fpin_pname_stats_update (struct Scsi_Host *shost, +struct fc_rport *attach_rport,u16 event_type, +u32 desc_len,u32 fixed_len,u32 pname_count, +__be64 *pname_list, +void (*stats_update)(u16 event_type, +struct fc_fpin_stats *stats)) +{ +u32 i; +struct fc_rport *rport; +u64 wwpn; + +if (desc_len < fixed_len) + pname_count =0 ; +else + pname_count =min (pname_count, (desc_len - fixed_len) / +sizeof (pname_list[0 ])); + +for (i =0 ; i < pname_count; i++) { + wwpn =be64_to_cpu (pname_list[i]); + rport =fc_find_rport_by_wwpn (shost, wwpn); +if (rport && + (rport->roles &FC_PORT_ROLE_FCP_TARGET || + rport->roles &FC_PORT_ROLE_NVME_TARGET )) { +if (rport == attach_rport) +continue ; +stats_update (event_type, &rport->fpin_stats); + } + } +} +/* * fc_fpin_li_stats_update - routine to update Link Integrity * event statistics.
@@ -752,13 +783,11 @@ fc_cn_stats_update(u16 event_type, strucstatic void fc_fpin_li_stats_update (struct Scsi_Host *shost,struct fc_tlv_desc *tlv) { -u8 i;struct fc_rport *rport =NULL ;struct fc_rport *attach_rport =NULL ;struct fc_host_attrs *fc_host =shost_to_fc_host (shost);struct fc_fn_li_desc *li_desc = (struct fc_fn_li_desc *)tlv;u16 event_type =be16_to_cpu (li_desc->event_type); -u64 wwpn; rport =fc_find_rport_by_wwpn (shost,be64_to_cpu (li_desc->attached_wwpn));
@@ -769,22 +798,11 @@ fc_fpin_li_stats_update(struct Scsi_Hostfc_li_stats_update (event_type, &attach_rport->fpin_stats); } -if (be32_to_cpu (li_desc->pname_count) >0 ) { -for (i =0 ; - i <be32_to_cpu (li_desc->pname_count); - i++) { - wwpn =be64_to_cpu (li_desc->pname_list[i]); - rport =fc_find_rport_by_wwpn (shost, wwpn); -if (rport && - (rport->roles &FC_PORT_ROLE_FCP_TARGET || - rport->roles &FC_PORT_ROLE_NVME_TARGET )) { -if (rport == attach_rport) -continue ; -fc_li_stats_update (event_type, - &rport->fpin_stats); - } - } - } +fc_fpin_pname_stats_update (shost, attach_rport, event_type, +be32_to_cpu (li_desc->desc_len), +FC_TLV_DESC_LENGTH_FROM_SZ (*li_desc), +be32_to_cpu (li_desc->pname_count), + li_desc->pname_list, fc_li_stats_update);if (fc_host->port_name ==be64_to_cpu (li_desc->attached_wwpn))fc_li_stats_update (event_type, &fc_host->fpin_stats);
@@ -832,13 +850,11 @@ static void fc_fpin_peer_congn_stats_update(struct Scsi_Host *shost, struct fc_tlv_desc *tlv) { - u8 i; struct fc_rport *rport = NULL;struct fc_rport *attach_rport =NULL ;struct fc_fn_peer_congn_desc *pc_desc = (struct fc_fn_peer_congn_desc *)tlv;u16 event_type =be16_to_cpu (pc_desc->event_type); -u64 wwpn; rport =fc_find_rport_by_wwpn (shost,be64_to_cpu (pc_desc->attached_wwpn));
@@ -849,22 +865,11 @@ fc_fpin_peer_congn_stats_update(struct Sfc_cn_stats_update (event_type, &attach_rport->fpin_stats); } -if (be32_to_cpu (pc_desc->pname_count) >0 ) { -for (i =0 ; - i <be32_to_cpu (pc_desc->pname_count); - i++) { - wwpn =be64_to_cpu (pc_desc->pname_list[i]); - rport =fc_find_rport_by_wwpn (shost, wwpn); -if (rport && - (rport->roles &FC_PORT_ROLE_FCP_TARGET || - rport->roles &FC_PORT_ROLE_NVME_TARGET )) { -if (rport == attach_rport) -continue ; -fc_cn_stats_update (event_type, - &rport->fpin_stats); - } - } - } +fc_fpin_pname_stats_update (shost, attach_rport, event_type, +be32_to_cpu (pc_desc->desc_len), +FC_TLV_DESC_LENGTH_FROM_SZ (*pc_desc), +be32_to_cpu (pc_desc->pname_count), + pc_desc->pname_list, fc_cn_stats_update); }/*
Greg Kroah-Hartman
maintainerPATCH 241/307 scsi: target: iscsi: Bound iscsi_encode_text_output() appends to rsp_buf
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
commit bf33e01f88388c43e285492a63e539df6ffed64c upstream.
iscsi_encode_text_output() concatenates "key=value\0" records into login->rsp_buf, an 8192-byte kzalloc(MAX_KEY_VALUE_PAIRS) buffer allocated in iscsit_alloc_login_setup_buffer(). The three sprintf() call sites in this function (lines 1398, 1411, 1424 in v7.1-rc2) never check the remaining buffer capacity:
*length += sprintf(output_buf, "%s=%s", er->key, er->value); *length += 1; output_buf = textbuf + *length;
The 8192-byte ceiling at iscsi_target_check_login_request() bounds the *input* Login PDU payload, but a single PDU can carry up to 2048 minimal four-byte "a=b\0" pairs, each unknown key expanding to a 16-byte "a=NotUnderstood\0" output record via iscsi_add_notunderstood_response(). 2048 * 16 = 32 KiB of output into an 8 KiB buffer, producing a ~24 KiB heap overrun in the kmalloc-8k slab.
The fix introduces a static iscsi_encode_text_record() helper that uses snprintf() with a per-call bounds check against the remaining buffer, and threads a u32 textbuf_size parameter through iscsi_encode_text_output(). Both call sites in iscsi_target_handle_csg_zero() (PHASE_SECURITY) and iscsi_target_handle_csg_one() (PHASE_OPERATIONAL) pass MAX_KEY_VALUE_PAIRS. On overflow the encoder logs the condition, calls iscsi_release_extra_responses() to drop queued records, and returns -1; both caller sites now emit ISCSI_STATUS_CLS_INITIATOR_ERR / ISCSI_LOGIN_STATUS_INIT_ERR via iscsit_tx_login_rsp() before returning, so the initiator sees an explicit failed-login response rather than a silent connection drop. (Prior to this patch only the PHASE_OPERATIONAL caller did that; the PHASE_SECURITY caller is converted to the same shape.)
--- drivers/target/iscsi/iscsi_target_nego.c | 7 ++ drivers/target/iscsi/iscsi_target_parameters.c | 62 +++++++++++++++++++------ drivers/target/iscsi/iscsi_target_parameters.h | 2 3 files changed, 55 insertions(+), 16 deletions(-)
drivers/target/iscsi/iscsi_target_nego.c +6 -1
@@ -899,10 +899,14 @@ static int iscsi_target_handle_csg_zero(SENDER_TARGET , login->rsp_buf, &login->rsp_length, +MAX_KEY_VALUE_PAIRS , conn->param_list, conn->tpg->tpg_attrib.login_keys_workaround); -if (ret <0 ) +if (ret <0 ) { +iscsit_tx_login_rsp (conn,ISCSI_STATUS_CLS_INITIATOR_ERR , +ISCSI_LOGIN_STATUS_INIT_ERR );return -1 ; + }if (!iscsi_check_negotiated_keys (conn->param_list)) {bool auth_required =iscsi_conn_auth_required (conn);
@@ -986,6 +990,7 @@ static int iscsi_target_handle_csg_one(sSENDER_TARGET , login->rsp_buf, &login->rsp_length, +MAX_KEY_VALUE_PAIRS , conn->param_list, conn->tpg->tpg_attrib.login_keys_workaround);if (ret <0 ) {
drivers/target/iscsi/iscsi_target_parameters.c +48 -14
101 lines not on this page · raw message
drivers/target/iscsi/iscsi_target_parameters.h +1 -1
@@ -46,7 +46,7 @@ extern struct iscsi_param *iscsi_find_paextern int iscsi_extract_key_value (char *,char **,char **);extern int iscsi_update_param_value (struct iscsi_param *,char *);extern int iscsi_decode_text_input (u8 ,u8 ,char *,u32 ,struct iscsit_conn *); -extern int iscsi_encode_text_output (u8 ,u8 ,char *,u32 *, +extern int iscsi_encode_text_output (u8 ,u8 ,char *,u32 *,u32 ,struct iscsi_param_list *,bool );extern int iscsi_check_negotiated_keys (struct iscsi_param_list *); extern void iscsi_set_connection_parameters(struct iscsi_conn_ops *,
Greg Kroah-Hartman
maintainerPATCH 242/307 scsi: target: iscsi: Validate CHAP_R length before base64 decode
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandru Hossu <[email protected]>
commit 85db7391310b1304d2dc8ae3b0b12105a9567147 upstream.
chap_server_compute_hash() allocates client_digest as kzalloc(chap->digest_size) and then, for BASE64-encoded responses, passes chap_r directly to chap_base64_decode() without checking whether the input length could produce more than digest_size bytes of output.
chap_base64_decode() writes to the destination unconditionally as long as there is input to consume. With MAX_RESPONSE_LENGTH set to 128 and the "0b" prefix stripped by extract_param(), up to 127 base64 characters can reach the decoder. 127 characters decode to 95 bytes. For SHA-256 (digest_size=32) this overflows client_digest by 63 bytes; for MD5 (digest_size=16) the overflow is 79 bytes.
The length check at line 344 fires after the write has already happened.
The HEX branch in the same switch statement already validates the length up front. Apply the same approach to the BASE64 branch: strip trailing base64 padding characters, then reject any input whose data length exceeds DIV_ROUND_UP(digest_size * 4, 3) before calling the decoder.
Stripping trailing '=' before the comparison handles both padded and unpadded encodings. chap_base64_decode() already returns early on '=', so the full original string is still passed to the decoder unchanged.
The mutual CHAP path decodes CHAP_C into initiatorchg_binhex, which is kzalloc(CHAP_CHALLENGE_STR_LEN). extract_param() caps initiatorchg at CHAP_CHALLENGE_STR_LEN characters, so at most CHAP_CHALLENGE_STR_LEN-1 base64 characters reach the decoder. The maximum decoded size, DIV_ROUND_UP((CHAP_CHALLENGE_STR_LEN-1) * 3, 4), is less than CHAP_CHALLENGE_STR_LEN, so no overflow is possible there. A comment is added at the call site to document this.
--- drivers/target/iscsi/iscsi_target_auth.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target_auth.c +18 -1
@@ -339,13 +339,22 @@ static int chap_server_compute_hash( goto out; }break ; -case BASE64 : +case BASE64 : { +size_t r_len =strlen (chap_r); + +while (r_len >0 && chap_r[r_len -1 ] =='=' ) + r_len--; +if (r_len >DIV_ROUND_UP (chap->digest_size *4 ,3 )) { +pr_err ("Malformed CHAP_R: base64 payload too long\n" ); + goto out; + }if (chap_base64_decode (client_digest, chap_r,strlen (chap_r)) != chap->digest_size) {pr_err ("Malformed CHAP_R: invalid BASE64\n" ); goto out; }break ; + }default :pr_err ("Could not find CHAP_R\n" ); goto out;
@@ -472,6 +481,14 @@ static int chap_server_compute_hash( }break ;case BASE64 : +/* +* No overflow check needed: initiatorchg_binhex is +* CHAP_CHALLENGE_STR_LEN bytes and extract_param() caps +* initiatorchg at CHAP_CHALLENGE_STR_LEN characters, so +* the decoded output is at most DIV_ROUND_UP( +* (CHAP_CHALLENGE_STR_LEN - 1) * 3, 4) bytes, which is +* less than CHAP_CHALLENGE_STR_LEN. +*/ initiatorchg_len =chap_base64_decode (initiatorchg_binhex, initiatorchg,strlen (initiatorchg));
Greg Kroah-Hartman
maintainerPATCH 243/307 drm/hyperv: validate resolution_count and fix WIN8 fallback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Berkant Koc <[email protected]>
commit 13d33b9ef67066c77c84273fac5a1d3fde3533d1 upstream.
A SYNTHVID_RESOLUTION_RESPONSE with resolution_count > 64 walks past the supported_resolution[SYNTHVID_MAX_RESOLUTION_COUNT] array in the parse loop. Bound resolution_count against the array size, folded into the existing zero-check.
When the WIN10 resolution probe fails, the caller in hyperv_connect_vsp() left hv->screen_*_max / preferred_* unpopulated, which sets mode_config.max_width / max_height to 0 and makes drm_internal_framebuffer_create() reject every userspace framebuffer with -EINVAL. The pre-WIN10 branch had the same gap for preferred_width / preferred_height. Use a single post-probe fallback guarded by screen_width_max == 0 so both paths converge on the WIN8 defaults.
--- drivers/gpu/drm/hyperv/hyperv_drm_proto.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +10 -3
@@ -396,8 +396,11 @@ static int hyperv_get_supported_resolutireturn -ETIMEDOUT ; } -if (msg->resolution_resp.resolution_count ==0 ) { -drm_err (dev,"No supported resolutions\n" ); +if (msg->resolution_resp.resolution_count ==0 || + msg->resolution_resp.resolution_count > +SYNTHVID_MAX_RESOLUTION_COUNT ) { +drm_err (dev,"Invalid resolution count: %d\n" , + msg->resolution_resp.resolution_count);return -ENODEV ; }
@@ -513,9 +516,13 @@ int hyperv_connect_vsp(struct hv_device ret =hyperv_get_supported_resolution (hdev);if (ret)drm_err (dev,"Failed to get supported resolution from host, use default\n" ); - }else { + } + +if (!hv->screen_width_max) { hv->screen_width_max =SYNTHVID_WIDTH_WIN8 ; hv->screen_height_max =SYNTHVID_HEIGHT_WIN8 ; + hv->preferred_width =SYNTHVID_WIDTH_WIN8 ; + hv->preferred_height =SYNTHVID_HEIGHT_WIN8 ; } hv->mmio_megabytes = hdev->channel->offermsg.offer.mmio_megabytes;
Greg Kroah-Hartman
maintainerPATCH 244/307 drm/hyperv: validate VMBus packet size in receive callback
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Berkant Koc <[email protected]>
commit 7f87763f47a3c22fb50265a00619ef10f2394b18 upstream.
hyperv_receive_sub() reads msg->vid_hdr.type and dispatches into one of four message-type branches without knowing how many bytes the host wrote into hv->recv_buf. The completion path then runs memcpy(hv->init_buf, msg, VMBUS_MAX_PACKET_SIZE), so the consumer that wakes on wait_for_completion_timeout() can read up to 16 KiB of residue from a prior message as if it were the response payload.
Pass bytes_recvd into hyperv_receive_sub() and reject any packet that does not cover the pipe + synthvid header. A single switch on msg->vid_hdr.type then computes the type-specific payload size: the three completion-driving types (SYNTHVID_VERSION_RESPONSE, SYNTHVID_RESOLUTION_RESPONSE, SYNTHVID_VRAM_LOCATION_ACK) fall through to a shared exit that requires that size before memcpy/complete, while SYNTHVID_FEATURE_CHANGE validates its own payload and returns before reading is_dirt_needed. Unknown types are dropped.
SYNTHVID_RESOLUTION_RESPONSE is variable length: the host fills resolution_count entries, not the full SYNTHVID_MAX_RESOLUTION_COUNT array. Validate the fixed prefix first so resolution_count can be read, bound it against the array, then require only the count-sized array, so the shorter responses the host actually sends are accepted.
Only run the sub-handler when vmbus_recvpacket() returned success. The memcpy length is bytes_recvd, which is bounded by VMBUS_MAX_PACKET_SIZE only on a successful receive; on -ENOBUFS vmbus_recvpacket() instead reports the required length, which can exceed hv->recv_buf, so copying bytes_recvd would read and write past the 16 KiB buffers. Gating on the success return keeps the copy bounded. The nonzero-return path is itself a malformed-message case and is now logged rather than silently skipped; channel recovery is not attempted.
Rejected packets are reported via drm_err_ratelimited() rather than silently dropped, matching the CoCo-hardened pattern in hv_kvp_onchannelcallback().
--- drivers/gpu/drm/hyperv/hyperv_drm_proto.c | 100 ++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 13 deletions(-)
drivers/gpu/drm/hyperv/hyperv_drm_proto.c +87 -13
@@ -425,30 +425,92 @@ static int hyperv_get_supported_resolutireturn 0 ; } -static void hyperv_receive_sub (struct hv_device *hdev) +static void hyperv_receive_sub (struct hv_device *hdev,u32 bytes_recvd) {struct hyperv_drm_device *hv =hv_get_drvdata (hdev);struct synthvid_msg *msg; +size_t hdr_size; +size_t need;if (!hv)return ; - msg = (struct synthvid_msg *)hv->recv_buf; - -/* Complete the wait event */ -if (msg->vid_hdr.type ==SYNTHVID_VERSION_RESPONSE || - msg->vid_hdr.type ==SYNTHVID_RESOLUTION_RESPONSE || - msg->vid_hdr.type ==SYNTHVID_VRAM_LOCATION_ACK ) { -memcpy (hv->init_buf, msg,VMBUS_MAX_PACKET_SIZE ); -complete (&hv->wait); + hdr_size =sizeof (struct pipe_msg_hdr ) + +sizeof (struct synthvid_msg_hdr ); +if (bytes_recvd < hdr_size) { +drm_err_ratelimited (&hv->dev, +"synthvid packet too small for header: %u\n" , + bytes_recvd);return ; } -if (msg->vid_hdr.type ==SYNTHVID_FEATURE_CHANGE ) { + msg = (struct synthvid_msg *)hv->recv_buf; + need = hdr_size; + +switch (msg->vid_hdr.type) { +case SYNTHVID_VERSION_RESPONSE : + need +=sizeof (struct synthvid_version_resp ); +break ; +case SYNTHVID_RESOLUTION_RESPONSE : +/* +* The resolution response is variable length: the host +* fills resolution_count entries, not the full +* SYNTHVID_MAX_RESOLUTION_COUNT array. Require the fixed +* prefix first so resolution_count can be read, then +* demand exactly the count-sized array. +*/ + need += offsetof(struct synthvid_supported_resolution_resp , + supported_resolution); +if (bytes_recvd < need) +break ; +if (msg->resolution_resp.resolution_count > +SYNTHVID_MAX_RESOLUTION_COUNT ) { +drm_err_ratelimited (&hv->dev, +"synthvid resolution count too large: %u\n" , + msg->resolution_resp.resolution_count); +return ; + } + need += msg->resolution_resp.resolution_count * +sizeof (struct hvd_screen_info ); +break ; +case SYNTHVID_VRAM_LOCATION_ACK : + need +=sizeof (struct synthvid_vram_location_ack ); +break ; +case SYNTHVID_FEATURE_CHANGE : +/* +* Not a completion-driving message: validate its own payload +* and consume it here rather than falling through to the +* memcpy/complete shared by the wait-event responses. +*/ +if (bytes_recvd < need + +sizeof (struct synthvid_feature_change )) { +drm_err_ratelimited (&hv->dev, +"synthvid feature change packet too small: %u\n" , + bytes_recvd); +return ; + } hv->dirt_needed = msg->feature_chg.is_dirt_needed;if (hv->dirt_needed)hyperv_hide_hw_ptr (hv->hdev); +return ; +default : +return ; + } + +/* +* Shared completion path for the wait-event responses +* (VERSION_RESPONSE, RESOLUTION_RESPONSE, VRAM_LOCATION_ACK): +* require the type-specific payload before handing the buffer to +* the waiter. +*/ +if (bytes_recvd < need) { +drm_err_ratelimited (&hv->dev, +"synthvid packet too small for type %u: %u < %zu\n" , + msg->vid_hdr.type, bytes_recvd, need); +return ; } +memcpy (hv->init_buf, msg, bytes_recvd); +complete (&hv->wait); }static void hyperv_receive (void *ctx)
@@ -469,9 +531,21 @@ static void hyperv_receive(void *ctx) ret =vmbus_recvpacket (hdev->channel, recv_buf,VMBUS_MAX_PACKET_SIZE , &bytes_recvd, &req_id); -if (bytes_recvd >0 && - recv_buf->pipe_hdr.type ==PIPE_MSG_DATA ) -hyperv_receive_sub (hdev); +if (ret) { +/* +* A nonzero return (e.g. -ENOBUFS for an oversized +* packet) is itself a malformed message: bytes_recvd +* then reports the required length rather than a copied +* payload, so it must not be forwarded to the +* sub-handler. Channel recovery is not attempted. +*/ +drm_err_ratelimited (&hv->dev, +"vmbus_recvpacket failed: %d (need %u)\n" , + ret, bytes_recvd); + }else if (bytes_recvd >0 && + recv_buf->pipe_hdr.type ==PIPE_MSG_DATA ) { +hyperv_receive_sub (hdev, bytes_recvd); + } }while (bytes_recvd >0 && ret ==0 ); }
Greg Kroah-Hartman
maintainerPATCH 245/307 drm/i915: Fix potential UAF in TTM object purge
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janusz Krzysztofik <[email protected]>
commit 5c4063c87a619e4df954c179d24628636f5db15f upstream.
TLDR: The bo->ttm object might be changed by calling ttm_bo_validate(),
move casting it to an i915_tt object later to actually get the right pointer.
A user reported hitting the following bug under heavy use on DG2:
[26620.095550] Oops: general protection fault, probably for non-canonical address 0xa56b6b6b6b6b6b8b: 0000 1 SMP NOPTI [26620.095556] CPU: 2 UID: 0 PID: 631 Comm: Xorg Not tainted 6.18.8 #1 PREEMPT(lazy) [26620.095558] Hardware name: ASRock B850M Steel Legend WiFi/B850M Steel Legend WiFi, BIOS 3.50 09/18/2025 [26620.095559] RIP: 0010:i915_ttm_purge+0x84/0x100 [i915] [26620.095604] Code: 00 00 00 48 8d 54 24 10 48 89 e6 48 89 fb e8 83 aa ae ff 85 c0 75 6f 48 83 bb a8 01 00 00 00 74 2c 48 8b 45 78 48 85 c0 74 23 <48> 8b 78 20 48 c7 c2 ff ff ff ff 31 f6 e8 7a 73 e3 e0 48 8b 7d 78 [26620.095605] RSP: 0018:ffffc90005fd7430 EFLAGS: 00010282 [26620.095607] RAX: a56b6b6b6b6b6b6b RBX: ffff8881f46c3dc0 RCX: 0000000000000000 [26620.095608] RDX: 0000000000000000 RSI: 0000000000000246 RDI: 00000000ffffffff [26620.095609] RBP: ffff888289610f00 R08: 0000000000000001 R09: ffff88823b022000 [26620.095609] R10: ffff888103029b28 R11: ffff8881fc7f3800 R12: ffff88810b6150d0 [26620.095609] R13: ffff888289610f00 R14: 0000000000000000 R15: ffff8881f46c3dc0 [26620.095610] FS: 00007f1004d86900(0000) GS:ffff88901c858000(0000) knlGS:0000000000000000 [26620.095611] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [26620.095611] CR2: 00007f0fdf489000 CR3: 000000035b0c1000 CR4: 0000000000750ef0 [26620.095612] PKRU: 55555554 [26620.095612] Call Trace: [26620.095615] <TASK> [26620.095615] i915_ttm_move+0x2b9/0x420 [i915] [26620.095642] ? ttm_tt_init+0x65/0x80 [ttm] [26620.095644] ? i915_ttm_tt_create+0xc6/0x150 [i915] [26620.095667] ttm_bo_handle_move_mem+0xb6/0x160 [ttm] [26620.095669] ttm_bo_evict+0x100/0x150 [ttm] [26620.095671] ? preempt_count_add+0x64/0xa0 [26620.095673] ? _raw_spin_lock+0xe/0x30 [26620.095675] ? _raw_spin_unlock+0xd/0x30 [26620.095675] ? i915_gem_object_evictable+0xb7/0xd0 [i915] [26620.095704] ttm_bo_evict_cb+0x6e/0xd0 [ttm] [26620.095705] ttm_lru_walk_for_evict+0xa6/0x200 [ttm] [26620.095708] ttm_bo_alloc_resource+0x185/0x4f0 [ttm] [26620.095709] ? init_object+0x62/0xd0 [26620.095712] ttm_bo_validate+0x7a/0x180 [ttm] [26620.095713] ? _raw_spin_unlock_irqrestore+0x16/0x30 [26620.095714] __i915_ttm_get_pages+0xb0/0x170 [i915] [26620.095737] i915_ttm_get_pages+0x9f/0x150 [i915] [26620.095759] ? i915_gem_do_execbuffer+0xedc/0x2b40 [i915] [26620.095786] ? alloc_debug_processing+0xd0/0x100 [26620.095787] ? _raw_spin_unlock_irqrestore+0x16/0x30 [26620.095788] ? i915_vma_instance+0xa0/0x4e0 [i915] [26620.095822] __i915_gem_object_get_pages+0x2f/0x40 [i915] [26620.095848] i915_vma_pin_ww+0x706/0x980 [i915] [26620.095875] ? i915_gem_do_execbuffer+0xedc/0x2b40 [i915] [26620.095904] eb_validate_vmas+0x170/0xa00 [i915] [26620.095930] i915_gem_do_execbuffer+0x1201/0x2b40 [i915] [26620.095953] ? alloc_debug_processing+0xd0/0x100 [26620.095954] ? _raw_spin_unlock_irqrestore+0x16/0x30 [26620.095955] ? i915_gem_execbuffer2_ioctl+0xc9/0x240 [i915] [26620.095977] ? __wake_up_sync_key+0x32/0x50 [26620.095979] ? i915_gem_execbuffer2_ioctl+0xc9/0x240 [i915] [26620.096001] ? __slab_alloc.isra.0+0x67/0xc0 [26620.096003] i915_gem_execbuffer2_ioctl+0x11a/0x240 [i915]
Results from decode_stacktrace.sh pointed to dereference of a file pointer field of a i915 TTM page vector container associated with an object being purged on eviction. That path is taken when the object is marked as no longer needed.
Code analysis revealed a possibility of the i915 TTM page vector container being replaced with a new instance inside a function that purges content of the object, should it be still busy. That function is called, indirectly via a more general function that changes the object's placement and caching policy, before the problematic dereference, but still after a pointer to the container is captured, rendering the pointer no longer valid.
Fix the issue by capturing the pointer to the container only after its potential replacement.
v2: Move the container_of() inside the if block (Sebastian),
- a simplified version of the commit description that explains briefly why the change is necessary (Christian).
--- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_ttm.c +16 -12
@@ -416,8 +416,6 @@ void i915_ttm_free_cached_io_rsgt(structint i915_ttm_purge (struct drm_i915_gem_object *obj) {struct ttm_buffer_object *bo =i915_gem_to_ttm (obj); -struct i915_ttm_tt *i915_tt = -container_of (bo->ttm,typeof (*i915_tt), ttm);struct ttm_operation_ctx ctx = { .interruptible = true, .no_wait_gpu = false,
@@ -432,16 +430,22 @@ int i915_ttm_purge(struct drm_i915_gem_oif (ret)return ret; -if (bo->ttm && i915_tt->filp) { -/* -* The below fput(which eventually calls shmem_truncate) might -* be delayed by worker, so when directly called to purge the -* pages(like by the shrinker) we should try to be more -* aggressive and release the pages immediately. -*/ -shmem_truncate_range (file_inode (i915_tt->filp), -0 , (loff_t)-1 ); -fput (fetch_and_zero (&i915_tt->filp)); +if (bo->ttm) { +struct i915_ttm_tt *i915_tt = +container_of (bo->ttm,typeof (*i915_tt), ttm); + +if (i915_tt->filp) { +/* +* The below fput(which eventually calls shmem_truncate) +* might be delayed by worker, so when directly called +* to purge the pages(like by the shrinker) we should +* try to be more aggressive and release the pages +* immediately. +*/ +shmem_truncate_range (file_inode (i915_tt->filp), +0 , (loff_t)-1 ); +fput (fetch_and_zero (&i915_tt->filp)); + } } obj->write_domain =0 ;
Greg Kroah-Hartman
maintainerPATCH 246/307 drm/amd/pm/si: Disregard vblank time when no displays are connected
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
commit dd4f3ee535b3b0ac027f75dbf9dc5fc88733c765 upstream.
When no displays are connected, there is no vblank happening so the power management code shouldn't worry about it.
This fixes a regression that caused the memory clock to be stuck at maximum when there were no displays connected to a SI GPU.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +4 -0
@@ -3062,6 +3062,10 @@ static bool si_dpm_vblank_too_short(void/* we never hit the non-gddr5 limit so disable it */ u32 switch_limit = adev->gmc.vram_type ==AMDGPU_VRAM_TYPE_GDDR5 ?450 :0 ; +/* Disregard vblank time when there are no displays connected */ +if (!adev->pm.pm_display_cfg.num_display) +return false; +/* Consider zero vblank time too short and disable MCLK switching. * Note that the vblank time is set to maximum when no displays are attached, * so we'll still enable MCLK switching in that case.
Greg Kroah-Hartman
maintainerPATCH 247/307 serial: altera_jtaguart: handle uart_add_one_port() failures
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit ea66be25f0e934f49d24cd0c5845d13cdba3520b upstream.
altera_jtaguart_probe() maps the register window before registering the UART port, but it ignores failures from uart_add_one_port(). If port registration fails, probe still returns success and the mapping remains live until a later remove path that is not part of probe failure cleanup.
Return the uart_add_one_port() error and unmap the register window on that failure path.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/tty/serial/altera_jtaguart.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/tty/serial/altera_jtaguart.c +6 -1
@@ -381,6 +381,7 @@ static int altera_jtaguart_probe(structstruct resource *res_mem;int i = pdev->id;int irq; +int ret;/* -1 emphasizes that the platform must have one port, no .N suffix */ if (i ==-1 )
@@ -420,7 +421,11 @@ static int altera_jtaguart_probe(struct port->flags =UPF_BOOT_AUTOCONF ; port->dev = &pdev->dev; -uart_add_one_port (&altera_jtaguart_driver, port); + ret =uart_add_one_port (&altera_jtaguart_driver, port); +if (ret) { +iounmap (port->membase); +return ret; + }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 248/307 serial: qcom-geni: fix UART_RX_PAR_EN bit position
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prasanna S <[email protected]>
commit ca2584d841b69391ffc4144840563d2e1a0018df upstream.
UART_RX_PAR_EN is incorrectly defined as bit 3, which triggers false framing errors (S_GP_IRQ_1_EN) and causes received data to be dropped when parity is enabled and the parity bit is 0.
Define UART_RX_PAR_EN as bit 4 of the SE_UART_RX_TRANS_CFG register, as specified in the reference manual.
--- drivers/tty/serial/qcom_geni_serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/qcom_geni_serial.c +1 -1
@@ -46,7 +46,7 @@#define TX_STOP_BIT_LEN_2 2/* SE_UART_RX_TRANS_CFG */ -#define UART_RX_PAR_EN BIT(3) +#define UART_RX_PAR_EN BIT(4)/* SE_UART_RX_WORD_LEN */ #define RX_WORD_LEN_MASK GENMASK(9, 0)
Greg Kroah-Hartman
maintainerPATCH 249/307 serial: qcom_geni: fix kfifo underflow when flush precedes DMA completion IRQ
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viken Dadhaniya <[email protected]>
commit 452d6fa37ae9b021f4f6d397dbae077f7296f6f4 upstream.
When uart_flush_buffer() runs before the DMA completion IRQ is delivered, the following race can occur (all steps serialized by uart_port_lock):
1. DMA starts: tx_remaining = N, kfifo contains N bytes
2. DMA completes in hardware; IRQ is pending but not yet delivered
3. uart_flush_buffer() acquires the port lock and calls kfifo_reset(), making kfifo_len() = 0 while tx_remaining remains N
4. uart_flush_buffer() releases the port lock
5. DMA IRQ fires; handle_tx_dma() acquires the port lock and calls uart_xmit_advance(uport, tx_remaining) on an empty kfifo
uart_xmit_advance() increments kfifo->out by tx_remaining. Since kfifo_reset() already set both in and out to 0, out wraps past in, causing kfifo_len() to return UART_XMIT_SIZE - tx_remaining. The next start_tx_dma() call then submits a DMA transfer of stale buffer data.
Fix this by snapshotting kfifo_len() at the start of handle_tx_dma() and skipping uart_xmit_advance() when fifo_len < tx_remaining, which indicates the kfifo was reset by a preceding flush.
--- drivers/tty/serial/qcom_geni_serial.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/tty/serial/qcom_geni_serial.c +13 -1
@@ -993,8 +993,20 @@ static void qcom_geni_serial_handle_tx_d {struct qcom_geni_serial_port *port =to_dev_port (uport);struct tty_port *tport = &uport->state->port; +unsigned int fifo_len =kfifo_len (&tport->xmit_fifo); + +/* +* Only advance the kfifo if it still contains the bytes that were +* transferred. uart_flush_buffer() may have run before this IRQ +* fired: it calls kfifo_reset() under the port lock, making +* fifo_len = 0 while tx_remaining remains non-zero. Calling +* uart_xmit_advance() in that case would underflow kfifo->out past +* kfifo->in, making kfifo_len() wrap to UART_XMIT_SIZE - tx_remaining +* and triggering a spurious large DMA transfer of stale data. +*/ +if (fifo_len >= port->tx_remaining) +uart_xmit_advance (uport, port->tx_remaining); -uart_xmit_advance (uport, port->tx_remaining);geni_se_tx_dma_unprep (&port->se, port->tx_dma_addr, port->tx_remaining); port->tx_dma_addr =0 ; port->tx_remaining =0 ;
Greg Kroah-Hartman
maintainerPATCH 250/307 serial: sh-sci: fix memory region release in error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
commit 92b1ea22454b08a39baef3a7290fb3ec50366616 upstream.
The sci_request_port() function uses request_mem_region() to reserve I/O memory, but in the error path when sci_remap_port() fails, it incorrectly calls release_resource() instead of release_mem_region().
This mismatch can cause resource accounting issues. Fix it by using the correct release function, consistent with sci_release_port().
--- drivers/tty/serial/sh-sci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/sh-sci.c +1 -1
@@ -2849,7 +2849,7 @@ static int sci_request_port(struct uart_ ret =sci_remap_port (port);if (unlikely (ret !=0 )) { -release_resource (res); +release_mem_region (port->mapbase, sport->reg_size);return ret; }
Greg Kroah-Hartman
maintainerPATCH 251/307 serial: zs: Fix swapped RI/DSR modem line transition counting
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit d15cd40cb1858f75846eaafa9a6bca841b790a92 upstream.
Fix a thinko in the status interrupt handler that has caused counters for the RI and DSR modem line transitions to be used for the other line each.
--- drivers/tty/serial/zs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/zs.c +2 -2
@@ -680,9 +680,9 @@ static void zs_status_handle(struct zs_puart_handle_dcd_change (uport, zport->mctrl &TIOCM_CAR );if (delta &TIOCM_RNG ) - uport->icount.dsr++; -if (delta &TIOCM_DSR ) uport->icount.rng++; +if (delta &TIOCM_DSR ) + uport->icount.dsr++;if (delta)wake_up_interruptible (&uport->state->port.delta_msr_wait);
Greg Kroah-Hartman
maintainerPATCH 252/307 serial: fsl_lpuart: fix rx buffer and DMA map leaks in start_rx_dma
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shitalkumar Gandhi <[email protected]>
commit 9a9254c4a2a3ca2b3da16d173f3b0dd01f397ff6 upstream.
lpuart_start_rx_dma() allocates sport->rx_ring.buf with kzalloc() and then maps a scatterlist via dma_map_sg(). On three subsequent error paths the function returns directly without releasing those resources:
- when dma_map_sg() returns 0 (-EINVAL):
ring->buf is leaked.
- when dmaengine_slave_config() fails:
ring->buf and the DMA mapping are leaked.
- when dmaengine_prep_dma_cyclic() returns NULL:
ring->buf and the DMA mapping are leaked.The sole cleanup path, lpuart_dma_rx_free(), is only reached when lpuart_dma_rx_use is set, and the caller lpuart_rx_dma_startup() clears that flag on failure of lpuart_start_rx_dma(). So these resources are permanently leaked on every failure in this function. Repeated port open/close or termios changes under error conditions will slowly consume memory and leave stale streaming DMA mappings behind.
Fix it by introducing two error labels that unmap the scatterlist and free the ring buffer as appropriate. While here, replace the misleading -EFAULT (bad userspace pointer) returned when dmaengine_prep_dma_cyclic() fails with the more accurate -ENOMEM, matching how other dmaengine users in the tree treat this failure.
No functional change on the success path.
--- drivers/tty/serial/fsl_lpuart.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/tty/serial/fsl_lpuart.c +12 -3
@@ -1375,7 +1375,8 @@ static inline int lpuart_start_rx_dma(stif (!nent) {dev_err (sport->port.dev,"DMA Rx mapping error\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto err_free_buf; } dma_rx_sconfig.src_addr =lpuart_dma_datareg_addr (sport);
@@ -1387,7 +1388,7 @@ static inline int lpuart_start_rx_dma(stif (ret <0 ) {dev_err (sport->port.dev,"DMA Rx slave config failed, err = %d\n" , ret); -return ret; + goto err_unmap_sg; } sport->dma_rx_desc = dmaengine_prep_dma_cyclic(chan,
@@ -1398,7 +1399,8 @@ static inline int lpuart_start_rx_dma(st DMA_PREP_INTERRUPT);if (!sport->dma_rx_desc) {dev_err (sport->port.dev,"Cannot prepare cyclic DMA\n" ); -return -EFAULT ; + ret = -ENOMEM ; + goto err_unmap_sg; } sport->dma_rx_desc->callback = lpuart_dma_rx_complete;
@@ -1422,6 +1424,13 @@ static inline int lpuart_start_rx_dma(st }return 0 ; + +err_unmap_sg: +dma_unmap_sg (chan->device->dev, &sport->rx_sgl,1 ,DMA_FROM_DEVICE ); +err_free_buf: +kfree (ring->buf); + ring->buf =NULL ; +return ret; }static void lpuart_dma_rx_free (struct uart_port *port)
Greg Kroah-Hartman
maintainerPATCH 253/307 drm/amdkfd: fix NULL pointer bug in svm_range_set_attr
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Huang <[email protected]>
commit e984d61d92e702096058f0f828f4b2b8563b88ce upstream.
The process_info could be NULL if user doesn't call kfd_ioctl_acquire_vm before calling kfd_ioctl_svm.
--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +3 -0
@@ -3668,6 +3668,9 @@ svm_range_set_attr(struct kfd_process *p svms = &p->svms; +if (!process_info) +return -EINVAL ; +mutex_lock (&process_info->lock);svm_range_list_lock_and_flush_work (svms, mm);
Greg Kroah-Hartman
maintainerPATCH 254/307 drm/amdkfd: fix a vulnerability of integer overflow in kfd debugger
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Huang <[email protected]>
commit 93f5534b35a05ef8a0109c1eefa800062fee810a upstream.
get_queue_ids() computes array_size = num_queues * sizeof(uint32_t), which could overflow on 32-bit size_t build. using array_size() instead, it saturates to SIZE_MAX on overflow.
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +5 -3
@@ -3194,12 +3194,14 @@ static void copy_context_work_handler (sstatic uint32_t *get_queue_ids (uint32_t num_queues,uint32_t *usr_queue_id_array) { -size_t array_size = num_queues *sizeof (uint32_t ); -if (!usr_queue_id_array)return NULL ; -return memdup_user (usr_queue_id_array, array_size); +if (num_queues >KFD_MAX_NUM_OF_QUEUES_PER_PROCESS ) +return ERR_PTR (-EINVAL ); + +return memdup_user (usr_queue_id_array, +array_size (num_queues,sizeof (uint32_t ))); } int resume_queues(struct kfd_process *p,
Greg Kroah-Hartman
maintainerPATCH 255/307 drm/amdkfd: Check for pdd drm file first in CRIU restore path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Francis <[email protected]>
commit 6842b6a4b72da9b2906ffc5ca9d846ace2c54c14 upstream.
CRIU restore ioctls are meant to be called by CRIU with no existing drm file. There's an error path
for if the drm file unexpectedly exists. It was positioned so it was missing a fput(drm_file).
Do that check earlier, as soon as we have the pdd.
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +5 -5
@@ -2260,6 +2260,11 @@ static int criu_restore_devices(struct k ret = -EINVAL ; goto exit; } + +if (pdd->drm_file) { + ret = -EINVAL ; + goto exit; + } pdd->user_gpu_id = device_buckets[i].user_gpu_id; drm_file =fget (device_buckets[i].drm_fd);
@@ -2269,11 +2274,6 @@ static int criu_restore_devices(struct k ret = -EINVAL ; goto exit; } - -if (pdd->drm_file) { - ret = -EINVAL ; - goto exit; - }/* create the vm using render nodes for kfd pdd */ if (kfd_process_device_init_vm (pdd, drm_file)) {
Greg Kroah-Hartman
maintainerPATCH 256/307 serial: dz: Fix bootconsole message clobbering at chip reset
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit ca904f4b42355287bc5ce8b7550ebe909cda4c2c upstream.
In the DZ interface as implemented by the DC7085 gate array the serial transmitters are double buffered, meaning that at the time a transmitter is ready to accept the next character there is one in the transmit shift register still being sent to the line. Issuing a master clear at this time causes this character to be lost, so wait an extra amount of time sufficient for the transmit shift register to drain at 9600bps, which is the baud rate setting used by the firmware console.
Mind the specified 1.4us TRDY recovery time in the course and continue using iob() as the completion barrier, since the platforms involved use a write buffer that can delay and combine writes, and reorder them with respect to reads regardless of the MMIO locations accessed and we still lack a platform-independent handler for that.
When called from dz_serial_console_init() this is too early for fsleep() to work and even before lpj has been calculated and therefore the delay is actually not sufficient for the transmitter to drain and is merely a placeholder now. This will be addressed in a follow-up change.
--- drivers/tty/serial/dz.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/tty/serial/dz.c +21 -0
@@ -542,10 +542,31 @@ static int dz_encode_baud_rate(unsignedstatic void dz_reset (struct dz_port *dport) {struct dz_mux *mux = dport->mux; +unsigned short tcr; +int loops =10000 ;if (mux->initialised)return ; + tcr =dz_in (dport,DZ_TCR ); + +/* Do not disturb any ongoing transmissions. */ +if (dz_in (dport,DZ_CSR ) &DZ_MSE ) { +unsigned short csr, mask; + + mask = tcr; +while ((mask &DZ_LNENB ) && loops--) { + csr =dz_in (dport,DZ_CSR ); +if (!(csr &DZ_TRDY )) +continue ; + mask &= ~(1 << ((csr &DZ_TLINE ) >>8 )); +dz_out (dport,DZ_TCR , mask); +iob (); +udelay (2 );/* 1.4us TRDY recovery. */ + } +udelay (1200 );/* Transmitter drain. */ + } +dz_out (dport,DZ_CSR ,DZ_CLR );while (dz_in (dport,DZ_CSR ) &DZ_CLR );iob ();
Greg Kroah-Hartman
maintainerPATCH 257/307 serial: dz: Fix bootconsole handover lockup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 7f127b2208e5e2b817243cad41fe4211a6d5a7a3 upstream.
Calling dz_reset() in the course of setting up the serial device causes line parameters to be reset and the transmitter disabled. We've been lucky in that no message is usually produced to the kernel log between this call and the later call to uart_set_options() in the course of console setup done by dz_serial_console_init(), or the system would hang as the console output handler in the firmware tried to access a port the transmitter of which has been disabled and line parameters messed up.
This will change with the next change to the driver, so fix dz_reset() such that line parameters are set for 9600n8 console operation as with the system firmware and the transmitter re-enabled after reset. This also means dz_pm() serves no purpose anymore, so drop it.
--- drivers/tty/serial/dz.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-)
drivers/tty/serial/dz.c +12 -24
@@ -571,6 +571,18 @@ static void dz_reset(struct dz_port *dpowhile (dz_in (dport,DZ_CSR ) &DZ_CLR );iob (); +/* +* Set parameters across all lines such as not to interfere +* with the initial PROM-based console. Otherwise any output +* produced before the console handover would cause the system +* firmware to produce rubbish. +*/ +for (int line =0 ; line <DZ_NB_PORT ; line++) +dz_out (dport,DZ_LPR ,DZ_B9600 |DZ_CS8 | line); + +/* Re-enable transmission for the initial PROM-based console. */ +dz_out (dport,DZ_TCR , tcr); +/* Enable scanning. */ dz_out (dport,DZ_CSR ,DZ_MSE );
@@ -654,26 +666,6 @@ static void dz_set_termios(struct uart_puart_port_unlock_irqrestore (&dport->port, flags); } -/* -* Hack alert! -* Required solely so that the initial PROM-based console -* works undisturbed in parallel with this one. -*/ -static void dz_pm (struct uart_port *uport,unsigned int state, -unsigned int oldstate) -{ -struct dz_port *dport =to_dport (uport); -unsigned long flags; - -uart_port_lock_irqsave (&dport->port, &flags); -if (state <3 ) -dz_start_tx (&dport->port); -else -dz_stop_tx (&dport->port); -uart_port_unlock_irqrestore (&dport->port, flags); -} - -static const char *dz_type (struct uart_port *uport) {return "DZ" ;
@@ -769,7 +761,6 @@ static const struct uart_ops dz_ops = { .startup = dz_startup, .shutdown = dz_shutdown, .set_termios = dz_set_termios, - .pm = dz_pm, .type = dz_type, .release_port = dz_release_port, .request_port = dz_request_port,
@@ -894,10 +885,7 @@ static int __init dz_console_setup(strucif (ret)return ret; -spin_lock_init (&dport->port.lock);/* For dz_pm(). */ -dz_reset (dport); -dz_pm (uport,0 ,-1 );if (options)uart_parse_options (options, &baud, &parity, &bits, &flow);
Greg Kroah-Hartman
maintainerPATCH 258/307 serial: dz: Convert to use a platform device
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 5d7a49d60b8fda66da60e240fd7315232fa1754f upstream.
Prevent a crash from happening as the first serial port is initialised:
Console: switching to colour frame buffer device 160x64
tgafb: SFB+ detected, rev=0x02
fb0: Digital ZLX-E1 frame buffer device at 0x1e000000
DECstation DZ serial driver version 1.04
CPU 0 Unable to handle kernel paging request at virtual address 000000bc, epc == 8048b3a4, ra == 80470a78 Oops[#1]:
CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.19.0-dirty #35 NONE
$ 0 : 00000000 1000ac00 00000004 804707ac
$ 4 : 00000000 80e20850 80e20858 81000030
$ 8 : 00000000 8072c81c 00000008 fefefeff
$12 : 6c616972 00000006 80c5917f 69726420
$16 : 80e20800 00000000 808f8968 80e20800
$20 : 00000000 807f5a90 808b0094 808d3bc8
$24 : 00000018 80479030
$28 : 80c2e000 80c2fd70 00000069 80470a78
Hi : 00000004
Lo : 00000000
epc : 8048b3a4 __dev_fwnode+0x0/0xc
ra : 80470a78 serial_base_ctrl_add+0xa0/0x168
Status: 1000ac04 IEp
Cause : 30000008 (ExcCode 02)
BadVA : 000000bc
PrId : 00000220 (R3000)
Modules linked in:
Process swapper/0 (pid: 1, threadinfo=(ptrval), task=(ptrval), tls=00000000)
Stack : 00400044 00400040 8046f4cc 00000000 808a6148 808a0000 808f8968 8086983c
808e0000 8046fc84 1000ac01 00000028 80e20700 802ba3f8 80e20700 80d34a94
80c1b900 80e20700 80e20700 80e20700 80e20700 80444650 00000000 00000000
00000000 807f5a90 808b0094 80447080 00400040 808e0000 80d34a94 808a6148
80d34a94 00000004 80e20700 00000000 8076974c 80469810 80c2fe3c 1000ac01
...
Call Trace:
[<8048b3a4>] __dev_fwnode+0x0/0xc
[<80470a78>] serial_base_ctrl_add+0xa0/0x168
[<8046fc84>] serial_core_register_port+0x1c8/0x974
[<808c6af0>] dz_init+0x74/0xc8
[<800470e0>] do_one_initcall+0x44/0x2d4
[<808b111c>] kernel_init_freeable+0x258/0x308
[<8072e434>] kernel_init+0x20/0x114
[<80049cd0>] ret_from_kernel_thread+0x14/0x1c
Code: 27bd0018 03e00008 2402ffea <8c8200bc> 03e00008 00000000 27bdffc0 afbe0038 afb30024
---[ end trace 0000000000000000 ]----- where a pointer is dereferenced that has been derived from a null pointer to the port's parent device.
Since no device is available with legacy probing and it's not anymore a preferable way to discover devices anyway, switch the driver to using a platform device and use it as the port's parent device. Update resource handling accordingly and only request the actual span of addresses used within the slot, which will have had its resource already requested by generic platform device code.
Use platform_driver_probe() not just because the DZ device is fixed with solder on board and not straightforward to remove, but foremost because the associated TTY's major device number is the same as used by the zs driver and the first driver to claim it will prevent the other one from using it. Either one DZ device or some SCC devices will be present in a given system but never both at a time, and therefore we want the major device number to be claimed by the first driver to actually successfully bind to its device and platform_driver_probe() is a way to fulfil that.
An unfortunate consequence of the switch to a platform device is we now hand the console over from the bootconsole much later in the bootstrap. The firmware console handler appears good enough though to work so late and in particular with interrupts enabled.
Conversely only starting the console port so late lets the reset code fully utilise our delay handlers, so switch from udelay() to fsleep() for transmitter draining so as to avoid busy-waiting for an excessive amount of time.
--- arch/mips/dec/platform.c | 55 +++++++++++++++++++++- drivers/tty/serial/dz.c | 116 ++++++++++++++++++++++------------------------- 2 files changed, 110 insertions(+), 61 deletions(-)
arch/mips/dec/platform.c +54 -1
@@ -10,6 +10,13 @@#include <linux/mc146818rtc.h> #include <linux/platform_device.h> +#include <asm/bootinfo.h> + +#include <asm/dec/interrupts.h> +#include <asm/dec/kn01.h> +#include <asm/dec/kn02.h> +#include <asm/dec/system.h> +static struct resource dec_rtc_resources[] = { { .name ="rtc" ,
@@ -30,11 +37,57 @@ static struct platform_device dec_rtc_de .num_resources = ARRAY_SIZE(dec_rtc_resources), }; +static struct resource dec_dz_resources[] = { + { .name ="dz" , .flags =IORESOURCE_MEM , }, + { .name ="dz" , .flags =IORESOURCE_IRQ , }, +}; + +static struct platform_device dec_dz_device = { + .name ="dz" , + .id =PLATFORM_DEVID_NONE , + .resource = dec_dz_resources, + .num_resources =ARRAY_SIZE (dec_dz_resources), +}; + +static struct platform_device *dec_dz_devices[]__initdata = { + &dec_dz_device, +}; +static int __init dec_add_devices (void ) { +int ret1, ret2; +int num_dz; +int irq, i; + dec_rtc_resources[0 ].start =RTC_PORT (0 ); dec_rtc_resources[0 ].end =RTC_PORT (0 ) + dec_kn_slot_size -1 ; -return platform_device_register (&dec_rtc_device); + + i =0 ; + irq = dec_interrupt[DEC_IRQ_DZ11 ]; +if (IS_ENABLED (CONFIG_32BIT ) && irq >=0 ) { +resource_size_t base; + +switch (mips_machtype) { +case MACH_DS23100 : +case MACH_DS5100 : + base = dec_kn_slot_base +KN01_DZ11 ; +break ; +default : + base = dec_kn_slot_base +KN02_DZ11 ; +break ; + } + dec_dz_device.resource[0 ].start = base; + dec_dz_device.resource[0 ].end = base + dec_kn_slot_size -1 ; + dec_dz_device.resource[1 ].start = irq; + dec_dz_device.resource[1 ].end = irq; + i++; + } + num_dz = i; + + ret1 =platform_device_register (&dec_rtc_device); + ret2 =IS_ENABLED (CONFIG_32BIT ) ? +platform_add_devices (dec_dz_devices, num_dz) :0 ; +return ret1 ? ret1 : ret2; }device_initcall (dec_add_devices);
drivers/tty/serial/dz.c +56 -60
223 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 259/307 serial: zs: Fix bootconsole handover lockup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 6c05cf72e13314ce9b770b5951695dc5a2152920 upstream.
Calling zs_reset() in the course of setting up the serial device causes line parameters to be reset and the transmitter disabled. We've been lucky in that no message is usually produced to the kernel log between this call and the later call to uart_set_options() in the course of console setup done by zs_serial_console_init(), or the system would hang as the console output handler in the firmware tried to access a port the transmitter of which has been disabled and line parameters messed up.
This will change with the next change to the driver, so fix zs_reset() such that line parameters are set for 9600n8 console operation as with the system firmware and the transmitter re-enabled after reset. This also means zs_pm() serves no purpose anymore, so drop it.
--- drivers/tty/serial/zs.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-)
drivers/tty/serial/zs.c +8 -21
@@ -105,18 +105,24 @@ struct zs_parms {static struct zs_scc zs_sccs[ZS_NUM_SCCS ]; +/* +* Set parameters in WR5, WR12, WR13 such as not to interfere +* with the initial PROM-based console. Otherwise any output +* produced before the console handover would cause the system +* firmware to hang (TxENAB) or produce rubbish (Tx8, B9600). +*/ static u8 zs_init_regs[ZS_NUM_REGS ]__initdata = {0 ,/* write 0 */ PAR_SPEC ,/* write 1 */ 0 ,/* write 2 */ 0 ,/* write 3 */ X16CLK |SB1 ,/* write 4 */ -0 ,/* write 5 */ + Tx8 | TxENAB,/* write 5 */ 0 ,0 ,0 ,/* write 6, 7, 8 */ MIE |DLC |NV ,/* write 9 */ NRZ ,/* write 10 */ TCBR |RCBR ,/* write 11 */ -0 ,0 ,/* BRG time constant, write 12 + 13 */ +0x16 ,0x00 ,/* BRG time constant, write 12 + 13 */ BRSRC |BRENABL ,/* write 14 */ 0 ,/* write 15 */ };
@@ -956,23 +962,6 @@ static void zs_set_termios(struct uart_pspin_unlock_irqrestore (&scc->zlock, flags); } -/* -* Hack alert! -* Required solely so that the initial PROM-based console -* works undisturbed in parallel with this one. -*/ -static void zs_pm (struct uart_port *uport,unsigned int state, -unsigned int oldstate) -{ -struct zs_port *zport =to_zport (uport); - -if (state <3 ) - zport->regs[5 ] |= TxENAB; -else - zport->regs[5 ] &= ~TxENAB; -write_zsreg (zport,R5 , zport->regs[5 ]); -} -static const char *zs_type (struct uart_port *uport) {
@@ -1055,7 +1044,6 @@ static const struct uart_ops zs_ops = { .startup = zs_startup, .shutdown = zs_shutdown, .set_termios = zs_set_termios, - .pm = zs_pm, .type = zs_type, .release_port = zs_release_port, .request_port = zs_request_port,
@@ -1210,7 +1198,6 @@ static int __init zs_console_setup(strucreturn ret;zs_reset (zport); -zs_pm (uport,0 ,-1 );if (options)uart_parse_options (options, &baud, &parity, &bits, &flow);
Greg Kroah-Hartman
maintainerPATCH 260/307 serial: zs: Switch to using channel reset
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 8572955630f30948837088aa98bcbe0532d1ceac upstream.
Switch the driver to using the channel reset rather than hardware reset, simplifying handling by removing an interference between channels that causes the other channel to become uninitialised afterwards.
There is little difference between the two kinds of reset in terms of register settings that result, and we initialise the whole register set right away anyway. However this prevents a hang from happening should the console output handler in the firmware try to access the other port whose transmitter has been disabled and line parameters messed up.
For example this will happen if the keyboard port (port A) is chosen for the system console, unusually but not insanely for a headless system, as the port is wired to a standard DA-15 connector and an adapter can be easily made. Or with the next change in place this would happen for the regular console port (port B), since the keyboard port (port A) will be initialised first.
Just remove the unnecessary complication then, a channel reset is good enough. We still need the initialisation marker, now per channel rather than per SCC, as for the console port zs_reset() will be called twice:
once early on via zs_serial_console_init() for the console setup only, and then again via zs_config_port() as the port is associated with a TTY device.
--- drivers/tty/serial/zs.c | 7 ++++--- drivers/tty/serial/zs.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/tty/serial/zs.c +4 -3
@@ -832,21 +832,22 @@ static void zs_shutdown(struct uart_portstatic void zs_reset (struct zs_port *zport) { +struct zs_port *zport_a = &zport->scc->zport[ZS_CHAN_A ];struct zs_scc *scc = zport->scc;int irq;unsigned long flags;spin_lock_irqsave (&scc->zlock, flags); irq = !irqs_disabled_flags (flags); -if (!scc->initialised) { +if (!zport->initialised) {/* Reset the pointer first, just in case... */ read_zsreg (zport,R0 );/* And let the current transmission finish. */ zs_line_drain (zport, irq); -write_zsreg (zport,R9 ,FHWRES ); +write_zsreg (zport,R9 , zport == zport_a ?CHRA :CHRB );udelay (10 );write_zsreg (zport,R9 ,0 ); - scc->initialised =1 ; + zport->initialised =1 ; }load_zsregs (zport, zport->regs, irq);spin_unlock_irqrestore (&scc->zlock, flags);
drivers/tty/serial/zs.h +1 -1
@@ -22,6 +22,7 @@struct zs_port {struct zs_scc *scc;/* Containing SCC. */ struct uart_port port;/* Underlying UART. */ +int initialised;/* For the console port. */ int clk_mode;/* May be 1, 16, 32, or 64. */
@@ -41,7 +42,6 @@ struct zs_scc {struct zs_port zport[2 ];spinlock_t zlock; atomic_t irq_guard; - int initialised; };#endif /* __KERNEL__ */
Greg Kroah-Hartman
maintainerPATCH 261/307 serial: zs: Convert to use a platform device
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 7cac59d08a73cb866ec51a483a6f3fe0f531947c upstream.
Prevent a crash from happening as the first serial port is initialised:
Console: switching to mono frame buffer device 160x64
fb0: PMAG-AA frame buffer device at tc0
DECstation Z85C30 serial driver version 0.10
CPU 0 Unable to handle kernel paging request at virtual address 0000002c, epc == 803ab00c, ra == 803aafe0 Oops[#1]:
CPU: 0 PID: 1 Comm: swapper Not tainted 6.4.0-rc3-00031-g84a9582fd203-dirty #57
$ 0 : 00000000 10012c00 803aaeb0 00000000
$ 4 : 80e12f60 80e12f50 80e12f58 81000030
$ 8 : 00000000 805ff37c 00000000 33433538
$12 : 65732030 00000006 80c2915d 6c616972
$16 : 80e12f00 807b7630 00000000 00000000
$20 : 00000004 00000348 000001a0 807623b8
$24 : 00000018 00000000
$28 : 80c24000 80c25d60 8078b148 803aafe0
Hi : 00000000
Lo : 00000000
epc : 803ab00c serial_base_ctrl_add+0x78/0xf4
ra : 803aafe0 serial_base_ctrl_add+0x4c/0xf4
Status: 10012c03 KERNEL EXL IE
Cause : 00000008 (ExcCode 02)
BadVA : 0000002c
PrId : 00000440 (R4400SC)
Modules linked in:
Process swapper (pid: 1, threadinfo=(ptrval), task=(ptrval), tls=00000000)
Stack : 80760000 00000cc0 00400044 00400040 803aa02c 80d61ab8 00000000 807b7630
80760000 807623b8 807b7628 803aa644 80386998 00000000 80e17780 80220f68
80e17780 80d61ab8 80c17d80 80e17780 80e17780 8063c798 80e17780 80383fa0
00000010 80e17780 00000000 80386998 807a0000 00000000 00400040 8038f848
807623b8 80d61ab8 00000004 80e17780 00000000 803a68e4 80c25e2c 803bb884
...
Call Trace:
[<803ab00c>] serial_base_ctrl_add+0x78/0xf4
[<803aa644>] serial_core_register_port+0x174/0x69c
[<8077e9ac>] zs_init+0xc8/0xfc
[<800404d4>] do_one_initcall+0x40/0x2ac
[<8076cecc>] kernel_init_freeable+0x1e4/0x270
[<80605bec>] kernel_init+0x20/0x108
[<800431e8>] ret_from_kernel_thread+0x14/0x1c
Code: 2442aeb0 ae120024 ae0200d0 <8c67002c> 50e00001 8c670000 3c06806e 3c05806e afb30010
---[ end trace 0000000000000000 ]---(report at the offending commit) -- where a pointer is dereferenced that has been derived from a null pointer to the port's parent device.
Since no device is available with legacy probing and it's not anymore a preferable way to discover devices anyway, switch the driver to using a platform device and use it as the port's parent device. Update resource handling accordingly and only request the actual span of addresses used within the slot, which will have had its resource already requested by generic platform device code.
Use platform_driver_probe() not just because SCC devices are fixed with solder on board and not straightforward to remove, but foremost because the associated TTY's major device number is the same as used by the dz driver and the first driver to claim it will prevent the other one from using it. Either one DZ device or some SCC devices will be present in a given system but never both at a time, and therefore we want the major device number to be claimed by the first driver to actually successfully bind to its device and platform_driver_probe() is a way to fulfil that.
An unfortunate consequence of the switch to a platform device is we now hand the console over from the bootconsole much later in the bootstrap. The firmware console handler appears good enough though to work so late and in particular with interrupts enabled.
Since there is one way only remaining to reach zs_reset() now, remove the port initialisation marker as no longer needed and go through the channel reset unconditionally.
--- arch/mips/dec/platform.c | 60 ++++++++++++++ drivers/tty/serial/zs.c | 190 +++++++++++++++++------------------------------ drivers/tty/serial/zs.h | 1 3 files changed, 128 insertions(+), 123 deletions(-)
arch/mips/dec/platform.c +57 -3
@@ -13,6 +13,7 @@#include <asm/bootinfo.h> #include <asm/dec/interrupts.h> +#include <asm/dec/ioasic_addrs.h> #include <asm/dec/kn01.h> #include <asm/dec/kn02.h> #include <asm/dec/system.h>
@@ -53,10 +54,37 @@ static struct platform_device *dec_dz_de &dec_dz_device, }; +static struct resource dec_zs_resources[][2 ] = { + { + { .name ="scc0" , .flags =IORESOURCE_MEM , }, + { .name ="scc0" , .flags =IORESOURCE_IRQ , }, + }, + { + { .name ="scc1" , .flags =IORESOURCE_MEM , }, + { .name ="scc1" , .flags =IORESOURCE_IRQ , }, + }, +}; + +static struct platform_device dec_zs_device[] = { + { + .name ="zs" , + .id =0 , + .resource = dec_zs_resources[0 ], + .num_resources =ARRAY_SIZE (dec_zs_resources[0 ]), + }, + { + .name ="zs" , + .id =1 , + .resource = dec_zs_resources[1 ], + .num_resources =ARRAY_SIZE (dec_zs_resources[1 ]), + }, +}; +static int __init dec_add_devices (void ) { -int ret1, ret2; -int num_dz; +struct platform_device *dec_zs_devices[ARRAY_SIZE (dec_zs_device)]; +int ret1, ret2, ret3; +int num_dz, num_zs;int irq, i; dec_rtc_resources[0 ].start =RTC_PORT (0 );
@@ -84,10 +112,36 @@ static int __init dec_add_devices(void) } num_dz = i; + i =0 ; + irq = dec_interrupt[DEC_IRQ_SCC0 ]; +if (irq >=0 ) { +resource_size_t base = dec_kn_slot_base +IOASIC_SCC0 ; + + dec_zs_device[i].resource[0 ].start = base; + dec_zs_device[i].resource[0 ].end = base + dec_kn_slot_size -1 ; + dec_zs_device[i].resource[1 ].start = irq; + dec_zs_device[i].resource[1 ].end = irq; + dec_zs_devices[i] = &dec_zs_device[i]; + i++; + } + irq = dec_interrupt[DEC_IRQ_SCC1 ]; +if (irq >=0 ) { +resource_size_t base = dec_kn_slot_base +IOASIC_SCC1 ; + + dec_zs_device[i].resource[0 ].start = base; + dec_zs_device[i].resource[0 ].end = base + dec_kn_slot_size -1 ; + dec_zs_device[i].resource[1 ].start = irq; + dec_zs_device[i].resource[1 ].end = irq; + dec_zs_devices[i] = &dec_zs_device[i]; + i++; + } + num_zs = i; + ret1 =platform_device_register (&dec_rtc_device); ret2 =IS_ENABLED (CONFIG_32BIT ) ?platform_add_devices (dec_dz_devices, num_dz) :0 ; -return ret1 ? ret1 : ret2; + ret3 =platform_add_devices (dec_zs_devices, num_zs); +return ret1 ? ret1 : ret2 ? ret2 : ret3; }device_initcall (dec_add_devices);
drivers/tty/serial/zs.c +71 -119
275 lines not on this page · raw message
drivers/tty/serial/zs.h +0 -1
@@ -22,7 +22,6 @@struct zs_port {struct zs_scc *scc;/* Containing SCC. */ struct uart_port port;/* Underlying UART. */ -int initialised;/* For the console port. */ int clk_mode;/* May be 1, 16, 32, or 64. */
Greg Kroah-Hartman
maintainerPATCH 262/307 USB: serial: cypress_m8: fix memory corruption with small endpoint
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 e1a9d791fd66ab2431b9e6f6f835823809869047 upstream.
Make sure that the interrupt-out endpoint max packet size is at least eight bytes to avoid user-controlled slab corruption or NULL-pointer dereference should a malicious device report a smaller size.
--- drivers/usb/serial/cypress_m8.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/usb/serial/cypress_m8.c +8 -0
@@ -445,6 +445,14 @@ static int cypress_generic_port_probe(struct usb_serial_port *port)return -ENODEV ; } +/* +* The buffer must be large enough for the one or two-byte header (and +* following data), but assume anything smaller than eight bytes is +* broken. +*/ +if (port->interrupt_out_size <8 ) +return -EINVAL ; + priv =kzalloc (sizeof (struct cypress_private ),GFP_KERNEL );if (!priv)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 263/307 USB: serial: digi_acceleport: fix memory corruption with small endpoints
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 cb3560e8eab1dfa1cac1ed52631adf8ec6ff2cd5 upstream.
Add the missing bulk-out buffer size sanity checks to avoid out-of-bounds memory accesses or slab corruption should a malicious device report smaller buffers than expected.
--- drivers/usb/serial/digi_acceleport.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/usb/serial/digi_acceleport.c +21 -2
@@ -1229,15 +1229,34 @@ static int digi_port_init(struct usb_serial_port *port, unsigned port_num)static int digi_startup (struct usb_serial *serial) {struct digi_serial *serial_priv; +int oob_port_num;int ret; +int i; + +/* +* The port bulk-out buffers must be large enough for header and +* buffered data. +*/ +for (i =0 ; i < serial->type->num_ports; i++) { +if (serial->port[i]->bulk_out_size <DIGI_OUT_BUF_SIZE +2 ) +return -EINVAL ; + } + +/* +* The OOB port bulk-out buffer must be large enough for the two +* commands in digi_set_modem_signals(). +*/ + oob_port_num = serial->type->num_ports; +if (serial->port[oob_port_num]->bulk_out_size <8 ) +return -EINVAL ; serial_priv =kzalloc (sizeof (*serial_priv),GFP_KERNEL );if (!serial_priv)return -ENOMEM ;spin_lock_init (&serial_priv->ds_serial_lock); - serial_priv->ds_oob_port_num = serial->type->num_ports; - serial_priv->ds_oob_port = serial->port[serial_priv->ds_oob_port_num]; + serial_priv->ds_oob_port_num = oob_port_num; + serial_priv->ds_oob_port = serial->port[oob_port_num]; ret =digi_port_init (serial_priv->ds_oob_port, serial_priv->ds_oob_port_num);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 264/307 xhci: tegra: Fix ghost USB device on dual-role port unplug
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei-Cheng Chen <[email protected]>
[ Upstream commit 5a4c828b8b29b47534814ade26d9aee09d5101fc ]
When a USB device is unplugged from the dual-role port, the device-mode path in tegra_xhci_id_work() explicitly clears both SS and HS port power via direct hub_control ClearPortFeature(POWER) calls. This preempts the xHCI controller's normal disconnect processing -- PORT_CSC is never generated, the USB core never sees the disconnect, and the device remains in its internal tree as a ghost visible in lsusb.
Add an otg_set_port_power flag to control whether the dual-role switch path performs explicit port power management. SoCs that need it (Tegra124 / Tegra210 / Tegra186) set the flag; later SoCs (Tegra194 and beyond) rely on the PHY mode change to handle disconnect naturally and skip all port power calls.
Within the port power path, otg_reset_sspi additionally gates the SSPI reset sequence on host-mode entry for SoCs that require it.
Flags set per SoC:
Tegra124, Tegra186 -> otg_set_port_power Tegra210 -> otg_set_port_power, otg_reset_sspi Tegra194 and later -> (none)
[ Backport to 6.12.y: keep the host-mode snapshot in the existing
tegra->lock section, retain pm_runtime_mark_last_busy() in the host port-power path, and resolve context around the SoC ops/Tegra234 entries. ]
--- drivers/usb/host/xhci-tegra.c | 79 ++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 34 deletions(-)
drivers/usb/host/xhci-tegra.c +45 -34
@@ -243,6 +243,7 @@ struct tegra_xusb_soc {bool has_ipfs;bool lpm_support;bool otg_reset_sspi; +bool otg_set_port_power;bool has_bar2; };
@@ -1346,14 +1347,17 @@ static void tegra_xhci_id_work(struct work_struct *work)struct tegra_xusb_mbox_msg msg;struct phy *phy =tegra_xusb_get_phy (tegra,"usb2" , tegra->otg_usb2_port); +bool host_mode;u32 status;int ret; -dev_dbg (tegra->dev,"host mode %s\n" , tegra->host_mode ?"on" :"off" ); -mutex_lock (&tegra->lock); -if (tegra->host_mode) + host_mode = tegra->host_mode; + +dev_dbg (tegra->dev,"host mode %s\n" , host_mode ?"on" :"off" ); + +if (host_mode)phy_set_mode_ext (phy,PHY_MODE_USB_OTG ,USB_ROLE_HOST );else phy_set_mode_ext (phy,PHY_MODE_USB_OTG ,USB_ROLE_NONE );
@@ -1364,42 +1368,44 @@ static void tegra_xhci_id_work(struct work_struct *work) tegra->otg_usb2_port);pm_runtime_get_sync (tegra->dev); -if (tegra->host_mode) { -/* switch to host mode */ -if (tegra->otg_usb3_port >=0 ) { -if (tegra->soc->otg_reset_sspi) { -/* set PP=0 */ - tegra_xhci_hc_driver.hub_control ( - xhci->shared_hcd, GetPortStatus, -0 , tegra->otg_usb3_port+1 , - (char *) &status,sizeof (status)); -if (status &USB_SS_PORT_STAT_POWER ) -tegra_xhci_set_port_power (tegra, false, - false); - -/* reset OTG port SSPI */ - msg.cmd =MBOX_CMD_RESET_SSPI ; - msg.data = tegra->otg_usb3_port+1 ; - - ret =tegra_xusb_mbox_send (tegra, &msg); -if (ret <0 ) { -dev_info (tegra->dev, -"failed to RESET_SSPI %d\n" , - ret); +if (tegra->soc->otg_set_port_power) { +if (host_mode) { +/* switch to host mode */ +if (tegra->otg_usb3_port >=0 ) { +if (tegra->soc->otg_reset_sspi) { +/* set PP=0 */ + tegra_xhci_hc_driver.hub_control ( + xhci->shared_hcd, GetPortStatus, +0 , tegra->otg_usb3_port+1 , + (char *) &status,sizeof (status)); +if (status &USB_SS_PORT_STAT_POWER ) +tegra_xhci_set_port_power (tegra, false, + false); + +/* reset OTG port SSPI */ + msg.cmd =MBOX_CMD_RESET_SSPI ; + msg.data = tegra->otg_usb3_port+1 ; + + ret =tegra_xusb_mbox_send (tegra, &msg); +if (ret <0 ) { +dev_info (tegra->dev, +"failed to RESET_SSPI %d\n" , + ret); + } } - } -tegra_xhci_set_port_power (tegra, false, true); - } +tegra_xhci_set_port_power (tegra, false, true); + } -tegra_xhci_set_port_power (tegra, true, true); -pm_runtime_mark_last_busy (tegra->dev); +tegra_xhci_set_port_power (tegra, true, true); +pm_runtime_mark_last_busy (tegra->dev); - }else { -if (tegra->otg_usb3_port >=0 ) -tegra_xhci_set_port_power (tegra, false, false); + }else { +if (tegra->otg_usb3_port >=0 ) +tegra_xhci_set_port_power (tegra, false, false); -tegra_xhci_set_port_power (tegra, true, false); +tegra_xhci_set_port_power (tegra, true, false); + } }pm_runtime_put_autosuspend (tegra->dev); }
@@ -2497,6 +2503,7 @@ static const struct tegra_xusb_soc tegra124_soc = { .scale_ss_clock = true, .has_ipfs = true, .otg_reset_sspi = false, + .otg_set_port_power = true, .ops = &tegra124_ops, .mbox = { .cmd = 0xe4,
@@ -2535,6 +2542,7 @@ static const struct tegra_xusb_soc tegra210_soc = { .scale_ss_clock = false, .has_ipfs = true, .otg_reset_sspi = true, + .otg_set_port_power = true, .ops = &tegra124_ops, .mbox = { .cmd = 0xe4,
@@ -2578,6 +2586,7 @@ static const struct tegra_xusb_soc tegra186_soc = { .scale_ss_clock = false, .has_ipfs = false, .otg_reset_sspi = false, + .otg_set_port_power = true, .ops = &tegra124_ops, .mbox = { .cmd = 0xe4,
@@ -2611,6 +2620,7 @@ static const struct tegra_xusb_soc tegra194_soc = { .scale_ss_clock = false, .has_ipfs = false, .otg_reset_sspi = false, + .otg_set_port_power = false, .ops = &tegra124_ops, .mbox = { .cmd = 0x68,
@@ -2643,6 +2653,7 @@ static const struct tegra_xusb_soc tegra234_soc = { .scale_ss_clock = false, .has_ipfs = false, .otg_reset_sspi = false, + .otg_set_port_power = false, .ops = &tegra234_ops, .mbox = { .cmd = XUSB_BAR2_ARU_MBOX_CMD,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 265/307 iommu: Skip PASID validation for devices without PASID capability
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tushar Dave <[email protected]>
[ Upstream commit b3f6fcd8404f9f92262303369bb877ec5d188a81 ]
Generally PASID support requires ACS settings that usually create single device groups, but there are some niche cases where we can get multi-device groups and still have working PASID support. The primary issue is that PCI switches are not required to treat PASID tagged TLPs specially so appropriate ACS settings are required to route all TLPs to the host bridge if PASID is going to work properly.
pci_enable_pasid() does check that each device that will use PASID has the proper ACS settings to achieve this routing.
However, no-PASID devices can be combined with PASID capable devices within the same topology using non-uniform ACS settings. In this case the no-PASID devices may not have strict route to host ACS flags and end up being grouped with the PASID devices.
This configuration fails to allow use of the PASID within the iommu core code which wrongly checks if the no-PASID device supports PASID.
Fix this by ignoring no-PASID devices during the PASID validation. They will never issue a PASID TLP anyhow so they can be ignored.
--- drivers/iommu/iommu.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/iommu/iommu.c +18 -7
@@ -3341,9 +3341,11 @@ static int __iommu_set_group_pasid(struct iommu_domain *domain,int ret;for_each_group_device (group, device) { - ret = domain->ops->set_dev_pasid (domain, device->dev, pasid); -if (ret) - goto err_revert; +if (device->dev->iommu->max_pasids >0 ) { + ret = domain->ops->set_dev_pasid (domain, device->dev, pasid); +if (ret) + goto err_revert; + } }return 0 ;
@@ -3355,7 +3357,8 @@ static int __iommu_set_group_pasid(struct iommu_domain *domain,if (device == last_gdev)break ; - ops->remove_dev_pasid (device->dev, pasid, domain); +if (device->dev->iommu->max_pasids >0 ) + ops->remove_dev_pasid (device->dev, pasid, domain); }return ret; }
@@ -3368,8 +3371,10 @@ static void __iommu_remove_group_pasid(struct iommu_group *group,const struct iommu_ops *ops;for_each_group_device (group, device) { - ops =dev_iommu_ops (device->dev); - ops->remove_dev_pasid (device->dev, pasid, domain); +if (device->dev->iommu->max_pasids >0 ) { + ops =dev_iommu_ops (device->dev); + ops->remove_dev_pasid (device->dev, pasid, domain); + } } }
@@ -3403,7 +3408,13 @@ int iommu_attach_device_pasid(struct iommu_domain *domain,mutex_lock (&group->mutex);for_each_group_device (group, device) { -if (pasid >= device->dev->iommu->max_pasids) { +/* +* Skip PASID validation for devices without PASID support +* (max_pasids = 0). These devices cannot issue transactions +* with PASID, so they don't affect group's PASID usage. +*/ +if ((device->dev->iommu->max_pasids >0 ) && + (pasid >= device->dev->iommu->max_pasids)) { ret = -EINVAL ; goto out_unlock; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 266/307 x86/boot: Disable stack protector for early boot code
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Gerst <[email protected]>
[ Upstream commit a9a76b38aaf577887103e3ebb41d70e6aa5a4b19 ]
On 64-bit, this will prevent crashes when the canary access is changed from %gs:40 to %gs:__stack_chk_guard(%rip). RIP-relative addresses from the identity-mapped early boot code will target the wrong address with zero-based percpu. KASLR could then shift that address to an unmapped page causing a crash on boot.
This early boot code runs well before user-space is active and does not need stack protector enabled.
Stable-dep-of: 917e3ad3321e ("x86/kexec: Disable KCOV instrumentation after load_segments()")
--- arch/x86/kernel/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/Makefile +2 -0
@@ -44,6 +44,8 @@ KCOV_INSTRUMENT_unwind_orc.o := n KCOV_INSTRUMENT_unwind_frame.o := n KCOV_INSTRUMENT_unwind_guess.o := n +CFLAGS_head32.o := -fno-stack-protector +CFLAGS_head64.o := -fno-stack-protector CFLAGS_irq.o := -I $(src)/../include/asm/trace obj-y += head_$(BITS).o
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 267/307 x86/kexec: Disable KCOV instrumentation after load_segments()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Nogikh <[email protected]>
[ Upstream commit 917e3ad3321e75ca0223d5ccf26ceda116aa51e1 ]
The load_segments() function changes segment registers, invalidating GS base (which KCOV relies on for per-cpu data). When CONFIG_KCOV is enabled, any subsequent instrumented C code call (e.g. native_gdt_invalidate()) begins crashing the kernel in an endless loop.
To reproduce the problem, it's sufficient to do kexec on a KCOV-instrumented kernel:
$ kexec -l /boot/otherKernel $ kexec -e
The real-world context for this problem is enabling crash dump collection in syzkaller. For this, the tool loads a panic kernel before fuzzing and then calls makedumpfile after the panic. This workflow requires both CONFIG_KEXEC and CONFIG_KCOV to be enabled simultaneously.
Adding safeguards directly to the KCOV fast-path (__sanitizer_cov_trace_pc()) is also undesirable as it would introduce an extra performance overhead.
Disabling instrumentation for the individual functions would be too fragile, so disable KCOV instrumentation for the entire machine_kexec_64.c and physaddr.c. If coverage-guided fuzzing ever needs these components in the future, other approaches should be considered.
The problem is not relevant for 32 bit kernels as CONFIG_KCOV is not supported there.
[ bp: Space out comment for better readability. ]
--- arch/x86/kernel/Makefile | 14 ++++++++++++++ arch/x86/mm/Makefile | 2 ++ 2 files changed, 16 insertions(+)
arch/x86/kernel/Makefile +14 -0
@@ -44,6 +44,20 @@ KCOV_INSTRUMENT_unwind_orc.o := n KCOV_INSTRUMENT_unwind_frame.o := n KCOV_INSTRUMENT_unwind_guess.o := n +# Disable KCOV to prevent crashes during kexec: load_segments() invalidates +# the GS base, which KCOV relies on for per-CPU data. +# +# As KCOV and KEXEC compatibility should be preserved (e.g. syzkaller is +# using it to collect crash dumps during kernel fuzzing), disabling +# KCOV for KEXEC kernels is not an option. Selectively disabling KCOV +# instrumentation for individual affected functions can be fragile, while +# adding more checks to KCOV would slow it down. +# +# As a compromise solution, disable KCOV instrumentation for the whole +# source code file. If its coverage is ever needed, other approaches +# should be considered. +KCOV_INSTRUMENT_machine_kexec_64.o := n + CFLAGS_head32.o := -fno-stack-protector CFLAGS_head64.o := -fno-stack-protector CFLAGS_irq.o := -I $(src)/../include/asm/trace
arch/x86/mm/Makefile +2 -0
@@ -5,6 +5,8 @@ KCOV_INSTRUMENT_mem_encrypt.o := n KCOV_INSTRUMENT_mem_encrypt_amd.o := n KCOV_INSTRUMENT_mem_encrypt_identity.o := n KCOV_INSTRUMENT_pgprot.o := n +# See the "Disable KCOV" comment in arch/x86/kernel/Makefile. +KCOV_INSTRUMENT_physaddr.o := n KASAN_SANITIZE_mem_encrypt.o := n KASAN_SANITIZE_mem_encrypt_amd.o := n
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 268/307 rxrpc: Fix DATA decrypt vs splice() by copying data to buffer in recvmsg
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit d2bc90cf6c75cb96d2ce549be6c35efa3099d25b ]
This improves the fix for CVE-2026-43500.
Fix the pagecache corruption from in-place decryption of a DATA packet transmitted locally by splice() by getting rid of the packet sharing in the I/O thread and unconditionally extracting the packet content into a bounce buffer in which the buffer is decrypted. recvmsg() (or the kernel equivalent) then copies the data from the bounce buffer to the destination buffer. The sk_buff then remains unmodified.
This has an additional advantage in that the packet is then arranged in the buffer with the correct alignment required for the crypto algorithms to process directly. The performance of the crypto does seem to be a little faster and, surprisingly, the unencrypted performance doesn't seem to change much - possibly due to removing complexity from the I/O thread.
Yet another advantage is that the I/O thread doesn't have to copy packets which would slow down packet distribution, ACK generation, etc..
The buffer belongs to the call and is allocated initially at 2K, sufficiently large to hold a whole jumbo subpacket, but the buffer will be increased in size if needed. However, to take this work, MSG_PEEK may cause a later packet to be decrypted into the buffer, in which case the earlier one will need re-decrypting for a subsequent recvmsg().
Note that rx_pkt_offset may legitimately see 0 as a valid offset now, so switch to using USHRT_MAX to indicate an invalid offset.
Note also that I would generally prefer to replace the buffers of the current sk_buff with a new kmalloc'd buffer of the right size, ditching the old data and frags as this makes the handling of MSG_PEEK easier and removes the re-decryption issue, but this looks like quite a complicated thing to achieve. skb_morph() looks half way to what I want, but I don't want to have to allocate a new sk_buff.
Stable-dep-of: 8bfab4b6ffc2 ("rxrpc: Fix RESPONSE packet verification to extract skb to a linear buffer")
--- net/rxrpc/ar-internal.h | 7 ++- net/rxrpc/call_event.c | 27 +-------------- net/rxrpc/call_object.c | 2 + net/rxrpc/insecure.c | 3 - net/rxrpc/recvmsg.c | 68 ++++++++++++++++++++++++++++++------- net/rxrpc/rxkad.c | 86 +++++++++++++++++------------------------------- 6 files changed, 96 insertions(+), 97 deletions(-)
net/rxrpc/ar-internal.h +5 -2
@@ -203,8 +203,6 @@ struct rxrpc_skb_priv {struct {u16 offset;/* Offset of data */ u16 len;/* Length of data */ -u8 flags; -#define RXRPC_RX_VERIFIED 0x01 };struct {rxrpc_seq_t first_ack;/* First packet in acks table */
@@ -686,6 +684,11 @@ struct rxrpc_call {/* Received data tracking */ struct sk_buff_head recvmsg_queue;/* Queue of packets ready for recvmsg() */ struct sk_buff_head rx_oos_queue;/* Queue of out of sequence packets */ +void *rx_dec_buffer;/* Decryption buffer */ +unsigned short rx_dec_bsize;/* rx_dec_buffer size */ +unsigned short rx_dec_offset;/* Decrypted packet data offset */ +unsigned short rx_dec_len;/* Decrypted packet data len */ +rxrpc_seq_t rx_dec_seq;/* Packet in decryption buffer */ rxrpc_seq_t rx_highest_seq;/* Higest sequence number received */ rxrpc_seq_t rx_consumed;/* Highest packet consumed */
net/rxrpc/call_event.c +2 -25
@@ -342,31 +342,8 @@ bool rxrpc_input_call_event(struct rxrpcif (skb && skb->mark ==RXRPC_SKB_MARK_ERROR ) goto out; -if (skb) { -struct rxrpc_skb_priv *sp =rxrpc_skb (skb); - -if (sp->hdr.type ==RXRPC_PACKET_TYPE_DATA && - sp->hdr.securityIndex !=0 && - (skb_cloned (skb) || -skb_has_frag_list (skb) || -skb_has_shared_frag (skb))) { -/* Unshare the packet so that it can be modified for -* in-place decryption. -*/ -struct sk_buff *nskb =skb_copy (skb,GFP_ATOMIC ); - -if (nskb) { -rxrpc_new_skb (nskb, rxrpc_skb_new_unshared); -rxrpc_input_call_packet (call, nskb); -rxrpc_free_skb (nskb, rxrpc_skb_put_input); - }else { -/* OOM - Drop the packet. */ -rxrpc_see_skb (skb, rxrpc_skb_see_unshare_nomem); - } - }else { -rxrpc_input_call_packet (call, skb); - } - } +if (skb) +rxrpc_input_call_packet (call, skb);/* If we see our async-event poke, check for timeout trippage. */ now =ktime_get_real ();
net/rxrpc/call_object.c +2 -0
@@ -154,6 +154,7 @@ struct rxrpc_call *rxrpc_alloc_call(struspin_lock_init (&call->tx_lock);refcount_set (&call->ref,1 ); call->debug_id = debug_id; + call->rx_pkt_offset =USHRT_MAX ; call->tx_total_len =-1 ; call->next_rx_timo =20 *HZ ; call->next_req_timo =1 *HZ ;
@@ -535,6 +536,7 @@ static void rxrpc_cleanup_ring(struct rx {rxrpc_purge_queue (&call->recvmsg_queue);rxrpc_purge_queue (&call->rx_oos_queue); +kfree (call->rx_dec_buffer); }/*
net/rxrpc/insecure.c +0 -3
@@ -29,9 +29,6 @@ static int none_secure_packet(struct rxrstatic int none_verify_packet (struct rxrpc_call *call,struct sk_buff *skb) { -struct rxrpc_skb_priv *sp =rxrpc_skb (skb); - - sp->flags |=RXRPC_RX_VERIFIED ;return 0 ; }
net/rxrpc/recvmsg.c +55 -13
104 lines not on this page · raw message
net/rxrpc/rxkad.c +32 -54
166 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 269/307 rxrpc: Fix RESPONSE packet verification to extract skb to a linear buffer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 8bfab4b6ffc2fe92da86300728fc8c3c7ebffb56 ]
This improves the fix for CVE-2026-43500.
Fix the verification of RESPONSE packets to avoid the problem of overwriting a RESPONSE packet sent via splice to a local address by extracting the contents of the UDP packet into a kmalloc'd linear buffer rather than decrypting the data in place in the sk_buff (which may corrupt the original buffer).
--- net/rxrpc/ar-internal.h | 5 +++-- net/rxrpc/conn_event.c | 30 ++++++++++++------------------ net/rxrpc/insecure.c | 5 +++-- net/rxrpc/rxkad.c | 29 ++++++++++------------------- 4 files changed, 28 insertions(+), 41 deletions(-)
net/rxrpc/ar-internal.h +3 -2
@@ -270,8 +270,9 @@ struct rxrpc_security { struct sk_buff *);/* verify a response */ -int (*verify_response)(struct rxrpc_connection *, -struct sk_buff *); +int (*verify_response)(struct rxrpc_connection *conn, +struct sk_buff *response_skb, +void *response,unsigned int len);/* clear connection security */ void (*clear)(struct rxrpc_connection *);
net/rxrpc/conn_event.c +12 -18
@@ -229,28 +229,22 @@ static void rxrpc_call_is_secure(structstatic int rxrpc_verify_response (struct rxrpc_connection *conn,struct sk_buff *skb) { +unsigned int len = skb->len -sizeof (struct rxrpc_wire_header ); +void *buffer;int ret; -if (skb_cloned (skb) ||skb_has_frag_list (skb) || -skb_has_shared_frag (skb)) { -/* Copy the packet if shared so that we can do in-place -* decryption. -*/ -struct sk_buff *nskb =skb_copy (skb,GFP_NOFS ); + buffer =kmalloc (len,GFP_NOFS ); +if (!buffer) +return -ENOMEM ; -if (nskb) { -rxrpc_new_skb (nskb, rxrpc_skb_new_unshared); - ret = conn->security->verify_response (conn, nskb); -rxrpc_free_skb (nskb, rxrpc_skb_put_response_copy); - }else { -/* OOM - Drop the packet. */ -rxrpc_see_skb (skb, rxrpc_skb_see_unshare_nomem); - ret = -ENOMEM ; - } - }else { - ret = conn->security->verify_response (conn, skb); - } + ret =skb_copy_bits (skb,sizeof (struct rxrpc_wire_header ), buffer, len); +if (ret <0 ) + goto out; + ret = conn->security->verify_response (conn, skb, buffer, len); + +out: +kfree (buffer);return ret; }
net/rxrpc/insecure.c +3 -2
@@ -44,9 +44,10 @@ static int none_respond_to_challenge(str }static int none_verify_response (struct rxrpc_connection *conn, -struct sk_buff *skb) +struct sk_buff *response_skb, +void *response,unsigned int len) { -return rxrpc_abort_conn (conn, skb,RX_PROTOCOL_ERROR , -EPROTO , +return rxrpc_abort_conn (conn, response_skb,RX_PROTOCOL_ERROR , -EPROTO , rxrpc_eproto_rxnull_response); }
net/rxrpc/rxkad.c +10 -19
@@ -875,7 +875,6 @@ static int rxkad_decrypt_ticket(struct r *_expiry =0 ;ASSERT (server_key->payload.data[0 ] !=NULL ); - ASSERTCMP((unsigned long) ticket & 7UL, ==, 0);memcpy (&iv, &server_key->payload.data[2 ],sizeof (iv));
@@ -1024,14 +1023,15 @@ unlock:* verify a response */ static int rxkad_verify_response (struct rxrpc_connection *conn, -struct sk_buff *skb) +struct sk_buff *skb, +void *buffer,unsigned int len) {struct rxkad_response *response;struct rxrpc_skb_priv *sp =rxrpc_skb (skb);struct rxrpc_crypt session_key;struct key *server_key;time64_t expiry; -void *ticket =NULL ; +void *ticket;u32 version, kvno, ticket_len, level;__be32 csum;int ret, i;
@@ -1054,13 +1054,8 @@ static int rxkad_verify_response(struct } } - ret = -ENOMEM ; - response =kzalloc (sizeof (struct rxkad_response ),GFP_NOFS ); -if (!response) - goto error; - -if (skb_copy_bits (skb,sizeof (struct rxrpc_wire_header ), - response,sizeof (*response)) <0 ) { + response = buffer; +if (len <sizeof (*response)) { ret =rxrpc_abort_conn (conn, skb,RXKADPACKETSHORT , -EPROTO , rxkad_abort_resp_short); goto error;
@@ -1072,6 +1067,9 @@ static int rxkad_verify_response(structtrace_rxrpc_rx_response (conn, sp->hdr.serial, version, kvno, ticket_len); + buffer +=sizeof (*response); + len -=sizeof (*response); +if (version !=RXKAD_VERSION ) { ret =rxrpc_abort_conn (conn, skb,RXKADINCONSISTENCY , -EPROTO , rxkad_abort_resp_version);
@@ -1091,13 +1089,8 @@ static int rxkad_verify_response(struct }/* extract the kerberos ticket and decrypt and decode it */ - ret = -ENOMEM ; - ticket =kmalloc (ticket_len,GFP_NOFS ); -if (!ticket) - goto error; - -if (skb_copy_bits (skb,sizeof (struct rxrpc_wire_header ) +sizeof (*response), - ticket, ticket_len) <0 ) { + ticket = buffer; +if (ticket_len > len) { ret =rxrpc_abort_conn (conn, skb,RXKADPACKETSHORT , -EPROTO , rxkad_abort_resp_short_tkt); goto error;
@@ -1177,8 +1170,6 @@ static int rxkad_verify_response(struct ret =rxrpc_get_server_data_key (conn, &session_key, expiry, kvno); error: -kfree (ticket); -kfree (response);key_put (server_key);_leave (" = %d" , ret);return ret;
Greg Kroah-Hartman
maintainerPATCH 270/307 serdev: Provide a bustype shutdown function
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 6d71c62b13c33ea858ab298fe20beaec5736edc7 ]
To prepare serdev driver to migrate away from struct device_driver::shutdown (and then eventually remove that callback) create a serdev driver shutdown callback and migration code to keep the existing behaviour. Note this introduces a warning for each driver at register time that isn't converted yet to that callback.
Stable-dep-of: 375ba7484132 ("Bluetooth: hci_qca: Convert timeout from jiffies to ms")
--- drivers/tty/serdev/core.c | 21 +++++++++++++++++++++ include/linux/serdev.h | 1 + 2 files changed, 22 insertions(+)
drivers/tty/serdev/core.c +21 -0
@@ -431,11 +431,21 @@ static void serdev_drv_remove(struct devdev_pm_domain_detach (dev, true); } +static void serdev_drv_shutdown (struct device *dev) +{ +const struct serdev_device_driver *sdrv = +to_serdev_device_driver (dev->driver); + +if (dev->driver && sdrv->shutdown) + sdrv->shutdown (to_serdev_device (dev)); +} +static const struct bus_type serdev_bus_type = { .name ="serial" , .match = serdev_device_match, .probe = serdev_drv_probe, .remove = serdev_drv_remove, + .shutdown = serdev_drv_shutdown, };/**
@@ -832,6 +842,14 @@ void serdev_controller_remove(struct ser }EXPORT_SYMBOL_GPL (serdev_controller_remove); +static void serdev_legacy_shutdown (struct serdev_device *serdev) +{ +struct device *dev = &serdev->dev; +struct device_driver *driver = dev->driver; + + driver->shutdown (dev); +} +/** * __serdev_device_driver_register() - Register client driver with serdev core * @sdrv: client driver to be associated with client-device.
@@ -848,6 +866,9 @@ int __serdev_device_driver_register(stru/* force drivers to async probe so I/O is possible in probe */ sdrv->driver.probe_type =PROBE_PREFER_ASYNCHRONOUS ; +if (!sdrv->shutdown && sdrv->driver.shutdown) + sdrv->shutdown = serdev_legacy_shutdown; +return driver_register (&sdrv->driver); }EXPORT_SYMBOL_GPL (__serdev_device_driver_register);
include/linux/serdev.h +1 -0
@@ -65,6 +65,7 @@ struct serdev_device_driver {struct device_driver driver;int (*probe)(struct serdev_device *);void (*remove)(struct serdev_device *); +void (*shutdown)(struct serdev_device *); };static inline struct serdev_device_driver *to_serdev_device_driver (struct device_driver *d)
Greg Kroah-Hartman
maintainerPATCH 271/307 Bluetooth: hci_qca: Migrate to serdev specific shutdown function
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 12a6a5726c515455935982429ac35dee2307233d ]
This saves a cast in the driver. The motivation is stop using the callback .shutdown in qca_serdev_driver.driver to make it possible to drop that.
Stable-dep-of: 375ba7484132 ("Bluetooth: hci_qca: Convert timeout from jiffies to ms")
--- drivers/bluetooth/hci_qca.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/bluetooth/hci_qca.c +2 -3
@@ -2516,11 +2516,10 @@ static void qca_serdev_remove(struct serhci_uart_unregister_device (&qcadev->serdev_hu); } -static void qca_serdev_shutdown (struct device *dev) +static void qca_serdev_shutdown (struct serdev_device *serdev) {int ret;int timeout =msecs_to_jiffies (CMD_TRANS_TIMEOUT_MS ); -struct serdev_device *serdev =to_serdev_device (dev);struct qca_serdev *qcadev =serdev_device_get_drvdata (serdev);struct hci_uart *hu = &qcadev->serdev_hu;struct hci_dev *hdev = hu->hdev;
@@ -2741,11 +2740,11 @@ static void hciqca_coredump(struct devicstatic struct serdev_device_driver qca_serdev_driver = { .probe = qca_serdev_probe, .remove = qca_serdev_remove, + .shutdown = qca_serdev_shutdown, .driver = { .name ="hci_uart_qca" , .of_match_table =of_match_ptr (qca_bluetooth_of_match), .acpi_match_table =ACPI_PTR (qca_bluetooth_acpi_match), - .shutdown = qca_serdev_shutdown, .pm = &qca_pm_ops, #ifdef CONFIG_DEV_COREDUMP .coredump = hciqca_coredump,
Greg Kroah-Hartman
maintainerPATCH 272/307 Bluetooth: hci_qca: Convert timeout from jiffies to ms
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuai Zhang <[email protected]>
[ Upstream commit 375ba7484132662a4a8c7547d088fb6275c00282 ]
Since the timer uses jiffies as its unit rather than ms, the timeout value must be converted from ms to jiffies when configuring the timer. Otherwise, the intended 8s timeout is incorrectly set to approximately 33s.
To improve readability, embed msecs_to_jiffies() directly in the macro definitions and drop the _MS suffix from macros that now yield jiffies
values: MEMDUMP_TIMEOUT, FW_DOWNLOAD_TIMEOUT, IBS_DISABLE_SSR_TIMEOUT, CMD_TRANS_TIMEOUT, and IBS_BTSOC_TX_IDLE_TIMEOUT.
IBS_WAKE_RETRANS_TIMEOUT_MS and IBS_HOST_TX_IDLE_TIMEOUT_MS are intentionally left unchanged. Their values are stored in the struct fields wake_retrans and tx_idle_delay, which hold ms values at runtime and can be modified via debugfs. The msecs_to_jiffies() conversion happens at each call site against the field value, so it cannot be embedded in the macro.
Wake timer depends on commit c347ca17d62a
--- drivers/bluetooth/hci_qca.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/bluetooth/hci_qca.c +16 -17
@@ -47,13 +47,12 @@#define HCI_MAX_IBS_SIZE 10#define IBS_WAKE_RETRANS_TIMEOUT_MS 100 -#define IBS_BTSOC_TX_IDLE_TIMEOUT_MS 200 +#define IBS_BTSOC_TX_IDLE_TIMEOUT msecs_to_jiffies(200)#define IBS_HOST_TX_IDLE_TIMEOUT_MS 2000 -#define CMD_TRANS_TIMEOUT_MS 100 -#define MEMDUMP_TIMEOUT_MS 8000 -#define IBS_DISABLE_SSR_TIMEOUT_MS \ - (MEMDUMP_TIMEOUT_MS + FW_DOWNLOAD_TIMEOUT_MS) -#define FW_DOWNLOAD_TIMEOUT_MS 3000 +#define CMD_TRANS_TIMEOUT msecs_to_jiffies(100) +#define MEMDUMP_TIMEOUT msecs_to_jiffies(8000) +#define FW_DOWNLOAD_TIMEOUT msecs_to_jiffies(3000) +#define IBS_DISABLE_SSR_TIMEOUT (MEMDUMP_TIMEOUT + FW_DOWNLOAD_TIMEOUT)/* susclk rate */ #define SUSCLK_RATE_32KHZ 32768
@@ -1078,7 +1077,7 @@ static void qca_controller_memdump(strucqueue_delayed_work (qca->workqueue, &qca->ctrl_memdump_timeout, -msecs_to_jiffies (MEMDUMP_TIMEOUT_MS )); +MEMDUMP_TIMEOUT );skb_pull (skb,sizeof (qca_memdump->ram_dump_size)); qca_memdump->current_seq_no =0 ; qca_memdump->received_dump =0 ;
@@ -1350,7 +1349,7 @@ static int qca_set_baudrate(struct hci_dif (hu->serdev)serdev_device_wait_until_sent (hu->serdev, -msecs_to_jiffies (CMD_TRANS_TIMEOUT_MS )); +CMD_TRANS_TIMEOUT );/* Give the controller time to process the request */ switch (qca_soc_type (hu)) {
@@ -1381,8 +1380,8 @@ static inline void host_set_baudrate(strstatic int qca_send_power_pulse (struct hci_uart *hu,bool on) { +int timeout =CMD_TRANS_TIMEOUT ;int ret; -int timeout =msecs_to_jiffies (CMD_TRANS_TIMEOUT_MS );u8 cmd = on ?QCA_WCN3990_POWERON_PULSE :QCA_WCN3990_POWEROFF_PULSE ;/* These power pulses are single byte command which are sent
@@ -1584,7 +1583,7 @@ static void qca_wait_for_dump_collectionstruct qca_data *qca = hu->priv;wait_on_bit_timeout (&qca->flags,QCA_MEMDUMP_COLLECTION , -TASK_UNINTERRUPTIBLE ,MEMDUMP_TIMEOUT_MS ); +TASK_UNINTERRUPTIBLE ,MEMDUMP_TIMEOUT );clear_bit (QCA_MEMDUMP_COLLECTION , &qca->flags); }
@@ -2519,7 +2518,7 @@ static void qca_serdev_remove(struct serstatic void qca_serdev_shutdown (struct serdev_device *serdev) {int ret; -int timeout =msecs_to_jiffies (CMD_TRANS_TIMEOUT_MS ); +int timeout =CMD_TRANS_TIMEOUT ;struct qca_serdev *qcadev =serdev_device_get_drvdata (serdev);struct hci_uart *hu = &qcadev->serdev_hu;struct hci_dev *hdev = hu->hdev;
@@ -2576,7 +2575,7 @@ static int __maybe_unused qca_suspend(stbool tx_pending = false;int ret =0 ;u8 cmd; -u32 wait_timeout =0 ; +unsigned long wait_timeout =0 ;set_bit (QCA_SUSPENDING , &qca->flags);
@@ -2597,15 +2596,15 @@ static int __maybe_unused qca_suspend(stif (test_bit (QCA_IBS_DISABLED , &qca->flags) ||test_bit (QCA_SSR_TRIGGERED , &qca->flags)) { wait_timeout =test_bit (QCA_SSR_TRIGGERED , &qca->flags) ? -IBS_DISABLE_SSR_TIMEOUT_MS : -FW_DOWNLOAD_TIMEOUT_MS ; +IBS_DISABLE_SSR_TIMEOUT : +FW_DOWNLOAD_TIMEOUT ;/* QCA_IBS_DISABLED flag is set to true, During FW download * and during memory dump collection. It is reset to false, * After FW download complete. */ wait_on_bit_timeout (&qca->flags,QCA_IBS_DISABLED , -TASK_UNINTERRUPTIBLE ,msecs_to_jiffies (wait_timeout)); +TASK_UNINTERRUPTIBLE , wait_timeout);if (test_bit (QCA_IBS_DISABLED , &qca->flags)) {bt_dev_err (hu->hdev,"SSR or FW download time out" );
@@ -2657,7 +2656,7 @@ static int __maybe_unused qca_suspend(stif (tx_pending) {serdev_device_wait_until_sent (hu->serdev, -msecs_to_jiffies (CMD_TRANS_TIMEOUT_MS )); +CMD_TRANS_TIMEOUT );serial_clock_vote (HCI_IBS_TX_VOTE_CLOCK_OFF , hu); }
@@ -2666,7 +2665,7 @@ static int __maybe_unused qca_suspend(st*/ ret =wait_event_interruptible_timeout (qca->suspend_wait_q, qca->rx_ibs_state ==HCI_IBS_RX_ASLEEP , -msecs_to_jiffies (IBS_BTSOC_TX_IDLE_TIMEOUT_MS )); +IBS_BTSOC_TX_IDLE_TIMEOUT );if (ret ==0 ) { ret = -ETIMEDOUT ; goto error;
Greg Kroah-Hartman
maintainerPATCH 273/307 ALSA: scarlett2: Return ENOSPC for out-of-bounds flash writes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Geoffrey D. Bennett" <[email protected]>
[ Upstream commit 74641bfcbf4e698b770b1b62a74e73934843e90e ]
When writing to flash, return ENOSPC instead of EINVAL if the requested write would exceed the size of the flash segment.
Stable-dep-of: a69b677e47a8 ("ALSA: scarlett2: Allow flash writes ending at segment boundary")
--- sound/usb/mixer_scarlett2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/mixer_scarlett2.c +1 -1
@@ -9550,7 +9550,7 @@ static long scarlett2_hwdep_write(structSCARLETT2_FLASH_BLOCK_SIZE ;if (count <0 || *offset <0 || *offset + count >= flash_size) -return -EINVAL ; +return -ENOSPC ;if (!count)return 0 ;
Greg Kroah-Hartman
maintainerPATCH 274/307 ALSA: scarlett2: Allow flash writes ending at segment boundary
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit a69b677e47a80319ce148d61cc29a2b57006e78d ]
scarlett2_hwdep_write() rejects writes when offset + count is greater than or equal to the selected flash segment size. That incorrectly treats a write ending exactly at the end of the segment as out of space, although the last byte written is still within the segment.
Split invalid argument checks from the segment-space check, keep zero-length writes as no-ops, and compare count against the remaining segment size. This permits exact-end writes and avoids relying on offset + count before deciding whether the request is in bounds.
--- sound/usb/mixer_scarlett2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/usb/mixer_scarlett2.c +5 -2
@@ -9549,12 +9549,15 @@ static long scarlett2_hwdep_write(struct flash_size = private->flash_segment_blocks[segment_id] *SCARLETT2_FLASH_BLOCK_SIZE ; -if (count <0 || *offset <0 || *offset + count >= flash_size) -return -ENOSPC ; +if (count <0 || *offset <0 ) +return -EINVAL ;if (!count)return 0 ; +if (*offset >= flash_size || count > flash_size - *offset) +return -ENOSPC ; +/* Limit the *req size to SCARLETT2_FLASH_RW_MAX */ if (count > max_data_size) count = max_data_size;
Greg Kroah-Hartman
maintainerPATCH 275/307 mm/memory: fix spurious warning when unmapping device-private/exclusive pages
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alistair Popple <[email protected]>
[ Upstream commit be3f38d05cc5a7c3f13e51994c5dd043ab604d28 ]
Device private and exclusive entries are only supported for anonymous folios. This condition is tested in __migrate_device_pages() and make_device_exclusive() using folio_test_anon(). However the unmap path tests this assumption using vma_is_anonymous().
This is wrong because whilst anonymous VMAs can only contain folios where folio_test_anon() is true the opposite relation does not hold. A folio for which folio_test_anon() is true does not imply vma_is_anonymous() is true. Such a condition can occur if for example a folio is part of a private filebacked mapping.
In this case vma_is_anonymous() is false as the mapping is filebacked, but folio_test_anon() may be true, thus permitting devices to migrate the folio to device private memory. This can lead to the following spurious warnings during process teardown:
[ 772.737706] ------------[ cut here ]------------ [ 772.739201] WARNING: mm/memory.c:1754 at unmap_page_range.cold+0x26/0x18a, CPU#17: hmm-tests/2041 [ 772.742050] Modules linked in: test_hmm nvidia_uvm(O) nvidia(O) [ 772.743959] CPU: 17 UID: 0 PID: 2041 Comm: hmm-tests Tainted: G W O 7.0.0+ #387 PREEMPT(full) [ 772.747104] Tainted: [W]=WARN, [O]=OOT_MODULE [ 772.748509] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.17.0-0-gb52ca86e094d-prebuilt.qemu.org 04/01/2014 [ 772.752117] RIP: 0010:unmap_page_range.cold+0x26/0x18a [ 772.753780] Code: 7e fe ff ff 48 89 4c 24 78 4c 89 44 24 38 e8 f2 ff b1 00 48 8b 4c 24 78 4c 8b 44 24 38 48 8b 44 24 18 48 83 78 48 00 74 04 90 <0f> 0b 90 48 89 ca b8 ff ff 37 00 48 c1 ea 03 48 c1 e0 2a 80 3c 02 [ 772.759602] RSP: 0018:ffff888112607550 EFLAGS: 00010286 [ 772.761310] RAX: ffff88811bbf4dc0 RBX: dffffc0000000000 RCX: ffffea03e9bfffd8 [ 772.763583] RDX: 1ffff1102377e9c1 RSI: 0000000000000008 RDI: ffff88811bbf4e08 [ 772.765914] RBP: 0000000000000006 R08: ffff8881059f7448 R09: ffffed10224c0e68 [ 772.768184] R10: ffff888112607347 R11: 0000000000000001 R12: 0000000000000001 [ 772.770461] R13: ffffea03e9bfffc0 R14: ffff888112607908 R15: ffffea03e9bfffc0 [ 772.772782] FS: 00007f327caa2780(0000) GS:ffff888427b7d000(0000) knlGS:0000000000000000 [ 772.775328] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 772.777187] CR2: 00007f327ca89000 CR3: 00000001994d5000 CR4: 00000000000006f0 [ 772.779135] Call Trace: [ 772.779792] <TASK> [ 772.780317] ? dmirror_interval_invalidate+0x1a3/0x290 [test_hmm] [ 772.781873] ? vm_normal_page_pud+0x2b0/0x2b0 [ 772.782992] ? __rwlock_init+0x150/0x150 [ 772.784006] ? lock_release+0x216/0x2b0 [ 772.785008] ? __mmu_notifier_invalidate_range_start+0x505/0x6e0 [ 772.786522] ? lock_release+0x216/0x2b0 [ 772.787498] ? unmap_single_vma+0xb6/0x210 [ 772.788573] unmap_vmas+0x27d/0x520 [ 772.789506] ? unmap_single_vma+0x210/0x210 [ 772.790607] ? mas_update_gap.part.0+0x620/0x620 [ 772.791834] unmap_region+0x19e/0x350 [ 772.792769] ? remove_vma+0x130/0x130 [ 772.793684] ? mas_alloc_nodes+0x1f2/0x300 [ 772.794730] vms_complete_munmap_vmas+0x8c1/0xe20 [ 772.795926] ? unmap_region+0x350/0x350 [ 772.796917] do_vmi_align_munmap+0x36a/0x4e0 [ 772.798018] ? lock_release+0x216/0x2b0 [ 772.799024] ? vma_shrink+0x620/0x620 [ 772.799983] do_vmi_munmap+0x150/0x2c0 [ 772.800939] __vm_munmap+0x161/0x2c0 [ 772.801872] ? expand_downwards+0xd60/0xd60 [ 772.802948] ? clockevents_program_event+0x1ef/0x540 [ 772.804217] ? lock_release+0x216/0x2b0 [ 772.805158] __x64_sys_munmap+0x59/0x80 [ 772.805776] do_syscall_64+0xfc/0x670 [ 772.806336] ? irqentry_exit+0xda/0x580 [ 772.806976] entry_SYSCALL_64_after_hwframe+0x4b/0x53 [ 772.807772] RIP: 0033:0x7f327cbb2717 [ 772.808323] Code: 73 01 c3 48 8b 0d f9 76 0d 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 0b 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c9 76 0d 00 f7 d8 64 89 01 48 [ 772.811337] RSP: 002b:00007ffde7f57d38 EFLAGS: 00000202 ORIG_RAX: 000000000000000b [ 772.812564] RAX: ffffffffffffffda RBX: 00007f327cc9c000 RCX: 00007f327cbb2717 [ 772.813733] RDX: 0000000000000000 RSI: 0000000000400000 RDI: 00007f327c289000 [ 772.814867] RBP: 0000000000421360 R08: 000000000000001a R09: 0000000000000000 [ 772.815991] R10: 0000000000000003 R11: 0000000000000202 R12: 00007ffde7f57d74 [ 772.817121] R13: 00007f327c689010 R14: 0000000000100000 R15: 00007f327c289000 [ 772.818272] </TASK> [ 772.818614] irq event stamp: 0 [ 772.819159] hardirqs last enabled at (0): [<0000000000000000>] 0x0 [ 772.820174] hardirqs last disabled at (0): [<ffffffff82a57ab3>] copy_process+0x19f3/0x6440 [ 772.821511] softirqs last enabled at (0): [<ffffffff82a57b00>] copy_process+0x1a40/0x6440 [ 772.822869] softirqs last disabled at (0): [<0000000000000000>] 0x0 [ 772.823871] ---[ end trace 0000000000000000 ]---
Fix this by using the same check for folio_test_anon() in zap_nonpresent_ptes(). Also add a hmm-test case for this.
--- mm/memory.c | 2 - tools/testing/selftests/mm/hmm-tests.c | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-)
mm/memory.c +1 -1
@@ -1639,7 +1639,7 @@ static unsigned long zap_pte_range(struc* consider uffd-wp bit when zap. For more information, * see zap_install_uffd_wp_if_needed(). */ -WARN_ON_ONCE (!vma_is_anonymous (vma)); +WARN_ON_ONCE (!folio_test_anon (folio)); rss[mm_counter (folio)]--;if (is_device_private_entry (entry))folio_remove_rmap_pte (folio, page, vma);
tools/testing/selftests/mm/hmm-tests.c +50 -0
56 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 276/307 platform/x86/intel/vsec: Fix enable_cnt imbalance on PCIe error recovery
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
[ Upstream commit 348ccc754d8939e21ca5956ff45720b81d6e407f ]
After a PCIe Uncorrectable Error has been reported by a device with Intel Vendor Specific Extended Capabilities and has been recovered through a Secondary Bus Reset, its driver calls intel_vsec_pci_probe() to rescan and reinitialize VSECs.
intel_vsec_pci_probe() invokes pcim_enable_device() and thereby adds another devm action which calls pcim_disable_device() on driver unbind.
So once the driver unbinds, pcim_disable_device() will be called as many times as an Uncorrectable Error occurred, plus one. This will lead to an enable_cnt imbalance on driver unbind.
Additionally, since commit dc957ab6aa05 ("platform/x86/intel/vsec: Add private data for per-device data"), a devm_kzalloc() allocation is leaked on every Uncorrectable Error.
Avoid by splitting the VSEC rescan out of intel_vsec_pci_probe() into a separate helper and calling that on PCIe error recovery.
--- drivers/platform/x86/intel/vsec.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
drivers/platform/x86/intel/vsec.c +22 -14
@@ -348,20 +348,10 @@ void intel_vsec_register(struct pci_dev }EXPORT_SYMBOL_NS_GPL (intel_vsec_register,INTEL_VSEC ); -static int intel_vsec_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) +static int intel_vsec_pci_init (struct pci_dev *pdev, +struct intel_vsec_platform_info *info) { -struct intel_vsec_platform_info *info;bool have_devices = false; -int ret; - - ret =pcim_enable_device (pdev); -if (ret) -return ret; - -pci_save_state (pdev); - info = (struct intel_vsec_platform_info *)id->driver_data; -if (!info) -return -EINVAL ;if (intel_vsec_walk_dvsec (pdev, info)) have_devices = true;
@@ -379,6 +369,23 @@ static int intel_vsec_pci_probe(struct preturn 0 ; } +static int intel_vsec_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) +{ +struct intel_vsec_platform_info *info; +int ret; + + ret =pcim_enable_device (pdev); +if (ret) +return ret; + +pci_save_state (pdev); + info = (struct intel_vsec_platform_info *)id->driver_data; +if (!info) +return -EINVAL ; + +return intel_vsec_pci_init (pdev, info); +} +/* DG1 info */ static struct intel_vsec_header dg1_header = { .length =0x10 ,
@@ -467,6 +474,7 @@ static pci_ers_result_t intel_vsec_pci_estatic pci_ers_result_t intel_vsec_pci_slot_reset (struct pci_dev *pdev) {struct intel_vsec_device *intel_vsec_dev; +struct intel_vsec_platform_info *info;pci_ers_result_t status =PCI_ERS_RESULT_DISCONNECT ;const struct pci_device_id *pci_dev_id;unsigned long index;
@@ -489,10 +497,10 @@ static pci_ers_result_t intel_vsec_pci_sdevm_release_action (&pdev->dev, intel_vsec_remove_aux, &intel_vsec_dev->auxdev); } -pci_disable_device (pdev);pci_restore_state (pdev); pci_dev_id =pci_match_id (intel_vsec_pci_ids, pdev); -intel_vsec_pci_probe (pdev, pci_dev_id); + info = (struct intel_vsec_platform_info *)pci_dev_id->driver_data; +intel_vsec_pci_init (pdev, info); out:return status;
Greg Kroah-Hartman
maintainerPATCH 277/307 net: hsr: defer node table free until after RCU readers
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 aaec7096f9961eb223b5b149abe9495525c205d9 ]
HSR node-list and node-status generic-netlink operations run under rcu_read_lock(). They walk hsr->node_db through hsr_get_next_node() and hsr_get_node_data(), but RTM_DELLINK teardown removes the same node table with plain list_del() and frees each node immediately.
That lets a generic-netlink reader hold a struct hsr_node pointer across hsr_dellink(). In a KASAN build, widening the reader window after hsr_get_next_node() obtains the node reproduces a slab-use-after-free when the reader copies node->macaddress_A; the freeing stack is hsr_del_nodes() from hsr_dellink().
Use list_del_rcu() and defer the free through the existing hsr_free_node_rcu() callback. This matches the lifetime rule used by the HSR prune paths, which already delete nodes with list_del_rcu() and call_rcu().
--- net/hsr/hsr_framereg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/hsr/hsr_framereg.c +4 -2
@@ -131,8 +131,10 @@ void hsr_del_nodes(struct list_head *nodstruct hsr_node *node;struct hsr_node *tmp; -list_for_each_entry_safe (node, tmp, node_db, mac_list) -kfree (node); +list_for_each_entry_safe (node, tmp, node_db, mac_list) { +list_del_rcu (&node->mac_list); +kfree_rcu (node, rcu_head); + } } void prp_handle_san_frame(bool san, enum hsr_port_type port,
Greg Kroah-Hartman
maintainerPATCH 278/307 selftests: mptcp: drop nanoseconds width specifier
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 01ff78e4b3d98689184c52d97f9575dfbdc3b10f ]
Using the format specifier +%s%3N with GNU date is honoured, and only prints 3 digits of the nanoseconds portion of the seconds since epoch, which corresponds to the milliseconds.
The uutils implementation of date currently does not honour this, and always prints all 9 digits. This is a known issue [1], but can be worked around by adapting this test to use nanoseconds instead of microseconds, and then divide it by 1e6.
This fix is similar to what has been done on systemd side [2], and it is needed to run the selftests on Ubuntu 26.04, containing uutils 0.8.0.
Note that the Fixes tag is there even if this patch doesn't fix an issue in the kernel selftests, but it is useful for those using uutils 0.8.0.
--- tools/testing/selftests/net/mptcp/mptcp_connect.sh | 6 +++--- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +3 -3
@@ -412,7 +412,7 @@ do_transfer() mptcp_lib_wait_local_port_listen "${listener_ns}" "${port}" local start - start=$(date +%s%3N) + start=$(date +%s%N) timeout ${timeout_test} \ ip netns exec ${connector_ns} \ ./mptcp_connect -t ${timeout_poll} -p $port -s ${cl_proto} \
@@ -425,7 +425,7 @@ do_transfer() local rets=$? local stop - stop=$(date +%s%3N) + stop=$(date +%s%N) if $capture; then sleep 1
@@ -441,7 +441,7 @@ do_transfer() fi local duration - duration=$((stop-start)) + duration=$(((stop-start) / 1000000)) printf "(duration %05sms) " "${duration}" if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then mptcp_lib_pr_fail "client exit code $retc, server $rets"
tools/testing/selftests/net/mptcp/mptcp_lib.sh +5 -5
@@ -29,7 +29,7 @@ declare -rx MPTCP_LIB_AF_INET6=10 MPTCP_LIB_SUBTESTS=() MPTCP_LIB_SUBTESTS_DUPLICATED=0 MPTCP_LIB_SUBTEST_FLAKY=0 -MPTCP_LIB_SUBTESTS_LAST_TS_MS= +MPTCP_LIB_SUBTESTS_LAST_TS_NS= MPTCP_LIB_TEST_COUNTER=0 MPTCP_LIB_TEST_FORMAT="%02u %-50s" MPTCP_LIB_IP_MPTCP=0
@@ -207,7 +207,7 @@ mptcp_lib_kversion_ge() { } mptcp_lib_subtests_last_ts_reset() { - MPTCP_LIB_SUBTESTS_LAST_TS_MS="$(date +%s%3N)" + MPTCP_LIB_SUBTESTS_LAST_TS_NS="$(date +%s%N)" } mptcp_lib_subtests_last_ts_reset
@@ -226,7 +226,7 @@ __mptcp_lib_result_check_duplicated() { __mptcp_lib_result_add() { local result="${1}" local time="time=" - local ts_prev_ms + local ts_prev_ns shift local id=$((${#MPTCP_LIB_SUBTESTS[@]} + 1))
@@ -236,9 +236,9 @@ __mptcp_lib_result_add() { # not to add two '#' [[ "${*}" != *"#"* ]] && time="# ${time}" - ts_prev_ms="${MPTCP_LIB_SUBTESTS_LAST_TS_MS}" + ts_prev_ns="${MPTCP_LIB_SUBTESTS_LAST_TS_NS}" mptcp_lib_subtests_last_ts_reset - time+="$((MPTCP_LIB_SUBTESTS_LAST_TS_MS - ts_prev_ms))ms" + time+="$(((MPTCP_LIB_SUBTESTS_LAST_TS_NS - ts_prev_ns) / 1000000))ms" MPTCP_LIB_SUBTESTS+=("${result} ${id} - ${KSFT_TEST}: ${*} ${time}") }
Greg Kroah-Hartman
maintainerPATCH 279/307 mptcp: pm: fix ADD_ADDR timer infinite retry on option space insufficient
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Xiasong <[email protected]>
[ Upstream commit 51e398a3b8961b26a8c0a4ba9a777c5339791707 ]
When TCP option space is insufficient (e.g., when sending ADD_ADDR with an IPv6 address and port while tcp_timestamps is enabled), the original code jumped to out_unlock without clearing the addr_signal flag. This caused mptcp_pm_add_timer to keep rescheduling indefinitely, not sending ADD_ADDR, preventing subsequent addresses in the endpoint list from being announced.
Handle this case by clearing the ADD_ADDR signal and skipping the matching ADD_ADDR retransmission entry. The skip path cancels the matching timer (with id check) and advances PM state progression, preserving forward progress to subsequent PM work.
This cancellation is inherently best-effort. A concurrent add_timer callback may already be running and may acquire pm.lock before the cancel path updates entry state. In that case, one final ADD_ADDR transmit attempt can still be executed.
Once the cancel path sets entry->retrans_times to ADD_ADDR_RETRANS_MAX, the callback-side retrans_times check suppresses further ADD_ADDR retransmissions.
Note that when an ADD_ADDR is being prepared, a pure-ACK is queued. On the output side, it means that it is fine to skip non-pure-ACK packets, when drop_other_suboptions is set: a pure-ACK will be processed soon after.
--- net/mptcp/pm.c | 40 +++++++++++++++++++++++++++++++++------- net/mptcp/pm_netlink.c | 16 +++++++++++++--- 2 files changed, 46 insertions(+), 10 deletions(-)
net/mptcp/pm.c +33 -7
@@ -334,6 +334,7 @@ bool mptcp_pm_add_addr_signal(struct mpt struct mptcp_addr_info *addr, bool *echo, bool *drop_other_suboptions) { + bool skip_add_addr = false;int ret = false;u8 add_addr;u8 family;
@@ -355,24 +356,49 @@ bool mptcp_pm_add_addr_signal(struct mpt } *echo =mptcp_pm_should_add_signal_echo (msk); - port = !!(*echo ? msk->pm.remote.port : msk->pm.local.port); - - family = *echo ? msk->pm.remote.family : msk->pm.local.family; -if (remaining <mptcp_add_addr_len (family, *echo, port)) - goto out_unlock; -if (*echo) { *addr = msk->pm.remote; add_addr = msk->pm.addr_signal & ~BIT (MPTCP_ADD_ADDR_ECHO ); + port = !!msk->pm.remote.port; + family = msk->pm.remote.family; }else { *addr = msk->pm.local; add_addr = msk->pm.addr_signal & ~BIT (MPTCP_ADD_ADDR_SIGNAL ); + port = !!msk->pm.local.port; + family = msk->pm.local.family; } -WRITE_ONCE (msk->pm.addr_signal, add_addr); + +if (remaining <mptcp_add_addr_len (family, *echo, port)) { +struct net *net =sock_net ((struct sock *)msk); + +if (!*drop_other_suboptions) + goto out_unlock; + +if (*echo) { +MPTCP_INC_STATS (net,MPTCP_MIB_ECHOADDTXDROP ); + }else { + skip_add_addr = true; +MPTCP_INC_STATS (net,MPTCP_MIB_ADDADDRTXDROP ); + } + goto drop_signal_mark; + } + ret = true; +drop_signal_mark: +WRITE_ONCE (msk->pm.addr_signal, add_addr); + out_unlock:spin_unlock_bh (&msk->pm.lock); + +/* On pure-ACK option-space exhaustion, stop retrying this ADD_ADDR: +* clear the signal bit, cancel the matching retransmission timer, and +* let the PM state machine progress. +*/ +if (skip_add_addr) { +mptcp_pm_del_add_timer (msk, addr, true); +mptcp_pm_subflow_established (msk); + }return ret; }
net/mptcp/pm_netlink.c +13 -3
@@ -320,7 +320,13 @@ static void mptcp_pm_add_timer(struct tispin_lock_bh (&msk->pm.lock); -if (!mptcp_pm_should_add_signal_addr (msk)) { +/* The cancel path (mptcp_pm_del_add_timer()) can race with this +* callback. Once cancel updates retrans_times to MAX, suppress further +* retransmissions here. If this callback acquires pm.lock first, one +* final transmit attempt is still possible. +*/ +if (entry->retrans_times <ADD_ADDR_RETRANS_MAX && + !mptcp_pm_should_add_signal_addr (msk)) {pr_debug ("retransmit ADD_ADDR id=%d\n" , entry->addr.id);mptcp_pm_announce_addr (msk, &entry->addr, false);mptcp_pm_add_addr_send_ack (msk);
@@ -368,8 +374,12 @@ mptcp_pm_del_add_timer(struct mptcp_sock/* Note: entry might have been removed by another thread. * We hold rcu_read_lock() to ensure it is not freed under us. */ -if (stop_timer) -sk_stop_timer_sync (sk, &entry->add_timer); +if (stop_timer) { +if (check_id) +sk_stop_timer (sk, &entry->add_timer); +else +sk_stop_timer_sync (sk, &entry->add_timer); + }rcu_read_unlock ();return entry;
Greg Kroah-Hartman
maintainerPATCH 280/307 ice: fix VF queue configuration with low MTU values
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jose Ignacio Tornos Martinez <[email protected]>
[ Upstream commit 3ba4dd024d26372733d1c02e13e076c6016e3320 ]
The ice driver's VF queue configuration validation rejects databuffer_size values below 1024 bytes, which prevents VFs from using MTU values below 871 bytes.
The iavf driver calculates databuffer_size based on the MTU using:
databuffer_size = ALIGN(MTU + LIBETH_RX_LL_LEN, 128)
where LIBETH_RX_LL_LEN = 26 (ETH_HLEN + 2*VLAN_HLEN + ETH_FCS_LEN).
For MTU values below 871:
MTU 870: 870 + 26 = 896, aligned to 128 = 896 (< 1024, rejected) MTU 871: 871 + 26 = 897, aligned to 128 = 1024 (>= 1024, accepted)
The 1024-byte minimum seems unnecessarily restrictive, because the hardware supports databuffer_size as low as 128 bytes (the alignment boundary), which should allow MTU values down to the standard minimum of 68 bytes.
I haven't found the reason why the limit was configured in the commit 9c7dd7566d18 ("ice: add validation in OP_CONFIG_VSI_QUEUES VF message"), so with no more information and since it is working, change the minimum databuffer_size validation from 1024 to 128 bytes to allow standard low MTU values while still preventing invalid configurations.
--- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +1 -1
@@ -1746,7 +1746,7 @@ static int ice_vc_cfg_qs_msg(struct ice_if (qpi->rxq.databuffer_size !=0 && (qpi->rxq.databuffer_size > ((16 *1024 ) -128 ) || - qpi->rxq.databuffer_size <1024 )) + qpi->rxq.databuffer_size <128 )) goto error_param; ring->rx_buf_len = qpi->rxq.databuffer_size; if (qpi->rxq.max_pkt_size > max_frame_size ||
Greg Kroah-Hartman
maintainerPATCH 281/307 ring-buffer: Flush and stop persistent ring buffer on panic
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Masami Hiramatsu (Google)" <[email protected]>
[ Upstream commit a494d3c8d5392bcdff83c2a593df0c160ff9f322 ]
On real hardware, panic and machine reboot may not flush hardware cache to memory. This means the persistent ring buffer, which relies on a coherent state of memory, may not have its events written to the buffer and they may be lost. Moreover, there may be inconsistency with the counters which are used for validation of the integrity of the persistent ring buffer which may cause all data to be discarded.
To avoid this issue, stop recording of the ring buffer on panic and flush the cache of the ring buffer's memory.
--- arch/alpha/include/asm/Kbuild | 1 + arch/arc/include/asm/Kbuild | 1 + arch/arm/include/asm/Kbuild | 1 + arch/arm64/include/asm/ring_buffer.h | 10 ++++++++++ arch/csky/include/asm/Kbuild | 1 + arch/hexagon/include/asm/Kbuild | 1 + arch/loongarch/include/asm/Kbuild | 1 + arch/m68k/include/asm/Kbuild | 1 + arch/microblaze/include/asm/Kbuild | 1 + arch/mips/include/asm/Kbuild | 1 + arch/nios2/include/asm/Kbuild | 1 + arch/openrisc/include/asm/Kbuild | 1 + arch/parisc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/Kbuild | 1 + arch/riscv/include/asm/Kbuild | 1 + arch/s390/include/asm/Kbuild | 1 + arch/sh/include/asm/Kbuild | 1 + arch/sparc/include/asm/Kbuild | 1 + arch/um/include/asm/Kbuild | 1 + arch/x86/include/asm/Kbuild | 1 + arch/xtensa/include/asm/Kbuild | 1 + include/asm-generic/ring_buffer.h | 13 +++++++++++++ kernel/trace/ring_buffer.c | 22 ++++++++++++++++++++++ 23 files changed, 65 insertions(+) create mode 100644 arch/arm64/include/asm/ring_buffer.h create mode 100644 include/asm-generic/ring_buffer.h
arch/alpha/include/asm/Kbuild +1 -0
@@ -5,3 +5,4 @@ generic-y += agp.h generic-y += asm-offsets.h generic-y += kvm_para.h generic-y += mcs_spinlock.h +generic-y += ring_buffer.h
arch/arc/include/asm/Kbuild +1 -0
@@ -5,4 +5,5 @@ generic-y += extable.h generic-y += kvm_para.h generic-y += mcs_spinlock.h generic-y += parport.h +generic-y += ring_buffer.h generic-y += user.h
arch/arm/include/asm/Kbuild +1 -0
@@ -3,6 +3,7 @@ generic-y += early_ioremap.h generic-y += extable.h generic-y += flat.h generic-y += parport.h +generic-y += ring_buffer.h generated-y += mach-types.h generated-y += unistd-nr.h
arch/arm64/include/asm/ring_buffer.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_ARM64_RING_BUFFER_H +#define _ASM_ARM64_RING_BUFFER_H + +#include <asm/cacheflush.h> + +/* Flush D-cache on persistent ring buffer */ +#define arch_ring_buffer_flush_range (start, end) dcache_clean_pop(start, end) + +#endif /* _ASM_ARM64_RING_BUFFER_H */
arch/csky/include/asm/Kbuild +1 -0
@@ -9,5 +9,6 @@ generic-y += qrwlock.h generic-y += qrwlock_types.h generic-y += qspinlock.h generic-y += parport.h +generic-y += ring_buffer.h generic-y += user.h generic-y += vmlinux.lds.h
arch/hexagon/include/asm/Kbuild +1 -0
@@ -5,3 +5,4 @@ generic-y += extable.h generic-y += iomap.h generic-y += kvm_para.h generic-y += mcs_spinlock.h +generic-y += ring_buffer.h
arch/loongarch/include/asm/Kbuild +1 -0
@@ -9,5 +9,6 @@ generic-y += qrwlock.h generic-y += user.h generic-y += ioctl.h generic-y += mmzone.h +generic-y += ring_buffer.h generic-y += statfs.h generic-y += param.h
arch/m68k/include/asm/Kbuild +1 -0
@@ -3,4 +3,5 @@ generated-y += syscall_table.h generic-y += extable.h generic-y += kvm_para.h generic-y += mcs_spinlock.h +generic-y += ring_buffer.h generic-y += spinlock.h
arch/microblaze/include/asm/Kbuild +1 -0
@@ -5,6 +5,7 @@ generic-y += extable.h generic-y += kvm_para.h generic-y += mcs_spinlock.h generic-y += parport.h +generic-y += ring_buffer.h generic-y += syscalls.h generic-y += tlb.h generic-y += user.h
arch/mips/include/asm/Kbuild +1 -0
@@ -12,4 +12,5 @@ generic-y += mcs_spinlock.h generic-y += parport.h generic-y += qrwlock.h generic-y += qspinlock.h +generic-y += ring_buffer.h generic-y += user.h
arch/nios2/include/asm/Kbuild +1 -0
@@ -5,5 +5,6 @@ generic-y += cmpxchg.h generic-y += extable.h generic-y += kvm_para.h generic-y += mcs_spinlock.h +generic-y += ring_buffer.h generic-y += spinlock.h generic-y += user.h
arch/openrisc/include/asm/Kbuild +1 -0
@@ -8,4 +8,5 @@ generic-y += spinlock_types.h generic-y += spinlock.h generic-y += qrwlock_types.h generic-y += qrwlock.h +generic-y += ring_buffer.h generic-y += user.h
arch/parisc/include/asm/Kbuild +1 -0
@@ -4,4 +4,5 @@ generated-y += syscall_table_64.h generic-y += agp.h generic-y += kvm_para.h generic-y += mcs_spinlock.h +generic-y += ring_buffer.h generic-y += user.h
arch/powerpc/include/asm/Kbuild +1 -0
@@ -6,4 +6,5 @@ generic-y += agp.h generic-y += kvm_types.h generic-y += mcs_spinlock.h generic-y += qrwlock.h +generic-y += ring_buffer.h generic-y += early_ioremap.h
arch/riscv/include/asm/Kbuild +1 -0
@@ -11,5 +11,6 @@ generic-y += spinlock.h generic-y += spinlock_types.h generic-y += qrwlock.h generic-y += qrwlock_types.h +generic-y += ring_buffer.h generic-y += user.h generic-y += vmlinux.lds.h
arch/s390/include/asm/Kbuild +1 -0
@@ -8,3 +8,4 @@ generic-y += asm-offsets.h generic-y += kvm_types.h generic-y += mcs_spinlock.h generic-y += mmzone.h +generic-y += ring_buffer.h
arch/sh/include/asm/Kbuild +1 -0
@@ -3,3 +3,4 @@ generated-y += syscall_table.h generic-y += kvm_para.h generic-y += mcs_spinlock.h generic-y += parport.h +generic-y += ring_buffer.h
arch/sparc/include/asm/Kbuild +1 -0
@@ -4,3 +4,4 @@ generated-y += syscall_table_64.h generic-y += agp.h generic-y += kvm_para.h generic-y += mcs_spinlock.h +generic-y += ring_buffer.h
arch/um/include/asm/Kbuild +1 -0
@@ -19,6 +19,7 @@ generic-y += param.h generic-y += parport.h generic-y += percpu.h generic-y += preempt.h +generic-y += ring_buffer.h generic-y += runtime-const.h generic-y += softirq_stack.h generic-y += switch_to.h
arch/x86/include/asm/Kbuild +1 -0
@@ -12,3 +12,4 @@ generated-y += xen-hypercalls.h generic-y += early_ioremap.h generic-y += mcs_spinlock.h generic-y += mmzone.h +generic-y += ring_buffer.h
arch/xtensa/include/asm/Kbuild +1 -0
@@ -7,4 +7,5 @@ generic-y += param.h generic-y += parport.h generic-y += qrwlock.h generic-y += qspinlock.h +generic-y += ring_buffer.h generic-y += user.h
include/asm-generic/ring_buffer.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Generic arch dependent ring_buffer macros. +*/ +#ifndef __ASM_GENERIC_RING_BUFFER_H__ +#define __ASM_GENERIC_RING_BUFFER_H__ + +#include <linux/cacheflush.h> + +/* Flush cache on ring buffer range if needed. Do nothing by default. */ +#define arch_ring_buffer_flush_range (start, end) do { } while (0) + +#endif /* __ASM_GENERIC_RING_BUFFER_H__ */
kernel/trace/ring_buffer.c +22 -0
@@ -5,6 +5,7 @@* Copyright (C) 2008 Steven Rostedt <[email protected]> */ #include <linux/trace_recursion.h> +#include <linux/panic_notifier.h> #include <linux/trace_events.h> #include <linux/ring_buffer.h> #include <linux/trace_clock.h>
@@ -29,6 +30,7 @@#include <linux/oom.h> #include <linux/mm.h> +#include <asm/ring_buffer.h> #include <asm/local64.h> #include <asm/local.h>
@@ -549,6 +551,7 @@ struct trace_buffer {unsigned long range_addr_start;unsigned long range_addr_end; +struct notifier_block flush_nb;long last_text_delta;long last_data_delta;
@@ -2316,6 +2319,16 @@ static void rb_free_cpu_buffer(struct rikfree (cpu_buffer); } +/* Stop recording on a persistent buffer and flush cache if needed. */ +static int rb_flush_buffer_cb (struct notifier_block *nb,unsigned long event,void *data) +{ + struct trace_buffer *buffer = container_of(nb, struct trace_buffer, flush_nb); + +ring_buffer_record_off (buffer); +arch_ring_buffer_flush_range (buffer->range_addr_start, buffer->range_addr_end); +return NOTIFY_DONE ; +} + static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flags, int order, unsigned long start, unsigned long end,
@@ -2421,6 +2434,12 @@ static struct trace_buffer *alloc_buffermutex_init (&buffer->mutex); +/* Persistent ring buffer needs to flush cache before reboot. */ +if (start && end) { + buffer->flush_nb.notifier_call = rb_flush_buffer_cb; +atomic_notifier_chain_register (&panic_notifier_list, &buffer->flush_nb); + } +return buffer; fail_free_buffers:
@@ -2512,6 +2531,9 @@ ring_buffer_free(struct trace_buffer *bu {int cpu; +if (buffer->range_addr_start && buffer->range_addr_end) +atomic_notifier_chain_unregister (&panic_notifier_list, &buffer->flush_nb); +cpuhp_state_remove_instance (CPUHP_TRACE_RB_PREPARE , &buffer->node);irq_work_sync (&buffer->irq_work.work);
Greg Kroah-Hartman
maintainerPATCH 282/307 mptcp: cleanup fallback dummy mapping generation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 2834f8edd74d5dda368087a654c0e52b141e9893 ]
MPTCP currently access ack_seq outside the msk socket log scope to generate the dummy mapping for fallback socket. Soon we are going to introduce backlog usage and even for fallback socket the ack_seq value will be significantly off outside of the msk socket lock scope.
Avoid relying on ack_seq for dummy mapping generation, using instead the subflow sequence number. Note that in case of disconnect() and (re)connect() we must ensure that any previous state is re-set.
Stable-dep-of: 0981f90e1a05 ("mptcp: reset rcv wnd on disconnect")
--- net/mptcp/protocol.c | 3 +++ net/mptcp/subflow.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
net/mptcp/protocol.c +3 -0
@@ -3369,6 +3369,9 @@ static int mptcp_disconnect(struct sock msk->rcvspace_init =0 ; msk->fastclosing =0 ; +/* for fallback's sake */ +WRITE_ONCE (msk->ack_seq,0 ); +WRITE_ONCE (sk->sk_shutdown,0 );sk_error_report (sk);return 0 ;
net/mptcp/subflow.c +7 -1
@@ -490,6 +490,9 @@ static void subflow_set_remote_key(strucmptcp_crypto_key_sha (subflow->remote_key,NULL , &subflow->iasn); subflow->iasn++; +/* for fallback's sake */ + subflow->map_seq = subflow->iasn; +WRITE_ONCE (msk->remote_key, subflow->remote_key);WRITE_ONCE (msk->ack_seq, subflow->iasn);WRITE_ONCE (msk->can_ack, true);
@@ -1415,9 +1418,12 @@ reset: skb =skb_peek (&ssk->sk_receive_queue); subflow->map_valid =1 ; - subflow->map_seq =READ_ONCE (msk->ack_seq); subflow->map_data_len = skb->len; subflow->map_subflow_seq =tcp_sk (ssk)->copied_seq - subflow->ssn_offset; + subflow->map_seq =__mptcp_expand_seq (subflow->map_seq, + subflow->iasn + +TCP_SKB_CB (skb)->seq - + subflow->ssn_offset -1 );WRITE_ONCE (subflow->data_avail, true);return true; }
Greg Kroah-Hartman
maintainerPATCH 283/307 mptcp: reset rcv wnd on disconnect
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 0981f90e1a05773a4c29c6e720f5ea1e3c8f1876 ]
If the MPTCP socket fallback to TCP before the MP handshake completion, the IASN remain 0, and the rcv_wnd_sent field is not explicitly initialized, just incremented over time with the data transfer.
At disconnect time such value is not cleared. If the next connection falls back to TCP before the MP handshake completion, the data transfer will keep incrementing the receive window end sequence starting from the last value used in the previous connection: the announced window will be unrelated from the actual receiver buffer size and likely too big.
Address the issue zeroing the field at disconnect time.
--- net/mptcp/protocol.c | 1 + 1 file changed, 1 insertion(+)
net/mptcp/protocol.c +1 -0
@@ -3371,6 +3371,7 @@ static int mptcp_disconnect(struct sock/* for fallback's sake */ WRITE_ONCE (msk->ack_seq,0 ); +atomic64_set (&msk->rcv_wnd_sent,0 );WRITE_ONCE (sk->sk_shutdown,0 );sk_error_report (sk);
Greg Kroah-Hartman
maintainerPATCH 284/307 arm64: tlb: Flush walk cache when unsharing PMD tables
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zeng Heng <[email protected]>
[ Upstream commit c2ff4764e03e7a8d758352f4aceb8fe1be6ac971 ]
When huge_pmd_unshare() is called to unshare a PMD table, the tlb_unshare_pmd_ptdesc() function sets tlb->unshared_tables=true but the aarch64 tlb_flush() only checked tlb->freed_tables to determine whether to use TLBF_NONE (vae1is, invalidates walk cache) or TLBF_NOWALKCACHE (vale1is, leaf-only).
This caused the stale PMD page table entry to remain in the walk cache after unshare, potentially leading to incorrect page table walks.
Fix by including unshared_tables in the check, so that when unsharing tables, TLBF_NONE is used and the walk cache is properly invalidated.
Here is the detailed distinction between vae1is and vale1is:
| Instruction Combination | Actual Invalidation Scope | | ------------------------ | --------------------------------------------------| | `VAE1IS` + TTL=`0` | All entries at all levels (full invalidation) | | `VAE1IS` + TTL=`2` (L2) | Non-leaf at Level 0/1 + leaf at Level 2 | | `VALE1IS` + TTL=`0` | Leaf entries at all levels (non-leaf not cleared) | | `VALE1IS` + TTL=`2` (L2) | Leaf entry at Level 2 only |
--- arch/arm64/include/asm/tlb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/tlb.h +1 -1
@@ -58,7 +58,7 @@ static inline int tlb_get_level(struct mstatic inline void tlb_flush (struct mmu_gather *tlb) {struct vm_area_struct vma =TLB_FLUSH_VMA (tlb->mm,0 ); -bool last_level = !tlb->freed_tables; +bool last_level = !(tlb->freed_tables || tlb->unshared_tables);unsigned long stride =tlb_get_unmap_size (tlb);int tlb_level =tlb_get_level (tlb);
Greg Kroah-Hartman
maintainerPATCH 285/307 octeontx2-pf: avoid double free of pool->stack on AQ init failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dawei Feng <[email protected]>
[ Upstream commit 9b244c242bec48b37e82b89787afd6a4c43457e1 ]
otx2_pool_aq_init() frees pool->stack when mailbox sync or retry allocation fails, but leaves the pointer unchanged. Later, otx2_sq_aura_pool_init() unwinds the partial setup through otx2_aura_pool_free(), which frees pool->stack again. The CN20K-specific cn20k_pool_aq_init() implementation has the same bug in
its corresponding error path.
Set pool->stack to NULL immediately after the local free so the shared cleanup path does not free the same stack again while cleaning up partially initialized pool state.
The bug was first flagged by an experimental analysis tool we are developing for kernel memory-management bugs while analyzing v6.13-rc1. The tool is still under development and is not yet publicly available. Manual inspection confirms that the bug is still present in v7.1-rc3.
Runtime validation was not performed because reproducing this path requires OcteonTX2/CN20K hardware.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +2 -0
@@ -1386,11 +1386,13 @@ int otx2_pool_init(struct otx2_nic *pfvf err =otx2_sync_mbox_msg (&pfvf->mbox);if (err) {qmem_free (pfvf->dev, pool->stack); + pool->stack =NULL ;return err; } aq =otx2_mbox_alloc_msg_npa_aq_enq (&pfvf->mbox);if (!aq) {qmem_free (pfvf->dev, pool->stack); + pool->stack =NULL ;return -ENOMEM ; } }
Greg Kroah-Hartman
maintainerPATCH 286/307 mptcp: introduce the mptcp_init_skb helper
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 9a0afe0db46720ce1a009c7dac168aa0584bd732 ]
Factor out all the skb initialization step in a new helper and use it. Note that this change moves the MPTCP CB initialization
earlier: we can do such step as soon as the skb leaves the subflow socket receive queues.
Stable-dep-of: 50c2d91c5dfa ("mptcp: do not drop partial packets")
--- net/mptcp/protocol.c | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-)
net/mptcp/protocol.c +27 -23
@@ -321,7 +321,7 @@ end:mptcp_set_owner_r (skb, sk); } -static bool mptcp_rmem_schedule (struct sock *sk,struct sock *ssk,int size) +static bool mptcp_rmem_schedule (struct sock *sk,int size) {struct mptcp_sock *msk =mptcp_sk (sk);int amt, amount;
@@ -339,27 +339,11 @@ static bool mptcp_rmem_schedule(struct sreturn true; } -static bool __mptcp_move_skb (struct mptcp_sock *msk,struct sock *ssk, -struct sk_buff *skb,unsigned int offset, -size_t copy_len) +static void mptcp_init_skb (struct sock *ssk,struct sk_buff *skb,int offset, +int copy_len) { -struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk); -struct sock *sk = (struct sock *)msk; -struct sk_buff *tail; -bool has_rxtstamp; - -__skb_unlink (skb, &ssk->sk_receive_queue); - -skb_ext_reset (skb); -skb_orphan (skb); - -/* try to fetch required memory from subflow */ -if (!mptcp_rmem_schedule (sk, ssk, skb->truesize)) { -MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RCVPRUNED ); - goto drop; - } - - has_rxtstamp =TCP_SKB_CB (skb)->has_rxtstamp; +const struct mptcp_subflow_context *subflow =mptcp_subflow_ctx (ssk); +bool has_rxtstamp =TCP_SKB_CB (skb)->has_rxtstamp;/* the skb map_seq accounts for the skb offset: * mptcp_subflow_get_mapped_dsn() is based on the current tp->copied_seq
@@ -371,6 +355,25 @@ static bool __mptcp_move_skb(struct mptcMPTCP_SKB_CB (skb)->has_rxtstamp = has_rxtstamp;MPTCP_SKB_CB (skb)->cant_coalesce =0 ; +__skb_unlink (skb, &ssk->sk_receive_queue); + +skb_ext_reset (skb); +skb_dst_drop (skb); +} + +static bool __mptcp_move_skb (struct sock *sk,struct sk_buff *skb) +{ +u64 copy_len =MPTCP_SKB_CB (skb)->end_seq -MPTCP_SKB_CB (skb)->map_seq; +struct mptcp_sock *msk =mptcp_sk (sk); +struct sk_buff *tail; + +/* try to fetch required memory from subflow */ +if (!mptcp_rmem_schedule (sk, skb->truesize)) { +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_RCVPRUNED ); +mptcp_drop (sk, skb); +return false; + } +if (MPTCP_SKB_CB (skb)->map_seq == msk->ack_seq) {/* in sequence */ msk->bytes_received += copy_len;
@@ -391,7 +394,6 @@ static bool __mptcp_move_skb(struct mptc* will retransmit as needed, if needed. */ MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_DUPDATA ); -drop:mptcp_drop (sk, skb);return false; }
@@ -720,7 +722,9 @@ static bool __mptcp_move_skbs_from_subflif (tp->urg_data) done = true; -if (__mptcp_move_skb (msk, ssk, skb, offset, len)) +mptcp_init_skb (ssk, skb, offset, len); +skb_orphan (skb); +if (__mptcp_move_skb (sk, skb)) moved += len; seq += len;
t t;
- if (!chan || !chan->cl) + if (!chan || !chan->cl || mssg == MBOX_NO_MSG)
return -EINVAL;
t = add_to_rbuf(chan, mssg);
@@ -319,7 +319,7 @@ static int __mbox_bind_client(struct mbo
scoped_guard(spinlock_irqsave, &chan->lock) {
chan->msg_free = 0; chan->msg_count = 0;
- chan->active_req = NULL;
+ chan->active_req = MBOX_NO_MSG;
chan->cl = cl; init_completion(&chan->tx_complete);
@@ -477,7 +477,7 @@ void mbox_free_channel(struct mbox_chan
/* The queued TX requests are simply aborted, no callbacks are made */ scoped_guard(spinlock_irqsave, &chan->lock) {
chan->cl = NULL;
- chan->active_req = NULL;
+ chan->active_req = MBOX_NO_MSG;
if (chan->txdone_method == TXDONE_BY_ACK)
chan->txdone_method = TXDONE_BY_POLL;
}
@@ -531,6 +531,7 @@ int mbox_controller_register(struct mbox
chan->cl = NULL;
chan->mbox = mbox;
+ chan->active_req = MBOX_NO_MSG;
chan->txdone_method = txdone;
spin_lock_init(&chan->lock);
}
drivers/mailbox/tegra-hsp.c +1 -1
@@ -497,7 +497,7 @@ static int tegra_hsp_mailbox_flush(strucmbox_chan_txdone (chan,0 );/* Wait until channel is empty */ -if (chan->active_req !=NULL ) +if (chan->active_req !=MBOX_NO_MSG )continue ;return 0 ;
include/linux/mailbox_controller.h +3 -0
@@ -11,6 +11,9 @@struct mbox_chan ; +/* Sentinel value distinguishing "no active request" from "NULL message data" */ +#define MBOX_NO_MSG ((void *)-1) +/** * struct mbox_chan_ops - methods to control mailbox channels * @send_data: The API asks the MBOX controller driver, in atomic
Greg Kroah-Hartman
maintainerPATCH 287/307 mptcp: handle first subflow closing consistently
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 0eeb372deebce6c25b9afc09e35d6c75a744299a ]
Currently, as soon as the PM closes a subflow, the msk stops accepting data from it, even if the TCP socket could be still formally open in the incoming direction, with the notable exception of the first subflow.
The root cause of such behavior is that code currently piggy back two separate semantic on the subflow->disposable bit: the subflow context must be released and that the subflow must stop accepting incoming data.
The first subflow is never disposed, so it also never stop accepting incoming data. Use a separate bit to mark the latter status and set such bit in __mptcp_close_ssk() for all subflows.
Beyond making per subflow behaviour more consistent this will also simplify the next patch.
Stable-dep-of: 50c2d91c5dfa ("mptcp: do not drop partial packets")
--- net/mptcp/protocol.c | 14 +++++++++----- net/mptcp/protocol.h | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-)
net/mptcp/protocol.c +9 -5
@@ -877,10 +877,10 @@ void mptcp_data_ready(struct sock *sk, sint sk_rbuf, ssk_rbuf;/* The peer can send data while we are shutting down this -* subflow at msk destruction time, but we must avoid enqueuing +* subflow at subflow destruction time, but we must avoid enqueuing * more data to the msk receive queue */ -if (unlikely (subflow->disposable)) +if (unlikely (subflow->closing))return ; ssk_rbuf =READ_ONCE (ssk->sk_rcvbuf);
@@ -2514,6 +2514,13 @@ static void __mptcp_close_ssk(struct socstruct mptcp_sock *msk =mptcp_sk (sk);bool dispose_it, need_push = false; +/* Do not pass RX data to the msk, even if the subflow socket is not +* going to be freed (i.e. even for the first subflow on graceful +* subflow close. +*/ +lock_sock_nested (ssk,SINGLE_DEPTH_NESTING ); + subflow->closing =1 ; +/* If the first subflow moved to a close state before accept, e.g. due * to an incoming reset or listener shutdown, the subflow socket is * already deleted by inet_child_forget() and the mptcp socket can't
@@ -2524,7 +2531,6 @@ static void __mptcp_close_ssk(struct soc/* ensure later check in mptcp_worker() will dispose the msk */ sock_set_flag (sk,SOCK_DEAD );mptcp_set_close_tout (sk, tcp_jiffies32 - (mptcp_close_timeout (sk) +1 )); -lock_sock_nested (ssk,SINGLE_DEPTH_NESTING );mptcp_subflow_drop_ctx (ssk); goto out_release; }
@@ -2533,8 +2539,6 @@ static void __mptcp_close_ssk(struct socif (dispose_it)list_del (&subflow->node); -lock_sock_nested (ssk,SINGLE_DEPTH_NESTING ); -if (subflow->send_fastclose && ssk->sk_state !=TCP_CLOSE )tcp_set_state (ssk,TCP_CLOSE );
net/mptcp/protocol.h +2 -1
@@ -537,12 +537,13 @@ struct mptcp_subflow_context { send_infinite_map : 1, remote_key_valid : 1, /* received the peer key from */ disposable : 1, /* ctx can be free at ulp release time */ + closing : 1, /* must not pass rx data to msk anymore */ stale : 1, /* unable to snd/rcv data, do not use for xmit */ valid_csum_seen : 1, /* at least one csum validated */ is_mptfo : 1, /* subflow is doing TFO */ close_event_done : 1, /* has done the post-closed part */ mpc_drop : 1, /* the MPC option has been dropped in a rtx */ - __unused : 9; + __unused : 8;bool data_avail;bool scheduled;bool pm_listener;/* a listener managed by the kernel PM? */
Greg Kroah-Hartman
maintainerPATCH 288/307 mptcp: do not drop partial packets
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shardul Bankar <[email protected]>
[ Upstream commit 50c2d91c5dfa0e465826ec1f8dbad9cdc254bd85 ]
When a packet arrives with map_seq < ack_seq < end_seq, the beginning of the packet has already been acknowledged but the end contains new data. Currently the entire packet is dropped as "old data," forcing the sender to retransmit.
Instead, skip the already-acked bytes by adjusting the skb offset and enqueue only the new portion. Update bytes_received and ack_seq to reflect the new data consumed.
A previous attempt at this fix has been sent by Paolo Abeni [1], but had issues [2]: it also added a zero-window check and changed rcv_wnd_sent initialization, which caused test regressions. This version addresses only the partial packet handling without modifying receive window accounting.
--- net/mptcp/protocol.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
net/mptcp/protocol.c +19 -5
@@ -390,12 +390,26 @@ static bool __mptcp_move_skb(struct sockreturn false; } -/* old data, keep it simple and drop the whole pkt, sender -* will retransmit as needed, if needed. +/* Completely old data? */ +if (!after64 (MPTCP_SKB_CB (skb)->end_seq, msk->ack_seq)) { +MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_DUPDATA ); +mptcp_drop (sk, skb); +return false; + } + +/* Partial packet: map_seq < ack_seq < end_seq. +* Skip the already-acked bytes and enqueue the new data. */ -MPTCP_INC_STATS (sock_net (sk),MPTCP_MIB_DUPDATA ); -mptcp_drop (sk, skb); -return false; + copy_len =MPTCP_SKB_CB (skb)->end_seq - msk->ack_seq; +MPTCP_SKB_CB (skb)->offset += msk->ack_seq -MPTCP_SKB_CB (skb)->map_seq; +MPTCP_SKB_CB (skb)->map_seq += msk->ack_seq - +MPTCP_SKB_CB (skb)->map_seq; + msk->bytes_received += copy_len; +WRITE_ONCE (msk->ack_seq, msk->ack_seq + copy_len); + +skb_set_owner_r (skb, sk); +__skb_queue_tail (&sk->sk_receive_queue, skb); +return true; }static void mptcp_stop_rtx_timer (struct sock *sk)
Greg Kroah-Hartman
maintainerPATCH 289/307 mm/damon/sysfs-schemes: delete tried region in regions_rmdirs()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeongJae Park <[email protected]>
[ Upstream commit 441f92f7d386b85bad16de49db95a307cba048a2 ]
DAMON sysfs maintains the DAMOS tried region directory objects via a linked list. When the user requests refresh of the directories, DAMON sysfs removes all the region directories first, and then generate updated regions directory on the empty space. The removal function (damon_sysfs_scheme_regions_rm_dirs()) only puts the kobj objects. Deletion of the container region object from the linked list is done inside the kobj release callback function.
If somehow the callback invocation is delayed, the list will contain regions list that gonna be freed. If the updated region directories creation is started in this situation, the list can be corrupted and use-after-free can happen.
Because the kobj objects are managed by only DAMON sysfs, the issue cannot happen in normal situation. But, such delays can be made on kernels that built with CONFIG_DEBUG_KOBJECT_RELEASE. On the kernel, the issue can indeed be reproduced like below.
# damo start --damos_action stat
# cd /sys/kernel/mm/damon/admin/kdamonds/0/
# for i in {1..10}; do echo update_schemes_tried_regions > state; done
# dmesg | grep underflow
[ 89.296152] refcount_t: underflow; use-after-free.Fix the issue by removing the region object from the list when decrementing the reference count.
Also update damos_sysfs_populate_region_dir() to add the region object to the list only after the kobject_init_and_add() is success, so that fail of kobject_init_and_add() is not leaving the deallocated object on the list.
The issue was discovered [1] by Sashiko.
--- mm/damon/sysfs-schemes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
mm/damon/sysfs-schemes.c +4 -4
@@ -79,7 +79,6 @@ static void damon_sysfs_scheme_region_restruct damon_sysfs_scheme_region *region =container_of (kobj, struct damon_sysfs_scheme_region, kobj); -list_del (®ion->list);kfree (region); }
@@ -197,7 +196,7 @@ static void damon_sysfs_scheme_regions_rstruct damon_sysfs_scheme_region *r, *next;list_for_each_entry_safe (r, next, ®ions->regions_list, list) { -/* release function deletes it from the list */ +list_del (&r->list);kobject_put (&r->kobj); regions->nr_regions--; }
@@ -2186,14 +2185,15 @@ static int damon_sysfs_before_damos_appl region =damon_sysfs_scheme_region_alloc (r);if (!region)return 0 ; -list_add_tail (®ion->list, &sysfs_regions->regions_list); - sysfs_regions->nr_regions++;if (kobject_init_and_add (®ion->kobj, &damon_sysfs_scheme_region_ktype, &sysfs_regions->kobj,"%d" , damon_sysfs_schemes_region_idx++)) {kobject_put (®ion->kobj); +return 0 ; } +list_add_tail (®ion->list, &sysfs_regions->regions_list); + sysfs_regions->nr_regions++;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 290/307 iio: chemical: scd30: Use guard(mutex) to allow early returns
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Cameron <[email protected]>
[ Upstream commit 5feb5532870fbced5d6f450b8061a33f461b88ca ]
Auto cleanup based release of the lock allows for simpler code flow in a few functions with large multiplexing style switch statements and no common operations following the switch.
Stable-dep-of: 5aba4f94b225 ("iio: chemical: scd30: fix division by zero in write_raw")
--- drivers/iio/chemical/scd30_core.c | 63 ++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 35 deletions(-)
drivers/iio/chemical/scd30_core.c +28 -35
@@ -5,6 +5,7 @@* Copyright (c) 2020 Tomasz Duszynski <[email protected]> */ #include <linux/bits.h> +#include <linux/cleanup.h> #include <linux/completion.h> #include <linux/delay.h> #include <linux/device.h>
@@ -198,112 +199,104 @@ static int scd30_read_raw(struct iio_dev int *val, int *val2, long mask) { struct scd30_state *state = iio_priv(indio_dev); -int ret = -EINVAL ; +int ret;u16 tmp; -mutex_lock (&state->lock); +guard (mutex)(&state->lock);switch (mask) {case IIO_CHAN_INFO_RAW :case IIO_CHAN_INFO_PROCESSED :if (chan->output) { *val = state->pressure_comp; - ret =IIO_VAL_INT ; -break ; +return IIO_VAL_INT ; } ret =iio_device_claim_direct_mode (indio_dev);if (ret) -break ; +return ret; ret =scd30_read (state);if (ret) {iio_device_release_direct_mode (indio_dev); -break ; +return ret; } *val = state->meas[chan->address];iio_device_release_direct_mode (indio_dev); - ret =IIO_VAL_INT ; -break ; +return IIO_VAL_INT ;case IIO_CHAN_INFO_SCALE : *val =0 ; *val2 =1 ; - ret =IIO_VAL_INT_PLUS_MICRO ; -break ; +return IIO_VAL_INT_PLUS_MICRO ;case IIO_CHAN_INFO_SAMP_FREQ : ret =scd30_command_read (state,CMD_MEAS_INTERVAL , &tmp);if (ret) -break ; +return ret; *val =0 ; *val2 =1000000000 / tmp; - ret =IIO_VAL_INT_PLUS_NANO ; -break ; +return IIO_VAL_INT_PLUS_NANO ;case IIO_CHAN_INFO_CALIBBIAS : ret =scd30_command_read (state,CMD_TEMP_OFFSET , &tmp);if (ret) -break ; +return ret; *val = tmp; - ret =IIO_VAL_INT ; -break ; +return IIO_VAL_INT ; +default : +return -EINVAL ; } -mutex_unlock (&state->lock); - -return ret; }static int scd30_write_raw (struct iio_dev *indio_dev,struct iio_chan_spec const *chan,int val,int val2,long mask) {struct scd30_state *state =iio_priv (indio_dev); -int ret = -EINVAL ; +int ret; -mutex_lock (&state->lock); +guard (mutex)(&state->lock);switch (mask) {case IIO_CHAN_INFO_SAMP_FREQ :if (val) -break ; +return -EINVAL ; val =1000000000 / val2;if (val <SCD30_MEAS_INTERVAL_MIN_S || val >SCD30_MEAS_INTERVAL_MAX_S ) -break ; +return -EINVAL ; ret =scd30_command_write (state,CMD_MEAS_INTERVAL , val);if (ret) -break ; +return ret; state->meas_interval = val; -break ; +return 0 ;case IIO_CHAN_INFO_RAW :switch (chan->type) {case IIO_PRESSURE :if (val <SCD30_PRESSURE_COMP_MIN_MBAR || val >SCD30_PRESSURE_COMP_MAX_MBAR ) -break ; +return -EINVAL ; ret =scd30_command_write (state,CMD_START_MEAS , val);if (ret) -break ; +return ret; state->pressure_comp = val; -break ; +return 0 ;default : -break ; +return -EINVAL ; } -break ;case IIO_CHAN_INFO_CALIBBIAS :if (val <0 || val >SCD30_TEMP_OFFSET_MAX ) -break ; +return -EINVAL ;/* * Manufacturer does not explicitly specify min/max sensible * values hence check is omitted for simplicity. */ - ret =scd30_command_write (state,CMD_TEMP_OFFSET /10 , val); +return scd30_command_write (state,CMD_TEMP_OFFSET /10 , val); +default : +return -EINVAL ; } -mutex_unlock (&state->lock); - -return ret; } static int scd30_write_raw_get_fmt(struct iio_dev *indio_dev, struct iio_chan_spec const *chan,
Greg Kroah-Hartman
maintainerPATCH 291/307 iio: chemical: scd30: fix division by zero in write_raw
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoniu Miclaus <[email protected]>
[ Upstream commit 5aba4f94b225617a55fed442a70329b2ee19c0a5 ]
Add a zero check for val2 before using it as a divisor when setting the sampling frequency. A user writing a zero fractional part to the sampling_frequency sysfs attribute triggers a division by zero in the kernel.
--- drivers/iio/chemical/scd30_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/scd30_core.c +1 -1
@@ -257,7 +257,7 @@ static int scd30_write_raw(struct iio_deguard (mutex)(&state->lock);switch (mask) {case IIO_CHAN_INFO_SAMP_FREQ : -if (val) +if (val || !val2)return -EINVAL ; val =1000000000 / val2;
Greg Kroah-Hartman
maintainerPATCH 292/307 iio: dac: ad5686: fix ref bit initialization for single-channel parts
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rodrigo Alencar <[email protected]>
[ Upstream commit ecae2ae606d493cf11457946436335bd0e726663 ]
The reference bit position was ignored when writing the register at the probe() function (!!val was used). When such bit is 1, internal voltage reference is disabled so that an external one can be used. For multi-channel devices, bit 0 of the Internal Reference Setup command behaves the same way, so AD5686_REF_BIT_MSK is created. The issue exists since support for single-channel devices were first introduced.
--- drivers/iio/dac/ad5686.c | 6 +++--- drivers/iio/dac/ad5686.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/iio/dac/ad5686.c +3 -3
@@ -528,7 +528,7 @@ int ad5686_probe(struct device *dev,break ;case AD5686_REGMAP : cmd =AD5686_CMD_INTERNAL_REFER_SETUP ; - ref_bit_msk =0 ; + ref_bit_msk =AD5686_REF_BIT_MSK ;break ;case AD5693_REGMAP : cmd =AD5686_CMD_CONTROL_REG ;
@@ -540,9 +540,9 @@ int ad5686_probe(struct device *dev, goto error_disable_reg; } - val = (voltage_uv | ref_bit_msk); + val = voltage_uv ? ref_bit_msk :0 ; - ret = st->write (st, cmd,0 , !!val); + ret = st->write (st, cmd,0 , val);if (ret) goto error_disable_reg;
drivers/iio/dac/ad5686.h +1 -0
@@ -46,6 +46,7 @@#define AD5310_REF_BIT_MSK BIT(8)#define AD5683_REF_BIT_MSK BIT(12) +#define AD5686_REF_BIT_MSK BIT(0)#define AD5693_REF_BIT_MSK BIT(12)/**
Greg Kroah-Hartman
maintainerPATCH 293/307 ALSA: firewire-motu: Protect register DSP event queue positions
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit 98fb1c1bb11e29eb609b7200a25e136e05aa4498 ]
The register DSP event queue is updated under parser->lock, but snd_motu_register_dsp_message_parser_count_event() reads pull_pos and push_pos without the lock. snd_motu_register_dsp_message_parser_copy_event() also reads both queue positions before taking the lock.
Protect these accesses with parser->lock as well. This keeps the hwdep poll/read path consistent with the producer side and with the cached meter/parameter accessors.
--- sound/firewire/motu/motu-register-dsp-message-parser.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
sound/firewire/motu/motu-register-dsp-message-parser.c +7 -7
@@ -393,6 +393,8 @@ unsigned int snd_motu_register_dsp_messa {struct msg_parser *parser = motu->message_parser; +guard (spinlock_irqsave)(&parser->lock); +if (parser->pull_pos > parser->push_pos)return EVENT_QUEUE_SIZE - parser->pull_pos + parser->push_pos;else
@@ -402,14 +404,14 @@ unsigned int snd_motu_register_dsp_messabool snd_motu_register_dsp_message_parser_copy_event (struct snd_motu *motu,u32 *event) {struct msg_parser *parser = motu->message_parser; -unsigned int pos = parser->pull_pos; -unsigned long flags; +unsigned int pos; -if (pos == parser->push_pos) -return false; +guard (spinlock_irqsave)(&parser->lock); -spin_lock_irqsave (&parser->lock, flags); +if (parser->pull_pos == parser->push_pos) +return false; + pos = parser->pull_pos; *event = parser->event_queue[pos]; ++pos;
@@ -417,7 +419,5 @@ bool snd_motu_register_dsp_message_parse pos =0 ; parser->pull_pos = pos; -spin_unlock_irqrestore (&parser->lock, flags); -return true; }
Greg Kroah-Hartman
maintainerPATCH 294/307 usb: dwc3: xilinx: fix error handling in zynqmp init error paths
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Radhey Shyam Pandey <[email protected]>
[ Upstream commit c1a0ecbf32c4b397353204e2ec94c5bb9f3300ed ]
Fix error handling and resource cleanup i.e remove invalid phy_exit() after failed phy_init(), route failures through proper cleanup paths and return 0 explicitly on success.
--- drivers/usb/dwc3/dwc3-xilinx.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/usb/dwc3/dwc3-xilinx.c +14 -12
@@ -170,15 +170,13 @@ static int dwc3_xlnx_init_zynqmp(struct } ret =phy_init (priv_data->usb3_phy); -if (ret <0 ) { -phy_exit (priv_data->usb3_phy); +if (ret <0 ) goto err; - } ret =reset_control_deassert (apbrst);if (ret <0 ) {dev_err (dev,"Failed to release APB reset\n" ); - goto err; + goto err_phy_exit; }/* Set PIPE Power Present signal in FPD Power Present Register*/
@@ -190,27 +188,25 @@ static int dwc3_xlnx_init_zynqmp(struct ret =reset_control_deassert (crst);if (ret <0 ) {dev_err (dev,"Failed to release core reset\n" ); - goto err; + goto err_phy_exit; } ret =reset_control_deassert (hibrst);if (ret <0 ) {dev_err (dev,"Failed to release hibernation reset\n" ); - goto err; + goto err_phy_exit; } ret =phy_power_on (priv_data->usb3_phy); -if (ret <0 ) { -phy_exit (priv_data->usb3_phy); - goto err; - } +if (ret <0 ) + goto err_phy_exit; skip_usb3_phy:/* ulpi reset via gpio-modepin or gpio-framework driver */ reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (reset_gpio)) { -return dev_err_probe (dev,PTR_ERR (reset_gpio), -"Failed to request reset GPIO\n" ); + ret =PTR_ERR (reset_gpio); + goto err_phy_power_off; }if (reset_gpio) {
@@ -230,6 +226,12 @@ skip_usb3_phy:writel (reg, priv_data->regs +XLNX_USB_TRAFFIC_ROUTE_CONFIG ); } +return 0 ; + +err_phy_power_off: +phy_power_off (priv_data->usb3_phy); +err_phy_exit: +phy_exit (priv_data->usb3_phy); err:return ret; }
Greg Kroah-Hartman
maintainerPATCH 295/307 usb: musb: omap2430: Fix use-after-free in omap2430_probe()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit e194ce048f5a6c549b3a23a8c568c6470f40f772 ]
In omap2430_probe(), of_node_put(np) is called prematurely before the last access to np, leading to a use-after-free if the node's reference count drops to zero. Move the of_node_put() calls after the last use of np in both the success and error paths.
--- drivers/usb/musb/omap2430.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/musb/omap2430.c +2 -1
@@ -340,7 +340,6 @@ static int omap2430_probe(struct platfor }else {device_set_of_node_from_dev (&musb->dev, &pdev->dev); } -of_node_put (np); glue->dev = &pdev->dev; glue->musb = musb;
@@ -458,6 +457,7 @@ static int omap2430_probe(struct platfordev_err (&pdev->dev,"failed to register musb device\n" ); goto err3; } +of_node_put (np);return 0 ;
@@ -467,6 +467,7 @@ err_put_control_otghs:if (!IS_ERR (glue->control_otghs))put_device (glue->control_otghs); err2: +of_node_put (np);platform_device_put (musb); err0:
Greg Kroah-Hartman
maintainerPATCH 296/307 usb: typec: ucsi: Check if power role change actually happened before handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myrrh Periwinkle <[email protected]>
[ Upstream commit b80e7d34c7ea6a564525119d6138fbb577a23dba ]
The CrOS EC may send a connector status change event with the power direction changed flag set even if the power direction hasn't actually changed after initiating a SET_PDR command internally [1]. In practice this happens on every system suspend due to other changes performed by the EC [2][3][4], causing suspend to fail.
Fix this by checking if the power role change actually happened before handling it.
[1]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/subsys/pd_controller/pdc_power_mgmt.c;l=1689;drc=2d5a1cffce4e5ac8a39442cb3b764d2d5e1cf794
[2]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/subsys/pd_controller/pdc_power_mgmt.c;l=3923;drc=2d5a1cffce4e5ac8a39442cb3b764d2d5e1cf794
[3]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/subsys/pd_controller/pdc_power_mgmt.c;l=5094;drc=2d5a1cffce4e5ac8a39442cb3b764d2d5e1cf794
[4]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/subsys/pd_controller/pdc_power_mgmt.c;l=2229;drc=2d5a1cffce4e5ac8a39442cb3b764d2d5e1cf794
--- drivers/usb/typec/ucsi/ucsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +4 -2
@@ -1201,7 +1201,7 @@ static void ucsi_handle_connector_change struct ucsi_connector *con = container_of(work, struct ucsi_connector, work);struct ucsi *ucsi = con->ucsi; -enum typec_role role; +enum typec_role role, prev_role;u64 command;int ret;
@@ -1211,6 +1211,8 @@ static void ucsi_handle_connector_changedev_err_once (ucsi->dev,"%s entered without EVENT_PENDING\n" , __func__); + prev_role = !!(con->status.flags &UCSI_CONSTAT_PWR_DIR ); + command =UCSI_GET_CONNECTOR_STATUS |UCSI_CONNECTOR_NUMBER (con->num); ret = ucsi_send_command_common(ucsi, command, &con->status,
@@ -1229,7 +1231,7 @@ static void ucsi_handle_connector_change role = !!(con->status.flags &UCSI_CONSTAT_PWR_DIR ); -if (con->status.change &UCSI_CONSTAT_POWER_DIR_CHANGE ) { +if ((con->status.change &UCSI_CONSTAT_POWER_DIR_CHANGE ) && role != prev_role) {typec_set_pwr_role (con->port, role);ucsi_port_psy_changed (con);
Greg Kroah-Hartman
maintainerPATCH 297/307 thunderbolt: property: Cap recursion depth in __tb_property_parse_dir()
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 928abe19fbf0127003abcb1ea69cabc1c897d0ab ]
A DIRECTORY entry's value field is used as the dir_offset for a recursive call into __tb_property_parse_dir() with no depth counter. A crafted peer that chains DIRECTORY entries into a back-reference loop drives the parser until the kernel stack is exhausted and the guard page fires. Any untrusted XDomain peer (cable, dock, in-line inspector, adjacent host) that reaches the PROPERTIES_REQUEST control-plane exchange can trigger this without authentication.
Thread a depth counter through tb_property_parse() and __tb_property_parse_dir(), and reject blocks that exceed TB_PROPERTY_MAX_DEPTH = 8. That is comfortably larger than any observed legitimate XDomain layout.
Operators who do not need XDomain host-to-host discovery can disable the path entirely with thunderbolt.xdomain=0 on the kernel command line.
--- drivers/thunderbolt/property.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/thunderbolt/property.c +12 -6
@@ -35,10 +35,11 @@ struct tb_property_dir_entry { };#define TB_PROPERTY_ROOTDIR_MAGIC 0x55584401 +#define TB_PROPERTY_MAX_DEPTH 8static struct tb_property_dir *__tb_property_parse_dir (const u32 *block,size_t block_len,unsigned int dir_offset,size_t dir_len, -bool is_root); +bool is_root,unsigned int depth);static inline void parse_dwdata (void *dst,const void *src,size_t dwords) {
@@ -97,7 +98,8 @@ tb_property_alloc(const char *key, enum }static struct tb_property *tb_property_parse (const u32 *block,size_t block_len, -const struct tb_property_entry *entry) +const struct tb_property_entry *entry, +unsigned int depth) {char key[TB_PROPERTY_KEY_SIZE +1 ];struct tb_property *property;
@@ -118,7 +120,7 @@ static struct tb_property *tb_property_pswitch (property->type) {case TB_PROPERTY_TYPE_DIRECTORY : dir =__tb_property_parse_dir (block, block_len, entry->value, - entry->length, false); + entry->length, false, depth +1 );if (!dir) {kfree (property);return NULL ;
@@ -163,13 +165,17 @@ static struct tb_property *tb_property_p }static struct tb_property_dir *__tb_property_parse_dir (const u32 *block, -size_t block_len,unsigned int dir_offset,size_t dir_len,bool is_root) +size_t block_len,unsigned int dir_offset,size_t dir_len,bool is_root, +unsigned int depth) {const struct tb_property_entry *entries;size_t i, content_len, nentries;unsigned int content_offset;struct tb_property_dir *dir; +if (depth >TB_PROPERTY_MAX_DEPTH ) +return NULL ; + dir =kzalloc (sizeof (*dir),GFP_KERNEL );if (!dir)return NULL ;
@@ -200,7 +206,7 @@ static struct tb_property_dir *__tb_propfor (i =0 ; i < nentries; i++) {struct tb_property *property; - property =tb_property_parse (block, block_len, &entries[i]); + property =tb_property_parse (block, block_len, &entries[i], depth);if (!property) {tb_property_free_dir (dir);return NULL ;
@@ -237,7 +243,7 @@ struct tb_property_dir *tb_property_parsreturn NULL ;return __tb_property_parse_dir (block, block_len,0 , rootdir->length, - true); + true,0 ); }/**
Greg Kroah-Hartman
maintainerPATCH 298/307 scsi: target: iscsi: Fix CRC overread and double-free in iscsit_handle_text_cmd()
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 778c2ab142c625a8a8afa570e0f9b7873f445d99 ]
Two latent bugs in the Text-phase handler, both present since the original LIO integration in commit e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1"):
1) DataDigest CRC buffer overread (4 bytes past text_in).
text_in is kzalloc()'d at ALIGN(payload_length, 4). rx_size is then incremented by ISCSI_CRC_LEN to make room for the received DataDigest in the iovec, but the same (now-bumped) rx_size is passed as the buffer length to iscsit_crc_buf():
if (conn->conn_ops->DataDigest) {
...
rx_size += ISCSI_CRC_LEN;
}
...
if (conn->conn_ops->DataDigest) {
data_crc = iscsit_crc_buf(text_in, rx_size, 0, NULL); iscsit_crc_buf() walks rx_size bytes of text_in with crc32c(), so when DataDigest is negotiated it reads 4 bytes past the end of the text_in allocation. KASAN reproduces this directly on the unpatched mainline tree as slab-out-of-bounds in crc32c() called from the Text PDU path. The OOB bytes feed crc32c() and are then compared against the initiator-supplied checksum, so the value does not flow back to the attacker, but the kernel does read past the buffer on every Text PDU with DataDigest=CRC32C.
Fix by passing the actual padded payload length (ALIGN(payload_length, 4)) that was used for the kzalloc().
2) Stale cmd->text_in_ptr re-free (double-free) on ERL>0 bad DataDigest drop.
On DataDigest mismatch with ErrorRecoveryLevel > 0 the handler silently drops the PDU and lets the initiator plug the CmdSN gap:
kfree(text_in);
return 0; cmd->text_in_ptr still points at the freed buffer. The next Text Request on the same ITT re-enters iscsit_setup_text_cmd(), which unconditionally does
kfree(cmd->text_in_ptr);
cmd->text_in_ptr = NULL; freeing the same pointer a second time. Session teardown via iscsit_release_cmd() has the same shape and hits the same double-free if the connection is dropped before a second Text Request arrives.
On an unmodified mainline tree the bug-1 CRC overread fires first on the initial valid Text Request and perturbs the subsequent state, so #4 was isolated by building a kernel with only the bug-1 hunk of this patch applied plus temporary printk() observability around the three relevant kfree() sites. The observability prints are not part of this patch. On that build, a three-PDU Text Request sequence after login produces two back-to-back splats:
BUG: KASAN: double-free in iscsit_setup_text_cmd+0x??
BUG: KASAN: double-free in iscsit_release_cmd+0x?? showing the same pointer freed in the ERL>0 drop path and again in iscsit_setup_text_cmd() (next Text Request on the same ITT) and once more in iscsit_release_cmd() (session teardown). On distro kernels with CONFIG_SLAB_FREELIST_HARDENED=y (default) the double-free becomes a remote kernel BUG(); on non-hardened kernels it corrupts the slab freelist.
Fix by clearing cmd->text_in_ptr after the kfree() in the ERL>0 drop path. With both hunks applied #4 is directly observable on the stock tree without observability printks; fixing bug-1 alone would mask #4 less, not more, so the hunks are submitted together.
Both fixes are one-liners. The Text PDU state machine is unchanged and the wire protocol is unaffected.
--- drivers/target/iscsi/iscsi_target.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/target/iscsi/iscsi_target.c +4 -2
@@ -2329,8 +2329,9 @@ iscsit_handle_text_cmd(struct iscsit_conif (conn->conn_ops->DataDigest) {iscsit_do_crypto_hash_buf (conn->conn_rx_hash, - text_in, rx_size,0 ,NULL , - &data_crc); + text_in, +ALIGN (payload_length,4 ), +0 ,NULL , &data_crc);if (checksum != data_crc) { pr_err("Text data CRC32C DataDigest"
@@ -2350,6 +2351,7 @@ iscsit_handle_text_cmd(struct iscsit_con" Command CmdSN: 0x%08x due to" " DataCRC error.\n", hdr->cmdsn);kfree (text_in); + cmd->text_in_ptr =NULL ;return 0 ; } }else {
Greg Kroah-Hartman
maintainerPATCH 299/307 usb: typec: ucsi: Dont update power_supply on power role change if not connected
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myrrh Periwinkle <[email protected]>
[ Upstream commit d98d413ca65d0790a8f3695d0a5845538958ab84 ]
We only need to update the power_supply on power role change if the port is connected, because otherwise the online status should be the same for both cases.
[ This is documentation for an already-completed backport. The change is described clearly.
"translated upstream UCSI_CONSTAT(con, CONNECTED) accessor macro to in-tree idiom con->status.flags & UCSI_CONSTAT_CONNECTED" ]
--- drivers/usb/typec/ucsi/ucsi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +6 -1
@@ -1233,7 +1233,12 @@ static void ucsi_handle_connector_changeif ((con->status.change &UCSI_CONSTAT_POWER_DIR_CHANGE ) && role != prev_role) {typec_set_pwr_role (con->port, role); -ucsi_port_psy_changed (con); + +/* Some power_supply properties vary depending on the power direction when +* connected +*/ +if (con->status.flags &UCSI_CONSTAT_CONNECTED ) +ucsi_port_psy_changed (con);/* Complete pending power role swap */ if (!completion_done (&con->complete))
Greg Kroah-Hartman
maintainerPATCH 300/307 x86/alternatives: Rename apply_relocation() to text_poke_apply_relocation()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ingo Molnar <[email protected]>
[ Upstream commit 023f42dd59203be8ad2fc0574af32d3b4ad041ec ]
Join the text_poke_*() API namespace.
Stable-dep-of: a17dc12bfed8 ("x86/ftrace: Relocate %rip-relative percpu refs in dynamic trampolines")
--- arch/x86/include/asm/text-patching.h | 2 +- arch/x86/kernel/alternative.c | 6 +++--- arch/x86/kernel/callthunks.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
arch/x86/include/asm/text-patching.h +1 -1
@@ -15,7 +15,7 @@extern void text_poke_early (void *addr,const void *opcode,size_t len); -extern void apply_relocation (u8 *buf,const u8 *const instr,size_t instrlen,u8 *repl,size_t repl_len); +extern void text_poke_apply_relocation (u8 *buf,const u8 *const instr,size_t instrlen,u8 *repl,size_t repl_len);/* * Clear and restore the kernel write-protection flag on the local CPU.
arch/x86/kernel/alternative.c +3 -3
@@ -502,7 +502,7 @@ static void __apply_relocation(u8 *buf, } } -void apply_relocation (u8 *buf,const u8 *const instr,size_t instrlen,u8 *repl,size_t repl_len) +void text_poke_apply_relocation (u8 *buf,const u8 *const instr,size_t instrlen,u8 *repl,size_t repl_len) {__apply_relocation (buf, instr, instrlen, repl, repl_len);optimize_nops (instr, buf, instrlen);
@@ -658,7 +658,7 @@ void __init_or_module noinline apply_altfor (; insn_buff_sz < a->instrlen; insn_buff_sz++) insn_buff[insn_buff_sz] =0x90 ; -apply_relocation (insn_buff, instr, a->instrlen, replacement, a->replacementlen); +text_poke_apply_relocation (insn_buff, instr, a->instrlen, replacement, a->replacementlen);DUMP_BYTES (ALT , instr, a->instrlen,"%px: old_insn: " , instr);DUMP_BYTES (ALT , replacement, a->replacementlen,"%px: rpl_insn: " , replacement);
@@ -1865,7 +1865,7 @@ __visible noinline void __init __alt_rel static noinline void __init alt_reloc_selftest(void) {/* -* Tests apply_relocation(). +* Tests text_poke_apply_relocation(). * * This has a relative immediate (CALL) in a place other than the first * instruction and additionally on x86_64 we get a RIP-relative LEA:
arch/x86/kernel/callthunks.c +3 -3
@@ -180,7 +180,7 @@ static void *patch_dest(void *dest, boolu8 *pad = dest - tsize;memcpy (insn_buff, skl_call_thunk_template, tsize); -apply_relocation (insn_buff, pad, tsize, skl_call_thunk_template, tsize); +text_poke_apply_relocation (insn_buff, pad, tsize, skl_call_thunk_template, tsize);/* Already patched? */ if (!bcmp (pad, insn_buff, tsize))
@@ -302,7 +302,7 @@ static bool is_callthunk(void *addr) pad = (void *)(dest - tmpl_size);memcpy (insn_buff, skl_call_thunk_template, tmpl_size); -apply_relocation (insn_buff, pad, tmpl_size, skl_call_thunk_template, tmpl_size); +text_poke_apply_relocation (insn_buff, pad, tmpl_size, skl_call_thunk_template, tmpl_size);return !bcmp (pad, insn_buff, tmpl_size); }
@@ -320,7 +320,7 @@ int x86_call_depth_emit_accounting(u8 **return 0 ;memcpy (insn_buff, skl_call_thunk_template, tmpl_size); -apply_relocation (insn_buff, ip, tmpl_size, skl_call_thunk_template, tmpl_size); +text_poke_apply_relocation (insn_buff, ip, tmpl_size, skl_call_thunk_template, tmpl_size);memcpy (*pprog, insn_buff, tmpl_size); *pprog += tmpl_size;
Greg Kroah-Hartman
maintainerPATCH 301/307 x86/ftrace: Relocate %rip-relative percpu refs in dynamic trampolines
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexis Lothoré (eBPF Foundation) <[email protected]>
[ Upstream commit a17dc12bfed8868e6a86f3b45c16065a70641acb ]
With CONFIG_CALL_DEPTH_TRACKING enabled on an x86 retbleed-affected platform (eg: Skylake), with retbleed=stuff, registering a dynamic ftrace trampoline crashes on the first call into the traced function:
BUG: unable to handle page fault for address: ffff88817ae18880 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 4b53067 P4D 4b53067 PUD 0 Oops: Oops: 0002 [#1] SMP PTI CPU: 3 UID: 0 PID: 187 Comm: usleep Not tainted 7.0.10 #243 PREEMPT(full) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Arch Linux 1.17.0-2-2 04/01/2014 Code: 24 78 00 00 00 00 48 89 ea 48 89 54 24 20 48 8b b4 24 b8 00 00 00 48 8b bc 24 b0 00 00 00 48 89 bc 24 80 00 00 00 48 83 ef 05 <65> 48 c1 3d 1f a8 b6 02 05 48 8b 15 f6 00 00 00 4c 89 3c 24 4c 89 Call Trace: <TASK> ? find_held_lock ? exc_page_fault ? lock_release ? __x64_sys_clock_nanosleep ? lockdep_hardirqs_on_prepare ? trace_hardirqs_on __x64_sys_clock_nanosleep do_syscall_64 ? exc_page_fault ? call_depth_return_thunk entry_SYSCALL_64_after_hwframe ... Kernel panic - not syncing: Fatal exception
This small reproducer allows to easily trigger the crash:
# echo 'p __x64_sys_clock_nanosleep' > /sys/kernel/tracing/kprobe_events # echo 1 > /sys/kernel/tracing/events/kprobes/p___x64_sys_clock_nanosleep_0/enable # usleep 1
Monitoring the crash under GDB points to the exact instruction in charge of incrementing the call depth:
sarq $5, %gs:__x86_call_depth(%rip)
This instruction matches the one inserted by the ftrace_regs_caller from ftrace_64.S. This emitted code was likely working fine until the introduction of
59bec00ace28 ("x86/percpu: Introduce %rip-relative addressing to PER_CPU_VAR()"):
it has made the call depth accounting addressing relative to $rip, instead of being based on an absolute address.
As this code exact location depends on where the trampoline lives in memory, the corresponding displacement needs to be adjusted at runtime to actually correctly find the per-cpu __x86_call_depth value, otherwise the targeted address is wrong, leading to the page fault seen above.
Fix the %rip-relative displacement of the copied CALL_DEPTH_ACCOUNT instruction (from ftrace_regs_caller) by calling text_poke_apply_relocation(), as it is done for example by the x86 BPF JIT compiler through x86_call_depth_emit_accounting(). This corrects both CALL_DEPTH_ACCOUNT slots, in ftrace_caller and ftrace_regs_caller.
[ bp: Massage. ]
--- arch/x86/kernel/ftrace.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kernel/ftrace.c +7 -0
@@ -371,6 +371,13 @@ create_trampoline(struct ftrace_ops *ops }/* +* Generated trampoline may contain rIP-relative addressing which +* displacement needs to be fixed. +*/ +text_poke_apply_relocation (trampoline, trampoline, size, + (void *)start_offset, size); + +/* * The address of the ftrace_ops that is used for this trampoline * is stored at the end of the trampoline. This will be used to * load the third parameter for the callback. Basically, that
Greg Kroah-Hartman
maintainerPATCH 302/307 hwmon: (pmbus/adm1266) serialize sequencer_state debugfs read with pmbus_lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
[ Upstream commit 4e4af55aaca7f6d7673d5f9889ad0529db86a048 ]
adm1266_state_read() backs the sequencer_state debugfs entry and issues an i2c_smbus_read_word_data(client, ADM1266_READ_STATE) against the device without taking pmbus_lock. pmbus_core holds pmbus_lock around its own multi-transaction sequences (notably the "set PAGE, then read paged register" pattern used by hwmon attributes), so an unlocked debugfs reader can land between a PAGE write and the subsequent paged read in another thread. READ_STATE itself is not paged, so it cannot corrupt PAGE in flight, but the same defensive serialisation that applies to the GPIO accessors applies here: any direct device access from outside pmbus_core should be ordered with respect to pmbus_core's own.
Take pmbus_lock at the top of adm1266_state_read() via the scope-based guard().
--- drivers/hwmon/pmbus/adm1266.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwmon/pmbus/adm1266.c +5 -0
@@ -328,7 +328,12 @@ static int adm1266_state_read(struct seqstruct i2c_client *client =to_i2c_client (dev);int ret; + ret =pmbus_lock_interruptible (client); +if (ret) +return ret; + ret =i2c_smbus_read_word_data (client,ADM1266_READ_STATE ); +pmbus_unlock (client);if (ret <0 )return ret;
Greg Kroah-Hartman
maintainerPATCH 303/307 hwmon: (pmbus/adm1266) serialize NVMEM blackbox read with pmbus_lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
[ Upstream commit 9f1dd8f9491eb840cbea7ffdf4cad031e25f8ae0 ]
adm1266_nvmem_read() is the reg_read callback the NVMEM core invokes when userspace reads /sys/bus/nvmem/devices/.../nvmem on this chip. On the first byte of every read it does a memset of data->dev_mem, walks the device blackbox through adm1266_nvmem_read_blackbox() (which issues a chain of PMBus block transactions), and then memcpys the refreshed buffer out to userspace. None of that runs under pmbus_lock today.
Two consequences:
- The PMBus traffic the refresh issues is not serialised against pmbus_core's own multi-step PAGE+register sequences. A paged hwmon attribute read from another thread can land between a PAGE write and the paged read in either direction and corrupt one side's view of the device state machine.
- The NVMEM core does not serialise concurrent reg_read calls, so two userspace readers racing at offset 0 can interleave the memset of data->dev_mem with another reader's adm1266_nvmem_read_blackbox() refill or memcpy out, returning torn data to userspace.
Take pmbus_lock at the top of adm1266_nvmem_read() via the scope-based guard(). Patch 5 of this series moves adm1266_config_nvmem() past pmbus_do_probe() so the lock is guaranteed to be live before the callback is reachable from userspace.
--- drivers/hwmon/pmbus/adm1266.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/hwmon/pmbus/adm1266.c +7 -0
@@ -398,18 +398,25 @@ static int adm1266_nvmem_read(void *privif (offset + bytes > data->nvmem_config.size)return -EINVAL ; + ret =pmbus_lock_interruptible (data->client); +if (ret) +return ret; +if (offset ==0 ) {memset (data->dev_mem,0 , data->nvmem_config.size); ret =adm1266_nvmem_read_blackbox (data, data->dev_mem);if (ret) {dev_err (&data->client->dev,"Could not read blackbox!" ); +pmbus_unlock (data->client);return ret; } }memcpy (val, data->dev_mem + offset, bytes); +pmbus_unlock (data->client); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 304/307 hwmon: (pmbus/adm1266) serialize GPIO PMBus accesses with pmbus_lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdurrahman Hussain <[email protected]>
[ Upstream commit bab8c6fb5af8df7e753d196c1262cb78e92ca872 ]
adm1266_gpio_get(), adm1266_gpio_get_multiple(), and adm1266_gpio_dbg_show() all issue PMBus reads against the device but none of them take pmbus_lock. The pmbus_core framework holds pmbus_lock around its own multi-transaction sequences (notably the "set PAGE, then read paged register" pattern used by hwmon attributes), so an unlocked GPIO accessor can land between a PAGE write and the subsequent paged read in another thread and corrupt either side's view of the device state machine.
Take pmbus_lock at the top of each of the three accessors via the scope-based guard(). The lock is uncontended in the common case and adds only a single mutex round-trip per call.
--- drivers/hwmon/pmbus/adm1266.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-)
drivers/hwmon/pmbus/adm1266.c +34 -6
@@ -173,7 +173,12 @@ static int adm1266_gpio_get(struct gpio_else pmbus_cmd =ADM1266_PDIO_STATUS ; + ret =pmbus_lock_interruptible (data->client); +if (ret) +return ret; + ret =i2c_smbus_read_block_data (data->client, pmbus_cmd, read_buf); +pmbus_unlock (data->client);if (ret <0 )return ret;if (ret <2 )
@@ -195,11 +200,19 @@ static int adm1266_gpio_get_multiple(strunsigned int gpio_nr;int ret; + ret =pmbus_lock_interruptible (data->client); +if (ret) +return ret; + ret =i2c_smbus_read_block_data (data->client,ADM1266_GPIO_STATUS , read_buf); -if (ret <0 ) +if (ret <0 ) { +pmbus_unlock (data->client);return ret; -if (ret <2 ) + } +if (ret <2 ) { +pmbus_unlock (data->client);return -EIO ; + } status = read_buf[0 ] + (read_buf[1 ] <<8 );
@@ -210,10 +223,14 @@ static int adm1266_gpio_get_multiple(str } ret =i2c_smbus_read_block_data (data->client,ADM1266_PDIO_STATUS , read_buf); -if (ret <0 ) +if (ret <0 ) { +pmbus_unlock (data->client);return ret; -if (ret <2 ) + } +if (ret <2 ) { +pmbus_unlock (data->client);return -EIO ; + } status = read_buf[0 ] + (read_buf[1 ] <<8 );
@@ -222,6 +239,8 @@ static int adm1266_gpio_get_multiple(strset_bit (gpio_nr, bits); } +pmbus_unlock (data->client); +return 0 ; }
@@ -236,11 +255,16 @@ static void adm1266_gpio_dbg_show(structint ret;int i; +if (pmbus_lock_interruptible (data->client)) +return ; +for (i =0 ; i <ADM1266_GPIO_NR ; i++) { write_cmd = adm1266_gpio_mapping[i][1 ]; ret =adm1266_pmbus_block_xfer (data,ADM1266_GPIO_CONFIG ,1 , &write_cmd, read_buf); -if (ret !=2 ) +if (ret !=2 ) { +pmbus_unlock (data->client);return ; + } gpio_config = read_buf[0 ];seq_puts (s, adm1266_names[i]);
@@ -262,8 +286,10 @@ static void adm1266_gpio_dbg_show(struct write_cmd =0xFF ; ret =adm1266_pmbus_block_xfer (data,ADM1266_PDIO_CONFIG ,1 , &write_cmd, read_buf); -if (ret !=32 ) +if (ret !=32 ) { +pmbus_unlock (data->client);return ; + }for (i =0 ; i <ADM1266_PDIO_NR ; i++) {seq_puts (s, adm1266_names[ADM1266_GPIO_NR + i]);
@@ -286,6 +312,8 @@ static void adm1266_gpio_dbg_show(structseq_puts (s,")\n" ); } + +pmbus_unlock (data->client); }static int adm1266_config_gpio (struct adm1266_data *data)
Greg Kroah-Hartman
maintainerPATCH 305/307 mm: perform all memfd seal checks in a single place
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Stoakes <[email protected]>
[ Upstream commit fa00b8ef1803fe133b4897c25227aa0d298dd093 ]
We no longer actually need to perform these checks in the f_op->mmap() hook any longer.
We already moved the operation which clears VM_MAYWRITE on a read-only mapping of a write-sealed memfd in order to work around the restrictions imposed by commit 5de195060b2e ("mm: resolve faulty mmap_region() error path behaviour").
There is no reason for us not to simply go ahead and additionally check to see if any pre-existing seals are in place here rather than defer this to the f_op->mmap() hook.
By doing this we remove more logic from shmem_mmap() which doesn't belong there, as well as doing the same for hugetlbfs_file_mmap(). We also remove dubious shared logic in mm.h which simply does not belong there either.
It makes sense to do these checks at the earliest opportunity, we know these are shmem (or hugetlbfs) mappings whose relevant VMA flags will not change from the invoking do_mmap() so there is simply no need to wait.
This also means the implementation of further memfd seal flags can be done within mm/memfd.c and also have the opportunity to modify VMA flags as necessary early in the mapping logic.
Stable-dep-of: 3b041514cb6e ("memfd: deny writeable mappings when implying SEAL_WRITE")
--- fs/hugetlbfs/inode.c | 5 ---- include/linux/memfd.h | 23 ++++++++++---------- include/linux/mm.h | 55 -------------------------------------------------- mm/memfd.c | 44 +++++++++++++++++++++++++++++++++++++++- mm/mmap.c | 12 ++++++++-- mm/shmem.c | 6 ----- 6 files changed, 63 insertions(+), 82 deletions(-)
fs/hugetlbfs/inode.c +0 -5
@@ -96,7 +96,6 @@ static const struct fs_parameter_spec hustatic int hugetlbfs_file_mmap (struct file *file,struct vm_area_struct *vma) {struct inode *inode =file_inode (file); -struct hugetlbfs_inode_info *info =HUGETLBFS_I (inode);loff_t len, vma_len;int ret;struct hstate *h =hstate_file (file);
@@ -113,10 +112,6 @@ static int hugetlbfs_file_mmap(struct fivm_flags_set (vma,VM_HUGETLB |VM_DONTEXPAND ); vma->vm_ops = &hugetlb_vm_ops; - ret =seal_check_write (info->seals, vma); -if (ret) -return ret; -/* * page based offset in vm_pgoff could be sufficiently large to * overflow a loff_t when converted to byte offset. This can
include/linux/memfd.h +11 -12
@@ -7,7 +7,14 @@#ifdef CONFIG_MEMFD_CREATE extern long memfd_fcntl (struct file *file,unsigned int cmd,unsigned int arg);struct folio *memfd_alloc_folio (struct file *memfd,pgoff_t idx); -unsigned int *memfd_file_seals_ptr (struct file *file); +/* +* Check for any existing seals on mmap, return an error if access is denied due +* to sealing, or 0 otherwise. +* +* We also update VMA flags if appropriate by manipulating the VMA flags pointed +* to by vm_flags_ptr. +*/ +int memfd_check_seals_mmap (struct file *file,unsigned long *vm_flags_ptr);#else static inline long memfd_fcntl (struct file *f,unsigned int c,unsigned int a) {
@@ -17,19 +24,11 @@ static inline struct folio *memfd_alloc_ {return ERR_PTR (-EINVAL ); } - -static inline unsigned int *memfd_file_seals_ptr (struct file *file) +static inline int memfd_check_seals_mmap (struct file *file, +unsigned long *vm_flags_ptr) { -return NULL ; +return 0 ; }#endif -/* Retrieve memfd seals associated with the file, if any. */ -static inline unsigned int memfd_file_seals (struct file *file) -{ -unsigned int *sealsp =memfd_file_seals_ptr (file); - -return sealsp ? *sealsp :0 ; -} -#endif /* __LINUX_MEMFD_H */
include/linux/mm.h +0 -55
61 lines not on this page · raw message
mm/memfd.c +43 -1
56 lines not on this page · raw message
mm/mmap.c +9 -3
@@ -369,8 +369,8 @@ unsigned long do_mmap(struct file *file,if (file) {struct inode *inode =file_inode (file); -unsigned int seals =memfd_file_seals (file);unsigned long flags_mask; +int err;if (!file_mmap_ok (file, inode, pgoff, len))return -EOVERFLOW ;
@@ -410,8 +410,6 @@ unsigned long do_mmap(struct file *file, vm_flags |=VM_SHARED |VM_MAYSHARE ;if (!(file->f_mode &FMODE_WRITE )) vm_flags &= ~(VM_MAYWRITE |VM_SHARED ); -else if (is_readonly_sealed (seals, vm_flags)) - vm_flags &= ~VM_MAYWRITE ; fallthrough;case MAP_PRIVATE :if (!(file->f_mode &FMODE_READ ))
@@ -431,6 +429,14 @@ unsigned long do_mmap(struct file *file,default :return -EINVAL ; } + +/* +* Check to see if we are violating any seals and update VMA +* flags if necessary to avoid future seal violations. +*/ + err =memfd_check_seals_mmap (file, &vm_flags); +if (err) +return (unsigned long )err; }else {switch (flags &MAP_TYPE ) {case MAP_SHARED :
mm/shmem.c +0 -6
@@ -2820,12 +2820,6 @@ out_nomem:static int shmem_mmap (struct file *file,struct vm_area_struct *vma) {struct inode *inode =file_inode (file); -struct shmem_inode_info *info =SHMEM_I (inode); -int ret; - - ret =seal_check_write (info->seals, vma); -if (ret) -return ret;file_accessed (file);/* This is anonymous shared memory if it is unlinked at the time of mmap */
Greg Kroah-Hartman
maintainerPATCH 306/307 mm/memfd: fix spelling and grammatical issues
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Ye <[email protected]>
[ Upstream commit 33c9b01ed2fcbc101cdfeb497f4581e981e7c1e7 ]
The comment "If a private mapping then writability is irrelevant" contains a typo. It should be "If a private mapping then writability is irrelevant". The comment "SEAL_EXEC implys SEAL_WRITE, making W^X from the start." contains a typo. It should be "SEAL_EXEC implies SEAL_WRITE, making W^X from the start."
Stable-dep-of: 3b041514cb6e ("memfd: deny writeable mappings when implying SEAL_WRITE")
--- mm/memfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memfd.c +2 -2
@@ -286,7 +286,7 @@ static int memfd_add_seals(struct file * }/* -* SEAL_EXEC implys SEAL_WRITE, making W^X from the start. +* SEAL_EXEC implies SEAL_WRITE, making W^X from the start. */ if (seals &F_SEAL_EXEC && inode->i_mode &0111 ) seals |=F_SEAL_SHRINK |F_SEAL_GROW |F_SEAL_WRITE |F_SEAL_FUTURE_WRITE ;
@@ -364,7 +364,7 @@ static int check_write_seal(unsigned lonunsigned long vm_flags = *vm_flags_ptr;unsigned long mask = vm_flags & (VM_SHARED |VM_WRITE ); -/* If a private matting then writability is irrelevant. */ +/* If a private mapping then writability is irrelevant. */ if (!(mask &VM_SHARED ))return 0 ;
Greg Kroah-Hartman
maintainerPATCH 307/307 memfd: deny writeable mappings when implying SEAL_WRITE
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Pratyush Yadav (Google)" <[email protected]>
[ Upstream commit 3b041514cb6eae45869b020f743c14d983363222 ]
When SEAL_EXEC is added, SEAL_WRITE is implied to make W^X. But the implied seal is set after the check that makes sure the memfd can not have any writable mappings. This means one can use SEAL_EXEC to apply SEAL_WRITE while having writeable mappings.
This breaks the contract that SEAL_WRITE provides and can be used by an attacker to pass a memfd that appears to be write sealed but can still be modified arbitrarily.
Fix this by adding the implied seals before the call for mapping_deny_writable() is done.
--- mm/memfd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
mm/memfd.c +6 -6
@@ -273,6 +273,12 @@ static int memfd_add_seals(struct file * goto unlock; } +/* +* SEAL_EXEC implies SEAL_WRITE, making W^X from the start. +*/ +if (seals &F_SEAL_EXEC && inode->i_mode &0111 ) + seals |=F_SEAL_SHRINK |F_SEAL_GROW |F_SEAL_WRITE |F_SEAL_FUTURE_WRITE ; +if ((seals &F_SEAL_WRITE ) && !(*file_seals &F_SEAL_WRITE )) { error =mapping_deny_writable (file->f_mapping);if (error)
@@ -285,12 +291,6 @@ static int memfd_add_seals(struct file * } } -/* -* SEAL_EXEC implies SEAL_WRITE, making W^X from the start. -*/ -if (seals &F_SEAL_EXEC && inode->i_mode &0111 ) - seals |=F_SEAL_SHRINK |F_SEAL_GROW |F_SEAL_WRITE |F_SEAL_FUTURE_WRITE ; - *file_seals |= seals; error =0 ;
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
In reply to Greg Kroah-HartmanHi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.12.93 release. There are 307 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.12.y
Best regards,
Pavel
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
In reply to Greg Kroah-HartmanQuoted 8 lines · On Sun, 07 Jun 2026 11:56:37 +0200 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.12.93 release. There are 307 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue, 09 Jun 2026 09:56:47 +0000. Anything received after that time might be too late.
Boot-tested under QEMU for Rust x86_64, arm64 and riscv64; built-tested for loongarch64:
arm32 also builds fine.
On arm64, I am seeing:
net/sched/act_mirred.c:451:43: warning: variable 'm_eaction' is uninitialized when used here [-Wuninitialized]
451 | is_redirect = tcf_mirred_is_act_redirect(m_eaction);
| ^~~~~~~~~
net/sched/act_mirred.c:429:18: note: initialize the variable 'm_eaction' to silence this warning
429 | int i, m_eaction;
| ^
| = 0
due to commit a01fbdecc3a2 ("net/sched: act_mirred: Fix return code in early mirred redirect error paths") here.
And that one seems to be missing at least the assignment to the variable that happened in commit a005fa5d7502 ("net/sched: act_mirred: Fix blockcast recursion bypass leading to stack overflow").
I hope this helps!
Cheers,
Miguel
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
Hi Miguel,
Thanks for reporting this.
Quoted 28 lines · Miguel Ojeda
Quoted 8 lines · On Sun, 07 Jun 2026 11:56:37 +0200 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.12.93 release. There are 307 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue, 09 Jun 2026 09:56:47 +0000. Anything received after that time might be too late.
Boot-tested under QEMU for Rust
x86_64, arm64 and riscv64; built-tested for loongarch64:Tested-by Miguel Ojeda <[email protected]>arm32 also builds fine.
On arm64, I am seeing:
net/sched/act_mirred.c:451:43: warning: variable 'm_eaction' is uninitialized when used here [-Wuninitialized]
451 |is_redirect=tcf_mirred_is_act_redirect(m_eaction);
| ^~~~~~~~~
net/sched/act_mirred.c:429:18: note: initialize the variable 'm_eaction' to silence this warning
429 | int i,m_eaction;
| ^
| = 0
Quoted 7 lines
due to commit
a01fbdecc3a2("net/sched:act_mirred: Fix return code in early mirred redirect error paths") here.And that one seems to be missing at least the assignment to the variable that happened in commit
a005fa5d7502("net/sched:act_mirred: Fix blockcast recursion bypass leading to stack overflow").
Unless i am looking at the wrong code version, in the current code i see m_eaction is always initialized before being used. m_eaction = READ_ONCE(m->tcfm_eaction);
Probably a compiler false positive?
As per suggestion emmited, initializing m_eaction to 0 should help. Not sure what the process is.
Perhaps, Miguel you want to send the fix? commit should say "appease compiler ..."
cheers,
jamal
Quoted 11 lines
I hope this helps!
Cc Kito Xu (veritas501) <[email protected]>Cc Victor Nogueira <[email protected]>Cc Paolo Abeni <[email protected]>Cc Jamal Hadi Salim <[email protected]>Cc Jiri Pirko <[email protected]>Cheers,
Miguel
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
Quoted 2 lines · Jamal Hadi Salim
Thanks for reporting this.
You're welcome!
Quoted 4 lines
Unless i am looking at the wrong code version, in the current code i see
m_eactionis always initialized before being used.m_eaction=READ_ONCE(m->tcfm_eaction);
Probably a compiler false positive?
No, it is an actual bug -- you have:
int i, m_eaction;
...
is_redirect = tcf_mirred_is_act_redirect(m_eaction);
...
m_eaction = READ_ONCE(m->tcfm_eaction);i.e. the assignment goes later.
Maybe you are looking at mainline? Please note that this is a 6.12.y -rc thread -- are you looking at the commit hash I mentioned?
Or maybe you are looking at tcf_blockcast() instead of tcf_mirred_act()?
I hope that helps.
Cheers,
Miguel
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
Quoted 20 lines · Miguel Ojeda
Quoted 2 lines · Jamal Hadi Salim
Thanks for reporting this.
You're welcome!
Quoted 4 lines
Unless i am looking at the wrong code version, in the current code i see
m_eactionis always initialized before being used.m_eaction=READ_ONCE(m->tcfm_eaction);
Probably a compiler false positive?No, it is an actual bug -- you have:
int i, m_eaction; ... is_redirect = tcf_mirred_is_act_redirect(m_eaction); ... m_eaction = READ_ONCE(m->tcfm_eaction);
Quoted 7 lines
i.e. the assignment goes later.
Maybe you are looking at mainline? Please note that this is a 6.12.y -rc thread -- are you looking at the commit hash I mentioned?
Or maybe you are looking at
tcf_blockcast()instead oftcf_mirred_act()?
I was certainly looking at the wrong version.
For example what you described as commit a01fbdecc3a2 ("net/sched:act_mirred: Fix return code in early mirred redirect error paths") shows up for me as commit e80ad525fc7e
I believe this bug slipped in during a small window but was fixed very quickly. Probably some fix never trickled to stable.
If you can point me to the exact tree where this happens i can take a look. Still curious: So only the arm compiler catches this?
cheers,
jamal
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
Quoted 3 lines · Jamal Hadi Salim
I believe this bug slipped in during a small window but was fixed very quickly. Probably some fix never trickled to stable.
Yeah, as I mentioned above, I think commit a005fa5d7502 ("net/sched:act_mirred: Fix blockcast recursion bypass leading to stack overflow") is missing (at least).
I would suggest reviewing the entire chain to see what needs to be backported.
Quoted 1 line
If you can point me to the exact tree where this happens i can take a look.
This is the 6.12.y -rc tree:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
linux-6.12.y
The stable kernel team puts the link to the repository at the top of the thread too:
https://lore.kernel.org/stable/[email protected]/
Quoted 1 line
Still curious: So only the arm compiler catches this?
It likely gets caught by other arches too, i.e. I just happened to catch it in my arm64 build.
This is Clang, not GCC, by the way.
I hope this helps!
Cheers,
Miguel
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
Hi Miguel,
Quoted 22 lines · Miguel Ojeda
Quoted 3 lines · Jamal Hadi Salim
I believe this bug slipped in during a small window but was fixed very quickly. Probably some fix never trickled to stable.
Yeah, as I mentioned above, I think commit
a005fa5d7502("net/sched:act_mirred: Fix blockcast recursion bypass leading to stack overflow") is missing (at least).I would suggest reviewing the entire chain to see what needs to be backported.
Quoted 1 line
If you can point me to the exact tree where this happens i can take a look.
This is the 6.12.y -rc tree:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
linux-6.12.yThe stable kernel team puts the link to the repository at the top of the thread too:
Quoted 9 lines
https://lore.kernel.org/stable/[email protected]/
Quoted 1 line
Still curious: So only the arm compiler catches this?
It likely gets caught by other arches too, i.e. I just happened to catch it in my arm64 build.
This is Clang, not GCC, by the way.
I think it was too early AM here when i was looking at this. The answer was right there all along in what you said: The missing piece is commit a005fa5d7502
cheers,
jamal
Quoted 4 lines
I hope this helps!
Cheers,
Miguel
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
Quoted 4 lines · Jamal Hadi Salim
I think it was too early AM here when i was looking at this. The answer was right there all along in what you said: The missing piece is commit
a005fa5d7502
No worries, it happens :)
I see a005fa5d7502 is now in the release.
Cheers,
Miguel
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
In reply to Greg Kroah-HartmanAm 07.06.2026 um 11:56 schrieb Greg Kroah-Hartman:
Quoted 4 lines
This is the start of the stable review cycle for the 6.12.93 release. There are 307 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Builds, boots and works on my 2-socket Ivy Bridge Xeon E5-2697 v2 server. No dmesg oddities or regressions found.
Beste Grüße,
Peter Schneider
Signature · 8 lines
Climb the mountain not to plant your flag, but to embrace the challenge, enjoy the air and behold the view. Climb it so you can see the world, not so the world can see you. -- David McCullough Jr. OpenPGP: 0xA3828BD796CCE11A8CADE8866E3A92C92C3FF244 Download: https://www.peters-netzplatz.de/download/pschneider1968_pub.asc https://keys.mailvelope.com/pks/lookup?op=get&[email protected] https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
In reply to Greg Kroah-HartmanQuoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.93 release. There are 307 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
In reply to Greg Kroah-HartmanQuoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.93 release. There are 307 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue, 09 Jun 2026 09:56:47 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.93-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
In reply to Greg Kroah-HartmanQuoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.93 release. There are 307 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
In reply to Greg Kroah-HartmanQuoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.93 release. There are 307 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue, 09 Jun 2026 09:56:47 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.93-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
In reply to Greg Kroah-HartmanGreg Kroah-Hartman wrote on Sun, Jun 07, 2026 at 11:56:37AM +0200:
Quoted 5 lines
This is the start of the stable review cycle for the 6.12.93 release. There are 307 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 8 lines
Responses should be made by Tue, 09 Jun 2026 09:56:47 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.93-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.
Tested e22d99f0e6cb ("Linux 6.12.93-rc1") on:
- arm i.MX6ULL (Armadillo 640)
- arm64 i.MX8ULP (Armadillo IoT A9E)
No obvious regression in dmesg or basic tests:
Signature · 1 line
Dominique Martinet
Re: [PATCH 6.12 000/307] 6.12.93-rc1 review
In reply to Greg Kroah-HartmanHi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.93 release. There are 307 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Tue, 09 Jun 2026 09:56:47 +0000. Anything received after that time might be too late.
Too late,
but yes, no problems seen on x86_64 and aarch64 with our testing.
Thanks,
Harshit