5.4.297-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 148/403 perf/core: Dont leak AUX buffer refcount on allocation failure
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 5468c0fbccbb9d156522c50832244a8b722374fb upstream.
Failure of the AUX buffer allocation leaks the reference count.
Set the reference count to 1 only when the allocation succeeds.
--- kernel/events/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/events/core.c +4 -3
@@ -5877,9 +5877,7 @@ static int perf_mmap(struct file *file, goto unlock; } -atomic_set (&rb->aux_mmap_count,1 ); user_extra = nr_pages; - goto accounting; }
@@ -5986,8 +5984,10 @@ accounting: }else { ret =rb_alloc_aux (rb, event, vma->vm_pgoff, nr_pages, event->attr.aux_watermark, flags); -if (!ret) +if (!ret) { +atomic_set (&rb->aux_mmap_count,1 ); rb->aux_mmap_locked = extra; + } } unlock:
@@ -5997,6 +5997,7 @@ unlock:atomic_inc (&event->mmap_count); }else if (rb) { +/* AUX allocation failed */ atomic_dec (&rb->mmap_count); } aux_unlock:
Greg Kroah-Hartman
maintainerPATCH 149/403 perf/core: Exit early on perf_mmap() fail
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 07091aade394f690e7b655578140ef84d0e8d7b0 upstream.
When perf_mmap() fails to allocate a buffer, it still invokes the event_mapped() callback of the related event. On X86 this might increase the perf_rdpmc_allowed reference counter. But nothing undoes this as perf_mmap_close() is never called in this case, which causes another reference count leak.
Return early on failure to prevent that.
--- kernel/events/core.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/events/core.c +3 -0
@@ -6003,6 +6003,9 @@ unlock: aux_unlock:mutex_unlock (&event->mmap_mutex); +if (ret) +return ret; +/* * Since pinned accounting is per vm we cannot allow fork() to copy our * vma.
Greg Kroah-Hartman
maintainerPATCH 150/403 perf/core: Prevent VMA split of buffer mappings
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit b024d7b56c77191cde544f838debb7f8451cd0d6 upstream.
The perf mmap code is careful about mmap()'ing the user page with the ringbuffer and additionally the auxiliary buffer, when the event supports it. Once the first mapping is established, subsequent mapping have to use the same offset and the same size in both cases. The reference counting for the ringbuffer and the auxiliary buffer depends on this being correct.
Though perf does not prevent that a related mapping is split via mmap(2), munmap(2) or mremap(2). A split of a VMA results in perf_mmap_open() calls, which take reference counts, but then the subsequent perf_mmap_close() calls are not longer fulfilling the offset and size checks. This leads to reference count leaks.
As perf already has the requirement for subsequent mappings to match the initial mapping, the obvious consequence is that VMA splits, caused by resizing of a mapping or partial unmapping, have to be prevented.
Implement the vm_operations_struct::may_split() callback and return unconditionally -EINVAL.
That ensures that the mapping offsets and sizes cannot be changed after the fact. Remapping to a different fixed address with the same size is still possible as it takes the references for the new mapping and drops those of the old mapping.
--- kernel/events/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/events/core.c +10 -0
@@ -5789,11 +5789,21 @@ out_put:ring_buffer_put (rb);/* could be last */ } +static int perf_mmap_may_split (struct vm_area_struct *vma,unsigned long addr) +{ +/* +* Forbid splitting perf mappings to prevent refcount leaks due to +* the resulting non-matching offsets and sizes. See open()/close(). +*/ +return -EINVAL ; +} +static const struct vm_operations_struct perf_mmap_vmops = { .open = perf_mmap_open, .close = perf_mmap_close,/* non mergeable */ .fault = perf_mmap_fault, .page_mkwrite = perf_mmap_fault, + .split = perf_mmap_may_split, };static int perf_mmap (struct file *file,struct vm_area_struct *vma)
Greg Kroah-Hartman
maintainerPATCH 151/403 net/packet: fix a race in packet_set_ring() and packet_notifier()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quang Le <[email protected]>
commit 01d3c8417b9c1b884a8a981a3b886da556512f36 upstream.
When packet_set_ring() releases po->bind_lock, another thread can run packet_notifier() and process an NETDEV_UP event.
This race and the fix are both similar to that of commit 15fe076edea7 ("net/packet: fix a race in packet_bind() and packet_notifier()").
There too the packet_notifier NETDEV_UP event managed to run while a po->bind_lock critical section had to be temporarily released. And the fix was similarly to temporarily set po->num to zero to keep the socket unhooked until the lock is retaken.
The po->bind_lock in packet_set_ring and packet_notifier precede the introduction of git history.
--- net/packet/af_packet.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/packet/af_packet.c +6 -6
@@ -4504,10 +4504,10 @@ static int packet_set_ring(struct sock *spin_lock (&po->bind_lock); was_running = po->running; num = po->num; -if (was_running) { -WRITE_ONCE (po->num,0 ); +WRITE_ONCE (po->num,0 ); +if (was_running)__unregister_prot_hook (sk, false); - } +spin_unlock (&po->bind_lock);synchronize_net ();
@@ -4539,10 +4539,10 @@ static int packet_set_ring(struct sock *mutex_unlock (&po->pg_vec_lock);spin_lock (&po->bind_lock); -if (was_running) { -WRITE_ONCE (po->num, num); +WRITE_ONCE (po->num, num); +if (was_running)register_prot_hook (sk); - } +spin_unlock (&po->bind_lock);if (pg_vec && (po->tp_version >TPACKET_V2 )) {/* Because we don't support block-based V3 on tx-ring */
Greg Kroah-Hartman
maintainerPATCH 152/403 vsock: Do not allow binding to VMADDR_PORT_ANY
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Budimir Markovic <[email protected]>
commit aba0c94f61ec05315fa7815d21aefa4c87f6a9f4 upstream.
It is possible for a vsock to autobind to VMADDR_PORT_ANY. This can cause a use-after-free when a connection is made to the bound socket. The socket returned by accept() also has port VMADDR_PORT_ANY but is not on the list of unbound sockets. Binding it will result in an extra refcount decrement similar to the one fixed in fcdd2242c023 (vsock: Keep the binding until socket destruction).
Modify the check in __vsock_bind_connectible() to also prevent binding to VMADDR_PORT_ANY.
--- net/vmw_vsock/af_vsock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/vmw_vsock/af_vsock.c +2 -1
@@ -487,7 +487,8 @@ static int __vsock_bind_stream(struct vsunsigned int i;for (i =0 ; i <MAX_PORT_RETRIES ; i++) { -if (port <=LAST_RESERVED_PORT ) +if (port ==VMADDR_PORT_ANY || + port <=LAST_RESERVED_PORT ) port =LAST_RESERVED_PORT +1 ; new_addr.svm_port = port++;
Greg Kroah-Hartman
maintainerPATCH 153/403 USB: serial: option: add Foxconn T99W709
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slark Xiao <[email protected]>
commit ad1244e1ce18f8c1a5ebad8074bfcf10eacb0311 upstream.
T99W709 is designed based on MTK T300(5G redcap) chip. There are 7 serial ports to be enumerated: AP_LOG, GNSS, AP_META, AT, MD_META, NPT, DBG. RSVD(5) for ADB port.
test evidence as below:
T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 7 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0489 ProdID=e15f Rev=00.01 S: Manufacturer=MediaTek Inc. S: Product=USB DATA CARD S: SerialNumber=355511220000399 C: #Ifs=10 Cfg#= 1 Atr=a0 MxPwr=500mA I: If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim I: If#=0x1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim I: If#=0x2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=usbfs I: If#=0x6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x7 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x8 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option I: If#=0x9 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
--- drivers/usb/serial/option.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/option.c +2 -0
@@ -2346,6 +2346,8 @@ static const struct usb_device_id option .driver_info = RSVD(3) }, { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe145, 0xff), /* Foxconn T99W651 RNDIS */ .driver_info = RSVD(5) | RSVD(6) }, + { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe15f, 0xff), /* Foxconn T99W709 */ + .driver_info = RSVD(5) }, { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe167, 0xff), /* Foxconn T99W640 MBIM */ .driver_info = RSVD(3) }, { USB_DEVICE(0x1508, 0x1001), /* Fibocom NL668 (IOT version) */
Greg Kroah-Hartman
maintainerPATCH 154/403 MIPS: mm: tlb-r4k: Uniquify TLB entries on init
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit 35ad7e181541aa5757f9f316768d3e64403ec843 upstream.
Hardware or bootloader will initialize TLB entries to any value, which may collide with kernel's UNIQUE_ENTRYHI value. On MIPS microAptiv/M5150 family of cores this will trigger machine check exception and cause boot failure. On M5150 simulation this could happen 7 times out of 1000 boots.
Replace local_flush_tlb_all() with r4k_tlb_uniquify() which probes each TLB ENTRIHI unique value for collisions before it's written, and in case of collision try a different ASID.
--- arch/mips/mm/tlb-r4k.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-)
arch/mips/mm/tlb-r4k.c +55 -1
@@ -497,6 +497,60 @@ static int __init set_ntlb(char *str)__setup ("ntlb=" , set_ntlb); +/* Initialise all TLB entries with unique values */ +static void r4k_tlb_uniquify (void ) +{ +int entry =num_wired_entries (); + +htw_stop (); +write_c0_entrylo0 (0 ); +write_c0_entrylo1 (0 ); + +while (entry < current_cpu_data.tlbsize) { +unsigned long asid_mask =cpu_asid_mask (¤t_cpu_data); +unsigned long asid =0 ; +int idx; + +/* Skip wired MMID to make ginvt_mmid work */ +if (cpu_has_mmid) + asid =MMID_KERNEL_WIRED +1 ; + +/* Check for match before using UNIQUE_ENTRYHI */ +do { +if (cpu_has_mmid) { +write_c0_memorymapid (asid); +write_c0_entryhi (UNIQUE_ENTRYHI (entry)); + }else { +write_c0_entryhi (UNIQUE_ENTRYHI (entry) | asid); + } +mtc0_tlbw_hazard (); +tlb_probe (); +tlb_probe_hazard (); + idx =read_c0_index (); +/* No match or match is on current entry */ +if (idx <0 || idx == entry) +break ; +/* +* If we hit a match, we need to try again with +* a different ASID. +*/ + asid++; + }while (asid < asid_mask); + +if (idx >=0 && idx != entry) +panic ("Unable to uniquify TLB entry %d" , idx); + +write_c0_index (entry); +mtc0_tlbw_hazard (); +tlb_write_indexed (); + entry++; + } + +tlbw_use_hazard (); +htw_start (); +flush_micro_tlb (); +} +/* * Configure TLB (for init or after a CPU has been powered off). */
@@ -536,7 +590,7 @@ static void r4k_tlb_configure(void) temp_tlb_entry = current_cpu_data.tlbsize -1 ;/* From this point on the ARC firmware is dead. */ -local_flush_tlb_all (); +r4k_tlb_uniquify ();/* Did I tell you that ARC SUCKS? */ }
Greg Kroah-Hartman
maintainerPATCH 155/403 usb: gadget : fix use-after-free in composite_dev_cleanup()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Xue <[email protected]>
commit 151c0aa896c47a4459e07fee7d4843f44c1bb18e upstream.
1. In func configfs_composite_bind() -> composite_os_desc_req_prepare():
if kmalloc fails, the pointer cdev->os_desc_req will be freed but not set to NULL. Then it will return a failure to the upper-level function.
2. in func configfs_composite_bind() -> composite_dev_cleanup():
it will checks whether cdev->os_desc_req is NULL. If it is not NULL, it will attempt to use it.This will lead to a use-after-free issue.
BUG: KASAN: use-after-free in composite_dev_cleanup+0xf4/0x2c0 Read of size 8 at addr 0000004827837a00 by task init/1 CPU: 10 PID: 1 Comm: init Tainted: G O 5.10.97-oh #1 kasan_report+0x188/0x1cc __asan_load8+0xb4/0xbc composite_dev_cleanup+0xf4/0x2c0 configfs_composite_bind+0x210/0x7ac udc_bind_to_driver+0xb4/0x1ec usb_gadget_probe_driver+0xec/0x21c gadget_dev_desc_UDC_store+0x264/0x27c
--- drivers/usb/gadget/composite.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/usb/gadget/composite.c +5 -0
@@ -2241,6 +2241,11 @@ int composite_os_desc_req_prepare(structif (!cdev->os_desc_req->buf) { ret = -ENOMEM ;usb_ep_free_request (ep0, cdev->os_desc_req); +/* +* Set os_desc_req to NULL so that composite_dev_cleanup() +* will not try to free it again. +*/ + cdev->os_desc_req =NULL ; goto end; } cdev->os_desc_req->context = cdev;
Greg Kroah-Hartman
maintainerPATCH 156/403 io_uring: dont use int for ABI
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit cf73d9970ea4f8cace5d8f02d2565a2723003112 upstream.
__kernel_rwf_t is defined as int, the actual size of which is implementation defined. It won't go well if some compiler / archs ever defines it as i64, so replace it with __u32, hoping that there is no one using i16 for it.
--- include/uapi/linux/io_uring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/io_uring.h +1 -1
@@ -23,7 +23,7 @@ struct io_uring_sqe {__u64 addr;/* pointer to buffer or iovecs */ __u32 len;/* buffer size or number of iovecs */ union { -__kernel_rwf_t rw_flags; +__u32 rw_flags;__u32 fsync_flags;__u16 poll_events;__u32 sync_range_flags;
Greg Kroah-Hartman
maintainerPATCH 157/403 ALSA: usb-audio: Validate UAC3 power domain descriptors, too
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit d832ccbc301fbd9e5a1d691bdcf461cdb514595f upstream.
UAC3 power domain descriptors need to be verified with its variable bLength for avoiding the unexpected OOB accesses by malicious firmware, too.
--- sound/usb/validate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/usb/validate.c +12 -0
@@ -221,6 +221,17 @@ static bool validate_uac3_feature_unit(creturn d->bLength >=sizeof (*d) +4 +2 ; } +static bool validate_uac3_power_domain_unit (const void *p, +const struct usb_desc_validator *v) +{ +const struct uac3_power_domain_descriptor *d = p; + +if (d->bLength <sizeof (*d)) +return false; +/* baEntities[] + wPDomainDescrStr */ +return d->bLength >=sizeof (*d) + d->bNrEntities +2 ; +} +static bool validate_midi_out_jack (const void *p,const struct usb_desc_validator *v) {
@@ -285,6 +296,7 @@ static const struct usb_desc_validator a struct uac3_clock_multiplier_descriptor), /* UAC_VERSION_3, UAC3_SAMPLE_RATE_CONVERTER: not implemented yet */ /* UAC_VERSION_3, UAC3_CONNECTORS: not implemented yet */ + FUNC(UAC_VERSION_3, UAC3_POWER_DOMAIN, validate_uac3_power_domain_unit), { }/* terminator */ };
Greg Kroah-Hartman
maintainerPATCH 158/403 ALSA: usb-audio: Validate UAC3 cluster segment descriptors
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit ecfd41166b72b67d3bdeb88d224ff445f6163869 upstream.
UAC3 class segment descriptors need to be verified whether their sizes match with the declared lengths and whether they fit with the allocated buffer sizes, too. Otherwise malicious firmware may lead to the unexpected OOB accesses.
--- sound/usb/stream.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
sound/usb/stream.c +22 -3
@@ -342,20 +342,28 @@ snd_pcm_chmap_elem *convert_chmap_v3(str len =le16_to_cpu (cluster->wLength); c =0 ; - p +=sizeof (struct uac3_cluster_header_descriptor ); + p +=sizeof (*cluster); + len -=sizeof (*cluster); -while (((p - (void *)cluster) < len) && (c < channels)) { +while (len >0 && (c < channels)) {struct uac3_cluster_segment_descriptor *cs_desc = p;u16 cs_len;u8 cs_type; +if (len <sizeof (*p)) +break ; cs_len =le16_to_cpu (cs_desc->wLength); +if (len < cs_len) +break ; cs_type = cs_desc->bSegmentType;if (cs_type ==UAC3_CHANNEL_INFORMATION ) {struct uac3_cluster_information_segment_descriptor *is = p;unsigned char map; +if (cs_len <sizeof (*is)) +break ; +/* * TODO: this conversion is not complete, update it * after adding UAC3 values to asound.h
@@ -457,6 +465,7 @@ snd_pcm_chmap_elem *convert_chmap_v3(str chmap->map[c++] = map; } p += cs_len; + len -= cs_len; }if (channels < c)
@@ -873,7 +882,7 @@ snd_usb_get_audioformat_uac3(struct snd_u64 badd_formats =0 ;unsigned int num_channels;struct audioformat *fp; -u16 cluster_id, wLength; +u16 cluster_id, wLength, cluster_wLength;int clock =0 ;int err;
@@ -1000,6 +1009,16 @@ snd_usb_get_audioformat_uac3(struct snd_ iface_no, altno);kfree (cluster);return ERR_PTR (-EIO ); + } + + cluster_wLength =le16_to_cpu (cluster->wLength); +if (cluster_wLength <sizeof (*cluster) || + cluster_wLength > wLength) { +dev_err (&dev->dev, +"%u:%d : invalid Cluster Descriptor size\n" , + iface_no, altno); +kfree (cluster); +return ERR_PTR (-EIO ); } num_channels = cluster->bNrChannels;
Greg Kroah-Hartman
maintainerPATCH 159/403 netlink: avoid infinite retry looping in netlink_unicast()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
commit 759dfc7d04bab1b0b86113f1164dc1fec192b859 upstream.
netlink_attachskb() checks for the socket's read memory allocation constraints. Firstly, it has:
rmem < READ_ONCE(sk->sk_rcvbuf)
to check if the just increased rmem value fits into the socket's receive buffer. If not, it proceeds and tries to wait for the memory under:
rmem + skb->truesize > READ_ONCE(sk->sk_rcvbuf)
The checks don't cover the case when skb->truesize + sk->sk_rmem_alloc is equal to sk->sk_rcvbuf. Thus the function neither successfully accepts these conditions, nor manages to reschedule the task - and is called in retry loop for indefinite time which is caught as:
rcu: INFO: rcu_sched self-detected stall on CPU rcu: 0-....: (25999 ticks this GP) idle=ef2/1/0x4000000000000000 softirq=262269/262269 fqs=6212 (t=26000 jiffies g=230833 q=259957) NMI backtrace for cpu 0 CPU: 0 PID: 22 Comm: kauditd Not tainted 5.10.240 #68 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-4.fc42 04/01/2014 Call Trace: <IRQ> dump_stack lib/dump_stack.c:120 nmi_cpu_backtrace.cold lib/nmi_backtrace.c:105 nmi_trigger_cpumask_backtrace lib/nmi_backtrace.c:62 rcu_dump_cpu_stacks kernel/rcu/tree_stall.h:335 rcu_sched_clock_irq.cold kernel/rcu/tree.c:2590 update_process_times kernel/time/timer.c:1953 tick_sched_handle kernel/time/tick-sched.c:227 tick_sched_timer kernel/time/tick-sched.c:1399 __hrtimer_run_queues kernel/time/hrtimer.c:1652 hrtimer_interrupt kernel/time/hrtimer.c:1717 __sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1113 asm_call_irq_on_stack arch/x86/entry/entry_64.S:808 </IRQ> netlink_attachskb net/netlink/af_netlink.c:1234 netlink_unicast net/netlink/af_netlink.c:1349 kauditd_send_queue kernel/audit.c:776 kauditd_thread kernel/audit.c:897 kthread kernel/kthread.c:328 ret_from_fork arch/x86/entry/entry_64.S:304
Restore the original behavior of the check which commit in Fixes accidentally missed when restructuring the code.
Found by Linux Verification Center (linuxtesting.org).
--- net/netlink/af_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netlink/af_netlink.c +1 -1
@@ -1212,7 +1212,7 @@ int netlink_attachskb(struct sock *sk, s nlk =nlk_sk (sk); rmem =atomic_add_return (skb->truesize, &sk->sk_rmem_alloc); -if ((rmem == skb->truesize || rmem <READ_ONCE (sk->sk_rcvbuf)) && +if ((rmem == skb->truesize || rmem <=READ_ONCE (sk->sk_rcvbuf)) && !test_bit (NETLINK_S_CONGESTED , &nlk->state)) {netlink_skb_set_owner_r (skb, sk);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 160/403 net: gianfar: fix device leak when querying time stamp info
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit da717540acd34e5056e3fa35791d50f6b3303f55 upstream.
Make sure to drop the reference to the ptp device taken by of_find_device_by_node() when querying the time stamping capabilities.
Note that holding a reference to the ptp device does not prevent its driver data from going away.
--- drivers/net/ethernet/freescale/gianfar_ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +3 -1
@@ -1490,8 +1490,10 @@ static int gfar_get_ts_info(struct net_dif (ptp_node) { ptp_dev =of_find_device_by_node (ptp_node);of_node_put (ptp_node); -if (ptp_dev) +if (ptp_dev) { ptp =platform_get_drvdata (ptp_dev); +put_device (&ptp_dev->dev); + } }if (ptp)
Greg Kroah-Hartman
maintainerPATCH 161/403 net: dpaa: fix device leak when querying time stamp info
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 3fa840230f534385b34a4f39c8dd313fbe723f05 upstream.
Make sure to drop the reference to the ptp device taken by of_find_device_by_node() when querying the time stamping capabilities.
Note that holding a reference to the ptp device does not prevent its driver data from going away.
--- drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c +3 -1
@@ -516,8 +516,10 @@ static int dpaa_get_ts_info(struct net_dof_node_put (ptp_node); } -if (ptp_dev) +if (ptp_dev) { ptp =platform_get_drvdata (ptp_dev); +put_device (&ptp_dev->dev); + }if (ptp) info->phc_index = ptp->phc_index;
Greg Kroah-Hartman
maintainerPATCH 162/403 NFSD: detect mismatch of file handle and delegation stateid in OPEN op
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dai Ngo <[email protected]>
commit 9c65001c57164033ad08b654c8b5ae35512ddf4a upstream.
When the client sends an OPEN with claim type CLAIM_DELEG_CUR_FH or CLAIM_DELEGATION_CUR, the delegation stateid and the file handle must belong to the same file, otherwise return NFS4ERR_INVAL.
Note that RFC8881, section 8.2.4, mandates the server to return NFS4ERR_BAD_STATEID if the selected table entry does not match the current filehandle. However returning NFS4ERR_BAD_STATEID in the OPEN causes the client to retry the operation and therefor get the client into a loop. To avoid this situation we return NFS4ERR_INVAL instead.
--- fs/nfsd/nfs4state.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/nfsd/nfs4state.c +14 -0
@@ -5081,6 +5081,20 @@ nfsd4_process_open2(struct svc_rqst *rqs status =nfs4_check_deleg (cl, open, &dp);if (status) goto out; +if (dp &&nfsd4_is_deleg_cur (open) && + (dp->dl_stid.sc_file != fp)) { +/* +* RFC8881 section 8.2.4 mandates the server to return +* NFS4ERR_BAD_STATEID if the selected table entry does +* not match the current filehandle. However returning +* NFS4ERR_BAD_STATEID in the OPEN can cause the client +* to repeatedly retry the operation with the same +* stateid, since the stateid itself is valid. To avoid +* this situation NFSD returns NFS4ERR_INVAL instead. +*/ + status = nfserr_inval; + goto out; + } stp =nfsd4_find_and_lock_existing_open (fp, open); }else { open->op_file =NULL ;
Greg Kroah-Hartman
maintainerPATCH 163/403 sunvdc: Balance device refcount in vdc_port_mpgroup_check
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 63ce53724637e2e7ba51fe3a4f78351715049905 upstream.
Using device_find_child() to locate a probed virtual-device-port node causes a device refcount imbalance, as device_find_child() internally calls get_device() to increment the device’s reference count before returning its pointer. vdc_port_mpgroup_check() directly returns true upon finding a matching device without releasing the reference via put_device(). We should call put_device() to decrement refcount.
As comment of device_find_child() says, 'NOTE: you will need to drop the reference with put_device() after use'.
Found by code review.
--- drivers/block/sunvdc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/block/sunvdc.c +3 -1
@@ -967,8 +967,10 @@ static bool vdc_port_mpgroup_check(struc dev =device_find_child (vdev->dev.parent, &port_data, vdc_device_probed); -if (dev) +if (dev) { +put_device (dev);return true; + }return false; }
Greg Kroah-Hartman
maintainerPATCH 164/403 fs: Prevent file descriptor table allocations exceeding INT_MAX
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sasha Levin <[email protected]>
commit 04a2c4b4511d186b0fce685da21085a5d4acd370 upstream.
When sysctl_nr_open is set to a very high value (for example, 1073741816 as set by systemd), processes attempting to use file descriptors near the limit can trigger massive memory allocation attempts that exceed INT_MAX, resulting in a WARNING in mm/slub.c:
WARNING: CPU: 0 PID: 44 at mm/slub.c:5027 __kvmalloc_node_noprof+0x21a/0x288
This happens because kvmalloc_array() and kvmalloc() check if the requested size exceeds INT_MAX and emit a warning when the allocation is not flagged with __GFP_NOWARN.
Specifically, when nr_open is set to 1073741816 (0x3ffffff8) and a process calls dup2(oldfd, 1073741880), the kernel attempts to allocate:
- File descriptor array: 1073741880 * 8 bytes = 8,589,935,040 bytes
- Multiple bitmaps: ~400MB
- Total allocation size: > 8GB (exceeding INT_MAX = 2,147,483,647)
Reproducer:
1. Set /proc/sys/fs/nr_open to 1073741816:
# echo 1073741816 > /proc/sys/fs/nr_open
2. Run a program that uses a high file descriptor:
#include <unistd.h>
#include <sys/resource.h>
int main() {
struct rlimit rlim = {1073741824, 1073741824};
setrlimit(RLIMIT_NOFILE, &rlim);
dup2(2, 1073741880); // Triggers the warning
return 0;
}3. Observe WARNING in dmesg at mm/slub.c:5027
systemd commit a8b627a introduced automatic bumping of fs.nr_open to the maximum possible value. The rationale was that systems with memory control groups (memcg) no longer need separate file descriptor limits since memory is properly accounted. However, this change overlooked that:
1. The kernel's allocation functions still enforce INT_MAX as a maximum size regardless of memcg accounting
2. Programs and tests that legitimately test file descriptor limits can inadvertently trigger massive allocations
3. The resulting allocations (>8GB) are impractical and will always fail
systemd's algorithm starts with INT_MAX and keeps halving the value until the kernel accepts it. On most systems, this results in nr_open being set to 1073741816 (0x3ffffff8), which is just under 1GB of file descriptors.
While processes rarely use file descriptors near this limit in normal operation, certain selftests (like tools/testing/selftests/core/unshare_test.c) and programs that test file descriptor limits can trigger this issue.
Fix this by adding a check in alloc_fdtable() to ensure the requested allocation size does not exceed INT_MAX. This causes the operation to fail with -EMFILE instead of triggering a kernel warning and avoids the impractical >8GB memory allocation request.
--- fs/file.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/file.c +15 -0
@@ -104,6 +104,21 @@ static struct fdtable * alloc_fdtable(unif (unlikely (nr > sysctl_nr_open)) nr = ((sysctl_nr_open -1 ) | (BITS_PER_LONG -1 )) +1 ; +/* +* Check if the allocation size would exceed INT_MAX. kvmalloc_array() +* and kvmalloc() will warn if the allocation size is greater than +* INT_MAX, as filp_cachep objects are not __GFP_NOWARN. +* +* This can happen when sysctl_nr_open is set to a very high value and +* a process tries to use a file descriptor near that limit. For example, +* if sysctl_nr_open is set to 1073741816 (0x3ffffff8) - which is what +* systemd typically sets it to - then trying to use a file descriptor +* close to that value will require allocating a file descriptor table +* that exceeds 8GB in size. +*/ +if (unlikely (nr >INT_MAX /sizeof (struct file *))) +return ERR_PTR (-EMFILE ); + fdt =kmalloc (sizeof (struct fdtable ),GFP_KERNEL_ACCOUNT );if (!fdt) goto out;
Greg Kroah-Hartman
maintainerPATCH 165/403 Documentation: ACPI: Fix parent device references
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit e65cb011349e653ded541dddd6469c2ca813edcf upstream.
The _CRS resources in many cases want to have ResourceSource field to be a type of ACPI String. This means that to compile properly we need to enclosure the name path into double quotes. This will in practice defer the interpretation to a run-time stage, However, this may be interpreted differently on different OSes and ACPI interpreter implementations. In particular ACPICA might not correctly recognize the leading '^' (caret) character and will not resolve the relative name path properly. On top of that, this piece may be used in SSDTs which are loaded after the DSDT and on itself may also not resolve relative name paths outside of their own scopes. With this all said, fix documentation to use fully-qualified name paths always to avoid any misinterpretations, which is proven to work.
--- Documentation/firmware-guide/acpi/i2c-muxes.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/firmware-guide/acpi/i2c-muxes.rst +4 -4
@@ -14,7 +14,7 @@ Consider this topology:: | | | 0x70 |--CH01--> i2c client B (0x50) +------+ +------+ -which corresponds to the following ASL:: +which corresponds to the following ASL (in the scope of \_SB):: Device (SMB1) {
@@ -24,7 +24,7 @@ which corresponds to the following ASL:: Name (_HID, ...) Name (_CRS, ResourceTemplate () { I2cSerialBus (0x70, ControllerInitiated, I2C_SPEED, - AddressingMode7Bit, "^SMB1", 0x00, + AddressingMode7Bit, "\\_SB.SMB1", 0x00, ResourceConsumer,,) }
@@ -37,7 +37,7 @@ which corresponds to the following ASL:: Name (_HID, ...) Name (_CRS, ResourceTemplate () { I2cSerialBus (0x50, ControllerInitiated, I2C_SPEED, - AddressingMode7Bit, "^CH00", 0x00, + AddressingMode7Bit, "\\_SB.SMB1.CH00", 0x00, ResourceConsumer,,) } }
@@ -52,7 +52,7 @@ which corresponds to the following ASL:: Name (_HID, ...) Name (_CRS, ResourceTemplate () { I2cSerialBus (0x50, ControllerInitiated, I2C_SPEED, - AddressingMode7Bit, "^CH01", 0x00, + AddressingMode7Bit, "\\_SB.SMB1.CH01", 0x00, ResourceConsumer,,) } }
Greg Kroah-Hartman
maintainerPATCH 166/403 ACPI: processor: perflib: Fix initial _PPC limit application
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayi Li <[email protected]>
commit d33bd88ac0ebb49e7f7c8f29a8c7ee9eae85d765 upstream.
If the BIOS sets a _PPC frequency limit upfront, it will fail to take effect due to a call ordering issue. Namely, freq_qos_update_request() is called before freq_qos_add_request() for the given request causing the constraint update to be ignored. The call sequence in question is as follows:
cpufreq_policy_online()
acpi_cpufreq_cpu_init()
acpi_processor_register_performance()
acpi_processor_get_performance_info()
acpi_processor_get_platform_limit()
freq_qos_update_request(&perflib_req) <- inactive QoS request
blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
CPUFREQ_CREATE_POLICY)
acpi_processor_notifier()
acpi_processor_ppc_init()
freq_qos_add_request(&perflib_req) <- QoS request activation
Address this by adding an acpi_processor_get_platform_limit() call to acpi_processor_ppc_init(), after the perflib_req activation via freq_qos_add_request(), which causes the initial _PPC limit to be picked up as appropriate. However, also ensure that the _PPC limit will not be picked up in the cases when the cpufreq driver does not call acpi_processor_register_performance() by adding a pr->performance check to the related_cpus loop in acpi_processor_ppc_init().
--- drivers/acpi/processor_perflib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/acpi/processor_perflib.c +9 -1
@@ -176,11 +176,14 @@ void acpi_processor_ppc_init(struct cpuf {unsigned int cpu; +if (ignore_ppc ==1 ) +return ; +for_each_cpu (cpu, policy->related_cpus) {struct acpi_processor *pr =per_cpu (processors, cpu);int ret; -if (!pr) +if (!pr || !pr->performance)continue ;/*
@@ -196,6 +199,11 @@ void acpi_processor_ppc_init(struct cpufif (ret <0 )pr_err ("Failed to add freq constraint for CPU%d (%d)\n" , cpu, ret); + + ret =acpi_processor_get_platform_limit (pr); +if (ret) +pr_err ("Failed to update freq constraint for CPU%d (%d)\n" , + cpu, ret); } }
Greg Kroah-Hartman
maintainerPATCH 167/403 ACPI: processor: perflib: Move problematic pr->performance check
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit d405ec23df13e6df599f5bd965a55d13420366b8 upstream.
Commit d33bd88ac0eb ("ACPI: processor: perflib: Fix initial _PPC limit application") added a pr->performance check that prevents the frequency QoS request from being added when the given processor has no performance object. Unfortunately, this causes a WARN() in freq_qos_remove_request() to trigger on an attempt to take the given CPU offline later because the frequency QoS object has not been added for it due to the missing performance object.
Address this by moving the pr->performance check before calling acpi_processor_get_platform_limit() so it only prevents a limit from being set for the CPU if the performance object is not present. This way, the frequency QoS request is added as it was before the above commit and it is present all the time along with the CPU's cpufreq policy regardless of whether or not the CPU is online.
--- drivers/acpi/processor_perflib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/acpi/processor_perflib.c +4 -1
@@ -183,7 +183,7 @@ void acpi_processor_ppc_init(struct cpufstruct acpi_processor *pr =per_cpu (processors, cpu);int ret; -if (!pr || !pr->performance) +if (!pr)continue ;/*
@@ -200,6 +200,9 @@ void acpi_processor_ppc_init(struct cpufpr_err ("Failed to add freq constraint for CPU%d (%d)\n" , cpu, ret); +if (!pr->performance) +continue ; + ret =acpi_processor_get_platform_limit (pr);if (ret) pr_err("Failed to update freq constraint for CPU%d (%d)\n",
Greg Kroah-Hartman
maintainerPATCH 168/403 udp: also consider secpath when evaluating ipsec use for checksumming
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 1118aaa3b35157777890fffab91d8c1da841b20b ]
Commit b40c5f4fde22 ("udp: disable inner UDP checksum offloads in IPsec case") tried to fix checksumming in UFO when the packets are going through IPsec, so that we can't rely on offloads because the UDP header and payload will be encrypted.
But when doing a TCP test over VXLAN going through IPsec transport mode with GSO enabled (esp4_offload module loaded), I'm seeing broken UDP checksums on the encap after successful decryption.
The skbs get to udp4_ufo_fragment/__skb_udp_tunnel_segment via __dev_queue_xmit -> validate_xmit_skb -> skb_gso_segment and at this point we've already dropped the dst (unless the device sets IFF_XMIT_DST_RELEASE, which is not common), so need_ipsec is false and we proceed with checksum offload.
Make need_ipsec also check the secpath, which is not dropped on this callpath.
--- net/ipv4/udp_offload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/udp_offload.c +1 -1
@@ -58,7 +58,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb, remcsum = !!(skb_shinfo (skb)->gso_type &SKB_GSO_TUNNEL_REMCSUM ); skb->remcsum_offload = remcsum; - need_ipsec =skb_dst (skb) &&dst_xfrm (skb_dst (skb)); + need_ipsec = (skb_dst (skb) &&dst_xfrm (skb_dst (skb))) ||skb_sec_path (skb);/* Try to offload checksum if possible */ offload_csum = !!(need_csum && !need_ipsec &&
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 169/403 netfilter: ctnetlink: fix refcount leak on table dump
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit de788b2e6227462b6dcd0e07474e72c089008f74 ]
There is a reference count leak in ctnetlink_dump_table():
if (res < 0) {
nf_conntrack_get(&ct->ct_general); // HERE
cb->args[1] = (unsigned long)ct;
...While its very unlikely, its possible that ct == last. If this happens, then the refcount of ct was already incremented. This 2nd increment is never undone.
This prevents the conntrack object from being released, which in turn keeps prevents cnet->count from dropping back to 0.
This will then block the netns dismantle (or conntrack rmmod) as nf_conntrack_cleanup_net_list() will wait forever.
This can be reproduced by running conntrack_resize.sh selftest in a loop. It takes ~20 minutes for me on a preemptible kernel on average before I see a runaway kworker spinning in nf_conntrack_cleanup_net_list.
One fix would to change this to:
if (res < 0) {
if (ct != last)
nf_conntrack_get(&ct->ct_general);But this reference counting isn't needed in the first place. We can just store a cookie value instead.
A followup patch will do the same for ctnetlink_exp_dump_table, it looks to me as if this has the same problem and like ctnetlink_dump_table, we only need a 'skip hint', not the actual object so we can apply the same cookie strategy there as well.
--- net/netfilter/nf_conntrack_netlink.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
net/netfilter/nf_conntrack_netlink.c +13 -11
@@ -808,8 +808,6 @@ ctnetlink_conntrack_event(unsigned int events, struct nf_ct_event *item)static int ctnetlink_done (struct netlink_callback *cb) { -if (cb->args[1 ]) -nf_ct_put ((struct nf_conn *)cb->args[1 ]);kfree (cb->data);return 0 ; }
@@ -890,18 +888,25 @@ static int ctnetlink_filter_match(struct nf_conn *ct, void *data)return 0 ; } +static unsigned long ctnetlink_get_id (const struct nf_conn *ct) +{ +unsigned long id =nf_ct_get_id (ct); + +return id ? id :1 ; +} +static int ctnetlink_dump_table (struct sk_buff *skb,struct netlink_callback *cb) {struct net *net =sock_net (skb->sk); -struct nf_conn *ct, *last; +unsigned long last_id = cb->args[1 ];struct nf_conntrack_tuple_hash *h;struct hlist_nulls_node *n;struct nf_conn *nf_ct_evict[8 ]; +struct nf_conn *ct;int res, i;spinlock_t *lockp; - last = (struct nf_conn *)cb->args[1 ]; i =0 ;local_bh_disable ();
@@ -936,7 +941,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)continue ;if (cb->args[1 ]) { -if (ct != last) +if (ctnetlink_get_id (ct) != last_id)continue ; cb->args[1 ] =0 ; }
@@ -951,8 +956,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) ct);rcu_read_unlock ();if (res <0 ) { -nf_conntrack_get (&ct->ct_general); - cb->args[1 ] = (unsigned long )ct; + cb->args[1 ] =ctnetlink_get_id (ct);spin_unlock (lockp); goto out; }
@@ -965,12 +969,10 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) } out:local_bh_enable (); -if (last) { +if (last_id) {/* nf ct hash resize happened, now clear the leftover. */ -if ((struct nf_conn *)cb->args[1 ] == last) +if (cb->args[1 ] == last_id) cb->args[1 ] =0 ; - -nf_ct_put (last); }while (i) {
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 170/403 sctp: linearize cloned gso packets in sctp_rcv
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit fd60d8a086191fe33c2d719732d2482052fa6805 ]
A cloned head skb still shares these frag skbs in fraglist with the original head skb. It's not safe to access these frag skbs.
syzbot reported two use-of-uninitialized-memory bugs caused by this:
BUG: KMSAN: uninit-value in sctp_inq_pop+0x15b7/0x1920 net/sctp/inqueue.c:211 sctp_inq_pop+0x15b7/0x1920 net/sctp/inqueue.c:211 sctp_assoc_bh_rcv+0x1a7/0xc50 net/sctp/associola.c:998 sctp_inq_push+0x2ef/0x380 net/sctp/inqueue.c:88 sctp_backlog_rcv+0x397/0xdb0 net/sctp/input.c:331 sk_backlog_rcv+0x13b/0x420 include/net/sock.h:1122 __release_sock+0x1da/0x330 net/core/sock.c:3106 release_sock+0x6b/0x250 net/core/sock.c:3660 sctp_wait_for_connect+0x487/0x820 net/sctp/socket.c:9360 sctp_sendmsg_to_asoc+0x1ec1/0x1f00 net/sctp/socket.c:1885 sctp_sendmsg+0x32b9/0x4a80 net/sctp/socket.c:2031 inet_sendmsg+0x25a/0x280 net/ipv4/af_inet.c:851 sock_sendmsg_nosec net/socket.c:718 [inline]
and
BUG: KMSAN: uninit-value in sctp_assoc_bh_rcv+0x34e/0xbc0 net/sctp/associola.c:987 sctp_assoc_bh_rcv+0x34e/0xbc0 net/sctp/associola.c:987 sctp_inq_push+0x2a3/0x350 net/sctp/inqueue.c:88 sctp_backlog_rcv+0x3c7/0xda0 net/sctp/input.c:331 sk_backlog_rcv+0x142/0x420 include/net/sock.h:1148 __release_sock+0x1d3/0x330 net/core/sock.c:3213 release_sock+0x6b/0x270 net/core/sock.c:3767 sctp_wait_for_connect+0x458/0x820 net/sctp/socket.c:9367 sctp_sendmsg_to_asoc+0x223a/0x2260 net/sctp/socket.c:1886 sctp_sendmsg+0x3910/0x49f0 net/sctp/socket.c:2032 inet_sendmsg+0x269/0x2a0 net/ipv4/af_inet.c:851 sock_sendmsg_nosec net/socket.c:712 [inline]
This patch fixes it by linearizing cloned gso packets in sctp_rcv().
--- net/sctp/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/input.c +1 -1
@@ -114,7 +114,7 @@ int sctp_rcv(struct sk_buff *skb)* it's better to just linearize it otherwise crc computing * takes longer. */ -if ((!is_gso &&skb_linearize (skb)) || +if (((!is_gso ||skb_cloned (skb)) &&skb_linearize (skb)) || !pskb_may_pull (skb,sizeof (struct sctphdr ))) goto discard_it;
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 171/403 hfs: fix slab-out-of-bounds in hfs_bnode_read()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viacheslav Dubeyko <[email protected]>
[ Upstream commit a431930c9bac518bf99d6b1da526a7f37ddee8d8 ]
This patch introduces is_bnode_offset_valid() method that checks the requested offset value. Also, it introduces check_and_correct_requested_length() method that checks and correct the requested length (if it is necessary). These methods are used in hfs_bnode_read(), hfs_bnode_write(), hfs_bnode_clear(), hfs_bnode_copy(), and hfs_bnode_move() with the goal to prevent the access out of allocated memory and triggering the crash.
--- fs/hfs/bnode.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
fs/hfs/bnode.c +92 -0
@@ -15,6 +15,48 @@#include "btree.h" +static inline +bool is_bnode_offset_valid (struct hfs_bnode *node,int off) +{ +bool is_valid = off < node->tree->node_size; + +if (!is_valid) { +pr_err ("requested invalid offset: " +"NODE: id %u, type %#x, height %u, " +"node_size %u, offset %d\n" , + node->this, node->type, node->height, + node->tree->node_size, off); + } + +return is_valid; +} + +static inline +int check_and_correct_requested_length (struct hfs_bnode *node,int off,int len) +{ +unsigned int node_size; + +if (!is_bnode_offset_valid (node, off)) +return 0 ; + + node_size = node->tree->node_size; + +if ((off + len) > node_size) { +int new_len = (int )node_size - off; + +pr_err ("requested length has been corrected: " +"NODE: id %u, type %#x, height %u, " +"node_size %u, offset %d, " +"requested_len %d, corrected_len %d\n" , + node->this, node->type, node->height, + node->tree->node_size, off, len, new_len); + +return new_len; + } + +return len; +} +void hfs_bnode_read (struct hfs_bnode *node,void *buf,int off,int len) {struct page *page;
@@ -23,6 +65,20 @@ void hfs_bnode_read(struct hfs_bnode *node, void *buf, int off, int len)int bytes_to_read;void *vaddr; +if (!is_bnode_offset_valid (node, off)) +return ; + +if (len ==0 ) { +pr_err ("requested zero length: " +"NODE: id %u, type %#x, height %u, " +"node_size %u, offset %d, len %d\n" , + node->this, node->type, node->height, + node->tree->node_size, off, len); +return ; + } + + len =check_and_correct_requested_length (node, off, len); + off += node->page_offset; pagenum = off >>PAGE_SHIFT ; off &= ~PAGE_MASK ;/* compute page offset for the first page */
@@ -83,6 +139,20 @@ void hfs_bnode_write(struct hfs_bnode *node, void *buf, int off, int len) {struct page *page; +if (!is_bnode_offset_valid (node, off)) +return ; + +if (len ==0 ) { +pr_err ("requested zero length: " +"NODE: id %u, type %#x, height %u, " +"node_size %u, offset %d, len %d\n" , + node->this, node->type, node->height, + node->tree->node_size, off, len); +return ; + } + + len =check_and_correct_requested_length (node, off, len); + off += node->page_offset; page = node->page[0 ];
@@ -108,6 +178,20 @@ void hfs_bnode_clear(struct hfs_bnode *node, int off, int len) {struct page *page; +if (!is_bnode_offset_valid (node, off)) +return ; + +if (len ==0 ) { +pr_err ("requested zero length: " +"NODE: id %u, type %#x, height %u, " +"node_size %u, offset %d, len %d\n" , + node->this, node->type, node->height, + node->tree->node_size, off, len); +return ; + } + + len =check_and_correct_requested_length (node, off, len); + off += node->page_offset; page = node->page[0 ];
@@ -124,6 +208,10 @@ void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst,hfs_dbg (BNODE_MOD ,"copybytes: %u,%u,%u\n" , dst, src, len);if (!len)return ; + + len =check_and_correct_requested_length (src_node, src, len); + len =check_and_correct_requested_length (dst_node, dst, len); + src += src_node->page_offset; dst += dst_node->page_offset; src_page = src_node->page[0 ];
@@ -143,6 +231,10 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len)hfs_dbg (BNODE_MOD ,"movebytes: %u,%u,%u\n" , dst, src, len);if (!len)return ; + + len =check_and_correct_requested_length (node, src, len); + len =check_and_correct_requested_length (node, dst, len); + src += node->page_offset; dst += node->page_offset; page = node->page[0 ];
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 172/403 hfsplus: fix slab-out-of-bounds in hfsplus_bnode_read()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viacheslav Dubeyko <[email protected]>
[ Upstream commit c80aa2aaaa5e69d5219c6af8ef7e754114bd08d2 ]
The hfsplus_bnode_read() method can trigger the issue:
[ 174.852007][ T9784] ================================================================== [ 174.852709][ T9784] BUG: KASAN: slab-out-of-bounds in hfsplus_bnode_read+0x2f4/0x360 [ 174.853412][ T9784] Read of size 8 at addr ffff88810b5fc6c0 by task repro/9784 [ 174.854059][ T9784] [ 174.854272][ T9784] CPU: 1 UID: 0 PID: 9784 Comm: repro Not tainted 6.16.0-rc3 #7 PREEMPT(full) [ 174.854281][ T9784] Hardware name: QEMU Ubuntu 24.04 PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 174.854286][ T9784] Call Trace: [ 174.854289][ T9784] <TASK> [ 174.854292][ T9784] dump_stack_lvl+0x10e/0x1f0 [ 174.854305][ T9784] print_report+0xd0/0x660 [ 174.854315][ T9784] ? __virt_addr_valid+0x81/0x610 [ 174.854323][ T9784] ? __phys_addr+0xe8/0x180 [ 174.854330][ T9784] ? hfsplus_bnode_read+0x2f4/0x360 [ 174.854337][ T9784] kasan_report+0xc6/0x100 [ 174.854346][ T9784] ? hfsplus_bnode_read+0x2f4/0x360 [ 174.854354][ T9784] hfsplus_bnode_read+0x2f4/0x360 [ 174.854362][ T9784] hfsplus_bnode_dump+0x2ec/0x380 [ 174.854370][ T9784] ? __pfx_hfsplus_bnode_dump+0x10/0x10 [ 174.854377][ T9784] ? hfsplus_bnode_write_u16+0x83/0xb0 [ 174.854385][ T9784] ? srcu_gp_start+0xd0/0x310 [ 174.854393][ T9784] ? __mark_inode_dirty+0x29e/0xe40 [ 174.854402][ T9784] hfsplus_brec_remove+0x3d2/0x4e0 [ 174.854411][ T9784] __hfsplus_delete_attr+0x290/0x3a0 [ 174.854419][ T9784] ? __pfx_hfs_find_1st_rec_by_cnid+0x10/0x10 [ 174.854427][ T9784] ? __pfx___hfsplus_delete_attr+0x10/0x10 [ 174.854436][ T9784] ? __asan_memset+0x23/0x50 [ 174.854450][ T9784] hfsplus_delete_all_attrs+0x262/0x320 [ 174.854459][ T9784] ? __pfx_hfsplus_delete_all_attrs+0x10/0x10 [ 174.854469][ T9784] ? rcu_is_watching+0x12/0xc0 [ 174.854476][ T9784] ? __mark_inode_dirty+0x29e/0xe40 [ 174.854483][ T9784] hfsplus_delete_cat+0x845/0xde0 [ 174.854493][ T9784] ? __pfx_hfsplus_delete_cat+0x10/0x10 [ 174.854507][ T9784] hfsplus_unlink+0x1ca/0x7c0 [ 174.854516][ T9784] ? __pfx_hfsplus_unlink+0x10/0x10 [ 174.854525][ T9784] ? down_write+0x148/0x200 [ 174.854532][ T9784] ? __pfx_down_write+0x10/0x10 [ 174.854540][ T9784] vfs_unlink+0x2fe/0x9b0 [ 174.854549][ T9784] do_unlinkat+0x490/0x670 [ 174.854557][ T9784] ? __pfx_do_unlinkat+0x10/0x10 [ 174.854565][ T9784] ? __might_fault+0xbc/0x130 [ 174.854576][ T9784] ? getname_flags.part.0+0x1c5/0x550 [ 174.854584][ T9784] __x64_sys_unlink+0xc5/0x110 [ 174.854592][ T9784] do_syscall_64+0xc9/0x480 [ 174.854600][ T9784] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 174.854608][ T9784] RIP: 0033:0x7f6fdf4c3167 [ 174.854614][ T9784] Code: f0 ff ff 73 01 c3 48 8b 0d 26 0d 0e 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 08 [ 174.854622][ T9784] RSP: 002b:00007ffcb948bca8 EFLAGS: 00000206 ORIG_RAX: 0000000000000057 [ 174.854630][ T9784] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f6fdf4c3167 [ 174.854636][ T9784] RDX: 00007ffcb948bcc0 RSI: 00007ffcb948bcc0 RDI: 00007ffcb948bd50 [ 174.854641][ T9784] RBP: 00007ffcb948cd90 R08: 0000000000000001 R09: 00007ffcb948bb40 [ 174.854645][ T9784] R10: 00007f6fdf564fc0 R11: 0000000000000206 R12: 0000561e1bc9c2d0 [ 174.854650][ T9784] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 [ 174.854658][ T9784] </TASK> [ 174.854661][ T9784] [ 174.879281][ T9784] Allocated by task 9784: [ 174.879664][ T9784] kasan_save_stack+0x20/0x40 [ 174.880082][ T9784] kasan_save_track+0x14/0x30 [ 174.880500][ T9784] __kasan_kmalloc+0xaa/0xb0 [ 174.880908][ T9784] __kmalloc_noprof+0x205/0x550 [ 174.881337][ T9784] __hfs_bnode_create+0x107/0x890 [ 174.881779][ T9784] hfsplus_bnode_find+0x2d0/0xd10 [ 174.882222][ T9784] hfsplus_brec_find+0x2b0/0x520 [ 174.882659][ T9784] hfsplus_delete_all_attrs+0x23b/0x320 [ 174.883144][ T9784] hfsplus_delete_cat+0x845/0xde0 [ 174.883595][ T9784] hfsplus_rmdir+0x106/0x1b0 [ 174.884004][ T9784] vfs_rmdir+0x206/0x690 [ 174.884379][ T9784] do_rmdir+0x2b7/0x390 [ 174.884751][ T9784] __x64_sys_rmdir+0xc5/0x110 [ 174.885167][ T9784] do_syscall_64+0xc9/0x480 [ 174.885568][ T9784] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 174.886083][ T9784] [ 174.886293][ T9784] The buggy address belongs to the object at ffff88810b5fc600 [ 174.886293][ T9784] which belongs to the cache kmalloc-192 of size 192 [ 174.887507][ T9784] The buggy address is located 40 bytes to the right of [ 174.887507][ T9784] allocated 152-byte region [ffff88810b5fc600, ffff88810b5fc698) [ 174.888766][ T9784] [ 174.888976][ T9784] The buggy address belongs to the physical page: [ 174.889533][ T9784] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10b5fc [ 174.890295][ T9784] flags: 0x57ff00000000000(node=1|zone=2|lastcpupid=0x7ff) [ 174.890927][ T9784] page_type: f5(slab) [ 174.891284][ T9784] raw: 057ff00000000000 ffff88801b4423c0 ffffea000426dc80 dead000000000002 [ 174.892032][ T9784] raw: 0000000000000000 0000000080100010 00000000f5000000 0000000000000000 [ 174.892774][ T9784] page dumped because: kasan: bad access detected [ 174.893327][ T9784] page_owner tracks the page as allocated [ 174.893825][ T9784] page last allocated via order 0, migratetype Unmovable, gfp_mask 0x52c00(GFP_NOIO|__GFP_NOWARN|__GFP_NO1 [ 174.895373][ T9784] post_alloc_hook+0x1c0/0x230 [ 174.895801][ T9784] get_page_from_freelist+0xdeb/0x3b30 [ 174.896284][ T9784] __alloc_frozen_pages_noprof+0x25c/0x2460 [ 174.896810][ T9784] alloc_pages_mpol+0x1fb/0x550 [ 174.897242][ T9784] new_slab+0x23b/0x340 [ 174.897614][ T9784] ___slab_alloc+0xd81/0x1960 [ 174.898028][ T9784] __slab_alloc.isra.0+0x56/0xb0 [ 174.898468][ T9784] __kmalloc_noprof+0x2b0/0x550 [ 174.898896][ T9784] usb_alloc_urb+0x73/0xa0 [ 174.899289][ T9784] usb_control_msg+0x1cb/0x4a0 [ 174.899718][ T9784] usb_get_string+0xab/0x1a0 [ 174.900133][ T9784] usb_string_sub+0x107/0x3c0 [ 174.900549][ T9784] usb_string+0x307/0x670 [ 174.900933][ T9784] usb_cache_string+0x80/0x150 [ 174.901355][ T9784] usb_new_device+0x1d0/0x19d0 [ 174.901786][ T9784] register_root_hub+0x299/0x730 [ 174.902231][ T9784] page last free pid 10 tgid 10 stack trace: [ 174.902757][ T9784] __free_frozen_pages+0x80c/0x1250 [ 174.903217][ T9784] vfree.part.0+0x12b/0xab0 [ 174.903645][ T9784] delayed_vfree_work+0x93/0xd0 [ 174.904073][ T9784] process_one_work+0x9b5/0x1b80 [ 174.904519][ T9784] worker_thread+0x630/0xe60 [ 174.904927][ T9784] kthread+0x3a8/0x770 [ 174.905291][ T9784] ret_from_fork+0x517/0x6e0 [ 174.905709][ T9784] ret_from_fork_asm+0x1a/0x30 [ 174.906128][ T9784] [ 174.906338][ T9784] Memory state around the buggy address: [ 174.906828][ T9784] ffff88810b5fc580: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc [ 174.907528][ T9784] ffff88810b5fc600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 174.908222][ T9784] >ffff88810b5fc680: 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc [ 174.908917][ T9784] ^ [ 174.909481][ T9784] ffff88810b5fc700: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 174.910432][ T9784] ffff88810b5fc780: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc [ 174.911401][ T9784] ==================================================================
The reason of the issue that code doesn't check the correctness of the requested offset and length. As a result, incorrect value of offset or/and length could result in access out of allocated memory.
This patch introduces is_bnode_offset_valid() method that checks the requested offset value. Also, it introduces check_and_correct_requested_length() method that checks and correct the requested length (if it is necessary). These methods are used in hfsplus_bnode_read(), hfsplus_bnode_write(), hfsplus_bnode_clear(), hfsplus_bnode_copy(), and hfsplus_bnode_move() with the goal to prevent the access out of allocated memory and triggering the crash.
--- fs/hfsplus/bnode.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
fs/hfsplus/bnode.c +92 -0
@@ -18,12 +18,68 @@#include "hfsplus_fs.h" #include "hfsplus_raw.h" +static inline +bool is_bnode_offset_valid (struct hfs_bnode *node,int off) +{ +bool is_valid = off < node->tree->node_size; + +if (!is_valid) { +pr_err ("requested invalid offset: " +"NODE: id %u, type %#x, height %u, " +"node_size %u, offset %d\n" , + node->this, node->type, node->height, + node->tree->node_size, off); + } + +return is_valid; +} + +static inline +int check_and_correct_requested_length (struct hfs_bnode *node,int off,int len) +{ +unsigned int node_size; + +if (!is_bnode_offset_valid (node, off)) +return 0 ; + + node_size = node->tree->node_size; + +if ((off + len) > node_size) { +int new_len = (int )node_size - off; + +pr_err ("requested length has been corrected: " +"NODE: id %u, type %#x, height %u, " +"node_size %u, offset %d, " +"requested_len %d, corrected_len %d\n" , + node->this, node->type, node->height, + node->tree->node_size, off, len, new_len); + +return new_len; + } + +return len; +} +/* Copy a specified range of bytes from the raw data of a node */ void hfs_bnode_read (struct hfs_bnode *node,void *buf,int off,int len) {struct page **pagep;int l; +if (!is_bnode_offset_valid (node, off)) +return ; + +if (len ==0 ) { +pr_err ("requested zero length: " +"NODE: id %u, type %#x, height %u, " +"node_size %u, offset %d, len %d\n" , + node->this, node->type, node->height, + node->tree->node_size, off, len); +return ; + } + + len =check_and_correct_requested_length (node, off, len); + off += node->page_offset; pagep = node->page + (off >>PAGE_SHIFT ); off &= ~PAGE_MASK ;
@@ -83,6 +139,20 @@ void hfs_bnode_write(struct hfs_bnode *node, void *buf, int off, int len)struct page **pagep;int l; +if (!is_bnode_offset_valid (node, off)) +return ; + +if (len ==0 ) { +pr_err ("requested zero length: " +"NODE: id %u, type %#x, height %u, " +"node_size %u, offset %d, len %d\n" , + node->this, node->type, node->height, + node->tree->node_size, off, len); +return ; + } + + len =check_and_correct_requested_length (node, off, len); + off += node->page_offset; pagep = node->page + (off >>PAGE_SHIFT ); off &= ~PAGE_MASK ;
@@ -113,6 +183,20 @@ void hfs_bnode_clear(struct hfs_bnode *node, int off, int len)struct page **pagep;int l; +if (!is_bnode_offset_valid (node, off)) +return ; + +if (len ==0 ) { +pr_err ("requested zero length: " +"NODE: id %u, type %#x, height %u, " +"node_size %u, offset %d, len %d\n" , + node->this, node->type, node->height, + node->tree->node_size, off, len); +return ; + } + + len =check_and_correct_requested_length (node, off, len); + off += node->page_offset; pagep = node->page + (off >>PAGE_SHIFT ); off &= ~PAGE_MASK ;
@@ -139,6 +223,10 @@ void hfs_bnode_copy(struct hfs_bnode *dst_node, int dst,hfs_dbg (BNODE_MOD ,"copybytes: %u,%u,%u\n" , dst, src, len);if (!len)return ; + + len =check_and_correct_requested_length (src_node, src, len); + len =check_and_correct_requested_length (dst_node, dst, len); + src += src_node->page_offset; dst += dst_node->page_offset; src_page = src_node->page + (src >>PAGE_SHIFT );
@@ -196,6 +284,10 @@ void hfs_bnode_move(struct hfs_bnode *node, int dst, int src, int len)hfs_dbg (BNODE_MOD ,"movebytes: %u,%u,%u\n" , dst, src, len);if (!len)return ; + + len =check_and_correct_requested_length (node, src, len); + len =check_and_correct_requested_length (node, dst, len); + src += node->page_offset; dst += node->page_offset;if (dst > src) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 173/403 hfsplus: fix slab-out-of-bounds read in hfsplus_uni2asc()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viacheslav Dubeyko <[email protected]>
[ Upstream commit 94458781aee6045bd3d0ad4b80b02886b9e2219b ]
The hfsplus_readdir() method is capable to crash by calling hfsplus_uni2asc():
[ 667.121659][ T9805] ================================================================== [ 667.122651][ T9805] BUG: KASAN: slab-out-of-bounds in hfsplus_uni2asc+0x902/0xa10 [ 667.123627][ T9805] Read of size 2 at addr ffff88802592f40c by task repro/9805 [ 667.124578][ T9805] [ 667.124876][ T9805] CPU: 3 UID: 0 PID: 9805 Comm: repro Not tainted 6.16.0-rc3 #1 PREEMPT(full) [ 667.124886][ T9805] Hardware name: QEMU Ubuntu 24.04 PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 [ 667.124890][ T9805] Call Trace: [ 667.124893][ T9805] <TASK> [ 667.124896][ T9805] dump_stack_lvl+0x10e/0x1f0 [ 667.124911][ T9805] print_report+0xd0/0x660 [ 667.124920][ T9805] ? __virt_addr_valid+0x81/0x610 [ 667.124928][ T9805] ? __phys_addr+0xe8/0x180 [ 667.124934][ T9805] ? hfsplus_uni2asc+0x902/0xa10 [ 667.124942][ T9805] kasan_report+0xc6/0x100 [ 667.124950][ T9805] ? hfsplus_uni2asc+0x902/0xa10 [ 667.124959][ T9805] hfsplus_uni2asc+0x902/0xa10 [ 667.124966][ T9805] ? hfsplus_bnode_read+0x14b/0x360 [ 667.124974][ T9805] hfsplus_readdir+0x845/0xfc0 [ 667.124984][ T9805] ? __pfx_hfsplus_readdir+0x10/0x10 [ 667.124994][ T9805] ? stack_trace_save+0x8e/0xc0 [ 667.125008][ T9805] ? iterate_dir+0x18b/0xb20 [ 667.125015][ T9805] ? trace_lock_acquire+0x85/0xd0 [ 667.125022][ T9805] ? lock_acquire+0x30/0x80 [ 667.125029][ T9805] ? iterate_dir+0x18b/0xb20 [ 667.125037][ T9805] ? down_read_killable+0x1ed/0x4c0 [ 667.125044][ T9805] ? putname+0x154/0x1a0 [ 667.125051][ T9805] ? __pfx_down_read_killable+0x10/0x10 [ 667.125058][ T9805] ? apparmor_file_permission+0x239/0x3e0 [ 667.125069][ T9805] iterate_dir+0x296/0xb20 [ 667.125076][ T9805] __x64_sys_getdents64+0x13c/0x2c0 [ 667.125084][ T9805] ? __pfx___x64_sys_getdents64+0x10/0x10 [ 667.125091][ T9805] ? __x64_sys_openat+0x141/0x200 [ 667.125126][ T9805] ? __pfx_filldir64+0x10/0x10 [ 667.125134][ T9805] ? do_user_addr_fault+0x7fe/0x12f0 [ 667.125143][ T9805] do_syscall_64+0xc9/0x480 [ 667.125151][ T9805] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 667.125158][ T9805] RIP: 0033:0x7fa8753b2fc9 [ 667.125164][ T9805] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 48 [ 667.125172][ T9805] RSP: 002b:00007ffe96f8e0f8 EFLAGS: 00000217 ORIG_RAX: 00000000000000d9 [ 667.125181][ T9805] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fa8753b2fc9 [ 667.125185][ T9805] RDX: 0000000000000400 RSI: 00002000000063c0 RDI: 0000000000000004 [ 667.125190][ T9805] RBP: 00007ffe96f8e110 R08: 00007ffe96f8e110 R09: 00007ffe96f8e110 [ 667.125195][ T9805] R10: 0000000000000000 R11: 0000000000000217 R12: 0000556b1e3b4260 [ 667.125199][ T9805] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 [ 667.125207][ T9805] </TASK> [ 667.125210][ T9805] [ 667.145632][ T9805] Allocated by task 9805: [ 667.145991][ T9805] kasan_save_stack+0x20/0x40 [ 667.146352][ T9805] kasan_save_track+0x14/0x30 [ 667.146717][ T9805] __kasan_kmalloc+0xaa/0xb0 [ 667.147065][ T9805] __kmalloc_noprof+0x205/0x550 [ 667.147448][ T9805] hfsplus_find_init+0x95/0x1f0 [ 667.147813][ T9805] hfsplus_readdir+0x220/0xfc0 [ 667.148174][ T9805] iterate_dir+0x296/0xb20 [ 667.148549][ T9805] __x64_sys_getdents64+0x13c/0x2c0 [ 667.148937][ T9805] do_syscall_64+0xc9/0x480 [ 667.149291][ T9805] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 667.149809][ T9805] [ 667.150030][ T9805] The buggy address belongs to the object at ffff88802592f000 [ 667.150030][ T9805] which belongs to the cache kmalloc-2k of size 2048 [ 667.151282][ T9805] The buggy address is located 0 bytes to the right of [ 667.151282][ T9805] allocated 1036-byte region [ffff88802592f000, ffff88802592f40c) [ 667.152580][ T9805] [ 667.152798][ T9805] The buggy address belongs to the physical page: [ 667.153373][ T9805] page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x25928 [ 667.154157][ T9805] head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 [ 667.154916][ T9805] anon flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff) [ 667.155631][ T9805] page_type: f5(slab) [ 667.155997][ T9805] raw: 00fff00000000040 ffff88801b442f00 0000000000000000 dead000000000001 [ 667.156770][ T9805] raw: 0000000000000000 0000000080080008 00000000f5000000 0000000000000000 [ 667.157536][ T9805] head: 00fff00000000040 ffff88801b442f00 0000000000000000 dead000000000001 [ 667.158317][ T9805] head: 0000000000000000 0000000080080008 00000000f5000000 0000000000000000 [ 667.159088][ T9805] head: 00fff00000000003 ffffea0000964a01 00000000ffffffff 00000000ffffffff [ 667.159865][ T9805] head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008 [ 667.160643][ T9805] page dumped because: kasan: bad access detected [ 667.161216][ T9805] page_owner tracks the page as allocated [ 667.161732][ T9805] page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN9 [ 667.163566][ T9805] post_alloc_hook+0x1c0/0x230 [ 667.164003][ T9805] get_page_from_freelist+0xdeb/0x3b30 [ 667.164503][ T9805] __alloc_frozen_pages_noprof+0x25c/0x2460 [ 667.165040][ T9805] alloc_pages_mpol+0x1fb/0x550 [ 667.165489][ T9805] new_slab+0x23b/0x340 [ 667.165872][ T9805] ___slab_alloc+0xd81/0x1960 [ 667.166313][ T9805] __slab_alloc.isra.0+0x56/0xb0 [ 667.166767][ T9805] __kmalloc_cache_noprof+0x255/0x3e0 [ 667.167255][ T9805] psi_cgroup_alloc+0x52/0x2d0 [ 667.167693][ T9805] cgroup_mkdir+0x694/0x1210 [ 667.168118][ T9805] kernfs_iop_mkdir+0x111/0x190 [ 667.168568][ T9805] vfs_mkdir+0x59b/0x8d0 [ 667.168956][ T9805] do_mkdirat+0x2ed/0x3d0 [ 667.169353][ T9805] __x64_sys_mkdir+0xef/0x140 [ 667.169784][ T9805] do_syscall_64+0xc9/0x480 [ 667.170195][ T9805] entry_SYSCALL_64_after_hwframe+0x77/0x7f [ 667.170730][ T9805] page last free pid 1257 tgid 1257 stack trace: [ 667.171304][ T9805] __free_frozen_pages+0x80c/0x1250 [ 667.171770][ T9805] vfree.part.0+0x12b/0xab0 [ 667.172182][ T9805] delayed_vfree_work+0x93/0xd0 [ 667.172612][ T9805] process_one_work+0x9b5/0x1b80 [ 667.173067][ T9805] worker_thread+0x630/0xe60 [ 667.173486][ T9805] kthread+0x3a8/0x770 [ 667.173857][ T9805] ret_from_fork+0x517/0x6e0 [ 667.174278][ T9805] ret_from_fork_asm+0x1a/0x30 [ 667.174703][ T9805] [ 667.174917][ T9805] Memory state around the buggy address: [ 667.175411][ T9805] ffff88802592f300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 667.176114][ T9805] ffff88802592f380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 667.176830][ T9805] >ffff88802592f400: 00 04 fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 667.177547][ T9805] ^ [ 667.177933][ T9805] ffff88802592f480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 667.178640][ T9805] ffff88802592f500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 667.179350][ T9805] ==================================================================
The hfsplus_uni2asc() method operates by struct hfsplus_unistr:
struct hfsplus_unistr {
__be16 length;
hfsplus_unichr unicode[HFSPLUS_MAX_STRLEN];
} __packed;where HFSPLUS_MAX_STRLEN is 255 bytes. The issue happens if length of the structure instance has value bigger than 255 (for example, 65283). In such case, pointer on unicode buffer is going beyond of the allocated memory.
The patch fixes the issue by checking the length value of hfsplus_unistr instance and using 255 value in the case if length value is bigger than HFSPLUS_MAX_STRLEN. Potential reason of such situation could be a corruption of Catalog File b-tree's node.
--- fs/hfsplus/unicode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/hfsplus/unicode.c +7 -0
@@ -132,7 +132,14 @@ int hfsplus_uni2asc(struct super_block *sb, op = astr; ip = ustr->unicode; + ustrlen =be16_to_cpu (ustr->length); +if (ustrlen >HFSPLUS_MAX_STRLEN ) { + ustrlen =HFSPLUS_MAX_STRLEN ; +pr_err ("invalid length %u has been corrected to %d\n" , +be16_to_cpu (ustr->length), ustrlen); + } + len = *len_p; ce1 =NULL ; compose = !test_bit (HFSPLUS_SB_NODECOMPOSE , &HFSPLUS_SB (sb)->flags);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 174/403 hfsplus: dont use BUG_ON() in hfsplus_create_attributes_file()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tetsuo Handa <[email protected]>
[ Upstream commit c7c6363ca186747ebc2df10c8a1a51e66e0e32d9 ]
When the volume header contains erroneous values that do not reflect the actual state of the filesystem, hfsplus_fill_super() assumes that the attributes file is not yet created, which later results in hitting BUG_ON() when hfsplus_create_attributes_file() is called. Replace this BUG_ON() with -EIO error with a message to suggest running fsck tool.
--- fs/hfsplus/xattr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/hfsplus/xattr.c +5 -1
@@ -172,7 +172,11 @@ static int hfsplus_create_attributes_file(struct super_block *sb)return PTR_ERR (attr_file); } -BUG_ON (i_size_read (attr_file) !=0 ); +if (i_size_read (attr_file) !=0 ) { + err = -EIO ; +pr_err ("detected inconsistent attributes file, running fsck.hfsplus is recommended.\n" ); + goto end_attr_file_creation; + } hip =HFSPLUS_I (attr_file);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 175/403 arm64: Handle KCOV __init vs inline mismatches
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 65c430906efffee9bd7551d474f01a6b1197df90 ]
GCC appears to have kind of fragile inlining heuristics, in the sense that it can change whether or not it inlines something based on optimizations. It looks like the kcov instrumentation being added (or in this case, removed) from a function changes the optimization results, and some functions marked "inline" are _not_ inlined. In that case, we end up with __init code calling a function not marked __init, and we get the build warnings I'm trying to eliminate in the coming patch that adds __no_sanitize_coverage to __init functions:
WARNING: modpost: vmlinux: section mismatch in reference: acpi_get_enable_method+0x1c (section: .text.unlikely) -> acpi_psci_present (section: .init.text)
This problem is somewhat fragile (though using either __always_inline or __init will deterministically solve it), but we've tripped over this before with GCC and the solution has usually been to just use __always_inline and move on.
For arm64 this requires forcing one ACPI function to be inlined with __always_inline.
--- arch/arm64/include/asm/acpi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/acpi.h +1 -1
@@ -141,7 +141,7 @@ acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor) {}#endif -static inline const char *acpi_get_enable_method (int cpu) +static __always_inline const char *acpi_get_enable_method(int cpu) {if (acpi_psci_present ())return "psci" ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 176/403 udf: Verify partition map count
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit 1a11201668e8635602577dcf06f2e96c591d8819 ]
Verify that number of partition maps isn't insanely high which can lead to large allocation in udf_sb_alloc_partition_maps(). All partition maps have to fit in the LVD which is in a single block.
--- fs/udf/super.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
fs/udf/super.c +11 -2
@@ -1417,7 +1417,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block,struct genericPartitionMap *gpm;uint16_t ident;struct buffer_head *bh; -unsigned int table_len; +unsigned int table_len, part_map_count;int ret; bh =udf_read_tagged (sb, block, block, &ident);
@@ -1438,7 +1438,16 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, "logical volume");if (ret) goto out_bh; - ret =udf_sb_alloc_partition_maps (sb,le32_to_cpu (lvd->numPartitionMaps)); + + part_map_count =le32_to_cpu (lvd->numPartitionMaps); +if (part_map_count > table_len /sizeof (struct genericPartitionMap1 )) { +udf_err (sb,"error loading logical volume descriptor: " +"Too many partition maps (%u > %u)\n" , part_map_count, + table_len / (unsigned )sizeof (struct genericPartitionMap1 )); + ret = -EIO ; + goto out_bh; + } + ret =udf_sb_alloc_partition_maps (sb, part_map_count);if (ret) goto out_bh;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 177/403 drbd: add missing kref_get in handle_write_conflicts
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarah Newman <[email protected]>
[ Upstream commit 00c9c9628b49e368d140cfa61d7df9b8922ec2a8 ]
With two-primaries enabled, DRBD tries to detect "concurrent" writes and handle write conflicts, so that even if you write to the same sector simultaneously on both nodes, they end up with the identical data once the writes are completed.
In handling "superseeded" writes, we forgot a kref_get, resulting in a premature drbd_destroy_device and use after free, and further to kernel crashes with symptoms.
Relevance: No one should use DRBD as a random data generator, and apparently all users of "two-primaries" handle concurrent writes correctly on layer up. That is cluster file systems use some distributed lock manager, and live migration in virtualization environments stops writes on one node before starting writes on the other node.
Which means that other than for "test cases",
this code path is never taken in real life.
FYI, in DRBD 9, things are handled differently nowadays. We still detect "write conflicts", but no longer try to be smart about them.
We decided to disconnect hard instead: upper layers must not submit concurrent writes. If they do, that's their fault.
--- drivers/block/drbd/drbd_receiver.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/block/drbd/drbd_receiver.c +5 -1
@@ -2531,7 +2531,11 @@ static int handle_write_conflicts(struct drbd_device *device, peer_req->w.cb = superseded ? e_send_superseded : e_send_retry_write;list_add_tail (&peer_req->w.list, &device->done_ee); -queue_work (connection->ack_sender, &peer_req->peer_device->send_acks_work); +/* put is in drbd_send_acks_wf() */ +kref_get (&device->kref); +if (!queue_work (connection->ack_sender, + &peer_req->peer_device->send_acks_work)) +kref_put (&device->kref, drbd_destroy_device); err = -ENOENT ; goto out;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 178/403 hfs: fix not erasing deleted b-tree node issue
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viacheslav Dubeyko <[email protected]>
[ Upstream commit d3ed6d6981f4756f145766753c872482bc3b28d3 ]
The generic/001 test of xfstests suite fails and corrupts the HFS volume:
sudo ./check generic/001
FSTYP -- hfs PLATFORM -- Linux/x86_64 hfsplus-testing-0001 6.15.0-rc2+ #3 SMP PREEMPT_DYNAMIC Fri Apr 25 17:13:00 PDT 2> MKFS_OPTIONS -- /dev/loop51
MOUNT_OPTIONS -- /dev/loop51 /mnt/scratch
generic/001 32s ... _check_generic_filesystem: filesystem on /dev/loop50 is inconsistent (see /home/slavad/XFSTESTS-2/xfstests-dev/results//generic/001.full for details)
Ran: generic/001
Failures: generic/001
Failed 1 of 1 tests
fsck.hfs -d -n ./test-image.bin
** ./test-image.bin (NO WRITE)
Using cacheBlockSize=32K cacheTotalBlock=1024 cacheSize=32768K.
Executing fsck_hfs (version 540.1-Linux).
** Checking HFS volume.
The volume name is untitled
** Checking extents overflow file.
** Checking catalog file.
Unused node is not erased (node = 2)
Unused node is not erased (node = 4)
<skipped>
Unused node is not erased (node = 253)
Unused node is not erased (node = 254)
Unused node is not erased (node = 255)
Unused node is not erased (node = 256)
** Checking catalog hierarchy.
** Checking volume bitmap.
** Checking volume information.
Verify Status: VIStat = 0x0000, ABTStat = 0x0000 EBTStat = 0x0000
CBTStat = 0x0004 CatStat = 0x00000000 ** The volume untitled was found corrupt and needs to be repaired. volume type is HFS primary MDB is at block 2 0x02 alternate MDB is at block 20971518 0x13ffffe primary VHB is at block 0 0x00 alternate VHB is at block 0 0x00 sector size = 512 0x200 VolumeObject flags = 0x19 total sectors for volume = 20971520 0x1400000 total sectors for embedded volume = 0 0x00
This patch adds logic of clearing the deleted b-tree node.
sudo ./check generic/001
FSTYP -- hfs PLATFORM -- Linux/x86_64 hfsplus-testing-0001 6.15.0-rc2+ #3 SMP PREEMPT_DYNAMIC Fri Apr 25 17:13:00 PDT 2025 MKFS_OPTIONS -- /dev/loop51
MOUNT_OPTIONS -- /dev/loop51 /mnt/scratch
generic/001 9s ... 32s
Ran: generic/001
Passed all 1 tests
fsck.hfs -d -n ./test-image.bin
** ./test-image.bin (NO WRITE)
Using cacheBlockSize=32K cacheTotalBlock=1024 cacheSize=32768K.
Executing fsck_hfs (version 540.1-Linux).
** Checking HFS volume.
The volume name is untitled
** Checking extents overflow file.
** Checking catalog file.
** Checking catalog hierarchy.
** Checking volume bitmap.
** Checking volume information.
** The volume untitled appears to be OK.
--- fs/hfs/bnode.c | 1 + 1 file changed, 1 insertion(+)
fs/hfs/bnode.c +1 -0
@@ -586,6 +586,7 @@ void hfs_bnode_put(struct hfs_bnode *node)if (test_bit (HFS_BNODE_DELETED , &node->flags)) {hfs_bnode_unhash (node);spin_unlock (&tree->hash_lock); +hfs_bnode_clear (node,0 , tree->node_size);hfs_bmap_free (node);hfs_bnode_free (node);return ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 179/403 securityfs: dont pin dentries twice, once is enough...
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit 27cd1bf1240d482e4f02ca4f9812e748f3106e4f ]
incidentally, securityfs_recursive_remove() is broken without that - it leaks dentries, since simple_recursive_removal() does not expect anything of that sort. It could be worked around by dput() in remove_one() callback, but it's easier to just drop that double-get stuff.
--- security/inode.c | 2 -- 1 file changed, 2 deletions(-)
security/inode.c +0 -2
@@ -159,7 +159,6 @@ static struct dentry *securityfs_create_dentry(const char *name, umode_t mode, inode->i_fop = fops; }d_instantiate (dentry, inode); -dget (dentry);inode_unlock (dir);return dentry;
@@ -306,7 +305,6 @@ void securityfs_remove(struct dentry *dentry)simple_rmdir (dir, dentry); elsesimple_unlink (dir ,dentry ); -dput (dentry); }inode_unlock (dir);simple_release_fs (&mount, &mount_count);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 180/403 usb: xhci: print xhci->xhc_state when queue_command failed
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Su Hui <[email protected]>
[ Upstream commit 7919407eca2ef562fa6c98c41cfdf6f6cdd69d92 ]
When encounters some errors like these:xhci_hcd 0000:4a:00.2: xHCI dying or halted, can't queue_command xhci_hcd 0000:4a:00.2: FIXME: allocate a command ring segment usb usb5-port6: couldn't allocate usb_device
It's hard to know whether xhc_state is dying or halted. So it's better to print xhc_state's value which can help locate the resaon of the bug.
--- drivers/usb/host/xhci-ring.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-ring.c +2 -1
@@ -4076,7 +4076,8 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,if ((xhci->xhc_state &XHCI_STATE_DYING ) || (xhci->xhc_state &XHCI_STATE_HALTED )) { -xhci_dbg (xhci,"xHCI dying or halted, can't queue_command\n" ); +xhci_dbg (xhci,"xHCI dying or halted, can't queue_command. state: 0x%x\n" , + xhci->xhc_state);return -ESHUTDOWN ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 181/403 cpufreq: CPPC: Mark driver with NEED_UPDATE_LIMITS flag
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prashant Malani <[email protected]>
[ Upstream commit 0a1416a49e63c320f6e6c1c8d07e1b58c0d4a3f3 ]
AMU counters on certain CPPC-based platforms tend to yield inaccurate delivered performance measurements on systems that are idle/mostly idle. This results in an inaccurate frequency being stored by cpufreq in its policy structure when the CPU is brought online. [1]
Consequently, if the userspace governor tries to set the frequency to a new value, there is a possibility that it would be the erroneous value stored earlier. In such a scenario, cpufreq would assume that the requested frequency has already been set and return early, resulting in the correct/new frequency request never making it to the hardware.
Since the operating frequency is liable to this sort of inconsistency, mark the CPPC driver with CPUFREQ_NEED_UPDATE_LIMITS so that it is always invoked when a target frequency update is requested.
--- drivers/cpufreq/cppc_cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cppc_cpufreq.c +1 -1
@@ -407,7 +407,7 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpunum) }static struct cpufreq_driver cppc_cpufreq_driver = { - .flags =CPUFREQ_CONST_LOOPS , + .flags =CPUFREQ_CONST_LOOPS |CPUFREQ_NEED_UPDATE_LIMITS , .verify = cppc_verify_policy, .target = cppc_cpufreq_set_target, .get = cppc_cpufreq_get_rate,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 182/403 selftests/futex: Define SYS_futex on 32-bit architectures with 64-bit time_t
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cynthia Huang <[email protected]>
[ Upstream commit 04850819c65c8242072818655d4341e70ae998b5 ]
The kernel does not provide sys_futex() on 32-bit architectures that do not support 32-bit time representations, such as riscv32.
As a result, glibc cannot define SYS_futex, causing compilation failures in tests that rely on this syscall. Define SYS_futex as SYS_futex_time64 in such cases to ensure successful compilation and compatibility.
--- tools/testing/selftests/futex/include/futextest.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/testing/selftests/futex/include/futextest.h +11 -0
@@ -47,6 +47,17 @@ typedef volatile u_int32_t futex_t; FUTEX_PRIVATE_FLAG)#endif +/* +* SYS_futex is expected from system C library, in glibc some 32-bit +* architectures (e.g. RV32) are using 64-bit time_t, therefore it doesn't have +* SYS_futex defined but just SYS_futex_time64. Define SYS_futex as +* SYS_futex_time64 in this situation to ensure the compilation and the +* compatibility. +*/ +#if !defined(SYS_futex) && defined(SYS_futex_time64) +#define SYS_futex SYS_futex_time64 +#endif +/** * futex() - SYS_futex syscall wrapper * @uaddr: address of first futex
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 183/403 usb: xhci: Avoid showing warnings for dying controller
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
[ Upstream commit 65fc0fc137b5da3ee1f4ca4f61050fcb203d7582 ]
When a USB4 dock is unplugged from a system it won't respond to ring events. The PCI core handles the surprise removal event and notifies all PCI drivers. The XHCI PCI driver sets a flag that the device is being removed, and when the device stops responding a flag is also added to indicate it's dying.
When that flag is set don't bother to show warnings about a missing controller.
--- drivers/usb/host/xhci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.c +4 -2
@@ -118,7 +118,8 @@ int xhci_halt(struct xhci_hcd *xhci) ret =xhci_handshake (&xhci->op_regs->status,STS_HALT ,STS_HALT ,XHCI_MAX_HALT_USEC );if (ret) { -xhci_warn (xhci,"Host halt failed, %d\n" , ret); +if (!(xhci->xhc_state &XHCI_STATE_DYING )) +xhci_warn (xhci,"Host halt failed, %d\n" , ret);return ret; } xhci->xhc_state |=XHCI_STATE_HALTED ;
@@ -175,7 +176,8 @@ int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us) state =readl (&xhci->op_regs->status);if (state == ~(u32 )0 ) { -xhci_warn (xhci,"Host not accessible, reset failed.\n" ); +if (!(xhci->xhc_state &XHCI_STATE_DYING )) +xhci_warn (xhci,"Host not accessible, reset failed.\n" );return -ENODEV ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 184/403 usb: xhci: Set avg_trb_len = 8 for EP0 during Address Device Command
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jay Chen <[email protected]>
[ Upstream commit f72b9aa821a2bfe4b6dfec4be19f264d0673b008 ]
There is a subtle contradiction between sections of the xHCI 1.2 spec regarding the initialization of Input Endpoint Context fields. Section 4.8.2 ("Endpoint Context Initialization") states that all fields should be initialized to 0. However, Section 6.2.3 ("Endpoint Context", p.453) specifies that the Average TRB Length (avg_trb_len) field shall be greater than 0, and explicitly notes (p.454): "Software shall set Average TRB Length to '8' for control endpoints."
Strictly setting all fields to 0 during initialization conflicts with the specific recommendation for control endpoints. In practice, setting avg_trb_len = 0 is not meaningful for the hardware/firmware, as the value is used for bandwidth calculation.
Motivation: Our company is developing a custom Virtual xHC hardware platform that strictly follows the xHCI spec and its recommendations. During validation, we observed that enumeration fails and a parameter error (TRB Completion Code = 5) is reported if avg_trb_len for EP0 is not set to 8 as recommended by Section 6.2.3. This demonstrates the importance of assigning a meaningful, non-zero value to avg_trb_len, even in virtualized or emulated environments.
This patch explicitly sets avg_trb_len to 8 for EP0 in xhci_setup_addressable_virt_dev(), as recommended in Section 6.2.3, to prevent potential issues with xHCI host controllers that enforce the spec strictly.
--- drivers/usb/host/xhci-mem.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/xhci-mem.c +2 -0
@@ -1214,6 +1214,8 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud ep0_ctx->deq =cpu_to_le64 (dev->eps[0 ].ring->first_seg->dma | dev->eps[0 ].ring->cycle_state); + ep0_ctx->tx_info =cpu_to_le32 (EP_AVG_TRB_LENGTH (8 )); +trace_xhci_setup_addressable_virt_device (dev);/* Steps 7 and 8 were done in xhci_alloc_virt_device() */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 185/403 usb: xhci: Avoid showing errors during surprise removal
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
[ Upstream commit 4b9c60e440525b729ac5f071e00bcee12e0a7e84 ]
When a USB4 dock is unplugged from a system it won't respond to ring events. The PCI core handles the surprise removal event and notifies all PCI drivers. The XHCI PCI driver sets a flag that the device is being removed as well.
When that flag is set don't show messages in the cleanup path for marking the controller dead.
--- drivers/usb/host/xhci-ring.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-ring.c +5 -2
@@ -973,12 +973,15 @@ static void xhci_kill_endpoint_urbs(struct xhci_hcd *xhci,*/ void xhci_hc_died (struct xhci_hcd *xhci) { +bool notify;int i, j;if (xhci->xhc_state &XHCI_STATE_DYING )return ; -xhci_err (xhci,"xHCI host controller not responding, assume dead\n" ); + notify = !(xhci->xhc_state &XHCI_STATE_REMOVING ); +if (notify) +xhci_err (xhci,"xHCI host controller not responding, assume dead\n" ); xhci->xhc_state |=XHCI_STATE_DYING ;xhci_cleanup_command_queue (xhci);
@@ -992,7 +995,7 @@ void xhci_hc_died(struct xhci_hcd *xhci) }/* inform usb core hc died if PCI remove isn't already handling it */ -if (!(xhci->xhc_state &XHCI_STATE_REMOVING )) +if (notify)usb_hc_died (xhci_to_hcd (xhci)); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 186/403 cpufreq: Exit governor when failed to start old governor
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lifeng Zheng <[email protected]>
[ Upstream commit 0ae204405095abfbc2d694ee0fbb49bcbbe55c57 ]
Detect the result of starting old governor in cpufreq_set_policy(). If it fails, exit the governor and clear policy->governor.
--- drivers/cpufreq/cpufreq.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/cpufreq/cpufreq.c +5 -3
@@ -2483,10 +2483,12 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,pr_debug ("starting governor %s failed\n" , policy->governor->name);if (old_gov) { policy->governor = old_gov; -if (cpufreq_init_governor (policy)) +if (cpufreq_init_governor (policy)) { policy->governor =NULL ; -else -cpufreq_start_governor (policy); + }else if (cpufreq_start_governor (policy)) { +cpufreq_exit_governor (policy); + policy->governor =NULL ; + } }return ret;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 187/403 ARM: rockchip: fix kernel hang during smp initialization
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Kochetkov <[email protected]>
[ Upstream commit 7cdb433bb44cdc87dc5260cdf15bf03cc1cd1814 ]
In order to bring up secondary CPUs main CPU write trampoline code to SRAM. The trampoline code is written while secondary CPUs are powered on (at least that true for RK3188 CPU). Sometimes that leads to kernel hang. Probably because secondary CPU execute trampoline code while kernel doesn't expect.
The patch moves SRAM initialization step to the point where all secondary CPUs are powered down.
That fixes rarely hangs on RK3188:
[ 0.091568] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 [ 0.091996] rockchip_smp_prepare_cpus: ncores 4
--- arch/arm/mach-rockchip/platsmp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
arch/arm/mach-rockchip/platsmp.c +9 -6
@@ -279,11 +279,6 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus) }if (read_cpuid_part () ==ARM_CPU_PART_CORTEX_A9 ) { -if (rockchip_smp_prepare_sram (node)) { -of_node_put (node); -return ; - } -/* enable the SCU power domain */ pmu_set_power_domain (PMU_PWRDN_SCU , true);
@@ -316,11 +311,19 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus) asm ("mrc p15, 1, %0, c9, c0, 2\n" :"=r" (l2ctlr)); ncores = ((l2ctlr >>24 ) &0x3 ) +1 ; } -of_node_put (node);/* Make sure that all cores except the first are really off */ for (i =1 ; i < ncores; i++)pmu_set_power_domain (0 + i, false); + +if (read_cpuid_part () ==ARM_CPU_PART_CORTEX_A9 ) { +if (rockchip_smp_prepare_sram (node)) { +of_node_put (node); +return ; + } + } + +of_node_put (node); }static void __init rk3036_smp_prepare_cpus (unsigned int max_cpus)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 188/403 ASoC: soc-dapm: set bias_level if snd_soc_dapm_set_bias_level() was successed
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit f40ecc2743652c0b0f19935f81baf57c601eb7f0 ]
ASoC has 2 functions to set bias level.
(A) snd_soc_dapm_force_bias_level() (B) snd_soc_dapm_set_bias_level()
snd_soc_dapm_force_bias_level() (A) will set dapm->bias_level (a) if successed.
(A) int snd_soc_dapm_force_bias_level(...)
{
...
if (ret == 0)
(a) dapm->bias_level = level;
...
}snd_soc_dapm_set_bias_level() (B) is also a function that sets bias_level. It will call snd_soc_dapm_force_bias_level() (A) inside, but doesn't set dapm->bias_level by itself. One note is that (A) might not be called.
(B) static int snd_soc_dapm_set_bias_level(...)
{
...
ret = snd_soc_card_set_bias_level(...);
...
if (dapm != &card->dapm)
(A) ret = snd_soc_dapm_force_bias_level(...);
...
ret = snd_soc_card_set_bias_level_post(...);
...
}dapm->bias_level will be set if (A) was called, but might not be set if (B) was called, even though it calles set_bias_level() function.
We should set dapm->bias_level if we callssnd_soc_dapm_set_bias_level() (B), too.
--- sound/soc/soc-dapm.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/soc/soc-dapm.c +4 -0
@@ -741,6 +741,10 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm, out:trace_snd_soc_bias_level_done (card, level); +/* success */ +if (ret ==0 ) +snd_soc_dapm_init_bias_level (dapm, level); +return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 189/403 gpio: tps65912: check the return value of regmap_update_bits()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
[ Upstream commit a0b2a6bbff8c26aafdecd320f38f52c341d5cafa ]
regmap_update_bits() can fail, check its return value like we do elsewhere in the driver.
--- drivers/gpio/gpio-tps65912.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpio/gpio-tps65912.c +5 -2
@@ -49,10 +49,13 @@ static int tps65912_gpio_direction_output(struct gpio_chip *gc, unsigned offset, int value) {struct tps65912_gpio *gpio =gpiochip_get_data (gc); +int ret;/* Set the initial value */ -regmap_update_bits (gpio->tps->regmap,TPS65912_GPIO1 + offset, -GPIO_SET_MASK , value ?GPIO_SET_MASK :0 ); + ret =regmap_update_bits (gpio->tps->regmap,TPS65912_GPIO1 + offset, +GPIO_SET_MASK , value ?GPIO_SET_MASK :0 ); +if (ret) +return ret;return regmap_update_bits (gpio->tps->regmap,TPS65912_GPIO1 + offset,GPIO_CFG_MASK ,GPIO_CFG_MASK );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 190/403 ARM: tegra: Use I/O memcpy to write to IRAM
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Kling <[email protected]>
[ Upstream commit 398e67e0f5ae04b29bcc9cbf342e339fe9d3f6f1 ]
Kasan crashes the kernel trying to check boundaries when using the normal memcpy.
--- arch/arm/mach-tegra/reset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-tegra/reset.c +1 -1
@@ -63,7 +63,7 @@ static void __init tegra_cpu_reset_handler_enable(void)BUG_ON (is_enabled);BUG_ON (tegra_cpu_reset_handler_size >TEGRA_IRAM_RESET_HANDLER_SIZE ); -memcpy (iram_base, (void *)__tegra_cpu_reset_handler_start, +memcpy_toio (iram_base, (void *)__tegra_cpu_reset_handler_start, tegra_cpu_reset_handler_size); err =call_firmware_op (set_cpu_boot_addr,0 , reset_address);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 191/403 selftests: tracing: Use mutex_unlock for testing glob filter
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit a089bb2822a49b0c5777a8936f82c1f8629231fb ]
Since commit c5b6ababd21a ("locking/mutex: implement mutex_trylock_nested") makes mutex_trylock() as an inlined function if CONFIG_DEBUG_LOCK_ALLOC=y, we can not use mutex_trylock() for testing the glob filter of ftrace.
Use mutex_unlock instead.
--- .../testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc +1 -1
@@ -33,7 +33,7 @@ ftrace_filter_check 'schedule*' '^schedule.*$' ftrace_filter_check '*pin*lock' '.*pin.*lock$' # filter by start*mid* -ftrace_filter_check 'mutex*try*' '^mutex.*try.*' +ftrace_filter_check 'mutex*unl*' '^mutex.*unl.*' # Advanced full-glob matching feature is recently supported. # Skip the tests if we are sure the kernel does not support it.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 192/403 PM: runtime: Clear power.needs_force_resume in pm_runtime_reinit()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 89d9cec3b1e9c49bae9375a2db6dc49bc7468af0 ]
Clear power.needs_force_resume in pm_runtime_reinit() in case it has been set by pm_runtime_force_suspend() invoked from a driver remove callback.
--- drivers/base/power/runtime.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/base/power/runtime.c +5 -0
@@ -1698,6 +1698,11 @@ void pm_runtime_reinit(struct device *dev)pm_runtime_put (dev->parent); } } +/* +* Clear power.needs_force_resume in case it has been set by +* pm_runtime_force_suspend() invoked from a driver remove callback. +*/ + dev->power.needs_force_resume = false; }/**
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 193/403 thermal: sysfs: Return ENODATA instead of EAGAIN for reads
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hsin-Te Yuan <[email protected]>
[ Upstream commit 1a4aabc27e95674837f2e25f4ef340c0469e6203 ]
According to POSIX spec, EAGAIN returned by read with O_NONBLOCK set means the read would block. Hence, the common implementation in nonblocking model will poll the file when the nonblocking read returns EAGAIN. However, when the target file is thermal zone, this mechanism will totally malfunction because thermal zone doesn't implement sysfs notification and thus the poll will never return.
For example, the read in Golang implemnts such method and sometimes hangs at reading some thermal zones via sysfs.
Change to return -ENODATA instead of -EAGAIN to userspace.
--- drivers/thermal/thermal_sysfs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/thermal/thermal_sysfs.c +6 -3
@@ -39,10 +39,13 @@ temp_show(struct device *dev, struct device_attribute *attr, char *buf) ret =thermal_zone_get_temp (tz, &temperature); -if (ret) -return ret; +if (!ret) +return sprintf (buf,"%d\n" , temperature); -return sprintf (buf,"%d\n" , temperature); +if (ret == -EAGAIN ) +return -ENODATA ; + +return ret; } static ssize_t
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 194/403 PM: sleep: console: Fix the black screen issue
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: tuhaowen <[email protected]>
[ Upstream commit 4266e8fa56d3d982bf451d382a410b9db432015c ]
When the computer enters sleep status without a monitor connected, the system switches the console to the virtual terminal tty63(SUSPEND_CONSOLE).
If a monitor is subsequently connected before waking up, the system skips the required VT restoration process during wake-up, leaving the console on tty63 instead of switching back to tty1.
To fix this issue, a global flag vt_switch_done is introduced to record whether the system has successfully switched to the suspend console via vt_move_to_console() during suspend.
If the switch was completed, vt_switch_done is set to 1. Later during resume, this flag is checked to ensure that the original console is restored properly by calling vt_move_to_console(orig_fgconsole, 0).
This prevents scenarios where the resume logic skips console restoration due to incorrect detection of the console state, especially when a monitor is reconnected before waking up.
--- kernel/power/console.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/power/console.c +6 -1
@@ -16,6 +16,7 @@#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)static int orig_fgconsole, orig_kmsg; +static bool vt_switch_done;static DEFINE_MUTEX (vt_switch_mutex);
@@ -136,17 +137,21 @@ void pm_prepare_console(void)if (orig_fgconsole <0 )return ; + vt_switch_done = true; + orig_kmsg =vt_kmsg_redirect (SUSPEND_CONSOLE );return ; }void pm_restore_console (void ) { -if (!pm_vt_switch ()) +if (!pm_vt_switch () && !vt_switch_done)return ;if (orig_fgconsole >=0 ) {vt_move_to_console (orig_fgconsole,0 );vt_kmsg_redirect (orig_kmsg); } + + vt_switch_done = false; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 195/403 ACPI: processor: fix acpi_object initialization
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Ott <[email protected]>
[ Upstream commit 13edf7539211d8f7d0068ce3ed143005f1da3547 ]
Initialization of the local acpi_object in acpi_processor_get_info() only sets the first 4 bytes to zero and is thus incomplete. This is indicated by messages like:
acpi ACPI0007:be: Invalid PBLK length [166288104]
Fix this by initializing all 16 bytes of the processor member of that union.
--- drivers/acpi/acpi_processor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpi_processor.c +1 -1
@@ -228,7 +228,7 @@ static inline int acpi_processor_hotadd_init(struct acpi_processor *pr)static int acpi_processor_get_info (struct acpi_device *device) { -union acpi_object object = {0 }; +union acpi_object object = { .processor = {0 } };struct acpi_buffer buffer = {sizeof (union acpi_object ), &object };struct acpi_processor *pr =acpi_driver_data (device);int device_declaration =0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 196/403 ACPI: APEI: GHES: add TAINT_MACHINE_CHECK on GHES panic path
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 4734c8b46b901cff2feda8b82abc710b65dc31c1 ]
When a GHES (Generic Hardware Error Source) triggers a panic, add the TAINT_MACHINE_CHECK taint flag to the kernel. This explicitly marks the kernel as tainted due to a machine check event, improving diagnostics and post-mortem analysis. The taint is set with LOCKDEP_STILL_OK to indicate lockdep remains valid.
At large scale deployment, this helps to quickly determine panics that are coming due to hardware failures.
--- drivers/acpi/apei/ghes.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/acpi/apei/ghes.c +2 -0
@@ -709,6 +709,8 @@ static void __ghes_panic(struct ghes *ghes,__ghes_print_estatus (KERN_EMERG , ghes->generic, estatus); +add_taint (TAINT_MACHINE_CHECK ,LOCKDEP_STILL_OK ); +ghes_clear_estatus (ghes, estatus, buf_paddr, fixmap_idx);if (!panic_timeout)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 197/403 mmc: rtsx_usb_sdmmc: Fix error-path in sd_set_power_mode()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ulf Hansson <[email protected]>
[ Upstream commit 47a255f7d2eabee06cfbf5b1c2379749442fd01d ]
In the error path of sd_set_power_mode() we don't update host->power_mode, which could lead to an imbalance of the runtime PM usage count. Fix this by always updating host->power_mode.
--- drivers/mmc/host/rtsx_usb_sdmmc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/mmc/host/rtsx_usb_sdmmc.c +1 -3
@@ -1038,9 +1038,7 @@ static int sd_set_power_mode(struct rtsx_usb_sdmmc *host, err =sd_power_on (host); } -if (!err) - host->power_mode = power_mode; - + host->power_mode = power_mode;return err; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 198/403 ASoC: hdac_hdmi: Rate limit logging on connection and disconnection
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit c4ca928a6db1593802cd945f075a7e21dd0430c1 ]
We currently log parse failures for ELD data and some disconnection events as errors without rate limiting. These log messages can be triggered very frequently in some situations, especially ELD parsing when there is nothing connected to a HDMI port which will generate:
hdmi-audio-codec hdmi-audio-codec.1.auto: HDMI: Unknown ELD version 0
While there's doubtless work that could be done on reducing the number of connection notification callbacks it's possible these may be legitimately generated by poor quality physical connections so let's use rate limiting to mitigate the log spam for the parse errors and lower the severity for disconnect logging to debug level.
--- sound/soc/codecs/hdac_hdmi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
sound/soc/codecs/hdac_hdmi.c +6 -4
@@ -1231,7 +1231,8 @@ static int hdac_hdmi_parse_eld(struct hdac_device *hdev, >> DRM_ELD_VER_SHIFT;if (ver !=ELD_VER_CEA_861D && ver !=ELD_VER_PARTIAL ) { -dev_err (&hdev->dev,"HDMI: Unknown ELD version %d\n" , ver); +dev_err_ratelimited (&hdev->dev, +"HDMI: Unknown ELD version %d\n" , ver);return -EINVAL ; }
@@ -1239,7 +1240,8 @@ static int hdac_hdmi_parse_eld(struct hdac_device *hdev, DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT;if (mnl >ELD_MAX_MNL ) { -dev_err (&hdev->dev,"HDMI: MNL Invalid %d\n" , mnl); +dev_err_ratelimited (&hdev->dev, +"HDMI: MNL Invalid %d\n" , mnl);return -EINVAL ; }
@@ -1293,8 +1295,8 @@ static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin,if (!port->eld.monitor_present || !port->eld.eld_valid) { -dev_err (&hdev->dev,"%s: disconnect for pin:port %d:%d\n" , - __func__, pin->nid, port->id); +dev_dbg (&hdev->dev,"%s: disconnect for pin:port %d:%d\n" , + __func__, pin->nid, port->id);/* * PCMs are not registered during device probe, so don't
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 199/403 ALSA: intel8x0: Fix incorrect codec index usage in mixer for ICH4
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit 87aafc8580acf87fcaf1a7e30ed858d8c8d37d81 ]
code mistakenly used a hardcoded index (codec[1]) instead of iterating, over the codec array using the loop variable i. Use codec[i] instead of codec[1] to match the loop iteration.
--- sound/pci/intel8x0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/intel8x0.c +1 -1
@@ -2285,7 +2285,7 @@ static int snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock, tmp |= chip->ac97_sdin[0 ] <<ICH_DI1L_SHIFT ;for (i =1 ; i <4 ; i++) {if (pcm->r[0 ].codec[i]) { - tmp |= chip->ac97_sdin[pcm->r[0 ].codec[1 ]->num] <<ICH_DI2L_SHIFT ; + tmp |= chip->ac97_sdin[pcm->r[0 ].codec[i]->num] <<ICH_DI2L_SHIFT ;break ; } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 200/403 usb: core: usb_submit_urb: downgrade type check
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit 503bbde34cc3dd2acd231f277ba70c3f9ed22e59 ]
Checking for the endpoint type is no reason for a WARN, as that can cause a reboot. A driver not checking the endpoint type must not cause a reboot, as there is just no point in this. We cannot prevent a device from doing something incorrect as a reaction to a transfer. Hence warning for a mere assumption being wrong is not sensible.
--- drivers/usb/core/urb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/core/urb.c +1 -1
@@ -490,7 +490,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)/* Check that the pipe's type matches the endpoint's type */ if (usb_pipe_type_check (urb->dev, urb->pipe)) -dev_WARN (&dev->dev,"BOGUS urb xfer, pipe %x != type %x\n" , +dev_warn_once (&dev->dev,"BOGUS urb xfer, pipe %x != type %x\n" ,usb_pipetype (urb->pipe), pipetypes[xfertype]);/* Check against a simple/standard policy */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 201/403 pm: cpupower: Fix the snapshot-order of tsc,mperf, clock in mperf_stop()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautham R. Shenoy <[email protected]>
[ Upstream commit cda7ac8ce7de84cf32a3871ba5f318aa3b79381e ]
In the function mperf_start(), mperf_monitor snapshots the time, tsc and finally the aperf,mperf MSRs. However, this order of snapshotting in is reversed in mperf_stop(). As a result, the C0 residency (which is computed as delta_mperf * 100 / delta_tsc) is under-reported on CPUs that is 100% busy.
Fix this by snapshotting time, tsc and then aperf,mperf in mperf_stop() in the same order as in mperf_start().
--- tools/power/cpupower/utils/idle_monitor/mperf_monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/power/cpupower/utils/idle_monitor/mperf_monitor.c +2 -2
@@ -201,9 +201,9 @@ static int mperf_stop(void)int cpu;for (cpu =0 ; cpu < cpu_count; cpu++) { -mperf_measure_stats (cpu); -mperf_get_tsc (&tsc_at_measure_end[cpu]);clock_gettime (CLOCK_REALTIME , &time_end[cpu]); +mperf_get_tsc (&tsc_at_measure_end[cpu]); +mperf_measure_stats (cpu); }return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 202/403 platform/x86: thinkpad_acpi: Handle KCOV __init vs inline mismatches
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 6418a8504187dc7f5b6f9d0649c03e362cb0664b ]
When KCOV is enabled all functions get instrumented, unless the __no_sanitize_coverage attribute is used. To prepare for __no_sanitize_coverage being applied to __init functions[1], we have to handle differences in how GCC's inline optimizations get resolved. For thinkpad_acpi routines, this means forcing two functions to be inline with __always_inline.
--- drivers/platform/x86/thinkpad_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +2 -2
@@ -514,12 +514,12 @@ static unsigned long __init tpacpi_check_quirks(return 0 ; } -static inline bool __pure __init tpacpi_is_lenovo (void ) +static __always_inline bool __pure __init tpacpi_is_lenovo(void) {return thinkpad_id.vendor ==PCI_VENDOR_ID_LENOVO ; } -static inline bool __pure __init tpacpi_is_ibm (void ) +static __always_inline bool __pure __init tpacpi_is_ibm(void) {return thinkpad_id.vendor ==PCI_VENDOR_ID_IBM ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 203/403 ALSA: hda/ca0132: Fix buffer overflow in add_tuning_control
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucy Thrun <[email protected]>
[ Upstream commit a409c60111e6bb98fcabab2aeaa069daa9434ca0 ]
The 'sprintf' call in 'add_tuning_control' may exceed the 44-byte buffer if either string argument is too long. This triggers a compiler warning.
Replaced 'sprintf' with 'snprintf' to limit string lengths to prevent overflow.
--- sound/pci/hda/patch_ca0132.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/patch_ca0132.c +1 -1
@@ -4014,7 +4014,7 @@ static int add_tuning_control(struct hda_codec *codec, } knew.private_value =HDA_COMPOSE_AMP_VAL (nid,1 ,0 , type); -sprintf (namestr,"%s %s Volume" , name, dirstr[dir]); +snprintf (namestr,sizeof (namestr),"%s %s Volume" , name, dirstr[dir]);return snd_hda_ctl_add (codec, nid,snd_ctl_new1 (&knew, codec)); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 204/403 ALSA: usb-audio: Avoid precedence issues in mixer_quirks macros
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cristian Ciocaltea <[email protected]>
[ Upstream commit fd3ab72e42e9871a9902b945a2bf8bb87b49c718 ]
Fix all macro related issues identified by checkpatch.pl:
CHECK: Macro argument 'x' may be better as '(x)' to avoid precedence issues
--- sound/usb/mixer_quirks.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
sound/usb/mixer_quirks.c +7 -7
@@ -1990,15 +1990,15 @@ static int dell_dock_mixer_init(struct usb_mixer_interface *mixer)#define SND_RME_CLK_FREQMUL_SHIFT 18#define SND_RME_CLK_FREQMUL_MASK 0x7#define SND_RME_CLK_SYSTEM (x) \ - ((x >> SND_RME_CLK_SYSTEM_SHIFT) & SND_RME_CLK_SYSTEM_MASK) + (((x) >> SND_RME_CLK_SYSTEM_SHIFT) & SND_RME_CLK_SYSTEM_MASK)#define SND_RME_CLK_AES (x) \ - ((x >> SND_RME_CLK_AES_SHIFT) & SND_RME_CLK_AES_SPDIF_MASK) + (((x) >> SND_RME_CLK_AES_SHIFT) & SND_RME_CLK_AES_SPDIF_MASK)#define SND_RME_CLK_SPDIF (x) \ - ((x >> SND_RME_CLK_SPDIF_SHIFT) & SND_RME_CLK_AES_SPDIF_MASK) + (((x) >> SND_RME_CLK_SPDIF_SHIFT) & SND_RME_CLK_AES_SPDIF_MASK)#define SND_RME_CLK_SYNC (x) \ - ((x >> SND_RME_CLK_SYNC_SHIFT) & SND_RME_CLK_SYNC_MASK) + (((x) >> SND_RME_CLK_SYNC_SHIFT) & SND_RME_CLK_SYNC_MASK)#define SND_RME_CLK_FREQMUL (x) \ - ((x >> SND_RME_CLK_FREQMUL_SHIFT) & SND_RME_CLK_FREQMUL_MASK) + (((x) >> SND_RME_CLK_FREQMUL_SHIFT) & SND_RME_CLK_FREQMUL_MASK)#define SND_RME_CLK_AES_LOCK 0x1#define SND_RME_CLK_AES_SYNC 0x4#define SND_RME_CLK_SPDIF_LOCK 0x2
@@ -2007,9 +2007,9 @@ static int dell_dock_mixer_init(struct usb_mixer_interface *mixer)#define SND_RME_SPDIF_FORMAT_SHIFT 5#define SND_RME_BINARY_MASK 0x1#define SND_RME_SPDIF_IF (x) \ - ((x >> SND_RME_SPDIF_IF_SHIFT) & SND_RME_BINARY_MASK) + (((x) >> SND_RME_SPDIF_IF_SHIFT) & SND_RME_BINARY_MASK)#define SND_RME_SPDIF_FORMAT (x) \ - ((x >> SND_RME_SPDIF_FORMAT_SHIFT) & SND_RME_BINARY_MASK) + (((x) >> SND_RME_SPDIF_FORMAT_SHIFT) & SND_RME_BINARY_MASK)static const u32 snd_rme_rate_table[] = {32000 ,44100 ,48000 ,50000 ,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 205/403 ASoC: codecs: rt5640: Retry DEVICE_ID verification
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xinxin Wan <[email protected]>
[ Upstream commit 19f971057b2d7b99c80530ec1052b45de236a8da ]
To be more resilient to codec-detection failures when the hardware powers on slowly, add retry mechanism to the device verification check. Similar pattern is found throughout a number of Realtek codecs. Our tests show that 60ms delay is sufficient to address readiness issues on rt5640 chip.
--- sound/soc/codecs/rt5640.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/soc/codecs/rt5640.c +5 -0
@@ -2810,6 +2810,11 @@ static int rt5640_i2c_probe(struct i2c_client *i2c, }regmap_read (rt5640->regmap,RT5640_VENDOR_ID2 , &val); +if (val !=RT5640_DEVICE_ID ) { +usleep_range (60000 ,100000 ); +regmap_read (rt5640->regmap,RT5640_VENDOR_ID2 , &val); + } +if (val !=RT5640_DEVICE_ID ) {dev_err (&i2c->dev,"Device with ID register %#x is not rt5640/39\n" , val);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 206/403 ktest.pl: Prevent recursion of default variable options
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
[ Upstream commit 61f7e318e99d3b398670518dd3f4f8510d1800fc ]
If a default variable contains itself, do not recurse on it.
For example:
ADD_CONFIG := ${CONFIG_DIR}/temp_config
DEFAULTS
ADD_CONFIG = ${CONFIG_DIR}/default_config ${ADD_CONFIG}The above works because the temp variable ADD_CONFIG (is a temp because it is created with ":=") is already defined, it will be substituted in the variable option. But if it gets commented out:
# ADD_CONFIG := ${CONFIG_DIR}/temp_config
DEFAULTS
ADD_CONFIG = ${CONFIG_DIR}/default_config ${ADD_CONFIG}Then the above will go into a recursive loop where ${ADD_CONFIG} will get replaced with the current definition of ADD_CONFIG which contains the ${ADD_CONFIG} and that will also try to get converted. ktest.pl will error after 100 attempts of recursion and fail.
When replacing a variable with the default variable, if the default variable contains itself, do not replace it.
--- tools/testing/ktest/ktest.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/ktest/ktest.pl +4 -1
@@ -1280,7 +1280,10 @@ sub __eval_option { # If a variable contains itself, use the default var if (($var eq $name) && defined($opt{$var})) { $o = $opt{$var}; - $retval = "$retval$o"; + # Only append if the default doesn't contain itself + if ($o !~ m/\$\{$var\}/) { + $retval = "$retval$o"; + } } elsif (defined($opt{$o})) { $o = $opt{$o}; $retval = "$retval$o";
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 207/403 wifi: cfg80211: reject HTC bit for management frames
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit be06a8c7313943109fa870715356503c4c709cbc ]
Management frames sent by userspace should never have the order/HTC bit set, reject that. It could also cause some confusion with the length of the buffer and the header so the validation might end up wrong.
--- net/wireless/mlme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/wireless/mlme.c +2 -1
@@ -598,7 +598,8 @@ int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev, mgmt = (const struct ieee80211_mgmt *)params->buf; -if (!ieee80211_is_mgmt (mgmt->frame_control)) +if (!ieee80211_is_mgmt (mgmt->frame_control) || +ieee80211_has_order (mgmt->frame_control))return -EINVAL ; stype =le16_to_cpu (mgmt->frame_control) &IEEE80211_FCTL_STYPE ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 208/403 s390/time: Use monotonic clock in get_cycles()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Schnelle <[email protected]>
[ Upstream commit 09e7e29d2b49ba84bcefb3dc1657726d2de5bb24 ]
Otherwise the code might not work correctly when the clock is changed.
--- arch/s390/include/asm/timex.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
arch/s390/include/asm/timex.h +6 -7
@@ -172,13 +172,6 @@ static inline unsigned long long get_tod_clock_fast(void)return get_tod_clock ();#endif } - -static inline cycles_t get_cycles (void ) -{ -return (cycles_t )get_tod_clock () >>2 ; -} -#define get_cycles get_cycles -int get_phys_clock (unsigned long *clock);void init_cpu_timer (void );unsigned long long monotonic_clock (void );
@@ -202,6 +195,12 @@ static inline unsigned long long get_tod_clock_monotonic(void)return tod; } +static inline cycles_t get_cycles (void ) +{ +return (cycles_t )get_tod_clock_monotonic () >>2 ; +} +#define get_cycles get_cycles +/** * tod_to_ns - convert a TOD format value to nanoseconds * @todval: to be converted TOD format value
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 209/403 be2net: Use correct byte order and format string for TCP seq and ack_seq
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit 4701ee5044fb3992f1c910630a9673c2dc600ce5 ]
The TCP header fields seq and ack_seq are 32-bit values in network byte order as (__be32). these fields were earlier printed using ntohs(), which converts only 16-bit values and produces incorrect results for 32-bit fields. This patch is changeing the conversion to ntohl(), ensuring correct interpretation of these sequence numbers.
Notably, the format specifier is updated from %d to %u to reflect the unsigned nature of these fields.
improves the accuracy of debug log messages for TCP sequence and acknowledgment numbers during TX timeouts.
--- drivers/net/ethernet/emulex/benet/be_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/emulex/benet/be_main.c +4 -4
@@ -1467,10 +1467,10 @@ static void be_tx_timeout(struct net_device *netdev) ntohs(tcphdr->source));dev_info (dev,"TCP dest port %d\n" ,ntohs (tcphdr->dest)); -dev_info (dev,"TCP sequence num %d\n" , -ntohs (tcphdr->seq)); -dev_info (dev,"TCP ack_seq %d\n" , -ntohs (tcphdr->ack_seq)); +dev_info (dev,"TCP sequence num %u\n" , +ntohl (tcphdr->seq)); +dev_info (dev,"TCP ack_seq %u\n" , +ntohl (tcphdr->ack_seq)); }else if (ip_hdr (skb)->protocol ==IPPROTO_UDP ) { udphdr =udp_hdr (skb);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 210/403 et131x: Add missing check after DMA map
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit d61f6cb6f6ef3c70d2ccc0d9c85c508cb8017da9 ]
The DMA map functions can fail and should be tested for errors. If the mapping fails, unmap and return an error.
--- drivers/net/ethernet/agere/et131x.c | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
drivers/net/ethernet/agere/et131x.c +36 -0
@@ -2464,6 +2464,10 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) skb->data,skb_headlen (skb), DMA_TO_DEVICE); +if (dma_mapping_error (&adapter->pdev->dev, + dma_addr)) +return -ENOMEM ; + desc[frag].addr_lo =lower_32_bits (dma_addr); desc[frag].addr_hi =upper_32_bits (dma_addr); frag++;
@@ -2473,6 +2477,10 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) skb->data,skb_headlen (skb) /2 , DMA_TO_DEVICE); +if (dma_mapping_error (&adapter->pdev->dev, + dma_addr)) +return -ENOMEM ; + desc[frag].addr_lo =lower_32_bits (dma_addr); desc[frag].addr_hi =upper_32_bits (dma_addr); frag++;
@@ -2483,6 +2491,10 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)skb_headlen (skb) /2 ,skb_headlen (skb) /2 , DMA_TO_DEVICE); +if (dma_mapping_error (&adapter->pdev->dev, + dma_addr)) + goto unmap_first_out; + desc[frag].addr_lo =lower_32_bits (dma_addr); desc[frag].addr_hi =upper_32_bits (dma_addr); frag++;
@@ -2494,6 +2506,9 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)0 , desc[frag].len_vlan, DMA_TO_DEVICE); +if (dma_mapping_error (&adapter->pdev->dev, dma_addr)) + goto unmap_out; + desc[frag].addr_lo =lower_32_bits (dma_addr); desc[frag].addr_hi =upper_32_bits (dma_addr); frag++;
@@ -2583,6 +2598,27 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb) &adapter->regs->global.watchdog_timer); }return 0 ; + +unmap_out: +// Unmap the body of the packet with map_page +while (--i) { + frag--; + dma_addr = desc[frag].addr_lo; + dma_addr |= (u64 )desc[frag].addr_hi <<32 ; +dma_unmap_page (&adapter->pdev->dev, dma_addr, + desc[frag].len_vlan,DMA_TO_DEVICE ); + } + +unmap_first_out: +// Unmap the header with map_single +while (frag--) { + dma_addr = desc[frag].addr_lo; + dma_addr |= (u64 )desc[frag].addr_hi <<32 ; +dma_unmap_single (&adapter->pdev->dev, dma_addr, + desc[frag].len_vlan,DMA_TO_DEVICE ); + } + +return -ENOMEM ; }static int send_packet (struct sk_buff *skb,struct et131x_adapter *adapter)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 211/403 net: ag71xx: Add missing check after DMA map
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 96a1e15e60216b52da0e6da5336b6d7f5b0188b0 ]
The DMA map functions can fail and should be tested for errors.
--- drivers/net/ethernet/atheros/ag71xx.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/ethernet/atheros/ag71xx.c +9 -0
@@ -1049,6 +1049,11 @@ static bool ag71xx_fill_rx_buf(struct ag71xx *ag, struct ag71xx_buf *buf, buf->rx.rx_buf = data; buf->rx.dma_addr =dma_map_single (&ag->pdev->dev, data, ag->rx_buf_size,DMA_FROM_DEVICE ); +if (dma_mapping_error (&ag->pdev->dev, buf->rx.dma_addr)) { +skb_free_frag (data); + buf->rx.rx_buf =NULL ; +return false; + } desc->data = (u32 )buf->rx.dma_addr + offset;return true; }
@@ -1343,6 +1348,10 @@ static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb, dma_addr =dma_map_single (&ag->pdev->dev, skb->data, skb->len,DMA_TO_DEVICE ); +if (dma_mapping_error (&ag->pdev->dev, dma_addr)) { +netif_dbg (ag, tx_err, ndev,"DMA mapping error\n" ); + goto err_drop; + } i = ring->curr & ring_mask; desc =ag71xx_ring_desc (ring, i);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 212/403 rcu: Protect ->defer_qs_iw_pending from data race
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul E. McKenney <[email protected]>
[ Upstream commit 90c09d57caeca94e6f3f87c49e96a91edd40cbfd ]
On kernels built with CONFIG_IRQ_WORK=y, when rcu_read_unlock() is invoked within an interrupts-disabled region of code [1], it will invoke rcu_read_unlock_special(), which uses an irq-work handler to force the system to notice when the RCU read-side critical section actually ends. That end won't happen until interrupts are enabled at the soonest.
In some kernels, such as those booted with rcutree.use_softirq=y, the irq-work handler is used unconditionally.
The per-CPU rcu_data structure's ->defer_qs_iw_pending field is updated by the irq-work handler and is both read and updated by rcu_read_unlock_special(). This resulted in the following KCSAN splat:
------------------------------------------------------------------------
BUG: KCSAN: data-race in rcu_preempt_deferred_qs_handler / rcu_read_unlock_special
read to 0xffff96b95f42d8d8 of 1 bytes by task 90 on cpu 8:
rcu_read_unlock_special+0x175/0x260 __rcu_read_unlock+0x92/0xa0 rt_spin_unlock+0x9b/0xc0 __local_bh_enable+0x10d/0x170 __local_bh_enable_ip+0xfb/0x150 rcu_do_batch+0x595/0xc40 rcu_cpu_kthread+0x4e9/0x830 smpboot_thread_fn+0x24d/0x3b0 kthread+0x3bd/0x410 ret_from_fork+0x35/0x40 ret_from_fork_asm+0x1a/0x30
write to 0xffff96b95f42d8d8 of 1 bytes by task 88 on cpu 8:
rcu_preempt_deferred_qs_handler+0x1e/0x30 irq_work_single+0xaf/0x160 run_irq_workd+0x91/0xc0 smpboot_thread_fn+0x24d/0x3b0 kthread+0x3bd/0x410 ret_from_fork+0x35/0x40 ret_from_fork_asm+0x1a/0x30
no locks held by irq_work/8/88.
irq event stamp: 200272 hardirqs last enabled at (200272): [<ffffffffb0f56121>] finish_task_switch+0x131/0x320 hardirqs last disabled at (200271): [<ffffffffb25c7859>] __schedule+0x129/0xd70 softirqs last enabled at (0): [<ffffffffb0ee093f>] copy_process+0x4df/0x1cc0 softirqs last disabled at (0): [<0000000000000000>] 0x0
------------------------------------------------------------------------
The problem is that irq-work handlers run with interrupts enabled, which means that rcu_preempt_deferred_qs_handler() could be interrupted, and that interrupt handler might contain an RCU read-side critical section, which might invoke rcu_read_unlock_special(). In the strict KCSAN mode of operation used by RCU, this constitutes a data race on the ->defer_qs_iw_pending field.
This commit therefore disables interrupts across the portion of the rcu_preempt_deferred_qs_handler() that updates the ->defer_qs_iw_pending field. This suffices because this handler is not a fast path.
--- kernel/rcu/tree_plugin.h | 3 +++ 1 file changed, 3 insertions(+)
kernel/rcu/tree_plugin.h +3 -0
@@ -582,10 +582,13 @@ static void rcu_preempt_deferred_qs(struct task_struct *t)*/ static void rcu_preempt_deferred_qs_handler (struct irq_work *iwp) { +unsigned long flags;struct rcu_data *rdp; rdp = container_of(iwp, struct rcu_data, defer_qs_iw); +local_irq_save (flags); rdp->defer_qs_iw_pending = false; +local_irq_restore (flags); }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 213/403 wifi: cfg80211: Fix interface type validation
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilan Peer <[email protected]>
[ Upstream commit 14450be2332a49445106403492a367412b8c23f4 ]
Fix a condition that verified valid values of interface types.
--- include/net/cfg80211.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/cfg80211.h +1 -1
@@ -433,7 +433,7 @@ ieee80211_get_sband_iftype_data(const struct ieee80211_supported_band *sband, {int i; -if (WARN_ON (iftype >=NL80211_IFTYPE_MAX )) +if (WARN_ON (iftype >=NUM_NL80211_IFTYPES ))return NULL ;if (iftype ==NL80211_IFTYPE_AP_VLAN )
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 214/403 net: ipv4: fix incorrect MTU in broadcast routes
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oscar Maes <[email protected]>
[ Upstream commit 9e30ecf23b1b8f091f7d08b27968dea83aae7908 ]
Currently, __mkroute_output overrules the MTU value configured for broadcast routes.
This buggy behaviour can be reproduced with:
ip link set dev eth1 mtu 9000
ip route del broadcast 192.168.0.255 dev eth1 proto kernel scope link src 192.168.0.2 ip route add broadcast 192.168.0.255 dev eth1 proto kernel scope link src 192.168.0.2 mtu 1500
The maximum packet size should be 1500, but it is actually 8000:
ping -b 192.168.0.255 -s 8000
Fix __mkroute_output to allow MTU values to be configured for for broadcast routes (to support a mixed-MTU local-area-network).
--- net/ipv4/route.c | 1 - 1 file changed, 1 deletion(-)
net/ipv4/route.c +0 -1
@@ -2378,7 +2378,6 @@ static struct rtable *__mkroute_output(const struct fib_result *res, do_cache = true;if (type ==RTN_BROADCAST ) { flags |=RTCF_BROADCAST |RTCF_LOCAL ; - fi =NULL ; } else if (type == RTN_MULTICAST) { flags |= RTCF_MULTICAST | RTCF_LOCAL; if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 215/403 net: thunderx: Fix format-truncation warning in bgx_acpi_match_id()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit 53d20606c40678d425cc03f0978c614dca51f25e ]
The buffer bgx_sel used in snprintf() was too small to safely hold the formatted string "BGX%d" for all valid bgx_id values. This caused a -Wformat-truncation warning with Werror enabled during build.
Increase the buffer size from 5 to 7 and use sizeof(bgx_sel) in snprintf() to ensure safety and suppress the warning.
Build warning:
CC drivers/net/ethernet/cavium/thunder/thunder_bgx.o
drivers/net/ethernet/cavium/thunder/thunder_bgx.c: In function
‘bgx_acpi_match_id’:
drivers/net/ethernet/cavium/thunder/thunder_bgx.c:1434:27: error: ‘%d’
directive output may be truncated writing between 1 and 3 bytes into a region of size 2 [-Werror=format-truncation=]
snprintf(bgx_sel, 5, "BGX%d", bgx->bgx_id);
^~
drivers/net/ethernet/cavium/thunder/thunder_bgx.c:1434:23: note:
directive argument in the range [0, 255]
snprintf(bgx_sel, 5, "BGX%d", bgx->bgx_id);
^~~~~~~
drivers/net/ethernet/cavium/thunder/thunder_bgx.c:1434:2: note:
‘snprintf’ output between 5 and 7 bytes into a destination of size 5
snprintf(bgx_sel, 5, "BGX%d", bgx->bgx_id);compiler warning due to insufficient snprintf buffer size.
--- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/cavium/thunder/thunder_bgx.c +2 -2
@@ -1430,9 +1430,9 @@ static acpi_status bgx_acpi_match_id(acpi_handle handle, u32 lvl, {struct acpi_buffer string = {ACPI_ALLOCATE_BUFFER ,NULL };struct bgx *bgx = context; -char bgx_sel[5 ]; +char bgx_sel[7 ]; -snprintf (bgx_sel,5 ,"BGX%d" , bgx->bgx_id); +snprintf (bgx_sel,sizeof (bgx_sel),"BGX%d" , bgx->bgx_id);if (ACPI_FAILURE (acpi_get_name (handle,ACPI_SINGLE_NAME , &string))) {pr_warn ("Invalid link device\n" );return AE_OK ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 216/403 wifi: iwlwifi: mvm: fix scan request validation
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avraham Stern <[email protected]>
[ Upstream commit 7c2f3ec7707188d8d5269ae2dce97d7be3e9f261 ]
The scan request validation function uses bitwise and instead of logical and. Fix it.
--- drivers/net/wireless/intel/iwlwifi/mvm/scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/scan.c +1 -1
@@ -874,7 +874,7 @@ static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids, int n_channels) { return ((n_ssids <= PROBE_OPTION_MAX) && - (n_channels <= mvm->fw->ucode_capa.n_scan_channels) & + (n_channels <= mvm->fw->ucode_capa.n_scan_channels) && (ies->common_ie_len + ies->len[NL80211_BAND_2GHZ] + ies->len[NL80211_BAND_5GHZ] <=
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 217/403 s390/stp: Remove udelay from stp_sync_clock()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Schnelle <[email protected]>
[ Upstream commit b367017cdac21781a74eff4e208d3d38e1f38d3f ]
When an stp sync check is handled on a system with multiple cpus each cpu gets a machine check but only the first one actually handles the sync operation. All other CPUs spin waiting for the first one to finish with a short udelay(). But udelay can't be used here as the first CPU modifies tod_clock_base before performing the sync op. During this timeframe get_tod_clock_monotonic() might return a non-monotonic time.
The time spent waiting should be very short and udelay is a busy loop anyways, therefore simply remove the udelay.
--- arch/s390/kernel/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/time.c +1 -1
@@ -642,7 +642,7 @@ static int stp_sync_clock(void *data)atomic_dec (&sync->cpus);/* Wait for in_sync to be set. */ while (READ_ONCE (sync->in_sync) ==0 ) -__udelay (1 ); + ; }if (sync->in_sync !=1 )/* Didn't work. Clear per-cpu in sync bit again. */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 218/403 (powerpc/512) Fix possible `dma_unmap_single()` on uninitialized pointer
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 760b9b4f6de9a33ca56a05f950cabe82138d25bd ]
If the device configuration fails (if dma_dev->device_config()), sg_dma_address(&sg) is not initialized and the jump to err_dma_prep leads to calling dma_unmap_single() on sg_dma_address(&sg).
--- arch/powerpc/platforms/512x/mpc512x_lpbfifo.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/powerpc/platforms/512x/mpc512x_lpbfifo.c +2 -4
@@ -240,10 +240,8 @@ static int mpc512x_lpbfifo_kick(void) dma_conf.src_addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ;/* Make DMA channel work with LPB FIFO data register */ -if (dma_dev->device_config (lpbfifo.chan, &dma_conf)) { - ret = -EINVAL ; - goto err_dma_prep; - } +if (dma_dev->device_config (lpbfifo.chan, &dma_conf)) +return -EINVAL ;sg_init_table (&sg,1 );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 219/403 net: fec: allow disable coalescing
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonas Rebmann <[email protected]>
[ Upstream commit b7ad21258f9e9a7f58b19595d5ceed2cde3bed68 ]
In the current implementation, IP coalescing is always enabled and cannot be disabled.
As setting maximum frames to 0 or 1, or setting delay to zero implies immediate delivery of single packets/IRQs, disable coalescing in hardware in these cases.
This also guarantees that coalescing is never enabled with ICFT or ICTT set to zero, a configuration that could lead to unpredictable behaviour according to i.MX8MP reference manual.
--- drivers/net/ethernet/freescale/fec_main.c | 34 +++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-)
drivers/net/ethernet/freescale/fec_main.c +16 -18
@@ -2590,27 +2590,25 @@ static int fec_enet_us_to_itr_clock(struct net_device *ndev, int us)static void fec_enet_itr_coal_set (struct net_device *ndev) {struct fec_enet_private *fep =netdev_priv (ndev); -int rx_itr, tx_itr; +u32 rx_itr =0 , tx_itr =0 ; +int rx_ictt, tx_ictt; -/* Must be greater than zero to avoid unpredictable behavior */ -if (!fep->rx_time_itr || !fep->rx_pkts_itr || - !fep->tx_time_itr || !fep->tx_pkts_itr) -return ; - -/* Select enet system clock as Interrupt Coalescing -* timer Clock Source -*/ - rx_itr =FEC_ITR_CLK_SEL ; - tx_itr =FEC_ITR_CLK_SEL ; + rx_ictt =fec_enet_us_to_itr_clock (ndev, fep->rx_time_itr); + tx_ictt =fec_enet_us_to_itr_clock (ndev, fep->tx_time_itr); -/* set ICFT and ICTT */ - rx_itr |=FEC_ITR_ICFT (fep->rx_pkts_itr); - rx_itr |=FEC_ITR_ICTT (fec_enet_us_to_itr_clock (ndev, fep->rx_time_itr)); - tx_itr |=FEC_ITR_ICFT (fep->tx_pkts_itr); - tx_itr |=FEC_ITR_ICTT (fec_enet_us_to_itr_clock (ndev, fep->tx_time_itr)); +if (rx_ictt >0 && fep->rx_pkts_itr >1 ) { +/* Enable with enet system clock as Interrupt Coalescing timer Clock Source */ + rx_itr =FEC_ITR_EN |FEC_ITR_CLK_SEL ; + rx_itr |=FEC_ITR_ICFT (fep->rx_pkts_itr); + rx_itr |=FEC_ITR_ICTT (rx_ictt); + } - rx_itr |=FEC_ITR_EN ; - tx_itr |=FEC_ITR_EN ; +if (tx_ictt >0 && fep->tx_pkts_itr >1 ) { +/* Enable with enet system clock as Interrupt Coalescing timer Clock Source */ + tx_itr =FEC_ITR_EN |FEC_ITR_CLK_SEL ; + tx_itr |=FEC_ITR_ICFT (fep->tx_pkts_itr); + tx_itr |=FEC_ITR_ICTT (tx_ictt); + }writel (tx_itr, fep->hwp +FEC_TXIC0 );writel (rx_itr, fep->hwp +FEC_RXIC0 );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 220/403 wifi: iwlwifi: dvm: fix potential overflow in rs_fill_link_cmd()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rand Deeb <[email protected]>
[ Upstream commit e3ad987e9dc7d1e12e3f2f1e623f0e174cd0ca78 ]
The 'index' variable in the rs_fill_link_cmd() function can reach LINK_QUAL_MAX_RETRY_NUM during the execution of the inner loop. This variable is used as an index for the lq_cmd->rs_table array, which has a size of LINK_QUAL_MAX_RETRY_NUM, without proper validation.
Modify the condition of the inner loop to ensure that the 'index' variable does not exceed LINK_QUAL_MAX_RETRY_NUM - 1, thereby preventing any potential overflow issues.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wireless/intel/iwlwifi/dvm/rs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/dvm/rs.c +1 -1
@@ -2935,7 +2935,7 @@ static void rs_fill_link_cmd(struct iwl_priv *priv,/* Repeat initial/next rate. * For legacy IWL_NUMBER_TRY == 1, this loop will not execute. * For HT IWL_HT_NUMBER_TRY == 3, this executes twice. */ -while (repeat_rate >0 && (index <LINK_QUAL_MAX_RETRY_NUM )) { +while (repeat_rate >0 && index < (LINK_QUAL_MAX_RETRY_NUM -1 )) {if (is_legacy (tbl_type.lq_type)) {if (ant_toggle_cnt <NUM_TRY_BEFORE_ANT_TOGGLE ) ant_toggle_cnt++;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 221/403 wifi: iwlwifi: fw: Fix possible memory leak in iwl_fw_dbg_collect
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pagadala Yesu Anjaneyulu <[email protected]>
[ Upstream commit cc8d9cbf269dab363c768bfa9312265bc807fca5 ]
Ensure descriptor is freed on error to avoid memory leak.
--- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +6 -1
@@ -2130,6 +2130,7 @@ int iwl_fw_dbg_collect(struct iwl_fw_runtime *fwrt,struct iwl_fw_dump_desc *desc;unsigned int delay =0 ;bool monitor_only = false; +int ret;if (trigger) {u16 occurrences =le16_to_cpu (trigger->occurrences) -1 ;
@@ -2160,7 +2161,11 @@ int iwl_fw_dbg_collect(struct iwl_fw_runtime *fwrt, desc->trig_desc.type =cpu_to_le32 (trig);memcpy (desc->trig_desc.data, str, len); -return iwl_fw_dbg_collect_desc (fwrt, desc, monitor_only, delay); + ret =iwl_fw_dbg_collect_desc (fwrt, desc, monitor_only, delay); +if (ret) +kfree (desc); + +return ret; }IWL_EXPORT_SYMBOL (iwl_fw_dbg_collect);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 222/403 wifi: rtlwifi: fix possible skb memory leak in `_rtl_pci_rx_interrupt()`.
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 44c0e191004f0e3aa1bdee3be248be14dbe5b020 ]
The function _rtl_pci_init_one_rxdesc() can fail even when the new skb is passed because of a DMA mapping error. If it fails, the skb is not saved in the rx ringbuffer and thus lost.
Compile tested only
--- drivers/net/wireless/realtek/rtlwifi/pci.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/net/wireless/realtek/rtlwifi/pci.c +12 -6
@@ -804,13 +804,19 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) skb = new_skb; no_new:if (rtlpriv->use_new_trx_flow) { -_rtl_pci_init_one_rxdesc (hw, skb, (u8 *)buffer_desc, - rxring_idx, - rtlpci->rx_ring[rxring_idx].idx); +if (!_rtl_pci_init_one_rxdesc (hw, skb, (u8 *)buffer_desc, + rxring_idx, + rtlpci->rx_ring[rxring_idx].idx)) { +if (new_skb) +dev_kfree_skb_any (skb); + } }else { -_rtl_pci_init_one_rxdesc (hw, skb, (u8 *)pdesc, - rxring_idx, - rtlpci->rx_ring[rxring_idx].idx); +if (!_rtl_pci_init_one_rxdesc (hw, skb, (u8 *)pdesc, + rxring_idx, + rtlpci->rx_ring[rxring_idx].idx)) { +if (new_skb) +dev_kfree_skb_any (skb); + }if (rtlpci->rx_ring[rxring_idx].idx == rtlpci->rxringcount -1 ) rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 223/403 netmem: fix skb_frag_address_safe with unreadable skbs
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mina Almasry <[email protected]>
[ Upstream commit 4672aec56d2e8edabcb74c3e2320301d106a377e ]
skb_frag_address_safe() needs a check that the skb_frag_page exists check similar to skb_frag_address().
--- include/linux/skbuff.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/linux/skbuff.h +7 -1
@@ -3073,7 +3073,13 @@ static inline void *skb_frag_address(const skb_frag_t *frag)*/ static inline void *skb_frag_address_safe (const skb_frag_t *frag) { -void *ptr =page_address (skb_frag_page (frag)); +struct page *page =skb_frag_page (frag); +void *ptr; + +if (!page) +return NULL ; + + ptr =page_address (page);if (unlikely (!ptr))return NULL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 224/403 wifi: iwlegacy: Check rate_idx range after addition
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislaw Gruszka <[email protected]>
[ Upstream commit 0de19d5ae0b2c5b18b88c5c7f0442f707a207409 ]
Limit rate_idx to IL_LAST_OFDM_RATE for 5GHz band for thinkable case the index is incorrect.
--- drivers/net/wireless/intel/iwlegacy/4965-mac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlegacy/4965-mac.c +4 -1
@@ -1573,8 +1573,11 @@ il4965_tx_cmd_build_rate(struct il_priv *il, || rate_idx > RATE_COUNT_LEGACY) rate_idx =rate_lowest_index (&il->bands[info->band], sta);/* For 5 GHZ band, remap mac80211 rate indices into driver indices */ -if (info->band ==NL80211_BAND_5GHZ ) +if (info->band ==NL80211_BAND_5GHZ ) { rate_idx +=IL_FIRST_OFDM_RATE ; +if (rate_idx >IL_LAST_OFDM_RATE ) + rate_idx =IL_LAST_OFDM_RATE ; + }/* Get PLCP rate for tx_cmd->rate_n_flags */ rate_plcp = il_rates[rate_idx].plcp;/* Zero out flags for this packet */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 225/403 net: vlan: Replace BUG() with WARN_ON_ONCE() in vlan_dev_* stubs
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <[email protected]>
[ Upstream commit 60a8b1a5d0824afda869f18dc0ecfe72f8dfda42 ]
When CONFIG_VLAN_8021Q=n, a set of stub helpers are used, three of these helpers use BUG() unconditionally.
This code should not be reached, as callers of these functions should always check for is_vlan_dev() first, but the usage of BUG() is not recommended, replace it with WARN_ON() instead.
--- include/linux/if_vlan.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/if_vlan.h +3 -3
@@ -240,19 +240,19 @@ vlan_for_each(struct net_device *dev,static inline struct net_device *vlan_dev_real_dev (const struct net_device *dev) { -BUG (); +WARN_ON_ONCE (1 );return NULL ; }static inline u16 vlan_dev_vlan_id (const struct net_device *dev) { -BUG (); +WARN_ON_ONCE (1 );return 0 ; }static inline __be16 vlan_dev_vlan_proto (const struct net_device *dev) { -BUG (); +WARN_ON_ONCE (1 );return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 226/403 net: dsa: b53: fix b53_imp_vlan_setup for BCM5325
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Álvaro Fernández Rojas <[email protected]>
[ Upstream commit c00df1018791185ea398f78af415a2a0aaa0c79c ]
CPU port should be B53_CPU_PORT instead of B53_CPU_PORT_25 for B53_PVLAN_PORT_MASK register.
--- drivers/net/dsa/b53/b53_common.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/dsa/b53/b53_common.c +4 -0
@@ -502,6 +502,10 @@ void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port)unsigned int i;u16 pvlan; +/* BCM5325 CPU port is at 8 */ +if ((is5325 (dev) ||is5365 (dev)) && cpu_port ==B53_CPU_PORT_25 ) + cpu_port =B53_CPU_PORT ; +/* Enable the IMP port to be in the same VLAN as the other ports * on a per-port basis such that we only have Port i and IMP in * the same VLAN.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 227/403 net: dsa: b53: prevent SWITCH_CTRL access on BCM5325
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Álvaro Fernández Rojas <[email protected]>
[ Upstream commit 22ccaaca43440e90a3b68d2183045b42247dc4be ]
BCM5325 doesn't implement SWITCH_CTRL register so we should avoid reading or writing it.
--- drivers/net/dsa/b53/b53_common.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/net/dsa/b53/b53_common.c +6 -5
@@ -337,11 +337,12 @@ static void b53_set_forwarding(struct b53_device *dev, int enable)b53_write8 (dev,B53_CTRL_PAGE ,B53_SWITCH_MODE , mgmt); -/* Include IMP port in dumb forwarding mode -*/ -b53_read8 (dev,B53_CTRL_PAGE ,B53_SWITCH_CTRL , &mgmt); - mgmt |=B53_MII_DUMB_FWDG_EN ; -b53_write8 (dev,B53_CTRL_PAGE ,B53_SWITCH_CTRL , mgmt); +if (!is5325 (dev)) { +/* Include IMP port in dumb forwarding mode */ +b53_read8 (dev,B53_CTRL_PAGE ,B53_SWITCH_CTRL , &mgmt); + mgmt |=B53_MII_DUMB_FWDG_EN ; +b53_write8 (dev,B53_CTRL_PAGE ,B53_SWITCH_CTRL , mgmt); + }/* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether * frames should be flooded or not.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 228/403 net: ncsi: Fix buffer overflow in fetching version id
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hari Kalavakunta <[email protected]>
[ Upstream commit 8e16170ae972c7fed132bc928914a2ffb94690fc ]
In NC-SI spec v1.2 section 8.4.44.2, the firmware name doesn't need to be null terminated while its size occupies the full size of the field. Fix the buffer overflow issue by adding one additional byte for null terminator.
--- net/ncsi/internal.h | 2 +- net/ncsi/ncsi-rsp.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
net/ncsi/internal.h +1 -1
@@ -86,7 +86,7 @@ struct ncsi_channel_version {u8 update;/* NCSI version update */ char alpha1;/* NCSI version alpha1 */ char alpha2;/* NCSI version alpha2 */ -u8 fw_name[12 ];/* Firmware name string */ +u8 fw_name[12 +1 ];/* Firmware name string */ u32 fw_version;/* Firmware version */ u16 pci_ids[4 ];/* PCI identification */ u32 mf_id;/* Manufacture ID */
net/ncsi/ncsi-rsp.c +1 -0
@@ -782,6 +782,7 @@ static int ncsi_rsp_handler_gvi(struct ncsi_request *nr) ncv->alpha1 = rsp->alpha1; ncv->alpha2 = rsp->alpha2;memcpy (ncv->fw_name, rsp->fw_name,12 ); + ncv->fw_name[12 ] ='\0' ; ncv->fw_version =ntohl (rsp->fw_version);for (i =0 ; i <ARRAY_SIZE (ncv->pci_ids); i++) ncv->pci_ids[i] =ntohs (rsp->pci_ids[i]);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 229/403 uapi: in6: restore visibility of most IPv6 socket options
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 31557b3487b349464daf42bc4366153743c1e727 ]
A decade ago commit 6d08acd2d32e ("in6: fix conflict with glibc") hid the definitions of IPV6 options, because GCC was complaining about duplicates. The commit did not list the warnings seen, but trying to recreate them now I think they are (building iproute2):
In file included from ./include/uapi/rdma/rdma_user_cm.h:39,
from rdma.h:16,
from res.h:9,
from res-ctx.c:7:
../include/uapi/linux/in6.h:171:9: warning: ‘IPV6_ADD_MEMBERSHIP’ redefined
171 | #define IPV6_ADD_MEMBERSHIP 20
| ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/netinet/in.h:37,
from rdma.h:13:
/usr/include/bits/in.h:233:10: note: this is the location of the previous definition
233 | # define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
| ^~~~~~~~~~~~~~~~~~~
../include/uapi/linux/in6.h:172:9: warning: ‘IPV6_DROP_MEMBERSHIP’ redefined
172 | #define IPV6_DROP_MEMBERSHIP 21
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/bits/in.h:234:10: note: this is the location of the previous definition
234 | # define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
| ^~~~~~~~~~~~~~~~~~~~Compilers don't complain about redefinition if the defines are identical, but here we have the kernel using the literal value, and glibc using an indirection (defining to a name of another define, with the same numerical value).
Problem is, the commit in question hid all the IPV6 socket options, and glibc has a pretty sparse list. For instance it lacks Flow Label related options. Willem called this out in commit 3fb321fde22d ("selftests/net: ipv6 flowlabel"):
/* uapi/glibc weirdness may leave this undefined */ #ifndef IPV6_FLOWINFO #define IPV6_FLOWINFO 11 #endif
More interestingly some applications (socat) use a #ifdef IPV6_FLOWINFO to gate compilation of thier rudimentary flow label support. (For added confusion socat misspells it as IPV4_FLOWINFO in some places.)
Hide only the two defines we know glibc has a problem with. If we discover more warnings we can hide more but we should avoid covering the entire block of defines for "IPV6 socket options".
--- include/uapi/linux/in6.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/in6.h +2 -2
@@ -151,7 +151,6 @@ struct in6_flowlabel_req {/* * IPV6 socket options */ -#if __UAPI_DEF_IPV6_OPTIONS#define IPV6_ADDRFORM 1#define IPV6_2292PKTINFO 2#define IPV6_2292HOPOPTS 3
@@ -168,8 +167,10 @@ struct in6_flowlabel_req {#define IPV6_MULTICAST_IF 17#define IPV6_MULTICAST_HOPS 18#define IPV6_MULTICAST_LOOP 19 +#if __UAPI_DEF_IPV6_OPTIONS#define IPV6_ADD_MEMBERSHIP 20#define IPV6_DROP_MEMBERSHIP 21 +#endif #define IPV6_ROUTER_ALERT 22#define IPV6_MTU_DISCOVER 23#define IPV6_MTU 24
@@ -201,7 +202,6 @@ struct in6_flowlabel_req {#define IPV6_IPSEC_POLICY 34#define IPV6_XFRM_POLICY 35#define IPV6_HDRINCL 36 -#endif /* * Multicast:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 230/403 net: dsa: b53: fix IP_MULTICAST_CTRL on BCM5325
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Álvaro Fernández Rojas <[email protected]>
[ Upstream commit 044d5ce2788b165798bfd173548e61bf7b6baf4d ]
BCM5325 doesn't implement B53_UC_FWD_EN, B53_MC_FWD_EN or B53_IPMC_FWD_EN.
--- drivers/net/dsa/b53/b53_common.c | 18 +++++++++++------- drivers/net/dsa/b53/b53_regs.h | 1 + 2 files changed, 12 insertions(+), 7 deletions(-)
drivers/net/dsa/b53/b53_common.c +11 -7
@@ -342,14 +342,18 @@ static void b53_set_forwarding(struct b53_device *dev, int enable)b53_read8 (dev,B53_CTRL_PAGE ,B53_SWITCH_CTRL , &mgmt); mgmt |=B53_MII_DUMB_FWDG_EN ;b53_write8 (dev,B53_CTRL_PAGE ,B53_SWITCH_CTRL , mgmt); - } -/* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether -* frames should be flooded or not. -*/ -b53_read8 (dev,B53_CTRL_PAGE ,B53_IP_MULTICAST_CTRL , &mgmt); - mgmt |=B53_UC_FWD_EN |B53_MC_FWD_EN |B53_IPMC_FWD_EN ; -b53_write8 (dev,B53_CTRL_PAGE ,B53_IP_MULTICAST_CTRL , mgmt); +/* Look at B53_UC_FWD_EN and B53_MC_FWD_EN to decide whether +* frames should be flooded or not. +*/ +b53_read8 (dev,B53_CTRL_PAGE ,B53_IP_MULTICAST_CTRL , &mgmt); + mgmt |=B53_UC_FWD_EN |B53_MC_FWD_EN |B53_IPMC_FWD_EN ; +b53_write8 (dev,B53_CTRL_PAGE ,B53_IP_MULTICAST_CTRL , mgmt); + }else { +b53_read8 (dev,B53_CTRL_PAGE ,B53_IP_MULTICAST_CTRL , &mgmt); + mgmt |=B53_IP_MCAST_25 ; +b53_write8 (dev,B53_CTRL_PAGE ,B53_IP_MULTICAST_CTRL , mgmt); + } } static void b53_enable_vlan(struct b53_device *dev, bool enable,
drivers/net/dsa/b53/b53_regs.h +1 -0
@@ -103,6 +103,7 @@/* IP Multicast control (8 bit) */ #define B53_IP_MULTICAST_CTRL 0x21 +#define B53_IP_MCAST_25 BIT(0)#define B53_IPMC_FWD_EN BIT(1)#define B53_UC_FWD_EN BIT(6)#define B53_MC_FWD_EN BIT(7)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 231/403 vhost: fail early when __vhost_add_used() fails
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Wang <[email protected]>
[ Upstream commit b4ba1207d45adaafa2982c035898b36af2d3e518 ]
This patch fails vhost_add_used_n() early when __vhost_add_used() fails to make sure used idx is not updated with stale used ring information.
Message-Id: <[email protected]>
--- drivers/vhost/vhost.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/vhost/vhost.c +3 -0
@@ -2422,6 +2422,9 @@ int vhost_add_used_n(struct vhost_virtqueue *vq, struct vring_used_elem *heads, } r =__vhost_add_used_n (vq, heads, count); +if (r <0 ) +return r; +/* Make sure buffer is written before we update index. */ smp_wmb ();if (vhost_put_used_idx (vq)) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 232/403 cifs: Fix calling CIFSFindFirst() for root path without msearch
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pali Rohár <[email protected]>
[ Upstream commit b460249b9a1dab7a9f58483e5349d045ad6d585c ]
To query root path (without msearch wildcard) it is needed to send pattern '\' instead of '' (empty string).
This allows to use CIFSFindFirst() to query information about root path which is being used in followup changes.
This change fixes the stat() syscall called on the root path on the mount. It is because stat() syscall uses the cifs_query_path_info() function and it can fallback to the CIFSFindFirst() usage with msearch=false.
--- fs/cifs/cifssmb.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/cifs/cifssmb.c +10 -0
@@ -4544,6 +4544,12 @@ CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon, pSMB->FileName[name_len] =0 ; pSMB->FileName[name_len+1 ] =0 ; name_len +=2 ; + }else if (!searchName[0 ]) { + pSMB->FileName[0 ] =CIFS_DIR_SEP (cifs_sb); + pSMB->FileName[1 ] =0 ; + pSMB->FileName[2 ] =0 ; + pSMB->FileName[3 ] =0 ; + name_len =4 ; } }else { name_len =copy_path_name (pSMB->FileName, searchName);
@@ -4555,6 +4561,10 @@ CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon, pSMB->FileName[name_len] ='*' ; pSMB->FileName[name_len+1 ] =0 ; name_len +=2 ; + }else if (!searchName[0 ]) { + pSMB->FileName[0 ] =CIFS_DIR_SEP (cifs_sb); + pSMB->FileName[1 ] =0 ; + name_len =2 ; } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 233/403 ext4: do not BUG when INLINE_DATA_FL lacks system.data xattr
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
[ Upstream commit 099b847ccc6c1ad2f805d13cfbcc83f5b6d4bc42 ]
A syzbot fuzzed image triggered a BUG_ON in ext4_update_inline_data() when an inode had the INLINE_DATA_FL flag set but was missing the system.data extended attribute.
Since this can happen due to a maiciouly fuzzed file system, we shouldn't BUG, but rather, report it as a corrupted file system.
Add similar replacements of BUG_ON with EXT4_ERROR_INODE() ii ext4_create_inline_data() and ext4_inline_data_truncate().
--- fs/ext4/inline.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
fs/ext4/inline.c +16 -3
@@ -296,7 +296,11 @@ static int ext4_create_inline_data(handle_t *handle,if (error) goto out; -BUG_ON (!is.s.not_found); +if (!is.s.not_found) { +EXT4_ERROR_INODE (inode,"unexpected inline data xattr" ); + error = -EFSCORRUPTED ; + goto out; + } error =ext4_xattr_ibody_set (handle, inode, &i, &is);if (error) {
@@ -347,7 +351,11 @@ static int ext4_update_inline_data(handle_t *handle, struct inode *inode,if (error) goto out; -BUG_ON (is.s.not_found); +if (is.s.not_found) { +EXT4_ERROR_INODE (inode,"missing inline data xattr" ); + error = -EFSCORRUPTED ; + goto out; + } len -=EXT4_MIN_INLINE_DATA_SIZE ; value =kzalloc (len,GFP_NOFS );
@@ -1978,7 +1986,12 @@ int ext4_inline_data_truncate(struct inode *inode, int *has_inline)if ((err =ext4_xattr_ibody_find (inode, &i, &is)) !=0 ) goto out_error; -BUG_ON (is.s.not_found); +if (is.s.not_found) { +EXT4_ERROR_INODE (inode, +"missing inline data xattr" ); + err = -EFSCORRUPTED ; + goto out_error; + } value_len =le32_to_cpu (is.s.here->e_value_size); value =kmalloc (value_len,GFP_NOFS );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 234/403 scsi: libiscsi: Initialize iscsi_conn->dd_data only if memory is allocated
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Showrya M N <[email protected]>
[ Upstream commit 3ea3a256ed81f95ab0f3281a0e234b01a9cae605 ]
In case of an ib_fast_reg_mr allocation failure during iSER setup, the machine hits a panic because iscsi_conn->dd_data is initialized unconditionally, even when no memory is allocated (dd_size == 0). This leads invalid pointer dereference during connection teardown.
Fix by setting iscsi_conn->dd_data only if memory is actually allocated.
Panic trace:
------------
iser: iser_create_fastreg_desc: Failed to allocate ib_fast_reg_mr err=-12
iser: iser_alloc_rx_descriptors: failed allocating rx descriptors / data buffers
BUG: unable to handle page fault for address: fffffffffffffff8 RIP: 0010:swake_up_locked.part.5+0xa/0x40 Call Trace: complete+0x31/0x40 iscsi_iser_conn_stop+0x88/0xb0 [ib_iser] iscsi_stop_conn+0x66/0xc0 [scsi_transport_iscsi] iscsi_if_stop_conn+0x14a/0x150 [scsi_transport_iscsi] iscsi_if_rx+0x1135/0x1834 [scsi_transport_iscsi] ? netlink_lookup+0x12f/0x1b0 ? netlink_deliver_tap+0x2c/0x200 netlink_unicast+0x1ab/0x280 netlink_sendmsg+0x257/0x4f0 ? _copy_from_user+0x29/0x60 sock_sendmsg+0x5f/0x70
--- drivers/scsi/libiscsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/libiscsi.c +2 -1
@@ -2893,7 +2893,8 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, conn = cls_conn->dd_data;memset (conn,0 ,sizeof (*conn) + dd_size); - conn->dd_data = cls_conn->dd_data +sizeof (*conn); +if (dd_size) + conn->dd_data = cls_conn->dd_data +sizeof (*conn); conn->session = session; conn->cls_conn = cls_conn; conn->c_stage =ISCSI_CONN_INITIAL_STAGE ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 235/403 fs/orangefs: use snprintf() instead of sprintf()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Mohammad Jahangirzad <[email protected]>
[ Upstream commit cdfa1304657d6f23be8fd2bb0516380a3c89034e ]
sprintf() is discouraged for use with bounded destination buffers as it does not prevent buffer overflows when the formatted output exceeds the destination buffer size. snprintf() is a safer alternative as it limits the number of bytes written and ensures NUL-termination.
Replace sprintf() with snprintf() for copying the debug string into a temporary buffer, using ORANGEFS_MAX_DEBUG_STRING_LEN as the maximum size to ensure safe formatting and prevent memory corruption in edge cases.
EDIT: After this patch sat on linux-next for a few days, Dan Carpenter saw it and suggested that I use scnprintf instead of snprintf. I made the change and retested.
--- fs/orangefs/orangefs-debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/orangefs/orangefs-debugfs.c +1 -1
@@ -354,7 +354,7 @@ static ssize_t orangefs_debug_read(struct file *file, goto out;mutex_lock (&orangefs_debug_lock); - sprintf_ret =sprintf (buf,"%s" , (char *)file->private_data); + sprintf_ret =scnprintf (buf,ORANGEFS_MAX_DEBUG_STRING_LEN ,"%s" , (char *)file->private_data);mutex_unlock (&orangefs_debug_lock); read_ret =simple_read_from_buffer (ubuf, count, ppos, buf, sprintf_ret);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 236/403 watchdog: dw_wdt: Fix default timeout
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit ac3dbb91e0167d017f44701dd51c1efe30d0c256 ]
The Synopsys Watchdog driver sets the default timeout to 30 seconds, but on some devices this is not a valid timeout. E.g. on RK3588 the actual timeout being used is 44 seconds instead.
Once the watchdog is started the value is updated accordingly, but it would be better to expose a sensible timeout to userspace without the need to first start the watchdog.
--- drivers/watchdog/dw_wdt.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/watchdog/dw_wdt.c +2 -0
@@ -289,6 +289,8 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) }else { wdd->timeout =DW_WDT_DEFAULT_SECONDS ;watchdog_init_timeout (wdd,0 , dev); +/* Limit timeout value to hardware constraints. */ +dw_wdt_set_timeout (wdd, wdd->timeout); }platform_set_drvdata (pdev, dw_wdt);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 237/403 MIPS: vpe-mt: add missing prototypes for vpe_{alloc,start,stop,free}
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shiji Yang <[email protected]>
[ Upstream commit 844615dd0f2d95c018ec66b943e08af22b62aff3 ]
These functions are exported but their prototypes are not defined. This patch adds the missing function prototypes to fix the following compilation warnings:
arch/mips/kernel/vpe-mt.c:180:7: error: no previous prototype for 'vpe_alloc' [-Werror=missing-prototypes]
180 | void *vpe_alloc(void)
| ^~~~~~~~~
arch/mips/kernel/vpe-mt.c:198:5: error: no previous prototype for 'vpe_start' [-Werror=missing-prototypes]
198 | int vpe_start(void *vpe, unsigned long start)
| ^~~~~~~~~
arch/mips/kernel/vpe-mt.c:208:5: error: no previous prototype for 'vpe_stop' [-Werror=missing-prototypes]
208 | int vpe_stop(void *vpe)
| ^~~~~~~~
arch/mips/kernel/vpe-mt.c:229:5: error: no previous prototype for 'vpe_free' [-Werror=missing-prototypes]
229 | int vpe_free(void *vpe)
| ^~~~~~~~--- arch/mips/include/asm/vpe.h | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/mips/include/asm/vpe.h +8 -0
@@ -126,4 +126,12 @@ void cleanup_tc(struct tc *tc);int __init vpe_module_init (void ); void __exit vpe_module_exit(void); + +#ifdef CONFIG_MIPS_VPE_LOADER_MT +void *vpe_alloc (void ); +int vpe_start (void *vpe,unsigned long start); +int vpe_stop (void *vpe); +int vpe_free (void *vpe); +#endif /* CONFIG_MIPS_VPE_LOADER_MT */ +#endif /* _ASM_VPE_H */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 238/403 scsi: bfa: Double-free fix
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: jackysliu <[email protected]>
[ Upstream commit add4c4850363d7c1b72e8fce9ccb21fdd2cf5dc9 ]
When the bfad_im_probe() function fails during initialization, the memory pointed to by bfad->im is freed without setting bfad->im to NULL.
Subsequently, during driver uninstallation, when the state machine enters the bfad_sm_stopping state and calls the bfad_im_probe_undo() function, it attempts to free the memory pointed to by bfad->im again, thereby triggering a double-free vulnerability.
Set bfad->im to NULL if probing fails.
--- drivers/scsi/bfa/bfad_im.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/bfa/bfad_im.c +1 -0
@@ -707,6 +707,7 @@ bfad_im_probe(struct bfad_s *bfad)if (bfad_thread_workq (bfad) !=BFA_STATUS_OK ) {kfree (im); + bfad->im =NULL ;return BFA_STATUS_FAILED ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 239/403 jfs: truncate good inode pages when hard link is 0
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Xu <[email protected]>
[ Upstream commit 2d91b3765cd05016335cd5df5e5c6a29708ec058 ]
The fileset value of the inode copy from the disk by the reproducer is AGGR_RESERVED_I. When executing evict, its hard link number is 0, so its inode pages are not truncated. This causes the bugon to be triggered when executing clear_inode() because nrpages is greater than 0.
--- fs/jfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/inode.c +1 -1
@@ -145,9 +145,9 @@ void jfs_evict_inode(struct inode *inode)if (!inode->i_nlink && !is_bad_inode (inode)) {dquot_initialize (inode); +truncate_inode_pages_final (&inode->i_data);if (JFS_IP (inode)->fileset ==FILESYSTEM_I ) {struct inode *ipimap =JFS_SBI (inode->i_sb)->ipimap; -truncate_inode_pages_final (&inode->i_data);if (test_cflag (COMMIT_Freewmap, inode))jfs_free_zero_link (inode);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 240/403 jfs: Regular file corruption check
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Adam Davis <[email protected]>
[ Upstream commit 2d04df8116426b6c7b9f8b9b371250f666a2a2fb ]
The reproducer builds a corrupted file on disk with a negative i_size value. Add a check when opening this file to avoid subsequent operation failures.
--- fs/jfs/file.c | 3 +++ 1 file changed, 3 insertions(+)
fs/jfs/file.c +3 -0
@@ -44,6 +44,9 @@ static int jfs_open(struct inode *inode, struct file *file) {int rc; +if (S_ISREG (inode->i_mode) && inode->i_size <0 ) +return -EIO ; +if ((rc =dquot_file_open (inode, file)))return rc;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 241/403 jfs: upper bound check of tree index in dbAllocAG
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaud Lecomte <[email protected]>
[ Upstream commit c214006856ff52a8ff17ed8da52d50601d54f9ce ]
When computing the tree index in dbAllocAG, we never check if we are out of bounds realative to the size of the stree.
This could happen in a scenario where the filesystem metadata are corrupted.
--- fs/jfs/jfs_dmap.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/jfs/jfs_dmap.c +6 -0
@@ -1457,6 +1457,12 @@ dbAllocAG(struct bmap * bmp, int agno, s64 nblocks, int l2nb, s64 * results) (1 << (L2LPERCTL - (bmp->db_agheight <<1 ))) / bmp->db_agwidth; ti = bmp->db_agstart + bmp->db_agwidth * (agno & (agperlev -1 )); +if (ti <0 || ti >=le32_to_cpu (dcp->nleafs)) { +jfs_error (bmp->db_ipbmap->i_sb,"Corrupt dmapctl page\n" ); +release_metapage (mp); +return -EIO ; + } +/* dmap control page trees fan-out by 4 and a single allocation * group may be described by 1 or 2 subtrees within the ag level * dmap control page, depending upon the ag size. examine the ag's
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 242/403 MIPS: Dont crash in stack_top() for tasks without ABI or vDSO
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit e9f4a6b3421e936c3ee9d74710243897d74dbaa2 ]
Not all tasks have an ABI associated or vDSO mapped,
for example kthreads never do.
If such a task ever ends up calling stack_top(), it will derefence the NULL ABI pointer and crash.
This can for example happen when using kunit:
mips_stack_top+0x28/0xc0
arch_pick_mmap_layout+0x190/0x220
kunit_vm_mmap_init+0xf8/0x138
__kunit_add_resource+0x40/0xa8
kunit_vm_mmap+0x88/0xd8
usercopy_test_init+0xb8/0x240
kunit_try_run_case+0x5c/0x1a8
kunit_generic_run_threadfn_adapter+0x28/0x50
kthread+0x118/0x240
ret_from_kernel_thread+0x14/0x1cOnly dereference the ABI point if it is set.
The GIC page is also included as it is specific to the vDSO. Also move the randomization adjustment into the same conditional.
--- arch/mips/kernel/process.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
arch/mips/kernel/process.c +9 -7
@@ -654,18 +654,20 @@ unsigned long mips_stack_top(void) top -=PAGE_SIZE ;/* Space for the VDSO, data page & GIC user page */ - top -=PAGE_ALIGN (current->thread.abi->vdso->size); - top -=PAGE_SIZE ; - top -=mips_gic_present () ?PAGE_SIZE :0 ; +if (current->thread.abi) { + top -=PAGE_ALIGN (current->thread.abi->vdso->size); + top -=PAGE_SIZE ; + top -=mips_gic_present () ?PAGE_SIZE :0 ; + +/* Space to randomize the VDSO base */ +if (current->flags &PF_RANDOMIZE ) + top -=VDSO_RANDOMIZE_SIZE ; + }/* Space for cache colour alignment */ if (cpu_has_dc_aliases) top -= shm_align_mask +1 ; -/* Space to randomize the VDSO base */ -if (current->flags &PF_RANDOMIZE ) - top -=VDSO_RANDOMIZE_SIZE ; -return top; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 243/403 RDMA: hfi1: fix possible divide-by-zero in find_hw_thread_mask()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yury Norov [NVIDIA] <[email protected]>
[ Upstream commit 59f7d2138591ef8f0e4e4ab5f1ab674e8181ad3a ]
The function divides number of online CPUs by num_core_siblings, and later checks the divider by zero. This implies a possibility to get and divide-by-zero runtime error. Fix it by moving the check prior to division. This also helps to save one indentation level.
--- drivers/infiniband/hw/hfi1/affinity.c | 44 +++++++++++++++------------ 1 file changed, 24 insertions(+), 20 deletions(-)
drivers/infiniband/hw/hfi1/affinity.c +24 -20
@@ -1009,31 +1009,35 @@ static void find_hw_thread_mask(uint hw_thread_no, cpumask_var_t hw_thread_mask, struct hfi1_affinity_node_list *affinity) {int possible, curr_cpu, i; -uint num_cores_per_socket = node_affinity.num_online_cpus / +uint num_cores_per_socket; + +cpumask_copy (hw_thread_mask, &affinity->proc.mask); + +if (affinity->num_core_siblings ==0 ) +return ; + + num_cores_per_socket = node_affinity.num_online_cpus / affinity->num_core_siblings / node_affinity.num_online_nodes; -cpumask_copy (hw_thread_mask, &affinity->proc.mask); -if (affinity->num_core_siblings >0 ) { -/* Removing other siblings not needed for now */ - possible =cpumask_weight (hw_thread_mask); - curr_cpu =cpumask_first (hw_thread_mask); -for (i =0 ; - i < num_cores_per_socket * node_affinity.num_online_nodes; - i++) - curr_cpu =cpumask_next (curr_cpu, hw_thread_mask); - -for (; i < possible; i++) { -cpumask_clear_cpu (curr_cpu, hw_thread_mask); - curr_cpu =cpumask_next (curr_cpu, hw_thread_mask); - } +/* Removing other siblings not needed for now */ + possible =cpumask_weight (hw_thread_mask); + curr_cpu =cpumask_first (hw_thread_mask); +for (i =0 ; + i < num_cores_per_socket * node_affinity.num_online_nodes; + i++) + curr_cpu =cpumask_next (curr_cpu, hw_thread_mask); -/* Identifying correct HW threads within physical cores */ -cpumask_shift_left (hw_thread_mask, hw_thread_mask, - num_cores_per_socket * - node_affinity.num_online_nodes * - hw_thread_no); +for (; i < possible; i++) { +cpumask_clear_cpu (curr_cpu, hw_thread_mask); + curr_cpu =cpumask_next (curr_cpu, hw_thread_mask); } + +/* Identifying correct HW threads within physical cores */ +cpumask_shift_left (hw_thread_mask, hw_thread_mask, + num_cores_per_socket * + node_affinity.num_online_nodes * + hw_thread_no); }int hfi1_get_proc_affinity (int node)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 244/403 scsi: lpfc: Check for hdwq null ptr when cleaning up lpfc_vport structure
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Tee <[email protected]>
[ Upstream commit 6698796282e828733cde3329c887b4ae9e5545e9 ]
If a call to lpfc_sli4_read_rev() from lpfc_sli4_hba_setup() fails, the resultant cleanup routine lpfc_sli4_vport_delete_fcp_xri_aborted() may occur before sli4_hba.hdwqs are allocated. This may result in a null pointer dereference when attempting to take the abts_io_buf_list_lock for the first hardware queue. Fix by adding a null ptr check on phba->sli4_hba.hdwq and early return because this situation means there must have been an error during port initialization.
--- drivers/scsi/lpfc/lpfc_scsi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/lpfc/lpfc_scsi.c +4 -0
@@ -469,6 +469,10 @@ lpfc_sli4_vport_delete_fcp_xri_aborted(struct lpfc_vport *vport)if (!(vport->cfg_enable_fc4_type &LPFC_ENABLE_FCP ))return ; +/* may be called before queues established if hba_setup fails */ +if (!phba->sli4_hba.hdwq) +return ; +spin_lock_irqsave (&phba->hbalock, iflag);for (idx =0 ; idx < phba->cfg_hdw_queue; idx++) { qp = &phba->sli4_hba.hdwq[idx];
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 245/403 scsi: mpt3sas: Correctly handle ATA device errors
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 15592a11d5a5c8411ac8494ec49736b658f6fbff ]
With the ATA error model, an NCQ command failure always triggers an abort (termination) of all NCQ commands queued on the device. In such case, the SAT or the host must handle the failed command according to the command sense data and immediately retry all other NCQ commands that were aborted due to the failed NCQ command.
For SAS HBAs controlled by the mpt3sas driver, NCQ command aborts are not handled by the HBA SAT and sent back to the host, with an ioc log information equal to 0x31080000 (IOC_LOGINFO_PREFIX_PL with the PL code PL_LOGINFO_CODE_SATA_NCQ_FAIL_ALL_CMDS_AFTR_ERR). The function _scsih_io_done() always forces a retry of commands terminated with the status MPI2_IOCSTATUS_SCSI_IOC_TERMINATED using the SCSI result DID_SOFT_ERROR, regardless of the log_info for the command. This correctly forces the retry of collateral NCQ abort commands, but with the retry counter for the command being incremented. If a command to an ATA device is subject to too many retries due to other NCQ commands failing (e.g. read commands trying to access unreadable sectors), the collateral NCQ abort commands may be terminated with an error as they run out of retries. This violates the SAT specification and causes hard-to-debug command errors.
Solve this issue by modifying the handling of the MPI2_IOCSTATUS_SCSI_IOC_TERMINATED status to check if a command is for an ATA device and if the command loginfo indicates an NCQ collateral abort. If that is the case, force the command retry using the SCSI result DID_IMM_RETRY to avoid incrementing the command retry count.
--- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/scsi/mpt3sas/mpt3sas_scsih.c +19 -0
@@ -181,6 +181,14 @@ struct sense_info {#define MPT3SAS_PORT_ENABLE_COMPLETE (0xFFFD)#define MPT3SAS_ABRT_TASK_SET (0xFFFE)#define MPT3SAS_REMOVE_UNRESPONDING_DEVICES (0xFFFF) + +/* +* SAS Log info code for a NCQ collateral abort after an NCQ error: +* IOC_LOGINFO_PREFIX_PL | PL_LOGINFO_CODE_SATA_NCQ_FAIL_ALL_CMDS_AFTR_ERR +* See: drivers/message/fusion/lsi/mpi_log_sas.h +*/ +#define IOC_LOGINFO_SATA_NCQ_FAIL_AFTER_ERR 0x31080000 +/** * struct fw_event_work - firmware event struct * @list: link list framework
@@ -5327,6 +5335,17 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply) scmd->result =DID_TRANSPORT_DISRUPTED <<16 ; goto out; } +if (log_info ==IOC_LOGINFO_SATA_NCQ_FAIL_AFTER_ERR ) { +/* +* This is a ATA NCQ command aborted due to another NCQ +* command failure. We must retry this command +* immediately but without incrementing its retry +* counter. +*/ +WARN_ON_ONCE (xfer_cnt !=0 ); + scmd->result =DID_IMM_RETRY <<16 ; +break ; + }if (log_info ==0x31110630 ) {if (scmd->retries >2 ) { scmd->result =DID_NO_CONNECT <<16 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 246/403 pinctrl: stm32: Manage irq affinity settings
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheick Traore <[email protected]>
[ Upstream commit 4c5cc2f65386e22166ce006efe515c667aa075e4 ]
Trying to set the affinity of the interrupts associated to stm32 pinctrl results in a write error.
Fill struct irq_chip::irq_set_affinity to use the default helper function.
--- drivers/pinctrl/stm32/pinctrl-stm32.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/stm32/pinctrl-stm32.c +1 -0
@@ -340,6 +340,7 @@ static struct irq_chip stm32_gpio_irq_chip = { .irq_set_wake = irq_chip_set_wake_parent, .irq_request_resources = stm32_gpio_irq_request_resources, .irq_release_resources = stm32_gpio_irq_release_resources, + .irq_set_affinity = IS_ENABLED(CONFIG_SMP) ? irq_chip_set_affinity_parent : NULL, }; static int stm32_gpio_domain_translate(struct irq_domain *d,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 247/403 media: tc358743: Check I2C succeeded during probe
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Stevenson <[email protected]>
[ Upstream commit 303d81635e1d9c949b370215cc94526ed81f2e3d ]
The probe for the TC358743 reads the CHIPID register from the device and compares it to the expected value of 0. If the I2C request fails then that also returns 0, so the driver loads thinking that the device is there.
Generally I2C communications are reliable so there is limited need to check the return value on every transfer, therefore only amend the one read during probe to check for I2C errors.
--- drivers/media/i2c/tc358743.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
drivers/media/i2c/tc358743.c +23 -4
@@ -110,7 +110,7 @@ static inline struct tc358743_state *to_state(struct v4l2_subdev *sd)/* --------------- I2C --------------- */ -static void i2c_rd (struct v4l2_subdev *sd,u16 reg,u8 *values,u32 n) +static int i2c_rd (struct v4l2_subdev *sd,u16 reg,u8 *values,u32 n) {struct tc358743_state *state =to_state (sd);struct i2c_client *client = state->i2c_client;
@@ -136,6 +136,7 @@ static void i2c_rd(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n)v4l2_err (sd,"%s: reading register 0x%x from 0x%x failed\n" , __func__, reg, client->addr); } +return err !=ARRAY_SIZE (msgs); }static void i2c_wr (struct v4l2_subdev *sd,u16 reg,u8 *values,u32 n)
@@ -192,15 +193,24 @@ static void i2c_wr(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n) } } -static noinline u32 i2c_rdreg(struct v4l2_subdev *sd, u16 reg, u32 n) +static noinline u32 i2c_rdreg_err(struct v4l2_subdev *sd, u16 reg, u32 n, +int *err) { +int error;__le32 val =0 ; -i2c_rd (sd, reg, (u8 __force *)&val, n); + error =i2c_rd (sd, reg, (u8 __force *)&val, n); +if (err) + *err = error;return le32_to_cpu (val); } +static inline u32 i2c_rdreg (struct v4l2_subdev *sd,u16 reg,u32 n) +{ +return i2c_rdreg_err (sd, reg, n,NULL ); +} + static noinline void i2c_wrreg(struct v4l2_subdev *sd, u16 reg, u32 val, u32 n) {__le32 raw =cpu_to_le32 (val);
@@ -229,6 +239,13 @@ static u16 i2c_rd16(struct v4l2_subdev *sd, u16 reg)return i2c_rdreg (sd, reg,2 ); } +static int i2c_rd16_err (struct v4l2_subdev *sd,u16 reg,u16 *value) +{ +int err; + *value =i2c_rdreg_err (sd, reg,2 , &err); +return err; +} +static void i2c_wr16 (struct v4l2_subdev *sd,u16 reg,u16 val) {i2c_wrreg (sd, reg, val,2 );
@@ -2041,6 +2058,7 @@ static int tc358743_probe(struct i2c_client *client)struct tc358743_platform_data *pdata = client->dev.platform_data;struct v4l2_subdev *sd;u16 irq_mask =MASK_HDMI_MSK |MASK_CSI_MSK ; +u16 chipid;int err;if (!i2c_check_functionality (client->adapter,I2C_FUNC_SMBUS_BYTE_DATA ))
@@ -2072,7 +2090,8 @@ static int tc358743_probe(struct i2c_client *client) sd->flags |=V4L2_SUBDEV_FL_HAS_DEVNODE |V4L2_SUBDEV_FL_HAS_EVENTS ;/* i2c access */ -if ((i2c_rd16 (sd,CHIPID ) &MASK_CHIPID ) !=0 ) { +if (i2c_rd16_err (sd,CHIPID , &chipid) || + (chipid &MASK_CHIPID ) !=0 ) {v4l2_info (sd,"not a TC358743 on address 0x%x\n" , client->addr <<1 );return -ENODEV ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 248/403 media: tc358743: Return an appropriate colorspace from tc358743_set_fmt
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Stevenson <[email protected]>
[ Upstream commit 377cc006a364dfdab2f3f221cfad63a9265200b8 ]
When calling tc358743_set_fmt, the code was calling tc358743_get_fmt to choose a valid format. However that sets the colorspace based on information read back from the chip, not the colour format requested.
The result was that if you called try or set format for UYVY when the current format was RGB3 then you would get told SRGB, and try RGB3 when current was UYVY and you would get told SMPTE170M.
The value programmed in the VI_REP register for the colorspace is always set by this driver, therefore there is no need to read back the value, and never set to REC709.
Return the colorspace based on the format set/tried instead.
--- drivers/media/i2c/tc358743.c | 44 ++++++++++++++---------------------- 1 file changed, 17 insertions(+), 27 deletions(-)
drivers/media/i2c/tc358743.c +17 -27
@@ -1685,12 +1685,23 @@ static int tc358743_enum_mbus_code(struct v4l2_subdev *sd,return 0 ; } +static u32 tc358743_g_colorspace (u32 code) +{ +switch (code) { +case MEDIA_BUS_FMT_RGB888_1X24 : +return V4L2_COLORSPACE_SRGB ; +case MEDIA_BUS_FMT_UYVY8_1X16 : +return V4L2_COLORSPACE_SMPTE170M ; +default : +return 0 ; + } +} +static int tc358743_get_fmt (struct v4l2_subdev *sd,struct v4l2_subdev_pad_config *cfg,struct v4l2_subdev_format *format) {struct tc358743_state *state =to_state (sd); -u8 vi_rep =i2c_rd8 (sd,VI_REP );if (format->pad !=0 )return -EINVAL ;
@@ -1700,23 +1711,7 @@ static int tc358743_get_fmt(struct v4l2_subdev *sd, format->format.height = state->timings.bt.height; format->format.field =V4L2_FIELD_NONE ; -switch (vi_rep &MASK_VOUT_COLOR_SEL ) { -case MASK_VOUT_COLOR_RGB_FULL : -case MASK_VOUT_COLOR_RGB_LIMITED : - format->format.colorspace =V4L2_COLORSPACE_SRGB ; -break ; -case MASK_VOUT_COLOR_601_YCBCR_LIMITED : -case MASK_VOUT_COLOR_601_YCBCR_FULL : - format->format.colorspace =V4L2_COLORSPACE_SMPTE170M ; -break ; -case MASK_VOUT_COLOR_709_YCBCR_FULL : -case MASK_VOUT_COLOR_709_YCBCR_LIMITED : - format->format.colorspace =V4L2_COLORSPACE_REC709 ; -break ; -default : - format->format.colorspace =0 ; -break ; - } + format->format.colorspace =tc358743_g_colorspace (format->format.code);return 0 ; }
@@ -1730,19 +1725,14 @@ static int tc358743_set_fmt(struct v4l2_subdev *sd,u32 code = format->format.code;/* is overwritten by get_fmt */ int ret =tc358743_get_fmt (sd, cfg, format); - format->format.code = code; +if (code ==MEDIA_BUS_FMT_RGB888_1X24 || + code ==MEDIA_BUS_FMT_UYVY8_1X16 ) + format->format.code = code; + format->format.colorspace =tc358743_g_colorspace (format->format.code);if (ret)return ret; -switch (code) { -case MEDIA_BUS_FMT_RGB888_1X24 : -case MEDIA_BUS_FMT_UYVY8_1X16 : -break ; -default : -return -EINVAL ; - } -if (format->which ==V4L2_SUBDEV_FORMAT_TRY )return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 249/403 media: tc358743: Increase FIFO trigger level to 374
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Stevenson <[email protected]>
[ Upstream commit 86addd25314a1e77dbdcfddfeed0bab2f27da0e2 ]
The existing fixed value of 16 worked for UYVY 720P60 over 2 lanes at 594MHz, or UYVY 1080P60 over 4 lanes. (RGB888 1080P60 needs 6 lanes at 594MHz).
It doesn't allow for lower resolutions to work as the FIFO underflows.
374 is required for 1080P24 or 1080P30 UYVY over 2 lanes @ 972Mbit/s, but >374 means that the FIFO underflows on 1080P50 UYVY over 2 lanes @ 972Mbit/s.
Whilst it would be nice to compute it, the required information isn't published by Toshiba.
--- drivers/media/i2c/tc358743.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/media/i2c/tc358743.c +13 -2
@@ -1959,8 +1959,19 @@ static int tc358743_probe_of(struct tc358743_state *state) state->pdata.refclk_hz =clk_get_rate (refclk); state->pdata.ddc5v_delay =DDC5V_DELAY_100_MS ; state->pdata.enable_hdcp = false; -/* A FIFO level of 16 should be enough for 2-lane 720p60 at 594 MHz. */ - state->pdata.fifo_level =16 ; +/* +* Ideally the FIFO trigger level should be set based on the input and +* output data rates, but the calculations required are buried in +* Toshiba's register settings spreadsheet. +* A value of 16 works with a 594Mbps data rate for 720p60 (using 2 +* lanes) and 1080p60 (using 4 lanes), but fails when the data rate +* is increased, or a lower pixel clock is used that result in CSI +* reading out faster than the data is arriving. +* +* A value of 374 works with both those modes at 594Mbps, and with most +* modes on 972Mbps. +*/ + state->pdata.fifo_level =374 ;/* * The PLL input clock is obtained by dividing refclk by pll_prd. * It must be between 6 MHz and 40 MHz, lower frequency is better.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 250/403 media: usb: hdpvr: disable zero-length read messages
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit b5ae5a79825ba8037b0be3ef677a24de8c063abf ]
This driver passes the length of an i2c_msg directly to usb_control_msg(). If the message is now a read and of length 0, it violates the USB protocol and a warning will be printed. Enable the I2C_AQ_NO_ZERO_LEN_READ quirk for this adapter thus forbidding 0-length read messages altogether.
--- drivers/media/usb/hdpvr/hdpvr-i2c.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/usb/hdpvr/hdpvr-i2c.c +6 -0
@@ -165,10 +165,16 @@ static const struct i2c_algorithm hdpvr_algo = { .functionality = hdpvr_functionality, }; +/* prevent invalid 0-length usb_control_msg */ +static const struct i2c_adapter_quirks hdpvr_quirks = { + .flags =I2C_AQ_NO_ZERO_LEN_READ , +}; +static const struct i2c_adapter hdpvr_i2c_adapter_template = { .name ="Hauppauge HD PVR I2C" , .owner =THIS_MODULE , .algo = &hdpvr_algo, + .quirks = &hdpvr_quirks, };static int hdpvr_activate_ir (struct hdpvr_device *dev)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 251/403 media: dvb-frontends: dib7090p: fix null-ptr-deref in dib7090p_rw_on_apb()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Guo <[email protected]>
[ Upstream commit ce5cac69b2edac3e3246fee03e8f4c2a1075238b ]
In dib7090p_rw_on_apb, msg is controlled by user. When msg[0].buf is null and msg[0].len is zero, former checks on msg[0].buf would be passed. If accessing msg[0].buf[2] without sanity check, null pointer deref would happen. We add check on msg[0].len to prevent crash. Similar issue occurs when access msg[1].buf[0] and msg[1].buf[1].
Similar commit: commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
--- drivers/media/dvb-frontends/dib7000p.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/dvb-frontends/dib7000p.c +4 -0
@@ -2261,8 +2261,12 @@ static int dib7090p_rw_on_apb(struct i2c_adapter *i2c_adap,u16 word;if (num ==1 ) {/* write */ +if (msg[0 ].len <3 ) +return -EOPNOTSUPP ;dib7000p_write_word (state, apb_address, ((msg[0 ].buf[1 ] <<8 ) | (msg[0 ].buf[2 ]))); }else { +if (msg[1 ].len <2 ) +return -EOPNOTSUPP ; word =dib7000p_read_word (state, apb_address); msg[1 ].buf[0 ] = (word >>8 ) &0xff ; msg[1 ].buf[1 ] = (word) &0xff ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 252/403 media: dvb-frontends: w7090p: fix null-ptr-deref in w7090p_tuner_write_serpar and w7090p_tuner_read_serpar
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Guo <[email protected]>
[ Upstream commit ed0234c8458b3149f15e496b48a1c9874dd24a1b ]
In w7090p_tuner_write_serpar, msg is controlled by user. When msg[0].buf is null and msg[0].len is zero, former checks on msg[0].buf would be passed. If accessing msg[0].buf[2] without sanity check, null pointer deref would happen. We add check on msg[0].len to prevent crash.
Similar commit: commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
--- drivers/media/dvb-frontends/dib7000p.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/dvb-frontends/dib7000p.c +4 -0
@@ -2198,6 +2198,8 @@ static int w7090p_tuner_write_serpar(struct i2c_adapter *i2c_adap, struct i2c_msstruct dib7000p_state *state =i2c_get_adapdata (i2c_adap);u8 n_overflow =1 ;u16 i =1000 ; +if (msg[0 ].len <3 ) +return -EOPNOTSUPP ;u16 serpar_num = msg[0 ].buf[0 ];while (n_overflow ==1 && i) {
@@ -2217,6 +2219,8 @@ static int w7090p_tuner_read_serpar(struct i2c_adapter *i2c_adap, struct i2c_msgstruct dib7000p_state *state =i2c_get_adapdata (i2c_adap);u8 n_overflow =1 , n_empty =1 ;u16 i =1000 ; +if (msg[0 ].len <1 || msg[1 ].len <2 ) +return -EOPNOTSUPP ;u16 serpar_num = msg[0 ].buf[0 ];u16 read_word;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 253/403 media: uvcvideo: Fix bandwidth issue for Alcor camera
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: chenchangcheng <[email protected]>
[ Upstream commit 9764401bf6f8a20eb11c2e78470f20fee91a9ea7 ]
Some broken device return wrong dwMaxPayloadTransferSize fields as follows:
[ 218.632537] uvcvideo: Device requested 2752512 B/frame bandwidth. [ 218.632598] uvcvideo: No fast enough alt setting for requested bandwidth.
When dwMaxPayloadTransferSize is greater than maxpsize, it will prevent the camera from starting. So use the bandwidth of maxpsize.
--- drivers/media/usb/uvc/uvc_video.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/usb/uvc/uvc_video.c +9 -0
@@ -228,6 +228,15 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream, ctrl->dwMaxPayloadTransferSize = bandwidth; } + +if (stream->intf->num_altsetting >1 && + ctrl->dwMaxPayloadTransferSize > stream->maxpsize) { +dev_warn_ratelimited (&stream->intf->dev, +"UVC non compliance: the max payload transmission size (%u) exceeds the size of the ep max packet (%u). Using the max size.\n" , + ctrl->dwMaxPayloadTransferSize, + stream->maxpsize); + ctrl->dwMaxPayloadTransferSize = stream->maxpsize; + } }static size_t uvc_video_ctrl_size (struct uvc_streaming *stream)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 254/403 i3c: add missing include to internal header
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit 3b661ca549b9e5bb11d0bc97ada6110aac3282d2 ]
LKP found a random config which failed to build because IO accessors were not defined:
In file included from drivers/i3c/master.c:21:
drivers/i3c/internals.h: In function 'i3c_writel_fifo':
Quoted 1 line
Quoted 1 line
drivers/i3c/internals.h:35:9: error: implicit declaration of function 'writesl' [-Werror=implicit-function-declaration]
Add the proper header to where the IO accessors are used.
--- drivers/i3c/internals.h | 1 + 1 file changed, 1 insertion(+)
drivers/i3c/internals.h +1 -0
@@ -9,6 +9,7 @@#define I3C_INTERNALS_H #include <linux/i3c/master.h> +#include <linux/io.h> extern struct bus_type i3c_bus_type;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 255/403 PCI: pnv_php: Work around switches with broken presence detection
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timothy Pearson <[email protected]>
[ Upstream commit 80f9fc2362797538ebd4fd70a1dfa838cc2c2cdb ]
The Microsemi Switchtec PM8533 PFX 48xG3 [11f8:8533] PCIe switch system was observed to incorrectly assert the Presence Detect Set bit in its capabilities when tested on a Raptor Computing Systems Blackbird system, resulting in the hot insert path never attempting a rescan of the bus and any downstream devices not being re-detected.
Work around this by additionally checking whether the PCIe data link is active or not when performing presence detection on downstream switches' ports, similar to the pciehp_hpc.c driver.
--- drivers/pci/hotplug/pnv_php.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/pci/hotplug/pnv_php.c +27 -0
@@ -395,6 +395,20 @@ static int pnv_php_get_power_state(struct hotplug_slot *slot, u8 *state)return 0 ; } +static int pcie_check_link_active (struct pci_dev *pdev) +{ +u16 lnk_status; +int ret; + + ret =pcie_capability_read_word (pdev,PCI_EXP_LNKSTA , &lnk_status); +if (ret ==PCIBIOS_DEVICE_NOT_FOUND ||PCI_POSSIBLE_ERROR (lnk_status)) +return -ENODEV ; + + ret = !!(lnk_status &PCI_EXP_LNKSTA_DLLLA ); + +return ret; +} +static int pnv_php_get_adapter_state (struct hotplug_slot *slot,u8 *state) {struct pnv_php_slot *php_slot =to_pnv_php_slot (slot);
@@ -407,6 +421,19 @@ static int pnv_php_get_adapter_state(struct hotplug_slot *slot, u8 *state)*/ ret =pnv_pci_get_presence_state (php_slot->id, &presence);if (ret >=0 ) { +if (pci_pcie_type (php_slot->pdev) ==PCI_EXP_TYPE_DOWNSTREAM && + presence ==OPAL_PCI_SLOT_EMPTY ) { +/* +* Similar to pciehp_hpc, check whether the Link Active +* bit is set to account for broken downstream bridges +* that don't properly assert Presence Detect State, as +* was observed on the Microsemi Switchtec PM8533 PFX +* [11f8:8533]. +*/ +if (pcie_check_link_active (php_slot->pdev) >0 ) + presence =OPAL_PCI_SLOT_PRESENT ; + } + *state = presence; ret =0 ; }else {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 256/403 i3c: dont fail if GETHDRCAP is unsupported
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit 447270cdb41b1c8c3621bb14b93a6749f942556e ]
'I3C_BCR_HDR_CAP' is still spec v1.0 and has been renamed to 'advanced capabilities' in v1.1 onwards. The ST pressure sensor LPS22DF does not have HDR, but has the 'advanced cap' bit set. The core still wants to get additional information using the CCC 'GETHDRCAP' (or GETCAPS in v1.1 onwards). Not all controllers support this CCC and will notify the upper layers about it. For instantiating the device, we can ignore this unsupported CCC as standard communication will work. Without this patch, the device will not be instantiated at all.
--- drivers/i3c/master.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master.c +1 -1
@@ -1243,7 +1243,7 @@ static int i3c_master_retrieve_dev_info(struct i3c_dev_desc *dev)if (dev->info.bcr &I3C_BCR_HDR_CAP ) { ret =i3c_master_gethdrcap_locked (master, &dev->info); -if (ret) +if (ret && ret != -ENOTSUPP )return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 257/403 kconfig: lxdialog: replace strcpy() with strncpy() in inputbox.c
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suchit Karunakaran <[email protected]>
[ Upstream commit 5ac726653a1029a2eccba93bbe59e01fc9725828 ]
strcpy() performs no bounds checking and can lead to buffer overflows if the input string exceeds the destination buffer size. This patch replaces it with strncpy(), and null terminates the input string.
--- scripts/kconfig/lxdialog/inputbox.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/kconfig/lxdialog/inputbox.c +4 -2
@@ -39,8 +39,10 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int widthif (!init) instr[0 ] ='\0' ; -else -strcpy (instr, init); +else { +strncpy (instr, init,sizeof (dialog_input_result) -1 ); + instr[sizeof (dialog_input_result) -1 ] ='\0' ; + } do_resize:if (getmaxy (stdscr) <= (height -INPUTBOX_HEIGTH_MIN ))
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 258/403 kconfig: nconf: Ensure null termination where strncpy is used
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shankari Anand <[email protected]>
[ Upstream commit f468992936894c9ce3b1659cf38c230d33b77a16 ]
strncpy() does not guarantee null-termination if the source string is longer than the destination buffer.
Ensure the buffer is explicitly null-terminated to prevent potential string overflows or undefined behavior.
--- scripts/kconfig/nconf.c | 2 ++ scripts/kconfig/nconf.gui.c | 1 + 2 files changed, 3 insertions(+)
scripts/kconfig/nconf.c +2 -0
@@ -580,6 +580,8 @@ static void item_add_str(const char *fmt, ...) tmp_str, sizeof(k_menu_items[index].str)); + k_menu_items[index].str[sizeof (k_menu_items[index].str) -1 ] ='\0' ; +free_item (curses_menu_items[index]); curses_menu_items[index] = new_item( k_menu_items[index].str,
scripts/kconfig/nconf.gui.c +1 -0
@@ -398,6 +398,7 @@ int dialog_inputbox(WINDOW *main_window, x = (columns-win_cols)/2 ;strncpy (result, init, *result_len); + result[*result_len -1 ] ='\0' ;/* create the windows */ win =newwin (win_lines, win_cols, y, x);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 259/403 scsi: Fix sas_user_scan() to handle wildcard and multi-channel scans
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ranjan Kumar <[email protected]>
[ Upstream commit 37c4e72b0651e7697eb338cd1fb09feef472cc1a ]
sas_user_scan() did not fully process wildcard channel scans (SCAN_WILD_CARD) when a transport-specific user_scan() callback was present. Only channel 0 would be scanned via user_scan(), while the remaining channels were skipped, potentially missing devices.
user_scan() invokes updated sas_user_scan() for channel 0, and if successful, iteratively scans remaining channels (1 to shost->max_channel) via scsi_scan_host_selected(). This ensures complete wildcard scanning without affecting transport-specific scanning behavior.
--- drivers/scsi/scsi_scan.c | 2 +- drivers/scsi/scsi_transport_sas.c | 60 ++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 13 deletions(-)
drivers/scsi/scsi_scan.c +1 -1
@@ -1686,7 +1686,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,return 0 ; } - +EXPORT_SYMBOL (scsi_scan_host_selected);static void scsi_sysfs_add_devices (struct Scsi_Host *shost) {struct scsi_device *sdev;
drivers/scsi/scsi_transport_sas.c +48 -12
86 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 260/403 scsi: aacraid: Stop using PCI_IRQ_AFFINITY
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Garry <[email protected]>
[ Upstream commit dafeaf2c03e71255438ffe5a341d94d180e6c88e ]
When PCI_IRQ_AFFINITY is set for calling pci_alloc_irq_vectors(), it means interrupts are spread around the available CPUs. It also means that the interrupts become managed, which means that an interrupt is shutdown when all the CPUs in the interrupt affinity mask go offline.
Using managed interrupts in this way means that we should ensure that completions should not occur on HW queues where the associated interrupt is shutdown. This is typically achieved by ensuring only CPUs which are online can generate IO completion traffic to the HW queue which they are mapped to (so that they can also serve completion interrupts for that HW queue).
The problem in the driver is that a CPU can generate completions to a HW queue whose interrupt may be shutdown, as the CPUs in the HW queue interrupt affinity mask may be offline. This can cause IOs to never complete and hang the system. The driver maintains its own CPU <-> HW queue mapping for submissions, see aac_fib_vector_assign(), but this does not reflect the CPU <-> HW queue interrupt affinity mapping.
Commit 9dc704dcc09e ("scsi: aacraid: Reply queue mapping to CPUs based on IRQ affinity") tried to remedy this issue may mapping CPUs properly to HW queue interrupts. However this was later reverted in commit c5becf57dd56 ("Revert "scsi: aacraid: Reply queue mapping to CPUs based on IRQ affinity") - it seems that there were other reports of hangs. I guess that this was due to some implementation issue in the original commit or maybe a HW issue.
Fix the very original hang by just not using managed interrupts by not setting PCI_IRQ_AFFINITY. In this way, all CPUs will be in each HW queue affinity mask, so should not create completion problems if any CPUs go offline.
--- drivers/scsi/aacraid/comminit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/aacraid/comminit.c +1 -2
@@ -482,8 +482,7 @@ void aac_define_int_mode(struct aac_dev *dev) pci_find_capability(dev->pdev, PCI_CAP_ID_MSIX)) { min_msix =2 ; i =pci_alloc_irq_vectors (dev->pdev, - min_msix, msi_count, -PCI_IRQ_MSIX |PCI_IRQ_AFFINITY ); + min_msix, msi_count,PCI_IRQ_MSIX );if (i >0 ) { dev->msi_enabled =1 ; msi_count = i;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 261/403 ipmi: Use dev_warn_ratelimited() for incorrect message warnings
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit ec50ec378e3fd83bde9b3d622ceac3509a60b6b5 ]
During BMC firmware upgrades on live systems, the ipmi_msghandler generates excessive "BMC returned incorrect response" warnings while the BMC is temporarily offline. This can flood system logs in large deployments.
Replace dev_warn() with dev_warn_ratelimited() to throttle these warnings and prevent log spam during BMC maintenance operations.
Message-ID: <[email protected]>
--- drivers/char/ipmi/ipmi_msghandler.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +4 -4
@@ -4302,10 +4302,10 @@ static int handle_one_recv_msg(struct ipmi_smi *intf,* The NetFN and Command in the response is not even * marginally correct. */ -dev_warn (intf->si_dev, -"BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n" , - (msg->data[0 ] >>2 ) |1 , msg->data[1 ], - msg->rsp[0 ] >>2 , msg->rsp[1 ]); +dev_warn_ratelimited (intf->si_dev, +"BMC returned incorrect response, expected netfn %x cmd %x, got netfn %x cmd %x\n" , + (msg->data[0 ] >>2 ) |1 , msg->data[1 ], + msg->rsp[0 ] >>2 , msg->rsp[1 ]);/* Generate an error response for the message. */ msg->rsp[0 ] = msg->data[0 ] | (1 <<2 );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 262/403 kconfig: gconf: avoid hardcoding model2 in on_treeview2_cursor_changed()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit cae9cdbcd9af044810bcceeb43a87accca47c71d ]
The on_treeview2_cursor_changed() handler is connected to both the left and right tree views, but it hardcodes model2 (the GtkTreeModel of the right tree view). This is incorrect. Get the associated model from the view.
--- scripts/kconfig/gconf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/kconfig/gconf.c +3 -2
@@ -980,13 +980,14 @@ on_treeview2_key_press_event(GtkWidget * widget,void on_treeview2_cursor_changed (GtkTreeView * treeview,gpointer user_data) { +GtkTreeModel *model =gtk_tree_view_get_model (treeview);GtkTreeSelection *selection;GtkTreeIter iter;struct menu *menu; selection =gtk_tree_view_get_selection (treeview); -if (gtk_tree_selection_get_selected (selection, &model2, &iter)) { -gtk_tree_model_get (model2, &iter,COL_MENU , &menu,-1 ); +if (gtk_tree_selection_get_selected (selection, &model, &iter)) { +gtk_tree_model_get (model, &iter,COL_MENU , &menu,-1 );text_insert_help (menu); } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 263/403 kconfig: gconf: fix potential memory leak in renderer_edited()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit f72ed4c6a375e52a3f4b75615e4a89d29d8acea7 ]
If gtk_tree_model_get_iter() fails, gtk_tree_path_free() is not called.
--- scripts/kconfig/gconf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/kconfig/gconf.c +2 -1
@@ -786,7 +786,7 @@ static void renderer_edited(GtkCellRendererText * cell,struct symbol *sym;if (!gtk_tree_model_get_iter (model2, &iter, path)) -return ; + goto free;gtk_tree_model_get (model2, &iter,COL_MENU , &menu,-1 ); sym = menu->sym;
@@ -798,6 +798,7 @@ static void renderer_edited(GtkCellRendererText * cell,update_tree (&rootmenu,NULL ); +free:gtk_tree_path_free (path); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 264/403 kconfig: lxdialog: fix space to (de)select options
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yann E. MORIN <[email protected]>
[ Upstream commit 694174f94ebeeb5ec5cc0e9de9b40c82057e1d95 ]
In case a menu has comment without letters/numbers (eg. characters matching the regexp '^[^[:alpha:][:digit:]]+$', for example - or *), hitting space will cycle through those comments, rather than selecting/deselecting the currently-highlighted option.
This is the behaviour of hitting any letter/digit: jump to the next option which prompt starts with that letter. The only letters that do not behave as such are 'y' 'm' and 'n'. Prompts that start with one of those three letters are instead matched on the first letter that is not 'y', 'm' or 'n'.
Fix that by treating 'space' as we treat y/m/n, ie. as an action key, not as shortcut to jump to prompt.
--- scripts/kconfig/lxdialog/menubox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/lxdialog/menubox.c +1 -1
@@ -272,7 +272,7 @@ int dialog_menu(const char *title, const char *prompt,if (key <256 &&isalpha (key)) key =tolower (key); -if (strchr ("ynmh" , key)) +if (strchr ("ynmh " , key)) i = max_choice;else {for (i = choice +1 ; i < max_choice; i++) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 265/403 ipmi: Fix strcpy source and destination the same
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Corey Minyard <[email protected]>
[ Upstream commit 8ffcb7560b4a15faf821df95e3ab532b2b020f8c ]
The source and destination of some strcpy operations was the same. Split out the part of the operations that needed to be done for those particular calls so the unnecessary copy wasn't done.
--- drivers/char/ipmi/ipmi_watchdog.c | 59 ++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 17 deletions(-)
drivers/char/ipmi/ipmi_watchdog.c +42 -17
@@ -1192,14 +1192,8 @@ static struct ipmi_smi_watcher smi_watcher = { .smi_gone = ipmi_smi_gone }; -static int action_op (const char *inval,char *outval) +static int action_op_set_val (const char *inval) { -if (outval) -strcpy (outval, action); - -if (!inval) -return 0 ; -if (strcmp (inval,"reset" ) ==0 ) action_val =WDOG_TIMEOUT_RESET ;else if (strcmp (inval,"none" ) ==0 )
@@ -1210,18 +1204,26 @@ static int action_op(const char *inval, char *outval) action_val =WDOG_TIMEOUT_POWER_DOWN ; else return -EINVAL; -strcpy (action, inval);return 0 ; } -static int preaction_op (const char *inval,char *outval) +static int action_op (const char *inval,char *outval) { +int rv; +if (outval) -strcpy (outval, preaction); +strcpy (outval, action);if (!inval)return 0 ; + rv =action_op_set_val (inval); +if (!rv) +strcpy (action, inval); +return rv; +} +static int preaction_op_set_val (const char *inval) +{if (strcmp (inval,"pre_none" ) ==0 ) preaction_val =WDOG_PRETIMEOUT_NONE ;else if (strcmp (inval,"pre_smi" ) ==0 )
@@ -1234,18 +1236,26 @@ static int preaction_op(const char *inval, char *outval) preaction_val =WDOG_PRETIMEOUT_MSG_INT ; else return -EINVAL; -strcpy (preaction, inval);return 0 ; } -static int preop_op (const char *inval,char *outval) +static int preaction_op (const char *inval,char *outval) { +int rv; +if (outval) -strcpy (outval, preop); +strcpy (outval, preaction);if (!inval)return 0 ; + rv =preaction_op_set_val (inval); +if (!rv) +strcpy (preaction, inval); +return 0 ; +} +static int preop_op_set_val (const char *inval) +{if (strcmp (inval,"preop_none" ) ==0 ) preop_val =WDOG_PREOP_NONE ;else if (strcmp (inval,"preop_panic" ) ==0 )
@@ -1254,7 +1264,22 @@ static int preop_op(const char *inval, char *outval) preop_val =WDOG_PREOP_GIVE_DATA ; else return -EINVAL; -strcpy (preop, inval); +return 0 ; +} + +static int preop_op (const char *inval,char *outval) +{ +int rv; + +if (outval) +strcpy (outval, preop); + +if (!inval) +return 0 ; + + rv =preop_op_set_val (inval); +if (!rv) +strcpy (preop, inval);return 0 ; }
@@ -1291,18 +1316,18 @@ static int __init ipmi_wdog_init(void) {int rv; -if (action_op (action,NULL )) { +if (action_op_set_val (action)) {action_op ("reset" ,NULL );pr_info ("Unknown action '%s', defaulting to reset\n" , action); } -if (preaction_op (preaction,NULL )) { +if (preaction_op_set_val (preaction)) {preaction_op ("pre_none" ,NULL );pr_info ("Unknown preaction '%s', defaulting to none\n" , preaction); } -if (preop_op (preop,NULL )) { +if (preop_op_set_val (preop)) {preop_op ("preop_none" ,NULL );pr_info ("Unknown preop '%s', defaulting to none\n" , preop); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 266/403 net: phy: smsc: add proper reset flags for LAN8710A
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Buday Csaba <[email protected]>
[ Upstream commit 57ec5a8735dc5dccd1ee68afdb1114956a3fce0d ]
According to the LAN8710A datasheet (Rev. B, section 3.8.5.1), a hardware reset is required after power-on, and the reference clock (REF_CLK) must be established before asserting reset.
--- drivers/net/phy/smsc.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/smsc.c +1 -0
@@ -306,6 +306,7 @@ static struct phy_driver smsc_phy_driver[] = {/* PHY_BASIC_FEATURES */ .flags = PHY_RST_AFTER_CLK_EN, + .flags = PHY_RST_AFTER_CLK_EN, .probe = smsc_phy_probe,/* basic functions */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 267/403 pNFS: Fix stripe mapping in block/scsi layout
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Bashirov <[email protected]>
[ Upstream commit 81438498a285759f31e843ac4800f82a5ce6521f ]
Because of integer division, we need to carefully calculate the disk offset. Consider the example below for a stripe of 6 volumes, a chunk size of 4096, and an offset of 70000.
chunk = div_u64(offset, dev->chunk_size) = 70000 / 4096 = 17 offset = chunk * dev->chunk_size = 17 * 4096 = 69632 disk_offset_wrong = div_u64(offset, dev->nr_children) = 69632 / 6 = 11605 disk_chunk = div_u64(chunk, dev->nr_children) = 17 / 6 = 2 disk_offset = disk_chunk * dev->chunk_size = 2 * 4096 = 8192
--- fs/nfs/blocklayout/dev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfs/blocklayout/dev.c +3 -2
@@ -199,10 +199,11 @@ static bool bl_map_stripe(struct pnfs_block_dev *dev, u64 offset,struct pnfs_block_dev *child;u64 chunk;u32 chunk_idx; +u64 disk_chunk;u64 disk_offset; chunk =div_u64 (offset, dev->chunk_size); -div_u64_rem (chunk, dev->nr_children, &chunk_idx); + disk_chunk =div_u64_rem (chunk, dev->nr_children, &chunk_idx);if (chunk_idx >= dev->nr_children) { dprintk("%s: invalid chunk idx %d (%lld/%lld)\n",
@@ -215,7 +216,7 @@ static bool bl_map_stripe(struct pnfs_block_dev *dev, u64 offset, offset = chunk * dev->chunk_size;/* disk offset of the stripe */ - disk_offset =div_u64 (offset, dev->nr_children); + disk_offset = disk_chunk * dev->chunk_size; child = &dev->children[chunk_idx]; child->map (child, disk_offset, map);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 268/403 pNFS: Fix disk addr range check in block/scsi layout
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Bashirov <[email protected]>
[ Upstream commit 7db6e66663681abda54f81d5916db3a3b8b1a13d ]
At the end of the isect translation, disc_addr represents the physical disk offset. Thus, end calculated from disk_addr is also a physical disk offset. Therefore, range checking should be done using map->disk_offset, not map->start.
--- fs/nfs/blocklayout/blocklayout.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/blocklayout/blocklayout.c +2 -2
@@ -171,8 +171,8 @@ do_add_page_to_bio(struct bio *bio, int npg, int rw, sector_t isect,/* limit length to what the device mapping allows */ end = disk_addr + *len; -if (end >= map->start + map->len) - *len = map->start + map->len - disk_addr; +if (end >= map->disk_offset + map->len) + *len = map->disk_offset + map->len - disk_addr; retry:if (!bio) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 269/403 pNFS: Handle RPC size limit for layoutcommits
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Bashirov <[email protected]>
[ Upstream commit d897d81671bc4615c80f4f3bd5e6b218f59df50c ]
When there are too many block extents for a layoutcommit, they may not all fit into the maximum-sized RPC. This patch allows the generic pnfs code to properly handle -ENOSPC returned by the block/scsi layout driver and trigger additional layoutcommits if necessary.
--- fs/nfs/pnfs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
fs/nfs/pnfs.c +8 -3
@@ -3047,6 +3047,7 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)struct nfs_inode *nfsi =NFS_I (inode);loff_t end_pos;int status; +bool mark_as_dirty = false;if (!pnfs_layoutcommit_outstanding (inode))return 0 ;
@@ -3098,19 +3099,23 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)if (ld->prepare_layoutcommit) { status = ld->prepare_layoutcommit (&data->args);if (status) { -put_cred (data->cred); +if (status != -ENOSPC ) +put_cred (data->cred);spin_lock (&inode->i_lock);set_bit (NFS_INO_LAYOUTCOMMIT , &nfsi->flags);if (end_pos > nfsi->layout->plh_lwb) nfsi->layout->plh_lwb = end_pos; - goto out_unlock; +if (status != -ENOSPC ) + goto out_unlock; +spin_unlock (&inode->i_lock); + mark_as_dirty = true; } } status =nfs4_proc_layoutcommit (data, sync); out: -if (status) +if (status || mark_as_dirty)mark_inode_dirty_sync (inode);dprintk ("<-- %s status %d\n" , __func__, status);return status;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 270/403 pNFS: Fix uninited ptr deref in block/scsi layout
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Bashirov <[email protected]>
[ Upstream commit 9768797c219326699778fba9cd3b607b2f1e7950 ]
The error occurs on the third attempt to encode extents. When function ext_tree_prepare_commit() reallocates a larger buffer to retry encoding extents, the "layoutupdate_pages" page array is initialized only after the retry loop. But ext_tree_free_commitdata() is called on every iteration and tries to put pages in the array, thus dereferencing uninitialized pointers.
An additional problem is that there is no limit on the maximum possible buffer_size. When there are too many extents, the client may create a layoutcommit that is larger than the maximum possible RPC size accepted by the server.
During testing, we observed two typical scenarios. First, one memory page for extents is enough when we work with small files, append data to the end of the file, or preallocate extents before writing. But when we fill a new large file without preallocating, the number of extents can be huge, and counting the number of written extents in ext_tree_encode_commit() does not help much. Since this number increases even more between unlocking and locking of ext_tree, the reallocated buffer may not be large enough again and again.
--- fs/nfs/blocklayout/extent_tree.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
fs/nfs/blocklayout/extent_tree.c +15 -5
@@ -552,6 +552,15 @@ static int ext_tree_encode_commit(struct pnfs_block_layout *bl, __be32 *p,return ret; } +/** +* ext_tree_prepare_commit - encode extents that need to be committed +* @arg: layout commit data +* +* Return values: +* %0: Success, all required extents are encoded +* %-ENOSPC: Some extents are encoded, but not all, due to RPC size limit +* %-ENOMEM: Out of memory, extents not encoded +*/ int ext_tree_prepare_commit (struct nfs4_layoutcommit_args *arg) {
@@ -568,12 +577,12 @@ ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg) start_p =page_address (arg->layoutupdate_page); arg->layoutupdate_pages = &arg->layoutupdate_page; -retry: - ret =ext_tree_encode_commit (bl, start_p +1 , buffer_size, &count, &arg->lastbytewritten); + ret =ext_tree_encode_commit (bl, start_p +1 , buffer_size, + &count, &arg->lastbytewritten);if (unlikely (ret)) {ext_tree_free_commitdata (arg, buffer_size); - buffer_size =ext_tree_layoutupdate_size (bl, count); + buffer_size =NFS_SERVER (arg->inode)->wsize; count =0 ; arg->layoutupdate_pages =
@@ -588,7 +597,8 @@ ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg)return -ENOMEM ; } - goto retry; + ret =ext_tree_encode_commit (bl, start_p +1 , buffer_size, + &count, &arg->lastbytewritten); } *start_p =cpu_to_be32 (count);
@@ -608,7 +618,7 @@ ext_tree_prepare_commit(struct nfs4_layoutcommit_args *arg) }dprintk ("%s found %zu ranges\n" , __func__, count); -return 0 ; +return ret; }void
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 271/403 rtc: ds1307: remove clear of oscillator stop flag (OSF) in probe
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Meagan Lloyd <[email protected]>
[ Upstream commit 48458654659c9c2e149c211d86637f1592470da5 ]
In using CONFIG_RTC_HCTOSYS, rtc_hctosys() will sync the RTC time to the kernel time as long as rtc_read_time() succeeds. In some power loss situations, our supercapacitor-backed DS1342 RTC comes up with either an unpredictable future time or the default 01/01/00 from the datasheet. The oscillator stop flag (OSF) is set in these scenarios due to the power loss and can be used to determine the validity of the RTC data.
Some chip types in the ds1307 driver already have OSF handling to determine whether .read_time provides valid RTC data or returns -EINVAL.
This change removes the clear of the OSF in .probe as the OSF needs to be preserved to expand the OSF handling to the ds1341 chip type (note that DS1341 and DS1342 share a datasheet).
--- drivers/rtc/rtc-ds1307.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/rtc/rtc-ds1307.c +1 -3
@@ -1686,10 +1686,8 @@ static int ds1307_probe(struct i2c_client *client,regmap_write (ds1307->regmap,DS1337_REG_CONTROL , regs[0 ]); -/* oscillator fault? clear flag, and warn */ +/* oscillator fault? warn */ if (regs[1 ] &DS1337_BIT_OSF ) { -regmap_write (ds1307->regmap,DS1337_REG_STATUS , - regs[1 ] & ~DS1337_BIT_OSF );dev_warn (ds1307->dev,"SET TIME!\n" ); }break ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 272/403 scsi: lpfc: Remove redundant assignment to avoid memory leak
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
[ Upstream commit eea6cafb5890db488fce1c69d05464214616d800 ]
Remove the redundant assignment if kzalloc() succeeds to avoid memory leak.
--- drivers/scsi/lpfc/lpfc_debugfs.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/lpfc/lpfc_debugfs.c +0 -1
@@ -5886,7 +5886,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport) } phba->nvmeio_trc_on =1 ; phba->nvmeio_trc_output_idx =0 ; - phba->nvmeio_trc =NULL ; }else { nvmeio_off: phba->nvmeio_trc_size =0 ;
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 273/403 drm/amdgpu: fix incorrect vm flags to map bo
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jack Xiao <[email protected]>
[ Upstream commit 040bc6d0e0e9c814c9c663f6f1544ebaff6824a8 ]
It should use vm flags instead of pte flags
to specify bo vm attributes.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c +2 -2
@@ -94,8 +94,8 @@ int amdgpu_map_static_csa(struct amdgpu_ } r =amdgpu_vm_bo_map (adev, *bo_va, csa_addr,0 , size, -AMDGPU_PTE_READABLE |AMDGPU_PTE_WRITEABLE | -AMDGPU_PTE_EXECUTABLE ); +AMDGPU_VM_PAGE_READABLE |AMDGPU_VM_PAGE_WRITEABLE | +AMDGPU_VM_PAGE_EXECUTABLE );if (r) {DRM_ERROR ("failed to do bo_map on static CSA, err=%d\n" , r);
Greg Kroah-Hartman
maintainerPATCH 274/403 misc: rtsx: usb: Ensure mmc child device is active when card is present
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricky Wu <[email protected]>
commit 966c5cd72be8989c8a559ddef8e8ff07a37c5eb0 upstream.
When a card is present in the reader, the driver currently defers autosuspend by returning -EAGAIN during the suspend callback to trigger USB remote wakeup signaling. However, this does not guarantee that the mmc child device has been resumed, which may cause issues if it remains suspended while the card is accessible.
This patch ensures that all child devices, including the mmc host controller, are explicitly resumed before returning -EAGAIN. This fixes a corner case introduced by earlier remote wakeup handling, improving reliability of runtime PM when a card is inserted.
--- drivers/misc/cardreader/rtsx_usb.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/misc/cardreader/rtsx_usb.c +9 -7
@@ -698,6 +698,12 @@ static void rtsx_usb_disconnect(struct u }#ifdef CONFIG_PM +static int rtsx_usb_resume_child (struct device *dev,void *data) +{ +pm_request_resume (dev); +return 0 ; +} +static int rtsx_usb_suspend (struct usb_interface *intf,pm_message_t message) { struct rtsx_ucr *ucr =
@@ -713,8 +719,10 @@ static int rtsx_usb_suspend(struct usb_imutex_unlock (&ucr->dev_mutex);/* Defer the autosuspend if card exists */ -if (val & (SD_CD |MS_CD )) +if (val & (SD_CD |MS_CD )) { +device_for_each_child (&intf->dev,NULL , rtsx_usb_resume_child);return -EAGAIN ; + } }else {/* There is an ongoing operation*/ return -EAGAIN ;
@@ -724,12 +732,6 @@ static int rtsx_usb_suspend(struct usb_ireturn 0 ; } -static int rtsx_usb_resume_child (struct device *dev,void *data) -{ -pm_request_resume (dev); -return 0 ; -} -static int rtsx_usb_resume (struct usb_interface *intf) {device_for_each_child (&intf->dev,NULL , rtsx_usb_resume_child);
Greg Kroah-Hartman
maintainerPATCH 275/403 comedi: fix race between polling and detaching
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <[email protected]>
commit 35b6fc51c666fc96355be5cd633ed0fe4ccf68b2 upstream.
syzbot reports a use-after-free in comedi in the below link, which is due to comedi gladly removing the allocated async area even though poll requests are still active on the wait_queue_head inside of it. This can cause a use-after-free when the poll entries are later triggered or removed, as the memory for the wait_queue_head has been freed. We need to check there are no tasks queued on any of the subdevices' wait queues before allowing the device to be detached by the COMEDI_DEVCONFIG ioctl.
Tasks will read-lock dev->attach_lock before adding themselves to the subdevice wait queue, so fix the problem in the COMEDI_DEVCONFIG ioctl handler by write-locking dev->attach_lock before checking that all of the subdevices are safe to be deleted. This includes testing for any sleepers on the subdevices' wait queues. It remains locked until the device has been detached. This requires the comedi_device_detach() function to be refactored slightly, moving the bulk of it into new function comedi_device_detach_locked().
Note that the refactor of comedi_device_detach() results in comedi_device_cancel_all() now being called while dev->attach_lock is write-locked, which wasn't the case previously, but that does not matter.
Thanks to Jens Axboe for diagnosing the problem and co-developing this patch.
--- drivers/staging/comedi/comedi_fops.c | 33 +++++++++++++++++++++++-------- drivers/staging/comedi/comedi_internal.h | 1 drivers/staging/comedi/drivers.c | 13 +++++++++--- 3 files changed, 36 insertions(+), 11 deletions(-)
drivers/staging/comedi/comedi_fops.c +25 -8
@@ -781,6 +781,7 @@ static int is_device_busy(struct comedi_struct comedi_subdevice *s;int i; +lockdep_assert_held_write (&dev->attach_lock);lockdep_assert_held (&dev->mutex);if (!dev->attached)return 0 ;
@@ -789,7 +790,16 @@ static int is_device_busy(struct comedi_ s = &dev->subdevices[i];if (s->busy)return 1 ; -if (s->async &&comedi_buf_is_mmapped (s)) +if (!s->async) +continue ; +if (comedi_buf_is_mmapped (s)) +return 1 ; +/* +* There may be tasks still waiting on the subdevice's wait +* queue, although they should already be about to be removed +* from it since the subdevice has no active async command. +*/ +if (wq_has_sleeper (&s->async->wait_head))return 1 ; }
@@ -819,15 +829,22 @@ static int do_devconfig_ioctl(struct comreturn -EPERM ;if (!arg) { -if (is_device_busy (dev)) -return -EBUSY ; -if (dev->attached) { -struct module *driver_module = dev->driver->module; +int rc =0 ; -comedi_device_detach (dev); -module_put (driver_module); +if (dev->attached) { +down_write (&dev->attach_lock); +if (is_device_busy (dev)) { + rc = -EBUSY ; + }else { +struct module *driver_module = + dev->driver->module; + +comedi_device_detach_locked (dev); +module_put (driver_module); + } +up_write (&dev->attach_lock); } -return 0 ; +return rc; }if (copy_from_user (&it, arg,sizeof (it)))
drivers/staging/comedi/comedi_internal.h +1 -0
@@ -50,6 +50,7 @@ extern struct mutex comedi_drivers_list_int insn_inval (struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); +void comedi_device_detach_locked (struct comedi_device *dev);void comedi_device_detach (struct comedi_device *dev);int comedi_device_attach (struct comedi_device *dev,struct comedi_devconfig *it);
drivers/staging/comedi/drivers.c +10 -3
@@ -159,7 +159,7 @@ static void comedi_device_detach_cleanupint i;struct comedi_subdevice *s; -lockdep_assert_held (&dev->attach_lock); +lockdep_assert_held_write (&dev->attach_lock);lockdep_assert_held (&dev->mutex);if (dev->subdevices) {for (i =0 ; i < dev->n_subdevices; i++) {
@@ -196,16 +196,23 @@ static void comedi_device_detach_cleanupcomedi_clear_hw_dev (dev); } -void comedi_device_detach (struct comedi_device *dev) +void comedi_device_detach_locked (struct comedi_device *dev) { +lockdep_assert_held_write (&dev->attach_lock);lockdep_assert_held (&dev->mutex);comedi_device_cancel_all (dev); -down_write (&dev->attach_lock); dev->attached = false; dev->detach_count++;if (dev->driver) dev->driver->detach (dev);comedi_device_detach_cleanup (dev); +} + +void comedi_device_detach (struct comedi_device *dev) +{ +lockdep_assert_held (&dev->mutex); +down_write (&dev->attach_lock); +comedi_device_detach_locked (dev);up_write (&dev->attach_lock); }
Greg Kroah-Hartman
maintainerPATCH 276/403 thunderbolt: Fix copy+paste error in match_service_id()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 5cc1f66cb23cccc704e3def27ad31ed479e934a5 upstream.
The second instance of TBSVC_MATCH_PROTOCOL_VERSION seems to have been intended to be TBSVC_MATCH_PROTOCOL_REVISION.
--- drivers/thunderbolt/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thunderbolt/domain.c +1 -1
@@ -38,7 +38,7 @@ static bool match_service_id(const strucreturn false; } -if (id->match_flags &TBSVC_MATCH_PROTOCOL_VERSION ) { +if (id->match_flags &TBSVC_MATCH_PROTOCOL_REVISION ) {if (id->protocol_revision != svc->prtcrevs)return false; }
Greg Kroah-Hartman
maintainerPATCH 277/403 btrfs: fix log tree replay failure due to file with 0 links and extents
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 0a32e4f0025a74c70dcab4478e9b29c22f5ecf2f upstream.
If we log a new inode (not persisted in a past transaction) that has 0 links and extents, then log another inode with an higher inode number, we end up with failing to replay the log tree with -EINVAL. The steps for this are:
1) create new file A
2) write some data to file A
3) open an fd on file A
4) unlink file A
5) fsync file A using the previously open fd
6) create file B (has higher inode number than file A)
7) fsync file B
8) power fail before current transaction commits
Now when attempting to mount the fs, the log replay will fail with -ENOENT at replay_one_extent() when attempting to replay the first extent of file A. The failure comes when trying to open the inode for file A in the subvolume tree, since it doesn't exist.
Before commit 5f61b961599a ("btrfs: fix inode lookup error handling during log replay"), the returned error was -EIO instead of -ENOENT, since we converted any errors when attempting to read an inode during log replay to -EIO.
The reason for this is that the log replay procedure fails to ignore the current inode when we are at the stage LOG_WALK_REPLAY_ALL, our current inode has 0 links and last inode we processed in the previous stage has a non 0 link count. In other words, the issue is that at replay_one_extent() we only update wc->ignore_cur_inode if the current replay stage is LOG_WALK_REPLAY_INODES.
Fix this by updating wc->ignore_cur_inode whenever we find an inode item regardless of the current replay stage. This is a simple solution and easy to backport, but later we can do other alternatives like avoid logging extents or inode items other than the inode item for inodes with a link count of 0.
The problem with the wc->ignore_cur_inode logic has been around since commit f2d72f42d5fa ("Btrfs: fix warning when replaying log after fsync of a tmpfile") but it only became frequent to hit since the more recent commit 5e85262e542d ("btrfs: fix fsync of files with no hard links not persisting deletion"), because we stopped skipping inodes with a link count of 0 when logging, while before the problem would only be triggered if trying to replay a log tree created with an older kernel which has a logged inode with 0 links.
A test case for fstests will be submitted soon.
--- fs/btrfs/tree-log.c | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-)
fs/btrfs/tree-log.c +30 -18
@@ -274,8 +274,7 @@ struct walk_control {/* * Ignore any items from the inode currently being processed. Needs -* to be set every time we find a BTRFS_INODE_ITEM_KEY and we are in -* the LOG_WALK_REPLAY_INODES stage. +* to be set every time we find a BTRFS_INODE_ITEM_KEY. */ bool ignore_cur_inode;
@@ -2604,23 +2603,30 @@ static int replay_one_buffer(struct btrf nritems =btrfs_header_nritems (eb);for (i =0 ; i < nritems; i++) { -btrfs_item_key_to_cpu (eb, &key, i); +struct btrfs_inode_item *inode_item; -/* inode keys are done during the first stage */ -if (key.type ==BTRFS_INODE_ITEM_KEY && - wc->stage ==LOG_WALK_REPLAY_INODES ) { -struct btrfs_inode_item *inode_item; -u32 mode; +btrfs_item_key_to_cpu (eb, &key, i); - inode_item =btrfs_item_ptr (eb, i, - struct btrfs_inode_item); +if (key.type ==BTRFS_INODE_ITEM_KEY ) { + inode_item = btrfs_item_ptr(eb, i, struct btrfs_inode_item);/* -* If we have a tmpfile (O_TMPFILE) that got fsync'ed -* and never got linked before the fsync, skip it, as -* replaying it is pointless since it would be deleted -* later. We skip logging tmpfiles, but it's always -* possible we are replaying a log created with a kernel -* that used to log tmpfiles. +* An inode with no links is either: +* +* 1) A tmpfile (O_TMPFILE) that got fsync'ed and never +* got linked before the fsync, skip it, as replaying +* it is pointless since it would be deleted later. +* We skip logging tmpfiles, but it's always possible +* we are replaying a log created with a kernel that +* used to log tmpfiles; +* +* 2) A non-tmpfile which got its last link deleted +* while holding an open fd on it and later got +* fsynced through that fd. We always log the +* parent inodes when inode->last_unlink_trans is +* set to the current transaction, so ignore all the +* inode items for this inode. We will delete the +* inode when processing the parent directory with +* replay_dir_deletes(). */ if (btrfs_inode_nlink (eb, inode_item) ==0 ) { wc->ignore_cur_inode = true;
@@ -2628,8 +2634,14 @@ static int replay_one_buffer(struct btrf }else { wc->ignore_cur_inode = false; } - ret =replay_xattr_deletes (wc->trans, root, log, - path, key.objectid); + } + +/* Inode keys are done during the first stage. */ +if (key.type ==BTRFS_INODE_ITEM_KEY && + wc->stage ==LOG_WALK_REPLAY_INODES ) { +u32 mode; + + ret =replay_xattr_deletes (wc->trans, root, log, path, key.objectid);if (ret)break ; mode =btrfs_inode_mode (eb, inode_item);
Greg Kroah-Hartman
maintainerPATCH 278/403 parisc: Makefile: fix a typo in palo.conf
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
commit 963f1b20a8d2a098954606b9725cd54336a2a86c upstream.
Correct "objree" to "objtree". "objree" is not defined.
--- arch/parisc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/Makefile +1 -1
@@ -134,7 +134,7 @@ palo lifimage: vmlinuz fi @if test ! -f "$(PALOCONF)"; then \ cp $(srctree)/arch/parisc/defpalo.conf $(objtree)/palo.conf; \ - echo 'A generic palo config file ($(objree)/palo.conf) has been created for you.'; \ + echo 'A generic palo config file ($(objtree)/palo.conf) has been created for you.'; \ echo 'You should check it and re-run "make palo".'; \ echo 'WARNING: the "lifimage" file is now placed in this directory by default!'; \ false; \
Greg Kroah-Hartman
maintainerPATCH 279/403 mm/kmemleak: avoid soft lockup in __kmemleak_do_cleanup()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
commit d1534ae23c2b6be350c8ab060803fbf6e9682adc upstream.
A soft lockup warning was observed on a relative small system x86-64 system with 16 GB of memory when running a debug kernel with kmemleak enabled.
watchdog: BUG: soft lockup - CPU#8 stuck for 33s! [kworker/8:1:134]
The test system was running a workload with hot unplug happening in parallel. Then kemleak decided to disable itself due to its inability to allocate more kmemleak objects. The debug kernel has its CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE set to 40,000.
The soft lockup happened in kmemleak_do_cleanup() when the existing kmemleak objects were being removed and deleted one-by-one in a loop via a workqueue. In this particular case, there are at least 40,000 objects that need to be processed and given the slowness of a debug kernel and the fact that a raw_spinlock has to be acquired and released in __delete_object(), it could take a while to properly handle all these objects.
As kmemleak has been disabled in this case, the object removal and deletion process can be further optimized as locking isn't really needed. However, it is probably not worth the effort to optimize for such an edge case that should rarely happen. So the simple solution is to call cond_resched() at periodic interval in the iteration loop to avoid soft lockup.
--- mm/kmemleak.c | 5 +++++ 1 file changed, 5 insertions(+)
mm/kmemleak.c +5 -0
@@ -1849,6 +1849,7 @@ static const struct file_operations kmemstatic void __kmemleak_do_cleanup (void ) {struct kmemleak_object *object, *tmp; +unsigned int cnt =0 ;/* * Kmemleak has already been disabled, no need for RCU list traversal
@@ -1857,6 +1858,10 @@ static void __kmemleak_do_cleanup(void)list_for_each_entry_safe (object, tmp, &object_list, object_list) {__remove_object (object);__delete_object (object); + +/* Call cond_resched() once per 64 iterations to avoid soft lockup */ +if (!(++cnt &0x3f )) +cond_resched (); } }
Greg Kroah-Hartman
maintainerPATCH 280/403 media: uvcvideo: Fix 1-byte out-of-bounds read in uvc_parse_format()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youngjun Lee <[email protected]>
commit 782b6a718651eda3478b1824b37a8b3185d2740c upstream.
The buffer length check before calling uvc_parse_format() only ensured that the buffer has at least 3 bytes (buflen > 2), buf the function accesses buffer[3], requiring at least 4 bytes.
This can lead to an out-of-bounds read if the buffer has exactly 3 bytes.
Fix it by checking that the buffer has at least 4 bytes in uvc_parse_format().
--- drivers/media/usb/uvc/uvc_driver.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +3 -0
@@ -452,6 +452,9 @@ static int uvc_parse_format(struct uvc_dunsigned int i, n;u8 ftype; +if (buflen <4 ) +return -EINVAL ; + format->type = buffer[2 ]; format->index = buffer[3 ];
Greg Kroah-Hartman
maintainerPATCH 281/403 media: uvcvideo: Do not mark valid metadata as invalid
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
commit bda2859bff0b9596a19648f3740c697ce4c71496 upstream.
Currently, the driver performs a length check of the metadata buffer before the actual metadata size is known and before the metadata is decided to be copied. This results in valid metadata buffers being incorrectly marked as invalid.
Move the length check to occur after the metadata size is determined and is decided to be copied.
--- drivers/media/usb/uvc/uvc_video.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/usb/uvc/uvc_video.c +6 -6
@@ -1309,12 +1309,6 @@ static void uvc_video_decode_meta(structif (!meta_buf || length ==2 )return ; -if (meta_buf->length - meta_buf->bytesused < - length +sizeof (meta->ns) +sizeof (meta->sof)) { - meta_buf->error =1 ; -return ; - } - has_pts = mem[1 ] &UVC_STREAM_PTS ; has_scr = mem[1 ] &UVC_STREAM_SCR ;
@@ -1335,6 +1329,12 @@ static void uvc_video_decode_meta(struct !memcmp(scr, stream->clock.last_scr, 6)))return ; +if (meta_buf->length - meta_buf->bytesused < + length +sizeof (meta->ns) +sizeof (meta->sof)) { + meta_buf->error =1 ; +return ; + } + meta = (struct uvc_meta_buf *)((u8 *)meta_buf->mem + meta_buf->bytesused);local_irq_save (flags); time =uvc_video_get_time ();
Greg Kroah-Hartman
maintainerPATCH 282/403 serial: 8250: fix panic due to PSLVERR
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yunhui Cui <[email protected]>
commit 7f8fdd4dbffc05982b96caf586f77a014b2a9353 upstream.
When the PSLVERR_RESP_EN parameter is set to 1, the device generates an error response if an attempt is made to read an empty RBR (Receive Buffer Register) while the FIFO is enabled.
In serial8250_do_startup(), calling serial_port_out(port, UART_LCR, UART_LCR_WLEN8) triggers dw8250_check_lcr(), which invokes dw8250_force_idle() and serial8250_clear_and_reinit_fifos(). The latter function enables the FIFO via serial_out(p, UART_FCR, p->fcr). Execution proceeds to the serial_port_in(port, UART_RX). This satisfies the PSLVERR trigger condition.
When another CPU (e.g., using printk()) is accessing the UART (UART is busy), the current CPU fails the check (value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR) in dw8250_check_lcr(), causing it to enter dw8250_force_idle().
Put serial_port_out(port, UART_LCR, UART_LCR_WLEN8) under the port->lock to fix this issue.
Panic backtrace:
[ 0.442336] Oops - unknown exception [#1] [ 0.442343] epc : dw8250_serial_in32+0x1e/0x4a [ 0.442351] ra : serial8250_do_startup+0x2c8/0x88e ... [ 0.442416] console_on_rootfs+0x26/0x70
--- drivers/tty/serial/8250/8250_port.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/serial/8250/8250_port.c +1 -2
@@ -2296,9 +2296,8 @@ int serial8250_do_startup(struct uart_po/* * Now, initialize the UART */ -serial_port_out (port,UART_LCR ,UART_LCR_WLEN8 ); -spin_lock_irqsave (&port->lock, flags); +serial_port_out (port,UART_LCR ,UART_LCR_WLEN8 );if (up->port.flags &UPF_FOURPORT ) {if (!up->port.irq) up->port.mctrl |=TIOCM_OUT1 ;
Greg Kroah-Hartman
maintainerPATCH 283/403 cpufreq: armada-8k: Fix off by one in armada_8k_cpufreq_free_table()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 4a26df233266a628157d7f0285451d8655defdfc upstream.
The freq_tables[] array has num_possible_cpus() elements so, to avoid an out of bounds access, this loop should be capped at "< nb_cpus" instead of "<= nb_cpus". The freq_tables[] array is allocated in armada_8k_cpufreq_init().
--- drivers/cpufreq/armada-8k-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/armada-8k-cpufreq.c +1 -1
@@ -96,7 +96,7 @@ static void armada_8k_cpufreq_free_table {int opps_index, nb_cpus =num_possible_cpus (); -for (opps_index =0 ; opps_index <= nb_cpus; opps_index++) { +for (opps_index =0 ; opps_index < nb_cpus; opps_index++) {int i;/* If cpu_dev is NULL then we reached the end of the array */
Greg Kroah-Hartman
maintainerPATCH 284/403 m68k: Fix lost column on framebuffer debug console
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
commit 210a1ce8ed4391b64a888b3fb4b5611a13f5ccc7 upstream.
Move the cursor position rightward after rendering the character, not before. This avoids complications that arise when the recursive console_putc call has to wrap the line and/or scroll the display. This also fixes the linewrap bug that crops off the rightmost column.
When the cursor is at the bottom of the display, a linefeed will not move the cursor position further downward. Instead, the display scrolls upward. Avoid the repeated add/subtract sequence by way of a single subtraction at the initialization of console_struct_num_rows.
--- arch/m68k/kernel/head.S | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
arch/m68k/kernel/head.S +21 -10
@@ -3379,6 +3379,7 @@ L(console_clear_loop): movel %d4,%d1 /* screen height in pixels */ divul %a0@(FONT_DESC_HEIGHT),%d1 /* d1 = max num rows */ + subql #1,%d1 /* row range is 0 to num - 1 */ movel %d0,%a2@(Lconsole_struct_num_columns) movel %d1,%a2@(Lconsole_struct_num_rows)
@@ -3525,15 +3526,14 @@ func_start console_putc,%a0/%a1/%d0-%d7 cmpib #10,%d7 jne L(console_not_lf) movel %a0@(Lconsole_struct_cur_row),%d0 - addil #1,%d0 - movel %d0,%a0@(Lconsole_struct_cur_row) movel %a0@(Lconsole_struct_num_rows),%d1 cmpl %d1,%d0 jcs 1f - subil #1,%d0 - movel %d0,%a0@(Lconsole_struct_cur_row) console_scroll + jra L(console_exit) 1: + addql #1,%d0 + movel %d0,%a0@(Lconsole_struct_cur_row) jra L(console_exit) L(console_not_lf):
@@ -3560,12 +3560,6 @@ L(console_not_cr): */ L(console_not_home): movel %a0@(Lconsole_struct_cur_column),%d0 - addql #1,%a0@(Lconsole_struct_cur_column) - movel %a0@(Lconsole_struct_num_columns),%d1 - cmpl %d1,%d0 - jcs 1f - console_putc #'\n' /* recursion is OK! */ -1: movel %a0@(Lconsole_struct_cur_row),%d1 /*
@@ -3612,6 +3606,23 @@ L(console_do_font_scanline): addq #1,%d1 dbra %d7,L(console_read_char_scanline) + /* + * Register usage in the code below: + * a0 = pointer to console globals + * d0 = cursor column + * d1 = cursor column limit + */ + + lea %pc@(L(console_globals)),%a0 + + movel %a0@(Lconsole_struct_cur_column),%d0 + addql #1,%d0 + movel %d0,%a0@(Lconsole_struct_cur_column) /* Update cursor pos */ + movel %a0@(Lconsole_struct_num_columns),%d1 + cmpl %d1,%d0 + jcs L(console_exit) + console_putc #'\n' /* Line wrap using tail recursion */ + L(console_exit): func_return console_putc
Greg Kroah-Hartman
maintainerPATCH 285/403 usb: atm: cxacru: Merge cxacru_upload_firmware() into cxacru_heavy_init()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 8d1b02e5d7e3a6d2acffb1f4c094678fda9e3456 upstream.
After a recent change in clang to expose uninitialized warnings from const variables [1], there is a warning in cxacru_heavy_init():
drivers/usb/atm/cxacru.c:1104:6: error: variable 'bp' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
1104 | if (instance->modem_type->boot_rom_patch) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/atm/cxacru.c:1113:39: note: uninitialized use occurs here
1113 | cxacru_upload_firmware(instance, fw, bp);
| ^~
drivers/usb/atm/cxacru.c:1104:2: note: remove the 'if' if its condition is always true
1104 | if (instance->modem_type->boot_rom_patch) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/usb/atm/cxacru.c:1095:32: note: initialize the variable 'bp' to silence this warning
1095 | const struct firmware *fw, *bp;
| ^
| = NULLWhile the warning is technically correct that bp is conditionally passed uninitialized to cxacru_upload_firmware(), it is ultimately a false positive warning on the uninitialized use of bp because the same condition that initializes bp, instance->modem_type->boot_rom_patch, is the same one that gates the use of bp within cxacru_upload_firmware(). As this warning occurs in clang's frontend before inlining occurs, it cannot know that these conditions are indentical to avoid the warning.
Manually inline cxacru_upload_firmware() into cxacru_heavy_init(), as that is its only callsite, so that clang can see that bp is initialized and used under the same condition, clearing up the warning without any functional changes to the code (LLVM was already doing this inlining later).
--- drivers/usb/atm/cxacru.c | 106 +++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 57 deletions(-)
drivers/usb/atm/cxacru.c +49 -57
@@ -984,25 +984,60 @@ cleanup:return ret; } -static void cxacru_upload_firmware (struct cxacru_data *instance, -const struct firmware *fw, -const struct firmware *bp) + +static int cxacru_find_firmware (struct cxacru_data *instance, +char *phase,const struct firmware **fw_p) { -int ret; +struct usbatm_data *usbatm = instance->usbatm; +struct device *dev = &usbatm->usb_intf->dev; +char buf[16 ]; + +sprintf (buf,"cxacru-%s.bin" , phase); +usb_dbg (usbatm,"cxacru_find_firmware: looking for %s\n" , buf); + +if (request_firmware (fw_p, buf, dev)) { +usb_dbg (usbatm,"no stage %s firmware found\n" , phase); +return -ENOENT ; + } + +usb_info (usbatm,"found firmware %s\n" , buf); + +return 0 ; +} + +static int cxacru_heavy_init (struct usbatm_data *usbatm_instance, +struct usb_interface *usb_intf) +{ +const struct firmware *fw, *bp; +struct cxacru_data *instance = usbatm_instance->driver_data;struct usbatm_data *usbatm = instance->usbatm;struct usb_device *usb_dev = usbatm->usb_dev;__le16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct };__le32 val; +int ret; + + ret =cxacru_find_firmware (instance,"fw" , &fw); +if (ret) { +usb_warn (usbatm_instance,"firmware (cxacru-fw.bin) unavailable (system misconfigured?)\n" ); +return ret; + } -usb_dbg (usbatm,"%s\n" , __func__); +if (instance->modem_type->boot_rom_patch) { + ret =cxacru_find_firmware (instance,"bp" , &bp); +if (ret) { +usb_warn (usbatm_instance,"boot ROM patch (cxacru-bp.bin) unavailable (system misconfigured?)\n" ); +release_firmware (fw); +return ret; + } + }/* FirmwarePllFClkValue */ val =cpu_to_le32 (instance->modem_type->pll_f_clk); ret =cxacru_fw (usb_dev,FW_WRITE_MEM ,0x2 ,0x0 ,PLLFCLK_ADDR , (u8 *) &val,4 );if (ret) {usb_err (usbatm,"FirmwarePllFClkValue failed: %d\n" , ret); -return ; + goto done; }/* FirmwarePllBClkValue */
@@ -1010,7 +1045,7 @@ static void cxacru_upload_firmware(struc ret =cxacru_fw (usb_dev,FW_WRITE_MEM ,0x2 ,0x0 ,PLLBCLK_ADDR , (u8 *) &val,4 );if (ret) {usb_err (usbatm,"FirmwarePllBClkValue failed: %d\n" , ret); -return ; + goto done; }/* Enable SDRAM */
@@ -1018,7 +1053,7 @@ static void cxacru_upload_firmware(struc ret =cxacru_fw (usb_dev,FW_WRITE_MEM ,0x2 ,0x0 ,SDRAMEN_ADDR , (u8 *) &val,4 );if (ret) {usb_err (usbatm,"Enable SDRAM failed: %d\n" , ret); -return ; + goto done; }/* Firmware */
@@ -1026,7 +1061,7 @@ static void cxacru_upload_firmware(struc ret =cxacru_fw (usb_dev,FW_WRITE_MEM ,0x2 ,0x0 ,FW_ADDR , fw->data, fw->size);if (ret) {usb_err (usbatm,"Firmware upload failed: %d\n" , ret); -return ; + goto done; }/* Boot ROM patch */
@@ -1035,7 +1070,7 @@ static void cxacru_upload_firmware(struc ret =cxacru_fw (usb_dev,FW_WRITE_MEM ,0x2 ,0x0 ,BR_ADDR , bp->data, bp->size);if (ret) {usb_err (usbatm,"Boot ROM patching failed: %d\n" , ret); -return ; + goto done; } }
@@ -1043,7 +1078,7 @@ static void cxacru_upload_firmware(struc ret =cxacru_fw (usb_dev,FW_WRITE_MEM ,0x2 ,0x0 ,SIG_ADDR , (u8 *) signature,4 );if (ret) {usb_err (usbatm,"Signature storing failed: %d\n" , ret); -return ; + goto done; }usb_info (usbatm,"starting device\n" );
@@ -1055,7 +1090,7 @@ static void cxacru_upload_firmware(struc }if (ret) {usb_err (usbatm,"Passing control to firmware failed: %d\n" , ret); -return ; + goto done; }/* Delay to allow firmware to start up. */
@@ -1069,53 +1104,10 @@ static void cxacru_upload_firmware(struc ret =cxacru_cm (instance,CM_REQUEST_CARD_GET_STATUS ,NULL ,0 ,NULL ,0 );if (ret <0 ) {usb_err (usbatm,"modem failed to initialize: %d\n" , ret); -return ; - } -} - -static int cxacru_find_firmware (struct cxacru_data *instance, -char *phase,const struct firmware **fw_p) -{ -struct usbatm_data *usbatm = instance->usbatm; -struct device *dev = &usbatm->usb_intf->dev; -char buf[16 ]; - -sprintf (buf,"cxacru-%s.bin" , phase); -usb_dbg (usbatm,"cxacru_find_firmware: looking for %s\n" , buf); - -if (request_firmware (fw_p, buf, dev)) { -usb_dbg (usbatm,"no stage %s firmware found\n" , phase); -return -ENOENT ; + goto done; } -usb_info (usbatm,"found firmware %s\n" , buf); - -return 0 ; -} - -static int cxacru_heavy_init (struct usbatm_data *usbatm_instance, -struct usb_interface *usb_intf) -{ -const struct firmware *fw, *bp; -struct cxacru_data *instance = usbatm_instance->driver_data; -int ret =cxacru_find_firmware (instance,"fw" , &fw); - -if (ret) { -usb_warn (usbatm_instance,"firmware (cxacru-fw.bin) unavailable (system misconfigured?)\n" ); -return ret; - } - -if (instance->modem_type->boot_rom_patch) { - ret =cxacru_find_firmware (instance,"bp" , &bp); -if (ret) { -usb_warn (usbatm_instance,"boot ROM patch (cxacru-bp.bin) unavailable (system misconfigured?)\n" ); -release_firmware (fw); -return ret; - } - } - -cxacru_upload_firmware (instance, fw, bp); - +done:if (instance->modem_type->boot_rom_patch)release_firmware (bp);release_firmware (fw);
Greg Kroah-Hartman
maintainerPATCH 286/403 usb: gadget: udc: renesas_usb3: fix device leak at unbind
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 868837b0a94c6b1b1fdbc04d3ba218ca83432393 upstream.
Make sure to drop the reference to the companion device taken during probe when the driver is unbound.
--- drivers/usb/gadget/udc/renesas_usb3.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/udc/renesas_usb3.c +1 -0
@@ -2551,6 +2551,7 @@ static int renesas_usb3_remove(struct plstruct renesas_usb3 *usb3 =platform_get_drvdata (pdev);debugfs_remove_recursive (usb3->dentry); +put_device (usb3->host_dev);device_remove_file (&pdev->dev, &dev_attr_role);cancel_work_sync (&usb3->role_work);
Greg Kroah-Hartman
maintainerPATCH 287/403 usb: dwc3: meson-g12a: fix device leaks at unbind
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 93b400f4951404d040197943a25d6fef9f8ccabb upstream.
Make sure to drop the references taken to the child devices by of_find_device_by_node() during probe on driver unbind.
--- drivers/usb/dwc3/dwc3-meson-g12a.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/dwc3/dwc3-meson-g12a.c +3 -0
@@ -529,6 +529,9 @@ static int dwc3_meson_g12a_remove(structusb_role_switch_unregister (priv->role_switch); +put_device (priv->switch_desc.udc); +put_device (priv->switch_desc.usb2_port); +of_platform_depopulate (dev);for (i =0 ; i <PHY_COUNT ; ++i) {
Greg Kroah-Hartman
maintainerPATCH 288/403 vt: keyboard: Dont process Unicode characters in K_OFF mode
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myrrh Periwinkle <[email protected]>
commit b1cc2092ea7a52e2c435aee6d2b1bcb773202663 upstream.
We don't process Unicode characters if the virtual terminal is in raw mode, so there's no reason why we shouldn't do the same for K_OFF (especially since people would expect K_OFF to actually turn off all VT key processing).
--- drivers/tty/vt/keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/vt/keyboard.c +1 -1
@@ -1460,7 +1460,7 @@ static void kbd_keycode(unsigned int key rc =atomic_notifier_call_chain (&keyboard_notifier_list,KBD_UNICODE , ¶m);if (rc !=NOTIFY_STOP ) -if (down && !raw_mode) +if (down && !(raw_mode || kbd->kbdmode ==VC_OFF ))k_unicode (vc, keysym, !down);return ; }
Greg Kroah-Hartman
maintainerPATCH 289/403 vt: defkeymap: Map keycodes above 127 to K_HOLE
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myrrh Periwinkle <[email protected]>
commit b43cb4ff85da5cf29c4cd351ef1d7dd8210780f7 upstream.
The maximum number of keycodes got bumped to 256 a very long time ago, but the default keymaps were never adjusted to match. This is causing the kernel to interpret keycodes above 127 as U+0000 if the shipped generated keymap is used.
Fix this by mapping all keycodes above 127 to K_HOLE so the kernel ignores them.
The contents of this patche were generated by rerunning loadkeys --mktable --unicode and only including the changes to map keycodes above 127 to K_HOLE.
--- drivers/tty/vt/defkeymap.c_shipped | 112 +++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+)
drivers/tty/vt/defkeymap.c_shipped +112 -0
@@ -23,6 +23,22 @@ u_short plain_map[NR_KEYS] = { 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short shift_map[NR_KEYS] = {
@@ -42,6 +58,22 @@ u_short shift_map[NR_KEYS] = { 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short altgr_map[NR_KEYS] = {
@@ -61,6 +93,22 @@ u_short altgr_map[NR_KEYS] = { 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short ctrl_map[NR_KEYS] = {
@@ -80,6 +128,22 @@ u_short ctrl_map[NR_KEYS] = { 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short shift_ctrl_map[NR_KEYS] = {
@@ -99,6 +163,22 @@ u_short shift_ctrl_map[NR_KEYS] = { 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short alt_map[NR_KEYS] = {
@@ -118,6 +198,22 @@ u_short alt_map[NR_KEYS] = { 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; u_short ctrl_alt_map[NR_KEYS] = {
@@ -137,6 +233,22 @@ u_short ctrl_alt_map[NR_KEYS] = { 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, + 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; ushort *key_maps[MAX_NR_KEYMAPS] = {
Greg Kroah-Hartman
maintainerPATCH 290/403 Revert "vgacon: Add check for vc_origin address range in vgacon_scroll()"
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit e4fc307d8e24f122402907ebf585248cad52841d upstream.
This reverts commit 864f9963ec6b4b76d104d595ba28110b87158003.
The patch is wrong as it checks vc_origin against vc_screenbuf, while in text mode it should compare against vga_vram_base.
As such it broke VGA text scrolling, which can be reproduced like this:
(1) boot a kernel that is configured to use text mode VGA-console
(2) type commands: ls -l /usr/bin | less -S
(3) scroll up/down with cursor-down/up keys
--- drivers/video/console/vgacon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/console/vgacon.c +1 -1
@@ -1198,7 +1198,7 @@ static bool vgacon_scroll(struct vc_data c->vc_screenbuf_size - delta); c->vc_origin = vga_vram_end - c->vc_screenbuf_size; vga_rolled_over =0 ; - }else if (oldo - delta >= (unsigned long )c->vc_screenbuf) + }else c->vc_origin -= delta; c->vc_scr_end = c->vc_origin + c->vc_screenbuf_size; scr_memsetw((u16 *) (c->vc_origin), c->vc_video_erase_char,
Greg Kroah-Hartman
maintainerPATCH 291/403 ext4: check fast symlink for ea_inode correctly
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Dilger <[email protected]>
commit b4cc4a4077268522e3d0d34de4b2dc144e2330fa upstream.
The check for a fast symlink in the presence of only an external xattr inode is incorrect. If a fast symlink does not have an xattr block (i_file_acl == 0), but does have an external xattr inode that increases inode i_blocks, then the check for a fast symlink will incorrectly fail and __ext4_iget()->ext4_ind_check_inode() will report the inode is corrupt when it "validates" i_data[] on the next read:
# ln -s foo /mnt/tmp/bar
# setfattr -h -n trusted.test \
-v "$(yes | head -n 4000)" /mnt/tmp/bar
# umount /mnt/tmp
# mount /mnt/tmp
# ls -l /mnt/tmp
ls: cannot access '/mnt/tmp/bar': Structure needs cleaning
total 4
? l?????????? ? ? ? ? ? bar
# dmesg | tail -1
EXT4-fs error (device dm-8): __ext4_iget:5098:
inode #24578: block 7303014: comm ls: invalid block(note that "block 7303014" = 0x6f6f66 = "foo" in LE order).
ext4_inode_is_fast_symlink() should check the superblock EXT4_FEATURE_INCOMPAT_EA_INODE feature flag, not the inode EXT4_EA_INODE_FL, since the latter is only set on the xattr inode itself, and not on the inode that uses this xattr.
Reviewed-on: https://review.whamcloud.com/59879
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-19121
--- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
@@ -150,7 +150,7 @@ static int ext4_meta_trans_blocks(struct*/ int ext4_inode_is_fast_symlink (struct inode *inode) { -if (!(EXT4_I (inode)->i_flags &EXT4_EA_INODE_FL )) { +if (!ext4_has_feature_ea_inode (inode->i_sb)) {int ea_blocks =EXT4_I (inode)->i_file_acl ?EXT4_CLUSTER_SIZE (inode->i_sb) >>9 :0 ;
Greg Kroah-Hartman
maintainerPATCH 292/403 ext4: fix fsmap end of range reporting with bigalloc
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ojaswin Mujoo <[email protected]>
commit bae76c035bf0852844151e68098c9b7cd63ef238 upstream.
With bigalloc enabled, the logic to report last extent has a bug since we try to use cluster units instead of block units. This can cause an issue where extra incorrect entries might be returned back to the user. This was flagged by generic/365 with 64k bs and -O bigalloc.
** Details of issue **
The issue was noticed on 5G 64k blocksize FS with -O bigalloc which has only 1 bg.
$ xfs_io -c "fsmap -d" /mnt/scratch
0: 253:48 [0..127]: static fs metadata 128 /* sb */
1: 253:48 [128..255]: special 102:1 128 /* gdt */ 3: 253:48 [256..383]: special 102:3 128 /* block bitmap */ 4: 253:48 [384..2303]: unknown 1920 /* flex bg empty space */
5: 253:48 [2304..2431]: special 102:4 128 /* inode bitmap */
6: 253:48 [2432..4351]: unknown 1920 /* flex bg empty space */
7: 253:48 [4352..6911]: inodes 2560
8: 253:48 [6912..538623]: unknown 531712 9: 253:48 [538624..10485759]: free space 9947136
The issue can be seen with:
$ xfs_io -c "fsmap -d 0 3" /mnt/scratch
0: 253:48 [0..127]: static fs metadata 128
1: 253:48 [384..2047]: unknown 1664
Only the first entry was expected to be returned but we get 2. This is because:
ext4_getfsmap_datadev()
first_cluster, last_cluster = 0
...
info->gfi_last = true;
ext4_getfsmap_datadev_helper(sb, end_ag, last_cluster + 1, 0, info);
fsb = C2B(1) = 16
fslen = 0
...
/* Merge in any relevant extents from the meta_list */
list_for_each_entry_safe(p, tmp, &info->gfi_meta_list, fmr_list) {
...
// since fsb = 16, considers all metadata which starts before 16 blockno
iter 1: error = ext4_getfsmap_helper(sb, info, p); // p = sb (0,1), nop
info->gfi_next_fsblk = 1
iter 2: error = ext4_getfsmap_helper(sb, info, p); // p = gdt (1,2), nop
info->gfi_next_fsblk = 2
iter 3: error = ext4_getfsmap_helper(sb, info, p); // p = blk bitmap (2,3), nop
info->gfi_next_fsblk = 3
iter 4: error = ext4_getfsmap_helper(sb, info, p); // p = ino bitmap (18,19)
if (rec_blk > info->gfi_next_fsblk) { // (18 > 3)
// emits an extra entry ** BUG **
}
}Fix this by directly calling ext4_getfsmap_datadev() with a dummy record that has fmr_physical set to (end_fsb + 1) instead of last_cluster + 1. By using the block instead of cluster we get the correct behavior.
Replacing ext4_getfsmap_datadev_helper() with ext4_getfsmap_helper() is okay since the gfi_lastfree and metadata checks in ext4_getfsmap_datadev_helper() are anyways redundant when we only want to emit the last allocated block of the range, as we have already taken care of emitting metadata and any last free blocks.
--- fs/ext4/fsmap.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
fs/ext4/fsmap.c +12 -3
@@ -526,6 +526,7 @@ static int ext4_getfsmap_datadev(structext4_group_t end_ag;ext4_grpblk_t first_cluster;ext4_grpblk_t last_cluster; +struct ext4_fsmap irec;int error =0 ; bofs =le32_to_cpu (sbi->s_es->s_first_data_block);
@@ -609,10 +610,18 @@ static int ext4_getfsmap_datadev(struct goto err; } -/* Report any gaps at the end of the bg */ +/* +* The dummy record below will cause ext4_getfsmap_helper() to report +* any allocated blocks at the end of the range. +*/ + irec.fmr_device =0 ; + irec.fmr_physical = end_fsb +1 ; + irec.fmr_length =0 ; + irec.fmr_owner =EXT4_FMR_OWN_FREE ; + irec.fmr_flags =0 ; + info->gfi_last = true; - error =ext4_getfsmap_datadev_helper (sb, end_ag, last_cluster +1 , -0 , info); + error =ext4_getfsmap_helper (sb, info, &irec);if (error) goto err;
Greg Kroah-Hartman
maintainerPATCH 293/403 ext4: fix reserved gdt blocks handling in fsmap
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ojaswin Mujoo <[email protected]>
commit 3ffbdd1f1165f1b2d6a94d1b1aabef57120deaf7 upstream.
In some cases like small FSes with no meta_bg and where the resize doesn't need extra gdt blocks as it can fit in the current one, s_reserved_gdt_blocks is set as 0, which causes fsmap to emit a 0 length entry, which is incorrect.
$ mkfs.ext4 -b 65536 -O bigalloc /dev/sda 5G $ mount /dev/sda /mnt/scratch $ xfs_io -c "fsmap -d" /mnt/scartch
0: 253:48 [0..127]: static fs metadata 128
1: 253:48 [128..255]: special 102:1 128
2: 253:48 [256..255]: special 102:2 0 <---- 0 len entry
3: 253:48 [256..383]: special 102:3 128Fix this by adding a check for this case.
--- fs/ext4/fsmap.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/ext4/fsmap.c +8 -0
@@ -393,6 +393,14 @@ static unsigned int ext4_getfsmap_find_s/* Reserved GDT blocks */ if (!ext4_has_feature_meta_bg (sb) || metagroup < first_meta_bg) { len =le16_to_cpu (sbi->s_es->s_reserved_gdt_blocks); + +/* +* mkfs.ext4 can set s_reserved_gdt_blocks as 0 in some cases, +* check for that. +*/ +if (!len) +return 0 ; + error =ext4_getfsmap_fill (meta_list, fsb, len,EXT4_FMR_OWN_RESV_GDT );if (error)
Greg Kroah-Hartman
maintainerPATCH 294/403 ata: libata-scsi: Fix ata_to_sense_error() status handling
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit cf3fc037623c54de48d2ec1a1ee686e2d1de2d45 upstream.
Commit 8ae720449fca ("libata: whitespace fixes in ata_to_sense_error()") inadvertantly added the entry 0x40 (ATA_DRDY) to the stat_table array in the function ata_to_sense_error(). This entry ties a failed qc which has a status filed equal to ATA_DRDY to the sense key ILLEGAL REQUEST with the additional sense code UNALIGNED WRITE COMMAND. This entry will be used to generate a failed qc sense key and sense code when the qc is missing sense data and there is no match for the qc error field in the sense_table array of ata_to_sense_error().
As a result, for a failed qc for which we failed to get sense data (e.g. read log 10h failed if qc is an NCQ command, or REQUEST SENSE EXT command failed for the non-ncq case, the user very often end up seeing the completely misleading "unaligned write command" error, even if qc was not a write command. E.g.:
sd 0:0:0:0: [sda] tag#12 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s sd 0:0:0:0: [sda] tag#12 Sense Key : Illegal Request [current]
sd 0:0:0:0: [sda] tag#12 Add. Sense: Unaligned write command
sd 0:0:0:0: [sda] tag#12 CDB: Read(10) 28 00 00 00 10 00 00 00 08 00
I/O error, dev sda, sector 4096 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
Fix this by removing the ATA_DRDY entry from the stat_table array so that we default to always returning ABORTED COMMAND without any additional sense code, since we do not know any better. The entry 0x08 (ATA_DRQ) is also removed since signaling ABORTED COMMAND with a parity error is also misleading (as a parity error would likely be signaled through a bus error). So for this case, also default to returning ABORTED COMMAND without any additional sense code. With this, the previous example error case becomes:
sd 0:0:0:0: [sda] tag#17 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s sd 0:0:0:0: [sda] tag#17 Sense Key : Aborted Command [current]
sd 0:0:0:0: [sda] tag#17 Add. Sense: No additional sense information
sd 0:0:0:0: [sda] tag#17 CDB: Read(10) 28 00 00 00 10 00 00 00 08 00
I/O error, dev sda, sector 4096 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
Together with these fixes, refactor stat_table to make it more readable by putting the entries comments in front of the entries and using the defined status bits macros instead of hardcoded values.
--- drivers/ata/libata-scsi.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/ata/libata-scsi.c +8 -12
@@ -984,18 +984,14 @@ static void ata_to_sense_error(unsigned {0xFF, 0xFF, 0xFF, 0xFF}, // END mark };static const unsigned char stat_table[][4 ] = { -/* Must be first because BUSY means no other bits valid */ - {0x80 ,ABORTED_COMMAND ,0x47 ,0x00 }, -// Busy, fake parity for now - {0x40 ,ILLEGAL_REQUEST ,0x21 ,0x04 }, -// Device ready, unaligned write command - {0x20 ,HARDWARE_ERROR ,0x44 ,0x00 }, -// Device fault, internal target failure - {0x08 ,ABORTED_COMMAND ,0x47 ,0x00 }, -// Timed out in xfer, fake parity for now - {0x04 ,RECOVERED_ERROR ,0x11 ,0x00 }, -// Recovered ECC error Medium error, recovered - {0xFF ,0xFF ,0xFF ,0xFF },// END mark +/* Busy: must be first because BUSY means no other bits valid */ + {ATA_BUSY ,ABORTED_COMMAND ,0x00 ,0x00 }, +/* Device fault: INTERNAL TARGET FAILURE */ + {ATA_DF ,HARDWARE_ERROR ,0x44 ,0x00 }, +/* Corrected data error */ + {ATA_CORR ,RECOVERED_ERROR ,0x00 ,0x00 }, + + {0xFF ,0xFF ,0xFF ,0xFF },/* END mark */ };/*
Greg Kroah-Hartman
maintainerPATCH 295/403 zynq_fpga: use sgtable-based scatterlist wrappers
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
commit 37e00703228ab44d0aacc32a97809a4f6f58df1b upstream.
Use common wrappers operating directly on the struct sg_table objects to fix incorrect use of statterlists related calls. dma_unmap_sg() function has to be called with the number of elements originally passed to the dma_map_sg() function, not the one returned in sgtable's nents.
--- drivers/fpga/zynq-fpga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/fpga/zynq-fpga.c +2 -2
@@ -406,7 +406,7 @@ static int zynq_fpga_ops_write(struct fp } priv->dma_nelms = -dma_map_sg (mgr->dev.parent, sgt->sgl, sgt->nents,DMA_TO_DEVICE ); +dma_map_sgtable (mgr->dev.parent, sgt,DMA_TO_DEVICE ,0 );if (priv->dma_nelms ==0 ) {dev_err (&mgr->dev,"Unable to DMA map (TO_DEVICE)\n" );return -ENOMEM ;
@@ -478,7 +478,7 @@ out_clk:clk_disable (priv->clk); out_free: -dma_unmap_sg (mgr->dev.parent, sgt->sgl, sgt->nents,DMA_TO_DEVICE ); +dma_unmap_sgtable (mgr->dev.parent, sgt,DMA_TO_DEVICE ,0 );return err; }
Greg Kroah-Hartman
maintainerPATCH 296/403 wifi: brcmsmac: Remove const from tbl_ptr parameter in wlc_lcnphy_common_read_table()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 81284e86bf8849f8e98e8ead3ff5811926b2107f upstream.
A new warning in clang [1] complains that diq_start in wlc_lcnphy_tx_iqlo_cal() is passed uninitialized as a const pointer to wlc_lcnphy_common_read_table():
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c:2728:13: error: variable 'diq_start' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer]
2728 | &diq_start, 1, 16, 69);
| ^~~~~~~~~
The table pointer passed to wlc_lcnphy_common_read_table() should not be considered constant, as wlc_phy_read_table() is ultimately going to update it. Remove the const qualifier from the tbl_ptr to clear up the warning.
--- drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c +1 -1
@@ -974,7 +974,7 @@ void wlc_lcnphy_read_table(struct brcms_static void wlc_lcnphy_common_read_table (struct brcms_phy *pi,u32 tbl_id, -const u16 *tbl_ptr,u32 tbl_len, +u16 *tbl_ptr,u32 tbl_len,u32 tbl_width,u32 tbl_offset) {struct phytbl_info tab;
Greg Kroah-Hartman
maintainerPATCH 297/403 pwm: imx-tpm: Reset counter if CMOD is 0
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurentiu Mihalcea <[email protected]>
commit 65c6f742ab14ab1a2679fba72b82dcc0289d96f1 upstream.
As per the i.MX93 TRM, section 67.3.2.1 "MOD register update", the value of the TPM counter does NOT get updated when writing MOD.MOD unless SC.CMOD != 0. Therefore, with the current code, assuming the following sequence:
1) pwm_disable()
2) pwm_apply_might_sleep() /* period is changed here */
3) pwm_enable()
and assuming only one channel is active, if CNT.COUNT is higher than the MOD.MOD value written during the pwm_apply_might_sleep() call then, when re-enabling the PWM during pwm_enable(), the counter will end up resetting after UINT32_MAX - CNT.COUNT + MOD.MOD cycles instead of MOD.MOD cycles as normally expected.
Fix this problem by forcing a reset of the TPM counter before MOD.MOD is written.
--- drivers/pwm/pwm-imx-tpm.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/pwm/pwm-imx-tpm.c +9 -0
@@ -205,6 +205,15 @@ static int pwm_imx_tpm_apply_hw(struct pwritel (val, tpm->base +PWM_IMX_TPM_SC );/* +* if the counter is disabled (CMOD == 0), programming the new +* period length (MOD) will not reset the counter (CNT). If +* CNT.COUNT happens to be bigger than the new MOD value then +* the counter will end up being reset way too late. Therefore, +* manually reset it to 0. +*/ +if (!cmod) +writel (0x0 , tpm->base +PWM_IMX_TPM_CNT ); +/* * set period count: * if the PWM is disabled (CMOD[1:0] = 2b00), then MOD register * is updated when MOD register is written.
Greg Kroah-Hartman
maintainerPATCH 298/403 mtd: rawnand: fsmc: Add missing check after DMA map
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
commit 6c4dab38431fee3d39a841d66ba6f2890b31b005 upstream.
The DMA map functions can fail and should be tested for errors.
Rule: add
--- drivers/mtd/nand/raw/fsmc_nand.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/nand/raw/fsmc_nand.c +2 -0
@@ -492,6 +492,8 @@ static int dma_xfer(struct fsmc_nand_dat dma_dev = chan->device; dma_addr =dma_map_single (dma_dev->dev, buffer, len, direction); +if (dma_mapping_error (dma_dev->dev, dma_addr)) +return -EINVAL ;if (direction ==DMA_TO_DEVICE ) { dma_src = dma_addr;
Greg Kroah-Hartman
maintainerPATCH 299/403 PCI: endpoint: Fix configfs group list head handling
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit d79123d79a8154b4318529b7b2ff7e15806f480b upstream.
Doing a list_del() on the epf_group field of struct pci_epf_driver in pci_epf_remove_cfs() is not correct as this field is a list head, not a list entry. This list_del() call triggers a KASAN warning when an endpoint function driver which has a configfs attribute group is torn down:
==================================================================
BUG: KASAN: slab-use-after-free in pci_epf_remove_cfs+0x17c/0x198 Write of size 8 at addr ffff00010f4a0d80 by task rmmod/319 CPU: 3 UID: 0 PID: 319 Comm: rmmod Not tainted 6.16.0-rc2 #1 NONE Hardware name: Radxa ROCK 5B (DT) Call trace: show_stack+0x2c/0x84 (C) dump_stack_lvl+0x70/0x98 print_report+0x17c/0x538 kasan_report+0xb8/0x190 __asan_report_store8_noabort+0x20/0x2c pci_epf_remove_cfs+0x17c/0x198 pci_epf_unregister_driver+0x18/0x30 nvmet_pci_epf_cleanup_module+0x24/0x30 [nvmet_pci_epf] __arm64_sys_delete_module+0x264/0x424 invoke_syscall+0x70/0x260 el0_svc_common.constprop.0+0xac/0x230 do_el0_svc+0x40/0x58 el0_svc+0x48/0xdc el0t_64_sync_handler+0x10c/0x138 el0t_64_sync+0x198/0x19c
...
Remove this incorrect list_del() call from pci_epf_remove_cfs().
--- drivers/pci/endpoint/pci-epf-core.c | 1 - 1 file changed, 1 deletion(-)
drivers/pci/endpoint/pci-epf-core.c +0 -1
@@ -155,7 +155,6 @@ static void pci_epf_remove_cfs(struct pcmutex_lock (&pci_epf_mutex);list_for_each_entry_safe (group, tmp, &driver->epf_group, group_entry)pci_ep_cfs_remove_epf_group (group); -list_del (&driver->epf_group);mutex_unlock (&pci_epf_mutex); }
Greg Kroah-Hartman
maintainerPATCH 300/403 PCI: endpoint: Fix configfs group removal on driver teardown
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 910bdb8197f9322790c738bb32feaa11dba26909 upstream.
An endpoint driver configfs attributes group is added to the epf_group list of struct pci_epf_driver by pci_epf_add_cfs() but an added group is not removed from this list when the attribute group is unregistered with pci_ep_cfs_remove_epf_group().
Add the missing list_del() call in pci_ep_cfs_remove_epf_group() to correctly remove the attribute group from the driver list.
With this change, once the loop over all attribute groups in pci_epf_remove_cfs() completes, the driver epf_group list should be empty. Add a WARN_ON() to make sure of that.
--- drivers/pci/endpoint/pci-ep-cfs.c | 1 + drivers/pci/endpoint/pci-epf-core.c | 1 + 2 files changed, 2 insertions(+)
drivers/pci/endpoint/pci-ep-cfs.c +1 -0
@@ -480,6 +480,7 @@ void pci_ep_cfs_remove_epf_group(structif (IS_ERR_OR_NULL (group))return ; +list_del (&group->group_entry);configfs_unregister_default_group (group); }EXPORT_SYMBOL (pci_ep_cfs_remove_epf_group);
drivers/pci/endpoint/pci-epf-core.c +1 -0
@@ -155,6 +155,7 @@ static void pci_epf_remove_cfs(struct pcmutex_lock (&pci_epf_mutex);list_for_each_entry_safe (group, tmp, &driver->epf_group, group_entry)pci_ep_cfs_remove_epf_group (group); +WARN_ON (!list_empty (&driver->epf_group));mutex_unlock (&pci_epf_mutex); }
Greg Kroah-Hartman
maintainerPATCH 301/403 jbd2: prevent softlockup in jbd2_log_do_checkpoint()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 9d98cf4632258720f18265a058e62fde120c0151 upstream.
Both jbd2_log_do_checkpoint() and jbd2_journal_shrink_checkpoint_list() periodically release j_list_lock after processing a batch of buffers to avoid long hold times on the j_list_lock. However, since both functions contend for j_list_lock, the combined time spent waiting and processing can be significant.
jbd2_journal_shrink_checkpoint_list() explicitly calls cond_resched() when need_resched() is true to avoid softlockups during prolonged operations. But jbd2_log_do_checkpoint() only exits its loop when need_resched() is true, relying on potentially sleeping functions like __flush_batch() or wait_on_buffer() to trigger rescheduling. If those functions do not sleep, the kernel may hit a softlockup.
watchdog: BUG: soft lockup - CPU#3 stuck for 156s! [kworker/u129:2:373] CPU: 3 PID: 373 Comm: kworker/u129:2 Kdump: loaded Not tainted 6.6.0+ #10 Hardware name: Huawei TaiShan 2280 /BC11SPCD, BIOS 1.27 06/13/2017 Workqueue: writeback wb_workfn (flush-7:2) pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : native_queued_spin_lock_slowpath+0x358/0x418 lr : jbd2_log_do_checkpoint+0x31c/0x438 [jbd2] Call trace: native_queued_spin_lock_slowpath+0x358/0x418 jbd2_log_do_checkpoint+0x31c/0x438 [jbd2] __jbd2_log_wait_for_space+0xfc/0x2f8 [jbd2] add_transaction_credits+0x3bc/0x418 [jbd2] start_this_handle+0xf8/0x560 [jbd2] jbd2__journal_start+0x118/0x228 [jbd2] __ext4_journal_start_sb+0x110/0x188 [ext4] ext4_do_writepages+0x3dc/0x740 [ext4] ext4_writepages+0xa4/0x190 [ext4] do_writepages+0x94/0x228 __writeback_single_inode+0x48/0x318 writeback_sb_inodes+0x204/0x590 __writeback_inodes_wb+0x54/0xf8 wb_writeback+0x2cc/0x3d8 wb_do_writeback+0x2e0/0x2f8 wb_workfn+0x80/0x2a8 process_one_work+0x178/0x3e8 worker_thread+0x234/0x3b8 kthread+0xf0/0x108 ret_from_fork+0x10/0x20
So explicitly call cond_resched() in jbd2_log_do_checkpoint() to avoid softlockup.
--- fs/jbd2/checkpoint.c | 1 + 1 file changed, 1 insertion(+)
fs/jbd2/checkpoint.c +1 -0
@@ -321,6 +321,7 @@ restart: retry:if (batch_count)__flush_batch (journal, &batch_count); +cond_resched ();spin_lock (&journal->j_list_lock); goto restart; }
Greg Kroah-Hartman
maintainerPATCH 302/403 soc/tegra: pmc: Ensure power-domains are in a known state
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jon Hunter <[email protected]>
commit b6bcbce3359619d05bf387d4f5cc3af63668dbaa upstream.
After commit 13a4b7fb6260 ("pmdomain: core: Leave powered-on genpds on until late_initcall_sync") was applied, the Tegra210 Jetson TX1 board failed to boot. Looking into this issue, before this commit was applied, if any of the Tegra power-domains were in 'on' state when the kernel booted, they were being turned off by the genpd core before any driver had chance to request them. This was purely by luck and a consequence of the power-domains being turned off earlier during boot. After this commit was applied, any power-domains in the 'on' state are kept on for longer during boot and therefore, may never transitioned to the off state before they are requested/used. The hang on the Tegra210 Jetson TX1 is caused because devices in some power-domains are accessed without the power-domain being turned off and on, indicating that the power-domain is not in a completely on state.
Quoted 1 line
From reviewing the Tegra PMC driver code, if a power-domain is in the
'on' state there is no guarantee that all the necessary clocks associated with the power-domain are on and even if they are they would not have been requested via the clock framework and so could be turned off later. Some power-domains also have a 'clamping' register that needs to be configured as well. In short, if a power-domain is already 'on' it is difficult to know if it has been configured correctly. Given that the power-domains happened to be switched off during boot previously, to ensure that they are in a good known state on boot, fix this by switching off any power-domains that are on initially when registering the power-domains with the genpd framework.
Note that commit 05cfb988a4d0 ("soc/tegra: pmc: Initialise resets associated with a power partition") updated the tegra_powergate_of_get_resets() function to pass the 'off' to ensure that the resets for the power-domain are in the correct state on boot. However, now that we may power off a domain on boot, if it is on, it is better to move this logic into the tegra_powergate_add() function so that there is a single place where we are handling the initial state of the power-domain.
--- drivers/soc/tegra/pmc.c | 51 +++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 22 deletions(-)
drivers/soc/tegra/pmc.c +29 -22
@@ -950,7 +950,7 @@ err: }static int tegra_powergate_of_get_resets (struct tegra_powergate *pg, -struct device_node *np,bool off) +struct device_node *np) {struct device *dev = pg->pmc->dev;int err;
@@ -965,22 +965,6 @@ static int tegra_powergate_of_get_resets err =reset_control_acquire (pg->reset);if (err <0 ) {pr_err ("failed to acquire resets: %d\n" , err); - goto out; - } - -if (off) { - err =reset_control_assert (pg->reset); - }else { - err =reset_control_deassert (pg->reset); -if (err <0 ) - goto out; - -reset_control_release (pg->reset); - } - -out: -if (err) { -reset_control_release (pg->reset);reset_control_put (pg->reset); }
@@ -1025,20 +1009,43 @@ static int tegra_powergate_add(struct te goto set_available; } - err =tegra_powergate_of_get_resets (pg, np, off); + err =tegra_powergate_of_get_resets (pg, np);if (err <0 ) {dev_err (dev,"failed to get resets for %pOFn: %d\n" , np, err); goto remove_clks; } -if (!IS_ENABLED (CONFIG_PM_GENERIC_DOMAINS )) { -if (off) -WARN_ON (tegra_powergate_power_up (pg, true)); +/* +* If the power-domain is off, then ensure the resets are asserted. +* If the power-domain is on, then power down to ensure that when is +* it turned on the power-domain, clocks and resets are all in the +* expected state. +*/ +if (off) { + err =reset_control_assert (pg->reset); +if (err) { +pr_err ("failed to assert resets: %d\n" , err); + goto remove_resets; + } + }else { + err =tegra_powergate_power_down (pg); +if (err) { +dev_err (dev,"failed to turn off PM domain %s: %d\n" , + pg->genpd.name, err); + goto remove_resets; + } + } +/* +* If PM_GENERIC_DOMAINS is not enabled, power-on +* the domain and skip the genpd registration. +*/ +if (!IS_ENABLED (CONFIG_PM_GENERIC_DOMAINS )) { +WARN_ON (tegra_powergate_power_up (pg, true)); goto remove_resets; } - err =pm_genpd_init (&pg->genpd,NULL , off); + err =pm_genpd_init (&pg->genpd,NULL , true);if (err <0 ) {dev_err (dev,"failed to initialise PM domain %pOFn: %d\n" , np, err);
Greg Kroah-Hartman
maintainerPATCH 303/403 media: gspca: Add bounds checking to firmware parser
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit aef89c0b2417da79cb2062a95476288f9f203ab0 upstream.
This sd_init() function reads the firmware. The firmware data holds a series of records and the function reads each record and sends the data to the device. The request_ihex_firmware() function
calls ihex_validate_fw() which ensures that the total length of all the records won't read out of bounds of the fw->data[].
However, a potential issue is if there is a single very large record (larger than PAGE_SIZE) and that would result in memory corruption. Generally we trust the firmware, but it's always better to double check.
--- drivers/media/usb/gspca/vicam.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/usb/gspca/vicam.c +8 -2
@@ -227,6 +227,7 @@ static int sd_init(struct gspca_dev *gspconst struct ihex_binrec *rec;const struct firmware *fw;u8 *firmware_buf; +int len; ret =request_ihex_firmware (&fw,VICAM_FIRMWARE , &gspca_dev->dev->dev);
@@ -241,9 +242,14 @@ static int sd_init(struct gspca_dev *gsp goto exit; }for (rec = (void *)fw->data; rec; rec =ihex_next_binrec (rec)) { -memcpy (firmware_buf, rec->data,be16_to_cpu (rec->len)); + len =be16_to_cpu (rec->len); +if (len >PAGE_SIZE ) { + ret = -EINVAL ; +break ; + } +memcpy (firmware_buf, rec->data, len); ret =vicam_control_msg (gspca_dev,0xff ,0 ,0 , firmware_buf, -be16_to_cpu (rec->len)); + len);if (ret <0 )break ; }
Greg Kroah-Hartman
maintainerPATCH 304/403 media: imx: fix a potential memory leak in imx_media_csc_scaler_device_init()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit fc5f8aec77704373ee804b5dba0e0e5029c0f180 upstream.
Add video_device_release() in label 'err_m2m' to release the memory allocated by video_device_alloc() and prevent potential memory leaks. Remove the reduntant code in label 'err_m2m'.
--- drivers/staging/media/imx/imx-media-csc-scaler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/imx/imx-media-csc-scaler.c +1 -1
@@ -911,7 +911,7 @@ imx_media_csc_scaler_device_init(structreturn &priv->vdev; err_m2m: -video_set_drvdata (vfd,NULL ); +video_device_release (vfd); err_vfd:kfree (priv);return ERR_PTR (ret);
Greg Kroah-Hartman
maintainerPATCH 305/403 media: usbtv: Lock resolution while streaming
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ludwig Disterhof <[email protected]>
commit 7e40e0bb778907b2441bff68d73c3eb6b6cd319f upstream.
When an program is streaming (ffplay) and another program (qv4l2) changes the TV standard from NTSC to PAL, the kernel crashes due to trying to copy to unmapped memory.
Changing from NTSC to PAL increases the resolution in the usbtv struct, but the video plane buffer isn't adjusted, so it overflows.
--- drivers/media/usb/usbtv/usbtv-video.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/usb/usbtv/usbtv-video.c +4 -0
@@ -73,6 +73,10 @@ static int usbtv_configure_for_norm(stru }if (params) { +if (vb2_is_busy (&usbtv->vb2q) && + (usbtv->width != params->cap_width || + usbtv->height != params->cap_height)) +return -EBUSY ; usbtv->width = params->cap_width; usbtv->height = params->cap_height; usbtv->n_chunks = usbtv->width * usbtv->height
Greg Kroah-Hartman
maintainerPATCH 306/403 media: ov2659: Fix memory leaks in ov2659_probe()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Shurong <[email protected]>
commit 76142b137b968d47b35cdd8d1dc924677d319c8b upstream.
ov2659_probe() doesn't properly free control handler resources in failure paths, causing memory leaks. Add v4l2_ctrl_handler_free() to prevent these memory leaks and reorder the ctrl_handler assignment for better code flow.
--- drivers/media/i2c/ov2659.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/ov2659.c +2 -1
@@ -1432,14 +1432,15 @@ static int ov2659_probe(struct i2c_clienV4L2_CID_TEST_PATTERN ,ARRAY_SIZE (ov2659_test_pattern_menu) -1 , 0, 0, ov2659_test_pattern_menu); - ov2659->sd.ctrl_handler = &ov2659->ctrls;if (ov2659->ctrls.error) {dev_err (&client->dev,"%s: control initialization error %d\n" , __func__, ov2659->ctrls.error); +v4l2_ctrl_handler_free (&ov2659->ctrls);return ov2659->ctrls.error; } + ov2659->sd.ctrl_handler = &ov2659->ctrls; sd = &ov2659->sd; client->flags |=I2C_CLIENT_SCCB ;#ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
Greg Kroah-Hartman
maintainerPATCH 307/403 media: venus: Add a check for packet size after reading from shared memory
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vedang Nagar <[email protected]>
commit 49befc830daa743e051a65468c05c2ff9e8580e6 upstream.
Add a check to ensure that the packet size does not exceed the number of available words after reading the packet header from shared memory. This ensures that the size provided by the firmware is safe to process and prevent potential out-of-bounds memory access.
--- drivers/media/platform/qcom/venus/hfi_venus.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/platform/qcom/venus/hfi_venus.c +4 -0
@@ -240,6 +240,7 @@ static int venus_write_queue(struct venustatic int venus_read_queue (struct venus_hfi_device *hdev,struct iface_queue *queue,void *pkt,u32 *tx_req) { +struct hfi_pkt_hdr *pkt_hdr =NULL ;struct hfi_queue_header *qhdr;u32 dwords, new_rd_idx;u32 rd_idx, wr_idx, type, qsize;
@@ -305,6 +306,9 @@ static int venus_read_queue(struct venusmemcpy (pkt, rd_ptr, len);memcpy (pkt + len, queue->qmem.kva, new_rd_idx <<2 ); } + pkt_hdr = (struct hfi_pkt_hdr *)(pkt); +if ((pkt_hdr->size >>2 ) != dwords) +return -EINVAL ; }else {/* bad packet received, dropping */ new_rd_idx = qhdr->write_idx;
Greg Kroah-Hartman
maintainerPATCH 308/403 memstick: Fix deadlock by moving removing flag earlier
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayi Li <[email protected]>
commit 99d7ab8db9d8230b243f5ed20ba0229e54cc0dfa upstream.
The existing memstick core patch: commit 62c59a8786e6 ("memstick: Skip allocating card when removing host") sets host->removing in memstick_remove_host(),but still exists a critical time window where memstick_check can run after host->eject is set but before removing is set.
In the rtsx_usb_ms driver, the problematic sequence is:
rtsx_usb_ms_drv_remove: memstick_check:
host->eject = true
cancel_work_sync(handle_req) if(!host->removing)
... memstick_alloc_card()
memstick_set_rw_addr()
memstick_new_req()
rtsx_usb_ms_request()
if(!host->eject)
skip schedule_work
wait_for_completion()
memstick_remove_host: [blocks indefinitely]
host->removing = true
flush_workqueue()
[block]1. rtsx_usb_ms_drv_remove sets host->eject = true
2. cancel_work_sync(&host->handle_req) runs
3. memstick_check work may be executed here <-- danger window
4. memstick_remove_host sets removing = 1
During this window (step 3), memstick_check calls memstick_alloc_card, which may indefinitely waiting for mrq_complete completion that will never occur because rtsx_usb_ms_request sees eject=true and skips scheduling work, memstick_set_rw_addr waits forever for completion.
This causes a deadlock when memstick_remove_host tries to flush_workqueue, waiting for memstick_check to complete, while memstick_check is blocked waiting for mrq_complete completion.
Fix this by setting removing=true at the start of rtsx_usb_ms_drv_remove, before any work cancellation. This ensures memstick_check will see the removing flag immediately and exit early, avoiding the deadlock.
--- drivers/memstick/core/memstick.c | 1 - drivers/memstick/host/rtsx_usb_ms.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/memstick/core/memstick.c +0 -1
@@ -550,7 +550,6 @@ EXPORT_SYMBOL(memstick_add_host);*/ void memstick_remove_host (struct memstick_host *host) { - host->removing =1 ;flush_workqueue (workqueue);mutex_lock (&host->lock);if (host->card)
drivers/memstick/host/rtsx_usb_ms.c +1 -0
@@ -812,6 +812,7 @@ static int rtsx_usb_ms_drv_remove(structint err; host->eject = true; + msh->removing = true;cancel_work_sync (&host->handle_req);cancel_delayed_work_sync (&host->poll_card);
Greg Kroah-Hartman
maintainerPATCH 309/403 squashfs: fix memory leak in squashfs_fill_super
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Phillip Lougher <[email protected]>
commit b64700d41bdc4e9f82f1346c15a3678ebb91a89c upstream.
If sb_min_blocksize returns 0, squashfs_fill_super exits without freeing allocated memory (sb->s_fs_info).
Fix this by moving the call to sb_min_blocksize to before memory is allocated.
--- fs/squashfs/super.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/squashfs/super.c +7 -7
@@ -74,10 +74,15 @@ static int squashfs_fill_super(struct suunsigned short flags;unsigned int fragments;u64 lookup_table_start, xattr_id_table_start, next_table; -int err; +int err, devblksize =sb_min_blocksize (sb,SQUASHFS_DEVBLK_SIZE );TRACE ("Entered squashfs_fill_superblock\n" ); +if (!devblksize) { +errorf (fc,"squashfs: unable to set blocksize\n" ); +return -EINVAL ; + } + sb->s_fs_info =kzalloc (sizeof (*msblk),GFP_KERNEL );if (sb->s_fs_info ==NULL ) {ERROR ("Failed to allocate squashfs_sb_info\n" );
@@ -85,12 +90,7 @@ static int squashfs_fill_super(struct su } msblk = sb->s_fs_info; - msblk->devblksize =sb_min_blocksize (sb,SQUASHFS_DEVBLK_SIZE ); -if (!msblk->devblksize) { -errorf (fc,"squashfs: unable to set blocksize\n" ); -return -EINVAL ; - } - + msblk->devblksize = devblksize; msblk->devblksize_log2 =ffz (~msblk->devblksize);mutex_init (&msblk->meta_index_mutex);
Greg Kroah-Hartman
maintainerPATCH 310/403 drm/amd/display: Fix fractional fb divider in set_pixel_clock_v3
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
commit 10507478468f165ea681605d133991ed05cdff62 upstream.
For later VBIOS versions, the fractional feedback divider is calculated as the remainder of dividing the feedback divider by a factor, which is set to 1000000. For reference, see:
- calculate_fb_and_fractional_fb_divider
- calc_pll_max_vco_construct
However, in case of old VBIOS versions that have set_pixel_clock_v3, they only have 1 byte available for the fractional feedback divider, and it's expected to be set to the remainder from dividing the feedback divider by 10. For reference see the legacy display code:
- amdgpu_pll_compute
- amdgpu_atombios_crtc_program_pll
This commit fixes set_pixel_clock_v3 by dividing the fractional feedback divider passed to the function by 100000.
--- drivers/gpu/drm/amd/display/dc/bios/command_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/bios/command_table.c +1 -1
@@ -992,7 +992,7 @@ static enum bp_result set_pixel_clock_v3 allocation.sPCLKInput.usFbDiv =cpu_to_le16 ((uint16_t )bp_params->feedback_divider); allocation.sPCLKInput.ucFracFbDiv = - (uint8_t )bp_params->fractional_feedback_divider; + (uint8_t )(bp_params->fractional_feedback_divider /100000 ); allocation.sPCLKInput.ucPostDiv = (uint8_t )bp_params->pixel_clock_post_divider;
Greg Kroah-Hartman
maintainerPATCH 311/403 drm/amd/display: Find first CRTC and its line time in dce110_fill_display_configs
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
commit 669f73a26f6112eedbadac53a2f2707ac6d0b9c8 upstream.
dce110_fill_display_configs is shared between DCE 6-11, and finding the first CRTC and its line time is relevant to DCE 6 too. Move the code to find it from DCE 11 specific code.
--- drivers/gpu/drm/amd/display/dc/clk_mgr/dce110/dce110_clk_mgr.c | 30 ++++++---- 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dce110/dce110_clk_mgr.c +20 -10
@@ -120,9 +120,12 @@ void dce110_fill_display_configs(const struct dc_state *context, struct dm_pp_display_configuration *pp_display_cfg) { + struct dc *dc = context->clk_mgr->ctx->dc;int j;int num_cfgs =0 ; + pp_display_cfg->crtc_index = dc->res_pool->res_cap->num_timing_generator; +for (j =0 ; j < context->stream_count; j++) {int k;
@@ -164,6 +167,23 @@ void dce110_fill_display_configs( cfg->v_refresh /= stream->timing.h_total; cfg->v_refresh = (cfg->v_refresh + stream->timing.v_total /2 ) / stream->timing.v_total; + +/* Find first CRTC index and calculate its line time. +* This is necessary for DPM on SI GPUs. +*/ +if (cfg->pipe_idx < pp_display_cfg->crtc_index) { +const struct dc_crtc_timing *timing = + &context->streams[0 ]->timing; + + pp_display_cfg->crtc_index = cfg->pipe_idx; + pp_display_cfg->line_time_in_us = + timing->h_total *10000 / timing->pix_clk_100hz; + } + } + +if (!num_cfgs) { + pp_display_cfg->crtc_index =0 ; + pp_display_cfg->line_time_in_us =0 ; } pp_display_cfg->display_count = num_cfgs;
@@ -231,16 +251,6 @@ void dce11_pplib_apply_display_requiremedce110_fill_display_configs (context, pp_display_cfg); -/* TODO: is this still applicable?*/ -if (pp_display_cfg->display_count ==1 ) { -const struct dc_crtc_timing *timing = - &context->streams[0 ]->timing; - - pp_display_cfg->crtc_index = - pp_display_cfg->disp_configs[0 ].pipe_idx; - pp_display_cfg->line_time_in_us = timing->h_total *10000 / timing->pix_clk_100hz; - } -if (memcmp (&dc->current_state->pp_display_cfg, pp_display_cfg,sizeof (*pp_display_cfg)) !=0 )dm_pp_apply_display_requirements (dc->ctx, pp_display_cfg); }
Greg Kroah-Hartman
maintainerPATCH 312/403 fs/buffer: fix use-after-free when call bh_read() helper
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
[ Upstream commit 7375f22495e7cd1c5b3b5af9dcc4f6dffe34ce49 ]
There's issue as follows:
BUG: KASAN: stack-out-of-bounds in end_buffer_read_sync+0xe3/0x110 Read of size 8 at addr ffffc9000168f7f8 by task swapper/3/0 CPU: 3 UID: 0 PID: 0 Comm: swapper/3 Not tainted 6.16.0-862.14.0.6.x86_64 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) Call Trace: <IRQ> dump_stack_lvl+0x55/0x70 print_address_description.constprop.0+0x2c/0x390 print_report+0xb4/0x270 kasan_report+0xb8/0xf0 end_buffer_read_sync+0xe3/0x110 end_bio_bh_io_sync+0x56/0x80 blk_update_request+0x30a/0x720 scsi_end_request+0x51/0x2b0 scsi_io_completion+0xe3/0x480 ? scsi_device_unbusy+0x11e/0x160 blk_complete_reqs+0x7b/0x90 handle_softirqs+0xef/0x370 irq_exit_rcu+0xa5/0xd0 sysvec_apic_timer_interrupt+0x6e/0x90 </IRQ>
Above issue happens when do ntfs3 filesystem mount, issue may happens as follows:
mount IRQntfs_fill_super
read_cache_page
do_read_cache_folio
filemap_read_folio
mpage_read_folio
do_mpage_readpage
ntfs_get_block_vbo
bh_read
submit_bh
wait_on_buffer(bh);
blk_complete_reqs
scsi_io_completion
scsi_end_request
blk_update_request
end_bio_bh_io_sync
end_buffer_read_sync
__end_buffer_read_notouch
unlock_buffer
wait_on_buffer(bh);--> return will return to caller
put_bh
--> trigger stack-out-of-boundsIn the mpage_read_folio() function, the stack variable 'map_bh' is passed to ntfs_get_block_vbo(). Once unlock_buffer() unlocks and wait_on_buffer() returns to continue processing, the stack variable is likely to be reclaimed. Consequently, during the end_buffer_read_sync() process, calling put_bh() may result in stack overrun.
If the bh is not allocated on the stack, it belongs to a folio. Freeing a buffer head which belongs to a folio is done by drop_buffers() which will fail to free buffers which are still locked. So it is safe to call put_bh() before __end_buffer_read_notouch().
--- fs/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/buffer.c +1 -1
@@ -161,8 +161,8 @@ static void __end_buffer_read_notouch(struct buffer_head *bh, int uptodate)*/ void end_buffer_read_sync (struct buffer_head *bh,int uptodate) { -__end_buffer_read_notouch (bh, uptodate);put_bh (bh); +__end_buffer_read_notouch (bh, uptodate); }EXPORT_SYMBOL (end_buffer_read_sync);
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 313/403 move_mount: allow to add a mount into an existing group
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Tikhomirov <[email protected]>
[ Upstream commit 9ffb14ef61bab83fa818736bf3e7e6b6e182e8e2 ]
Previously a sharing group (shared and master ids pair) can be only inherited when mount is created via bindmount. This patch adds an ability to add an existing private mount into an existing sharing group.
With this functionality one can first create the desired mount tree from only private mounts (without the need to care about undesired mount propagation or mount creation order implied by sharing group dependencies), and next then setup any desired mount sharing between those mounts in tree as needed.
This allows CRIU to restore any set of mount namespaces, mount trees and sharing group trees for a container.
We have many issues with restoring mounts in CRIU related to sharing groups and propagation:
- reverse sharing groups vs mount tree order requires complex mounts reordering which mostly implies also using some temporary mounts
(please see https://lkml.org/lkml/2021/3/23/569 for more info)
- mount() syscall creates tons of mounts due to propagation
- mount re-parenting due to propagation
- "Mount Trap" due to propagation
- "Non Uniform" propagation, meaning that with different tricks with mount order and temporary children-"lock" mounts one can create mount trees which can't be restored without those tricks
(see https://www.linuxplumbersconf.org/event/7/contributions/640/)
With this new functionality we can resolve all the problems with propagation at once.
Stable-dep-of: cffd0441872e ("use uniform permission checks for all mount propagation changes")
--- fs/namespace.c | 77 +++++++++++++++++++++++++++++++++++++- include/uapi/linux/mount.h | 3 +- 2 files changed, 78 insertions(+), 2 deletions(-)
fs/namespace.c +76 -1
@@ -2624,6 +2624,78 @@ static bool check_for_nsfs_mounts(struct mount *subtree)return ret; } +static int do_set_group (struct path *from_path,struct path *to_path) +{ +struct mount *from, *to; +int err; + + from =real_mount (from_path->mnt); + to =real_mount (to_path->mnt); + +namespace_lock (); + + err = -EINVAL ; +/* To and From must be mounted */ +if (!is_mounted (&from->mnt)) + goto out; +if (!is_mounted (&to->mnt)) + goto out; + + err = -EPERM ; +/* We should be allowed to modify mount namespaces of both mounts */ +if (!ns_capable (from->mnt_ns->user_ns,CAP_SYS_ADMIN )) + goto out; +if (!ns_capable (to->mnt_ns->user_ns,CAP_SYS_ADMIN )) + goto out; + + err = -EINVAL ; +/* To and From paths should be mount roots */ +if (from_path->dentry != from_path->mnt->mnt_root) + goto out; +if (to_path->dentry != to_path->mnt->mnt_root) + goto out; + +/* Setting sharing groups is only allowed across same superblock */ +if (from->mnt.mnt_sb != to->mnt.mnt_sb) + goto out; + +/* From mount root should be wider than To mount root */ +if (!is_subdir (to->mnt.mnt_root, from->mnt.mnt_root)) + goto out; + +/* From mount should not have locked children in place of To's root */ +if (has_locked_children (from, to->mnt.mnt_root)) + goto out; + +/* Setting sharing groups is only allowed on private mounts */ +if (IS_MNT_SHARED (to) ||IS_MNT_SLAVE (to)) + goto out; + +/* From should not be private */ +if (!IS_MNT_SHARED (from) && !IS_MNT_SLAVE (from)) + goto out; + +if (IS_MNT_SLAVE (from)) { +struct mount *m = from->mnt_master; + +list_add (&to->mnt_slave, &m->mnt_slave_list); + to->mnt_master = m; + } + +if (IS_MNT_SHARED (from)) { + to->mnt_group_id = from->mnt_group_id; +list_add (&to->mnt_share, &from->mnt_share); +lock_mount_hash (); +set_mnt_shared (to); +unlock_mount_hash (); + } + + err =0 ; +out: +namespace_unlock (); +return err; +} +static int do_move_mount (struct path *old_path,struct path *new_path) {struct mnt_namespace *ns;
@@ -3583,7 +3655,10 @@ SYSCALL_DEFINE5(move_mount,if (ret <0 ) goto out_to; - ret =do_move_mount (&from_path, &to_path); +if (flags &MOVE_MOUNT_SET_GROUP ) + ret =do_set_group (&from_path, &to_path); +else + ret =do_move_mount (&from_path, &to_path); out_to:path_put (&to_path);
include/uapi/linux/mount.h +2 -1
@@ -70,7 +70,8 @@#define MOVE_MOUNT_T_SYMLINKS 0x00000010/* Follow symlinks on to path */ #define MOVE_MOUNT_T_AUTOMOUNTS 0x00000020/* Follow automounts on to path */ #define MOVE_MOUNT_T_EMPTY_PATH 0x00000040/* Empty to path permitted */ -#define MOVE_MOUNT__MASK 0x00000077 +#define MOVE_MOUNT_SET_GROUP 0x00000100/* Set sharing group instead */ +#define MOVE_MOUNT__MASK 0x00000177/* * fsopen() flags.
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 314/403 use uniform permission checks for all mount propagation changes
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit cffd0441872e7f6b1fce5e78fb1c99187a291330 ]
do_change_type() and do_set_group() are operating on different aspects of the same thing - propagation graph. The latter asks for mounts involved to be mounted in namespace(s) the caller has CAP_SYS_ADMIN for. The former is a mess - originally it didn't even check that mount *is* mounted. That got fixed, but the resulting check turns out to be too strict for userland - in effect, we check that mount is in our namespace, having already checked that we have CAP_SYS_ADMIN there.
What we really need (in both cases) is
* only touch mounts that are mounted. That's a must-have
constraint - data corruption happens if it get violated.
* don't allow to mess with a namespace unless you already
have enough permissions to do so (i.e. CAP_SYS_ADMIN in its userns).
That's an equivalent of what do_set_group() does; let's extract that into a helper (may_change_propagation()) and use it in both do_set_group() and do_change_type().
--- fs/namespace.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-)
fs/namespace.c +20 -14
@@ -2210,6 +2210,19 @@ static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp)return attach_recursive_mnt (mnt, p, mp, false); } +static int may_change_propagation (const struct mount *m) +{ +struct mnt_namespace *ns = m->mnt_ns; + +// it must be mounted in some namespace +if (IS_ERR_OR_NULL (ns))// is_mounted() +return -EINVAL ; +// and the caller must be admin in userns of that namespace +if (!ns_capable (ns->user_ns,CAP_SYS_ADMIN )) +return -EPERM ; +return 0 ; +} +/* * Sanity check the flags to change_mnt_propagation. */
@@ -2246,10 +2259,10 @@ static int do_change_type(struct path *path, int ms_flags)return -EINVAL ;namespace_lock (); -if (!check_mnt (mnt)) { - err = -EINVAL ; + err =may_change_propagation (mnt); +if (err) goto out_unlock; - } +if (type ==MS_SHARED ) { err =invent_group_ids (mnt, recurse);if (err)
@@ -2634,18 +2647,11 @@ static int do_set_group(struct path *from_path, struct path *to_path)namespace_lock (); - err = -EINVAL ; -/* To and From must be mounted */ -if (!is_mounted (&from->mnt)) - goto out; -if (!is_mounted (&to->mnt)) - goto out; - - err = -EPERM ; -/* We should be allowed to modify mount namespaces of both mounts */ -if (!ns_capable (from->mnt_ns->user_ns,CAP_SYS_ADMIN )) + err =may_change_propagation (from); +if (err) goto out; -if (!ns_capable (to->mnt_ns->user_ns,CAP_SYS_ADMIN )) + err =may_change_propagation (to); +if (err) goto out; err = -EINVAL ;
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerPATCH 315/403 fpga: zynq_fpga: Fix the wrong usage of dma_map_sgtable()
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Yilun <[email protected]>
commit 1ca61060de92a4320d73adfe5dc8d335653907ac upstream.
dma_map_sgtable() returns only 0 or the error code. Read sgt->nents to get the number of mapped segments.
--- drivers/fpga/zynq-fpga.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/fpga/zynq-fpga.c +4 -4
@@ -405,12 +405,12 @@ static int zynq_fpga_ops_write(struct fp } } - priv->dma_nelms = -dma_map_sgtable (mgr->dev.parent, sgt,DMA_TO_DEVICE ,0 ); -if (priv->dma_nelms ==0 ) { + err =dma_map_sgtable (mgr->dev.parent, sgt,DMA_TO_DEVICE ,0 ); +if (err) {dev_err (&mgr->dev,"Unable to DMA map (TO_DEVICE)\n" ); -return -ENOMEM ; +return err; } + priv->dma_nelms = sgt->nents;/* enable clock */ err =clk_enable (priv->clk);
Greg Kroah-Hartman
maintainerPATCH 316/403 ftrace: Also allocate and copy hash for reading of filter files
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit bfb336cf97df7b37b2b2edec0f69773e06d11955 upstream.
Currently the reader of set_ftrace_filter and set_ftrace_notrace just adds the pointer to the global tracer hash to its iterator. Unlike the writer that allocates a copy of the hash, the reader keeps the pointer to the filter hashes. This is problematic because this pointer is static across function calls that release the locks that can update the global tracer hashes. This can cause UAF and similar bugs.
Allocate and copy the hash for reading the filter files like it is done for the writers. This not only fixes UAF bugs, but also makes the code a bit simpler as it doesn't have to differentiate when to free the iterator's hash between writers and readers.
--- kernel/trace/ftrace.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
kernel/trace/ftrace.c +10 -9
@@ -3650,13 +3650,17 @@ ftrace_regex_open(struct ftrace_ops *ops }else { iter->hash =alloc_and_copy_ftrace_hash (size_bits, hash); } + }else { +if (hash) + iter->hash =alloc_and_copy_ftrace_hash (hash->size_bits, hash); +else + iter->hash =EMPTY_HASH ; + } -if (!iter->hash) { -trace_parser_put (&iter->parser); - goto out_unlock; - } - }else - iter->hash = hash; +if (!iter->hash) { +trace_parser_put (&iter->parser); + goto out_unlock; + } ret =0 ;
@@ -5117,9 +5121,6 @@ int ftrace_regex_release(struct inode *i ret =ftrace_hash_move_and_update_ops (iter->ops, orig_hash, iter->hash, filter_hash);mutex_unlock (&ftrace_lock); - }else { -/* For read only, the hash is the ops hash */ - iter->hash =NULL ; }mutex_unlock (&iter->ops->func_hash->regex_lock);
Greg Kroah-Hartman
maintainerPATCH 317/403 iio: proximity: isl29501: fix buffered read on big-endian systems
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lechner <[email protected]>
commit de18e978d0cda23e4c102e18092b63a5b0b3a800 upstream.
Fix passing a u32 value as a u16 buffer scan item. This works on little- endian systems, but not on big-endian systems.
A new local variable is introduced for getting the register value and the array is changed to a struct to make the data layout more explicit rather than just changing the type and having to recalculate the proper length needed for the timestamp.
--- drivers/iio/proximity/isl29501.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/iio/proximity/isl29501.c +10 -4
@@ -938,12 +938,18 @@ static irqreturn_t isl29501_trigger_handstruct iio_dev *indio_dev = pf->indio_dev;struct isl29501_private *isl29501 =iio_priv (indio_dev);const unsigned long *active_mask = indio_dev->active_scan_mask; -u32 buffer[4 ]__aligned(8) = {};/* 1x16-bit + naturally aligned ts */ +u32 value; +struct { +u16 data; +aligned_s64 ts; + } scan = { }; -if (test_bit (ISL29501_DISTANCE_SCAN_INDEX , active_mask)) -isl29501_register_read (isl29501,REG_DISTANCE , buffer); +if (test_bit (ISL29501_DISTANCE_SCAN_INDEX , active_mask)) { +isl29501_register_read (isl29501,REG_DISTANCE , &value); + scan.data = value; + } -iio_push_to_buffers_with_timestamp (indio_dev, buffer, pf->timestamp); +iio_push_to_buffers_with_timestamp (indio_dev, &scan, pf->timestamp);iio_trigger_notify_done (indio_dev->trig);return IRQ_HANDLED ;
Greg Kroah-Hartman
maintainerPATCH 318/403 usb: quirks: Add DELAY_INIT quick for another SanDisk 3.2Gen1 Flash Drive
In reply to Greg Kroah-Hartman5.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miao Li <[email protected]>
commit e664036cf36480414936cd91f4cfa2179a3d8367 upstream.
Another SanDisk 3.2Gen1 Flash Drive also need DELAY_INIT quick, or it will randomly work incorrectly on Huawei hisi platforms when doing reboot test.
--- drivers/usb/core/quirks.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/core/quirks.c +1 -0
@@ -368,6 +368,7 @@ static const struct usb_device_id usb_qu { USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM }, /* SanDisk Corp. SanDisk 3.2Gen1 */ + { USB_DEVICE(0x0781, 0x5596), .driver_info = USB_QUIRK_DELAY_INIT }, { USB_DEVICE(0x0781, 0x55a3), .driver_info = USB_QUIRK_DELAY_INIT },/* SanDisk Extreme 55AE */