6.1.193-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 224/2857 perf/x86: Free hybrid state on PMU init failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dapeng Mi <[email protected]>
[ Upstream commit 96746e731e1626545e343974ca4673739dceb31b ]
If PMU initialization fails, for example in check_hw_exists(), hybrid state can be left partially initialized: x86_pmu.hybrid_pmu is not freed and perf_is_hybrid remains set. This can leak memory and leave stale hybrid state reachable after a failed init path.
Add x86_pmu_free_hybrid() and use it on PMU init failure paths so all hybrid-related state is consistently reset.
--- arch/x86/events/core.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/x86/events/core.c +12 -3
@@ -2072,6 +2072,17 @@ void x86_pmu_update_cpu_context(struct pmu *pmu, int cpu) cpuctx->ctx.pmu = pmu; } +static void x86_pmu_free_hybrid (void ) +{ +if (!x86_pmu.hybrid_pmu) +return ; + +static_branch_disable (&perf_is_hybrid); +kfree (x86_pmu.hybrid_pmu); + x86_pmu.hybrid_pmu =NULL ; + x86_pmu.num_hybrid_pmus =0 ; +} +static int __init init_hw_perf_events (void ) {struct x86_pmu_quirk *quirk;
@@ -2207,9 +2218,6 @@ static int __init init_hw_perf_events(void)for (j =0 ; j < i; j++)perf_pmu_unregister (&x86_pmu.hybrid_pmu[j].pmu);pr_warn ("Failed to register hybrid PMUs\n" ); -kfree (x86_pmu.hybrid_pmu); - x86_pmu.hybrid_pmu =NULL ; - x86_pmu.num_hybrid_pmus =0 ; goto out2; } }
@@ -2225,6 +2233,7 @@ static int __init init_hw_perf_events(void) pmi_unregister:unregister_nmi_handler (NMI_LOCAL ,"PMI" ); out_bad_pmu: +x86_pmu_free_hybrid ();memset (&x86_pmu,0 ,sizeof (x86_pmu));return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 225/2857 nvmet: passthru: fix OOB reads when parsing ns id descriptor list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hari Mishal <[email protected]>
[ Upstream commit bc7f75eba50012ed447654d8ce169ebaba695193 ]
nvmet_passthru_override_id_descs() walks a namespace identification descriptor list populated from the underlying passthru controller's Identify response, which is device reported. The loop advanced pos by device controlled amounts (sizeof(*cur) + nidl) without checking that the next descriptor header actually fits inside the buffer, so a malicious device could push pos to within a few bytes of the buffer end and cause cur->nidl, cur->nidt or the reserved field to be read past the allocation.
Additionally, when a CSI descriptor lands exactly at the last valid header offset, cur + 1 points one byte past the end of the buffer. The unconditional memcpy(&csi, cur + 1, NVME_NIDT_CSI_LEN) could read that out-of-bounds byte and copy it back to the initiator via nvmet_copy_to_sgl(), leaking adjacent heap memory.
Bounds check both the descriptor header and the CSI value before dereferencing them.
--- drivers/nvme/target/passthru.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/nvme/target/passthru.c +9 -0
@@ -53,13 +53,22 @@ static u16 nvmet_passthru_override_id_descs(struct nvmet_req *req)for (pos =0 ; pos <NVME_IDENTIFY_DATA_SIZE ; pos += len) {struct nvme_ns_id_desc *cur = data + pos; +if (pos +sizeof (*cur) >NVME_IDENTIFY_DATA_SIZE ) +break ; +if (cur->nidl ==0 )break ; +if (cur->nidt ==NVME_NIDT_CSI ) { +if (pos +sizeof (*cur) +NVME_NIDT_CSI_LEN > +NVME_IDENTIFY_DATA_SIZE ) +break ; +memcpy (&csi, cur +1 ,NVME_NIDT_CSI_LEN ); csi_seen = true;break ; } + len =sizeof (struct nvme_ns_id_desc ) + cur->nidl; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 226/2857 selftests/net: fin_ack_lat: fix latency threshold typo
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Grech <[email protected]>
[ Upstream commit 2373107782a98ba15931a37bbd9dd46d7213e5aa ]
The commit message for af8c8a450bf4 ("selftests: net: Add FIN_ACK processing order related latency spike test") states: "if the latency is larger than 1 second (spike), print a message". However the code uses a threshold of 100000 us (100 ms), not 1000000 us (1 s).
The lower threshold causes false positives on slower hardware where normal connection latency occasionally exceeds 100 ms but never approaches the 1 s spike that indicates the actual FIN/ACK race bug.
Fix the threshold to match the documented intent.
--- tools/testing/selftests/net/fin_ack_lat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/fin_ack_lat.c +1 -1
@@ -69,7 +69,7 @@ static void client(int port) lat =timediff (start, end); sum_lat += lat; nr_lat++; -if (lat <100000 ) +if (lat <1000000 ) goto close;if (getsockname (sock, (struct sockaddr *)&laddr, &len) ==-1 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 227/2857 docs: cgroup-v2: fix stale "io" controller introduction
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhe Liu <[email protected]>
[ Upstream commit 3345c7248a9e2a91cb9e2477c29af16881706f4f ]
The introductory paragraph for the IO controller still states that weight based distribution is "available only if cfq-iosched is in use" and that "neither scheme is available for blk-mq devices". This text dates from when the cgroup v2 documentation was first written (2015) and was correct at the time, but is no longer accurate:
* cfq-iosched was removed in v5.0;
* blk-mq is now the only block I/O path, and both the absolute limit scheme (io.max via blk-throttle) and the weight based scheme (io.weight via iocost, or io.bfq.weight under BFQ) work on it;
* latency based protection (iolatency) and I/O priority (ioprio) controllers have since been added.
The rest of the section already documents io.weight, io.max, io.cost.{qos,model}, io.latency and io.prio.class correctly, so the introduction is the only part that contradicts them. Rewrite it to reflect the current state.
--- Documentation/admin-guide/cgroup-v2.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +7 -3
@@ -1675,9 +1675,13 @@ IO The "io" controller regulates the distribution of IO resources. This controller implements both weight based and absolute bandwidth or IOPS -limit distribution; however, weight based distribution is available -only if cfq-iosched is in use and neither scheme is available for -blk-mq devices. +limit distribution. Absolute BPS and IOPS limits are enforced by +blk-throttle and apply to all devices, while weight based proportional +distribution is provided by the iocost cost model controller +(CONFIG_BLK_CGROUP_IOCOST) and, when the BFQ I/O scheduler is in use +for a device, by BFQ's own cgroup support. Latency-based protection +(CONFIG_BLK_CGROUP_IOLATENCY) and I/O priority assignment +(CONFIG_BLK_CGROUP_IOPRIO) are also available. IO Interface Files
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 228/2857 nvme-tcp: look up host_iface in the current netns
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
[ Upstream commit 58202950e39c127d593ec4f0624d8b8985a285b1 ]
nvme_tcp_alloc_ctrl() looks opts->host_iface up in &init_net, the boot-time netns. When called from any other netns - e.g. the selftest's ns2, where ns2eth1 actually lives - the lookup misses and the controller setup fails with "invalid interface passed":
nvmet: adding nsid 1 to subsystem nqn.2014-08.org.nvmexpress.mptcpdev
nvmet_tcp: enabling port 24660 (0.0.0.0:24099)
# nvme discover -a 10.1.1.1 --tos=0x10 --host-iface=ns2eth1 nvme_tcp: invalid interface passed: ns2eth1 # failed to add controller, error invalid interface
Look the device up in current->nsproxy->net_ns instead so the check sees the calling task's netns.
--- drivers/nvme/host/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/tcp.c +2 -1
@@ -2765,7 +2765,8 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, }if (opts->mask &NVMF_OPT_HOST_IFACE ) { -if (!__dev_get_by_name (&init_net, opts->host_iface)) { +if (!__dev_get_by_name (current->nsproxy->net_ns, + opts->host_iface)) {pr_err ("invalid interface passed: %s\n" , opts->host_iface); ret = -ENODEV ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 229/2857 selftests: net: reuseport_bpf_numa: consider cpuless numa node
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Tang <[email protected]>
[ Upstream commit 88b8d85e889e2fe1cce3e66e50c3029dda94842a ]
reuseport_bpf_numa case failed when testing on a platform with CXL memory:
#./reuseport_bpf_numa
---- IPv4 UDP ----
send node 0, receive socket 0
./reuseport_bpf_numa: failed to pin to node: Invalid argument
The root cause is that the platform has 2 numa nodes: node 0 has both cpu and memory, while node 1 is a CXL node which only has memory, and caused numa_run_on_node() to fail.
Add sanity check to skip cpuless numa node for the numa binding test.
--- .../selftests/net/reuseport_bpf_numa.c | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)
tools/testing/selftests/net/reuseport_bpf_numa.c +24 -0
@@ -104,6 +104,26 @@ static void attach_bpf(int fd)close (bpf_fd); } +/* +* Return true if it is a cpuless node. Return false if it isn't or any +* error (very unlikely) happens during the libnuma calls. +*/ +static bool is_cpuless_node (int node_id) +{ +struct bitmask *cpumask; +bool ret = false; + + cpumask =numa_allocate_cpumask (); +if (!cpumask) +return ret; + +if (!numa_node_to_cpus (node_id, cpumask) && !numa_bitmask_weight (cpumask)) + ret = true; + +numa_bitmask_free (cpumask); +return ret; +} +static void send_from_node (int node_id,int family,int proto) {struct sockaddr_storage saddr, daddr;
@@ -213,6 +233,8 @@ static void test(int *rcv_fd, int len, int family, int proto)for (node =0 ; node < len; ++node) {if (!numa_bitmask_isbitset (numa_nodes_ptr, node))continue ; +if (is_cpuless_node (node)) +continue ;send_from_node (node, family, proto);receive_on_node (rcv_fd, len, epfd, node, proto); }
@@ -221,6 +243,8 @@ static void test(int *rcv_fd, int len, int family, int proto)for (node = len -1 ; node >=0 ; --node) {if (!numa_bitmask_isbitset (numa_nodes_ptr, node))continue ; +if (is_cpuless_node (node)) +continue ;send_from_node (node, family, proto);receive_on_node (rcv_fd, len, epfd, node, proto); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 230/2857 nfc: mrvl: spi: Unregister dev on allocation fail
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Griffin Kroah-Hartman <[email protected]>
[ Upstream commit d832b95697384a2b67f20b35106bbf925358cde9 ]
Call nfcmrvl_nci_unregister_dev() if nci_spi_allocate_spi() fails, unwrapping the previous call to nfcmrvl_nci_register_dev() during the nfcmrvl_spi_probe() function.
--- drivers/nfc/nfcmrvl/spi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nfc/nfcmrvl/spi.c +4 -0
@@ -168,6 +168,10 @@ static int nfcmrvl_spi_probe(struct spi_device *spi) drv_data->nci_spi =nci_spi_allocate_spi (drv_data->spi,0 ,10 , drv_data->priv->ndev); +if (!drv_data->nci_spi) { +nfcmrvl_nci_unregister_dev (drv_data->priv); +return -ENOMEM ; + }/* Init completion for slave handshake */ init_completion (&drv_data->handshake_completion);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 231/2857 nfc: nxp-nci: Add remove on IRQ error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Griffin Kroah-Hartman <[email protected]>
[ Upstream commit 56345cea6a30dc7a1b036d5fb7900434b4a4c5e8 ]
Add a call to nxp_nci_remove() in nxp_nci_i2c_probe() when the request_threaded_irq() fails.
Previously, IRQ resources were not being freed upon error.
--- drivers/nfc/nxp-nci/i2c.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nfc/nxp-nci/i2c.c +3 -1
@@ -327,8 +327,10 @@ static int nxp_nci_i2c_probe(struct i2c_client *client, nxp_nci_i2c_irq_thread_fn, irqflags |IRQF_ONESHOT , NXP_NCI_I2C_DRIVER_NAME, phy); -if (r <0 ) +if (r <0 ) {nfc_err (&client->dev,"Unable to register IRQ handler\n" ); +nxp_nci_remove (phy->ndev); + }return r; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 232/2857 nvme: ratelimit the completion-path messages driven by device data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Shi <[email protected]>
[ Upstream commit c05c86681170e381e24498257db3a879deb1ae89 ]
nvme_find_rq() and nvme_handle_cqe() print an unratelimited message for every completion queue entry whose command id does not resolve to an in-flight request. Both are reached from the completion interrupt path (nvme_irq() -> nvme_poll_cq() -> nvme_handle_cqe()) and the decision to print is made entirely from device-supplied data, so a controller that posts a stream of bogus command ids drives unbounded printk from hard interrupt context.
This is not hypothetical. A single boot under an emulated controller that posts invalid completions produced 846 "could not locate request for tag 0x0", 846 "invalid id 0 completed on queue 2" and 123 "genctr mismatch" lines. Once the tag set has been torn down every subsequent completion resolves to nothing, so the print rate is bounded only by how fast the device can post entries.
Ratelimit the three messages. The information they carry is diagnostic and repeats, so the suppression count printed by the ratelimit helpers is enough to tell that the condition persists. This matches how the other device-driven error prints in the driver are already handled, for example the status messages in nvme_log_error() and nvme_log_err_passthru().
nvme_find_rq() lives in nvme.h and is shared by pci, tcp, rdma, apple and target-loop, so all transports are covered.
Found by FuzzNvme.
--- drivers/nvme/host/nvme.h | 6 +++--- drivers/nvme/host/pci.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/nvme/host/nvme.h +3 -3
@@ -570,12 +570,12 @@ static inline struct request *nvme_find_rq(struct blk_mq_tags *tags, rq =blk_mq_tag_to_rq (tags, tag);if (unlikely (!rq)) { -pr_err ("could not locate request for tag %#x\n" , - tag); +pr_err_ratelimited ("could not locate request for tag %#x\n" , + tag);return NULL ; }if (unlikely (nvme_genctr_mask (nvme_req (rq)->genctr) != genctr)) { -dev_err (nvme_req (rq)->ctrl->device, +dev_err_ratelimited (nvme_req (rq)->ctrl->device,"request %#x genctr mismatch (got %#x expected %#x)\n" , tag, genctr,nvme_genctr_mask (nvme_req (rq)->genctr));return NULL ;
drivers/nvme/host/pci.c +3 -3
@@ -1075,9 +1075,9 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, req =nvme_find_rq (nvme_queue_tagset (nvmeq), command_id);if (unlikely (!req)) { -dev_warn (nvmeq->dev->ctrl.device, -"invalid id %d completed on queue %d\n" , - command_id,le16_to_cpu (cqe->sq_id)); +dev_warn_ratelimited (nvmeq->dev->ctrl.device, +"invalid id %d completed on queue %d\n" , + command_id,le16_to_cpu (cqe->sq_id));return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 233/2857 alpha: run the remote RTC access in a worker, not an IPI callback
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Turner <[email protected]>
[ Upstream commit 6f45effbd74012f1715584ba51abaa3196a47c08 ]
On Marvel the CMOS clock is only reachable from the boot cpu, so remote_read_time() and remote_set_time() bounce the access there with smp_call_function_single(), whose callback runs in hard interrupt context.
alpha_rtc_read_time() calls mc146818_get_time() with a 10 ms timeout. That waits out the RTC update cycle in mc146818_avoid_UIP(), which drops rtc_lock and udelay()s 100 us at a time until the update completes or the timeout expires:
for (i = 0; UIP_RECHECK_LOOPS_MS(i) < timeout; i++) {
spin_lock_irqsave(&rtc_lock, flags);
...
if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) {
spin_unlock_irqrestore(&rtc_lock, flags);
udelay(UIP_RECHECK_DELAY);
continue;
}So a clock read from a non-boot cpu can spin for up to 10 ms in hard interrupt context on the boot cpu, while the cpu that sent the request spins in smp_call_function_single() waiting for it to finish.
mc146818_set_time() does not poll, but it takes rtc_lock too, and rtc_lock is a spinlock_t. Only raw spinlocks may be taken in hard interrupt context, so lockdep reports the write path as soon as a non-boot cpu sets the clock:
[ BUG: Invalid wait context ]
-----------------------------
swapper/0/0 is trying to lock:
fffffc0003690470 (rtc_lock){....}-{3:3}, at: mc146818_set_time+0x74/0x450 other info that might help us debug this:
context-{2:2}
no locks held by swapper/0/0.
stack backtrace: CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 7.2.0-rc1 #1 NONE Trace: [<fffffc000102ebb0>] dump_stack+0x28/0x44 [<fffffc000110efcc>] __lock_acquire+0xb0c/0x1060 [<fffffc000110f5f0>] lock_acquire.part.0+0xd0/0x300 [...] [<fffffc0001b0d834>] mc146818_set_time+0x74/0x450 [<fffffc0001f090cc>] _raw_spin_lock_irqsave+0x7c/0xc0 [<fffffc0001042f90>] do_remote_set+0x90/0xc0 [<fffffc000119c1a4>] __flush_smp_call_function_queue+0x314/0x5c0 [<fffffc000119c474>] generic_smp_call_function_single_interrupt+0x24/0x40 [<fffffc000103d984>] handle_ipi+0xa4/0x230 [<fffffc0001037044>] do_entInt+0x1a4/0x2e0
The rtc class ops are always called from process context, so there is no reason to run the access from an interrupt at all. Use work_on_cpu() to run it in a worker on the boot cpu. Alpha does not support cpu hotplug, so the boot cpu cannot go offline while the work is pending.
Tested on an AlphaServer ES47 (Marvel/EV7): hwclock read and write pinned to a non-boot cpu, twenty times, with no splat.
--- arch/alpha/kernel/rtc.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-)
arch/alpha/kernel/rtc.c +12 -25
@@ -15,6 +15,7 @@#include <linux/bcd.h> #include <linux/rtc.h> #include <linux/platform_device.h> +#include <linux/workqueue.h> #include "proto.h"
@@ -142,54 +143,40 @@ static const struct rtc_class_ops alpha_rtc_ops = { };/* -* Similarly, except do the actual CMOS access on the boot cpu only. -* This requires marshalling the data across an interprocessor call. +* Similarly, except do the actual CMOS access on the boot cpu only. The +* access polls for the RTC update cycle and takes rtc_lock, so run it in a +* worker on that cpu rather than from an interprocessor interrupt. */ #if defined(CONFIG_SMP ) && \ (defined(CONFIG_ALPHA_GENERIC ) || defined(CONFIG_ALPHA_MARVEL ))# define HAVE_REMOTE_RTC 1 -union remote_data { -struct rtc_time *tm; -long retval; -}; - -static void +static long do_remote_read (void *data) { -union remote_data *x = data; - x->retval =alpha_rtc_read_time (NULL , x->tm); +return alpha_rtc_read_time (NULL , data); }static int remote_read_time (struct device *dev,struct rtc_time *tm) { -union remote_data x; -if (smp_processor_id () != boot_cpuid) { - x.tm = tm; -smp_call_function_single (boot_cpuid, do_remote_read, &x,1 ); -return x.retval; - } +if (smp_processor_id () != boot_cpuid) +return work_on_cpu (boot_cpuid, do_remote_read, tm);return alpha_rtc_read_time (NULL , tm); } -static void +static long do_remote_set (void *data) { -union remote_data *x = data; - x->retval =alpha_rtc_set_time (NULL , x->tm); +return alpha_rtc_set_time (NULL , data); }static int remote_set_time (struct device *dev,struct rtc_time *tm) { -union remote_data x; -if (smp_processor_id () != boot_cpuid) { - x.tm = tm; -smp_call_function_single (boot_cpuid, do_remote_set, &x,1 ); -return x.retval; - } +if (smp_processor_id () != boot_cpuid) +return work_on_cpu (boot_cpuid, do_remote_set, tm);return alpha_rtc_set_time (NULL , tm); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 234/2857 ALSA: hda/conexant: Add mute LED quirk for HP ProBook 440 G5
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmytro Moroziuk <[email protected]>
[ Upstream commit 191fe151eb85ff6cb24189fc88c970745497c057 ]
The HP ProBook 440 G5 requires the CXT_FIXUP_MUTE_LED_GPIO quirk to properly toggle the physical mute and mic-mute LEDs via the CX8200 codec. Without this quirk, the LEDs remain permanently dark.
--- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_conexant.c +1 -0
@@ -1125,6 +1125,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {SND_PCI_QUIRK (0x103c ,0x829a ,"HP 800 G3 DM" ,CXT_FIXUP_HP_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x103c ,0x82b4 ,"HP ProDesk 600 G3" ,CXT_FIXUP_HP_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x103c ,0x836e ,"HP ProBook 455 G5" ,CXT_FIXUP_MUTE_LED_GPIO ), +SND_PCI_QUIRK (0x103c ,0x837b ,"HP ProBook 440 G5" ,CXT_FIXUP_MUTE_LED_GPIO ),SND_PCI_QUIRK (0x103c ,0x837f ,"HP ProBook 470 G5" ,CXT_FIXUP_MUTE_LED_GPIO ),SND_PCI_QUIRK (0x103c ,0x83b2 ,"HP EliteBook 840 G5" ,CXT_FIXUP_HP_DOCK ), SND_PCI_QUIRK(0x103c, 0x83b3, "HP EliteBook 830 G5", CXT_FIXUP_HP_DOCK),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 235/2857 hfsplus: validate extent record length before writing it back
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Zhang <[email protected]>
[ Upstream commit 627b7865c062ff642c0000f3a4775f1a44b986a4 ]
__hfsplus_ext_write_extent() writes the cached extent record back into a B-tree node using fd->entrylength as the length, and fd->entrylength is derived in __hfs_brec_find() from two on-disk values:
fd->entrylength = len - keylen;
A crafted image can keep both len and keylen valid but make fd->entrylength negative (keylen > len). __hfsplus_ext_write_extent() doesn't check fd->entrylength before consuming it, and hfs_bnode_write() takes the length as u32, so the negative value turns into a huge one. The copy then reads data past the end of hip->cached_extents, which is only sizeof(hfsplus_extent_rec) bytes long, and leaks kernel memory into the image.
Reject an fd->entrylength that does not match sizeof(hfsplus_extent_rec) in __hfsplus_ext_write_extent(), mirroring the check already performed in __hfsplus_ext_read_extent().
--- fs/hfsplus/extents.c | 2 ++ 1 file changed, 2 insertions(+)
fs/hfsplus/extents.c +2 -0
@@ -110,6 +110,8 @@ static int __hfsplus_ext_write_extent(struct inode *inode, }else {if (res)return res; +if (fd->entrylength !=sizeof (hfsplus_extent_rec)) +return -EIO ;hfs_bnode_write (fd->bnode, hip->cached_extents, fd->entryoffset, fd->entrylength); hip->extent_state &= ~HFSPLUS_EXT_DIRTY ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 236/2857 soundwire: dmi-quirks: Disable ghost Realtek on Asus ROG Zephyrus Duo
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Keepax <[email protected]>
[ Upstream commit 5b08a3afd2995e5312c4c47ffea9d21b651e8e13 ]
The Asus ROG Zephyrus Duo also has a Realtek device in the ACPI that doesn't exist in the physical hardware. This confuses the machine driver into attempting to create DAI links for the device. Add a quirk to remove this device.
--- drivers/soundwire/dmi-quirks.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/soundwire/dmi-quirks.c +7 -0
@@ -193,6 +193,13 @@ static const struct dmi_system_id adr_remap_quirk_table[] = { }, .driver_data = (void *)ghost_realtek, }, + { + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"ASUS" ), + DMI_MATCH(DMI_BOARD_NAME, "GX651AR"), + }, + .driver_data = (void *)ghost_realtek, + }, { .matches = { DMI_MATCH(DMI_SYS_VENDOR, "ASUS"),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 237/2857 ipmi: Fix leak in __ipmi_bmc_register
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michail Tatas <[email protected]>
[ Upstream commit 18e633dd9674c8bf118ea8583bb5a531edc2728a ]
In case that ida_alloc(&ipmi_bmc_ida,...) succeeds and then platform_device_register() fails, ipmi_bmc_ida is leaked. Fix by freeing the error path
Message-ID: <anUK_HOy_pCgvsBm@michalis-linux>
--- drivers/char/ipmi/ipmi_msghandler.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/ipmi/ipmi_msghandler.c +1 -0
@@ -3257,6 +3257,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf,list_del (&intf->bmc_link);mutex_unlock (&bmc->dyn_mutex); intf->bmc = &intf->tmp_bmc; +ida_free (&ipmi_bmc_ida, bmc->pdev.id);put_device (&bmc->pdev.dev); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 238/2857 PCI: Avoid saving config space state if inaccessible
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Farhan Ali <[email protected]>
[ Upstream commit e18d1abc3bff0a24a5299f3c150ab9546e9439aa ]
The current reset process saves the device's config space state before reset and restores it afterward. However errors may occur unexpectedly and it may then be impossible to save config space because the device may be inaccessible (e.g. DPC). This results in saving invalid values that get written back to the device during state restoration.
With a reset we want to recover/restore the device into a functional state. So avoid saving the state of the config space when the device config space is inaccessible.
--- drivers/pci/pci.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/pci/pci.c +25 -0
@@ -776,6 +776,28 @@ u16 pci_find_dvsec_capability(struct pci_dev *dev, u16 vendor, u16 dvsec) }EXPORT_SYMBOL_GPL (pci_find_dvsec_capability); +static bool pci_dev_config_accessible (struct pci_dev *dev,char *msg) +{ +u32 val; + +/* +* If a device's config space is inaccessible, reads typically +* return ~0. Since Device and Vendor ID are always ~0 for VFs, +* check the Command and Status registers instead. +* +* N.B. This is racy because the device may become inaccessible +* before the next access. +*/ +pci_read_config_dword (dev,PCI_COMMAND , &val); +if (PCI_POSSIBLE_ERROR (val)) { +pci_warn (dev,"Device config space inaccessible; unable to %s\n" , + msg); +return false; + } + +return true; +} +/** * pci_find_parent_resource - return resource region of parent bus of given * region
@@ -5198,6 +5220,9 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)*/ pci_set_power_state (dev,PCI_D0 ); +if (!pci_dev_config_accessible (dev,"save state" )) +return ; +pci_save_state (dev);/* * Disable the device by clearing the Command register, except for
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 239/2857 ALSA: hda/intel: Add sanity check for BAR0 size
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 9895573b0185f922be4cf500a0f2e5b9560ab1c3 ]
The recent reports from syzkaller showed that we can bind any wild PCI device to HD-audio controller, and if PCI BAR of the device is too small, it may lead to a crash, as the driver believes as if the full register range were accessible.
For avoiding such a problem, add a safeguard before the actual probe to check the available BAR0 size.
Note that the threshold (0x200) is chosen to cover all needed registers at probing. But this doesn't mean that it would cover fully for all features including the extended ones.
--- sound/pci/hda/hda_intel.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/pci/hda/hda_intel.c +9 -0
@@ -2159,6 +2159,15 @@ static int azx_probe(struct pci_dev *pci,dev_warn (&pci->dev,"dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option instead\n" ); } +/* A sanity check against wild device binding; +* here the range 0x200 is enough for the registers used at probe, +* but it doesn't mean covering all HD-audio registers +*/ +if (pci_resource_len (pci,0 ) <0x200 ) { +dev_err (&pci->dev,"Too small PCI BAR0\n" ); +return -EINVAL ; + } + err =snd_card_new (&pci->dev, index[dev], id[dev],THIS_MODULE ,0 , &card);if (err <0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 240/2857 ALSA: usb-audio: Rename the Audient iD14 monitor mix volume control
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neil Andrews <[email protected]>
[ Upstream commit 9c0564fcc21aec4f5b7648f61865ce3fc2b84a7f ]
On the Audient iD14 (2708:0008), feature unit 12 is traced through to the Speaker output terminal and is therefore exported as "Speaker Playback Volume". The name fits it badly. It advertises Volume on only four of its six logical channels, which the driver records as cmask=0xf, channels=4 on a 6-channel playback stream, and it sits on the monitor mixer branch rather than in the direct playback path:
INPUT_TERMINAL 2 (USB streaming, 6ch) -> EXTENSION_UNIT 51 ->
FEATURE_UNIT 10 (no controls) -> OUTPUT_TERMINAL 20 (Speaker)
while FU 12 hangs off MIXER_UNIT 60 and feeds back into EXTENSION_UNIT 51.
Userspace adopts the control as the stream's hardware playback volume, so any setting below 0 dB attenuates part of the stream and not the rest. Measured over the device's own digital loopback, with one -12 dBFS tone per channel played straight to hw:, PCM channel 0 is unaffected while channel 1 tracks the control: at 107/127 (-20 dB) the two read -15.89 and -35.89 dBFS, a 20.00 dB imbalance, and at 127/127 both read -15.89 dBFS.
Give the unit a non-standard name so that it is no longer taken for the stream's master volume. Dropping the control instead also fixes the imbalance, but FU 12 keeps its value across a module reload, so dropping it strands a device that is already attenuated with nothing able to reset it. Renaming leaves the monitor gain reachable and that recovery path intact.
The mapped name ends in "Playback" because a name from the map suppresses the automatic " Playback" but still gets " Volume" appended; the control comes out as "Monitor Mix Playback Volume".
Tested on the ACP path with PipeWire, which is where the problem
reproduces: the control now stays at 127 at every volume setting and the imbalance is 0.00 dB, and setting it by hand to 107 and back to 127 gives 20.00 dB and 0.00 dB as before.
--- sound/usb/mixer_maps.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
sound/usb/mixer_maps.c +18 -0
@@ -505,6 +505,19 @@ static const struct usbmix_connector_map gigabyte_b450_connector_map[] = { {} }; +/* Audient iD14: FU 12 advertises Volume on only 4 of its 6 logical channels +* and sits on the monitor mixer branch, but it is traced through to the +* Speaker output terminal and gets named "Speaker Playback Volume". Userspace +* then adopts it as the stream's hardware volume, and any setting below 0 dB +* attenuates some channels but not others (20 dB imbalance at 80%). Give it a +* non-standard name so that it is no longer taken for the stream's master +* volume, while remaining reachable for anyone who wants the monitor gain. +*/ +static const struct usbmix_name_map audient_id14_map[] = { + {12 ,"Monitor Mix Playback" },/* FU, partial coverage */ + {} +}; +/* * Control map entries */
@@ -588,6 +601,11 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = { .id = USB_ID(0x2573, 0x0008), .map = maya44_map, }, + { +/* Audient iD14 */ + .id = USB_ID(0x2708, 0x0008), + .map = audient_id14_map, + }, {/* KEF X300A */ .id = USB_ID(0x27ac, 0x1000),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 241/2857 drm/virtio: reclaim pending vbufs before tearing down vqs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anuj Bolewar <[email protected]>
[ Upstream commit 61d85f99b5a55d4f717c4bb2f4c4acabf22ee3fc ]
virtio_gpu_free_vbufs() destroys the vbufs kmem_cache after the virtqueues have already been released. Commands that were queued but never completed by the device leave their vbuffers stranded in the virtqueue, so the cache still holds live objects when virtio_gpu_deinit() tears everything down. This triggers a WARNING in virtio_gpu_free_vbufs:
BUG virtio-gpu-vbufs (Not tainted): Objects remaining in cache on __kmem_cache_shutdown()
Drain any buffers still sitting in the control and cursor virtqueues in virtio_gpu_deinit() after the device has been reset and before the virtqueues are deleted, following the same pattern used by virtio_console's remove_vqs(). Each reclaimed buffer is released with free_vbuf(), dropping the reference on any GEM objects it holds. Pending RESOURCE_UNREF commands are handled as well: their resp_cb_data still references a GEM object, so it is cleaned up with virtio_gpu_cleanup_object() to avoid leaking it on teardown.
--- drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + drivers/gpu/drm/virtio/virtgpu_kms.c | 1 + drivers/gpu/drm/virtio/virtgpu_vq.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+)
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
@@ -323,6 +323,7 @@ void virtio_gpu_array_put_free_work(struct work_struct *work);/* virtgpu_vq.c */ int virtio_gpu_alloc_vbufs (struct virtio_gpu_device *vgdev);void virtio_gpu_free_vbufs (struct virtio_gpu_device *vgdev); +void virtio_gpu_reclaim_vbufs (struct virtio_gpu_device *vgdev); void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev, struct virtio_gpu_object *bo, struct virtio_gpu_object_params *params,
drivers/gpu/drm/virtio/virtgpu_kms.c +1 -0
@@ -280,6 +280,7 @@ void virtio_gpu_deinit(struct drm_device *dev)flush_work (&vgdev->cursorq.dequeue_work);flush_work (&vgdev->config_changed_work);virtio_reset_device (vgdev->vdev); +virtio_gpu_reclaim_vbufs (vgdev); vgdev->vdev->config->del_vqs (vgdev->vdev); }
drivers/gpu/drm/virtio/virtgpu_vq.c +15 -0
@@ -179,6 +179,21 @@ static void free_vbuf(struct virtio_gpu_device *vgdev,kmem_cache_free (vgdev->vbufs, vbuf); } +void virtio_gpu_reclaim_vbufs (struct virtio_gpu_device *vgdev) +{ +struct virtio_gpu_vbuffer *vbuf; + +while ((vbuf =virtqueue_detach_unused_buf (vgdev->ctrlq.vq))) { +if (vbuf->objs) +virtio_gpu_array_put_free (vbuf->objs); +if (vbuf->resp_cb_data) +virtio_gpu_cleanup_object (vbuf->resp_cb_data); +free_vbuf (vgdev, vbuf); + } +while ((vbuf =virtqueue_detach_unused_buf (vgdev->cursorq.vq))) +free_vbuf (vgdev, vbuf); +} +static void reclaim_vbufs (struct virtqueue *vq,struct list_head *reclaim_list) {struct virtio_gpu_vbuffer *vbuf;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 242/2857 exfat: keep FITRIM within the requested range
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Wen <[email protected]>
[ Upstream commit 2de727471b3b13409466a4af4f8824a86073bf4b ]
exfat_find_free_bitmap() searches the entire allocation bitmap and may wrap around to its beginning. exfat_trim_fs() does not verify that the returned cluster is still within the requested FITRIM range.
As a result, a partial FITRIM operation may discard free clusters outside the user-specified range and report a trimmed length larger than the requested length.
Validate each returned cluster against the requested range and stop the search when it wraps around or passes the range end.
--- fs/exfat/balloc.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
fs/exfat/balloc.c +19 -12
@@ -327,14 +327,27 @@ int exfat_trim_fs(struct inode *inode, struct fstrim_range *range)mutex_lock (&sbi->bitmap_lock); trim_begin = trim_end =exfat_find_free_bitmap (sb, clu_start); -if (trim_begin ==EXFAT_EOF_CLUSTER ) +/* +* exfat_find_free_bitmap() may wrap around to the beginning of +* the bitmap. Reject a cluster outside the requested range. +*/ +if (trim_begin ==EXFAT_EOF_CLUSTER || + trim_begin < clu_start || trim_begin > clu_end) goto unlock; - next_free_clu =exfat_find_free_bitmap (sb, trim_end +1 ); -if (next_free_clu ==EXFAT_EOF_CLUSTER ) - goto unlock; +for (;;) { +if (trim_end >= clu_end) +break ; + + next_free_clu =exfat_find_free_bitmap (sb, trim_end +1 ); +/* +* Stop if the search wrapped around or moved beyond the requested +* FITRIM range. +*/ +if (next_free_clu ==EXFAT_EOF_CLUSTER || + next_free_clu <= trim_end || next_free_clu > clu_end) +break ; - do {if (next_free_clu == trim_end +1 ) {/* extend trim range for continuous free cluster */ trim_end++;
@@ -355,17 +368,11 @@ int exfat_trim_fs(struct inode *inode, struct fstrim_range *range) trim_begin = trim_end = next_free_clu; } -if (next_free_clu >= clu_end) -break ; -if (fatal_signal_pending (current)) { err = -ERESTARTSYS ; goto unlock; } - - next_free_clu =exfat_find_free_bitmap (sb, next_free_clu +1 ); - }while (next_free_clu !=EXFAT_EOF_CLUSTER && - next_free_clu > trim_end); + }/* try to trim remainder */ count = trim_end - trim_begin +1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 243/2857 libbpf: Fix ring buffer consumer loop on 32-bit position wrap
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Israel Téllez García <[email protected]>
[ Upstream commit fdd4fad0bbbd08501465c5f9b556963093c5d58a ]
ringbuf_process_ring() walks the records between the consumer and the producer with an ordering comparison:
while (cons_pos < prod_pos) {cons_pos and prod_pos mirror the kernel's ring positions and are unsigned long here too, so on 32-bit they wrap at 2^32 bytes of traffic. When producer_pos has wrapped and consumer_pos has not, prod_pos is the smaller of the two, the loop body never runs and no record is consumed. Since consumer_pos only advances inside that loop, it never wraps either and the consumer stops delivering samples for good, with no error returned to the caller: ring_buffer__poll() keeps reporting zero records while the kernel side fills up and starts dropping.
Compare the distance instead. The consumer never runs ahead of the producer, so prod_pos - cons_pos is the amount of unconsumed data and stays correct across the wrap.
64-bit hosts are unaffected in practice: the counters would need 16 EiB to wrap. This is the userspace counterpart of the kernel-side walk fixed in "bpf: Fix pending_pos walk on 32-bit ring position wrap"; a 32-bit consumer hits whichever of the two comes first.
--- tools/lib/bpf/ringbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/ringbuf.c +1 -1
@@ -237,7 +237,7 @@ static int64_t ringbuf_process_ring(struct ring* r) do { got_new_data = false; prod_pos = smp_load_acquire(r->producer_pos); - while (cons_pos < prod_pos) { + while (prod_pos - cons_pos > 0) { len_ptr = r->data + (cons_pos & r->mask); len = smp_load_acquire(len_ptr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 244/2857 ksmbd: protect private extended attributes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 4ea46ea602fc7055eee4b5b0e84f90f22da7f7e7 ]
SMB clients can currently create an EA named NTACL because SMB EAs are mapped into the user namespace while the ksmbd security descriptor is stored as security.NTACL. Allowing the reserved logical name makes the server-private ACL metadata appear writable through the SMB EA API.
Reject NTACL, DOSATTRIB, and DosStream-prefixed EA names without regard to case. Filter the same private names from EA query results so stale or externally-created user namespace attributes cannot be exposed.
This fixes smb2.ea.acl_xattr when acl_xattr_name is configured as NTACL.
--- fs/smb/server/smb2pdu.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-)
fs/smb/server/smb2pdu.c +22 -6
@@ -2384,6 +2384,22 @@ static noinline int create_smb2_pipe(struct ksmbd_work *work)return err; } +static bool smb2_is_private_ea (const char *name,size_t name_len) +{ +if (name_len ==SD_PREFIX_LEN && + !strncasecmp (name,SD_PREFIX ,SD_PREFIX_LEN )) +return true; +if (name_len ==DOS_ATTRIBUTE_PREFIX_LEN && + !strncasecmp (name,DOS_ATTRIBUTE_PREFIX , +DOS_ATTRIBUTE_PREFIX_LEN )) +return true; +if (name_len >=STREAM_PREFIX_LEN && + !strncasecmp (name,STREAM_PREFIX ,STREAM_PREFIX_LEN )) +return true; + +return false; +} +/** * smb2_set_ea() - handler for setting extended attributes using set * info command
@@ -2425,6 +2441,10 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len, rc = -EINVAL ;break ; } +if (smb2_is_private_ea (eabuf->name, eabuf->EaNameLength)) { + rc = -EACCES ; +break ; + }memcpy (attr_name,XATTR_USER_PREFIX ,XATTR_USER_PREFIX_LEN ); memcpy(&attr_name[XATTR_USER_PREFIX_LEN], eabuf->name,
@@ -4492,17 +4512,13 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,if (strncmp (name,XATTR_USER_PREFIX ,XATTR_USER_PREFIX_LEN ))continue ; -if (!strncmp (&name[XATTR_USER_PREFIX_LEN ],STREAM_PREFIX , -STREAM_PREFIX_LEN )) -continue ; -if (req->InputBufferLength &&strncmp (&name[XATTR_USER_PREFIX_LEN ], ea_req->name, ea_req->EaNameLength))continue ; -if (!strncmp (&name[XATTR_USER_PREFIX_LEN ], -DOS_ATTRIBUTE_PREFIX ,DOS_ATTRIBUTE_PREFIX_LEN )) +if (smb2_is_private_ea (&name[XATTR_USER_PREFIX_LEN ], + name_len -XATTR_USER_PREFIX_LEN ))continue ;if (!strncmp (name,XATTR_USER_PREFIX ,XATTR_USER_PREFIX_LEN ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 245/2857 ksmbd: preserve access denied status for copychunk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit f7c0366e0a80bf8cd5eacc5479927abb50958b5e ]
The copychunk error mapping handles -EACCES in an independent if statement. The following error chain therefore reaches its final else clause and overwrites STATUS_ACCESS_DENIED with STATUS_UNEXPECTED_IO_ERROR.
Join the -EACCES check to the remaining error chain so an access failure is returned as STATUS_ACCESS_DENIED.
--- fs/smb/server/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +1 -1
@@ -7591,7 +7591,7 @@ static int fsctl_copychunk(struct ksmbd_work *work,if (ret <0 ) {if (ret == -EACCES ) rsp->hdr.Status =STATUS_ACCESS_DENIED ; -if (ret == -EAGAIN ) +else if (ret == -EAGAIN ) rsp->hdr.Status =STATUS_FILE_LOCK_CONFLICT ;else if (ret == -EBADF ) rsp->hdr.Status =STATUS_INVALID_HANDLE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 246/2857 ksmbd: allow I/O on directory named streams
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 8184c425a19d44f138d42b44cc363917c08e5f1c ]
Named streams are stored as extended attributes on the base inode. The VFS read and write helpers reject directory inodes before or together with checking whether the handle represents a stream.
Permit read and write operations when a directory-backed handle is a named stream. Continue rejecting direct I/O on ordinary directory handles.
This fixes creation of the directory stream in smb2.getinfo.complex.
--- fs/smb/server/vfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/smb/server/vfs.c +3 -2
@@ -378,7 +378,7 @@ int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,ssize_t nbytes =0 ;struct inode *inode =file_inode (filp); -if (S_ISDIR (inode->i_mode)) +if (S_ISDIR (inode->i_mode) && !ksmbd_stream_fd (fp))return -EISDIR ;if (unlikely (count ==0 ))
@@ -506,7 +506,8 @@ int ksmbd_vfs_write(struct ksmbd_work *work, struct ksmbd_file *fp,if (work->conn->connection_type) {if (!(fp->daccess & (FILE_WRITE_DATA_LE |FILE_APPEND_DATA_LE )) || -S_ISDIR (file_inode (fp->filp)->i_mode)) { + (S_ISDIR (file_inode (fp->filp)->i_mode) && + !ksmbd_stream_fd (fp))) {pr_err ("no right to write(%pD)\n" , fp->filp); err = -EACCES ; goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 247/2857 ksmbd: handle empty QUERY_ALLOCATED_RANGES output
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 7f07791522a251e2be087d11ae9cd51eb3408f1d ]
FSCTL_QUERY_ALLOCATED_RANGES can be issued with a valid input buffer but without room for an output range. Do not reject the request before looking at the file layout. If the query would produce a range, return STATUS_BUFFER_TOO_SMALL. If it produces no ranges, return success with an empty output.
--- fs/smb/server/smb2pdu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
fs/smb/server/smb2pdu.c +12 -4
@@ -7797,8 +7797,6 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id,int ret =0 ; *out_count =0 ; -if (in_count ==0 ) -return -EINVAL ; start =le64_to_cpu (qar_req->file_offset); length =le64_to_cpu (qar_req->length);
@@ -7810,8 +7808,18 @@ static int fsctl_query_allocated_ranges(struct ksmbd_work *work, u64 id,if (!fp)return -ENOENT ; - ret =ksmbd_vfs_fqar_lseek (fp, start, length, - qar_rsp, in_count, out_count); +if (!in_count) { +struct file_allocated_range_buffer range; + + ret =ksmbd_vfs_fqar_lseek (fp, start, length, &range,1 , + out_count); +if (!ret && *out_count) + ret = -ENOSPC ; + *out_count =0 ; + }else { + ret =ksmbd_vfs_fqar_lseek (fp, start, length, + qar_rsp, in_count, out_count); + }if (ret && ret != -E2BIG ) *out_count =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 248/2857 ksmbd: honor byte-range locks for zero data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 8b57448a147d2378088e63cd473e7f2a967d6802 ]
FSCTL_SET_ZERO_DATA changes file allocation state and must respect byte-range locks over the affected part of the file. Check the requested range, clipped to EOF, before issuing the fallocate operation.
Return STATUS_FILE_LOCK_CONFLICT when the range conflicts with an existing lock. Ranges starting past EOF are left untouched by the lock check so they continue to succeed.
--- fs/smb/server/smb2pdu.c | 7 ++++++- fs/smb/server/vfs.c | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
fs/smb/server/smb2pdu.c +6 -1
@@ -8158,8 +8158,13 @@ int smb2_ioctl(struct ksmbd_work *work) ret =ksmbd_vfs_zero_data (work, fp, off, len);ksmbd_fd_put (work, fp); -if (ret <0 ) +if (ret == -EAGAIN ) { + rsp->hdr.Status =STATUS_FILE_LOCK_CONFLICT ; + ret =0 ; goto out; + }else if (ret <0 ) { + goto out; + } }break ; }
fs/smb/server/vfs.c +12 -0
@@ -1000,6 +1000,18 @@ int ksmbd_vfs_zero_data(struct ksmbd_work *work, struct ksmbd_file *fp,int err;smb_break_all_levII_oplock (work, fp,1 ); +if (!work->tcon->posix_extensions) { +loff_t size =i_size_read (file_inode (fp->filp)); + +if (off < size) { + err =check_lock_range (fp->filp, off, +min (off + len, size) -1 , +WRITE ); +if (err) +return -EAGAIN ; + } + } + saved_cred =override_creds (fp->filp->f_cred);if (fp->f_ci->m_fattr &FILE_ATTRIBUTE_SPARSE_FILE_LE ) err = vfs_fallocate(fp->filp,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 249/2857 ksmbd: allow FSCTL_SET_SPARSE without input buffer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 86c84cc760080929b7be44bceebe5854957b99da ]
FSCTL_SET_SPARSE without an input buffer sets a file sparse. Treat a zero-length input buffer as SetSparse=true and keep rejecting truncated non-empty buffers.
--- fs/smb/server/smb2pdu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/server/smb2pdu.c +8 -2
@@ -8105,15 +8105,21 @@ int smb2_ioctl(struct ksmbd_work *work) rsp);break ;case FSCTL_SET_SPARSE : -if (in_buf_len <sizeof (struct file_sparse )) { + { +struct file_sparse sparse = {0 }; + +if (in_buf_len && in_buf_len <sizeof (struct file_sparse )) { ret = -EINVAL ; goto out; } - ret =fsctl_set_sparse (work, id, (struct file_sparse *)buffer); + *(u8 *)&sparse =1 ; + ret =fsctl_set_sparse (work, id, in_buf_len ? + (struct file_sparse *)buffer : &sparse);if (ret <0 ) goto out;break ; + }case FSCTL_SET_ZERO_DATA : {struct file_zero_data_information *zero_data;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 250/2857 ksmbd: skip fallocate for SMB2_CREATE_ALLOCATION_SIZE on a stream handle
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gael Blivet <[email protected]>
[ Upstream commit bfdf81c62f4f52a3626ea62db0744def6778e83f ]
smb2_open() calls vfs_fallocate(fp->filp, ...) unconditionally when a client's CREATE request includes an AllocationSize create context. For a stream handle, fp->filp refers to the base file's data fork (streams are xattr-backed on the same underlying file, not separate files), so this pre-allocates storage on the base file's actual data instead of doing anything meaningful for the stream -- fallocate has no applicability to an xattr-backed stream at all.
Skip the fallocate call for stream handles.
--- fs/smb/server/smb2pdu.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
fs/smb/server/smb2pdu.c +16 -7
@@ -3378,13 +3378,22 @@ int smb2_open(struct ksmbd_work *work)ksmbd_debug (SMB ,"request smb2 create allocate size : %llu\n" , alloc_size); -smb_break_all_levII_oplock (work, fp,1 ); - err =vfs_fallocate (fp->filp,FALLOC_FL_KEEP_SIZE ,0 , - alloc_size); -if (err <0 ) -ksmbd_debug (SMB , -"vfs_fallocate is failed : %d\n" , - err); +/* +* fp->filp is the base file's data fork for a stream +* handle (streams are xattr-backed on the same +* underlying file) -- fallocate has no meaning for a +* stream and would otherwise pre-allocate storage on +* the base file's data instead. +*/ +if (!ksmbd_stream_fd (fp)) { +smb_break_all_levII_oplock (work, fp,1 ); + err =vfs_fallocate (fp->filp,FALLOC_FL_KEEP_SIZE ,0 , + alloc_size); +if (err <0 ) +ksmbd_debug (SMB , +"vfs_fallocate is failed : %d\n" , + err); + } } context =smb2_find_context_vals (req,SMB2_CREATE_QUERY_ON_DISK_ID ,4 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 251/2857 smb/server: cancel async requests when closing connection
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChenXiaoSong <[email protected]>
[ Upstream commit 4fd5bad647bfa45eb86bfd2f03ba1bef3fcd5851 ]
An async request may still be waiting when a connection is closed. This can stop the connection from closing.
Cancel active async requests before waiting for them to finish.
--- fs/smb/server/connection.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
fs/smb/server/connection.c +21 -0
@@ -194,6 +194,26 @@ void ksmbd_conn_try_dequeue_request(struct ksmbd_work *work)wake_up_all (&conn->req_running_q); } +static void ksmbd_conn_cancel_async_requests (struct ksmbd_conn *conn) +{ +struct ksmbd_work *work, *tmp; + +ksmbd_debug (CONN ,"Cancel pending async requests on releasing connection\n" ); +spin_lock (&conn->request_lock); +list_for_each_entry_safe (work, tmp, &conn->async_requests, + async_request_entry) { +if (work->state !=KSMBD_WORK_ACTIVE ) +continue ; + +ksmbd_debug (CONN ,"Cancel async request id %d\n" , + work->async_id); + work->state =KSMBD_WORK_CANCELLED ; +if (work->cancel_fn) + work->cancel_fn (work->cancel_argv); + } +spin_unlock (&conn->request_lock); +} +void ksmbd_conn_lock (struct ksmbd_conn *conn) {mutex_lock (&conn->srv_mutex);
@@ -426,6 +446,7 @@ int ksmbd_conn_handler_loop(void *p) out:ksmbd_conn_set_releasing (conn); +ksmbd_conn_cancel_async_requests (conn);/* Wait till all reference dropped to the Server object*/ wait_event (conn->r_count_q,atomic_read (&conn->r_count) ==0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 252/2857 ksmbd: fix SMB2 byte-range lock end offset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 54d90311f9b4eb23f3b0b62650b0cfddb11a12ef ]
SMB2 describes a byte-range lock using an offset and a length, while Linux file_lock uses an inclusive end offset. smb2_lock() currently sets fl_end to start + length and consequently locks one extra byte for every nonzero-length request.
Translate nonzero lengths to start + length - 1 and reject ranges that cannot be represented by loff_t instead of silently truncating them at OFFSET_MAX. Track zero-length locks from the request length so one-byte ranges are not mistaken for zero-length locks after endpoint conversion.
--- fs/smb/server/smb2pdu.c | 44 +++++++++++++---------------------------- 1 file changed, 14 insertions(+), 30 deletions(-)
fs/smb/server/smb2pdu.c +14 -30
@@ -7084,7 +7084,7 @@ static int smb2_set_flock_flags(struct file_lock *flock, int flags) }static struct ksmbd_lock *smb2_lock_init (struct file_lock *flock, -unsigned int cmd,int flags, +unsigned int cmd,int flags,bool zero_len,struct list_head *lock_list) {struct ksmbd_lock *lock;
@@ -7098,8 +7098,7 @@ static struct ksmbd_lock *smb2_lock_init(struct file_lock *flock, lock->start = flock->fl_start; lock->end = flock->fl_end; lock->flags = flags; -if (lock->start == lock->end) - lock->zero_len =1 ; + lock->zero_len = zero_len;INIT_LIST_HEAD (&lock->clist);INIT_LIST_HEAD (&lock->flist);INIT_LIST_HEAD (&lock->llist);
@@ -7192,32 +7191,18 @@ int smb2_lock(struct ksmbd_work *work) lock_start =le64_to_cpu (lock_ele[i].Offset); lock_length =le64_to_cpu (lock_ele[i].Length); -if (lock_start >U64_MAX - lock_length) { +if (lock_start >OFFSET_MAX || + (lock_length && + lock_length -1 >OFFSET_MAX - lock_start)) {pr_err ("Invalid lock range requested\n" ); rsp->hdr.Status =STATUS_INVALID_LOCK_RANGE ;locks_free_lock (flock); goto out; } -if (lock_start >OFFSET_MAX ) - flock->fl_start =OFFSET_MAX ; -else - flock->fl_start = lock_start; - - lock_length =le64_to_cpu (lock_ele[i].Length); -if (lock_length >OFFSET_MAX - flock->fl_start) - lock_length =OFFSET_MAX - flock->fl_start; - - flock->fl_end = flock->fl_start + lock_length; - -if (flock->fl_end < flock->fl_start) { -ksmbd_debug (SMB , -"the end offset(%llx) is smaller than the start offset(%llx)\n" , - flock->fl_end, flock->fl_start); - rsp->hdr.Status =STATUS_INVALID_LOCK_RANGE ; -locks_free_lock (flock); - goto out; - } + flock->fl_start = lock_start; + flock->fl_end = lock_length ? + flock->fl_start + lock_length -1 : flock->fl_start;/* Check conflict locks in one request */ list_for_each_entry (cmp_lock, &lock_list, llist) {
@@ -7233,7 +7218,8 @@ int smb2_lock(struct ksmbd_work *work) } } - smb_lock =smb2_lock_init (flock, cmd, flags, &lock_list); + smb_lock =smb2_lock_init (flock, cmd, flags, !lock_length, + &lock_list);if (!smb_lock) { err = -EINVAL ;locks_free_lock (flock);
@@ -7307,7 +7293,7 @@ int smb2_lock(struct ksmbd_work *work)/* check zero byte lock range */ if (cmp_lock->zero_len && !smb_lock->zero_len && cmp_lock->start > smb_lock->start && - cmp_lock->start < smb_lock->end) { + cmp_lock->start <= smb_lock->end) {spin_unlock (&conn->llist_lock);up_read (&conn_list_lock);pr_err ("previous lock conflict with zero byte lock range\n" );
@@ -7316,17 +7302,15 @@ int smb2_lock(struct ksmbd_work *work)if (smb_lock->zero_len && !cmp_lock->zero_len && smb_lock->start > cmp_lock->start && - smb_lock->start < cmp_lock->end) { + smb_lock->start <= cmp_lock->end) {spin_unlock (&conn->llist_lock);up_read (&conn_list_lock);pr_err ("current lock conflict with zero byte lock range\n" ); goto out; } -if (((cmp_lock->start <= smb_lock->start && - cmp_lock->end > smb_lock->start) || - (cmp_lock->start < smb_lock->end && - cmp_lock->end >= smb_lock->end)) && +if (cmp_lock->start <= smb_lock->end && + smb_lock->start <= cmp_lock->end && !cmp_lock->zero_len && !smb_lock->zero_len) {spin_unlock (&conn->llist_lock);up_read (&conn_list_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 253/2857 ksmbd: fix AsyncId zeroed before use in smb2_lock() cancel response
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gael Blivet <[email protected]>
[ Upstream commit 7b461610882c8baa64d56dade57cdbfb686739fa ]
release_async_work() zeroes work->async_id before the CANCELLED path calls smb2_send_interim_resp(work, STATUS_CANCELLED), which reads work->async_id to build the response's AsyncId field. The cancellation response for a cancelled blocked-lock request is sent with AsyncId=0 instead of the id the client received in the original STATUS_PENDING response for this request.
Checked against every other release_async_work() call site in this
file: smb2_read()/smb2_write() don't send a further async response afterward (their status goes out on the synchronous path instead), and smb2_notify()'s two async paths already transfer the id to a separate struct before releasing, so this reordering is scoped to smb2_lock() only.
Send the STATUS_CANCELLED response while work->async_id is still valid, then release the async work afterward.
--- fs/smb/server/smb2pdu.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
fs/smb/server/smb2pdu.c +9 -6
@@ -7389,22 +7389,25 @@ int smb2_lock(struct ksmbd_work *work)spin_unlock (&fp->f_lock);list_del (&smb_lock->llist); -release_async_work (work); - -if (work->state ==KSMBD_WORK_ACTIVE ) - goto retry; - -locks_free_lock (flock);if (work->state ==KSMBD_WORK_CANCELLED ) { rsp->hdr.Status =STATUS_CANCELLED ;kfree (smb_lock);smb2_send_interim_resp (work,STATUS_CANCELLED ); +release_async_work (work); +locks_free_lock (flock); work->send_no_response =1 ; goto out; } +release_async_work (work); + +if (work->state ==KSMBD_WORK_ACTIVE ) + goto retry; + +locks_free_lock (flock); + rsp->hdr.Status =STATUS_RANGE_NOT_LOCKED ;kfree (smb_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 254/2857 ksmbd: reject blocking compound lock requests
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 16a7f7c2ecf3c893b65f0fb78fa7a7171ae0ba9e ]
Clients set SMB2_LOCKFLAG_FAIL_IMMEDIATELY when a LOCK request contains multiple lock elements, and servers reject requests that omit it. Accepting such a request can leave earlier elements locked while a later element waits asynchronously, enabling prolonged partial lock ownership and avoidable deadlocks.
Return STATUS_INVALID_PARAMETER before processing any element when a multi-element lock request contains a blocking lock. Unlock arrays remain unaffected.
--- fs/smb/server/smb2pdu.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/smb/server/smb2pdu.c +7 -0
@@ -7228,6 +7228,13 @@ int smb2_lock(struct ksmbd_work *work) }list_for_each_entry_safe (smb_lock, tmp, &lock_list, llist) { +if (lock_count >1 && + !(le32_to_cpu (lock_ele[0 ].Flags) &SMB2_LOCKFLAG_UNLOCK ) && + !(smb_lock->flags &SMB2_LOCKFLAG_FAIL_IMMEDIATELY )) { + err = -EINVAL ; + goto out; + } +if (smb_lock->cmd <0 ) { err = -EINVAL ; goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 255/2857 ksmbd: honor client signing-required in all modes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit bc2f3f3dd69424f76e2ed3dc53d29bfd6c9966d4 ]
The SMB2 NEGOTIATE request's SMB2_NEGOTIATE_SIGNING_REQUIRED bit requires the server to set Connection.ShouldSign. KSMBD represents that state with conn->sign, but previously set it only when its signing configuration was auto or disabled.
Set conn->sign whenever the client requires signing, independently of the server's signing mode. Keep the mandatory server-mode handling unchanged.
--- fs/smb/server/smb2pdu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/smb/server/smb2pdu.c +2 -4
@@ -1269,11 +1269,9 @@ int smb2_handle_negotiate(struct ksmbd_work *work) rsp->SecurityMode =SMB2_NEGOTIATE_SIGNING_ENABLED_LE ; conn->use_spnego = true; -if ((server_conf.signing ==KSMBD_CONFIG_OPT_AUTO || - server_conf.signing ==KSMBD_CONFIG_OPT_DISABLED ) && - req->SecurityMode &SMB2_NEGOTIATE_SIGNING_REQUIRED_LE ) +if (req->SecurityMode &SMB2_NEGOTIATE_SIGNING_REQUIRED_LE ) conn->sign = true; -else if (server_conf.signing ==KSMBD_CONFIG_OPT_MANDATORY ) { +if (server_conf.signing ==KSMBD_CONFIG_OPT_MANDATORY ) { server_conf.enforced_signing = true; rsp->SecurityMode |=SMB2_NEGOTIATE_SIGNING_REQUIRED_LE ; conn->sign = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 256/2857 ksmbd: notify parent directory leases on child create
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit abe5acb34282206c2a6303d0e09b3165b1addf0e ]
BVT_DirectoryLeasing_ReadWriteHandleCaching requires a parent directory lease break notification when another client creates a child in the leased directory. A child CREATE without a lease context did not notify the parent lease holders because the notification path expected a non-NULL lease context.
Allow the parent lease notification helper to handle a NULL child lease context and notify matching parent leases. Invoke it after a child is created without a lease context while preserving the existing lease-key filtering for requests that provide one.
--- fs/smb/server/oplock.c | 9 +++++---- fs/smb/server/smb2pdu.c | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-)
fs/smb/server/oplock.c +5 -4
@@ -1175,7 +1175,7 @@ void smb_send_parent_lease_break_noti(struct ksmbd_file *fp,struct oplock_info *opinfo;struct ksmbd_inode *p_ci =NULL ; -if (lctx->version !=2 ) +if (lctx && lctx->version !=2 )return ; p_ci =ksmbd_inode_lookup_lock (fp->filp->f_path.dentry->d_parent);
@@ -1188,9 +1188,10 @@ void smb_send_parent_lease_break_noti(struct ksmbd_file *fp,continue ;if (opinfo->o_lease->state !=SMB2_OPLOCK_LEVEL_NONE && - (!(lctx->flags &SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE ) || - !compare_guid_key (opinfo, fp->conn->ClientGUID, - lctx->parent_lease_key))) { + (!lctx || + (!(lctx->flags &SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE ) || + !compare_guid_key (opinfo, fp->conn->ClientGUID, + lctx->parent_lease_key)))) {if (!atomic_inc_not_zero (&opinfo->refcount))continue ;
fs/smb/server/smb2pdu.c +3 -0
@@ -3315,6 +3315,9 @@ int smb2_open(struct ksmbd_work *work) goto err_out1; } }else { +if (created && !lc) +smb_send_parent_lease_break_noti (fp,NULL ); +if (req_op_level ==SMB2_OPLOCK_LEVEL_LEASE && lc) {/* * Compare parent lease using parent key. If there is no
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 257/2857 smb: server: Free session data in user_session.c with kfree_sensitive()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Huth <[email protected]>
[ Upstream commit 9a4bd6507c21f66e84dc021705a4b9d84773111e ]
struct ksmbd_session contains some arrays with sensitive information, like sess_key, smb3encryptionkey, smb3decryptionkey and smb3signingkey. Thus let's make sure that this information cannot leak via the heap and use kfree_sensitive() to free it.
--- fs/smb/server/mgmt/user_session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/mgmt/user_session.c +2 -2
@@ -168,10 +168,10 @@ void ksmbd_session_destroy(struct ksmbd_session *sess)ksmbd_destroy_file_table (&sess->file_table);ksmbd_session_rpc_clear_list (sess);free_channel_list (sess); -kfree (sess->Preauth_HashValue); +kfree_sensitive (sess->Preauth_HashValue);ksmbd_release_id (&session_ida, sess->id);ida_destroy (&sess->tree_conn_ida); -kfree (sess); +kfree_sensitive (sess); }static struct ksmbd_session *__session_lookup (unsigned long long id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 258/2857 net: stmmac: use dma_addr_t for DMA addresses
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Elder <[email protected]>
[ Upstream commit 0c1f9020d2ada55aed8a2e055903ad9cd5d49dab ]
In jumbo_frm() (implemented in both "chain_mode.c" and "ring_mode.c"), an unsigned integer local variable is used to hold the value returned by dma_map_single(). On systems where a dma_addr_t is 64 bits, the subsequent dma_mapping_error() check of the returned value operates only on the low 32 bits (whose high bit won't be sign-extended). In this case, dma_mapping_error() would return 0 (no error) even if there were one.
Fix this in both spots by using a dma_addr_t for the local variable.
--- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 3 ++- drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/chain_mode.c +2 -1
@@ -20,9 +20,10 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb,unsigned int nopaged_len =skb_headlen (skb);struct stmmac_priv *priv = tx_q->priv_data;unsigned int entry = tx_q->cur_tx; -unsigned int bmax, buf_len, des2; +unsigned int bmax, buf_len;unsigned int i =1 , len;struct dma_desc *desc; +dma_addr_t des2; desc = tx_q->dma_tx + entry;
drivers/net/ethernet/stmicro/stmmac/ring_mode.c +2 -1
@@ -20,8 +20,9 @@ static int jumbo_frm(struct stmmac_tx_queue *tx_q, struct sk_buff *skb,unsigned int nopaged_len =skb_headlen (skb);struct stmmac_priv *priv = tx_q->priv_data;unsigned int entry = tx_q->cur_tx; -unsigned int bmax, len, des2; +unsigned int bmax, len;struct dma_desc *desc; +dma_addr_t des2;if (priv->extend_desc) desc = (struct dma_desc *)(tx_q->dma_etx + entry);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 259/2857 ASoC: codec: max98926: fixup invert setup mask
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit dd0ae9a2e19a24c532c9aa80a44f572b4907bcdf ]
invert might have both WCI/BCI mask, but regmap_update_bits() masks BCI only. It needs both mask. Fixup it.
static int max98926_dai_set_fmt(...)
{
...
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
case SND_SOC_DAIFMT_NB_NF:
break;
case SND_SOC_DAIFMT_NB_IF:
=> invert = MAX98926_DAI_WCI_MASK;
break; ^^^^^^^^^^^^^^^^^^^^^
case SND_SOC_DAIFMT_IB_NF:
=> invert = MAX98926_DAI_BCI_MASK;
break; ^^^^^^^^^^^^^^^^^^^^^
case SND_SOC_DAIFMT_IB_IF:
=> invert = MAX98926_DAI_BCI_MASK | MAX98926_DAI_WCI_MASK;
break; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
default:
...
}
...
regmap_update_bits(max98926->regmap, MAX98926_FORMAT,
MAX98926_DAI_BCI_MASK, invert);
... ^^^^^^^^^^^^^^^^^^^^^
}--- sound/soc/codecs/max98926.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/max98926.c +1 -1
@@ -360,7 +360,7 @@ static int max98926_dai_set_fmt(struct snd_soc_dai *codec_dai,regmap_write (max98926->regmap,MAX98926_FORMAT ,MAX98926_DAI_DLY_MASK );regmap_update_bits (max98926->regmap,MAX98926_FORMAT , -MAX98926_DAI_BCI_MASK , invert); +MAX98926_DAI_BCI_MASK |MAX98926_DAI_WCI_MASK , invert);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 260/2857 virtio_balloon: warn on failed buffer add in tell_host()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis V. Lunev <[email protected]>
[ Upstream commit 198eda395067b56ee605de076f0519620f4e5d90 ]
tell_host() ignores the return value of virtqueue_add_outbuf() and goes on to kick the queue and wait_event() for the host's ack. The comment claims "We should always be able to add one buffer to an empty queue", but that does not hold once the virtqueue has been broken (e.g. on device shutdown): the add then fails with -EIO and the following wait_event() would block forever on a buffer the host can never return.
Warn and bail out on failure, mirroring virtballoon_free_page_report().
Message-ID: <[email protected]>
--- drivers/virtio/virtio_balloon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/virtio/virtio_balloon.c +4 -2
@@ -147,16 +147,18 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq) {struct scatterlist sg;unsigned int len; +int err;sg_init_one (&sg, vb->pfns,sizeof (vb->pfns[0 ]) * vb->num_pfns);/* We should always be able to add one buffer to an empty queue. */ -virtqueue_add_outbuf (vq, &sg,1 , vb,GFP_KERNEL ); + err =virtqueue_add_outbuf (vq, &sg,1 , vb,GFP_KERNEL ); +if (WARN_ON_ONCE (err)) +return ;virtqueue_kick (vq);/* When host has read buffer, this completes via balloon_ack */ wait_event (vb->acked,virtqueue_get_buf (vq, &len)); - } static int virtballoon_free_page_report(struct page_reporting_dev_info *pr_dev_info,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 261/2857 rtc: ab-eoz9: add missing MODULE_DEVICE_TABLE()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 7490b8356e52e09c196645912f2c054f79aa5f3a ]
The driver has a match table for the i2c bus wired into its driver structure, but the table is not exported with MODULE_DEVICE_TABLE().
Add the missing MODULE_DEVICE_TABLE() entry so module alias information is generated for automatic module loading.
This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the driver registration structure, and the missing module alias publication.
--- drivers/rtc/rtc-ab-eoz9.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-ab-eoz9.c +1 -0
@@ -566,6 +566,7 @@ static const struct i2c_device_id abeoz9_id[] = { { "abeoz9", 0 }, { } }; +MODULE_DEVICE_TABLE(i2c, abeoz9_id); static struct i2c_driver abeoz9_driver = { .driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 262/2857 virtio_ring: fix infinite loop in virtnet_poll_cleantx when device is broken
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinqian Yang <[email protected]>
[ Upstream commit 0d0eff39ceb3dcbf7847a6f4517086c207c60081 ]
virtnet_poll_cleantx() contains a do-while loop that cleans up transmitted TX buffers and calls virtqueue_enable_cb_delayed() to check whether more buffers need processing. When the virtio backend stops responding during guest reboot, used->idx is never updated, so virtqueue_enable_cb_delayed() always returns false and the loop never terminates. Then it will block reboot process, and the guest will hang.
The problem occurs during guest reboot under network traffic:
1. kernel_restart() -> device_shutdown() traverses the device list
2. virtio_dev_shutdown() calls virtio_break_device() which sets
vq->broken = true
3. virtio_dev_shutdown() then calls virtio_synchronize_cbs() to wait
for in-flight callbacks to complete
4. A virtio interrupt fires, softirq is deferred to ksoftirqd which
calls net_rx_action() -> virtnet_poll() -> virtnet_poll_cleantx()
5. virtnet_poll_cleantx() enters the do-while loop and never exits
because the QEMU backend has stopped updating used->idx, despite
vq->broken having been set to true in step 2.Since the loop runs inside ksoftirqd (a SCHED_OTHER kthread), it is visible to the scheduler and does not trigger a hard lockup. However, the kthread never leaves the loop, so RCU detects it as a CPU stall and reports it periodically. Meanwhile, the reboot process remains blocked in device_shutdown() because virtio_dev_shutdown() cannot complete its synchronization step, and the guest hangs permanently.
This can be reproduced on a guest with a virtio-net device: run iperf3 traffic in the guest, then trigger reboot. The reboot occasionally hangs permanently with RCU stall on ksoftirqd.
Observed on ARM64 KVM guest:
CPU#1 RCU stall (ksoftirqd/1), repeated periodically:
virtqueue_enable_cb_delayed_split <- virtnet_poll <- __napi_poll <- net_rx_action <- handle_softirqs <- run_ksoftirqd <- smpboot_thread_fn <- kthread
Fix by adding a vq->broken check in virtqueue_enable_cb_delayed(), so that the loop exits immediately when the device is broken, allowing the device shutdown to proceed.
Message-ID: <[email protected]>
--- drivers/virtio/virtio_ring.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/virtio/virtio_ring.c +8 -0
@@ -2418,6 +2418,14 @@ bool virtqueue_enable_cb_delayed(struct virtqueue *_vq) {struct vring_virtqueue *vq =to_vvq (_vq); +/* +* When the device is broken there is no point in polling used->idx, +* the backend will never update it. Return true to let callers +* exit their cleanup loops instead of spinning forever. +*/ +if (unlikely (vq->broken)) +return true; +if (vq->event_triggered)data_race (vq->event_triggered = false);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 263/2857 rtc: ds1307: fix RX8130 wakeup alarm WADA bit for day-of-month mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Leussler <[email protected]>
[ Upstream commit 878d93aaa596a861dbc8d71f7c38e62a2e805f01 ]
The RX8130 wakeup alarm never fired when set via /sys/class/rtc/rtc0/wakealarm. The root cause is that the WADA bit (bit 3) in the Extension register (0x1c) was never set before programming the alarm registers.
Per the RX8130 datasheet:
WADA=0 - Week alarm: register 0x19 is compared against day-of-week WADA=1 - Day alarm: register 0x19 is compared against day-of-month
rx8130_set_alarm() always writes a BCD day-of-month value to alarm register 0x19, so WADA must be 1. With WADA=0 the hardware matched the day-of-month value (e.g. 15) as a day-of-week index, which is always out of range (valid weekdays are 0-6), so the alarm interrupt was never asserted.
Fix by setting the WADA bit in rx8130_set_alarm() before writing the Extension register back to the device.
This is consistent with rx8130_read_alarm(), which decodes the same register under the same assumption (24-hour and day-of-month mode).
--- drivers/rtc/rtc-ds1307.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ds1307.c +1 -1
@@ -656,7 +656,7 @@ static int rx8130_set_alarm(struct device *dev, struct rtc_wkalrm *t)if (ret <0 )return ret; - ctl[0 ] &=RX8130_REG_EXTENSION_WADA ; + ctl[0 ] |=RX8130_REG_EXTENSION_WADA ; ctl[1 ] &= ~RX8130_REG_FLAG_AF ; ctl[2 ] &= ~RX8130_REG_CONTROL0_AIE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 264/2857 rtc: brcmstb-waketimer: add missing MODULE_DEVICE_TABLE()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 402c89d28fecd28652a4bfe997f08f6544836381 ]
The driver has an OF match table wired to .of_match_table, but does not export the table with MODULE_DEVICE_TABLE().
Add the missing MODULE_DEVICE_TABLE(of, ...) entry so module alias information is generated for OF based module autoloading.
This is a source-level fix. It does not claim dynamic hardware reproduction; the evidence is the driver-owned match table, its use by the platform driver, and the missing module alias publication.
--- drivers/rtc/rtc-brcmstb-waketimer.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-brcmstb-waketimer.c +1 -0
@@ -310,6 +310,7 @@ static const __maybe_unused struct of_device_id brcmstb_waketmr_of_match[] = { { .compatible = "brcm,brcmstb-waketimer" }, { /* sentinel */ }, }; +MODULE_DEVICE_TABLE (of, brcmstb_waketmr_of_match);static struct platform_driver brcmstb_waketmr_driver = { .probe = brcmstb_waketmr_probe,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 265/2857 fbdev: maxine: fix 64-bit build error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit 3adec5c640dc09dca5605043e138412fd5a0629d ]
The KSEG1ADDR() macro is only defined for non-64BIT builds. Use the CKSEG1ADDR() macro instead.
In file included from ../drivers/video/fbdev/maxinefb.c:34:../drivers/video/fbdev/maxinefb.c: In function 'maxinefb_ims332_write_register':../include/video/maxinefb.h:16:41: error: implicit declaration of function 'KSEG1ADDR'; did you mean 'CKSEG1ADDR'? [-Wimplicit-function-declaration]
16 | #define MAXINEFB_IMS332_ADDRESS KSEG1ADDR(0x1c140000)../drivers/video/fbdev/maxinefb.c:66:49: note: in expansion of macro 'MAXINEFB_IMS332_ADDRESS'
66 | register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;../drivers/video/fbdev/maxinefb.c:66:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
66 | register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
--- include/video/maxinefb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/video/maxinefb.h +2 -2
@@ -13,13 +13,13 @@/* * IMS332 video controller register base address */ -#define MAXINEFB_IMS332_ADDRESS KSEG1ADDR(0x1c140000) +#define MAXINEFB_IMS332_ADDRESS CKSEG1ADDR(0x1c140000)/* * Begin of DECstation 5000/xx onboard framebuffer memory, default resolution * is 1024x768x8 */ -#define DS5000_xx_ONBOARD_FBMEM_START KSEG1ADDR(0x0a000000) +#define DS5000_xx_ONBOARD_FBMEM_START CKSEG1ADDR(0x0a000000)/* * The IMS 332 video controller used in the DECstation 5000/xx series
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 266/2857 fbdev: platinumfb: add error checking for ioremap calls
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: BingKun Yue <[email protected]>
[ Upstream commit ba13226fc966004713aed47931db8922b84d1960 ]
The ioremap() and ioremap_wt() calls in platinumfb_probe() were not checked for failure. If any of these mappings fail, the driver would dereference NULL pointers, leading to a kernel panic.
Add proper error checking and use goto-based cleanup to avoid code duplication across the error paths.
--- drivers/video/fbdev/platinumfb.c | 35 ++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
drivers/video/fbdev/platinumfb.c +29 -6
@@ -570,15 +570,30 @@ static int platinumfb_probe(struct platform_device* odev)/* frame buffer - map only 4MB */ pinfo->frame_buffer_phys = pinfo->rsrc_fb.start; pinfo->frame_buffer =ioremap_wt (pinfo->rsrc_fb.start,0x400000 ); +if (!pinfo->frame_buffer) { +dev_err (&odev->dev,"failed to ioremap frame buffer\n" ); + rc = -ENOMEM ; + goto err_release_fb; + } pinfo->base_frame_buffer = pinfo->frame_buffer;/* registers */ pinfo->platinum_regs_phys = pinfo->rsrc_reg.start; pinfo->platinum_regs =ioremap (pinfo->rsrc_reg.start,0x1000 ); +if (!pinfo->platinum_regs) { +dev_err (&odev->dev,"failed to ioremap registers\n" ); + rc = -ENOMEM ; + goto err_unmap_fb; + } pinfo->cmap_regs_phys =0xf301b000 ;/* XXX not in prom? */ request_mem_region (pinfo->cmap_regs_phys,0x1000 ,"platinumfb cmap" ); pinfo->cmap_regs =ioremap (pinfo->cmap_regs_phys,0x1000 ); +if (!pinfo->cmap_regs) { +dev_err (&odev->dev,"failed to ioremap cmap registers\n" ); + rc = -ENOMEM ; + goto err_release_cmap; + }/* Grok total video ram */ out_be32 (&pinfo->platinum_regs->reg[16 ].r, (unsigned )pinfo->frame_buffer_phys);
@@ -626,13 +641,21 @@ static int platinumfb_probe(struct platform_device* odev)dev_set_drvdata (&odev->dev, info); rc =platinum_init_fb (info); -if (rc !=0 ) { -iounmap (pinfo->frame_buffer); -iounmap (pinfo->platinum_regs); -iounmap (pinfo->cmap_regs); -framebuffer_release (info); - } +if (rc !=0 ) + goto err_unmap_cmap; + +return 0 ; +err_unmap_cmap: +iounmap (pinfo->cmap_regs); +err_release_cmap: +release_mem_region (pinfo->cmap_regs_phys,0x1000 ); +iounmap (pinfo->platinum_regs); +err_unmap_fb: +iounmap (pinfo->frame_buffer); +err_release_fb: +release_mem_region (pinfo->rsrc_fb.start,resource_size (&pinfo->rsrc_fb)); +framebuffer_release (info);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 267/2857 ksmbd: enable TCP keepalive for accepted connections
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 56549c18a4f75309161ca780feaa4d17904e3ee9 ]
A client that disappears without sending a FIN or RST can leave its ksmbd connection in ESTABLISHED indefinitely. ksmbd sets a socket receive timeout, but the connection receive loop retries timeout errors without a limit, so the connection remains in conn_list and consumes the per-IP connection quota.
Enable SO_KEEPALIVE on accepted TCP sockets so the TCP stack can detect a silent peer failure. The keepalive idle time, interval, and probe count remain controlled by the existing TCP sysctl settings.
--- fs/smb/server/transport_tcp.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/smb/server/transport_tcp.c +6 -0
@@ -304,6 +304,12 @@ static int ksmbd_kthread_fn(void *p)ksmbd_debug (CONN ,"connect success: accepted new connection\n" ); client_sk->sk->sk_rcvtimeo =KSMBD_TCP_RECV_TIMEOUT ; client_sk->sk->sk_sndtimeo =KSMBD_TCP_SEND_TIMEOUT ; +/* +* Detect peers that disappear without sending a FIN or RST. +* Otherwise the connection handler can retry receive timeouts +* indefinitely and keep the connection in conn_list. +*/ +sock_set_keepalive (client_sk->sk);ksmbd_tcp_new_connection (client_sk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 268/2857 ACPI: button: Add DMI quirk for Razer Blade Pro 17 early 2020 lid switch
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Everaars <[email protected]>
[ Upstream commit 415125669c2ddc773c579a60df108f75712dfa83 ]
The lid switch reports "close" but can miss the matching "open", leaving _LID closed after resume. systemd-logind then suspends the system again roughly every 35 seconds.
Reading the embedded controller's PSTA byte while _LID is stale shows that bit 0x04 is set, which the DSDT treats as open. The DSDT returns the cached LIDS byte from _LID. Its wake path aborts in RTEC on an unhandled SystemCMOS region before copying PSTA to LIDS.
Initialize the lid state to open on resume, matching the existing quirk for the Razer Blade Stealth 13 late 2019. With button.lid_init_state=open, a physical close suspended once and resume reported open without another suspend.
--- drivers/acpi/button.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/acpi/button.c +11 -0
@@ -121,6 +121,17 @@ static const struct dmi_system_id dmi_lid_quirks[] = { }, .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN, }, + { +/* +* Razer Blade Pro 17 early 2020, notification of the LID device +* only happens on close, not on open and _LID keeps returning closed. +*/ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Razer" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Blade Pro 17 (Early 2020) - RZ09-0329"), + }, + .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN, + }, {/* * Samsung galaxybook2 ,initial _LID device notification returns
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 269/2857 f2fs: avoid setting SBI_NEED_FSCK on transient resize failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 258c95150c26a30db1896eacd3bdef26314f2ca1 ]
When free_segment_range() fails in f2fs_resize_fs(), no on-disk superblock or filesystem metadata has been modified yet, and free_segment_range() safely restores all in-memory counters before returning.
However, the current error recovery path unconditionally sets the SBI_NEED_FSCK flag and prints a scary error message on any error, forcing an unnecessary and time-consuming fsck.f2fs repair on the subsequent mount/reboot.
Fix this by separating the error recovery path with a dedicated recover_user_blocks label to bypass setting SBI_NEED_FSCK on free_segment_range() failures.
--- fs/f2fs/gc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/f2fs/gc.c +6 -3
@@ -2233,7 +2233,7 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)set_sbi_flag (sbi,SBI_IS_RESIZEFS ); err =free_segment_range (sbi, secs, false);if (err) - goto recover_out; + goto recover_user_blocks;update_sb_metadata (sbi, -secs);
@@ -2254,11 +2254,14 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)f2fs_commit_super (sbi, false); } recover_out: -clear_sbi_flag (sbi,SBI_IS_RESIZEFS );if (err) { +f2fs_bug_on (sbi, err == -EAGAIN );set_sbi_flag (sbi,SBI_NEED_FSCK );f2fs_err (sbi,"resize_fs failed, should run fsck to repair!" ); - + } +recover_user_blocks: +clear_sbi_flag (sbi,SBI_IS_RESIZEFS ); +if (err) {spin_lock (&sbi->stat_lock); sbi->user_block_count += shrunk_blocks;spin_unlock (&sbi->stat_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 270/2857 ALSA: usb-audio: Add iD14 MkI to monitor-mix volume quirk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Porter <[email protected]>
[ Upstream commit 17056a36d276a740f09dca723de1bc6aa3eb4ef9 ]
Add the iD14 MkI USB ID to the existing audient_id14_map. This names feature unit 12 Monitor Mix Playback Volume.
Live meter A/B testing on MkI USB ID 2708:0002 reproduced the same asymmetric attenuation seen on MkII. At ALSA value 104, the right channel was 23.07 dB below the left. At 127, both channels were equal.
The misleading Speaker Playback Volume name causes PipeWire to adopt FU12 as the stream master. Reuse the existing map to keep the control available while preventing that selection.
Hardware-tested on Bazzite 7.2.0-ogc4.1.fc44.x86_64 with this change backported. ALSA exposed Monitor Mix Playback Volume after module load and USB reconnect. PipeWire volume changes from 100% to 35% and back left all four FU12 values at 127. Channel-isolated left/right playback remained balanced after reconnect.
Build-tested with CONFIG_SND_USB_AUDIO=m using the focused sound/usb target.
--- sound/usb/mixer_maps.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
sound/usb/mixer_maps.c +13 -8
@@ -505,13 +505,13 @@ static const struct usbmix_connector_map gigabyte_b450_connector_map[] = { {} }; -/* Audient iD14: FU 12 advertises Volume on only 4 of its 6 logical channels -* and sits on the monitor mixer branch, but it is traced through to the -* Speaker output terminal and gets named "Speaker Playback Volume". Userspace -* then adopts it as the stream's hardware volume, and any setting below 0 dB -* attenuates some channels but not others (20 dB imbalance at 80%). Give it a -* non-standard name so that it is no longer taken for the stream's master -* volume, while remaining reachable for anyone who wants the monitor gain. +/* Audient iD14 MkI and MkII: FU 12 sits on the monitor mixer branch but is +* traced through to the Speaker output terminal, so it is named "Speaker +* Playback Volume". On MkII it controls only 4 of 6 playback channels. MkI +* testing found asymmetric attenuation within the main stereo pair. Userspace +* adopts this control as the stream's hardware volume, causing imbalance below +* 0 dB. Give it a non-standard name so that userspace no longer treats it as +* the stream master, while keeping the monitor gain reachable. */ static const struct usbmix_name_map audient_id14_map[] = { {12 ,"Monitor Mix Playback" },/* FU, partial coverage */
@@ -602,7 +602,12 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = { .map = maya44_map, }, { -/* Audient iD14 */ + /* Audient iD14 MkI */ + .id = USB_ID(0x2708, 0x0002), + .map = audient_id14_map, + }, + { + /* Audient iD14 MkII */ .id = USB_ID(0x2708, 0x0008), .map = audient_id14_map, },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 271/2857 scsi: snic: Fix SCSI host leak on workqueue allocation failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Changcheng <[email protected]>
[ Upstream commit 12e67eb89eb2b9516685c744d3f7de0a2d1bd701 ]
In snic_add_host(), if scsi_add_host() succeeds but alloc_ordered_workqueue() fails, the function returns -ENOMEM with shost->work_q left as NULL. The caller's error path then calls snic_del_host(), which returns early when !shost->work_q without calling scsi_remove_host(). The Scsi_Host remains registered in sysfs as a zombie device even after the probe has failed. This causes:
- The leaked host remains visible in /sys/class/scsi_host/ after probe failure, with state "running".
- Subsequent SCSI host numbering is permanently shifted (the leaked host ID from ida_alloc() is never reclaimed).
- Memory leak: the Scsi_Host allocation can never be freed because device_add() took a reference that can only be released by device_del() inside scsi_remove_host().
Fix by adding scsi_remove_host() in the workqueue allocation failure path inside snic_add_host(), undoing the successful scsi_add_host() before returning the error. This is cleaner than modifying snic_del_host() because snic_del_host() is called from a shared error label that also serves paths where snic_add_host() was never invoked.
Reproducer (requires no real SNIC hardware):
- Build CONFIG_SCSI_SNIC=y (built-in)
- Add snic.test_mode=1 snic.inject_wq_fail=1 to kernel cmdline
- Boot with a PCI device matching the snic driver (e.g. QEMU edu device, PCI ID 0x1234:0x11e8, temporarily added to the driver's PCI ID table)
Before the fix:
# /sys/class/scsi_host/ contains a zombie host0: $ cat /sys/class/scsi_host/host0/proc_name snic_scsi $ cat /sys/class/scsi_host/host0/state running # ata_piix gets host1, host2 (host0 stuck): scsi host1: ata_piix scsi host2: ata_piix
After the fix:
# host0 is properly freed and reused by ata_piix: scsi host0: ata_piix scsi host1: ata_piix # No zombie host in /sys/class/scsi_host/
--- drivers/scsi/snic/snic_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/snic/snic_main.c +1 -0
@@ -306,6 +306,7 @@ snic_add_host(struct Scsi_Host *shost, struct pci_dev *pdev)if (!shost->work_q) {SNIC_HOST_ERR (shost,"Failed to Create ScsiHost wq.\n" ); +scsi_remove_host (shost); ret = -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 272/2857 docs: block: fix dead http link in blk-mq.rst
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jenson Johnathon Reggentin <[email protected]>
[ Upstream commit b40a680ea4efe4ef2addada63e304a94d19500d1 ]
The current link http://kernel.dk/blk-mq.pdf leads to a 404 error page.
https://www.kernel.dk/blk-mq.pdf leads to the correct document.
v2 to add the missing www. prefix in the actual file change.
Message-ID: <[email protected]>
--- Documentation/block/blk-mq.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/block/blk-mq.rst +1 -1
@@ -139,7 +139,7 @@ completed. Further reading --------------- -- `Linux Block IO: Introducing Multi-queue SSD Access on Multi-core Systems <http://kernel.dk/blk-mq.pdf>`_ +- `Linux Block IO: Introducing Multi-queue SSD Access on Multi-core Systems <https://www.kernel.dk/blk-mq.pdf>`_ - `NOOP scheduler <https://en.wikipedia.org/wiki/Noop_scheduler>`_
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 273/2857 fbcon: Fix KASAN slab-out-of-bounds Read in fbcon_prepare_logo
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
[ Upstream commit 94e6a058b16820e02f25e1221a4c4e713ba23550 ]
Ensure the logo will not exceed the screen size, which then should fix a reported KASAN: slab-out-of-bounds Read in fbcon_prepare_logo.
--- drivers/video/fbdev/core/fbcon.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/video/fbdev/core/fbcon.c +7 -0
@@ -575,6 +575,13 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, erase &= ~0x400 ; logo_height =fb_prepare_logo (info, par->rotate); logo_lines =DIV_ROUND_UP (logo_height, vc->vc_font.height); + logo_lines =min (logo_lines, rows); + logo_lines =min (logo_lines, new_rows -1 ); +if (logo_lines <=0 ) { + logo_lines =0 ; + logo_shown =FBCON_LOGO_DONTSHOW ; +return ; + } q = (unsigned short *) (vc->vc_origin + vc->vc_size_row * rows); step = logo_lines * cols;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 274/2857 net: stmmac: fix device node reference leaks in stmmac_mtl_setup()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Md Rabbani <[email protected]>
[ Upstream commit 317fe168f4c0fc30e5c375c22d9c8911940aea9b ]
In stmmac_mtl_setup(), q_node is shared across the RX and TX queue parsing loops. When the RX queue loop breaks early because the number of parsed queues reaches plat->rx_queues_to_use, q_node retains an acquired reference count. If the error check passes
(queue == plat->rx_queues_to_use), execution proceeds directly to the TX queue loop, where of_get_next_child() immediately overwrites q_node with the first TX child, permanently leaking the retained RX child device node reference.
Switch both loops to for_each_child_of_node_scoped() so child node references are automatically dropped upon loop exit or early break, and remove the now-unnecessary function-scoped q_node variable and its manual of_node_put() at the exit label.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +2 -4
@@ -132,7 +132,6 @@ static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)static int stmmac_mtl_setup (struct platform_device *pdev,struct plat_stmmacenet_data *plat) { -struct device_node *q_node;struct device_node *rx_node;struct device_node *tx_node;u8 queue =0 ;
@@ -175,7 +174,7 @@ static int stmmac_mtl_setup(struct platform_device *pdev, plat->rx_sched_algorithm =MTL_RX_ALGORITHM_SP ;/* Processing individual RX queue config */ -for_each_child_of_node (rx_node, q_node) { +for_each_child_of_node_scoped (rx_node, q_node) {if (queue >= plat->rx_queues_to_use)break ;
@@ -238,7 +237,7 @@ static int stmmac_mtl_setup(struct platform_device *pdev, queue =0 ;/* Processing individual TX queue config */ -for_each_child_of_node (tx_node, q_node) { +for_each_child_of_node_scoped (tx_node, q_node) {if (queue >= plat->tx_queues_to_use)break ;
@@ -288,7 +287,6 @@ static int stmmac_mtl_setup(struct platform_device *pdev, out:of_node_put (rx_node);of_node_put (tx_node); -of_node_put (q_node);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 275/2857 ALSA: hda/realtek: Add quirk for Lenovo IdeaPad Slim 3 15ABR8
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Heng <[email protected]>
[ Upstream commit be79a45e2ec289eb9fad519e8f5a3d4fc3789dd0 ]
The internal microphone on Lenovo IdeaPad Slim 3 15ABR8 (subsystem 17aa:3862) exhibits severe distortion at default gain levels. The Capture Volume is fixed at 63 (max) and cannot be lowered without explicit userspace intervention. The existing fixup ALC269_FIXUP_LIMIT_INT_MIC_BOOST limits the gain range and resolves the issue.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10417,6 +10417,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x3852 ,"Lenovo Yoga 7 14ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3853 ,"Lenovo Yoga 7 15ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3855 ,"Legion 7 16ITHG6" ,ALC287_FIXUP_LEGION_16ITHG6 ), +SND_PCI_QUIRK (0x17aa ,0x3862 ,"Lenovo IdeaPad Slim 3 15ABR8" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x17aa ,0x3865 ,"Lenovo 13X" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x17aa ,0x3866 ,"Lenovo 13X" ,ALC287_FIXUP_CS35L41_I2C_2 ), SND_PCI_QUIRK(0x17aa, 0x3869, "Lenovo Yoga7 14IAL7", ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 276/2857 ASoC: amd: yc: Add DMI entry for Alienware m18 R1 AMD
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Heng <[email protected]>
[ Upstream commit fd8ed52ecea6b93e23d52cb2758fb4fb4029067f ]
Add DMI entry so the YC machine driver probes on this model and the internal DMIC works.
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -409,6 +409,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m17 R5 AMD"), } }, + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"Alienware" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Alienware m18 R1 AMD"), + } + }, { .driver_data = &acp6x_card, .matches = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 277/2857 HID: multitouch: Fix stale MT slots when contact count drops to zero
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Carey <[email protected]>
[ Upstream commit e8e60b6439eed340a611e9d7a5b9bcbd0ef62725 ]
The INGENIC 17EF:6161 touchscreen (Lenovo Yoga Book 9 14IAH10) reports HID_DG_CONTACTCOUNT=0 in the frame immediately following the last finger lift rather than omitting the frame entirely. In mt_touch_report() the existing code only updates num_expected when contact_count is non-zero, so a zero contact count on the first packet of a new frame leaves num_expected at its previous value (e.g. 2 for a two-finger gesture). The sync check "num_received >= num_expected" then evaluates "0 >= 2" and never fires, preventing INPUT_MT_DROP_UNUSED from releasing the stale slots. Those slots remain active in the kernel MT layer until the next touch, at which point they are released in a batch alongside the new contact — causing the userspace event consumer to miss the intervening finger-up sequence and corrupt its gesture session state.
Fix by resetting num_expected to 0 when contact_count is zero and num_received is still 0 (i.e., this is the first and only packet of the frame, not a continuation packet in a multi-packet sequence). With num_expected=0 the sync check "0 >= 0" fires immediately, calling input_mt_sync_frame() which drops the stale slots via INPUT_MT_DROP_UNUSED.
The num_received==0 guard is critical: continuation packets in a multi-packet frame arrive after at least one contact has already been processed (num_received>0), so they are correctly excluded from this path and the existing multi-packet logic is unaffected.
--- drivers/hid/hid-multitouch.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/hid/hid-multitouch.c +8 -11
@@ -1227,21 +1227,18 @@ static void mt_touch_report(struct hid_device *hid,* Includes multi-packet support where subsequent * packets are sent with zero contactcount. */ -if (contact_count >=0 ) { +if (contact_count >0 ) + app->num_expected = contact_count; +else if (app->num_received ==0 && app->prev_scantime != scantime) {/* +* New multi-report frame: +* * For Win8 PTPs the first packet (td->num_received == 0) may * have a contactcount of 0 if there only is a button event. -* We double check that this is not a continuation packet -* of a possible multi-packet frame be checking that the -* timestamp has changed. +* +* Some other devices use a sentinel frame with 0 to release all contacts */ -if ((app->quirks &MT_QUIRK_WIN8_PTP_BUTTONS ) && - app->num_received ==0 && - app->prev_scantime != scantime) - app->num_expected = contact_count; -/* A non 0 contact count always indicates a first packet */ -else if (contact_count) - app->num_expected = contact_count; + app->num_expected =0 ; } app->prev_scantime = scantime;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 278/2857 tpm: tpm_tis_spi: fix nodef CR50 tpm_tis_spi_resume is null
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Jun <[email protected]>
[ Upstream commit b4d1adc70471d0752bba674552d19971ed9fa869 ]
if no define CONFIG_TCG_TIS_SPI_CR50 in config,
the add of tpm_tis_spi_resume is null, this cause the tpm chip to fail to resume.
--- drivers/char/tpm/tpm_tis_spi.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_tis_spi.h +6 -2
@@ -40,8 +40,12 @@ static inline int cr50_spi_probe(struct spi_device *spi) }#endif -#if defined(CONFIG_PM_SLEEP ) && defined(CONFIG_TCG_TIS_SPI_CR50 ) -extern int tpm_tis_spi_resume (struct device *dev); +#if defined(CONFIG_PM_SLEEP ) +#if defined(CONFIG_TCG_TIS_SPI_CR50 ) +extern int tpm_tis_spi_resume (struct device *dev); +#else +#define tpm_tis_spi_resume tpm_tis_resume +#endif #else #define tpm_tis_spi_resume NULL#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 279/2857 ALSA: usb-audio: Skip mixer creation on M-Audio Venom
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Federico Valentín Andrade <[email protected]>
[ Upstream commit 4c0ec35e011309bd7091053ad5bbc01420967a66 ]
The M-Audio Venom (0763:2084) does not answer any GET_CUR request of its feature units, hanging up the USB microcontroller and "responding" with timeouts. So the mixer building lasts around 47 seconds, and the device does not stream at all.
The same GET_CUR requests issued through libusb (with no kernel driver bound) complete correctly and blazingly fast. So it seems to only happen during the initial probe.
I defined an explicit composite quirk to bypass the mixer creation, as it is not needed (the synth already comes with volume controls).
With both this and the device flag applied, the synth works flawlessly.
--- sound/usb/quirks-table.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
sound/usb/quirks-table.h +22 -0
@@ -1814,6 +1814,28 @@ YAMAHA_DEVICE(0x7010, "UB99"), } } }, +{ +/* +* M-Audio Venom +* +* The AudioControl interface times out on every GET_CUR request, +* which adds around 47 seconds to the card registration and +* freezes the device, blocking streaming. +* Using an explicit composite quirk to skip the mixer entirely. +*/ +USB_DEVICE_VENDOR_SPEC (0x0763 ,0x2084 ), + QUIRK_DRIVER_INFO { + .vendor_name ="M-Audio" , + .product_name = "Venom", + QUIRK_DATA_COMPOSITE { + { QUIRK_DATA_IGNORE(0) }, + { QUIRK_DATA_STANDARD_AUDIO(1) }, + { QUIRK_DATA_STANDARD_AUDIO(2) }, + { QUIRK_DATA_STANDARD_MIDI(3) }, + QUIRK_COMPOSITE_END + } + } +},/* Casio devices */ {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 280/2857 ceph: do not cache negative dentries for snapped directories
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiubo Li <[email protected]>
[ Upstream commit af59562a5b3d34fb3aa7753f2543393578d06dbf ]
When a LOOKUP/LOOKUPSNAP in a snapped directory returns ENOENT without a trace, ceph_finish_lookup() creates a negative dentry via d_add(dentry, NULL). For live directories this is fine — the dentry naturally expires. But for snapped directories, ceph_d_revalidate() unconditionally trusts all cached dentries (valid = 1), so a negative dentry created by a transient error persists forever, hiding entries that genuinely exist in the snapshot.
Only cache negative dentries for live (non-snapshotted) parent directories. For snapped parents, skip the negative dentry so that VFS retries the lookup on the next access. Since the conditions that trigger a negative dentry (MDS transient error, local ENOENT shortcut, or MDS null dentry lease) are all rare in snapped directories, the performance impact of this change is negligible.
--- fs/ceph/dir.c | 10 ++++++++-- fs/ceph/inode.c | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-)
fs/ceph/dir.c +8 -2
@@ -721,8 +721,13 @@ struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,d_drop (dentry); err = -ENOENT ; }else { -if (d_unhashed (dentry)) -d_add (dentry,NULL ); +if (d_unhashed (dentry)) { +struct inode *parent = +d_inode (dentry->d_parent); +if (!parent || +ceph_snap (parent) ==CEPH_NOSNAP ) +d_add (dentry,NULL ); + } } } }
@@ -773,6 +778,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, dentry->d_name.len) && !is_root_ceph_dentry(dir, dentry) && ceph_test_mount_opt(fsc, DCACHE) && + ceph_snap(dir) == CEPH_NOSNAP && __ceph_dir_is_complete(ci) && __ceph_caps_issued_mask_metric(ci, CEPH_CAP_FILE_SHARED, 1)) {__ceph_touch_fmode (ci, mdsc,CEPH_FILE_MODE_RD );
fs/ceph/inode.c +2 -1
@@ -1462,7 +1462,8 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req)ceph_dir_clear_ordered (dir);d_delete (dn); }else if (have_lease) { -if (d_unhashed (dn)) +if (d_unhashed (dn) && +ceph_snap (dir) ==CEPH_NOSNAP )d_add (dn,NULL ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 281/2857 ALSA: hda/conexant: Always enable the headset-mic pin on plugin
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bob Song <[email protected]>
[ Upstream commit 9642a5e843758686e02a7f0d1df9eb0f7f96603c ]
Rename the function to cx_process_headset_detect_plug_type() to reflect that it only reports the detected plug type, and move the pin control write into cx_update_headset_mic_vref() so that node 0x19 is always set to enable the headset mic with the 80% VREF whenever the mic is present, regardless of the type detection result.
--- sound/pci/hda/patch_conexant.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
sound/pci/hda/patch_conexant.c +6 -4
@@ -213,7 +213,7 @@ static void cx_auto_free(struct hda_codec *codec)snd_hda_gen_free (codec); } -static void cx_process_headset_plugin (struct hda_codec *codec) +static void cx_process_headset_detect_plug_type (struct hda_codec *codec) {unsigned int val;unsigned int count =0 ;
@@ -249,10 +249,12 @@ static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_* Check hp&mic tag to process headset plugin & plugout. */ mic_present =snd_hda_codec_read (codec,0x19 ,0 ,AC_VERB_GET_PIN_SENSE ,0x0 ); -if (!(mic_present &AC_PINSENSE_PRESENCE ))/* mic plugout */ +if (!(mic_present &AC_PINSENSE_PRESENCE )) {/* mic plugout */ snd_hda_codec_write (codec,0x19 ,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL ,0x20 ); -else -cx_process_headset_plugin (codec); + }else { +cx_process_headset_detect_plug_type (codec); +snd_hda_codec_write (codec,0x19 ,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL ,0x24 ); + } }#ifdef CONFIG_PM
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 282/2857 netfilter: tproxy: use DEBUG_NET_WARN_ON_ONCE for protocol fallbacks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit 1f0391aea883e99d402d0f77ba3530e4e879350d ]
Replace WARN_ON calls with DEBUG_NET_WARN_ON_ONCE in the default switch blocks of nf_tproxy_get_sock_v4 and v6. Unsupported transport protocols are already safely handled by returning a NULL socket pointer. This prevents unnecessary system panics when panic_on_warn=1 is enabled in production systems.
--- net/ipv4/netfilter/nf_tproxy_ipv4.c | 2 +- net/ipv6/netfilter/nf_tproxy_ipv6.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/netfilter/nf_tproxy_ipv4.c +1 -1
@@ -138,7 +138,7 @@ nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb, }break ;default : -WARN_ON (1 ); +DEBUG_NET_WARN_ON_ONCE (1 ); sk =NULL ; }
net/ipv6/netfilter/nf_tproxy_ipv6.c +1 -1
@@ -137,7 +137,7 @@ nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff, }break ;default : -WARN_ON (1 ); +DEBUG_NET_WARN_ON_ONCE (1 ); sk =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 283/2857 ksmbd: handle allocated range queries on dense files
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 350684e0498512d06963858b810101f58563810b ]
FSCTL_QUERY_ALLOCATED_RANGES currently relies on SEEK_DATA and SEEK_HOLE for every file. That works for files with holes, but it is not a good match for dense files.
A zeroed range in a dense file may be represented as an unwritten extent and skipped by SEEK_DATA. The server can then return no allocated ranges even though the file should still be treated as allocated from the protocol point of view.
For dense files, report the requested range clipped to EOF as allocated instead of probing holes. Keep using SEEK_DATA and SEEK_HOLE for files marked with FILE_ATTRIBUTE_SPARSE_FILE, and wait for writeback before probing so punch-hole updates are visible to the filesystem seek implementation.
This fixes the case where a query after zeroing data could return no ranges for a dense file.
--- fs/smb/server/vfs.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
fs/smb/server/vfs.c +26 -3
@@ -1031,7 +1031,8 @@ int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length, {struct file *f = fp->filp;struct inode *inode =file_inode (fp->filp); -loff_t maxbytes = (u64 )inode->i_sb->s_maxbytes, end; +loff_t maxbytes = (u64 )inode->i_sb->s_maxbytes, end, query_start; +loff_t query_length, size;loff_t extent_start, extent_end;int ret =0 ;
@@ -1047,11 +1048,33 @@ int ksmbd_vfs_fqar_lseek(struct ksmbd_file *fp, loff_t start, loff_t length,if (length > maxbytes || (maxbytes - length) < start) length = maxbytes - start; -if (start + length > inode->i_size) - length = inode->i_size - start; + size =i_size_read (inode); +if (start >= size) +return 0 ; + +if (!length) +return 0 ; + +if (start + length > size) + length = size - start; *out_count =0 ; + query_start = start; + query_length = length; end = start + length; +if (!(fp->f_ci->m_fattr &FILE_ATTRIBUTE_SPARSE_FILE_LE )) { + ranges[0 ].file_offset =cpu_to_le64 (query_start); + ranges[0 ].length =cpu_to_le64 (query_length); + *out_count =1 ; +return 0 ; + } + +if (start < end) { + ret =file_write_and_wait_range (f, start, end -1 ); +if (ret) +return ret; + } +while (start < end && *out_count < in_count) { extent_start =vfs_llseek (f, start,SEEK_DATA );if (extent_start <0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 284/2857 HID: i2c-hid: Add i2c-hid-quirk-bad-input-size quirk for 0911:5288 device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Youth Cao <[email protected]>
[ Upstream commit 58d97b45f3f43af0afd9c74e8480d22d36fd3f72 ]
I have recently acquired a cheap Apollo Lake-based laptop that uses a Hynitron CST128-A touchpad controller. While booting from a Debian LiveCD, the kernel log is flooded with the following error (though the touchpad works well):
i2c_hid_acpi i2c-ALPS0001:00: i2c_hid_get_input: incomplete report (27/42405)
The CST128-A was identified via ACPI as ALPS0001:00, and the I2C HID device ID (0911:5288) was shared with the Hantick 5288.
Add the I2C_HID_QUIRK_BAD_INPUT_SIZE quirk option to the existing Hantick 5288 quirk entry to suppress the kernel log flood.
--- drivers/hid/i2c-hid/i2c-hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/i2c-hid/i2c-hid-core.c +1 -1
@@ -125,7 +125,7 @@ static const struct i2c_hid_quirks { {USB_VENDOR_ID_WEIDA ,HID_ANY_ID , I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, - I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, + I2C_HID_QUIRK_NO_IRQ_AFTER_RESET | I2C_HID_QUIRK_BAD_INPUT_SIZE }, { I2C_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15, I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_3118,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 285/2857 nvme-fc: do not warn on controller removal race
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maurizio Lombardi <[email protected]>
[ Upstream commit 62b70e6c87121ae5b79ca20c3a5b005590336ec5 ]
In nvme_fc_reconnect_or_delete(), the system attempts to remove the controller when reconnect limits are reached by calling nvme_delete_ctrl(). This call is currently wrapped in a WARN_ON().
If a user concurrently deletes the controller via sysfs, the controller's state may have already transitioned out of the CONNECTING state. When this happens, nvme_delete_ctrl() correctly rejects the operation and returns -EBUSY. Because of the WARN_ON() wrapper, this race condition triggers an unnecessary kernel warning stack trace.
Remove the WARN_ON() macro around nvme_delete_ctrl(); this allows the system to safely ignore the -EBUSY return value if the controller is already being deleted.
--- drivers/nvme/host/fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/fc.c +1 -1
@@ -3332,7 +3332,7 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) ctrl->cnum,min_t (int, portptr->dev_loss_tmo, (ctrl->ctrl.opts->max_reconnects * ctrl->ctrl.opts->reconnect_delay))); -WARN_ON (nvme_delete_ctrl (&ctrl->ctrl)); +nvme_delete_ctrl (&ctrl->ctrl); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 286/2857 HID: roccat: fix locking in roccat_connect() and roccat_disconnect()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Antipov <[email protected]>
[ Upstream commit d76994443eed0af297cb82bd038ae9d76327ef90 ]
Extend critical section in roccat_connect() to ensure that partially initialized 'struct roccat_device' is never exposed in 'devices' list, and do the same in roccat_disconnect() to avoid racy 'devices' access against roccat_release().
--- drivers/hid/hid-roccat.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/hid/hid-roccat.c +3 -5
@@ -344,8 +344,6 @@ int roccat_connect(struct class *klass, struct hid_device *hid, int report_size)return temp; } -mutex_unlock (&devices_lock); -init_waitqueue_head (&device->wait);INIT_LIST_HEAD (&device->readers);mutex_init (&device->readers_lock);
@@ -356,6 +354,7 @@ int roccat_connect(struct class *klass, struct hid_device *hid, int report_size) device->cbuf_end =0 ; device->report_size = report_size; +mutex_unlock (&devices_lock);return minor; }EXPORT_SYMBOL_GPL (roccat_connect);
@@ -369,15 +368,12 @@ void roccat_disconnect(int minor)mutex_lock (&devices_lock); device = devices[minor]; -mutex_unlock (&devices_lock); device->exist =0 ;/* TODO exist maybe not needed */ device_destroy (device->dev->class,MKDEV (roccat_major, minor)); -mutex_lock (&devices_lock); devices[minor] =NULL ; -mutex_unlock (&devices_lock);if (device->open) {hid_hw_close (device->hid);
@@ -385,6 +381,8 @@ void roccat_disconnect(int minor) }else {roccat_free_device (device); } + +mutex_unlock (&devices_lock); }EXPORT_SYMBOL_GPL (roccat_disconnect);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 287/2857 ASoC: amd: yc: Add Lenovo ThinkPad E16 Gen 2 (21JN) to quirks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seiji Adachi <[email protected]>
[ Upstream commit 4cae4ca34992d210d115e8e891f1e88c9df5f24c ]
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -234,6 +234,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "21J6"), } }, + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "21JN"), + } + }, { .driver_data = &acp6x_card, .matches = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 288/2857 gpio: mvebu: keep resume masks within the irqchip cache
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 02af7eac17bc62a72335c1fc8c4af4471654f6cc ]
mvebu_gpio_resume() writes the edge/level mask registers saved at suspend time straight back to hardware, bypassing the irqchip's mask_cache_priv. genirq skips mask_irq() for a line it already considers masked, so restoring a bit in hardware that genirq thinks is still masked leaves that line unmasked behind genirq's back. An asserted level line then has nobody to ack it, and the moment interrupts are re-enabled the chained handler storms, hanging resume.
AND the restored mask values with the matching irqchip mask cache so only lines genirq currently considers unmasked are unmasked again. Read the caches under gc->lock to keep them consistent with the mask/unmask handlers.
Tested on Helios4 (armhf): 5 suspend cycles woken by magic packet, no hang; mvebu_gpio_resume() returns in 6 usecs.
--- drivers/gpio/gpio-mvebu.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-)
drivers/gpio/gpio-mvebu.c +27 -6
@@ -1011,6 +1011,8 @@ static int mvebu_gpio_suspend(struct platform_device *pdev, pm_message_t state)static int mvebu_gpio_resume (struct platform_device *pdev) {struct mvebu_gpio_chip *mvchip =platform_get_drvdata (pdev); +u32 edge_cache = ~0U , level_cache = ~0U ; +unsigned long flags;int i; regmap_write(mvchip->regs, GPIO_OUT_OFF + mvchip->offset,
@@ -1022,32 +1024,51 @@ static int mvebu_gpio_resume(struct platform_device *pdev)regmap_write (mvchip->regs,GPIO_IN_POL_OFF + mvchip->offset, mvchip->in_pol_reg); +/* +* genirq skips mask_irq() for a line it already considers masked, so +* unmasking one behind its back leaves an asserted level line that +* nobody masks. Restore only bits the irqchip cache still has set. +* +* Snapshot the caches under the raw spinlock, but release it before +* the regmap writes below: regmap_write() takes a sleepable lock on +* PREEMPT_RT. +*/ +if (mvchip->domain) { +struct irq_chip_generic *gc; + + gc =irq_get_domain_generic_chip (mvchip->domain,0 ); +raw_spin_lock_irqsave (&gc->lock, flags); + level_cache = gc->chip_types[0 ].mask_cache_priv; + edge_cache = gc->chip_types[1 ].mask_cache_priv; +raw_spin_unlock_irqrestore (&gc->lock, flags); + } +switch (mvchip->soc_variant) {case MVEBU_GPIO_SOC_VARIANT_ORION :case MVEBU_GPIO_SOC_VARIANT_A8K :regmap_write (mvchip->regs,GPIO_EDGE_MASK_OFF + mvchip->offset, - mvchip->edge_mask_regs[0 ]); + mvchip->edge_mask_regs[0 ] & edge_cache);regmap_write (mvchip->regs,GPIO_LEVEL_MASK_OFF + mvchip->offset, - mvchip->level_mask_regs[0 ]); + mvchip->level_mask_regs[0 ] & level_cache);break ;case MVEBU_GPIO_SOC_VARIANT_MV78200 :for (i =0 ; i <2 ; i++) {regmap_write (mvchip->regs,GPIO_EDGE_MASK_MV78200_OFF (i), - mvchip->edge_mask_regs[i]); + mvchip->edge_mask_regs[i] & edge_cache);regmap_write (mvchip->regs,GPIO_LEVEL_MASK_MV78200_OFF (i), - mvchip->level_mask_regs[i]); + mvchip->level_mask_regs[i] & level_cache); }break ;case MVEBU_GPIO_SOC_VARIANT_ARMADAXP :for (i =0 ; i <4 ; i++) {regmap_write (mvchip->regs,GPIO_EDGE_MASK_ARMADAXP_OFF (i), - mvchip->edge_mask_regs[i]); + mvchip->edge_mask_regs[i] & edge_cache);regmap_write (mvchip->regs,GPIO_LEVEL_MASK_ARMADAXP_OFF (i), - mvchip->level_mask_regs[i]); + mvchip->level_mask_regs[i] & level_cache); }break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 289/2857 ASoC: amd: yc: Add DMI quirk for Lenovo V15 G6 ARP
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Ortiz <[email protected]>
[ Upstream commit d395e1b62d9694f2e4add9122f8d473eacd374aa ]
The Lenovo V15 G6 ARP (product name 83UU) uses the ACP6x PDM interface for its internal digital microphone array. Its firmware exposes neither the AcpDmicConnected _DSD property nor the _WOV method, so acp6x_probe() falls through to the DMI check and returns -ENODEV, leaving acp_yc_mach.0 unbound and no capture device registered.
Add a DMI quirk entry for this model. With it, the machine driver binds and the DMIC capture device is created:
acp_yc_mach acp_yc_mach.0: Enabling ACP DMIC support via DMI card 2: acp6x [acp6x], device 0: DMIC capture dmic-hifi-0
Capture was verified working with arecord and PipeWire.
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -360,6 +360,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "83Q3"), } }, + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "83UU"), + } + }, { .driver_data = &acp6x_card, .matches = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 290/2857 ASoC: Intel: bytcr_rt5651: Add quirk for Chuwi Hi8 with generic DMI strings
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jasper Firth <[email protected]>
[ Upstream commit c5a8fc2abe05cf6db71f57ff0177fddc59861a1a ]
Some Chuwi Hi8 tablets with model number CWI513 ship with a BIOS (American Megatrends 5.11, dated 05/21/2016) whose DMI sys_vendor and product_name are both "Default string". The tested unit is labelled just "Hi8", but its model number is the same as the existing "Chuwi Hi8 Pro (CWI513)" entry, and it needs the same quirks. That entry matches on sys_vendor "Hampoo" and product_name "X1D3_C806N", so it never applies to these units.
Without its quirks the internal speaker, whose amplifier has a differential input wired across LOUT left and right, cancels to a faint distorted residual for any centred (L == R) content, and the headphone channels are swapped.
Add an entry matching board_vendor "Hampoo" and board_name "Cherry Trail CR", plus the BIOS date since those two are too generic on their own. drivers/platform/x86/touchscreen_dmi.c already matches the Chuwi HiBook the same way.
The quirks are those of the existing Hi8 Pro entry, except for the over-current detection scale factor: 1.0 instead of the 0.75 from BYT_RT5651_DEFAULT_QUIRKS. With 0.75 and a CTIA headset (inline mic and one button), loud speech into the mic, and headphone playback coupling onto the mic line, were reported as spurious KEY_PLAYPAUSE presses, one of them held for a whole 8 second speech window. With 1.0 the same test gave no spurious events, and 3 real button presses were reported as exactly 3 press/release pairs.
Tested on a unit with the generic DMI strings, with a module built from this patch and no quirk module parameter. The quirks were applied via the new entry, the card components read "cfg-spk:1 cfg-mic:in2 cfg-hp:lrswap", and the following all work: speaker, headphone left/right order, jack and headset-mic detection, headset button, and the internal and headset mics.
The problem was diagnosed with the help of an AI coding assistant, which also drafted this changelog.
--- sound/soc/intel/boards/bytcr_rt5651.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
sound/soc/intel/boards/bytcr_rt5651.c +17 -0
@@ -409,6 +409,23 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = {BYT_RT5651_HP_LR_SWAPPED | BYT_RT5651_MONO_SPEAKER), }, + { +/* Chuwi Hi8 (CWI513) with a BIOS using generic DMI strings */ + .callback = byt_rt5651_quirk_cb, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"Hampoo" ), +DMI_MATCH (DMI_BOARD_NAME ,"Cherry Trail CR" ), +/* Above matches are too generic, add bios-date match */ + DMI_MATCH(DMI_BIOS_DATE, "05/21/2016"), + }, + .driver_data = (void *)(BYT_RT5651_MCLK_EN | +BYT_RT5651_JD1_1 | +BYT_RT5651_OVCD_TH_2000UA | +BYT_RT5651_OVCD_SF_1P0 | +BYT_RT5651_IN2_MAP | +BYT_RT5651_HP_LR_SWAPPED | + BYT_RT5651_MONO_SPEAKER), + }, {/* Chuwi Vi8 Plus (CWI519) */ .callback = byt_rt5651_quirk_cb,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 291/2857 ALSA: hda/realtek: Limit internal mic boost on HP Pavilion 15 (103c:2164)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hernan Ganzo <[email protected]>
[ Upstream commit 786fb6b3f513937f712db5a9ba6a12cbc6982ba9 ]
The HP Pavilion 15 with the ALC3227 codec (SSID 103c:2164) exposes the full four-step internal mic boost on pin 0x12: nsteps=3 with stepsize=0x2f, that is 0, 12, 24 and 36 dB. Combined with the ADC capture gain of +30 dB the analogue cascade reaches 66 dB, and the internal microphone clips on the ambient noise of a quiet room; the upper two steps are unusable at any useful input level. This is the defect class ALC269_FIXUP_LIMIT_INT_MIC_BOOST exists for.
The machine matches no SSID quirk and falls through to the pin table, which selects ALC269_FIXUP_HP_MUTE_LED_MIC1 through a pin signature shared with several other HP models. Add an SSID entry instead, using ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED: the existing fixup that applies alc269_fixup_limit_int_mic_boost() and chains to the same mute LED fixup, as already done for 103c:218b. The boost becomes 0 or 12 dB and the LED handling is unchanged.
Tested on the affected machine by selecting the same fixup through the model string (snd-hda-intel.model), which bypasses the SSID and pin tables, with the driver confirming the selection:
snd_hda_codec_alc269 hdaudioC1D0: ALC3227: picked fixup limit-mic-boost (model specified)
With that, Internal Mic Boost reports Limits 0 - 1 (0 or 12 dB) instead of 0 - 3 (0 to 36 dB), so alc269_fixup_limit_int_mic_boost() clamps this codec's internal mic pin as intended. Note that /proc/asound/card1/codec#0 keeps printing the unclamped hardware caps (nsteps=0x03): that file reads codec parameters uncached by design, while the fixup overrides the driver's cached parameter that the control is built from.
This does not by itself make the default capture volume sane -- the remaining 12 dB on top of the +30 dB ADC gain is still hotter than this machine's usable operating point. It removes the two unusable steps from the hardware range, which is what a quirk of this class can do.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9860,6 +9860,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1028 ,0x164b ,"Dell" ,ALC293_FIXUP_DELL1_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x103c ,0x1586 ,"HP" ,ALC269_FIXUP_HP_MUTE_LED_MIC2 ),SND_PCI_QUIRK (0x103c ,0x18e6 ,"HP" ,ALC269_FIXUP_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x2164 ,"HP Pavilion 15 Notebook PC" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED ),SND_PCI_QUIRK (0x103c ,0x218b ,"HP" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED ),SND_PCI_QUIRK (0x103c ,0x21f9 ,"HP" ,ALC269_FIXUP_HP_MUTE_LED_MIC1 ), SND_PCI_QUIRK(0x103c, 0x2210, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 292/2857 ALSA: usb-audio: Add mixer mapping for MSI MAG B850M MORTAR WIFI
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Bojanowski <[email protected]>
[ Upstream commit 7b457ae8cf711831f19d20963f5ed2fdf4842d3a ]
The USB audio device 0db0:cc78 (Realtek ALC4080) on the MSI MAG B850M MORTAR WIFI motherboard exposes all playback controls as "PCM", which makes it hard to tell the outputs apart.
Its mixer layout matches the one of the MSI MPG X570S Carbon Max Wifi (units 29, 30 and 32), so reuse msi_mpg_x570s_carbon_max_wifi_alc4080_map for this device too. With the mapping applied, the controls show up as "Speaker", "Front Headphone" and "IEC958".
Tested with a patched snd-usb-audio module on a 7.2.7 kernel.
--- sound/usb/mixer_maps.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/usb/mixer_maps.c +4 -0
@@ -718,6 +718,10 @@ static const struct usbmix_ctl_map usbmix_ctl_maps[] = { .id = USB_ID(0x0db0, 0xa073), .map = msi_mpg_x570s_carbon_max_wifi_alc4080_map, }, + {/* MSI MAG B850M MORTAR WIFI */ + .id = USB_ID(0x0db0, 0xcc78), + .map = msi_mpg_x570s_carbon_max_wifi_alc4080_map, + }, {/* MSI TRX40 */ .id = USB_ID(0x0db0, 0x543d), .map = trx40_mobo_map,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 293/2857 ALSA: hda/realtek: Add mute LED quirk for HP Pavilion 15-ec1xxx
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luis Banha <[email protected]>
[ Upstream commit 775aa96c310d59f3d15a6e5a9bd1796fd1ba95ec ]
The mute LED on the HP Pavilion Gaming Laptop 15-ec1xxx (103c:87b2) does not work automatically. Add the ALC285_FIXUP_HP_MUTE_LED quirk to fix this behavior.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9972,6 +9972,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x8786 ,"HP OMEN 15" ,ALC285_FIXUP_HP_MUTE_LED ),SND_PCI_QUIRK (0x103c ,0x8787 ,"HP OMEN 15" ,ALC285_FIXUP_HP_MUTE_LED ),SND_PCI_QUIRK (0x103c ,0x8788 ,"HP OMEN 15" ,ALC285_FIXUP_HP_MUTE_LED ), +SND_PCI_QUIRK (0x103c ,0x87b2 ,"HP Pavilion Gaming Laptop 15-ec1xxx" ,ALC285_FIXUP_HP_MUTE_LED ),SND_PCI_QUIRK (0x103c ,0x87b7 ,"HP Laptop 14-fq0xxx" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x87c8 ,"HP" ,ALC287_FIXUP_HP_GPIO_LED ), SND_PCI_QUIRK(0x103c, 0x87cb, "HP Pavilion 15-eg0xxx", ALC287_FIXUP_HP_GPIO_LED),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 294/2857 ALSA: hda/realtek: Add quirk for HP ENVY 13-aq1xxx
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tarun Noonemunthala <[email protected]>
[ Upstream commit a01a223bd685be42e908d970de32eeb3646097f3 ]
The HP ENVY Laptop 13-aq1xxx (PCI SSID 103c:86ad) uses an ALC285 codec with two speaker pairs: front (pin 0x14) and bottom (pin 0x17).
The BIOS leaves pin 0x14 as [N/A] ("not connected"), so the generic parser never enables the front pair and only the bottom speakers are audible. The vendor driver (RTKVHD64.sys) programs that pin with the value 0x90170150 and runs the HP amplifier initialization, which is already implemented in the driver as ALC285_FIXUP_HP_GPIO_AMP_INIT.
Add a board fixup that applies the pin configuration for 0x14 and chains to the existing amplifier init fixup.
The pin value was recovered from the vendor driver's own configuration data. The patch and this changelog were prepared with an AI coding assistant (see the Assisted-by tag below); the change was reviewed and tested by the submitter on the affected machine.
Tested on an HP ENVY 13-aq1xxx by rebuilding snd-hda-codec-alc269 from the Fedora 7.1.10 source and loading it: the codec now reports "line_outs=2 (0x14/0x17)", pin 0x14 comes up as an output (Pin-ctls 0x40) with its amplifier unmuted, and both speaker pairs play.
--- sound/pci/hda/patch_realtek.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/pci/hda/patch_realtek.c +11 -0
@@ -7375,6 +7375,7 @@ enum {ALC285_FIXUP_HP_SPECTRE_X360_EB1 ,ALC285_FIXUP_HP_SPECTRE_X360_DF1 ,ALC285_FIXUP_HP_ENVY_X360 , +ALC285_FIXUP_HP_ENVY_13AQ ,ALC288_FIXUP_DELL_HEADSET_MODE ,ALC288_FIXUP_DELL1_MIC_NO_PRESENCE , ALC288_FIXUP_DELL_XPS_13,
@@ -9388,6 +9389,15 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC285_FIXUP_HP_GPIO_AMP_INIT, }, + [ALC285_FIXUP_HP_ENVY_13AQ] = { + .type = HDA_FIXUP_PINS, + .v.pins = (const struct hda_pintbl []) { + {0x14 ,0x90170150 },/* front speakers */ + { } + }, + .chained = true, + .chain_id = ALC285_FIXUP_HP_GPIO_AMP_INIT, + }, [ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = { .type = HDA_FIXUP_FUNC, .v.func = alc285_fixup_ideapad_s740_coef,
@@ -9944,6 +9954,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x861f ,"HP Elite Dragonfly G1" ,ALC285_FIXUP_HP_GPIO_AMP_INIT ),SND_PCI_QUIRK (0x103c ,0x864f ,"HP Laptop 15-dy0xxx" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x869d ,"HP" ,ALC236_FIXUP_HP_MUTE_LED ), +SND_PCI_QUIRK (0x103c ,0x86ad ,"HP ENVY 13-aq1xxx" ,ALC285_FIXUP_HP_ENVY_13AQ ),SND_PCI_QUIRK (0x103c ,0x86c1 ,"HP Laptop 15-da3001TU" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x86c7 ,"HP Envy AiO 32" ,ALC274_FIXUP_HP_ENVY_GPIO ), SND_PCI_QUIRK(0x103c, 0x86c8, "HP Laptop 14s-dr1xxx", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 295/2857 ALSA: hda/realtek: Add quirk for Acer Nitro AN515-45
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Heng <[email protected]>
[ Upstream commit 0d90a929836344f1d3b39f22f08ccecc62378a59 ]
The Acer Nitro AN515-45 requires ALC2XX_FIXUP_HEADSET_MIC to make the headset microphone work properly.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9796,6 +9796,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1025 ,0x142b ,"Acer Swift SF314-42" ,ALC255_FIXUP_ACER_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1025 ,0x1430 ,"Acer TravelMate B311R-31" ,ALC256_FIXUP_ACER_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1025 ,0x1466 ,"Acer Aspire A515-56" ,ALC255_FIXUP_ACER_HEADPHONE_AND_MIC ), +SND_PCI_QUIRK (0x1025 ,0x151e ,"Acer Nitro AN515-45" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1025 ,0x1534 ,"Acer Predator PH315-54" ,ALC255_FIXUP_ACER_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1028 ,0x0470 ,"Dell M101z" ,ALC269_FIXUP_DELL_M101Z ), SND_PCI_QUIRK(0x1028, 0x053c, "Dell Latitude E5430", ALC292_FIXUP_DELL_E7X),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 296/2857 ALSA: hda/realtek: Add mute LED quirk for HP Pavilion 14-dv1001TU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: renpanpan <[email protected]>
[ Upstream commit ece609abc95cc0f75e633d93f3d868b030d9a8fe ]
The HP Pavilion 14-dv1001TU (subsystem ID 103c:8987) uses a Realtek ALC287 codec. The mute LED on this machine is controlled by GPIO bit 0x10, which was verified via hda-verb, but the subsystem ID is missing from the quirk table. As a result, the ALC287_FIXUP_HP_GPIO_LED fixup that drives GPIO 0x10 is never applied and the mute LED stays off even though the associated LED class device toggles correctly.
Add the missing SND_PCI_QUIRK entry to map this subsystem ID to ALC287_FIXUP_HP_GPIO_LED so the mute LED works as expected.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10037,6 +10037,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x8975 ,"HP EliteBook x360 840 Aero G9" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x897d ,"HP mt440 Mobile Thin Client U74" ,ALC236_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8981 ,"HP Elite Dragonfly G3" ,ALC245_FIXUP_CS35L41_SPI_4 ), +SND_PCI_QUIRK (0x103c ,0x8987 ,"HP Pavilion 14-dv1001TU" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x898a ,"HP Pavilion 15-eg100" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x898e ,"HP EliteBook 835 G9" ,ALC287_FIXUP_CS35L41_I2C_2 ), SND_PCI_QUIRK(0x103c, 0x898f, "HP EliteBook 835 G9", ALC287_FIXUP_CS35L41_I2C_2),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 297/2857 usb: mtu3: Fix double dereference in TP_printk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Murzin <[email protected]>
[ Upstream commit cfb3293c4573289f11f913611f530ea6b1926d67 ]
Paul reported kernel splat:
[ 0.000000] TRACE EVENT ERROR: Event mtu3_gadget_ep_set_halt has double dereference in TP_printk: &REC->gpd_ring->dma [ 0.000000] ------------[ cut here ]------------ [ 0.000000] Event mtu3_gadget_ep_set_halt has double dereference in TP_printk: &REC->gpd_ring->dma [ 0.000000] WARNING: kernel/trace/trace_events.c:420 at test_double_dereference+0x144/0x14c, CPU#0: swapper/0/0 [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 7.3.0-rc1 #15247 PREEMPT [ 0.000000] Hardware name: linux,dummy-virt (DT) [ 0.000000] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.000000] pc : test_double_dereference+0x144/0x14c [ 0.000000] lr : test_double_dereference+0x144/0x14c [ 0.000000] sp : ffffc80aa7633bf0 [ 0.000000] x29: ffffc80aa7633bf0 x28: ffffc80aa7c0f047 x27: 000508b58019388f [ 0.000000] x26: 0000000000000003 x25: 0000000000000007 x24: ffffc80aa5fceff8 [ 0.000000] x23: ffffc80aa7c0f05a x22: ffffc80aa64edfe8 x21: ffffc80aa7c0fce8 [ 0.000000] x20: ffffc80aa7c0f047 x19: 0000000000000013 x18: 0000000000000001 [ 0.000000] x17: 6572656420656c62 x16: 756f642073616820 x15: 746c61685f746573 [ 0.000000] x14: 0000000000000000 x13: ffff000139d90000 x12: 0000000000000045 [ 0.000000] x11: 00000000000000cf x10: ffff00013f546428 x9 : ffff000139d90000 [ 0.000000] x8 : 3fffffffffffc000 x7 : 0000000000000001 x6 : 0000000000000001 [ 0.000000] x5 : ffff00013f4e6440 x4 : 0000000000000000 x3 : 0000000000000000 [ 0.000000] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffffc80aa764a700 [ 0.000000] Call trace: [ 0.000000] test_double_dereference+0x144/0x14c (P) [ 0.000000] trace_event_raw_init+0x37c/0x5d8 [ 0.000000] event_init+0x34/0xc0 [ 0.000000] trace_event_init+0xec/0x588 [ 0.000000] trace_init+0x24/0x6e0 [ 0.000000] start_kernel+0x4a0/0x8ec [ 0.000000] __primary_switched+0x88/0x90 [ 0.000000] irq event stamp: 0 [ 0.000000] hardirqs last enabled at (0): [<0000000000000000>] 0x0 [ 0.000000] hardirqs last disabled at (0): [<0000000000000000>] 0x0 [ 0.000000] softirqs last enabled at (0): [<0000000000000000>] 0x0 [ 0.000000] softirqs last disabled at (0): [<0000000000000000>] 0x0 [ 0.000000] ---[ end trace 0000000000000000 ]--- [ 0.000000] TRACE EVENT ERROR: Event mtu3_gadget_ep_disable has double dereference in TP_printk: &REC->gpd_ring->dma [ 0.000000] TRACE EVENT ERROR: Event mtu3_gadget_ep_enable has double dereference in TP_printk: &REC->gpd_ring->dma
Which also observed by Mark and myself.
The splat it result of new check introduced by b5cc230af5e5 ("tracing:
Warn when an event dereferences a pointer in TP_printk()") which correctly catches issue with %pad dereferencing the address saved in the ring buffer. TP_fast_assign() logic gets executed when the tracepoint is triggered, however the TP_printk() is executed when the user reads the trace buffer which could be seconds, minutes, hours, days, even months later and nothing guarantee that __entry->gpd_ring pointer will still be pointing to what it was when it was recorded.
Fix the issue by capturing immediate value of gpd_ring.dma when trace point is triggered.
--- drivers/usb/mtu3/mtu3_trace.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/mtu3/mtu3_trace.h +3 -1
@@ -224,6 +224,7 @@ DECLARE_EVENT_CLASS(mtu3_log_ep, __field(unsigned int, flags) __field(unsigned int, direction) __field(struct mtu3_gpd_ring *, gpd_ring) + __field(dma_addr_t, gpd_ring_dma) ),TP_fast_assign ( __assign_str(name, mep->name);
@@ -235,12 +236,13 @@ DECLARE_EVENT_CLASS(mtu3_log_ep, __entry->flags = mep->flags; __entry->direction = mep->is_in; __entry->gpd_ring = &mep->gpd_ring; + __entry->gpd_ring_dma = mep->gpd_ring.dma ), TP_printk("%s: type %s maxp %d slot %d mult %d burst %d ring %p/%pad flags %c:%c%c%c:%c", __get_str(name), usb_ep_type_string(__entry->type), __entry->maxp, __entry->slot, __entry->mult, __entry->maxburst, - __entry->gpd_ring, &__entry->gpd_ring->dma, + __entry->gpd_ring, &__entry->gpd_ring_dma, __entry->flags & MTU3_EP_ENABLED ? 'E' : 'e', __entry->flags & MTU3_EP_STALL ? 'S' : 's', __entry->flags & MTU3_EP_WEDGE ? 'W' : 'w',
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 298/2857 net: usb: qmi_wwan: add Rolling Wireless RN947R
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Reinhard Speyerer <[email protected]>
[ Upstream commit 7375d38364a9aa66fb31716bcefef38aecad75d8 ]
Add Rolling Wireless RN947R 0x9300 composition:
DIAG + ADB + NMEA + MODEM + RMNET + QDSS + ADPL
T: Bus=01 Lev=01 Prnt=01 Port=02 Cnt=02 Dev#= 6 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=33f8 ProdID=9300 Rev= 0.00 S: Manufacturer=Rolling Wireless S: Product=RN947R S: SerialNumber=xxxxxxxxxxx C:* #Ifs= 7 Cfg#= 1 Atr=a0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=usbfs E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 8 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan E: Ad=88(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#=21 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=70 Driver=(none)
E: Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#=22 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=80 Driver=(none)
E: Ad=8a(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/net/usb/qmi_wwan.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/usb/qmi_wwan.c +1 -0
@@ -1455,6 +1455,7 @@ static const struct usb_device_id products[] = { {QMI_FIXED_INTF(0x2692, 0x9025, 4)}, /* Cellient MPL200 (rebranded Qualcomm 05c6:9025) */ {QMI_QUIRK_SET_DTR(0x1546, 0x1342, 4)}, /* u-blox LARA-L6 */ {QMI_QUIRK_SET_DTR(0x33f8, 0x0104, 4)}, /* Rolling RW101 RMNET */ + {QMI_QUIRK_SET_DTR(0x33f8, 0x9300, 8)}, /* Rolling RN947R RMNET */ {QMI_FIXED_INTF(0x2dee, 0x4d22, 5)}, /* MeiG Smart SRM825L */ {QMI_QUIRK_SET_DTR(0x2dee, 0x4d63, 0)}, /* MeiG SRM813Q w/ Modem(PPP) */ {QMI_QUIRK_SET_DTR(0x2dee, 0x4d64, 0)}, /* MeiG SRM813Q w/ NMEA */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 299/2857 ALSA: hda/realtek: Add quirk for ASRock NUC BOX-358H
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eckhart Mohr <[email protected]>
[ Upstream commit 9a44b828dd7c0be1d0d6d6cf178d9727ceb6da6e ]
Fix headphone jack detection for some devices
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10467,6 +10467,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x9e56 ,"Lenovo ZhaoYang CF4620Z" ,ALC286_FIXUP_SONY_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1849 ,0x0269 ,"Positivo Master C6400" ,ALC269VB_FIXUP_ASUS_ZENBOOK ),SND_PCI_QUIRK (0x1849 ,0x1233 ,"ASRock NUC Box 1100" ,ALC233_FIXUP_NO_AUDIO_JACK ), +SND_PCI_QUIRK (0x1849 ,0x6256 ,"ASRock NUC Box 358H" ,ALC233_FIXUP_NO_AUDIO_JACK ),SND_PCI_QUIRK (0x1849 ,0xa233 ,"Positivo Master C6300" ,ALC269_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x19e5 ,0x3204 ,"Huawei MACH-WX9" ,ALC256_FIXUP_HUAWEI_MACH_WX9_PINS ), SND_PCI_QUIRK(0x19e5, 0x320f, "Huawei WRT-WX9 ", ALC256_FIXUP_ASUS_MIC_NO_PRESENCE),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 300/2857 spi: cadence-qspi: Fix status polling with octal DTR chips
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit fd99864b0ac936e870c7ae28354c5cd3dad5efd0 ]
Most SPI NOR chips today use 0x05 as ReaD Status Register (RDSR) opcode. After almost every transaction, the core will wait for the said transation to be digested by the chip by polling its status register. This mechanism has been automated by certain chips, such as the Cadence QSPI controller. Unfortunately, the feature has been disabled for various (relevant) reasons. Disabling this feature has been done by setting WRITE_COMPLETION_CTRL_REG.DISABLE_POLLING_FLD, keeping the rest of the register intact. In this same register, there is also a field named WRITE_COMPLETION_CTRL_REG.OPCODE_FLD, which by default also contains 0x05, as primary RDSR opcode.
As a result, both the SPI NOR and SPI NAND cores, primary users through spi-mem of the spi_mem_ops interface, do send their own RDSR. In this driver, such command goes through one of the fifth possible data path specifically crafted for short register-like commands, named STIG. In STIG mode, the opcode of the operation is written to OSPI_FLASH_CMD_CTRL_REG. This means that the opcode field of STIG configuration and the opcode field of the automatic polling configuration contain the same value.
Unfortunately, the TRM explains in two different places that this configuration is forbidden, without explaining why it is problematic:
$12.4.2.4.11 OSPI Software-Triggered Instruction Generator (STIG)
``` OSPI_FLASH_CMD_CTRL_REG[31-24] CMD_OPCODE_FLD bits should be set different than OSPI_DEV_INSTR_RD_CONFIG_REG[7-0] RD_OPCODE_NON_XIP_FLD and OSPI_DEV_INSTR_WR_CONFIG_REG[7-0] WR_OPCODE_FLD. ```
and
$12.4.2.5.2 Configuring the OSPI Controller for Optimal Use
``` When using the OSPI Controller, the opcodes in OSPI_DEV_INSTR_RD_CONFIG_REG[7-0] RD_OPCODE_NON_XIP_FLD, OSPI_DEV_INSTR_WR_CONFIG_REG[7-0] WR_OPCODE_FLD and OSPI_WRITE_COMPLETION_CTRL_REG[7-0] OPCODE_FLD bit fields shall not match the opcode in the OSPI_FLASH_CMD_CTRL_REG[31-24] CMD_OPCODE_FLD bit field. ```
For some reasons, this is only unveiled now when testing in ODTR mode. Plain SDR modes work flawlessly with the same chips. One possible reason for this, is that the internal data path in ODTR mode is very different due to the extra opcode extension/repetition which may be interpreted differently (this is a wild guess). For sure there is an interference, as even the TRM states that there is some magic happening:
$12.4.2.4.13 OSPI Command Translation
``` The WREN and the RDSR device instructions are the only ones that are sent by the controller under the hood. ```
I cannot probe the bus when the problem arises, so I don't know exactly what is sent on the bus. Practically speaking, the chip was driving the lines low (reading all 0s), which is not the usual default state when the chip is not driving the lines (all 1s). Other people on the mailing list claimed successfully using ODTR chips with this controller. My take here is that either they were using a variant of the IP without write completion at all (there is a quirk for it), or they were using chips slightly more flexible about their opcode sequency or maybe with different addr/dummy requirements.
Clearing the WRITE_COMPLETION_CTRL_REG.OPCODE_FLD while disabling write completion polling entirely seems the best compromise.
--- drivers/spi/spi-cadence-quadspi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-cadence-quadspi.c +1 -2
@@ -954,8 +954,7 @@ static int cqspi_write_setup(struct cqspi_flash_pdata *f_pdata,* care of polling the status register. */ if (cqspi->wr_completion) { - reg =readl (reg_base +CQSPI_REG_WR_COMPLETION_CTRL ); - reg |=CQSPI_REG_WR_DISABLE_AUTO_POLL ; + reg =CQSPI_REG_WR_DISABLE_AUTO_POLL ;writel (reg, reg_base +CQSPI_REG_WR_COMPLETION_CTRL ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 301/2857 ALSA: usb-audio: Add native DSD support for Cambridge Audio streamers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matus Gajdos <[email protected]>
[ Upstream commit 4e1462e7cd6a9b920f441842726cc2b9d232673e ]
The Cambridge Audio streamer advertises the UAC2 RAW_DATA format on altsetting 2 of its playback interface, but without the DSD_RAW quirk flag the driver exposes it only as a SPECIAL format that cannot be used.
Add QUIRK_FLAG_DSD_RAW for the device (USB ID 22e8:ca10), so the altsetting is exposed as DSD_U32_BE, enabling native DSD64/128/256 playback.
Tested with: gst-launch-1.0 filesrc location=file.dsf ! \
avdemux_dsf ! dsdconvert ! \
alsasink device=hw:2,0--- sound/usb/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/quirks.c +2 -0
@@ -2259,6 +2259,8 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = { QUIRK_FLAG_DSD_RAW),DEVICE_FLG (0x21b4 ,0x0232 ,/* Ayre QX-5 Twenty */ QUIRK_FLAG_DSD_RAW ), +DEVICE_FLG (0x22e8 ,0xca10 ,/* Cambridge Audio streamers */ +QUIRK_FLAG_DSD_RAW ),DEVICE_FLG (0x2522 ,0x0007 ,/* LH Labs Geek Out HD Audio 1V5 */ QUIRK_FLAG_SET_IFACE_FIRST ), DEVICE_FLG(0x262a, 0x9302, /* ddHiFi TC44C */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 302/2857 media: em28xx: use video_unregister_device for radio_dev
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rohinthan P <[email protected]>
[ Upstream commit 2579cbe68005f46fc7f8f95364f6b101b07b9d1c ]
Commit 7c8bf63b7937 ("media: em28xx: use vb2_video_unregister_device") converted device unregistrations in em28xx to use vb2_video_unregister_device() instead of video_unregister_device().
However, radio devices do not have an associated videobuf2 queue (v4l2->radio_dev.queue is NULL). Calling vb2_video_unregister_device() on a radio device triggers a WARNING in vb2_video_unregister_device():
!vdev->queue
WARNING: drivers/media/common/videobuf2/videobuf2-v4l2.c:1264 at vb2_video_unregister_device+0x1f8/0x200
Call Trace:
em28xx_v4l2_init+0x1c39/0x3150 drivers/media/usb/em28xx/em28xx-video.c:3085As documented in vb2_video_unregister_device(), video_unregister_device() should be used instead when vdev->queue is NULL.
Revert to calling video_unregister_device() for v4l2->radio_dev in both em28xx_v4l2_fini() and the em28xx_v4l2_init() error unwind path.
--- drivers/media/usb/em28xx/em28xx-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/em28xx/em28xx-video.c +2 -2
@@ -2243,7 +2243,7 @@ static int em28xx_v4l2_fini(struct em28xx *dev)if (video_is_registered (&v4l2->radio_dev)) {dev_info (&dev->intf->dev,"V4L2 device %s deregistered\n" ,video_device_node_name (&v4l2->radio_dev)); -vb2_video_unregister_device (&v4l2->radio_dev); +video_unregister_device (&v4l2->radio_dev); }if (video_is_registered (&v4l2->vbi_dev)) { dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n",
@@ -2901,7 +2901,7 @@ static int em28xx_v4l2_init(struct em28xx *dev)dev_info (&dev->intf->dev,"V4L2 device %s deregistered\n" ,video_device_node_name (&v4l2->radio_dev)); -vb2_video_unregister_device (&v4l2->radio_dev); +video_unregister_device (&v4l2->radio_dev); }if (video_is_registered (&v4l2->vbi_dev)) { dev_info(&dev->intf->dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 303/2857 Revert "net: stmmac: protect updates of 64-bit statistics counters"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
This reverts commit 52002cae02db6ab4c50efe4095d68db3a6892b11 which is commit 38cc3c6dcc09dc3a1800b5ec22aef643ca11eab8 upstream.
It is reported to have regressions on tegra systems, so drop it for now.
--- drivers/net/ethernet/stmicro/stmmac/common.h | 56 ++------ drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 15 +- drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 15 +- drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c | 15 +- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 15 +- drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 129 ++++++------------ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 133 +++++++++---------- 7 files changed, 157 insertions(+), 221 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +16 -40
@@ -58,50 +58,27 @@#undef FRAME_FILTER_DEBUG/* #define FRAME_FILTER_DEBUG */ -struct stmmac_q_tx_stats { -u64_stats_t tx_bytes; -u64_stats_t tx_set_ic_bit; -u64_stats_t tx_tso_frames; -u64_stats_t tx_tso_nfrags; -}; - -struct stmmac_napi_tx_stats { -u64_stats_t tx_packets; -u64_stats_t tx_pkt_n; -u64_stats_t poll; -u64_stats_t tx_clean; -u64_stats_t tx_set_ic_bit; -}; -struct stmmac_txq_stats { -/* Updates protected by tx queue lock. */ -struct u64_stats_sync q_syncp; -struct stmmac_q_tx_stats q; - -/* Updates protected by NAPI poll logic. */ -struct u64_stats_sync napi_syncp; -struct stmmac_napi_tx_stats napi; +u64 tx_bytes; +u64 tx_packets; +u64 tx_pkt_n; +u64 tx_normal_irq_n; +u64 napi_poll; +u64 tx_clean; +u64 tx_set_ic_bit; +u64 tx_tso_frames; +u64 tx_tso_nfrags; +struct u64_stats_sync syncp; }____cacheline_aligned_in_smp ; -struct stmmac_napi_rx_stats { -u64_stats_t rx_bytes; -u64_stats_t rx_packets; -u64_stats_t rx_pkt_n; -u64_stats_t poll; -}; -struct stmmac_rxq_stats { -/* Updates protected by NAPI poll logic. */ -struct u64_stats_sync napi_syncp; -struct stmmac_napi_rx_stats napi; -}____cacheline_aligned_in_smp ; - -/* Updates on each CPU protected by not allowing nested irqs. */ -struct stmmac_pcpu_stats { +u64 rx_bytes; +u64 rx_packets; +u64 rx_pkt_n; +u64 rx_normal_irq_n; +u64 napi_poll;struct u64_stats_sync syncp; -u64_stats_t rx_normal_irq_n[MTL_MAX_TX_QUEUES ]; -u64_stats_t tx_normal_irq_n[MTL_MAX_RX_QUEUES ]; -}; +}____cacheline_aligned_in_smp ;/* Extra statistic and debug information exposed by ethtool */ struct stmmac_extra_stats {
@@ -227,7 +204,6 @@ struct stmmac_extra_stats {/* per queue statistics */ struct stmmac_txq_stats txq_stats[MTL_MAX_TX_QUEUES ];struct stmmac_rxq_stats rxq_stats[MTL_MAX_RX_QUEUES ]; -struct stmmac_pcpu_stats __percpu *pcpu_stats;unsigned long rx_dropped;unsigned long rx_errors;unsigned long tx_dropped;
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +8 -7
@@ -440,7 +440,8 @@ static int sun8i_dwmac_dma_interrupt(str struct stmmac_extra_stats *x, u32 chan, u32 dir) { - struct stmmac_pcpu_stats *stats = this_cpu_ptr(priv->xstats.pcpu_stats); + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[chan]; +struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[chan];int ret =0 ;u32 v;
@@ -453,9 +454,9 @@ static int sun8i_dwmac_dma_interrupt(strif (v &EMAC_TX_INT ) { ret |= handle_tx; -u64_stats_update_begin (&stats->syncp); -u64_stats_inc (&stats->tx_normal_irq_n[chan]); -u64_stats_update_end (&stats->syncp); +u64_stats_update_begin (&txq_stats->syncp); + txq_stats->tx_normal_irq_n++; +u64_stats_update_end (&txq_stats->syncp); }if (v &EMAC_TX_DMA_STOP_INT )
@@ -477,9 +478,9 @@ static int sun8i_dwmac_dma_interrupt(strif (v &EMAC_RX_INT ) { ret |= handle_rx; -u64_stats_update_begin (&stats->syncp); -u64_stats_inc (&stats->rx_normal_irq_n[chan]); -u64_stats_update_end (&stats->syncp); +u64_stats_update_begin (&rxq_stats->syncp); + rxq_stats->rx_normal_irq_n++; +u64_stats_update_end (&rxq_stats->syncp); }if (v &EMAC_RX_BUF_UA_INT )
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +8 -7
@@ -171,7 +171,8 @@ int dwmac4_dma_interrupt(struct stmmac_pconst struct dwmac4_addrs *dwmac4_addrs = priv->plat->dwmac4_addrs;u32 intr_status =readl (ioaddr +DMA_CHAN_STATUS (dwmac4_addrs, chan));u32 intr_en =readl (ioaddr +DMA_CHAN_INTR_ENA (dwmac4_addrs, chan)); -struct stmmac_pcpu_stats *stats =this_cpu_ptr (priv->xstats.pcpu_stats); +struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[chan]; +struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[chan];int ret =0 ;if (dir ==DMA_DIR_RX )
@@ -200,15 +201,15 @@ int dwmac4_dma_interrupt(struct stmmac_p }/* TX/RX NORMAL interrupts */ if (likely (intr_status &DMA_CHAN_STATUS_RI )) { -u64_stats_update_begin (&stats->syncp); -u64_stats_inc (&stats->rx_normal_irq_n[chan]); -u64_stats_update_end (&stats->syncp); +u64_stats_update_begin (&rxq_stats->syncp); + rxq_stats->rx_normal_irq_n++; +u64_stats_update_end (&rxq_stats->syncp); ret |= handle_rx; }if (likely (intr_status &DMA_CHAN_STATUS_TI )) { -u64_stats_update_begin (&stats->syncp); -u64_stats_inc (&stats->tx_normal_irq_n[chan]); -u64_stats_update_end (&stats->syncp); +u64_stats_update_begin (&txq_stats->syncp); + txq_stats->tx_normal_irq_n++; +u64_stats_update_end (&txq_stats->syncp); ret |= handle_tx; }
drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c +8 -7
@@ -162,7 +162,8 @@ static void show_rx_process_state(unsignint dwmac_dma_interrupt (struct stmmac_priv *priv,void __iomem *ioaddr,struct stmmac_extra_stats *x,u32 chan,u32 dir) { -struct stmmac_pcpu_stats *stats =this_cpu_ptr (priv->xstats.pcpu_stats); +struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[chan]; +struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[chan];int ret =0 ;/* read the status register (CSR5) */ u32 intr_status =readl (ioaddr +DMA_STATUS );
@@ -214,16 +215,16 @@ int dwmac_dma_interrupt(struct stmmac_pru32 value =readl (ioaddr +DMA_INTR_ENA );/* to schedule NAPI on real RIE event. */ if (likely (value &DMA_INTR_ENA_RIE )) { -u64_stats_update_begin (&stats->syncp); -u64_stats_inc (&stats->rx_normal_irq_n[chan]); -u64_stats_update_end (&stats->syncp); +u64_stats_update_begin (&rxq_stats->syncp); + rxq_stats->rx_normal_irq_n++; +u64_stats_update_end (&rxq_stats->syncp); ret |= handle_rx; } }if (likely (intr_status &DMA_STATUS_TI )) { -u64_stats_update_begin (&stats->syncp); -u64_stats_inc (&stats->tx_normal_irq_n[chan]); -u64_stats_update_end (&stats->syncp); +u64_stats_update_begin (&txq_stats->syncp); + txq_stats->tx_normal_irq_n++; +u64_stats_update_end (&txq_stats->syncp); ret |= handle_tx; }if (unlikely (intr_status &DMA_STATUS_ERI ))
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +8 -7
@@ -333,7 +333,8 @@ static int dwxgmac2_dma_interrupt(struct struct stmmac_extra_stats *x, u32 chan, u32 dir) { - struct stmmac_pcpu_stats *stats = this_cpu_ptr(priv->xstats.pcpu_stats); + struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[chan]; +struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[chan];u32 intr_status =readl (ioaddr +XGMAC_DMA_CH_STATUS (chan));u32 intr_en =readl (ioaddr +XGMAC_DMA_CH_INT_EN (chan));int ret =0 ;
@@ -362,15 +363,15 @@ static int dwxgmac2_dma_interrupt(struct/* TX/RX NORMAL interrupts */ if (likely (intr_status &XGMAC_NIS )) {if (likely (intr_status &XGMAC_RI )) { -u64_stats_update_begin (&stats->syncp); -u64_stats_inc (&stats->rx_normal_irq_n[chan]); -u64_stats_update_end (&stats->syncp); +u64_stats_update_begin (&rxq_stats->syncp); + rxq_stats->rx_normal_irq_n++; +u64_stats_update_end (&rxq_stats->syncp); ret |= handle_rx; }if (likely (intr_status & (XGMAC_TI |XGMAC_TBU ))) { -u64_stats_update_begin (&stats->syncp); -u64_stats_inc (&stats->tx_normal_irq_n[chan]); -u64_stats_update_end (&stats->syncp); +u64_stats_update_begin (&txq_stats->syncp); + txq_stats->tx_normal_irq_n++; +u64_stats_update_end (&txq_stats->syncp); ret |= handle_tx; } }
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +42 -87
170 lines not on this page · raw message
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +67 -66
273 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 304/2857 blk-crypto: fix NULL deref and UAF in __blk_crypto_evict_key()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit c8c53d669d4e45b3a804013251a34387d7e11bfb upstream.
Sashiko reported a possible NULL pointer dereference, triggered by the following flow:
dm-inlinecrypt ctor # first use of the fallback
├─ blk_crypto_init_key() # succeeds, ctx->key.size != 0
├─ blk_crypto_start_using_key()
│ ├─ hw-wrapped key: -EOPNOTSUPP
│ │ # profile never allocated (NULL)
│ └─ raw key: fallback_start_using_mode()
│ └─ blk_crypto_fallback_init() fails
│ └─ kfree(profile) # not NULLed
├─ goto bad
└─ inlinecrypt_dtr() # evicts whenever key.size is set
└─ blk_crypto_evict_key()
└─ blk_crypto_config_supported_natively() = false
└─ blk_crypto_fallback_evict_key()
└─ __blk_crypto_evict_key(blk_crypto_fallback_profile)
└─ profile->num_slots # BOOM!!!This issue can be reproduced using the following commands:
dd if=/dev/zero of=/tmp/backing bs=1M count=64
LOOP=$(losetup -f --show /tmp/backing)
SZ=$(blockdev --getsz $LOOP)
KEY=$(head -c 64 /dev/urandom | od -An -tx1 | tr -d ' \n')
dmsetup create ic --table "0 $SZ inlinecrypt aes-xts-plain64 \
$KEY 0 $LOOP 0 1 keytype:hw-wrapped"And the following oops is triggered:
==================================================================
blk-crypto: loop0: no support for wrapped keys
Oops: general protection fault, probably for non-canonical address
0xdffffc000000000b: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000058-0x000000000000005f]
CPU: 5 UID: 0 PID: 901 Comm: dmsetup 7.3.0-rc3 #1 PREEMPT(lazy)
RIP: 0010:__blk_crypto_evict_key+0x2e/0x3b0
Call Trace:
blk_crypto_evict_key+0x24c/0x320
inlinecrypt_dtr+0xf6/0x160
inlinecrypt_ctr+0x2d3/0xbd0
dm_table_add_target+0x661/0xf40
table_load+0x1c4/0x490
ctl_ioctl+0x32f/0x5f0
dm_ctl_ioctl+0xe/0x20
==================================================================dm-inlinecrypt is the only caller that can evict a key that was never started, as fscrypt frees such a key without evicting it.
Fix this by returning early from blk_crypto_fallback_evict_key() when tfms_inited[] is not set for the key's mode. tfms_inited[] is only set after blk_crypto_fallback_init() has successfully initialized the profile, so the crash above is no longer reachable.
The bug has been latent since commit c984ff1423ae ("blk-crypto:
dynamically allocate fallback profile") was merged in v6.5, and only became actually triggerable when commit e7f57d2c47e2 ("dm-inlinecrypt:
add target for inline block device encryption") was merged in v7.2.
--- block/blk-crypto-fallback.c | 6 ++++++ 1 file changed, 6 insertions(+)
block/blk-crypto-fallback.c +6 -0
@@ -529,6 +529,12 @@ bool blk_crypto_fallback_bio_prep(structint blk_crypto_fallback_evict_key (const struct blk_crypto_key *key) { +/* +* Pairs with smp_store_release() in +* blk_crypto_fallback_start_using_mode() +*/ +if (!smp_load_acquire (&tfms_inited[key->crypto_cfg.crypto_mode])) +return 0 ;return __blk_crypto_evict_key (blk_crypto_fallback_profile, key); }
Greg Kroah-Hartman
maintainerPATCH 305/2857 ceph: fail readdir when the MDS reply carries no dirfrag
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuanfu Xie <[email protected]>
commit 728c856d7da04fb79f7aa00e974ffb6f55e55995 upstream.
A ceph mount oopses in ceph_readdir() when the MDS answers a READDIR request with a reply whose extra blob is empty. parse_reply_info() skips reply blobs whose length is zero, so parse_reply_info_readdir() never runs, r_reply_info.dir_dir stays NULL, and the reply still parses as successful. ceph_mdsc_do_request() returns 0 and ceph_readdir() then reads rinfo->dir_dir->frag with no NULL check:
/* extra */
ceph_decode_32_safe(&p, end, len, bad);
if (len > 0) {
...
err = parse_reply_info_extra(&p, p + len, req, features, s);
...
}The oops on v7.3.0-rc4-00537-ga3ff15db6820, one getdents64(2) on the mount root after an ms_mode=legacy mount, trimmed:
BUG: KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN NOPTI CPU: 1 UID: 0 PID: 266 Comm: ls Tainted: G N 7.3.0-rc4-00537-ga3ff15db6820 #1 PREEMPT(lazy) RIP: 0010:ceph_readdir+0xbff/0x3ea0 Call Trace: <TASK> ? __pfx_ceph_readdir+0x10/0x10 wrap_directory_iterator+0xa2/0xe0 iterate_dir+0x1da/0x5d0 __x64_sys_getdents64+0x13b/0x2a0 do_syscall_64+0xdd/0x4a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
The unconditional frag read came in with 81c6aea5275ea ("ceph: handle frag mismatch between readdir request and reply"), so the bug is old.
Treat a reply with no dirfrag as a protocol violation: warn once, drop the request and return -EIO, the same way ceph_readdir() already handles the two malformed-reply cases later in the function.
Tested on v7.3.0-rc4-00537-ga3ff15db6820 (KASAN). Unpatched, the getdents64(2) above takes the machine down (oops=panic) on the first READDIR reply. With the patch it warns once and getdents64(2) returns -EIO, no oops, no hang. A conformant reply for an empty directory — dirfrag present, zero entries, FRAG_END|FRAG_COMPLETE — still lists "." and ".." and returns EOF on both kernels, so normal readdir behavior is unchanged. The oops is still present in v7.3-rc5 (72d3fcf802c45).
--- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ceph/dir.c +4 -0
@@ -436,6 +436,10 @@ more: (int)req->r_reply_info.hash_order); rinfo = &req->r_reply_info; +if (WARN_ON_ONCE (!rinfo->dir_dir)) { +ceph_mdsc_put_request (req); +return -EIO ; + }if (le32_to_cpu (rinfo->dir_dir->frag) != frag) { frag =le32_to_cpu (rinfo->dir_dir->frag);if (!rinfo->hash_order) {
Greg Kroah-Hartman
maintainerPATCH 306/2857 kcov: ignore an out-of-range comparison count in write_comp_data()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fang Xieyan <[email protected]>
commit f5263bee9eb84d2388fd7555a18d518e17226894 upstream.
write_comp_data() reads the comparison record count from area[0] and uses it to index the coverage buffer:
area = (u64 *)t->kcov_area;
max_pos = t->kcov_size * sizeof(unsigned long);
count = READ_ONCE(area[0]);
/* Every record is KCOV_WORDS_PER_CMP 64-bit words. */
start_index = 1 + count * KCOV_WORDS_PER_CMP;
end_pos = (start_index + KCOV_WORDS_PER_CMP) * sizeof(u64);
if (likely(end_pos <= max_pos)) {The buffer is mmap'd writable into the collecting process, so count is under its control and end_pos <= max_pos is its only bound. A count that wraps the u64 multiply leaves end_pos below max_pos, so the check passes while the record store lands 24 bytes before the buffer, in the unmapped vmalloc guard page, and faults:
BUG: unable to handle page fault for address: ffa0000000b60fe8 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page Oops: 0002 [#1] SMP KASAN NOPTI RIP: 0010:write_comp_data+0x7e/0xa0 ... Kernel panic - not syncing: Fatal exception
Bound count first: only max_pos / (sizeof(u64) * KCOV_WORDS_PER_CMP) records fit, so a larger count is not a valid index and is dropped. kcov_move_area() bounds the same untrusted count this way, and no count the end_pos <= max_pos check accepts reaches that limit, so no valid record is lost.
kcov is a root-only debugfs file (debugfs_create_file_unsafe("kcov", 0600, ...)) and write_comp_data() exists only under CONFIG_KCOV_ENABLE_COMPARISONS, so this is a local, debug-kernel robustness fix: the process corrupts its own buffer and the kernel oopses. It crosses no privilege boundary. Additional details at [1]
--- kernel/kcov.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/kcov.c +8 -0
@@ -252,6 +252,14 @@ static void notrace write_comp_data(u64 count =READ_ONCE (area[0 ]); +/* +* area[0] is writable by the collecting process, so count cannot be +* trusted. Bound it to the records that fit, as kcov_move_area() +* does, so the end_pos multiply below cannot wrap past its check. +*/ +if (count >= max_pos / (sizeof (u64) *KCOV_WORDS_PER_CMP )) +return ; +/* Every record is KCOV_WORDS_PER_CMP 64-bit words. */ start_index =1 + count *KCOV_WORDS_PER_CMP ; end_pos = (start_index +KCOV_WORDS_PER_CMP ) *sizeof (u64);
Greg Kroah-Hartman
maintainerPATCH 307/2857 kcsan: Avoid division by zero in kcsan_prandom_u32_max()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Parri <[email protected]>
commit 99b6fcce87037cfb6b5e177848342e97f5141205 upstream.
KCSAN's skip_watch, udelay_task and udelay_interrupt parameters can be changed at runtime through /sys/module/kcsan/parameters/, where 0 means watching every access or not delaying at all. With the default CONFIG_KCSAN_SKIP_WATCH_RANDOMIZE=y and CONFIG_KCSAN_DELAY_RANDOMIZE=y, writing 0 to any of them makes the next watchpoint setup divide by zero:
# echo 0 > /sys/module/kcsan/parameters/udelay_task Oops: divide error: 0000 [#1] SMP NOPTI CPU: 0 UID: 0 PID: 93 Comm: sh Not tainted 7.3.0-rc5 #3 PREEMPT(lazy) RIP: 0010:kcsan_setup_watchpoint+0x1b5/0x410 Code: ... 65 89 05 ad 8d 98 02 d3 ee <f7> f6 29 d7 e8 22 0e 0f 01 ... RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 ... __show_trace_log_lvl+0x1bd/0x315 __die_body.cold+0x19/0x2b die+0x34/0x50 ... BUG: TASK stack guard page was hit at ffffd3ab001fbfe8 (...)
reset_kcsan_skip() and delay_access() pass these values unchecked to kcsan_prandom_u32_max(), which returns "state % ep_ro". delay_access() halves the delay for compound and assert accesses, so udelay_interrupt=1 is enough there.
The oops path runs instrumented code, which faults again until the stack overflows. With skip_watch=0 the guest hangs without printing anything.
The division came in with commit 71a076f4a61a ("kcsan: Rewrite kcsan_prandom_u32_max() without prandom_u32_state()"). Before it, the helper scaled the random value with a multiply-shift, which yields 0 for ep_ro == 0. Go back to that via reciprocal_scale().
Tested in an x86-64 KCSAN guest with virtme-ng: after this patch, writing 0 to each parameter, or 1 to udelay_interrupt, no longer oopses. skip_watch=0 now watches every access, which is very slow with the default delays but completes when they are set to 0.
--- kernel/kcsan/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/kcsan/core.c +4 -3
@@ -290,8 +290,9 @@ should_watch(struct kcsan_ctx *ctx, cons }/* -* Returns a pseudo-random number in interval [0, ep_ro). Simple linear -* congruential generator, using constants from "Numerical Recipes". +* Returns a pseudo-random number in interval [0, ep_ro), or 0 if ep_ro is 0, +* which the runtime-tunable callers may pass. Simple linear congruential +* generator, using constants from "Numerical Recipes". */ static u32 kcsan_prandom_u32_max (u32 ep_ro) {
@@ -300,7 +301,7 @@ static u32 kcsan_prandom_u32_max(u32 ep_ state =1664525 * state +1013904223 ;this_cpu_write (kcsan_rand_state, state); -return state % ep_ro; +return reciprocal_scale (state, ep_ro); }static inline void reset_kcsan_skip (void )
Greg Kroah-Hartman
maintainerPATCH 308/2857 libceph: bound mon_command ack decode to front len
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
commit 62b41a16d8603d4d809fda212f15c3e9c783a82b upstream.
handle_command_ack() bounds the decode with msg->front_alloc_len, the size of the reply buffer, instead of msg->front.iov_len, the number of bytes the monitor sent. mon_alloc_msg() routes every CEPH_MSG_MON_COMMAND_ACK to get_generic_reply(), which returns the preallocated ->reply of whichever generic request carries the same tid, so the buffer keeps its fixed size however short the reply is. An ack with hdr.front_len below sizeof(struct ceph_mon_request_header) + sizeof(u32), including 0, still passes ceph_decode_need(), and ceph_decode_32() returns four bytes that were never
received: uninitialized slab memory, stale bytes of an earlier message, or bytes the peer planted by sending a reply that lands in the same buffer and is then rejected. The read stays within the allocation, so KASAN does not flag it.
req->result reaches userspace through ceph_monc_do_statfs(), ceph_monc_get_version() and ceph_monc_blocklist_add(); rbd hands it back from write() on /sys/bus/rbd/add_single_major, and rbd_get_client() passes it to ERR_PTR() unchecked, which faults:
rbd: failed to get latest osdmap: -186318427
BUG: unable to handle page fault for address: fffffbfffe9ca034 Oops: Oops: 0000 [#1] SMP KASAN NOPTI RIP: 0010:do_rbd_add (drivers/block/rbd.c:7105) Call Trace: ... kernfs_fop_write_iter (fs/kernfs/file.c:345) vfs_write (fs/read_write.c:595 fs/read_write.c:687) ksys_write (fs/read_write.c:739) do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:84) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) Kernel panic - not syncing: Fatal exception
Use msg->front.iov_len, matching handle_subscribe_ack(), handle_statfs_reply(), handle_get_version_reply() and handle_auth_reply(). A well-formed ack has front.iov_len >= 22 and is unaffected; a short one takes the existing bad: path. This applies commit d3c32939fa0e ("libceph:
bound get_version reply decode to front len") to the last decode-side use of front_alloc_len in this file.
--- net/ceph/mon_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ceph/mon_client.c +1 -1
@@ -943,7 +943,7 @@ static void handle_command_ack(struct ce {struct ceph_mon_generic_request *req;void *p = msg->front.iov_base; -void *const end = p + msg->front_alloc_len; +void *const end = p + msg->front.iov_len;u64 tid =le64_to_cpu (msg->hdr.tid);dout ("%s msg %p tid %llu\n" , __func__, msg, tid);
Greg Kroah-Hartman
maintainerPATCH 309/2857 media: cx88: Disable PCI device on MPEG initialization failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
commit 80494a83223bc972145c23890b083d20651512bd upstream.
cx8802_init_common() enables the PCI device, then returns directly if DMA mask setup or IRQ registration fails. cx8802_probe() frees the device and drops the shared core reference without disabling PCI.
Disable the PCI device on both post-enable failures. Preserve -EIO for a DMA mask failure and the original request_irq() error. Do not call the full fini helper because the IRQ was not successfully requested. The successful probe and normal removal paths are unchanged.
These missing error-path disables are present in the initial Git import.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/media/pci/cx88/cx88-mpeg.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/pci/cx88/cx88-mpeg.c +7 -2
@@ -392,7 +392,8 @@ static int cx8802_init_common(struct cx8 err =dma_set_mask (&dev->pci->dev,DMA_BIT_MASK (32 ));if (err) {pr_err ("Oops: no 32bit PCI DMA ???\n" ); -return -EIO ; + err = -EIO ; + goto fail_disable_device; } dev->pci_rev = dev->pci->revision;
@@ -413,13 +414,17 @@ static int cx8802_init_common(struct cx8 IRQF_SHARED, dev->core->name, dev);if (err <0 ) {pr_err ("can't get IRQ %d\n" , dev->pci->irq); -return err; + goto fail_disable_device; }cx_set (MO_PCI_INTMSK , core->pci_irqmask);/* everything worked */ pci_set_drvdata (dev->pci, dev);return 0 ; + +fail_disable_device: +pci_disable_device (dev->pci); +return err; }static void cx8802_fini_common (struct cx8802_dev *dev)
Greg Kroah-Hartman
maintainerPATCH 310/2857 media: em28xx: reject audio endpoint with zero packet size
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
commit aebfe430ba885d2f8fc882d7a6d60a7fdbe535d8 upstream.
em28xx_audio_urb_init() divides by the audio endpoint's wMaxPacketSize without checking it, so a USB device that declares a zero-sized audio endpoint divides by zero at probe time.
Reject a zero-sized audio endpoint like a missing one; the caller already unwinds on a negative return.
Oops: divide error: 0000 [#1] SMP NOPTI Workqueue: usb_hub_wq hub_event RIP: 0010:em28xx_audio_init (drivers/media/usb/em28xx/em28xx-audio.c:718) Call Trace: em28xx_init_extension (drivers/media/usb/em28xx/em28xx-core.c:1248) em28xx_init_dev.isra.0 (drivers/media/usb/em28xx/em28xx-cards.c:3887) em28xx_usb_probe (drivers/media/usb/em28xx/em28xx-cards.c:4258) usb_probe_interface (drivers/usb/core/driver.c:396) ... usb_set_configuration (drivers/usb/core/message.c:2268) usb_generic_driver_probe (drivers/usb/core/generic.c:250) usb_probe_device (drivers/usb/core/driver.c:291) ... usb_new_device (drivers/usb/core/hub.c:2703) hub_event (drivers/usb/core/hub.c:5961) process_one_work (kernel/workqueue.c:3322) worker_thread (kernel/workqueue.c:3486) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) Kernel panic - not syncing: Fatal exception
--- drivers/media/usb/em28xx/em28xx-audio.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/usb/em28xx/em28xx-audio.c +7 -0
@@ -693,6 +693,13 @@ static int em28xx_audio_urb_init(struct } ep_size =em28xx_audio_ep_packet_size (udev, ep); +if (ep_size ==0 ) { +dev_err (&dev->intf->dev, +"Audio endpoint 0x%02x has a zero packet size\n" , +EM28XX_EP_AUDIO ); +return -ENODEV ; + } + interval =1 << (ep->bInterval -1 ); dev_info(&dev->intf->dev,
Greg Kroah-Hartman
maintainerPATCH 311/2857 media: go7007: only set audio_enabled if go7007_snd_init() succeeded
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
commit 2eacf058d2dbb0ae3aaf576459da9e5f2b6bbfbd upstream.
go7007_register_encoder() sets go->audio_enabled before calling go7007_snd_init() and discards its return value. go7007_snd_init() assigns go->snd_context only on success, so a failed ALSA setup leaves audio_enabled set with snd_context still NULL. The disconnect path tests audio_enabled and calls go7007_snd_remove(), which dereferences snd_context unconditionally.
go7007_snd_init() returns -ENODEV once its never-decremented static card counter reaches SNDRV_CARDS, so SNDRV_CARDS attach/detach cycles arm the next attach; no memory pressure is needed.
Set go->audio_enabled only once go7007_snd_init() has succeeded.
Oops: general protection fault, probably for non-canonical address ... KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] Workqueue: usb_hub_wq hub_event RIP: 0010:go7007_snd_remove (drivers/media/usb/go7007/snd-go7007.c:273) Call Trace: go7007_usb_disconnect (drivers/media/usb/go7007/go7007-usb.c:1336) usb_unbind_interface (drivers/usb/core/driver.c:461) device_remove (drivers/base/dd.c:618) device_release_driver_internal (drivers/base/dd.c:1349) bus_remove_device (drivers/base/bus.c:664) device_del (drivers/base/core.c:3965) usb_disable_device (drivers/usb/core/message.c:1478) usb_disconnect hub_event (drivers/usb/core/hub.c:5966) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) Kernel panic - not syncing: Fatal exception
--- drivers/media/usb/go7007/go7007-driver.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/usb/go7007/go7007-driver.c +2 -3
@@ -306,10 +306,9 @@ int go7007_register_encoder(struct go700if (ret <0 )return ret; -if (go->board_info->flags &GO7007_BOARD_HAS_AUDIO ) { +if ((go->board_info->flags &GO7007_BOARD_HAS_AUDIO ) && +go7007_snd_init (go) ==0 ) go->audio_enabled =1 ; -go7007_snd_init (go); - }return 0 ; }EXPORT_SYMBOL (go7007_register_encoder);
Greg Kroah-Hartman
maintainerPATCH 312/2857 net: ipv4: add zero check for snd_cwnd_clamp
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaho Jiang <[email protected]>
commit 363c8c79220d0db4d65dcd570529ddda15067cb5 upstream.
When RTAX_CWND is locked, user is able to pass 0 into it. This could lead to writing 0 to tp->snd_cwnd, leading to a division by zero error.
Oops: divide error: 0000 [#1] SMP KASAN NOPTI Call Trace: <IRQ> tcp_reno_cong_avoid (net/ipv4/tcp_cong.c:510 (discriminator 1)) tcp_ack (net/ipv4/tcp_input.c:3517 net/ipv4/tcp_input.c:3873 net/ipv4/tcp_input.c:4440) tcp_rcv_established (net/ipv4/tcp_input.c:6685) tcp_v4_do_rcv (net/ipv4/tcp_ipv4.c:1854) tcp_v4_rcv (net/ipv4/tcp_ipv4.c:2248) ip_protocol_deliver_rcu (net/ipv4/ip_input.c:207 (discriminator 1)) ip_local_deliver_finish (net/ipv4/ip_input.c:241 (discriminator 1)) ip_local_deliver (./include/linux/netfilter.h:325 ./include/linux/netfilter.h:319 net/ipv4/ip_input.c:262) ip_rcv (./include/net/dst.h:481 (discriminator 6) net/ipv4/ip_input.c:492 (discriminator 6) ./include/linux/netfilter.h:325 (discriminator 6) ./include/li) __netif_receive_skb_one_core (net/core/dev.c:6297 (discriminator 4)) __netif_receive_skb (net/core/dev.c:6410) process_backlog (net/core/dev.c:6761) __napi_poll.constprop.0 (net/core/dev.c:7830) net_rx_action (net/core/dev.c:7893 net/core/dev.c:8050) handle_softirqs (kernel/softirq.c:645) __irq_exit_rcu (kernel/softirq.c:679 kernel/softirq.c:519 kernel/softirq.c:758) irq_exit_rcu (kernel/softirq.c:775) sysvec_apic_timer_interrupt (arch/x86/kernel/apic/apic.c:1062 (discriminator 35) arch/x86/kernel/apic/apic.c:1062 (discriminator 35)) RIP: 0010:tcp_cong_avoid_ai (net/ipv4/tcp_cong.c:482)
Fix by checking if user pass in zero as parameter and if lock is present.
--- net/ipv4/metrics.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ipv4/metrics.c +5 -0
@@ -63,6 +63,11 @@ static int ip_metrics_convert(struct netif (ecn_ca) metrics[RTAX_FEATURES -1 ] |=DST_FEATURE_ECN_CA ; +if ((metrics[RTAX_LOCK -1 ] & (1 <<RTAX_CWND )) && !metrics[RTAX_CWND -1 ]) { +NL_SET_ERR_MSG (extack,"Locked cwnd metric must be non zero" ); +return -EINVAL ; + } +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 313/2857 net: usb: pegasus: do not advance rx_skb->data on dropped frames
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Jie Law <[email protected]>
commit bfa09dccf98cf78dd9282259b2140bd1472f5ae9 upstream.
For the 0x8513 chip, read_bulk_callback() skips the 2-byte receive header by advancing pegasus->rx_skb->data in place. This is done before the pkt_len > PEGASUS_MTU check, and when that check drops the frame the good path resubmits the same skb with the advanced rx_skb->data as the transfer buffer, still PEGASUS_MTU bytes long.
Every frame with an oversized length field therefore moves the receive buffer two more bytes towards the end of the skb data area. A device that keeps sending such frames makes the host controller write received data over skb_shared_info and past the end of the allocation, and the corrupted skb_shared_info is used when the skb is eventually freed. With an emulated device sending frames filled with 0x5a on a KASAN kernel:
BUG: KASAN: slab-out-of-bounds in dummy_timer+0xade/0x3f00 [dummy_hcd] Write of size 1536 at addr ffff888105821202 by task swapper/1/0 ... Oops: general protection fault, probably for non-canonical address 0xeb4b474b4b4b4b4c: 0000 [#1] PREEMPT SMP KASAN NOPTI KASAN: maybe wild-memory-access in range [0x5a5a5a5a5a5a5a60-0x5a5a5a5a5a5a5a67] RIP: 0010:skb_release_data+0x36f/0x800
Only skip the header with skb_reserve() once the frame is going to be passed up, so the receive buffer always starts at the beginning of the skb data area. Unlike the old pointer adjustment, skb_reserve() also moves skb->tail, so the two header bytes now count against the buffer
size: lower the length limit for the 0x8513 accordingly, otherwise a pkt_len of PEGASUS_MTU - 1 or PEGASUS_MTU would trip skb_over_panic().
Found by code review with LLM assistance and reproduced with an emulated USB device (raw-gadget + dummy_hcd).
--- drivers/net/usb/pegasus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/usb/pegasus.c +4 -2
@@ -464,6 +464,7 @@ static void read_bulk_callback(struct uru8 *buf = urb->transfer_buffer;int rx_status, count = urb->actual_length;int status = urb->status; +int rx_offset =0 ;__u16 pkt_len;if (!pegasus)
@@ -513,7 +514,7 @@ static void read_bulk_callback(struct urif (pegasus->chip ==0x8513 ) { pkt_len =le32_to_cpu (*(__le32 *)urb->transfer_buffer); pkt_len &=0x0fff ; - pegasus->rx_skb->data +=2 ; + rx_offset =2 ; }else { pkt_len = buf[count -3 ] <<8 ; pkt_len += buf[count -4 ];
@@ -525,13 +526,14 @@ static void read_bulk_callback(struct ur* If the packet is unreasonably long, quietly drop it rather than * kernel panicing by calling skb_put. */ -if (pkt_len >PEGASUS_MTU ) +if (pkt_len >PEGASUS_MTU - rx_offset) goto goon;/* * at this point we are sure pegasus->rx_skb != NULL * so we go ahead and pass up the packet. */ +skb_reserve (pegasus->rx_skb, rx_offset);skb_put (pegasus->rx_skb, pkt_len); pegasus->rx_skb->protocol =eth_type_trans (pegasus->rx_skb, net);netif_rx (pegasus->rx_skb);
Greg Kroah-Hartman
maintainerPATCH 314/2857 ocfs2/dlm: drain join handlers before releasing module text
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
commit 28f366d84023651e50e32e29931401ba0df3e679 upstream.
The code for a registered DLM handler must remain resident until its last invocation finishes. dlm_unregister_net_handlers() only removes dlm_join_handlers from the o2net registry. o2net_handler_get() takes a kref on the wrapper, but that reference does not pin ocfs2_dlm text. o2net_process_message() calls nh_func after dropping o2net_handler_lock.
With CONFIG_OCFS2_FS_O2CB=m, ocfs2_dlm can be loaded independently of ocfs2_stack_o2cb while nodemanager continues handling messages from a configured, heartbeating peer. If no dependent module or module reference prevents normal unload, the following ordering is possible:
Receive worker Module unload
-------------- -------------
o2net_handler_get()
take wrapper kref
drop handler lock
<preempted>
dlm_exit()
unregister handlers
release DLM module text
call saved nh_func
in released module text
Use o2net_unregister_and_flush_handler_list() in the shared DLM unregister helper. It first prevents new lookups, then waits for the ordered o2net workqueue to drain, including a concurrent destruction of that queue. The acquired invocation therefore finishes before dlm_exit() returns and the loader releases the callback code. The same helper covers partial registration and dlm_init() error unwind before module memory is released.
Skip the drain when the private join-handler list is empty. Early dlm_init() failures can reach this helper before any handler has been published. Partial-registration failure also reaches it a second time after the first call has already unregistered and drained the list. Neither case needs to take o2net_wq_mutex or drain unrelated work. The list is changed only by serialized module init/exit paths; a nonempty list still uses the full unregister-and-flush helper.
Oops report as below:
Oops: int3: 0000 [#1] SMP KASAN NOPTI
CPU: 2 UID: 0 PID: 54 Comm: kworker/u16:3 Not tainted 7.3.0-rc4-next-20260921-pmb-ocfs2-functional-v1+ #1 PREEMPT(lazy)Hardware identification omitted.
Workqueue: o2net o2net_rx_until_empty [ocfs2_nodemanager]
RIP: 0010:0xffffffffc0423871
[Instruction byte dump omitted.]Register dump omitted.
Call Trace:
<TASK>
? o2net_rx_until_empty+0x19b1/0x3300 [ocfs2_nodemanager]
? __pfx_o2net_rx_until_empty+0x10/0x10 [ocfs2_nodemanager]
? lock_acquire+0x190/0x300
? process_one_work+0x935/0x1b40
? process_one_work+0x834/0x1b40
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x290
? srso_alias_return_thunk+0x5/0xfbef5
? process_one_work+0x9a8/0x1b40
? __pfx_process_one_work+0x10/0x10
? lock_acquire+0x190/0x300
? lock_is_held_type+0x8f/0x100
? srso_alias_return_thunk+0x5/0xfbef5
? worker_thread+0x65c/0xe40
? srso_alias_return_thunk+0x5/0xfbef5
? __kthread_parkme+0x177/0x220
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_worker_thread+0x10/0x10
? kthread+0x351/0x460
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_kthread+0x10/0x10
? ret_from_fork+0x659/0x940
? __pfx_ret_from_fork+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __switch_to+0x74f/0xf70
? __pfx_kthread+0x10/0x10
? ret_from_fork_asm+0x1a/0x30
</TASK>
Modules linked in: ocfs2_nodemanager [last unloaded: ocfs2_dlm]
---[ end trace 0000000000000000 ]------ fs/ocfs2/dlm/dlmdomain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ocfs2/dlm/dlmdomain.c +2 -1
@@ -2217,7 +2217,8 @@ static LIST_HEAD(dlm_join_handlers);static void dlm_unregister_net_handlers (void ) { -o2net_unregister_handler_list (&dlm_join_handlers); +if (!list_empty (&dlm_join_handlers)) +o2net_unregister_and_flush_handler_list (&dlm_join_handlers); }static int dlm_register_net_handlers (void )
Greg Kroah-Hartman
maintainerPATCH 315/2857 ocfs2: drain quorum work before removing the cluster
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
commit b584c45b6066fd9799c44ffb9badcb5db351c8a6 upstream.
The configured cluster must remain available until an in-flight quorum decision has finished using its fencing method. o2quo_make_decision() drops qs_lock before calling o2quo_fence_self(), which marks heartbeat regions for unclean stop and then reads o2nm_single_cluster->cl_fence_method. Cluster removal clears the singleton without waiting for this independent system-workqueue item.
When a failed-quorum decision overlaps removal of the heartbeat regions, nodes and cluster through configfs, the worker can be preempted after marking the regions and resume after the singleton has been cleared:
Quorum worker Configfs removal
select fence; drop qs_lock
o2hb_stop_all_regions()
remove regions; join heartbeat threads remove nodes; stop o2net clear singleton; release cluster
read cl_fence_method
The resumed read dereferences NULL instead of applying the configured fencing method. The heartbeat thread's dependency protects the local node only until the thread exits, and draining o2net does not wait for qs_work.
Add o2quo_flush_work() to drain pending or running quorum decisions before clearing the singleton in o2nm_cluster_group_drop_item(). By this point the heartbeat regions and nodes have been removed, so their work publishers are stopped. The worker can finish while the cluster and its configured fencing method remain available. It does not acquire the configfs mutex held by the removal path.
Keep o2quo_exit() as the counterpart of o2quo_init() for module teardown and initialization failure, and have it call the same drain helper. Cluster removal uses only the explicitly named drain operation.
KASAN report as below:
Oops: general protection fault, probably for non-canonical address 0xdffffc000000011b: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x00000000000008d8-0x00000000000008df]
CPU: 0 UID: 0 PID: 72 Comm: kworker/0:2 Not tainted 7.3.0-rc4-next-20260921-pmb-ocfs2-functional-v1+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: events o2quo_make_decision
RIP: 0010:o2quo_fence_self+0x65/0x200Register dump omitted.
Call Trace:
<TASK>
o2quo_make_decision+0x345/0x3a0
? __pfx_o2quo_make_decision+0x10/0x10
? process_one_work+0x834/0x1b40
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x290
? srso_alias_return_thunk+0x5/0xfbef5
process_one_work+0x9a8/0x1b40
? __pfx_process_one_work+0x10/0x10
? lock_acquire+0x190/0x300
? lock_is_held_type+0x8f/0x100
? srso_alias_return_thunk+0x5/0xfbef5
worker_thread+0x65c/0xe40
? srso_alias_return_thunk+0x5/0xfbef5
? __kthread_parkme+0x177/0x220
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_worker_thread+0x10/0x10
kthread+0x351/0x460
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_kthread+0x10/0x10
ret_from_fork+0x659/0x940
? __pfx_ret_from_fork+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __switch_to+0x74f/0xf70
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x1a/0x30
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]------ fs/ocfs2/cluster/nodemanager.c | 3 +++ fs/ocfs2/cluster/quorum.c | 7 ++++++- fs/ocfs2/cluster/quorum.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-)
fs/ocfs2/cluster/nodemanager.c +3 -0
@@ -11,6 +11,7 @@#include "tcp.h" #include "nodemanager.h" #include "heartbeat.h" +#include "quorum.h" #include "masklog.h" #include "sys.h"
@@ -739,6 +740,8 @@ static void o2nm_cluster_group_drop_itemstruct o2nm_cluster *cluster =to_o2nm_cluster (item);BUG_ON (o2nm_single_cluster != cluster); +/* Drain quorum work before it loses access to the cluster. */ +o2quo_flush_work (); o2nm_single_cluster =NULL ;configfs_remove_default_groups (&cluster->cl_group);
fs/ocfs2/cluster/quorum.c +6 -1
@@ -318,9 +318,14 @@ void o2quo_init(void)INIT_WORK (&qs->qs_work, o2quo_make_decision); } -void o2quo_exit (void ) +void o2quo_flush_work (void ) {struct o2quo_state *qs = &o2quo_state;flush_work (&qs->qs_work); } + +void o2quo_exit (void ) +{ +o2quo_flush_work (); +}
fs/ocfs2/cluster/quorum.h +1 -0
@@ -8,6 +8,7 @@void o2quo_init (void );void o2quo_exit (void ); +void o2quo_flush_work (void );void o2quo_hb_up (u8 node);void o2quo_hb_down (u8 node);
Greg Kroah-Hartman
maintainerPATCH 316/2857 ocfs2: pin owning modules for open debugfs files
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
commit 26d7e34b4226709084461a07bf28d9066fa96d8c upstream.
The OCFS2 debugfs file operation tables do not set owner. The full debugfs proxy obtains real_fops with fops_get() at open and keeps it until final release. Without an owner, this does not acquire a reference to the module containing the table and its callbacks. Removing the debugfs entries does not drain retained open files.
An open connected_nodes file can therefore outlive ocfs2_nodemanager and make full_proxy_release() read real_fops->release from freed module memory. Heming also reproduced the issue with fs_state and asked for the other OCFS2 debugfs operation tables to be checked.
Set owner to THIS_MODULE in all eleven explicit debugfs operation
tables: five in ocfs2_nodemanager, four in ocfs2_dlm, and two in ocfs2. The existing debugfs get/put pair then holds the appropriate module until final release. Leave the open, read and release callbacks unchanged. The blockcheck table already sets owner through DEFINE_DEBUGFS_ATTRIBUTE(), so it needs no change.
The original controlled test used an unloadable OCFS2 module and case-local probe filters without changing the candidate open, unload or release logic. Closing a retained connected_nodes file after normal unload produced:
BUG: unable to handle page fault for address: fffffbfff804cfef Oops: Oops: 0000 [#1] SMP KASAN NOPTI RIP: 0010:full_proxy_release+0xbf/0x190 Call Trace: <TASK> __fput+0x39a/0xa60 fput_close_sync+0xff/0x200 __x64_sys_close+0x8c/0xf0 do_syscall_64+0x114/0x620 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> Modules linked in: [last unloaded: ocfs2_nodemanager]
--- fs/ocfs2/cluster/heartbeat.c | 1 + fs/ocfs2/cluster/netdebug.c | 4 ++++ fs/ocfs2/dlm/dlmdebug.c | 5 +++++ fs/ocfs2/dlmglue.c | 2 ++ fs/ocfs2/super.c | 1 + 5 files changed, 13 insertions(+)
fs/ocfs2/cluster/heartbeat.c +1 -0
@@ -1420,6 +1420,7 @@ static ssize_t o2hb_debug_read(struct fi#endif /* CONFIG_DEBUG_FS */ static const struct file_operations o2hb_debug_fops = { + .owner =THIS_MODULE , .open = o2hb_debug_open, .release = o2hb_debug_release, .read = o2hb_debug_read,
fs/ocfs2/cluster/netdebug.c +4 -0
@@ -183,6 +183,7 @@ static int nst_fop_release(struct inode }static const struct file_operations nst_seq_fops = { + .owner =THIS_MODULE , .open = nst_fop_open, .read = seq_read, .llseek = seq_lseek,
@@ -415,6 +416,7 @@ static int stats_fop_open(struct inode * }static const struct file_operations stats_seq_fops = { + .owner =THIS_MODULE , .open = stats_fop_open, .read = seq_read, .llseek = seq_lseek,
@@ -427,6 +429,7 @@ static int sc_fop_open(struct inode *ino }static const struct file_operations sc_seq_fops = { + .owner =THIS_MODULE , .open = sc_fop_open, .read = seq_read, .llseek = seq_lseek,
@@ -476,6 +479,7 @@ static ssize_t o2net_debug_read(struct f }static const struct file_operations nodes_fops = { + .owner =THIS_MODULE , .open = nodes_fop_open, .release = o2net_debug_release, .read = o2net_debug_read,
fs/ocfs2/dlm/dlmdebug.c +5 -0
@@ -7,6 +7,7 @@* Copyright (C) 2004, 2008 Oracle. All rights reserved. */ +#include <linux/module.h> #include <linux/types.h> #include <linux/slab.h> #include <linux/highmem.h>
@@ -393,6 +394,7 @@ bail: }static const struct file_operations debug_purgelist_fops = { + .owner =THIS_MODULE , .open = debug_purgelist_open, .release = debug_release, .read = debug_read,
@@ -450,6 +452,7 @@ bail: }static const struct file_operations debug_mle_fops = { + .owner =THIS_MODULE , .open = debug_mle_open, .release = debug_release, .read = debug_read,
@@ -657,6 +660,7 @@ static int debug_lockres_release(struct }static const struct file_operations debug_lockres_fops = { + .owner =THIS_MODULE , .open = debug_lockres_open, .release = debug_lockres_release, .read = seq_read,
@@ -852,6 +856,7 @@ bail: }static const struct file_operations debug_state_fops = { + .owner =THIS_MODULE , .open = debug_state_open, .release = debug_release, .read = debug_read,
fs/ocfs2/dlmglue.c +2 -0
@@ -7,6 +7,7 @@* Copyright (C) 2003, 2004 Oracle. All rights reserved. */ +#include <linux/module.h> #include <linux/types.h> #include <linux/slab.h> #include <linux/highmem.h>
@@ -3313,6 +3314,7 @@ static int ocfs2_dlm_debug_open(struct i }static const struct file_operations ocfs2_dlm_debug_fops = { + .owner =THIS_MODULE , .open = ocfs2_dlm_debug_open, .release = ocfs2_dlm_debug_release, .read = seq_read,
fs/ocfs2/super.c +1 -0
@@ -383,6 +383,7 @@ static ssize_t ocfs2_debug_read(struct f#endif /* CONFIG_DEBUG_FS */ static const struct file_operations ocfs2_osb_debug_fops = { + .owner =THIS_MODULE , .open = ocfs2_osb_debug_open, .release = ocfs2_debug_release, .read = ocfs2_debug_read,
Greg Kroah-Hartman
maintainerPATCH 317/2857 ocfs2: publish the filecheck owner before adding sysfs attributes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
commit e062baf5680845705d21df415c8f0751c96b0792 upstream.
ocfs2_filecheck_create_sysfs() initializes the filecheck allocation before calling kobject_init_and_add(), but assigns entry->fs_fcheck only after that call returns. The default attribute group can already be visible while registration is in progress. A concurrent read can therefore enter ocfs2_filecheck_attr_show() with a NULL fs_fcheck and try to lock its fc_lock.
Assign the initialized owner before adding the kobject, so every activated attribute has valid state. Clear the pointer when addition fails, preserving the existing teardown guard and error cleanup.
A controlled probe-instrumented test kernel with the original OCFS2 registration ordering produced this Oops during a concurrent sysfs read:
KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f] RIP: 0010:kasan_byte_accessible+0x15/0x30 Call Trace: <TASK> __kasan_check_byte+0x13/0x50 lock_acquire+0x113/0x300 _raw_spin_lock+0x31/0x40 ocfs2_filecheck_attr_show+0x138/0x5f0 ocfs2_filecheck_show+0x5d/0x90 sysfs_kf_seq_show+0x1d3/0x360 seq_read_iter+0x480/0x1110 kernfs_fop_read_iter+0x419/0x5a0 vfs_read+0x7d2/0xc20 ksys_read+0x111/0x200 do_syscall_64+0x114/0x620 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> Modules linked in:
--- fs/ocfs2/filecheck.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ocfs2/filecheck.c +4 -1
@@ -179,17 +179,20 @@ int ocfs2_filecheck_create_sysfs(struct fcheck->fc_size =0 ; fcheck->fc_done =0 ; +/* Publish the initialized owner before activating its sysfs callbacks. */ + entry->fs_fcheck = fcheck; entry->fs_kobj.kset = osb->osb_dev_kset;init_completion (&entry->fs_kobj_unregister); ret =kobject_init_and_add (&entry->fs_kobj, &ocfs2_ktype_filecheck,NULL ,"filecheck" );if (ret) { +/* Mount failure still calls ocfs2_filecheck_remove_sysfs(). */ + entry->fs_fcheck =NULL ;kobject_put (&entry->fs_kobj);kfree (fcheck);return ret; } - entry->fs_fcheck = fcheck;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 318/2857 thunderbolt: Do not RPM complete unrelated subtrees on unplug
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Gopel <[email protected]>
commit 96a8479804e3f7af43e639e9df39f562f1a75fd5 upstream.
When a Thunderbolt device is unplugged, that switch and every switch subsequent to it on the bus device list is complete()d, not just its child devices. In the case of multiple domains, it may cause, eg, an attempt to complete() the uninitialized domain 1 root switch RPM completion on unplug of a switch from domain 0 (though ordering is not guaranteed numerically sorted).
I initially noticed this issue on a Dell XPS9720 when the system would seem to sporadically not wake after unplugging a Thunderbolt dock. I tried multiple kernel versions including v7.2.7 and v7.3-rc4 to see if that resolved the issue, but the issue persisted. Eventually I found that I could consistently generate a kernel Oops reporting a page fault at 0xffff_ffff_ffff_fff8 on unplug from one side of the laptop and went bug hunting. I became suspicious of the bus_for_each_dev() walk that I ultimately ended up changing. To confirm this issue, I did an eBPF trace of bus_for_each_dev(), complete_rpm(), and complete() while unplugging in a variety of situations and found that an unplug from domain 0 tries to complete_rpm() domain 1's switch, whose RPM completion is not initialized and thus is holding a null wait-list pointer, triggering the page fault.
Here are the key sections of that eBPF trace. Note that HEAD denotes the completion's own wait-list HEAD:
```
RESCAN_ENTER domain=0
COMPLETE rescan_domain=0 target=0-1 target_domain=0
route=0x1 parent=0-0 unplugged=1
COMPLETION done=0 head=HEAD next=HEAD prev=HEAD
BUS_WALK domain=0 start=0-1 callback=complete_rpm
CALLBACK_ENTER rescan_domain=0 dev=1-0 parent=domain1 is_switch=1
COMPLETE rescan_domain=0 target=1-0 target_domain=1
route=0x0 parent=domain1 unplugged=0
COMPLETION done=0 head=HEAD next=0 prev=0
complete+5
complete_rpm+43
bus_for_each_dev+133
icm_free_unplugged_children+250
icm_rescan_work+42
```This patch gates the complete() on an additional condition - that the Thunderbolt domain matches the domain of the device that was unplugged.
I only have a single system with multiple Thunderbolt domains - the Dell XPS9720. I am consistently able to reproduce the Oops on that system. Since running with this patch, I have not seen the Oops reoccur. I have also tested it on a Thinkpad X1-Gen12, and that system boots and runs well with it, but it only has a single Thunderbolt domain, so it does not exercise the multi-domain failure case.
--- drivers/thunderbolt/icm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/thunderbolt/icm.c +3 -3
@@ -2036,7 +2036,7 @@ static int complete_rpm(struct device *d {struct tb_switch *sw =tb_to_switch (dev); -if (sw) +if (sw && sw->tb == data)complete (&sw->rpm_complete);return 0 ; }
@@ -2052,8 +2052,8 @@ static void remove_unplugged_switch(stru* tb_switch_remove() calls pm_runtime_get_sync() that then waits * for it. */ -complete_rpm (&sw->dev,NULL ); -bus_for_each_dev (&tb_bus_type, &sw->dev,NULL , complete_rpm); +complete_rpm (&sw->dev, sw->tb); +bus_for_each_dev (&tb_bus_type, &sw->dev, sw->tb, complete_rpm);tb_switch_remove (sw);pm_runtime_mark_last_busy (parent);
Greg Kroah-Hartman
maintainerPATCH 319/2857 wwan: wwan_hwsim: Pin module for debugfs file operations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bui Viet Dung <[email protected]>
commit a388f17e23b7e305cb306aafd73bb10d6b8ca452 upstream.
An open debugfs file retains its file_operations pointer in the debugfs proxy state. However, wwan_hwsim_debugfs_portdestroy_fops, wwan_hwsim_debugfs_portcreate_fops, wwan_hwsim_debugfs_devdestroy_fops, and wwan_hwsim_debugfs_devcreate_fops in wwan_hwsim.c have no .owner set to THIS_MODULE.
As a result, full_proxy_open_regular() calls fops_get() which succeeds without taking a reference to the wwan_hwsim module. When a userspace process opens any of these debugfs files, a subsequent module unload (rmmod wwan_hwsim) can succeed while the file descriptor remains open.
When the userspace process subsequently closes the descriptor, full_proxy_release() accesses the already unmapped file_operations structure, triggering a kernel oops in full_proxy_release():
BUG: unable to handle page fault for address: fffffbfff84f90ef Oops: 0000 [#2] SMP KASAN NOPTI RIP: 0010:full_proxy_release+0x8e/0x140 Call Trace: <TASK> __fput+0x357/0xaa0 fput_close_sync+0xe6/0x1a0 file_close_fd_locked+0x17e/0x2f0 do_close+0x33/0x70 __x64_sys_close+0x44/0x80 do_syscall_64+0xc3/0x590 entry_SYSCALL_64_after_hwframe+0x76/0x7e </TASK>
The issue was discovered via manual code audit of wwan_hwsim.c and reproduced on a Linux 7.3-rc6 test VM with CONFIG_WWAN_HWSIM=m.
Set .owner = THIS_MODULE on all four debugfs file_operations structures in wwan_hwsim.c so that debugfs pins the module until close has completed.
--- drivers/net/wwan/wwan_hwsim.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wwan/wwan_hwsim.c +4 -0
@@ -378,6 +378,7 @@ static ssize_t wwan_hwsim_debugfs_portde }static const struct file_operations wwan_hwsim_debugfs_portdestroy_fops = { + .owner =THIS_MODULE , .write = wwan_hwsim_debugfs_portdestroy_write, .open = simple_open, .llseek = noop_llseek,
@@ -402,6 +403,7 @@ static ssize_t wwan_hwsim_debugfs_portcr }static const struct file_operations wwan_hwsim_debugfs_portcreate_fops = { + .owner =THIS_MODULE , .write = wwan_hwsim_debugfs_portcreate_write, .open = simple_open, .llseek = noop_llseek,
@@ -423,6 +425,7 @@ static ssize_t wwan_hwsim_debugfs_devdes }static const struct file_operations wwan_hwsim_debugfs_devdestroy_fops = { + .owner =THIS_MODULE , .write = wwan_hwsim_debugfs_devdestroy_write, .open = simple_open, .llseek = noop_llseek,
@@ -446,6 +449,7 @@ static ssize_t wwan_hwsim_debugfs_devcre }static const struct file_operations wwan_hwsim_debugfs_devcreate_fops = { + .owner =THIS_MODULE , .write = wwan_hwsim_debugfs_devcreate_write, .open = simple_open, .llseek = noop_llseek,
Greg Kroah-Hartman
maintainerPATCH 320/2857 wifi: cfg80211: release locks on error in cfg80211_wext_siwgenie()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Guan <[email protected]>
This error path returns while wdev_lock() is still held, so one malformed IE request can permanently block later operations on this wiphy. Route the error through out to release the lock.
This bug is stable-specific: it was introduced by the stable backport commit 8b921a899346 ("wifi: cfg80211: validate IEs in cfg80211_wext_siwgenie()") of upstream
commit a2f5286ca4f3 ("wifi: cfg80211: validate IEs in cfg80211_wext_siwgenie()"). Upstream is safe because that function runs under guard(wiphy)(), added by
commit f42d22d3f7963 ("wifi: cfg80211: define and use wiphy guard"), while this tree still uses explicit locking and the separate wdev mutex that upstream removed in
commit 076fc8775dafe ("wifi: cfg80211: remove wdev mutex"). Backporting those locking reworks is not appropriate as a minimal stable fix.
This is a fix for stable v6.1.189 backport commit, so no upstream commit.
--- net/wireless/wext-sme.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/wireless/wext-sme.c +4 -2
@@ -352,8 +352,10 @@ int cfg80211_wext_siwgenie(struct net_device *dev,/* nothing */ } -if (!for_each_element_completed (elem, extra, ie_len)) -return -EINVAL ; +if (!for_each_element_completed (elem, extra, ie_len)) { + err = -EINVAL ; + goto out; + } ie =kmemdup (extra, ie_len,GFP_KERNEL );if (!ie) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 321/2857 netfilter: nf_conntrack_expect: add and use nf_ct_expect_related_pair()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit 4aa63842fc92de1bce59d4709a0d32e718890bb2 upstream.
Add a new function to insert a pair of expectations, this is required by the SIP and H323 NAT helpers. The spinlock is held to check if there is a slot for both expectations, in such case, insert them.
This removes the need for nf_ct_unexpect_related() inside the loop to find a pair of consecutive ports, otherwise inserting expectations whose dead flag is already set on can happen.
Bump master_help->expecting for the expectation class after checking if the expectation fits in the master expectation list, which is needed for this new _pair() function variant to run the eviction routine including the preallocated slot for the first expectation in the pair.
[ Joas: nf_ct_expect_insert() and __nf_ct_expect_check() do not take
a master_help argument in this tree, so keep their existing signatures; nf_ct_expect_related_report() gets master_help from nfct_help(expect->master) for the moved expecting[] increment. ]
--- include/net/netfilter/nf_conntrack_expect.h | 3 ++ net/ipv4/netfilter/nf_nat_h323.c | 22 +++++-------- net/netfilter/nf_conntrack_expect.c | 35 ++++++++++++++++++++- net/netfilter/nf_nat_sip.c | 20 ++++-------- 4 files changed, 50 insertions(+), 30 deletions(-)
include/net/netfilter/nf_conntrack_expect.h +3 -0
@@ -160,6 +160,9 @@ static inline int nf_ct_expect_related(struct nf_conntrack_expect *expect,return nf_ct_expect_related_report (expect,0 ,0 , flags); } +int nf_ct_expect_related_pair (struct nf_conntrack_expect *expect[], +unsigned int flag); +struct nf_conn_help ;void nf_ct_expectation_gc (struct nf_conn_help *master_help);
net/ipv4/netfilter/nf_nat_h323.c +7 -15
@@ -179,6 +179,7 @@ static int nat_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,struct nf_conntrack_expect *rtp_exp, struct nf_conntrack_expect *rtcp_exp) { + struct nf_conntrack_expect *rtp_pair[2] = { rtp_exp, rtcp_exp };struct nf_ct_h323_master *info =nfct_help_data (ct);int dir =CTINFO2DIR (ctinfo);int i;
@@ -221,22 +222,13 @@ static int nat_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,int ret; rtp_exp->tuple.dst.u.udp.port =htons (nated_port); - ret =nf_ct_expect_related (rtp_exp,0 ); + rtcp_exp->tuple.dst.u.udp.port =htons (nated_port +1 ); + ret =nf_ct_expect_related_pair (rtp_pair,0 );if (ret ==0 ) { - rtcp_exp->tuple.dst.u.udp.port = -htons (nated_port +1 ); - ret =nf_ct_expect_related (rtcp_exp,0 ); -if (ret ==0 ) -break ; -else if (ret == -EBUSY ) { -nf_ct_unexpect_related (rtp_exp); -continue ; - }else if (ret <0 ) { -nf_ct_unexpect_related (rtp_exp); - nated_port =0 ; -break ; - } - }else if (ret != -EBUSY ) { +break ; + }else if (ret == -EBUSY ) { +continue ; + }else if (ret <0 ) { nated_port =0 ;break ; }
net/netfilter/nf_conntrack_expect.c +34 -1
@@ -425,7 +425,6 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp) exp->timeout += helper->expect_policy[exp->class].timeout *HZ ;hlist_add_head_rcu (&exp->lnode, &master_help->expectations); - master_help->expecting[exp->class]++;hlist_add_head_rcu (&exp->hnode, &nf_ct_expect_hash[h]); cnet =nf_ct_pernet (net);
@@ -524,6 +523,7 @@ int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,if (ret <0 ) goto out; +nfct_help (expect->master)->expecting[expect->class]++;nf_ct_expect_insert (expect);nf_ct_expect_event_report (IPEXP_NEW , expect, portid, report);
@@ -536,6 +536,39 @@ int nf_ct_expect_related_report(struct nf_conntrack_expect *expect, }EXPORT_SYMBOL_GPL (nf_ct_expect_related_report); +int nf_ct_expect_related_pair (struct nf_conntrack_expect *expect[], +unsigned int flags) +{ +struct nf_conn_help *master_help; +int i, ret; + +spin_lock_bh (&nf_conntrack_expect_lock); + master_help =nfct_help (expect[0 ]->master); +if (!master_help || master_help !=nfct_help (expect[1 ]->master)) { + ret = -EINVAL ; + goto out; + } + +for (i =0 ; i <2 ; i++) { + ret =__nf_ct_expect_check (expect[i], flags); +if (ret <0 ) { +if (i ==1 ) + master_help->expecting[expect[0 ]->class]--; + goto out; + } + master_help->expecting[expect[i]->class]++; + } + +for (i =0 ; i <2 ; i++) { +nf_ct_expect_insert (expect[i]); +nf_ct_expect_event_report (IPEXP_NEW , expect[i],0 ,0 ); + } +out: +spin_unlock_bh (&nf_conntrack_expect_lock); +return ret; +} +EXPORT_SYMBOL_GPL (nf_ct_expect_related_pair); +void nf_ct_expect_iterate_destroy (bool (*iter)(struct nf_conntrack_expect *e,void *data),void *data) {
net/netfilter/nf_nat_sip.c +6 -14
@@ -585,6 +585,7 @@ static unsigned int nf_nat_sdp_media(struct sk_buff *skb, unsigned int protoff,unsigned int medialen, union nf_inet_addr *rtp_addr) { + struct nf_conntrack_expect *rtp_pair[2] = { rtp_exp, rtcp_exp };enum ip_conntrack_info ctinfo;struct nf_conn *ct =nf_ct_get (skb, &ctinfo);enum ip_conntrack_dir dir =CTINFO2DIR (ctinfo);
@@ -615,24 +616,15 @@ static unsigned int nf_nat_sdp_media(struct sk_buff *skb, unsigned int protoff,int ret; rtp_exp->tuple.dst.u.udp.port =htons (port); - ret =nf_ct_expect_related (rtp_exp, -NF_CT_EXP_F_SKIP_MASTER ); -if (ret == -EBUSY ) -continue ; -else if (ret <0 ) { - port =0 ; -break ; - } rtcp_exp->tuple.dst.u.udp.port =htons (port +1 ); - ret =nf_ct_expect_related (rtcp_exp, -NF_CT_EXP_F_SKIP_MASTER ); + + ret =nf_ct_expect_related_pair (rtp_pair, +NF_CT_EXP_F_SKIP_MASTER );if (ret ==0 )break ; -else if (ret == -EBUSY ) { -nf_ct_unexpect_related (rtp_exp); +else if (ret == -EBUSY )continue ; - }else if (ret <0 ) { -nf_ct_unexpect_related (rtp_exp); +else if (ret <0 ) { port =0 ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 322/2857 sctp: auth: discard auth_chunk when skb_clone fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qing Luo <[email protected]>
[ Upstream commit 9ae7ed101cf28613071ebfbc42668c8917a670cf ]
When processing AUTH + COOKIE-ECHO packets, if skb_clone() fails due to memory pressure, chunk->auth_chunk is NULL. The original code still sets chunk->auth = 1 and continues, leaving the COOKIE-ECHO to be processed without a valid auth_chunk for deferred verification.
Discard the AUTH chunk early via pdiscard when skb_clone() fails, so that the receive loop can continue processing remaining chunks in the inqueue instead of stalling the entire packet.
--- net/sctp/associola.c | 4 ++++ net/sctp/endpointola.c | 4 ++++ 2 files changed, 8 insertions(+)
net/sctp/associola.c +4 -0
@@ -1029,6 +1029,10 @@ static void sctp_assoc_bh_rcv(struct work_struct *work)if (next_hdr->type ==SCTP_CID_COOKIE_ECHO ) { chunk->auth_chunk =skb_clone (chunk->skb,GFP_ATOMIC ); +if (!chunk->auth_chunk) { + chunk->pdiscard =1 ; +continue ; + } chunk->auth =1 ;continue ; }
net/sctp/endpointola.c +4 -0
@@ -362,6 +362,10 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work)if (next_hdr->type ==SCTP_CID_COOKIE_ECHO ) { chunk->auth_chunk =skb_clone (chunk->skb,GFP_ATOMIC ); +if (!chunk->auth_chunk) { + chunk->pdiscard =1 ; +continue ; + } chunk->auth =1 ;continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 323/2857 cxgb4: fix use after free bugs caused by circular dependency problem
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
[ Upstream commit e50b9b9e8610d47b7c22529443e45a16b1ea3a15 ]
The flower_stats_timer can schedule flower_stats_work and flower_stats_work can also arm the flower_stats_timer. The process is shown below:
----------- timer schedules work ------------ch_flower_stats_cb() //timer handler
schedule_work(&adap->flower_stats_work);
----------- work arms timer ------------ ch_flower_stats_handler() //workqueue callback function
mod_timer(&adap->flower_stats_timer, ...);
When the cxgb4 device is detaching, the timer and workqueue could still be rearmed. The process is shown below:
(cleanup routine) | (timer and workqueue routine)
remove_one() |
free_some_resources() | ch_flower_stats_cb() //timer
cxgb4_cleanup_tc_flower() | schedule_work()
del_timer_sync() |
| ch_flower_stats_handler() //workqueue
| mod_timer()
cancel_work_sync() |
kfree(adapter) //FREE | ch_flower_stats_cb() //timer
| adap->flower_stats_work //USEThis patch changes del_timer_sync() to timer_shutdown_sync(), which could prevent rearming of the timer from the workqueue.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +1 -1
@@ -1135,7 +1135,7 @@ void cxgb4_cleanup_tc_flower(struct adapter *adap)return ;if (adap->flower_stats_timer.function) -del_timer_sync (&adap->flower_stats_timer); +timer_shutdown_sync (&adap->flower_stats_timer);cancel_work_sync (&adap->flower_stats_work);rhashtable_destroy (&adap->flower_tbl); adap->tc_flower_initialized = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 324/2857 mtd: rawnand: pl353: Add message about ECC mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Scian <[email protected]>
[ Upstream commit 1e06dbfdfb851170b243d6498e442b449324c664 ]
This just add some information on kernel log about the selected ECC
Stable-dep-of: 80ecacd054ff ("mtd: rawnand: pl353: Make sure we use the monolithic helpers for raw accesses")
--- drivers/mtd/nand/raw/pl35x-nand-controller.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mtd/nand/raw/pl35x-nand-controller.c +3 -0
@@ -975,15 +975,18 @@ static int pl35x_nand_attach_chip(struct nand_chip *chip)switch (chip->ecc.engine_type) {case NAND_ECC_ENGINE_TYPE_ON_DIE : +dev_dbg (nfc->dev,"Using on-die ECC\n" );/* Keep these legacy BBT descriptors for ON_DIE situations */ chip->bbt_td = &bbt_main_descr; chip->bbt_md = &bbt_mirror_descr; fallthrough;case NAND_ECC_ENGINE_TYPE_NONE :case NAND_ECC_ENGINE_TYPE_SOFT : +dev_dbg (nfc->dev,"Using software ECC (Hamming 1-bit/512B)\n" ); chip->ecc.write_page_raw = nand_monolithic_write_page_raw;break ;case NAND_ECC_ENGINE_TYPE_ON_HOST : +dev_dbg (nfc->dev,"Using hardware ECC\n" ); ret =pl35x_nand_init_hw_ecc_controller (nfc, chip);if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 325/2857 mtd: rawnand: pl353: Make sure we use the monolithic helpers for raw accesses
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal (DAVE) <[email protected]>
[ Upstream commit 80ecacd054ffeb60cd28e46ed5cd6bd0d2de318b ]
Any access not using the hardware ECC engine should be monolithic because the controller has its very own way of handling the end of a transaction during operation configuration, so we cannot easily make repeated reads.
This has the side effect of fixing support for software ECC engines.
--- drivers/mtd/nand/raw/pl35x-nand-controller.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/pl35x-nand-controller.c +3 -2
@@ -916,7 +916,6 @@ static int pl35x_nand_init_hw_ecc_controller(struct pl35x_nandc *nfc, chip->ecc.steps = mtd->writesize / chip->ecc.size; chip->ecc.read_page = pl35x_nand_read_page_hwecc; chip->ecc.write_page = pl35x_nand_write_page_hwecc; - chip->ecc.write_page_raw = nand_monolithic_write_page_raw;pl35x_smc_set_ecc_pg_size (nfc, chip, mtd->writesize); nfc->ecc_buf = devm_kmalloc(nfc->dev, chip->ecc.bytes * chip->ecc.steps,
@@ -983,7 +982,6 @@ static int pl35x_nand_attach_chip(struct nand_chip *chip)case NAND_ECC_ENGINE_TYPE_NONE :case NAND_ECC_ENGINE_TYPE_SOFT :dev_dbg (nfc->dev,"Using software ECC (Hamming 1-bit/512B)\n" ); - chip->ecc.write_page_raw = nand_monolithic_write_page_raw;break ;case NAND_ECC_ENGINE_TYPE_ON_HOST :dev_dbg (nfc->dev,"Using hardware ECC\n" );
@@ -997,6 +995,9 @@ static int pl35x_nand_attach_chip(struct nand_chip *chip)return -EINVAL ; } + chip->ecc.read_page_raw = nand_monolithic_read_page_raw; + chip->ecc.write_page_raw = nand_monolithic_write_page_raw; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 326/2857 drm/sysfb: simpledrm: Improve framebuffer-size validation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit 03f1a3545b721fa7fdadd00080e237519a286a97 ]
Validate the framebuffer size from the firmware against the limitations of struct drm_display_mode. The type only stores sizes in 16-bit fields. Fail probing on errors.
v2:
- remove unused function simplefb_get_validated_int0() (Sashiko)
--- drivers/gpu/drm/tiny/simpledrm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tiny/simpledrm.c +1 -1
@@ -50,7 +50,7 @@ static int simplefb_get_validated_int0(struct drm_device *dev, const char *name, uint32_t value) { - if (!value) { + if (!value || value > U16_MAX) { drm_err(dev, "simplefb: invalid framebuffer %s of %u\n", name, value);return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 327/2857 KVM: nVMX: Decouple INVVPID operand checks from flushing of vpid02
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 32912404b4b1ee98400744941c78f019a63d6e8f ]
Separate the INVVPID operand checks from the actual flushing of vpid02 so the flushing can be adjusted to do the right thing when vmcs02 was last loaded on a different pCPU, without having to duplicate the logic across multiple case-statements.
Opportunistically let the VM-Fail paths poke out past 80 chars.
No functional change intended.
--- arch/x86/kvm/vmx/nested.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-)
arch/x86/kvm/vmx/nested.c +12 -26
@@ -5819,7 +5819,6 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)u64 vpid;u64 gla; } operand; -u16 vpid02;int r, gpr_index; if (!(vmx->nested.msrs.secondary_ctls_high &
@@ -5854,8 +5853,14 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)return kvm_handle_memory_failure (vcpu, r, &e);if (operand.vpid >>16 ) -return nested_vmx_fail (vcpu, -VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID ); +return nested_vmx_fail (vcpu,VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID ); + +if (type !=VMX_VPID_EXTENT_ALL_CONTEXT && !operand.vpid) +return nested_vmx_fail (vcpu,VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID ); + +if (type ==VMX_VPID_EXTENT_INDIVIDUAL_ADDR && +is_noncanonical_address (operand.gla, vcpu)) +return nested_vmx_fail (vcpu,VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID );/* * Always flush the effective vpid02, i.e. never flush the current VPID
@@ -5863,29 +5868,10 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)* VMCS, and so whether or not the current vmcs12 has VPID enabled is * irrelevant (and there may not be a loaded vmcs12). */ - vpid02 =nested_get_vpid02 (vcpu); -switch (type) { -case VMX_VPID_EXTENT_INDIVIDUAL_ADDR : -if (!operand.vpid || -is_noncanonical_address (operand.gla, vcpu)) -return nested_vmx_fail (vcpu, -VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID ); -vpid_sync_vcpu_addr (vpid02, operand.gla); -break ; -case VMX_VPID_EXTENT_SINGLE_CONTEXT : -case VMX_VPID_EXTENT_SINGLE_NON_GLOBAL : -if (!operand.vpid) -return nested_vmx_fail (vcpu, -VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID ); -vpid_sync_context (vpid02); -break ; -case VMX_VPID_EXTENT_ALL_CONTEXT : -vpid_sync_context (vpid02); -break ; -default : -WARN_ON_ONCE (1 ); -return kvm_skip_emulated_instruction (vcpu); - } +if (type ==VMX_VPID_EXTENT_INDIVIDUAL_ADDR ) +vpid_sync_vcpu_addr (nested_get_vpid02 (vcpu), operand.gla); +else +vpid_sync_context (nested_get_vpid02 (vcpu));/* * Sync the shadow page tables if EPT is disabled, L1 is invalidating
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 328/2857 KVM: nVM: Ensure INVVPID is emulated on the correct physical CPU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
[ Upstream commit 6d00e67326d831e6e610933a3800712f4ffe6ec1 ]
When emulating INVVPID, KVM executes INVVPID on the physical CPU using vpid02 (instead of the L1 assigned VPID), after doing some validations on the operands. However, it is possible that the physical CPU KVM executes INVVPID on is different from the CPU L2 is running on.
For example, in the following scenario:
- L2 runs on CPU #1 and exits to L1 (vmx->nested.vmcs02.cpu=1)
- L1 migrates to CPU #2 and executes INVVPID
- KVM executes INVVPID on CPU #2
- L1 migrates back to CPU #1 and runs L2 (vmx->nested.vmcs02.cpu=1)
The TLB entries on CPU #1 are never invalidated, because INVVPID was executed on CPU #2, and vmcs02 never ran on a different pCPU (i.e. vmx_vcpu_load_vmcs() will *not* request KVM_REQ_TLB_FLUSH).
Ensure that INVVPID is being executed on the same pCPU that L2 last ran on, and if not, fallback to clearing last_vpid=0 to trigger a full VPID flush on the next nested VM-Enter (as KVM will detect L1 using a different VPID for L2). If L2 ends up running on a different pCPU, KVM will flush the TLB anyway through vmx_vcpu_load_vmcs().
--- arch/x86/kvm/vmx/nested.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx/nested.c +10 -1
@@ -5820,6 +5820,7 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)u64 gla; } operand;int r, gpr_index; +int cpu; if (!(vmx->nested.msrs.secondary_ctls_high & SECONDARY_EXEC_ENABLE_VPID) ||
@@ -5867,11 +5868,19 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)* and never explicitly flush vpid01. INVVPID targets a VPID, not a * VMCS, and so whether or not the current vmcs12 has VPID enabled is * irrelevant (and there may not be a loaded vmcs12). +* +* If vmcs02 was last loaded on a different pCPU, then defer the flush +* by invalidating the nested VPID tracking to ensure that KVM performs +* the invalidation on the correct pCPU. */ -if (type ==VMX_VPID_EXTENT_INDIVIDUAL_ADDR ) + cpu =get_cpu (); +if (cpu != vmx->nested.vmcs02.cpu) + vmx->nested.last_vpid =0 ; +else if (type ==VMX_VPID_EXTENT_INDIVIDUAL_ADDR )vpid_sync_vcpu_addr (nested_get_vpid02 (vcpu), operand.gla);else vpid_sync_context (nested_get_vpid02 (vcpu)); +put_cpu ();/* * Sync the shadow page tables if EPT is disabled, L1 is invalidating
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 329/2857 crypto: atmel-ecc - avoid stale fallback key after set_secret failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit f07a0d251db7606e4792d2610788fbcc7b2c0d12 ]
Clear ->do_fallback before decoding a new ECDH secret and enable it only after the software fallback accepts a caller-provided private key. This avoids using a stale fallback key should crypto_kpp_set_secret() fail.
--- drivers/crypto/atmel-ecc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/atmel-ecc.c +4 -4
@@ -84,6 +84,7 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,kfree (ctx->public_key); ctx->public_key =NULL ; + ctx->do_fallback = false;if (crypto_ecdh_decode_key (buf, len, ¶ms) <0 ) {dev_err (&ctx->client->dev,"crypto_ecdh_decode_key failed\n" );
@@ -91,8 +92,9 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf, }if (params.key_size) { - ctx->do_fallback = true; -return crypto_kpp_set_secret (ctx->fallback, buf, len); + ret =crypto_kpp_set_secret (ctx->fallback, buf, len); + ctx->do_fallback = !ret; +return ret; } cmd =kmalloc (sizeof (*cmd),GFP_KERNEL );
@@ -103,8 +105,6 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,if (!public_key) goto free_cmd; - ctx->do_fallback = false; -atmel_i2c_init_genkey_cmd (cmd,DATA_SLOT_2 ); ret =atmel_i2c_send_receive (ctx->client, cmd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 330/2857 jbd2: use shrink_type type instead of bool type for __jbd2_journal_clean_checkpoint_list()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
[ Upstream commit 078760d950016f5982751f5512e69f26ad8feb31 ]
"enum shrink_type" can clearly express the meaning of the parameter of __jbd2_journal_clean_checkpoint_list(), and there is no need to use the bool type.
Stable-dep-of: f213e12ff5c9 ("jbd2: check need_resched() when skipping busy checkpoint buffers")
--- fs/jbd2/checkpoint.c | 16 +++++++++------- fs/jbd2/commit.c | 2 +- include/linux/jbd2.h | 4 +++- 3 files changed, 13 insertions(+), 9 deletions(-)
fs/jbd2/checkpoint.c +9 -7
@@ -367,8 +367,6 @@ int jbd2_cleanup_journal_tail(journal_t *journal)/* Checkpoint list management */ -enum shrink_type {SHRINK_DESTROY ,SHRINK_BUSY_STOP ,SHRINK_BUSY_SKIP }; -/* * journal_shrink_one_cp_list *
@@ -505,21 +503,25 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,* journal_clean_checkpoint_list * * Find all the written-back checkpoint buffers in the journal and release them. -* If 'destroy' is set, release all buffers unconditionally. +* If 'type' is SHRINK_DESTROY, release all buffers unconditionally. If 'type' +* is SHRINK_BUSY_STOP, will stop release buffers if encounters a busy buffer. +* To avoid wasting CPU cycles scanning the buffer list in some cases, don't +* pass SHRINK_BUSY_SKIP 'type' for this function. * * Called with j_list_lock held. */ -void __jbd2_journal_clean_checkpoint_list (journal_t *journal,bool destroy) +void __jbd2_journal_clean_checkpoint_list (journal_t *journal, +enum shrink_type type) {transaction_t *transaction, *last_transaction, *next_transaction; -enum shrink_type type;bool released; +WARN_ON_ONCE (type ==SHRINK_BUSY_SKIP ); + transaction = journal->j_checkpoint_transactions;if (!transaction)return ; - type = destroy ?SHRINK_DESTROY :SHRINK_BUSY_STOP ; last_transaction = transaction->t_cpprev; next_transaction = transaction; do {
@@ -560,7 +562,7 @@ void jbd2_journal_destroy_checkpoint(journal_t *journal)spin_unlock (&journal->j_list_lock);break ; } -__jbd2_journal_clean_checkpoint_list (journal, true); +__jbd2_journal_clean_checkpoint_list (journal,SHRINK_DESTROY );spin_unlock (&journal->j_list_lock);cond_resched (); }
fs/jbd2/commit.c +1 -1
@@ -535,7 +535,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)* frees some memory */ spin_lock (&journal->j_list_lock); -__jbd2_journal_clean_checkpoint_list (journal, false); +__jbd2_journal_clean_checkpoint_list (journal,SHRINK_BUSY_STOP );spin_unlock (&journal->j_list_lock);jbd2_debug (3 ,"JBD2: commit phase 1\n" );
include/linux/jbd2.h +3 -1
@@ -1443,7 +1443,9 @@ void jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block);extern void jbd2_journal_commit_transaction (journal_t *);/* Checkpoint list management */ -void __jbd2_journal_clean_checkpoint_list (journal_t *journal,bool destroy); +enum shrink_type {SHRINK_DESTROY ,SHRINK_BUSY_STOP ,SHRINK_BUSY_SKIP }; + +void __jbd2_journal_clean_checkpoint_list (journal_t *journal,enum shrink_type type);unsigned long jbd2_journal_shrink_checkpoint_list (journal_t *journal,unsigned long *nr_to_scan);int __jbd2_journal_remove_checkpoint (struct journal_head *);int jbd2_journal_try_remove_checkpoint (struct journal_head *jh);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 331/2857 jbd2: add prefix jbd2 for shrink_type
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
[ Upstream commit 26770a717cac57041d9414725e3e01dd19b08dd2 ]
As 'shrink_type' is exported. The module prefix 'jbd2' is added to distinguish from memory reclamation.
Stable-dep-of: f213e12ff5c9 ("jbd2: check need_resched() when skipping busy checkpoint buffers")
--- fs/jbd2/checkpoint.c | 22 +++++++++++----------- fs/jbd2/commit.c | 2 +- include/linux/jbd2.h | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-)
fs/jbd2/checkpoint.c +11 -11
@@ -378,7 +378,7 @@ int jbd2_cleanup_journal_tail(journal_t *journal)* Called with j_list_lock held. */ static unsigned long journal_shrink_one_cp_list (struct journal_head *jh, -enum shrink_type type, +enum jbd2_shrink_type type,bool *released) {struct journal_head *last_jh;
@@ -395,12 +395,12 @@ static unsigned long journal_shrink_one_cp_list(struct journal_head *jh, jh = next_jh; next_jh = jh->b_cpnext; -if (type ==SHRINK_DESTROY ) { +if (type ==JBD2_SHRINK_DESTROY ) { ret =__jbd2_journal_remove_checkpoint (jh); }else { ret =jbd2_journal_try_remove_checkpoint (jh);if (ret <0 ) { -if (type ==SHRINK_BUSY_SKIP ) +if (type ==JBD2_SHRINK_BUSY_SKIP )continue ;break ; }
@@ -470,7 +470,7 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal, tid = transaction->t_tid; freed =journal_shrink_one_cp_list (transaction->t_checkpoint_list, -SHRINK_BUSY_SKIP , &released); +JBD2_SHRINK_BUSY_SKIP , &released); nr_freed += freed; (*nr_to_scan) -=min (*nr_to_scan, freed);if (*nr_to_scan ==0 )
@@ -503,20 +503,20 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,* journal_clean_checkpoint_list * * Find all the written-back checkpoint buffers in the journal and release them. -* If 'type' is SHRINK_DESTROY, release all buffers unconditionally. If 'type' -* is SHRINK_BUSY_STOP, will stop release buffers if encounters a busy buffer. -* To avoid wasting CPU cycles scanning the buffer list in some cases, don't -* pass SHRINK_BUSY_SKIP 'type' for this function. +* If 'type' is JBD2_SHRINK_DESTROY, release all buffers unconditionally. If +* 'type' is JBD2_SHRINK_BUSY_STOP, will stop release buffers if encounters a +* busy buffer. To avoid wasting CPU cycles scanning the buffer list in some +* cases, don't pass JBD2_SHRINK_BUSY_SKIP 'type' for this function. * * Called with j_list_lock held. */ void __jbd2_journal_clean_checkpoint_list (journal_t *journal, -enum shrink_type type) +enum jbd2_shrink_type type) {transaction_t *transaction, *last_transaction, *next_transaction;bool released; -WARN_ON_ONCE (type ==SHRINK_BUSY_SKIP ); +WARN_ON_ONCE (type ==JBD2_SHRINK_BUSY_SKIP ); transaction = journal->j_checkpoint_transactions;if (!transaction)
@@ -562,7 +562,7 @@ void jbd2_journal_destroy_checkpoint(journal_t *journal)spin_unlock (&journal->j_list_lock);break ; } -__jbd2_journal_clean_checkpoint_list (journal,SHRINK_DESTROY ); +__jbd2_journal_clean_checkpoint_list (journal,JBD2_SHRINK_DESTROY );spin_unlock (&journal->j_list_lock);cond_resched (); }
fs/jbd2/commit.c +1 -1
@@ -535,7 +535,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)* frees some memory */ spin_lock (&journal->j_list_lock); -__jbd2_journal_clean_checkpoint_list (journal,SHRINK_BUSY_STOP ); +__jbd2_journal_clean_checkpoint_list (journal,JBD2_SHRINK_BUSY_STOP );spin_unlock (&journal->j_list_lock);jbd2_debug (3 ,"JBD2: commit phase 1\n" );
include/linux/jbd2.h +2 -2
@@ -1443,9 +1443,9 @@ void jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block);extern void jbd2_journal_commit_transaction (journal_t *);/* Checkpoint list management */ -enum shrink_type {SHRINK_DESTROY ,SHRINK_BUSY_STOP ,SHRINK_BUSY_SKIP }; +enum jbd2_shrink_type {JBD2_SHRINK_DESTROY ,JBD2_SHRINK_BUSY_STOP ,JBD2_SHRINK_BUSY_SKIP }; -void __jbd2_journal_clean_checkpoint_list (journal_t *journal,enum shrink_type type); +void __jbd2_journal_clean_checkpoint_list (journal_t *journal,enum jbd2_shrink_type type);unsigned long jbd2_journal_shrink_checkpoint_list (journal_t *journal,unsigned long *nr_to_scan);int __jbd2_journal_remove_checkpoint (struct journal_head *);int jbd2_journal_try_remove_checkpoint (struct journal_head *jh);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 332/2857 jbd2: check need_resched() when skipping busy checkpoint buffers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Kellermann <[email protected]>
[ Upstream commit f213e12ff5c9590b1034ae8da0e6d09665c772d0 ]
journal_shrink_one_cp_list() skips busy checkpoint buffers when called with JBD2_SHRINK_BUSY_SKIP. The continue statement on this path also skips the need_resched() check at the end of the loop body.
Consequently, when a checkpoint list contains mostly busy buffers, the shrinker can walk the entire list while holding journal->j_list_lock, even when a reschedule has been requested. Large checkpoint lists under memory pressure can therefore cause long lock hold times and leave other CPUs spinning on j_list_lock, resulting in soft lockups or RCU stalls.
Route the busy-buffer path through the need_resched() check so that the shrinker can release j_list_lock and reschedule promptly, restoring parity with the clean-buffer path, which already checks need_resched(). This does not change which checkpoint buffers are eligible for removal.
--- fs/jbd2/checkpoint.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/jbd2/checkpoint.c +2 -1
@@ -401,7 +401,7 @@ static unsigned long journal_shrink_one_cp_list(struct journal_head *jh, ret =jbd2_journal_try_remove_checkpoint (jh);if (ret <0 ) {if (type ==JBD2_SHRINK_BUSY_SKIP ) -continue ; + goto next;break ; } }
@@ -412,6 +412,7 @@ static unsigned long journal_shrink_one_cp_list(struct journal_head *jh,break ; } +next:if (need_resched ())break ; }while (jh != last_jh);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 333/2857 jbd2: bound shrinker scans by examined checkpoint buffers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Kellermann <[email protected]>
[ Upstream commit 15cb16496446b94e67f7abcb049b8e2c75cd3d02 ]
The jbd2 shrinker currently accounts only checkpoint buffers that it successfully releases against nr_to_scan. Busy buffers therefore do not consume the scan budget.
If a checkpoint transaction contains mostly busy buffers, the shrinker can scan its entire checkpoint list while holding journal->j_list_lock. Large checkpoint lists can result in excessive lock hold times and leave other CPUs spinning on j_list_lock, causing soft lockups or RCU stalls.
Pass nr_to_scan into journal_shrink_one_cp_list() and decrement it for every buffer examined, including busy buffers. Pass NULL from checkpoint cleanup paths so their existing full-list behavior is preserved.
This restores the scan-budget semantics that existed before journal_shrink_one_cp_list() was changed to always scan a complete checkpoint list.
--- fs/jbd2/checkpoint.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
fs/jbd2/checkpoint.c +13 -12
@@ -370,15 +370,16 @@ int jbd2_cleanup_journal_tail(journal_t *journal)/* * journal_shrink_one_cp_list * -* Find all the written-back checkpoint buffers in the given list -* and try to release them. If the whole transaction is released, set -* the 'released' parameter. Return the number of released checkpointed -* buffers. +* Find written-back checkpoint buffers in the given list and try to release +* them. If 'nr_to_scan' is set, scan at most that many buffers. If the whole +* transaction is released, set the 'released' parameter. Return the number of +* released checkpointed buffers. * * Called with j_list_lock held. */ static unsigned long journal_shrink_one_cp_list (struct journal_head *jh,enum jbd2_shrink_type type, +unsigned long *nr_to_scan,bool *released) {struct journal_head *last_jh;
@@ -387,13 +388,15 @@ static unsigned long journal_shrink_one_cp_list(struct journal_head *jh,int ret; *released = false; -if (!jh) +if (!jh || (nr_to_scan && !*nr_to_scan))return 0 ; last_jh = jh->b_cpprev; do { jh = next_jh; next_jh = jh->b_cpnext; + if (nr_to_scan) + (*nr_to_scan)--; if (type == JBD2_SHRINK_DESTROY) { ret = __jbd2_journal_remove_checkpoint(jh);
@@ -415,7 +418,7 @@ static unsigned long journal_shrink_one_cp_list(struct journal_head *jh, next:if (need_resched ())break ; - }while (jh != last_jh); + }while (jh != last_jh && (!nr_to_scan || *nr_to_scan));return nr_freed; }
@@ -437,7 +440,6 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,tid_t first_tid =0 , last_tid =0 , next_tid =0 ;tid_t tid =0 ;unsigned long nr_freed =0 ; -unsigned long freed;bool first_set = false; again:
@@ -470,10 +472,9 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal, next_transaction = transaction->t_cpnext; tid = transaction->t_tid; - freed =journal_shrink_one_cp_list (transaction->t_checkpoint_list, -JBD2_SHRINK_BUSY_SKIP , &released); - nr_freed += freed; - (*nr_to_scan) -=min (*nr_to_scan, freed); + nr_freed +=journal_shrink_one_cp_list (transaction->t_checkpoint_list, +JBD2_SHRINK_BUSY_SKIP , + nr_to_scan, &released);if (*nr_to_scan ==0 )break ;if (need_resched () ||spin_needbreak (&journal->j_list_lock))
@@ -529,7 +530,7 @@ void __jbd2_journal_clean_checkpoint_list(journal_t *journal, transaction = next_transaction; next_transaction = transaction->t_cpnext;journal_shrink_one_cp_list (transaction->t_checkpoint_list, - type, &released); + type,NULL , &released);/* * This function only frees up some memory if possible so we * dont have an obligation to finish processing. Bail out if
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 334/2857 KVM: x86: Always initialize EFER reserved bits on vendor initialization
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
[ Upstream commit a4b8acd428ba3f03952ef309d7f438dbc357557b ]
EFER reserved bits are statically initialized, and do not reset if a vendor module is re-loaded. For example, loading kvm_amd with nested=1 removes EFER.SVME (and potentially EFER.LMSLE) from the reserved bits. Reloading kvm_amd with nested=0 does not add them back, allowing userspace to set EFER.SVME with nested=0.
Re-initializing EFER reserved bits before configuring them on vendor initialization.
--- arch/x86/kvm/x86.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/kvm/x86.c +6 -0
@@ -12443,6 +12443,12 @@ int kvm_arch_hardware_setup(void *opaque)kvm_init_pmu_capability (); +#ifdef CONFIG_X86_64 + efer_reserved_bits = ~((u64)(EFER_SCE |EFER_LME |EFER_LMA )); +#else + efer_reserved_bits = ~((u64 )EFER_SCE ); +#endif + r = ops->hardware_setup ();if (r !=0 )return r;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 335/2857 KVM: x86: Check EFER validity on KVM_SET_SREGS*
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yosry Ahmed <[email protected]>
[ Upstream commit 184bd464bdb66daa9173670904f24c29c7b7f7d4 ]
When handling userspace SREGS writes, check the validity of EFER (i.e. allowed bits) before writing the new value of EFER through the per-vendor set_efer callbacks. This prevents userspace from writing bogus values (e.g. EFER.SVME=1 with nested=0).
Note: on KVM_SET_MSRS, KVM only checks EFER validity in terms of KVM caps, not guest caps, so it is possible to set EFER bits that are supported by KVM but not by the guest CPUID. Potentially allowing userspace to set msrs before CPUID.
However, for KVM_SET_SREGS*, check the validity of the set bits against both KVM and guest caps. This is consistent with other validity checks (e.g. for CR4) that check validity against guest caps, which already imposes the need to set CPUID before SREGS.
--- arch/x86/kvm/x86.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/x86.c +2 -1
@@ -11643,7 +11643,8 @@ static bool kvm_is_valid_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs) }return kvm_is_valid_cr4 (vcpu, sregs->cr4) && -kvm_is_valid_cr0 (vcpu, sregs->cr0); +kvm_is_valid_cr0 (vcpu, sregs->cr0) && +kvm_valid_efer (vcpu, sregs->efer); } static int __set_sregs_common(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 336/2857 PCI/AER: Emit TLP Log only for unmasked errors
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
[ Upstream commit a8bf2dd750de7d682fdaa2127f4e3217ce9c4a82 ]
Per PCIe r7.0 sec 6.2.5, the prefix and header of an offending TLP is only recorded for unmasked Uncorrectable Errors. Yet when the AER driver determines whether a prefix and header has been logged, it does not take the Uncorrectable Error Mask Register into account. Fix it.
--- drivers/pci/pcie/aer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pcie/aer.c +2 -2
@@ -779,7 +779,7 @@ void cper_print_aer(struct pci_dev *dev, int aer_severity, }else { status = aer->uncor_status; mask = aer->uncor_mask; - tlp_header_valid = status &AER_LOG_TLP_MASKS ; + tlp_header_valid = status & ~mask &AER_LOG_TLP_MASKS ; } layer =AER_GET_LAYER_ERROR (aer_severity, status);
@@ -1087,7 +1087,7 @@ int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)pci_read_config_dword (dev, aer +PCI_ERR_CAP , &temp); info->first_error =PCI_ERR_CAP_FEP (temp); -if (info->status &AER_LOG_TLP_MASKS ) { +if (info->status & ~info->mask &AER_LOG_TLP_MASKS ) { info->tlp_header_valid =1 ;pci_read_config_dword (dev, aer +PCI_ERR_HEADER_LOG , &info->tlp.dw0);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 337/2857 nvme-pci: disable controller on admin queue IRQ setup failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 08660a5c8d497f43191635d97efd31cd35051f15 ]
nvme_pci_configure_admin_queue() enables the controller and then requests the admin queue interrupt. If queue_request_irq() fails it returns without disabling the controller, and no caller compensates: nvme_pci_enable() only frees the IRQ vectors and calls pci_disable_device(), after which nvme_dev_disable() treats the controller as dead and skips nvme_disable_ctrl(). The controller is left enabled (CC.EN set) on this error path.
Disable it in the failure path, while the PCI device is still enabled so the CC.EN clear handshake completes.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/pci.c +1 -0
@@ -1892,6 +1892,7 @@ static int nvme_pci_configure_admin_queue(struct nvme_dev *dev) result =queue_request_irq (nvmeq);if (result) { dev->online_queues--; +nvme_disable_ctrl (&dev->ctrl);return result; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 338/2857 mm/rmap: use huge_ptep_get() in try_to_unmap_one()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dev Jain <[email protected]>
[ Upstream commit f5407e9b697c940e78b27ff63c6e14d8d171adc3 ]
Patch series "Fix incorrect access of hugetlb pte entries", v3.
There are various places which use ptep_get() to get the pte entry corresponding to a hugetlb folio. Some arches (like s390) have special handling to compute the pteval, so they provide huge_ptep_get(). Use this helper consistently.
Additionally, some code paths may provide huge_ptep_get with an unaligned address. This is a problem on arm64 (I checked other arches and it looks fine for them), which is fixed in patch 1. The fix is made to be
backport-friendly: the cleaner fix would be to perhaps pass the hstate to huge_ptep_get() - that is wider churn and we can do that later.
This patch (of 5):
try_to_unmap_one() handles hugetlb folios when memory failure needs to replace a poisoned hugetlb mapping with a hwpoison entry. In that case page_vma_mapped_walk() returns the pte pointer to the hugetlb folio in pvmw.pte, but the code reads it with ptep_get().
On arches which provide their own huge_ptep_get() to dereference a huge pte pointer, accessing via ptep_get() would cause pte_pfn(), pte_present() etc to misbehave.
It is not clear whether this has a trivially visible effect to userspace.
Just use huge_ptep_get() for dereferencing a huge pte pointer.
--- include/linux/hugetlb.h | 2 ++ mm/rmap.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
include/linux/hugetlb.h +2 -0
@@ -1199,6 +1199,8 @@ static inline void hugetlb_count_sub(long l, struct mm_struct *mm) { } +pte_t huge_ptep_get (pte_t *ptep); +static inline pte_t huge_ptep_clear_flush (struct vm_area_struct *vma,unsigned long addr,pte_t *ptep) {
mm/rmap.c +7 -2
@@ -1531,9 +1531,14 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,break ; } - subpage =folio_page (folio, -pte_pfn (*pvmw.pte) -folio_pfn (folio)); address = pvmw.address; +if (folio_test_hugetlb (folio)) + pteval =huge_ptep_get (pvmw.pte); +else + pteval =ptep_get (pvmw.pte); + + subpage =folio_page (folio, +pte_pfn (pteval) -folio_pfn (folio)); anon_exclusive =folio_test_anon (folio) &&PageAnonExclusive (subpage);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 339/2857 mm/rmap: use huge_ptep_get() in try_to_migrate_one()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dev Jain <[email protected]>
[ Upstream commit 9be12ffa78cd087d41086f937a156435d4e588e9 ]
try_to_migrate_one() is used by folio migration to replace a present mapping with a migration entry. For hugetlb folios, page_vma_mapped_walk() returns the pte pointer to the hugetlb folio in pvmw.pte, but the code reads the huge pte entry with ptep_get().
On arches which provide their own huge_ptep_get() to dereference a huge pte pointer, accessing via ptep_get() would cause pte_pfn(), pte_present() etc to misbehave.
It is not clear whether this has a trivially visible effect to userspace.
Use huge_ptep_get() to dereference a huge pte pointer.
Commit a98a2f0c8ce1 copied the bug from try_to_unmap_one into try_to_migrate_one.
[ sashal: Reworked the hugetlb pte read to fit the older code, using huge_ptep_get()/ptep_get() into pteval for subpage and declaring huge_ptep_get(ptep) with one argument. ]
--- mm/rmap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
mm/rmap.c +6 -1
@@ -1929,8 +1929,13 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma,VM_BUG_ON_FOLIO (folio_nr_pages (folio) >1 , folio); subpage = &folio->page; }else { +if (folio_test_hugetlb (folio)) + pteval =huge_ptep_get (pvmw.pte); +else + pteval =ptep_get (pvmw.pte); + subpage =folio_page (folio, -pte_pfn (*pvmw.pte) -folio_pfn (folio)); +pte_pfn (pteval) -folio_pfn (folio)); } address = pvmw.address; anon_exclusive = folio_test_anon(folio) &&
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 340/2857 mm/page_vma_mapped: use huge_ptep_get() for hugetlb
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dev Jain <[email protected]>
[ Upstream commit e87df0d5d6962bde50f55f6d02b779daa394f894 ]
check_pte() is the final validation step in page_vma_mapped_walk(). It reads pvmw->pte with ptep_get() to decide whether the entry maps the PFN range being walked. For hugetlb VMAs, that pointer refers to a hugetlb entry.
On arches which provide their own huge_ptep_get() to dereference a huge pte pointer, accessing via ptep_get() would cause pte_pfn(), pte_present() etc to misbehave.
It is not clear whether this has a trivially visible effect to userspace.
Use huge_ptep_get() to dereference a huge pte pointer.
--- mm/page_vma_mapped.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
mm/page_vma_mapped.c +12 -6
@@ -75,33 +75,39 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw)static bool check_pte (struct page_vma_mapped_walk *pvmw) {unsigned long pfn; +pte_t ptent; + +if (is_vm_hugetlb_page (pvmw->vma)) + ptent =huge_ptep_get (pvmw->pte); +else + ptent =ptep_get (pvmw->pte);if (pvmw->flags &PVMW_MIGRATION ) {swp_entry_t entry; -if (!is_swap_pte (*pvmw->pte)) +if (!is_swap_pte (ptent))return false; - entry =pte_to_swp_entry (*pvmw->pte); + entry =pte_to_swp_entry (ptent);if (!is_migration_entry (entry) && !is_device_exclusive_entry (entry))return false; pfn =swp_offset_pfn (entry); - }else if (is_swap_pte (*pvmw->pte)) { + }else if (is_swap_pte (ptent)) {swp_entry_t entry;/* Handle un-addressable ZONE_DEVICE memory */ - entry =pte_to_swp_entry (*pvmw->pte); + entry =pte_to_swp_entry (ptent);if (!is_device_private_entry (entry) && !is_device_exclusive_entry (entry))return false; pfn =swp_offset_pfn (entry); }else { -if (!pte_present (*pvmw->pte)) +if (!pte_present (ptent))return false; - pfn =pte_pfn (*pvmw->pte); + pfn =pte_pfn (ptent); }return (pfn - pvmw->pfn) < pvmw->nr_pages;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 341/2857 HID: input: read battery capacity from its actual report offset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jose Villaseñor Montfort <[email protected]>
[ Upstream commit d07644524b6511b622ee7b0e2e68c9ee43d522a4 ]
hidinput_query_battery_capacity() assumes the state-of-charge value is the first byte following the report ID (buf[1]) and ignores where the battery field actually sits within the report.
An Apple Magic Trackpad 2 precedes the AbsoluteStateOfCharge byte with a byte of status flags in its battery reports, so this query returns the flags byte instead of the charge level.
The device happens to make that easy to observe, because it exposes the same cell twice: its report descriptor declares AbsoluteStateOfCharge in two reports (0x90 and 0x9b), so hidinput_setup_battery() registers two power supplies. Only the first one is refreshed by hid-magicmouse -- it uses hid_get_battery(), which returns the first battery of the list -- and that refresh goes through the report event path, which parses the field correctly. Nothing ever reports the second one, so every read of its capacity takes the query path above. On a USB-C Magic Trackpad over USB, on an unpatched 7.1.5:
hid-<serial>-battery-144 = 100% (Charging) <- report event path hid-<serial>-battery-155 = 3% (Discharging) <- query path
Both are the same physical battery. A raw HIDIOCGINPUT of the two reports at that same moment:
report 0x90 -> [90 03 64]
report 0x9b -> [9b 03 64 64 00 00 10 00 00 00 00 00 00 00]
^flags ^SoC = 0x64 = 100%
The device answers correctly in both cases; only the offset the kernel reads the capacity from is wrong. 0x03 is the flags byte (present, charging), reported as "3%".
Bluetooth takes the same query path for its capacity, where the trackpad reported a bogus near-constant ~4% -- 0b100, the FullyCharged flag -- regardless of the real charge.
Store the battery field's offset within the report at setup time and use it when querying, so the capacity is read from its real position. The report event path already parses the field correctly through the HID core; only the explicit GET_REPORT query was wrong.
Devices whose capacity field is the first field in the report have a report_offset of 0 and are unaffected (buf[1 + 0] == buf[1]).
--- drivers/hid/hid-input.c | 17 +++++++++++++---- include/linux/hid.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/hid/hid-input.c +13 -4
@@ -437,19 +437,27 @@ static int hidinput_query_battery_capacity(struct hid_device *dev) {u8 *buf;int ret; +/* +* The capacity field may not be the first field in the report: some +* devices (e.g. the Apple Magic Trackpad 2 over Bluetooth) precede it +* with status flags. Read it from its actual byte offset in the report +* (report_offset is in bits; the leading byte is the report id). +*/ +int offset =1 + dev->battery_report_offset /8 ; +int len = offset +1 ; - buf =kmalloc (4 ,GFP_KERNEL ); + buf =kmalloc (max (len,4 ),GFP_KERNEL );if (!buf)return -ENOMEM ; - ret =hid_hw_raw_request (dev, dev->battery_report_id, buf,4 , + ret =hid_hw_raw_request (dev, dev->battery_report_id, buf,max (len,4 ), dev->battery_report_type,HID_REQ_GET_REPORT ); -if (ret <2 ) { +if (ret < len) {kfree (buf);return -ENODATA ; } - ret =hidinput_scale_battery_capacity (dev, buf[1 ]); + ret =hidinput_scale_battery_capacity (dev, buf[offset]);kfree (buf);return ret; }
@@ -567,6 +575,7 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type, dev->battery_max = max; dev->battery_report_type = report_type; dev->battery_report_id = field->report->id; + dev->battery_report_offset = field->report_offset; dev->battery_charge_status =POWER_SUPPLY_STATUS_DISCHARGING ;/*
include/linux/hid.h +1 -0
@@ -645,6 +645,7 @@ struct hid_device { /* device report descriptor */__s32 battery_max;__s32 battery_report_type;__s32 battery_report_id; +__s32 battery_report_offset;__s32 battery_charge_status;enum hid_battery_status battery_status;bool battery_avoid_query;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 342/2857 f2fs: dirty directory inodes on mtime/ctime update
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joanne Chang <[email protected]>
[ Upstream commit 9ec09d5f4b317a417c8655c14056f70cbe71eb6c ]
Xfstests generic/547 sometimes fail with mismatched directory metadata before and after a power failure. This happens because when a directory entry is added, renamed, or deleted, its mtime and ctime are updated and the inode is marked dirty via f2fs_mark_inode_dirty_sync(dir, sync=false). The sync=false flag means the dirty inode is not added to the global DIRTY_META list. Therefore, subsequent checkpoints skip flushing these updated directory blocks, causing directory timestamps to revert to stale values after a sudden power failure.
Address this by changing the dirtying parameter to sync=true during directory entry mutations and renames. This forces F2FS to immediately queue the updated directory blocks on the global DIRTY_META list, ensuring timestamps are committed to checkpoints.
--- fs/f2fs/dir.c | 6 +++--- fs/f2fs/inline.c | 2 +- fs/f2fs/namei.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-)
fs/f2fs/dir.c +3 -3
@@ -514,7 +514,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,set_page_dirty (page); dir->i_mtime = dir->i_ctime =current_time (dir); -f2fs_mark_inode_dirty_sync (dir, false); +f2fs_mark_inode_dirty_sync (dir, true);f2fs_put_page (page,1 ); }
@@ -668,7 +668,7 @@ void f2fs_update_parent_metadata(struct inode *dir, struct inode *inode,clear_inode_flag (inode,FI_NEW_INODE ); } dir->i_mtime = dir->i_ctime =current_time (dir); -f2fs_mark_inode_dirty_sync (dir, false); +f2fs_mark_inode_dirty_sync (dir, true);if (F2FS_I (dir)->i_current_depth != current_depth)f2fs_i_depth_write (dir, current_depth);
@@ -984,7 +984,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,f2fs_put_page (page,1 ); dir->i_ctime = dir->i_mtime =current_time (dir); -f2fs_mark_inode_dirty_sync (dir, false); +f2fs_mark_inode_dirty_sync (dir, true);if (inode)f2fs_drop_nlink (dir, inode);
fs/f2fs/inline.c +1 -1
@@ -711,7 +711,7 @@ void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page,f2fs_put_page (page,1 ); dir->i_ctime = dir->i_mtime =current_time (dir); -f2fs_mark_inode_dirty_sync (dir, false); +f2fs_mark_inode_dirty_sync (dir, true);if (inode)f2fs_drop_nlink (dir, inode);
fs/f2fs/namei.c +3 -3
@@ -1021,7 +1021,7 @@ static int f2fs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,f2fs_up_write (&F2FS_I (old_inode)->i_sem); old_inode->i_ctime =current_time (old_inode); -f2fs_mark_inode_dirty_sync (old_inode, false); +f2fs_mark_inode_dirty_sync (old_inode, true);f2fs_delete_entry (old_entry, old_page, old_dir,NULL ); old_page =NULL ;
@@ -1193,7 +1193,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,f2fs_i_links_write (old_dir, old_nlink >0 );f2fs_up_write (&F2FS_I (old_dir)->i_sem); } -f2fs_mark_inode_dirty_sync (old_dir, false); +f2fs_mark_inode_dirty_sync (old_dir, true);/* update directory entry info of new dir inode */ f2fs_set_link (new_dir, new_entry, new_page, old_inode);
@@ -1212,7 +1212,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,f2fs_i_links_write (new_dir, new_nlink >0 );f2fs_up_write (&F2FS_I (new_dir)->i_sem); } -f2fs_mark_inode_dirty_sync (new_dir, false); +f2fs_mark_inode_dirty_sync (new_dir, true);if (F2FS_OPTION (sbi).fsync_mode ==FSYNC_MODE_STRICT ) {f2fs_add_ino_entry (sbi, old_dir->i_ino,TRANS_DIR_INO );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 343/2857 spi: bcm63xx-hsspi: disable clocks on resume failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Can Peng <[email protected]>
[ Upstream commit 3b0cee02664041aea7e4f787c66cb86c82eb4e97 ]
bcm63xx_hsspi_resume() enables the HSSPI clock, and optionally the PLL clock, before restarting the SPI controller queue.
If spi_controller_resume() fails, the function currently reports success and leaves those clocks enabled. Propagate the error and disable the clocks before returning.
--- drivers/spi/spi-bcm63xx-hsspi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/spi/spi-bcm63xx-hsspi.c +7 -1
@@ -511,7 +511,13 @@ static int bcm63xx_hsspi_resume(struct device *dev) } } -spi_master_resume (master); + ret =spi_master_resume (master); +if (ret) { +if (bs->pll_clk) +clk_disable_unprepare (bs->pll_clk); +clk_disable_unprepare (bs->clk); +return ret; + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 344/2857 module: validate string table section types
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thiébaud Weksteen <[email protected]>
[ Upstream commit 9a5ff45689329835f874cefe5174e577d141d423 ]
In elf_validity_cache_sechdrs, section sizes and offsets are validated, unless the section type is SHT_NULL or SHT_NOBITS.
Later, elf_validity_cache_secstrings and elf_validity_cache_index_str access the section name table (.shstrtab) and symbol string table (.strtab) headers without first ensuring that their types are SHT_STRTAB. If a section type is SHT_NULL or SHT_NOBITS, sh_offset has not been validated and may reference out-of-bounds memory when dereferenced in elf_validity_cache_secstrings or elf_validity_cache_strtab.
Validate that both string section headers are of type SHT_STRTAB before caching them.
--- kernel/module/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/module/main.c +10 -0
@@ -1722,6 +1722,11 @@ static int elf_validity_check(struct load_info *info) } strhdr = &info->sechdrs[info->hdr->e_shstrndx]; +if (strhdr->sh_type !=SHT_STRTAB ) { +pr_err ("Invalid ELF section name table type: %u\n" , strhdr->sh_type); + goto no_exec; + } + err =validate_section_offset (info, strhdr);if (err <0 ) {pr_err ("Invalid ELF section hdr(type %u)\n" , strhdr->sh_type);
@@ -1769,6 +1774,11 @@ static int elf_validity_check(struct load_info *info) info->hdr->e_shnum); goto no_exec; } +if (info->sechdrs[shdr->sh_link].sh_type !=SHT_STRTAB ) { +pr_err ("Invalid ELF symbol string table type: %u\n" , + info->sechdrs[shdr->sh_link].sh_type); + goto no_exec; + } fallthrough;default : err =validate_section_offset (info, shdr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 345/2857 scsi: qla2xxx: Clamp max_npiv_vports to VP_CTRL bitmap capacity
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nilesh Javali <[email protected]>
[ Upstream commit 2ac6a829843cf3df522d19e091276109b94c4c7a ]
ha->max_npiv_vports is taken from firmware (mcp->mb[11]) and only constrained so that (max_npiv_vports + 1) is a multiple of MIN_MULTI_ID_FABRIC, which permits values of 63, 127, 191 and 255. NPIV vports are then allocated up to that count.
VP enable uses the VP_CONFIG IOCB, which addresses a vport through a plain vp_index byte, so a vp_index beyond 128 is enabled without issue. VP disable, however, uses the VP_CTRL IOCB, which selects target vports through the fixed 128-bit vp_idx_map bitmap. qla24xx_control_vp() rejects a vp_index past that bitmap and the IOCB builder cannot set a bit beyond 127, yet qla24xx_vport_delete() frees the local state regardless. A vport with vp_index > 128 can therefore be created and enabled but never disabled, leaving it permanently active in firmware: a resource leak.
Cap ha->max_npiv_vports at init to the vp_idx_map capacity so such vports are never created. This collapses 191/255 to 127 (still modulo-valid) and leaves the real-world 63/127 cases unaffected.
--- drivers/scsi/qla2xxx/qla_fw.h | 4 ++++ drivers/scsi/qla2xxx/qla_init.c | 13 +++++++++++++ drivers/scsi/qla2xxx/qla_mid.c | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_fw.h +4 -0
@@ -1442,6 +1442,10 @@ struct vp_ctrl_entry_24xx {uint8_t reserved_5[24 ]; }; +/* vp_idx_map is a 128-bit (16-byte) bitmap selecting target VPs. */ +#define VP_CTRL_IDX_MAP_BITS \ + (sizeof_field(struct vp_ctrl_entry_24xx, vp_idx_map) * 8) +/* * Modify Virtual Port Configuration IOCB */
drivers/scsi/qla2xxx/qla_init.c +13 -0
@@ -4404,6 +4404,19 @@ qla2x00_setup_chip(scsi_qla_host_t *vha) MIN_MULTI_ID_FABRIC)) ha->max_npiv_vports =MIN_MULTI_ID_FABRIC -1 ; + +/* +* The VP_CTRL IOCB selects target VPs +* through the fixed vp_idx_map bitmap, +* so a vp_index beyond it can be enabled +* via VP_CONFIG but never disabled via +* VP_CTRL, leaking the VP. Cap the count +* to the bitmap capacity. +*/ +if (ha->max_npiv_vports >= +VP_CTRL_IDX_MAP_BITS ) + ha->max_npiv_vports = +VP_CTRL_IDX_MAP_BITS -1 ; }qla2x00_get_resource_cnts (vha);qla_init_iocb_limit (vha);
drivers/scsi/qla2xxx/qla_mid.c +1 -1
@@ -976,7 +976,7 @@ int qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)* (16-byte) vp_idx_map bitmap, so vp_index must fit within it even * if firmware advertises more NPIV vports. */ - if (vp_index > sizeof_field(struct vp_ctrl_entry_24xx, vp_idx_map) * 8) +if (vp_index >VP_CTRL_IDX_MAP_BITS )return QLA_PARAMETER_ERROR ;/* ref: INIT */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 346/2857 x86/locking: Use sfence for wmb() if SSE is available
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yao Zi <[email protected]>
[ Upstream commit d824ed1307680dd482f607b0e707c575f70668c4 ]
When adding cc clobber to wmb()'s definition, the alternative() condition to use sfence was incorrectly raised from X86_FEATURE_XMM to X86_FEATURE_XMM2.
Restore the correct constraint for potential better performance on machines without SSE2.
--- arch/x86/include/asm/barrier.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/barrier.h +1 -1
@@ -17,7 +17,7 @@#define rmb () asm volatile(ALTERNATIVE("lock; addl $0,-4(%%esp)", "lfence", \ X86_FEATURE_XMM2) ::: "memory", "cc")#define wmb () asm volatile(ALTERNATIVE("lock; addl $0,-4(%%esp)", "sfence", \ - X86_FEATURE_XMM2) ::: "memory", "cc") + X86_FEATURE_XMM) ::: "memory", "cc")#else #define __mb () asm volatile("mfence":::"memory")#define __rmb () asm volatile("lfence":::"memory")
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 347/2857 btrfs: do not overwrite NODATASUM flag when removing NODATACOW flag
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 15f7c86215e8d5f14b24127fa88af6c79363d50e ]
[TEST FAILURE]
The test case generic/628 will fail if MOUNT_OPTIONS is set to "-o nodatasum":
FSTYP -- btrfs PLATFORM -- Linux/x86_64 btrfs-vm 7.1.0-rc4-custom+ #383 SMP PREEMPT_DYNAMIC Sat May 30 07:35:42 ACST 2026 MKFS_OPTIONS -- -O bgt -K /dev/mapper/test-scratch1
MOUNT_OPTIONS -- -o nodatasum /dev/mapper/test-scratch1 /mnt/scratch
# generic/628 1s ... - output mismatch (see /home/adam/xfstests/results//generic/628.out.bad)
# --- tests/generic/628.out 2022-05-11 11:25:30.816666664 +0930 # +++ /home/adam/xfstests/results//generic/628.out.bad 2026-06-08 18:56:49.878542927 +0930 # @@ -8,8 +8,9 @@ # 310f146ce52077fcd3308dcbe7632bb2 SCRATCH_MNT/a # 310f146ce52077fcd3308dcbe7632bb2 SCRATCH_MNT/d # test reflink flag not set iflag # +XFS_IOC_CLONE: Invalid argument # 310f146ce52077fcd3308dcbe7632bb2 SCRATCH_MNT/a # -310f146ce52077fcd3308dcbe7632bb2 SCRATCH_MNT/b # +d41d8cd98f00b204e9800998ecf8427e SCRATCH_MNT/b
# ...
[CAUSE]
The direct cause is that after "chattr +S", the btrfs inode will lose its NODATASUM flag inherited from the mount option. E.g.:
# mkfs.btrfs -f $dev
# mount $dev $mnt -o nodatasum
# touch $mnt/foobar
# sync
# btrfs ins dump-tree -t 5 $dev | grep "(257 INODE_ITEM 0) itemoff" -A 3
item 4 key (257 INODE_ITEM 0) itemoff 15879 itemsize 160
generation 9 transid 9 size 0 nbytes 0
block group 0 mode 100644 links 1 uid 0 gid 0 rdev 0
sequence 1 flags 0x1(NODATASUM)
^^^^^^^^^ Proper NODATASUM flag # chattr +S $mnt/foobar
# sync
# btrfs ins dump-tree -t 5 $dev | grep "(257 INODE_ITEM 0) itemoff" -A 3
item 4 key (257 INODE_ITEM 0) itemoff 15879 itemsize 160
generation 9 transid 10 size 0 nbytes 0
block group 0 mode 100644 links 1 uid 0 gid 0 rdev 0
sequence 2 flags 0x20(SYNC)
^^^^ Only the new SYNC flagThis makes the inode drop the old NODATASUM flag, while the new reflink destination will still inherit the NODATASUM flag. The mismatching NODATASUM flags will cause the reflink to fail.
The root cause is that, inside btrfs_fileattr_set() if no FS_NOCOW_FL is set, we remove both NODATASUM and NODATACOW flag.
However we should not touch NODATASUM flag, as data COW doesn't require checksum. Only NODATACOW implies NODATASUM, but DATACOW doesn't imply DATASUM.
The deeper problems are:
- Fileattr API is too binary
It either clears or sets a flag, there is no "do not change" option. So that why "chattr +S" implies "chattr -C", and is forcing us to change NODATACOW along with NODATASUM flag.
- No way to change NODATASUM through fileattr API
In fact NODATASUM can only be modified through mount option.
The deeper problems are much harder to attack.
[FIX]
Remove NODATACOW flag when FS_NOCOW_FL is not set, but only remove NODATASUM if "nodatasum" mount option is not set.
This allows the existing "chattr +C" then "chattr -C" to remove both NODATACOW and NODATASUM flags on a default mount.
But for a mount with "nodatasum" option, the NODATASUM inode flag will persist through either "chattr +C" and "chattr -C".
--- fs/btrfs/ioctl.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
fs/btrfs/ioctl.c +15 -8
@@ -310,14 +310,21 @@ int btrfs_fileattr_set(struct user_namespace *mnt_userns, binode_flags |=BTRFS_INODE_NODATACOW ; } }else { -/* -* Revert back under same assumptions as above -*/ -if (S_ISREG (inode->i_mode)) { -if (inode->i_size ==0 ) - binode_flags &= ~(BTRFS_INODE_NODATACOW | -BTRFS_INODE_NODATASUM ); - }else { +/* We can only change NODATACOW for zero-sized regular file. */ +if (S_ISREG (inode->i_mode) && (inode->i_size ==0 )) { + binode_flags &= ~BTRFS_INODE_NODATACOW ; +/* +* There is currently no way to change NODATASUM flag +* through fileattr API. If we unconditionally keep the +* current NODATASUM flag, chattr +C then chattr -C will +* keep the NODATASUM flag, and no way to remove that +* flag. +* +* So respect the current mount option for NODATASUM flag. +*/ +if (!btrfs_test_opt (fs_info,NODATASUM )) + binode_flags &= ~BTRFS_INODE_NODATASUM ; + }else if (!S_ISREG (inode->i_mode)) { binode_flags &= ~BTRFS_INODE_NODATACOW ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 348/2857 i3c: master: Fix potential UAF in i3c_device_uevent()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit e5e8dd2e959f470524c16ca444d001c90d6bb3ad ]
i3c_device_uevent() dereferences i3cdev->desc without holding the bus normal-use lock. Since the descriptor pointer can be replaced concurrently, including when a uevent is generated from sysfs, this can result in dereferencing a stale descriptor and lead to a use-after-free.
Use i3c_device_get_info() instead, which protects access to the descriptor with the normal-use lock.
Commit 6cf7b65f7029 ("i3c: Use i3cdev->desc->info instead of calling i3c_device_get_info() to avoid deadlock") replaced the accessor with a direct descriptor dereference because i3c_device_get_info() would recursively acquire bus->lock during device registration.
This change depends on "i3c: master: Fix recursive locking during device registration", which moves device registration out from under bus->lock and removes the possibility of that deadlock. Without that change, restoring the i3c_device_get_info() call would reintroduce the deadlock.
--- drivers/i3c/master.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/i3c/master.c +1 -2
@@ -280,8 +280,7 @@ static int i3c_device_uevent(struct device *dev, struct kobj_uevent_env *env)struct i3c_device_info devinfo;u16 manuf, part, ext; -if (i3cdev->desc) - devinfo = i3cdev->desc->info; +i3c_device_get_info (i3cdev, &devinfo); manuf =I3C_PID_MANUF_ID (devinfo.pid); part =I3C_PID_PART_ID (devinfo.pid); ext =I3C_PID_EXTRA_INFO (devinfo.pid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 349/2857 sticon/parisc: Detect default STI graphics card for console output
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
[ Upstream commit de508ece1d37cdbbbfa52f074954310f9b066b13 ]
If a machine has multiple graphic cards, detect the graphic card which is used to display firmware messages and use that one as the default graphic card for sticon and fbcon.
On parisc machines the default graphic card used for BCH (boot console handler, aka BIOS menu) is stored in the stable storage (equivalent to CMOS storage on x86) or in the console path in page zero. Extract that path and store it as default STI path for later comparism. Take care that the graphic card can be a GSC or a PCI card which use different path strings.
Increase max string size for default_sti_path to 32 chars as the print_pa_hwpath() function formats a hardware path using unbounded sprintf calls for up to 6 bus converter components and 1 module component (e.g., 255/255/...), which can produce a string up to 28 bytes long.
--- drivers/video/console/sticore.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/video/console/sticore.c +21 -1
@@ -284,7 +284,7 @@ static void sti_rom_copy(unsigned long base, unsigned long count, void *dest) -static char default_sti_path[21 ]__read_mostly ; +static char default_sti_path[32 ]__read_mostly ;#ifndef MODULE static int __init sti_setup (char *str)
@@ -1096,6 +1096,26 @@ static void sti_init_roms(void)pr_info ("STI GSC/PCI core graphics driver " STI_DRIVERVERSION "\n" ); +/* +* Find default console by hardware path which is either stored in +* console entry in stable storage or alternatively from console path +* in PAGE0 used by BCH and PDC. +*/ +if (!default_sti_path[0 ]) { +struct pdc_module_path conspath; +struct device *dev =NULL ; + +if (pdc_stable_read (0x60 , &conspath,sizeof (conspath)) ==PDC_OK ) + dev =hwpath_to_device (&conspath.path); +if (!dev) + dev =hwpath_to_device (&PAGE0 ->mem_cons.dp.path); +if (dev &&dev_is_pci (dev)) +print_pci_hwpath (to_pci_dev (dev), default_sti_path); +else if (dev && !dev_is_pci (dev)) +print_pa_hwpath (to_parisc_device (dev), default_sti_path); +pr_debug ("default graphic card: %s\n" , default_sti_path); + } +/* Register drivers for native & PCI cards */ register_parisc_driver (&pa_sti_driver);WARN_ON (pci_register_driver (&pci_sti_driver));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 350/2857 futex: Sanitize and document task_struct::futex::state transitions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
[ Upstream commit f9ece060cc43eae8a1f148737d193ba0d07b8f88 ]
The futex state is used to prevent a waiter from attaching to the lock owner while the owner runs the futex cleanup in exit() or exec().
Only the state transition from FUTEX_STATE_OK to FUTEX_STATE_EXITING must be done with the task's pi_lock held, the transition away from FUTEX_STATE_EXITING has no serialization requirements on the writer side, but it's completely non obvious why. It's magically protected by exit_pi_state(), which operates under tsk::pi_lock, as that's the state which has to be correct when the waiter observes the new state.
OTOH, taking the pi_lock in futex_cleanup_end() is not a performance issue because at that point the lock should be uncontended in the vast majority of cases.
Aside of that the handling of FUTEX_STATE_EXITING in attach_to_pi_owner() and handle_exit_race() is confusing at best.
Protect the store in futex_cleanup_end() with tsk::pi_lock, handle FUTEX_STATE_EXITING in attach_to_pi_owner() explicitly and document how this is supposed to work.
--- kernel/futex/core.c | 8 ++-- kernel/futex/pi.c | 100 +++++++++++++++++++++++++++++++------------- 2 files changed, 73 insertions(+), 35 deletions(-)
kernel/futex/core.c +3 -5
@@ -1126,11 +1126,9 @@ static void futex_cleanup_begin(struct task_struct *tsk)static void futex_cleanup_end (struct task_struct *tsk,int state) { -/* -* Lockless store. The only side effect is that an observer might -* take another loop until it becomes visible. -*/ - tsk->futex_state = state; +scoped_guard (raw_spinlock_irq, &tsk->pi_lock) + tsk->futex_state = state; +/* * Drop the exit protection. This unblocks waiters which observed * FUTEX_STATE_EXITING to reevaluate the state.
kernel/futex/pi.c +70 -30
134 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 351/2857 svcrdma: Clear sc_cm_id when ADDR_CHANGE replacement fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 01500306e1d50de7ca7a2cdcdfa28ac0523eb747 ]
When svc_rdma_listen_handler() handles RDMA_CM_EVENT_ADDR_CHANGE, it creates a replacement listener cm_id and returns 1, telling the CM core to destroy the old one. If the replacement allocation fails, sc_cm_id still points at the old cm_id that the CM core is about to destroy. Any subsequent dereference of sc_cm_id -- such as svc_rdma_detach()'s rdma_disconnect() call -- is a use-after-free.
NULL sc_cm_id on the failure path and guard svc_rdma_detach()'s rdma_disconnect() call against NULL so that the listener can be torn down safely when the server shuts down.
--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/sunrpc/xprtrdma/svc_rdma_transport.c +5 -2
@@ -305,6 +305,7 @@ static int svc_rdma_listen_handler(struct rdma_cm_id *cma_id,if (IS_ERR (listen_id)) {pr_err ("Listener dead, address change failed for device %s\n" , cma_id->device->name); + cma_xprt->sc_cm_id =NULL ; }else cma_xprt->sc_cm_id = listen_id;return 1 ;
@@ -584,7 +585,8 @@ static void svc_rdma_detach(struct svc_xprt *xprt)struct svcxprt_rdma *rdma = container_of(xprt, struct svcxprt_rdma, sc_xprt); -rdma_disconnect (rdma->sc_cm_id); +if (rdma->sc_cm_id) +rdma_disconnect (rdma->sc_cm_id); }static void __svc_rdma_free (struct work_struct *work)
@@ -616,7 +618,8 @@ static void __svc_rdma_free(struct work_struct *work)ib_dealloc_pd (rdma->sc_pd);/* Destroy the CM ID */ -rdma_destroy_id (rdma->sc_cm_id); +if (rdma->sc_cm_id) +rdma_destroy_id (rdma->sc_cm_id);kfree (rdma); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 352/2857 nfsd: convert nfsd_net boolean flags to unsigned long flags word
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit 11a5fe42e1811f793e04ef885b639ea7668f439d ]
nfsd_net contains several boolean fields that are accessed from concurrent contexts without serialization. In particular, nfsd4_end_grace() guards its drain path with a plain bool:
if (nn->grace_ended)
return;
nn->grace_ended = true;The read and the write are independent, and nothing in struct nfsd_net serializes them. At least two contexts can reach this code with no lock held:
laundromat path
laundry_wq kworker
nfs4_laundromat()
nfsd4_end_grace()
RECLAIM_COMPLETE path
nfsd compound kthread
nfsd4_reclaim_complete()
inc_reclaim_complete()
nfsd4_end_grace()Both callers can observe grace_ended == false on different CPUs, both store true, and both proceed into nfsd4_record_grace_done(), which invokes the active client_tracking_ops->grace_done callback. For tracking ops that drain reclaim_str_hashtbl (legacy_tracking_ops via nfsd4_recdir_purge_old, and the cld v1+ ops via nfsd4_cld_grace_done), grace_done calls nfs4_release_reclaim(), which walks every bucket of reclaim_str_hashtbl with no lock and calls nfs4_remove_reclaim_record() (list_del + kfree) on each entry. Two concurrent walkers corrupt the list and double-free every nfs4_client_reclaim. A concurrent nfsd4_find_reclaim_client() iterating the same bucket reads through freed memory.
A third call site exists in nfs4_state_start_net() on the skip_grace startup path, but it runs under nfsd_mutex before any client has connected and before the laundromat's first delayed work fires, so it cannot race with the two callers above.
Replace the scattered boolean fields in nfsd_net with a single unsigned long flags word and an enum nfsd_net_flag for the bit positions. The grace_ended race is fixed by using test_and_set_bit(), which is atomic on all architectures. The remaining flags (grace_end_forced, in_grace, somebody_reclaimed, track_reclaim_completes, nfsd_net_up, lockd_up) are converted to use test_bit/set_bit/clear_bit for consistency. This avoids sub-word cmpxchg issues on architectures like Hexagon that only support word-sized atomic operations.
--- fs/nfsd/netns.h | 19 +++++++++++-------- fs/nfsd/nfs4proc.c | 2 +- fs/nfsd/nfs4recover.c | 12 ++++++------ fs/nfsd/nfs4state.c | 41 +++++++++++++++++++++++++---------------- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfssvc.c | 20 ++++++++++---------- 6 files changed, 54 insertions(+), 42 deletions(-)
fs/nfsd/netns.h +11 -8
@@ -25,6 +25,16 @@struct cld_net ;struct nfsd4_client_tracking_ops ; +enum nfsd_net_flag { +NFSD_NET_GRACE_ENDED , +NFSD_NET_GRACE_END_FORCED , +NFSD_NET_IN_GRACE , +NFSD_NET_SOMEBODY_RECLAIMED , +NFSD_NET_TRACK_RECLAIM_COMPLETES , +NFSD_NET_UP , +NFSD_NET_LOCKD_UP , +}; +enum {/* cache misses due only to checksum comparison failures */ NFSD_STATS_PAYLOAD_MISSES ,
@@ -63,9 +73,8 @@ struct nfsd_net {struct cache_detail *nametoid_cache;struct lock_manager nfsd4_manager; -bool grace_ended; -bool grace_end_forced;bool client_tracking_active; +unsigned long flags;time64_t boot_time;time64_t boot_time_bt;/* same instant in CLOCK_BOOTTIME */
@@ -113,19 +122,13 @@ struct nfsd_net {spinlock_t blocked_locks_lock;struct file *rec_file; -bool in_grace;const struct nfsd4_client_tracking_ops *client_tracking_ops;time64_t nfsd4_lease;time64_t nfsd4_grace; -bool somebody_reclaimed; -bool track_reclaim_completes;atomic_t nr_reclaim_complete; -bool nfsd_net_up; -bool lockd_up; -seqlock_t writeverf_lock;unsigned char writeverf[8 ];
fs/nfsd/nfs4proc.c +1 -1
@@ -592,7 +592,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,pr_warn ("nfsd4_process_open2 failed to open newly-created file: status=%u\n" ,be32_to_cpu (status));if (reclaim && !status) - nn->somebody_reclaimed = true; +set_bit (NFSD_NET_SOMEBODY_RECLAIMED , &nn->flags); out:if (open->op_filp) {fput (open->op_filp);
fs/nfsd/nfs4recover.c +6 -6
@@ -228,7 +228,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp) out_unlock:inode_unlock (d_inode (dir));if (status ==0 ) { -if (nn->in_grace) +if (test_bit (NFSD_NET_IN_GRACE , &nn->flags))__nfsd4_create_reclaim_record_grace (clp, dname, nn);vfs_fsync (nn->rec_file,0 ); }else {
@@ -388,7 +388,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)nfs4_reset_creds (original_cred);if (status ==0 ) {vfs_fsync (nn->rec_file,0 ); -if (nn->in_grace) +if (test_bit (NFSD_NET_IN_GRACE , &nn->flags))__nfsd4_remove_reclaim_record_grace (dname,HEXDIR_LEN , nn); }
@@ -446,7 +446,7 @@ nfsd4_recdir_purge_old(struct nfsd_net *nn) {int status; - nn->in_grace = false; +clear_bit (NFSD_NET_IN_GRACE , &nn->flags);if (!nn->rec_file)return ; status =mnt_want_write_file (nn->rec_file);
@@ -528,7 +528,7 @@ nfsd4_init_recdir(struct net *net)nfs4_reset_creds (original_cred);if (!status) - nn->in_grace = true; +set_bit (NFSD_NET_IN_GRACE , &nn->flags);return status; }
@@ -1476,7 +1476,7 @@ nfs4_cld_state_init(struct net *net)for (i =0 ; i <CLIENT_HASH_SIZE ; i++)INIT_LIST_HEAD (&nn->reclaim_str_hashtbl[i]); nn->reclaim_str_hashtbl_size =0 ; - nn->track_reclaim_completes = true; +set_bit (NFSD_NET_TRACK_RECLAIM_COMPLETES , &nn->flags);atomic_set (&nn->nr_reclaim_complete,0 );return 0 ;
@@ -1487,7 +1487,7 @@ nfs4_cld_state_shutdown(struct net *net) {struct nfsd_net *nn =net_generic (net, nfsd_net_id); - nn->track_reclaim_completes = false; +clear_bit (NFSD_NET_TRACK_RECLAIM_COMPLETES , &nn->flags);kfree (nn->reclaim_str_hashtbl); }
fs/nfsd/nfs4state.c +25 -16
100 lines not on this page · raw message
fs/nfsd/nfsctl.c +1 -1
@@ -1124,7 +1124,7 @@ static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size) }return scnprintf (buf,SIMPLE_TRANSACTION_LIMIT ,"%c\n" , - nn->grace_ended ?'Y' :'N' ); +test_bit (NFSD_NET_GRACE_ENDED , &nn->flags) ?'Y' :'N' ); }#endif
fs/nfsd/nfssvc.c +10 -10
@@ -402,7 +402,7 @@ static int nfsd_startup_net(struct net *net, const struct cred *cred)struct nfsd_net *nn =net_generic (net, nfsd_net_id);int ret; -if (nn->nfsd_net_up) +if (test_bit (NFSD_NET_UP , &nn->flags))return 0 ; ret =nfsd_startup_generic ();
@@ -412,11 +412,11 @@ static int nfsd_startup_net(struct net *net, const struct cred *cred)if (ret) goto out_socks; -if (nfsd_needs_lockd (nn) && !nn->lockd_up) { +if (nfsd_needs_lockd (nn) && !test_bit (NFSD_NET_LOCKD_UP , &nn->flags)) { ret =lockd_up (net, cred);if (ret) goto out_socks; - nn->lockd_up = true; +set_bit (NFSD_NET_LOCKD_UP , &nn->flags); } ret =nfsd_file_cache_start_net (net);
@@ -434,7 +434,7 @@ static int nfsd_startup_net(struct net *net, const struct cred *cred)if (ret) goto out_reply_cache; - nn->nfsd_net_up = true; +set_bit (NFSD_NET_UP , &nn->flags);return 0 ; out_reply_cache:
@@ -442,9 +442,9 @@ static int nfsd_startup_net(struct net *net, const struct cred *cred) out_filecache:nfsd_file_cache_shutdown_net (net); out_lockd: -if (nn->lockd_up) { +if (test_bit (NFSD_NET_LOCKD_UP , &nn->flags)) {lockd_down (net); - nn->lockd_up = false; +clear_bit (NFSD_NET_LOCKD_UP , &nn->flags); } out_socks:nfsd_shutdown_generic ();
@@ -458,11 +458,11 @@ static void nfsd_shutdown_net(struct net *net)nfs4_state_shutdown_net (net);nfsd_reply_cache_shutdown (nn);nfsd_file_cache_shutdown_net (net); -if (nn->lockd_up) { +if (test_bit (NFSD_NET_LOCKD_UP , &nn->flags)) {lockd_down (net); - nn->lockd_up = false; +clear_bit (NFSD_NET_LOCKD_UP , &nn->flags); } - nn->nfsd_net_up = false; +clear_bit (NFSD_NET_UP , &nn->flags);nfsd_shutdown_generic (); }
@@ -558,7 +558,7 @@ void nfsd_last_thread(struct net *net)* other initialization has been done except the rpcb information. */ svc_rpcb_cleanup (serv, net); -if (!nn->nfsd_net_up) +if (!test_bit (NFSD_NET_UP , &nn->flags))return ;nfsd_shutdown_net (net);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 353/2857 nfsd: dedup nfs4_client_to_reclaim inserts
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit 9b57793863f69c608691c98e57c2f9be2db9dfed ]
nfs4_client_to_reclaim() unconditionally allocates a new nfs4_client_reclaim, prepends it to reclaim_str_hashtbl[], and bumps reclaim_str_hashtbl_size with no check for an existing entry for the same client name. After a reboot with a populated recovery directory that inflates the counter by one for every client that reclaims:
boot: load_recdir()
nfs4_client_to_reclaim(name) /* entry #1, size++ */
grace: RECLAIM_COMPLETE
__nfsd4_create_reclaim_record_grace()
nfs4_client_to_reclaim(name) /* entry #2, size++ */inc_reclaim_complete() ends the grace period early only when
atomic_inc_return(&nn->nr_reclaim_complete) ==
nn->reclaim_str_hashtbl_sizeWith reclaim_str_hashtbl_size at 2N and nr_reclaim_complete capped at N, the equality never holds and the fast end-of-grace path is dead. The grace period always runs out the full 90-second laundromat timer, and the shadow entry left in the hash table carries a dangling cr_clp for any reader that walks it.
Fix nfs4_client_to_reclaim() to look the name up with nfsd4_find_reclaim_client() first and, on a hit, fold the new princhash into the existing record (if it lacks one) and return that record without allocating or touching reclaim_str_hashtbl_size. On kmemdup() failure during the fold-in, return NULL so __cld_pipe_inprogress_downcall() surfaces -EFAULT to nfsdcld, matching the miss-path contract.
Add an rw_semaphore (reclaim_str_hashtbl_lock) to struct nfsd_net that serialises all access to reclaim_str_hashtbl[] and reclaim_str_hashtbl_size. Writers (nfs4_client_to_reclaim, nfs4_remove_reclaim_record callers) hold the write side; readers (nfsd4_cld_check*, inc_reclaim_complete, clients_still_reclaiming, nfs4_has_reclaimed_state, nfsd4_check_legacy_client) hold the read side. All call sites are in sleepable context, and none is a hot path, so the rwsem cost is negligible.
--- fs/nfsd/netns.h | 6 ++++- fs/nfsd/nfs4recover.c | 39 ++++++++++++++++++++++----- fs/nfsd/nfs4state.c | 61 ++++++++++++++++++++++++++++++++++++++----- 3 files changed, 92 insertions(+), 14 deletions(-)
fs/nfsd/netns.h +5 -1
@@ -92,6 +92,7 @@ struct nfsd_net {*/ struct list_head *reclaim_str_hashtbl;int reclaim_str_hashtbl_size; +struct rw_semaphore reclaim_str_hashtbl_lock;struct list_head *conf_id_hashtbl;struct rb_root conf_name_tree;struct list_head *unconf_id_hashtbl;
@@ -104,7 +105,10 @@ struct nfsd_net {* close_lru holds (open) stateowner queue ordered by nfs4_stateowner.so_time * for last close replay. * -* All of the above fields are protected by the client_mutex. +* reclaim_str_hashtbl[], reclaim_str_hashtbl_size are protected by +* reclaim_str_hashtbl_lock. +* +* All of the remaining fields are protected by the client_lock. */ struct list_head client_lru;struct list_head close_lru;
fs/nfsd/nfs4recover.c +32 -7
@@ -354,10 +354,12 @@ __nfsd4_remove_reclaim_record_grace(const char *dname, int len,return ; } name.len = len; +down_write (&nn->reclaim_str_hashtbl_lock); crp =nfsd4_find_reclaim_client (name, nn); -kfree (name.data);if (crp)nfs4_remove_reclaim_record (crp, nn); +up_write (&nn->reclaim_str_hashtbl_lock); +kfree (name.data); } static void
@@ -558,6 +560,7 @@ nfs4_legacy_state_init(struct net *net)for (i =0 ; i <CLIENT_HASH_SIZE ; i++)INIT_LIST_HEAD (&nn->reclaim_str_hashtbl[i]); nn->reclaim_str_hashtbl_size =0 ; +init_rwsem (&nn->reclaim_str_hashtbl_lock);return 0 ; }
@@ -677,13 +680,16 @@ nfsd4_check_legacy_client(struct nfs4_client *clp) goto out_enoent; } name.len =HEXDIR_LEN ; +down_read (&nn->reclaim_str_hashtbl_lock); crp =nfsd4_find_reclaim_client (name, nn); -kfree (name.data);if (crp) {set_bit (NFSD4_CLIENT_STABLE , &clp->cl_flags); crp->cr_clp = clp; -return 0 ; } +up_read (&nn->reclaim_str_hashtbl_lock); +kfree (name.data); +if (crp) +return 0 ; out_enoent:return -ENOENT ;
@@ -1282,19 +1288,23 @@ nfsd4_cld_check(struct nfs4_client *clp)return 0 ;/* look for it in the reclaim hashtable otherwise */ +down_read (&nn->reclaim_str_hashtbl_lock); crp =nfsd4_find_reclaim_client (clp->cl_name, nn);if (crp) goto found;if (cn->cn_has_legacy) { status =nfs4_make_rec_clidname (dname, &clp->cl_name); -if (status) +if (status) { +up_read (&nn->reclaim_str_hashtbl_lock);return -ENOENT ; + } name.data =kmemdup (dname,HEXDIR_LEN ,GFP_KERNEL );if (!name.data) {dprintk ("%s: failed to allocate memory for name.data!\n" , __func__); +up_read (&nn->reclaim_str_hashtbl_lock);return -ENOENT ; } name.len =HEXDIR_LEN ;
@@ -1304,9 +1314,11 @@ nfsd4_cld_check(struct nfs4_client *clp) goto found; } +up_read (&nn->reclaim_str_hashtbl_lock);return -ENOENT ; found: crp->cr_clp = clp; +up_read (&nn->reclaim_str_hashtbl_lock);return 0 ; }
@@ -1328,19 +1340,23 @@ nfsd4_cld_check_v2(struct nfs4_client *clp)return 0 ;/* look for it in the reclaim hashtable otherwise */ +down_read (&nn->reclaim_str_hashtbl_lock); crp =nfsd4_find_reclaim_client (clp->cl_name, nn);if (crp) goto found;if (cn->cn_has_legacy) { status =nfs4_make_rec_clidname (dname, &clp->cl_name); -if (status) +if (status) { +up_read (&nn->reclaim_str_hashtbl_lock);return -ENOENT ; + } name.data =kmemdup (dname,HEXDIR_LEN ,GFP_KERNEL );if (!name.data) {dprintk ("%s: failed to allocate memory for name.data\n" , __func__); +up_read (&nn->reclaim_str_hashtbl_lock);return -ENOENT ; } name.len =HEXDIR_LEN ;
@@ -1350,6 +1366,7 @@ nfsd4_cld_check_v2(struct nfs4_client *clp) goto found; } +up_read (&nn->reclaim_str_hashtbl_lock);return -ENOENT ; found:if (crp->cr_princhash.len) {
@@ -1357,26 +1374,33 @@ nfsd4_cld_check_v2(struct nfs4_client *clp) principal = clp->cl_cred.cr_raw_principal; else if (clp->cl_cred.cr_principal) principal = clp->cl_cred.cr_principal; -if (principal ==NULL ) +if (principal ==NULL ) { +up_read (&nn->reclaim_str_hashtbl_lock);return -ENOENT ; + } cksum.len =crypto_shash_digestsize (tfm); cksum.data =kmalloc (cksum.len,GFP_KERNEL ); -if (cksum.data ==NULL ) +if (cksum.data ==NULL ) { +up_read (&nn->reclaim_str_hashtbl_lock);return -ENOENT ; + } status =crypto_shash_tfm_digest (tfm, principal,strlen (principal), cksum.data);if (status) {kfree (cksum.data); +up_read (&nn->reclaim_str_hashtbl_lock);return -ENOENT ; }if (memcmp (crp->cr_princhash.data, cksum.data, crp->cr_princhash.len)) {kfree (cksum.data); +up_read (&nn->reclaim_str_hashtbl_lock);return -ENOENT ; }kfree (cksum.data); } crp->cr_clp = clp; +up_read (&nn->reclaim_str_hashtbl_lock);return 0 ; }
@@ -1476,6 +1500,7 @@ nfs4_cld_state_init(struct net *net)for (i =0 ; i <CLIENT_HASH_SIZE ; i++)INIT_LIST_HEAD (&nn->reclaim_str_hashtbl[i]); nn->reclaim_str_hashtbl_size =0 ; +init_rwsem (&nn->reclaim_str_hashtbl_lock);set_bit (NFSD_NET_TRACK_RECLAIM_COMPLETES , &nn->flags);atomic_set (&nn->nr_reclaim_complete,0 );
fs/nfsd/nfs4state.c +55 -6
122 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 354/2857 nfsd: use test_and_clear_bit for somebody_reclaimed to prevent lost update
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit 0a5a548861ab09e79a6b3062ac17e410323af3cd ]
clients_still_reclaiming() uses separate test_bit() and clear_bit() calls on NFSD_NET_SOMEBODY_RECLAIMED. A concurrent set_bit() from the OPEN or LOCK reclaim path arriving between the test and clear is silently lost, causing the next laundromat tick to end grace prematurely.
Replace with test_and_clear_bit() to make the read-and-clear atomic.
--- fs/nfsd/nfs4state.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfsd/nfs4state.c +1 -2
@@ -6058,9 +6058,8 @@ static bool clients_still_reclaiming(struct nfsd_net *nn)if (atomic_read (&nn->nr_reclaim_complete) == size)return false; } -if (!test_bit (NFSD_NET_SOMEBODY_RECLAIMED , &nn->flags)) +if (!test_and_clear_bit (NFSD_NET_SOMEBODY_RECLAIMED , &nn->flags))return false; -clear_bit (NFSD_NET_SOMEBODY_RECLAIMED , &nn->flags);/* * If we've given them *two* lease times to reclaim, and they're * still not done, give up:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 355/2857 NFSD: Prevent client use-after-free during blocked-lock reaping
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 9026932ac8be4d0ae01db47f23619a98cc57b671 ]
A bare lock owner -- its only remaining reference a blocked lock on nn->blocked_locks_lru -- holds a raw pointer to its nfs4_client but no reference keeping the client alive. When the per-net laundromat reaps such a lock, freeing the nbl drops the owner reference held through flc_owner, and the final nfs4_put_stateowner() takes the client's cl_lock. Because the laundromat detaches the nbl first, __destroy_client() no longer finds it, so a concurrent force_expire_client() can free the client before nfs4_put_stateowner() runs, dereferencing cl_lock in freed memory.
Pin the client with cl_rpc_users before dropping nn->blocked_locks_lock, and skip clients already expiring, whose blocked locks __destroy_client() frees while holding an owner reference. Take nn->client_lock outside nn->blocked_locks_lock. Every other site holds nn->blocked_locks_lock as a leaf, acquiring no further lock, so placing nn->client_lock outside it cannot form a lock-order cycle.
--- fs/nfsd/nfs4state.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
fs/nfsd/nfs4state.c +24 -3
@@ -329,6 +329,16 @@ free_blocked_lock(struct nfsd4_blocked_lock *nbl)kref_put (&nbl->nbl_kref, free_nbl); } +/* A blocked lock's fl_owner is its nfs4_lockowner. */ +static struct nfs4_client * +nbl_client (struct nfsd4_blocked_lock *nbl) +{ +struct nfs4_lockowner *lo; + + lo = (struct nfs4_lockowner *)nbl->nbl_lock.fl_owner; +return lo->lo_owner.so_client; +} +static void remove_blocked_locks (struct nfs4_lockowner *lo) {
@@ -6382,22 +6392,33 @@ nfs4_laundromat(struct nfsd_net *nn)* indefinitely once the lock does become free. */ BUG_ON (!list_empty (&reaplist)); +spin_lock (&nn->client_lock);spin_lock (&nn->blocked_locks_lock); -while (!list_empty (&nn->blocked_locks_lru)) { - nbl =list_first_entry (&nn->blocked_locks_lru, - struct nfsd4_blocked_lock, nbl_lru); +list_for_each_safe (pos, next, &nn->blocked_locks_lru) { + nbl = list_entry(pos, struct nfsd4_blocked_lock, nbl_lru);if (!state_expired (<, nbl->nbl_time))break ; + clp =nbl_client (nbl); +if (is_client_expired (clp)) +continue ; +atomic_inc (&clp->cl_rpc_users);list_move (&nbl->nbl_lru, &reaplist);list_del_init (&nbl->nbl_list); }spin_unlock (&nn->blocked_locks_lock); +spin_unlock (&nn->client_lock);while (!list_empty (&reaplist)) { nbl =list_first_entry (&reaplist, struct nfsd4_blocked_lock, nbl_lru); + clp =nbl_client (nbl);list_del_init (&nbl->nbl_lru);free_blocked_lock (nbl); +if (atomic_dec_and_lock (&clp->cl_rpc_users, &nn->client_lock)) { +if (is_client_expired (clp)) +wake_up_all (&expiry_wq); +spin_unlock (&nn->client_lock); + } }#ifdef CONFIG_NFSD_V4_2_INTER_SSC /* service the server-to-server copy delayed unmount list */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 356/2857 ALSA: hda/realtek: Enable micmute LED on HP EliteBook 6 G1a p/n: AD3Q9ET#UUG
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Batishchev <[email protected]>
[ Upstream commit e7da28b820d12927de30abf554c727a319f80359 ]
The HP EliteBook 6 G1a (SSID 103c:8e0d) uses a Realtek ALC236 codec. Without a quirk no fixup is selected and the mic-mute LED stays off. It needs the same ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF quirk as the already-supported 14" variant (SSID 103c:8dfb), so add it.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10134,6 +10134,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x8d84 ,"HP EliteBook X G1i" ,ALC285_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8d91 ,"HP ZBook Firefly 14 G12" ,ALC285_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8d92 ,"HP ZBook Firefly 16 G12" ,ALC285_FIXUP_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8e0d ,"HP EliteBook 6 G1a 14 (AD3Q9ET#UUG)" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ),SND_PCI_QUIRK (0x103c ,0x8e18 ,"HP ZBook Firefly 14 G12A" ,ALC285_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8e19 ,"HP ZBook Firefly 14 G12A" ,ALC285_FIXUP_HP_GPIO_LED ), SND_PCI_QUIRK(0x103c, 0x8e1a, "HP ZBook Firefly 14 G12A", ALC285_FIXUP_HP_GPIO_LED),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 357/2857 ALSA: hda/ext: preserve PPLCCTL bits when clearing reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Rao <[email protected]>
[ Upstream commit 36aa66de481d29edd63cbad9b5c4dc18c340fdf6 ]
snd_hdac_ext_stream_reset() polls PPLCCTL for STRST by masking the register value with AZX_PPLCCTL_STRST:
val = readl(...) & AZX_PPLCCTL_STRST;
The same masked value is then used when clearing STRST. Since val contains no bits other than STRST, clearing STRST from it always produces zero. The subsequent writel() therefore writes zero to the entire PPLCCTL register instead of clearing only the reset bit.
PPLCCTL contains other stream control fields, including the stream tag in AZX_PPLCCTL_STRM_MASK. Those fields must not be modified as a side effect of clearing stream reset.
Use snd_hdac_updatel() to clear STRST, matching the existing set-reset path and preserving all unrelated PPLCCTL bits.
--- sound/hda/ext/hdac_ext_stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/hda/ext/hdac_ext_stream.c +2 -2
@@ -182,8 +182,8 @@ void snd_hdac_ext_link_stream_reset(struct hdac_ext_stream *hext_stream)break ;udelay (3 ); }while (--timeout); - val &= ~AZX_PPLCCTL_STRST ; -writel (val, hext_stream->pplc_addr +AZX_REG_PPLCCTL ); +snd_hdac_updatel (hext_stream->pplc_addr,AZX_REG_PPLCCTL , +AZX_PPLCCTL_STRST ,0 );udelay (3 ); timeout =50 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 358/2857 block: set QUEUE_FLAG_DYING unconditionally in blk_mark_disk_dead()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: 胡连勤 <[email protected]>
[ Upstream commit 7e9a46004b471eaf69b082c473d865316a4158e0 ]
Disks created via blk_mq_alloc_disk_for_queue() (e.g. SCSI SD disks) do not have GD_OWNS_QUEUE set. Currently __blk_mark_disk_dead() only sets QUEUE_FLAG_DYING when GD_OWNS_QUEUE is set, so for such disks blk_queue_enter() and __bio_queue_enter() cannot detect the dying state via blk_queue_dying() and remain blocked waiting for I/O that will never complete after surprise removal.
blk_mark_disk_dead() is the explicit "surprise removal" API -- the caller has already decided the disk is dead. Setting QUEUE_FLAG_DYING unconditionally here is appropriate: any in-flight I/O from other threads should get -ENODEV immediately from blk_queue_enter() regardless of GD_OWNS_QUEUE ownership.
For disks that already have GD_OWNS_QUEUE set, __blk_mark_disk_dead() will set the flag again which is harmless.
--- block/genhd.c | 1 + 1 file changed, 1 insertion(+)
block/genhd.c +1 -0
@@ -592,6 +592,7 @@ EXPORT_SYMBOL(device_add_disk);*/ void blk_mark_disk_dead (struct gendisk *disk) { +blk_queue_flag_set (QUEUE_FLAG_DYING , disk->queue);set_bit (GD_DEAD , &disk->state);blk_queue_start_drain (disk->queue); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 359/2857 platform/x86: think-lmi: Fix certificate thumbprint sysfs output
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 4f3183f5ae9b8ddfe338d79a96146a05342bbe50 ]
cert_thumbprint() already returns the accumulated output length, but certificate_thumbprint_show() adds that value to count again, making the next line use the wrong offset. Errors returned by cert_thumbprint() are also ignored and their negative values added to count.
Assign the total length to count instead and propagate errors correctly.
--- drivers/platform/x86/think-lmi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/platform/x86/think-lmi.c +16 -3
@@ -676,14 +676,27 @@ static ssize_t certificate_thumbprint_show(struct kobject *kobj, struct kobj_att char *buf) {struct tlmi_pwd_setting *setting =to_tlmi_pwd_setting (kobj); +ssize_t ret;int count =0 ;if (!tlmi_priv.certificate_support || !setting->cert_installed)return -EOPNOTSUPP ; - count +=cert_thumbprint (buf,"Md5" , count); - count +=cert_thumbprint (buf,"Sha1" , count); - count +=cert_thumbprint (buf,"Sha256" , count); + ret =cert_thumbprint (buf,"Md5" , count); +if (ret <0 ) +return ret; + count = ret; + + ret =cert_thumbprint (buf,"Sha1" , count); +if (ret <0 ) +return ret; + count = ret; + + ret =cert_thumbprint (buf,"Sha256" , count); +if (ret <0 ) +return ret; + count = ret; +return count; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 360/2857 lib/string_helpers: Add kstrdup_and_replace() helper
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 045ad46441a1cf2ff358af0126f8c57f337804fa ]
Duplicate a NULL-terminated string and replace all occurrences of the old character with a new one. In other words, provide functionality of kstrdup() + strreplace().
Stable-dep-of: 54745d563114 ("platform/x86: think-lmi: Fix current password length check")
--- include/linux/string_helpers.h | 2 ++ lib/string_helpers.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+)
include/linux/string_helpers.h +2 -0
@@ -103,6 +103,8 @@ char *kstrdup_quotable(const char *src, gfp_t gfp);char *kstrdup_quotable_cmdline (struct task_struct *task,gfp_t gfp);char *kstrdup_quotable_file (struct file *file,gfp_t gfp); +char *kstrdup_and_replace (const char *src,char old,char new,gfp_t gfp); +char **kasprintf_strarray (gfp_t gfp,const char *prefix,size_t n);void kfree_strarray (char **array,size_t n);
lib/string_helpers.c +15 -0
@@ -719,6 +719,21 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp) }EXPORT_SYMBOL_GPL (kstrdup_quotable_file); +/* +* Returns duplicate string in which the @old characters are replaced by @new. +*/ +char *kstrdup_and_replace (const char *src,char old,char new,gfp_t gfp) +{ +char *dst; + + dst =kstrdup (src, gfp); +if (!dst) +return NULL ; + +return strreplace (dst, old, new); +} +EXPORT_SYMBOL_GPL (kstrdup_and_replace); +/** * kasprintf_strarray - allocate and fill array of sequential strings * @gfp: flags for the slab allocator
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 361/2857 platform/x86: think-lmi: Replace kstrdup() + strreplace() with kstrdup_and_replace()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit e621198016e99cddc097d32cd3b56b15cee27d91 ]
Replace open coded functionalify of kstrdup_and_replace() with a call.
Backport adaptation: drop the bulk-save check that is absent here, and make kstrdup_and_replace() return the duplicated string instead of the end pointer that strreplace() returns in this tree, which would yield an empty string and an invalid kfree().
Stable-dep-of: 54745d563114 ("platform/x86: think-lmi: Fix current password length check")
--- drivers/platform/x86/think-lmi.c | 43 +++++++++++--------------------- lib/string_helpers.c | 4 ++- 2 files changed, 18 insertions(+), 29 deletions(-)
drivers/platform/x86/think-lmi.c +15 -28
@@ -15,7 +15,7 @@#include <linux/errno.h> #include <linux/fs.h> #include <linux/mutex.h> -#include <linux/string.h> +#include <linux/string_helpers.h> #include <linux/types.h> #include <linux/dmi.h> #include <linux/wmi.h>
@@ -432,13 +432,11 @@ static ssize_t new_password_store(struct kobject *kobj,if (!tlmi_priv.can_set_bios_password)return -EOPNOTSUPP ; - new_pwd =kstrdup (buf,GFP_KERNEL ); +/* Strip out CR if one is present, setting password won't work if it is present */ + new_pwd =kstrdup_and_replace (buf,'\n' ,'\0' ,GFP_KERNEL );if (!new_pwd)return -ENOMEM ; -/* Strip out CR if one is present, setting password won't work if it is present */ -strip_cr (new_pwd); -/* Use lock in case multiple WMI operations needed */ mutex_lock (&tlmi_mutex);
@@ -722,13 +720,11 @@ static ssize_t cert_to_password_store(struct kobject *kobj,if (!setting->signature || !setting->signature[0 ])return -EACCES ; - passwd =kstrdup (buf,GFP_KERNEL ); +/* Strip out CR if one is present */ + passwd =kstrdup_and_replace (buf,'\n' ,'\0' ,GFP_KERNEL );if (!passwd)return -ENOMEM ; -/* Strip out CR if one is present */ -strip_cr (passwd); -/* Format: 'Password,Signature' */ auth_str =kasprintf (GFP_KERNEL ,"%s,%s" , passwd, setting->signature);if (!auth_str) {
@@ -778,11 +774,10 @@ static ssize_t certificate_store(struct kobject *kobj,return ret ?: count; } - new_cert =kstrdup (buf,GFP_KERNEL ); +/* Strip out CR if one is present */ + new_cert =kstrdup_and_replace (buf,'\n' ,'\0' ,GFP_KERNEL );if (!new_cert)return -ENOMEM ; -/* Strip out CR if one is present */ -strip_cr (new_cert);if (setting->cert_installed) {/* Certificate is installed so this is an update */
@@ -830,13 +825,11 @@ static ssize_t signature_store(struct kobject *kobj,if (!tlmi_priv.certificate_support)return -EOPNOTSUPP ; - new_signature =kstrdup (buf,GFP_KERNEL ); +/* Strip out CR if one is present */ + new_signature =kstrdup_and_replace (buf,'\n' ,'\0' ,GFP_KERNEL );if (!new_signature)return -ENOMEM ; -/* Strip out CR if one is present */ -strip_cr (new_signature); -/* Free any previous signature */ kfree (setting->signature); setting->signature = new_signature;
@@ -859,13 +852,11 @@ static ssize_t save_signature_store(struct kobject *kobj,if (!tlmi_priv.certificate_support)return -EOPNOTSUPP ; - new_signature =kstrdup (buf,GFP_KERNEL ); +/* Strip out CR if one is present */ + new_signature =kstrdup_and_replace (buf,'\n' ,'\0' ,GFP_KERNEL );if (!new_signature)return -ENOMEM ; -/* Strip out CR if one is present */ -strip_cr (new_signature); -/* Free any previous signature */ kfree (setting->save_signature); setting->save_signature = new_signature;
@@ -994,13 +985,11 @@ static ssize_t current_value_store(struct kobject *kobj,if (!tlmi_priv.can_set_bios_settings)return -EOPNOTSUPP ; - new_setting =kstrdup (buf,GFP_KERNEL ); +/* Strip out CR if one is present */ + new_setting =kstrdup_and_replace (buf,'\n' ,'\0' ,GFP_KERNEL );if (!new_setting)return -ENOMEM ; -/* Strip out CR if one is present */ -strip_cr (new_setting); -/* Use lock in case multiple WMI operations needed */ mutex_lock (&tlmi_mutex);
@@ -1173,13 +1162,11 @@ static ssize_t debug_cmd_store(struct kobject *kobj, struct kobj_attribute *attrif (!tlmi_priv.can_debug_cmd)return -EOPNOTSUPP ; - new_setting =kstrdup (buf,GFP_KERNEL ); +/* Strip out CR if one is present */ + new_setting =kstrdup_and_replace (buf,'\n' ,'\0' ,GFP_KERNEL );if (!new_setting)return -ENOMEM ; -/* Strip out CR if one is present */ -strip_cr (new_setting); -if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0 ]) { auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;", tlmi_priv.pwd_admin->password,
lib/string_helpers.c +3 -1
@@ -730,7 +730,9 @@ char *kstrdup_and_replace(const char *src, char old, char new, gfp_t gfp)if (!dst)return NULL ; -return strreplace (dst, old, new); +strreplace (dst, old, new); + +return dst; }EXPORT_SYMBOL_GPL (kstrdup_and_replace);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 362/2857 platform/x86: think-lmi: Use strreplace() to replace a character by nul
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 6cb9c8637c672584d4915559001020237840acba ]
We can replace
p = strchrnul(str, '$OLD'); *p = '\0'; with strreplace(str, '$OLD', '\0');
that does the compatible modification without a need of the temporary variable.
Stable-dep-of: 54745d563114 ("platform/x86: think-lmi: Fix current password length check")
--- drivers/platform/x86/think-lmi.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/platform/x86/think-lmi.c +4 -15
@@ -198,14 +198,6 @@ static struct think_lmi tlmi_priv;static struct class *fw_attr_class;static DEFINE_MUTEX (tlmi_mutex); -/* ------ Utility functions ------------*/ -/* Strip out CR if one is present */ -static void strip_cr (char *str) -{ -char *p =strchrnul (str,'\n' ); - *p ='\0' ; -} -/* Convert BIOS WMI error string to suitable error code */ static int tlmi_errstr_to_err (const char *errstr) {
@@ -411,7 +403,7 @@ static ssize_t current_password_store(struct kobject *kobj,strscpy (setting->password, buf, setting->maxlen);/* Strip out CR if one is present, setting password won't work if it is present */ -strip_cr (setting->password); +strreplace (setting->password,'\n' ,'\0' );return count; }
@@ -930,7 +922,7 @@ static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *atstatic ssize_t current_value_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf) {struct tlmi_attr_setting *setting =to_tlmi_attr_setting (kobj); -char *item, *value, *p; +char *item, *value;int ret; ret =tlmi_setting (setting->index, &item,LENOVO_BIOS_SETTING_GUID );
@@ -943,8 +935,7 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a ret = -EINVAL ; else {/* On Workstations remove the Options part after the value */ - p =strchrnul (value,';' ); - *p ='\0' ; +strreplace (value,';' ,'\0' ); ret =sysfs_emit (buf,"%s\n" , value +1 ); }kfree (item);
@@ -1451,7 +1442,6 @@ static int tlmi_analyze(void)for (i =0 ; i <TLMI_SETTINGS_COUNT ; ++i) {struct tlmi_attr_setting *setting;char *item =NULL ; -char *p; tlmi_priv.setting[i] =NULL ; status =tlmi_setting (i, &item,LENOVO_BIOS_SETTING_GUID );
@@ -1468,8 +1458,7 @@ static int tlmi_analyze(void)strreplace (item,'/' ,'\\' );/* Remove the value part */ - p =strchrnul (item,',' ); - *p ='\0' ; +strreplace (item,',' ,'\0' );/* Create a setting entry */ setting =kzalloc (sizeof (*setting),GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 363/2857 platform/x86: think-lmi: Fix current password length check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 54745d563114b74f6fecebce68cd020d06c1772b ]
current_password_store() checks the password length before removing the trailing newline, which can reject valid passwords that are exactly ->maxlen bytes long.
It also passes ->maxlen to strscpy(), which truncates passwords without a newline.
Use strchrnul() to measure the password length up to the newline, then copy that many bytes and add a trailing NUL terminator using strscpy().
--- drivers/platform/x86/think-lmi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/platform/x86/think-lmi.c +3 -4
@@ -396,14 +396,13 @@ static ssize_t current_password_store(struct kobject *kobj,struct tlmi_pwd_setting *setting =to_tlmi_pwd_setting (kobj);size_t pwdlen; - pwdlen =strlen (buf); +/* Strip newline; setting password won't work if one is present. */ + pwdlen =strchrnul (buf,'\n' ) - buf;/* pwdlen == 0 is allowed to clear the password */ if (pwdlen && ((pwdlen < setting->minlen) || (pwdlen > setting->maxlen)))return -EINVAL ; -strscpy (setting->password, buf, setting->maxlen); -/* Strip out CR if one is present, setting password won't work if it is present */ -strreplace (setting->password,'\n' ,'\0' ); +strscpy (setting->password, buf, pwdlen +1 );return count; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 364/2857 drm/amdgpu: Disable runtime PM for externally attached dGPUs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Wang <[email protected]>
[ Upstream commit c52feb4365396b6a881b5e8a95540517ffabb3b7 ]
pci_is_thunderbolt_attached() requires an upstream PCI bridge with is_thunderbolt set from an Intel Thunderbolt VSEC. This does not cover the affected ASM4242 USB4 PCI hierarchy:
00:02.2
\- 0f:00.0 [1b21:2421]
+- 10:01.0 [1b21:2423] -> 45:00.0 -> 46:00.0
| -> 47:00.0 -> 48:00.0 -> 49:00.0 [1002:7590]
\- 10:03.0 -> 76:00.0 [1b21:2425] USB4 Host RouterThe host router is outside the GPU upstream bridge chain, leaving no ancestor with is_thunderbolt set. PCI core propagates DEVICE_REMOVABLE below the external-facing PCIe tunnel. Disable Runtime PM when either pci_is_thunderbolt_attached() or dev_is_removable() is true.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5 -1
@@ -148,7 +148,11 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) } adev->pm.rpm_mode =AMDGPU_RUNPM_NONE ; -if (amdgpu_device_supports_px (dev) && +if (pci_is_thunderbolt_attached (adev->pdev) || +dev_is_removable (&adev->pdev->dev)) { +dev_info (adev->dev, +"Runtime PM disabled for externally attached device\n" ); + }else if (amdgpu_device_supports_px (dev) && (amdgpu_runtime_pm !=0 )) {/* enable PX as runtime mode */ adev->pm.rpm_mode =AMDGPU_RUNPM_PX ;dev_info (adev->dev,"Using ATPX for runtime pm\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 365/2857 drm/amdgpu: force complete the MES ring fences on reset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jesse Zhang <[email protected]>
[ Upstream commit 48dc279c3010ac8f91b1845b2abb3a1e9943a0f5 ]
The MES scheduler ring has no drm scheduler (no_scheduler = true), so it is skipped by the force-completion loop in amdgpu_device_pre_asic_reset(). It uses a polling fence whose hw value lives in wb (GTT) memory and survives a MODE1 reset, while fence_drv.sync_seq keeps advancing for every packet.
When the reset is triggered because MES itself stopped responding, the timed-out packets advance sync_seq past the last hw fence value MES wrote. After resume the first MES submission polls forever on a seq that is never written back, failing the resume and wedging the box on a second reset:
amdgpu: MES ring buffer is full.
amdgpu: *ERROR* ring gfx_0.0.0 test failed (-110)
amdgpu: resume of IP block <gfx_v11_0> failed -110
amdgpu: GPU reset end with ret = -110
Force complete the MES scheduler ring fences together with the scheduler rings so their hw fence is realigned to sync_seq.
v2: cover all XCCs (one scheduler ring each), not just mes.ring[0].
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 -0
@@ -4979,6 +4979,15 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,if (adev->gfx.kiq.ring.fence_drv.initialized && adev->gfx.kiq.ring.sched.ready)amdgpu_fence_driver_force_completion (&adev->gfx.kiq.ring); +/* +* MES scheduler rings have no drm scheduler, so they are missed by the +* loop above. Realign their polling fence too (one per XCC), otherwise the +* first post-reset submission polls forever on a stale seq. sched.ready is +* only set while the driver owns the ring. +*/ +if (adev->mes.ring.fence_drv.initialized && adev->mes.ring.sched.ready) +amdgpu_fence_driver_force_completion (&adev->mes.ring); +amdgpu_fence_driver_isr_toggle (adev, false);if (job && job->vm)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 366/2857 ALSA: hda/realtek: Add quirk for TongFang X6xx45xU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eckhart Mohr <[email protected]>
[ Upstream commit d595255241e5fec0c94adeebf2565524398e37c5 ]
Fix microphone detection on built in headphone jack for some devices.
Stable-dep-of: e72d5659a260 ("ALSA: hda/realtek: Add quirk for TongFang XxAF5xxx")
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10495,6 +10495,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1d05 ,0x300f ,"TongFang X6AR5xxY" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1d05 ,0x3019 ,"TongFang X6FR5xxY" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1d05 ,0x3031 ,"TongFang X6AR55xU" ,ALC2XX_FIXUP_HEADSET_MIC ), +SND_PCI_QUIRK (0x1d05 ,0x3034 ,"TongFang X6xx45xU" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1d17 ,0x3288 ,"Haier Boyue G42" ,ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS ),SND_PCI_QUIRK (0x1d72 ,0x1602 ,"RedmiBook" ,ALC255_FIXUP_XIAOMI_HEADSET_MIC ), SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 367/2857 ALSA: hda/realtek: Add quirk for TongFang X6SP45xU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eckhart Mohr <[email protected]>
[ Upstream commit 26a94400ffa4fcbeff32e23abebb83a1a20eb401 ]
TongFang X6KK45xU and X6SP45xU have actually different PCI IDs. This patch Adds the missing PCI ID to fix headphone detection and clarifies the naming.
Stable-dep-of: e72d5659a260 ("ALSA: hda/realtek: Add quirk for TongFang XxAF5xxx")
--- sound/pci/hda/patch_realtek.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/pci/hda/patch_realtek.c +2 -1
@@ -10495,7 +10495,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1d05 ,0x300f ,"TongFang X6AR5xxY" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1d05 ,0x3019 ,"TongFang X6FR5xxY" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1d05 ,0x3031 ,"TongFang X6AR55xU" ,ALC2XX_FIXUP_HEADSET_MIC ), -SND_PCI_QUIRK (0x1d05 ,0x3034 ,"TongFang X6xx45xU" ,ALC2XX_FIXUP_HEADSET_MIC ), +SND_PCI_QUIRK (0x1d05 ,0x3033 ,"TongFang X6SP45xU" ,ALC2XX_FIXUP_HEADSET_MIC ), +SND_PCI_QUIRK (0x1d05 ,0x3034 ,"TongFang X6KK45xU" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1d17 ,0x3288 ,"Haier Boyue G42" ,ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS ),SND_PCI_QUIRK (0x1d72 ,0x1602 ,"RedmiBook" ,ALC255_FIXUP_XIAOMI_HEADSET_MIC ), SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 368/2857 ALSA: hda/realtek: Add quirk for TongFang XxAF5xxx
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eckhart Mohr <[email protected]>
[ Upstream commit e72d5659a2606056a0c34af212b46a3275a55bbf ]
Fix microphone detection on built in headphone jack for some devices
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10497,6 +10497,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1d05 ,0x3031 ,"TongFang X6AR55xU" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1d05 ,0x3033 ,"TongFang X6SP45xU" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1d05 ,0x3034 ,"TongFang X6KK45xU" ,ALC2XX_FIXUP_HEADSET_MIC ), +SND_PCI_QUIRK (0x1d05 ,0x30ba ,"TongFang XxAF5xxx" ,ALC2XX_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1d17 ,0x3288 ,"Haier Boyue G42" ,ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS ),SND_PCI_QUIRK (0x1d72 ,0x1602 ,"RedmiBook" ,ALC255_FIXUP_XIAOMI_HEADSET_MIC ), SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 369/2857 mm: mempolicy: fix automatic numa balancing for shmem
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
[ Upstream commit d230991493b521eeff39f32434fddcbcdb109eb0 ]
Neha reports that mapped shmem aren't considered for NUMA balancing, noting convergence problems and bandwidth bottlenecking for cachelib based workloads on tiered memory systems.
Looking at the code and going through the git history, this doesn't actually seem intentional:
Commit fc3147245d19 ("mm: numa: Limit NUMA scanning to migrate-on-fault VMAs") added a vma_policy_mof() gate to task_numa_work() so VMAs whose policy lacks MPOL_F_MOF are skipped from NUMA balancing scans. The motivation was a real usecase: Oracle was pinning shared segments with mbind(MPOL_BIND) so trapping faults was both expensive and pointless.
The handling of NULL from vm_ops->get_policy, however, treated "user explicitly opted out" the same as "user never specified anything." For VMAs whose shared policy is absent - the common case for shmem - the scan was disabled too.
This issue is old. It probably hurts less in conventional NUMA. But it's very noticeable on tiered systems, where entire tmpfs workingsets can get stuck on lower-bandwidth memory.
Fix this by having vma_policy_mof() use __get_vma_policy() directly, and thereby handle the fallback to task policy (-> preferred_node_policy() has MPOL_F_MOF per default). Every other consumer of vm_ops->get_policy already handles it this way, the scan-eligibility check was the outlier.
This preserves Mel's intended fix: don't scan stuff the user explicitly pinned. But allow default policy vmas to participate in balancing.
--- mm/mempolicy.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
mm/mempolicy.c +5 -14
@@ -1798,23 +1798,14 @@ static struct mempolicy *get_vma_policy(struct vm_area_struct *vma,bool vma_policy_mof (struct vm_area_struct *vma) {struct mempolicy *pol; +bool mof; -if (vma->vm_ops && vma->vm_ops->get_policy) { -bool ret = false; - - pol = vma->vm_ops->get_policy (vma, vma->vm_start); -if (pol && (pol->flags &MPOL_F_MOF )) - ret = true; -mpol_cond_put (pol); - -return ret; - } - - pol = vma->vm_policy; + pol =__get_vma_policy (vma, vma->vm_start);if (!pol) pol =get_task_policy (current); - -return pol->flags &MPOL_F_MOF ; + mof = pol->flags &MPOL_F_MOF ; +mpol_cond_put (pol); +return mof; }bool apply_policy_zone (struct mempolicy *policy,enum zone_type zone)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 370/2857 mm/kmemleak: report RCU-tasks quiescent states during the scan
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 3541a2b06ecd78ba333188df04368dcf97273d6a ]
kmemleak_scan() can run for ages on large debug kernels. It was causing some soft-lockups which I got fixed with commit 3175fcfec8b16baeb ("mm/kmemleak: avoid soft lockup when scanning task stacks") with our beloved cond_resched().
I've got the fix above deployed in the Meta fleet, and now I am seeing:
INFO: rcu_tasks detected stalls on tasks:
task:kmemleak state:R ... nvcsw: 274/274 holdout: 1 idle_cpu: -1/3
scan_block
scan_gray_list
kmemleak_scanand, worse, blocks the callers waiting on that grace period. Here a BPF struct_ops map free, which waits via synchronize_rcu_mult(call_rcu, call_rcu_tasks), is stuck long enough to also trip the hung task check:
INFO: task kworker/...:bpf_map_free_deferred blocked for 122 seconds
__wait_rcu_gp
bpf_struct_ops_map_freeThen I've learned that cond_resched() is not an RCU-tasks quiescent state, so, we need to use stronger primitives.
Use cond_resched_tasks_rcu_qs() at the scan reschedule points so the scan reports an RCU-tasks quiescent state as it proceeds.
Inspired by commit b96285e10aad ("tracing: Have osnoise_main() add a quiescent state for task rcu").
--- mm/kmemleak.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
mm/kmemleak.c +6 -6
@@ -1395,7 +1395,7 @@ static void scan_large_block(void *start, void *end) next =min (start +MAX_SCAN_SIZE , end);scan_block (start, next,NULL ); start = next; - cond_resched(); + cond_resched_tasks_rcu_qs(); } }#endif
@@ -1440,7 +1440,7 @@ static void scan_object(struct kmemleak_object *object)break ;raw_spin_unlock_irqrestore (&object->lock, flags); -cond_resched (); +cond_resched_tasks_rcu_qs ();raw_spin_lock_irqsave (&object->lock, flags); }while (object->flags &OBJECT_ALLOCATED ); }else
@@ -1467,7 +1467,7 @@ static void scan_gray_list(void)*/ object =list_entry (gray_list.next,typeof (*object), gray_list);while (&object->gray_list != &gray_list) { -cond_resched (); +cond_resched_tasks_rcu_qs ();/* may add new objects to the list */ if (!scan_should_stop ())
@@ -1502,7 +1502,7 @@ static void kmemleak_cond_resched(struct kmemleak_object *object)raw_spin_unlock_irq (&kmemleak_lock);rcu_read_unlock (); -cond_resched (); +cond_resched_tasks_rcu_qs ();rcu_read_lock ();raw_spin_lock_irq (&kmemleak_lock);
@@ -1546,7 +1546,7 @@ static void kmemleak_scan_task_stacks(void) }put_task_struct (p); } -cond_resched (); +cond_resched_tasks_rcu_qs (); }while (pid && !scan_should_stop ()); }
@@ -1632,7 +1632,7 @@ static void kmemleak_scan(void)continue ;scan_block (page, page +1 ,NULL );if (!(pfn &63 )) -cond_resched (); +cond_resched_tasks_rcu_qs (); } }put_online_mems ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 371/2857 memcg: bypass the reclaim and oom killer for dying tasks once oom_reaper is done
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
[ Upstream commit 6b0d1083364fc8e7cc2f7d1f93ee3ee78f4d52f7 ]
At Meta, we are seeing instances where an OOM killed job is stuck in the exit path for several hours. In one particular case, the job was stuck for more than 8 hours and I had to manually remove the memory.max limits to allow the process to exit.
The job was a single process job and had ~55 GiB memory.max and zswap enabled. It had almost 0 anon in memory and ~111 GiB in zswap compressed to ~51 GiB zswap pool (i.e. almost all of memory.current was zswap). Nothing was left on the LRUs to reclaim.
On further inspection, I observed ~20k threads of that process stuck with the following stack:
[<0>] mem_cgroup_out_of_memory+0x4e/0xa0 [<0>] charge_memcg+0x8bf/0x990 [<0>] mem_cgroup_swapin_charge_folio+0x4e/0x80 [<0>] __read_swap_cache_async+0x10c/0x260 [<0>] swapin_readahead+0x116/0x3f0 [<0>] do_swap_page+0x13c/0x1ce0 [<0>] handle_mm_fault+0x61d/0x11f0 [<0>] do_user_addr_fault+0x3e7/0x6d0 [<0>] exc_page_fault+0x8f/0x110 [<0>] asm_exc_page_fault+0x22/0x30 [<0>] __get_user_8+0x14/0x20 [<0>] futex_cleanup+0x27/0x1c0 [<0>] futex_exit_release+0x47/0x60 [<0>] do_exit+0x107/0x940 [<0>] do_group_exit+0x81/0xa0 [<0>] get_signal+0x2b1/0x6e0 [<0>] arch_do_signal_or_restart+0x1a/0x1c0 [<0>] exit_to_user_mode_loop+0xa8/0x1c0 [<0>] do_syscall_64+0x152/0x250 [<0>] entry_SYSCALL_64_after_hwframe+0x4b/0x53
In addition the dmesg was filled with "Out of memory and no killable processes..." messages.
I have no idea why oom reaper was not able to reap/unmap the process. My guess is that since oom reaper tries to acquire mmap_lock in read mode limited number of times and then gives up, there might be a thread of that process which had mmap_lock in write mode at that time.
My initial suspicion was the futex_cleanup and kernel page fault causing infinite fault and charge retries but that was put to rest in previous discussions happened on similar problem [1].
My current theory is that it is just a simple slow serialization behind the oom_lock. Unlike page allocator, memcg charge code takes the oom_lock without the "try". Though memcg oom code uses mutex_lock_killable(), note that in the call stack get_signal() consumes SIGKILL (or sigdelset(SIGKILL)) before calling do_group_exit(). So this mutex_lock_killable() is just a mutex_lock() here. Therefore 10s of thousands of threads are waiting on oom_lock and one by one they get -EFAULT from get_user() in the futex cleanup code and bails out.
Discussion from [1] led to commit a75ffa26122b ("memcg, oom: do not bypass oom killer for dying tasks") which routes dying tasks into the OOM path precisely so the oom_reaper can reap their mm and free the memory asynchronously. But the reaper is best-effort and one-shot: if it cannot take mmap_lock for read (e.g. a sibling thread holds it for write) it sets MMF_OOM_SKIP and never retries, leaving only the glacial oom_lock-serialized synchronous drain.
Once MMF_OOM_SKIP is set there is no more asynchronous reclaim coming for the mm, so a dying task charging against it has nothing left to wait for:
it frees its memory only once it finishes exiting. Running reclaim and the (no-victim) OOM killer for it is then pointless, and doing it for 10s of thousands of exiting threads is what serializes them behind oom_lock. So before reclaim, if current is an OOM victim whose reaper is done, fail the charge.
Reproduced with 20k threads, each parking a robust futex head on its own zswapped page, OOM-group-killed while a sibling holds mmap_lock for write so the reaper gives up and sets MMF_OOM_SKIP. Tested on next-20260728 and baseline show ~90 seconds exit time while with the patch the exit time reduced to ~3 seconds.
to ~51 GiB zswap pool (i.e. almost all of memory.current was zswap). Nothing was left on the LRUs to reclaim.
On further inspection, I observed ~20k threads of that process stuck with the following stack:
[<0>] mem_cgroup_out_of_memory+0x4e/0xa0 [<0>] charge_memcg+0x8bf/0x990 [<0>] mem_cgroup_swapin_charge_folio+0x4e/0x80 [<0>] __read_swap_cache_async+0x10c/0x260 [<0>] swapin_readahead+0x116/0x3f0 [<0>] do_swap_page+0x13c/0x1ce0 [<0>] handle_mm_fault+0x61d/0x11f0 [<0>] do_user_addr_fault+0x3e7/0x6d0 [<0>] exc_page_fault+0x8f/0x110 [<0>] asm_exc_page_fault+0x22/0x30 [<0>] __get_user_8+0x14/0x20 [<0>] futex_cleanup+0x27/0x1c0 [<0>] futex_exit_release+0x47/0x60 [<0>] do_exit+0x107/0x940 [<0>] do_group_exit+0x81/0xa0 [<0>] get_signal+0x2b1/0x6e0 [<0>] arch_do_signal_or_restart+0x1a/0x1c0 [<0>] exit_to_user_mode_loop+0xa8/0x1c0 [<0>] do_syscall_64+0x152/0x250 [<0>] entry_SYSCALL_64_after_hwframe+0x4b/0x53
In addition the dmesg was filled with "Out of memory and no killable processes..." messages.
I have no idea why oom reaper was not able to reap/unmap the process. My guess is that since oom reaper tries to acquire mmap_lock in read mode limited number of times and then gives up, there might be a thread of that process which had mmap_lock in write mode at that time.
My initial suspicion was the futex_cleanup and kernel page fault causing infinite fault and charge retries but that was put to rest in previous discussions happened on similar problem [1].
My current theory is that it is just a simple slow serialization behind the oom_lock. Unlike page allocator, memcg charge code takes the oom_lock without the "try". Though memcg oom code uses mutex_lock_killable(), note that in the call stack get_signal() consumes SIGKILL (or sigdelset(SIGKILL)) before calling do_group_exit(). So this mutex_lock_killable() is just a mutex_lock() here. Therefore 10s of thousands of threads are waiting on oom_lock and one by one they get -EFAULT from get_user() in the futex cleanup code and bails out.
Discussion from [1] led to commit a75ffa26122b ("memcg, oom: do not bypass oom killer for dying tasks") which routes dying tasks into the OOM path precisely so the oom_reaper can reap their mm and free the memory asynchronously. But the reaper is best-effort and one-shot: if it cannot take mmap_lock for read (e.g. a sibling thread holds it for write) it sets MMF_OOM_SKIP and never retries, leaving only the glacial oom_lock-serialized synchronous drain.
Once MMF_OOM_SKIP is set there is no more asynchronous reclaim coming for the mm, so a dying task charging against it has nothing left to wait for:
it frees its memory only once it finishes exiting. Running reclaim and the (no-victim) OOM killer for it is then pointless, and doing it for 10s of thousands of exiting threads is what serializes them behind oom_lock.
--- mm/memcontrol.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
mm/memcontrol.c +13 -0
@@ -2677,6 +2677,19 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,if (!gfpflags_allow_blocking (gfp_mask)) goto nomem; +/* +* OOM victim still needs to charge memory to exit. OOM reaper should +* help but it might fail on mmap_lock contention. If the victim is a +* large thread group then all exiting threads might compete on oom_lock +* just to learn that there is nothing really killable anymore. Bail +* out early and fail the charge to expedite their exit. They are +* considered fully reclaimed by the oom reaper and they shouldn't +* contribute further charges. +*/ +if (tsk_is_oom_victim (current) && +test_bit (MMF_OOM_SKIP , ¤t->signal->oom_mm->flags)) + goto nomem; +memcg_memory_event (mem_over_limit,MEMCG_MAX ); raised_max_event = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 372/2857 mm/gup: fix always draining LRU caches in collect_longterm_unpinnable_folios()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 078e1a0fc41a42baaf113383b52dab8874c0b967 ]
folio_may_be_lru_cached() is currently only true for small folios, and for small folios FOLL_PIN adds GUP_PIN_COUNTING_BIAS references instead of 1 in try_grab_folio()/try_grab_folio_fast().
Consequently, our
folio_ref_count(folio) != folio_expected_ref_count(folio) + 1
check in collect_longterm_unpinnable_folios() will currently always identify "reference mismatch" and first drain the local LRU cache to then drain the LRU cache on all CPUs, as collect_longterm_unpinnable_folios() is really called after pinning the folios with FOLL_PIN.
Add a comment because the current code is not quite intuitive: we used to drain only to make sure the folio_isolate_lru() would succeed. But then we also started draining to make later migration more reliable.
We'll refactor that code soon a bit, to also make it usable in other context where we really want to remove any references from LRU caches.
Let's add CC stable, because having an easy way for excessive LRU cache draining on all CPUs does not sound right. In common scenarios we don't expect to ever have to drain.
--- mm/gup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
mm/gup.c +8 -2
@@ -1972,6 +1972,7 @@ static unsigned long collect_longterm_unpinnable_pages(for (i =0 ; i < nr_pages; i++) {struct folio *folio =page_folio (pages[i]); +const int pin_refs =folio_test_large (folio) ?1 :GUP_PIN_COUNTING_BIAS ;if (folio == prev_folio)continue ;
@@ -1990,15 +1991,20 @@ static unsigned long collect_longterm_unpinnable_pages(continue ; } +/* +* We drain not only to make the folio_isolate_lru() succeed, +* but also to remove any other folio references from LRU +* caches. +*/ if (drained ==0 &&folio_may_be_lru_cached (folio) &&folio_ref_count (folio) != -folio_expected_ref_count (folio) +1 ) { +folio_expected_ref_count (folio) + pin_refs) {lru_add_drain (); drained =1 ; }if (drained ==1 &&folio_may_be_lru_cached (folio) &&folio_ref_count (folio) != -folio_expected_ref_count (folio) +1 ) { +folio_expected_ref_count (folio) + pin_refs) {lru_add_drain_all (); drained =2 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 373/2857 mm, swap: ratelimit bad swap entry reports
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit f9dc428249ed962a70acf301f01eae8578449161 ]
A corrupt page table hands the same bogus entry to get_swap_device() on every access to the mapping, and every rejection is logged. One machine logged 6185620 copies of the same line in a few hours.
swap_dup_entry_direct() prints the same message from the fork path, once per call: the WARN_ON_ONCE() guarding it warns once, the pr_err() inside does not.
Rate limit all three prints.
--- mm/swapfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/swapfile.c +2 -2
@@ -1287,11 +1287,11 @@ struct swap_info_struct *get_swap_device(swp_entry_t entry)return si; bad_nofile: -pr_err ("%s: %s%08lx\n" , __func__, Bad_file, entry.val); +pr_err_ratelimited ("%s: %s%08lx\n" , __func__, Bad_file, entry.val); out:return NULL ; put_out: -pr_err ("%s: %s%08lx\n" , __func__, Bad_offset, entry.val); +pr_err_ratelimited ("%s: %s%08lx\n" , __func__, Bad_offset, entry.val);percpu_ref_put (&si->users);return NULL ; }
Signature · 1 line
2.53.0