* [PATCH 7.3 001/742] sched/fair: Use guard in sched_group_set_idle()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 002/742] sched/fair: Make cfs_rq::idle the sum of ancestor tg::idle Greg Kroah-Hartman
` (725 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Peter Zijlstra (Intel),
Kayra Cizmeci, Vincent Guittot, Josh Don, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <peterz@infradead.org>
[ Upstream commit 9a92f776dfa6a88fc16fe0512c725734190bf9d0 ]
Cleanup the code by using guards; prepares for further changes in this function.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kayra Cizmeci <kayracizmeci@gmail.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Josh Don <joshdon@google.com>
Link: https://patch.msgid.link/20261105170157.453569788@infradead.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/sched/fair.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d1ea0e53f1657..bb32341728d0f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -15819,12 +15819,9 @@ int sched_group_set_idle(struct task_group *tg, long idle)
if (idle < 0 || idle > 1)
return -EINVAL;
- mutex_lock(&shares_mutex);
-
- if (tg->idle == idle) {
- mutex_unlock(&shares_mutex);
+ guard(mutex)(&shares_mutex);
+ if (tg->idle == idle)
return 0;
- }
tg->idle = idle;
@@ -15834,13 +15831,12 @@ int sched_group_set_idle(struct task_group *tg, long idle)
struct cfs_rq *grp_cfs_rq = tg_cfs_rq(tg, i);
bool was_idle = cfs_rq_is_idle(grp_cfs_rq);
long idle_task_delta;
- struct rq_flags rf;
- rq_lock_irqsave(rq, &rf);
+ guard(rq_lock_irqsave)(rq);
grp_cfs_rq->idle = idle;
if (WARN_ON_ONCE(was_idle == cfs_rq_is_idle(grp_cfs_rq)))
- goto next_cpu;
+ continue;
idle_task_delta = grp_cfs_rq->h_nr_queued -
grp_cfs_rq->h_nr_idle;
@@ -15859,9 +15855,6 @@ int sched_group_set_idle(struct task_group *tg, long idle)
if (cfs_rq_is_idle(cfs_rq))
break;
}
-
-next_cpu:
- rq_unlock_irqrestore(rq, &rf);
}
/* Idle groups have minimum weight. */
@@ -15870,7 +15863,6 @@ int sched_group_set_idle(struct task_group *tg, long idle)
else
__sched_group_set_shares(tg, NICE_0_LOAD);
- mutex_unlock(&shares_mutex);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 002/742] sched/fair: Make cfs_rq::idle the sum of ancestor tg::idle
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 001/742] sched/fair: Use guard in sched_group_set_idle() Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 003/742] mm/page_alloc: apply per-task GFP context in bulk allocator Greg Kroah-Hartman
` (724 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Peter Zijlstra (Intel),
Kayra Cizmeci, Vincent Guittot, Josh Don, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <peterz@infradead.org>
[ Upstream commit 75545668ae0fd80c08fe8fd0c6799b2ba9284557 ]
Rather than keeping cfs_rq::idle as a copy of tg::idle, make it the sum of
all ancestor tg::idle. This makes it trivial to tell if the current cgroup
is marked idle somewhere along its ancestral path.
This makes se_is_idle() behave differently. Notably is will now be true when
there is a idle cgroup anywhere in the ancestor path. This addresses an issue
where preemption of cgroup::idle was overlooked when flattening the runqueue.
Fixes: 85570f10a4c6 ("sched/eevdf: Move to a single runqueue")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kayra Cizmeci <kayracizmeci@gmail.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Josh Don <joshdon@google.com>
Link: https://patch.msgid.link/20261107113639.GK2668200@noisy.programming.kicks-ass.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/sched/debug.c | 1 +
kernel/sched/fair.c | 88 +++++++++++++++++++++++++++-----------------
kernel/sched/sched.h | 2 +-
3 files changed, 56 insertions(+), 35 deletions(-)
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 72236db67983b..9206e081bec2c 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -1118,6 +1118,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
atomic_long_read(&cfs_rq->tg->load_avg));
SEQ_printf(m, " .%-30s: %lu\n", "h_load",
cfs_rq->h_load);
+ SEQ_printf(m, " .%-30s: %d\n", "idle", cfs_rq->idle);
#endif /* CONFIG_FAIR_GROUP_SCHED */
#ifdef CONFIG_CFS_BANDWIDTH
SEQ_printf(m, " .%-30s: %d\n", "throttled",
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index bb32341728d0f..2c9dd314771e8 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -445,8 +445,10 @@ static int cfs_rq_is_idle(struct cfs_rq *cfs_rq)
static int se_is_idle(struct sched_entity *se)
{
- if (entity_is_task(se))
- return task_has_idle_policy(task_of(se));
+ if (entity_is_task(se)) {
+ return task_has_idle_policy(task_of(se)) ||
+ cfs_rq_is_idle(cfs_rq_of(se));
+ }
return cfs_rq_is_idle(group_cfs_rq(se));
}
@@ -15688,19 +15690,20 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
void online_fair_sched_group(struct task_group *tg)
{
- struct sched_entity *se;
- struct rq_flags rf;
- struct rq *rq;
int i;
for_each_possible_cpu(i) {
- rq = cpu_rq(i);
- se = tg_se(tg, i);
- rq_lock_irq(rq, &rf);
+ struct cfs_rq *cfs_rq = tg_cfs_rq(tg, i);
+ struct sched_entity *se = tg_se(tg, i);
+ struct rq *rq = cpu_rq(i);
+
+ guard(rq_lock_irq)(rq);
+
update_rq_clock(rq);
attach_entity_cfs_rq(se);
sync_throttle(tg, i);
- rq_unlock_irq(rq, &rf);
+
+ cfs_rq->idle = tg_cfs_rq(tg->parent, i)->idle;
}
}
@@ -15809,6 +15812,43 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
return ret;
}
+struct tg_set_idle_struct {
+ long idle;
+ int cpu;
+};
+
+static int tg_set_idle_up(struct task_group *tg, void *data)
+{
+ struct tg_set_idle_struct *tsi = data;
+ struct cfs_rq *grp_cfs_rq = tg_cfs_rq(tg, tsi->cpu);
+ struct sched_entity *se = tg_se(tg, tsi->cpu);
+ int old_idle = grp_cfs_rq->idle;
+ int task_delta;
+
+ grp_cfs_rq->idle += tsi->idle;
+
+ if (!!old_idle == !!grp_cfs_rq->idle)
+ return 0;
+
+ task_delta = grp_cfs_rq->h_nr_queued - grp_cfs_rq->h_nr_idle;
+ if (!task_delta)
+ return 0;
+
+ task_delta *= tsi->idle;
+ for_each_sched_entity(se) {
+ struct cfs_rq *cfs_rq = cfs_rq_of(se);
+
+ if (!se->on_rq)
+ break;
+
+ cfs_rq->h_nr_idle += task_delta;
+
+ if (cfs_rq_is_idle(cfs_rq))
+ break;
+ }
+ return 0;
+}
+
int sched_group_set_idle(struct task_group *tg, long idle)
{
int i;
@@ -15827,34 +15867,14 @@ int sched_group_set_idle(struct task_group *tg, long idle)
for_each_possible_cpu(i) {
struct rq *rq = cpu_rq(i);
- struct sched_entity *se = tg_se(tg, i);
- struct cfs_rq *grp_cfs_rq = tg_cfs_rq(tg, i);
- bool was_idle = cfs_rq_is_idle(grp_cfs_rq);
- long idle_task_delta;
guard(rq_lock_irqsave)(rq);
- grp_cfs_rq->idle = idle;
- if (WARN_ON_ONCE(was_idle == cfs_rq_is_idle(grp_cfs_rq)))
- continue;
-
- idle_task_delta = grp_cfs_rq->h_nr_queued -
- grp_cfs_rq->h_nr_idle;
- if (!cfs_rq_is_idle(grp_cfs_rq))
- idle_task_delta *= -1;
-
- for_each_sched_entity(se) {
- struct cfs_rq *cfs_rq = cfs_rq_of(se);
-
- if (!se->on_rq)
- break;
-
- cfs_rq->h_nr_idle += idle_task_delta;
-
- /* Already accounted at parent level and above. */
- if (cfs_rq_is_idle(cfs_rq))
- break;
- }
+ struct tg_set_idle_struct tsi = {
+ .idle = idle ? 1 : -1,
+ .cpu = i,
+ };
+ walk_tg_tree_from(tg, tg_nop, tg_set_idle_up, &tsi);
}
/* Idle groups have minimum weight. */
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index b345f62263b3e..61b913032c640 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -751,7 +751,7 @@ struct cfs_rq {
struct list_head leaf_cfs_rq_list;
struct task_group *tg; /* Group that "owns" this runqueue */
- /* Locally cached copy of our task_group's idle value */
+ /* Sum of all ancestor tg->idle. */
int idle;
# ifdef CONFIG_CFS_BANDWIDTH
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 003/742] mm/page_alloc: apply per-task GFP context in bulk allocator
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 001/742] sched/fair: Use guard in sched_group_set_idle() Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 002/742] sched/fair: Make cfs_rq::idle the sum of ancestor tg::idle Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 004/742] mm/page_alloc: retry allocations that raced with a zonelist rebuild Greg Kroah-Hartman
` (723 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qiqi Liu, Andrew Morton,
Vlastimil Babka (SUSE), Brendan Jackman, Johannes Weiner,
Michal Hocko, Suren Baghdasaryan, Zi Yan, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiqi Liu <liuqiqi@kylinos.cn>
[ Upstream commit 1372648980b8524a5747a2732e90b20d3db10c3c ]
alloc_pages_bulk_noprof() does not call current_gfp_context(), so per-task
scoped allocation constraints (PF_MEMALLOC_NOIO, PF_MEMALLOC_NOFS,
PF_MEMALLOC_PIN) are not applied on the bulk fast path.
By ignoring PF_MEMALLOC_NOIO and PF_MEMALLOC_NOFS, the allocation can
theoretically result in a deadlock.
Ignoring PF_MEMALLOC_PIN also has consequences: without clearing
__GFP_MOVABLE, prepare_alloc_pages() selects MIGRATE_MOVABLE for the PCP
list, and a task with PF_MEMALLOC_PIN set receives movable pages from the
bulk allocator. Once pinned, these pages can no longer be migrated but
remain in MOVABLE pageblocks, violating the mobility contract. This can
increase fragmentation and interfere with compaction or contiguous-memory
allocations, eventually surfacing as higher allocation latency or
allocation failures under memory pressure.
Found via review of the bulk allocation tracepoint hooks [1].
Link: https://sashiko.dev/#/patchset/20260907120949.418450-1-liuqiqi%40kylinos.cn
Link: https://lore.kernel.org/all/20260907120949.418450-1-liuqiqi@kylinos.cn/ [1]
Link: https://lore.kernel.org/20260915074928.327471-1-liuqiqi@kylinos.cn
Fixes: 387ba26fb1cb ("mm/page_alloc: add a bulk page allocator")
Signed-off-by: Qiqi Liu <liuqiqi@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Cc: Brendan Jackman <brendan.jackman@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Zi Yan <ziy@nvidia.com>
Stable-dep-of: bcfc8286f0cd ("mm/page_alloc: retry allocations that raced with a zonelist rebuild")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
mm/page_alloc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 55232081a32b2..86f4901c4c2f2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5262,6 +5262,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
/* May set ALLOC_NOFRAGMENT, fragmentation will return 1 page. */
gfp &= gfp_allowed_mask;
+ gfp = current_gfp_context(gfp);
if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &gfp, &alloc_flags))
goto out;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 004/742] mm/page_alloc: retry allocations that raced with a zonelist rebuild
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (2 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 003/742] mm/page_alloc: apply per-task GFP context in bulk allocator Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 005/742] mm/hugetlb: retry the pool walk when the zonelist is rebuilt Greg Kroah-Hartman
` (722 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Gregory Price (Meta),
Vlastimil Babka (SUSE), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price (Meta) <gourry@gourry.net>
[ Upstream commit bcfc8286f0cd5a74c827d502f9f1ad408d7eff30 ]
Onlining the first block of a zone rebuilds every zonelist in place,
shifting the slots after the new zone. The iterator approves a slot,
then the allocator loads the zone from it, so a GFP_KERNEL request can
land in ZONE_MOVABLE and a nodemask request on a node outside its mask:
CPU 0 CPU 1
prepare_alloc_pages()
first_zones_zonelist(nodemask {1})
slot 0 (NORMAL1) approved
online_pages()
build_all_zonelists()
[NORMAL1, NORMAL2, ...]
-> [MOVABLE1, NORMAL1, ...]
get_page_from_freelist()
zone = zonelist_zone(slot 0) /* MOVABLE1 */
allocates from MOVABLE1
zonelist_update_seq detects the rebuild, but only the slowpath's failure
exits check it.
Check it whenever an allocation succeeds too, and if it changed, free
the page and retry, as the memcg charge failure path does. Eligible
pages are dropped as well: zonelists only change when memory comes or
goes, and a retry is simpler than rechecking the page.
Freeing the page does not undo a block the allocation claimed. A
GFP_KERNEL request that lands in a fresh ZONE_MOVABLE converts a free
block to MIGRATE_UNMOVABLE, which stays until the zone's movable free
list runs out and a movable allocation takes it back.
The fast and bulk paths read the seqlock's raw seqcount without waiting:
an ALLOC_NOLOCK caller can be an NMI that interrupted the writer, and on
PREEMPT_RT the seqlock accessor takes the spinlock. A sample taken
mid-write costs a retry, or NULL under ALLOC_NOLOCK.
check_retry_zonelist() returns 0 when compiled out, so a backport
without the hot-add change stays harmless.
Fixes: 11cd8638c37f ("mm, page_alloc: remove stop_machine from build_all_zonelists")
Cc: stable@vger.kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Link: https://patch.msgid.link/20261101021340.2251928-9-gourry@gourry.net
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
mm/page_alloc.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 86f4901c4c2f2..bc02971867220 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4443,12 +4443,25 @@ static unsigned int zonelist_iter_begin(void)
return 0;
}
+/*
+ * Never wait for the writer, which an ALLOC_NOLOCK caller in NMI may have
+ * interrupted. Read the raw seqcount: on PREEMPT_RT the seqlock accessor takes
+ * the spinlock while a write is in progress.
+ */
+static unsigned int zonelist_iter_sample(void)
+{
+ if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
+ return raw_seqcount_begin(&zonelist_update_seq.seqcount.seqcount);
+
+ return 0;
+}
+
static unsigned int check_retry_zonelist(unsigned int seq)
{
if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
return read_seqretry(&zonelist_update_seq, seq);
- return seq;
+ return 0;
}
/* Perform direct synchronous page reclaim */
@@ -5139,6 +5152,12 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
warn_alloc(gfp_mask, ac->nodemask,
"page allocation failure: order:%u", order);
got_pg:
+ /* A rebuild during the walk may have handed out an ineligible zone. */
+ if (page && check_retry_zonelist(zonelist_iter_cookie)) {
+ __free_frozen_pages(page, order, FPI_NONE);
+ page = NULL;
+ goto restart;
+ }
return page;
}
@@ -5223,6 +5242,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
struct list_head *pcp_list;
struct alloc_context ac;
unsigned int alloc_flags = ALLOC_WMARK_LOW;
+ unsigned int zonelist_iter_cookie;
int nr_populated = 0, nr_account = 0;
/*
@@ -5263,6 +5283,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
/* May set ALLOC_NOFRAGMENT, fragmentation will return 1 page. */
gfp &= gfp_allowed_mask;
gfp = current_gfp_context(gfp);
+ zonelist_iter_cookie = zonelist_iter_sample();
if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &gfp, &alloc_flags))
goto out;
@@ -5312,6 +5333,10 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
if (unlikely(!zone))
goto failed;
+ /* The zone was chosen from a zonelist that a rebuild may have changed. */
+ if (unlikely(check_retry_zonelist(zonelist_iter_cookie)))
+ goto failed;
+
/* spin_trylock may fail due to a parallel drain or IRQ reentrancy. */
pcp = pcp_spin_trylock(zone->per_cpu_pageset);
if (!pcp)
@@ -5450,6 +5475,7 @@ struct page *__alloc_frozen_pages_noprof(gfp_t gfp, unsigned int order,
.alloc_flags = alloc_flags,
};
unsigned int fastpath_alloc_flags = alloc_flags;
+ unsigned int zonelist_iter_cookie;
/* Other flags could be supported later if needed. */
if (WARN_ON(alloc_flags & ~(ALLOC_NOLOCK | ALLOC_NO_CODETAG)))
@@ -5479,6 +5505,7 @@ struct page *__alloc_frozen_pages_noprof(gfp_t gfp, unsigned int order,
*/
gfp = current_gfp_context(gfp);
alloc_gfp = gfp;
+ zonelist_iter_cookie = zonelist_iter_sample();
if (!prepare_alloc_pages(gfp, order, preferred_nid, nodemask, &ac,
&alloc_gfp, &fastpath_alloc_flags))
return NULL;
@@ -5495,6 +5522,11 @@ struct page *__alloc_frozen_pages_noprof(gfp_t gfp, unsigned int order,
/* First allocation attempt (or, for nolock, only attempt) */
page = get_page_from_freelist(alloc_gfp, order, fastpath_alloc_flags, &ac);
+ if (likely(page) && unlikely(check_retry_zonelist(zonelist_iter_cookie))) {
+ __free_frozen_pages(page, order,
+ alloc_flags & ALLOC_NOLOCK ? FPI_NOLOCK : 0);
+ page = NULL;
+ }
if (likely(page) || (alloc_flags & ALLOC_NOLOCK))
goto out;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 005/742] mm/hugetlb: retry the pool walk when the zonelist is rebuilt
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (3 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 004/742] mm/page_alloc: retry allocations that raced with a zonelist rebuild Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 006/742] gve: Fix race between stats query and queue reconfig Greg Kroah-Hartman
` (721 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Gregory Price (Meta),
Vlastimil Babka (SUSE), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price (Meta) <gourry@gourry.net>
[ Upstream commit 9f6674f842bbceda8326cf4e494af5ad3a5a05e6 ]
Onlining the first block of a zone rebuilds every zonelist in place,
shifting the slots after the new zone. dequeue_hugetlb_folio_nodemask()
approves a slot by its node, then loads the zone from it, so a hugetlb
fault bound to one node can take a pool page from another:
CPU 0 CPU 1
dequeue_hugetlb_folio_nodemask(nodemask {2})
slot 3 (NORMAL2) approved
online_pages()
build_all_zonelists()
[.., NORMAL1, NORMAL2]
-> [.., MOVABLE1, NORMAL1, ...]
zone = zonelist_zone(slot 3) /* NORMAL1 */
dequeue_hugetlb_folio_node_exact(h, 1)
Check zonelist_update_seq before using each zone, and on the way out
with nothing found, and restart the walk if it changed. Checking before
the dequeue leaves nothing to put back. Reset the last-tried node on
restart, so it is not skipped.
With kprobes holding the walk across the online, a fault bound to node 2
took a node 1 page in 3 of 3 runs, and a node 2 page in 3 of 3 with this
change.
Fixes: 11cd8638c37f ("mm, page_alloc: remove stop_machine from build_all_zonelists")
Cc: stable@vger.kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Link: https://patch.msgid.link/20261101021340.2251928-10-gourry@gourry.net
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
mm/hugetlb.c | 13 ++++++++++---
mm/page_alloc.c | 18 +-----------------
mm/page_alloc.h | 19 +++++++++++++++++++
3 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 82963b9977b45..4d184378b89a7 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1285,11 +1285,11 @@ static struct folio *dequeue_hugetlb_folio_node_exact(struct hstate *h,
static struct folio *dequeue_hugetlb_folio_nodemask(struct hstate *h, gfp_t gfp_mask,
int nid, nodemask_t *nmask)
{
- unsigned int cpuset_mems_cookie;
+ unsigned int cpuset_mems_cookie, zonelist_cookie;
struct zonelist *zonelist;
struct zone *zone;
struct zoneref *z;
- int node = NUMA_NO_NODE;
+ int node;
/* 'nid' should not be NUMA_NO_NODE. Try to catch any misuse of it and rectifiy. */
if (nid == NUMA_NO_NODE)
@@ -1298,10 +1298,16 @@ static struct folio *dequeue_hugetlb_folio_nodemask(struct hstate *h, gfp_t gfp_
zonelist = node_zonelist(nid, gfp_mask);
retry_cpuset:
+ node = NUMA_NO_NODE;
cpuset_mems_cookie = read_mems_allowed_begin();
+ zonelist_cookie = zonelist_iter_begin();
for_each_zone_zonelist_nodemask(zone, z, zonelist, gfp_zone(gfp_mask), nmask) {
struct folio *folio;
+ /* A rebuild may have shifted a node outside @nmask into this slot. */
+ if (unlikely(check_retry_zonelist(zonelist_cookie)))
+ goto retry_cpuset;
+
if (!cpuset_zone_allowed(zone, gfp_mask))
continue;
/*
@@ -1316,7 +1322,8 @@ static struct folio *dequeue_hugetlb_folio_nodemask(struct hstate *h, gfp_t gfp_
if (folio)
return folio;
}
- if (unlikely(read_mems_allowed_retry(cpuset_mems_cookie)))
+ if (unlikely(read_mems_allowed_retry(cpuset_mems_cookie) ||
+ check_retry_zonelist(zonelist_cookie)))
goto retry_cpuset;
return NULL;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bc02971867220..b006cc8217a6a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4433,15 +4433,7 @@ EXPORT_SYMBOL_GPL(fs_reclaim_release);
* retries the allocation if zonelist changes. Writer side is protected by the
* embedded spin_lock.
*/
-static DEFINE_SEQLOCK(zonelist_update_seq);
-
-static unsigned int zonelist_iter_begin(void)
-{
- if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
- return read_seqbegin(&zonelist_update_seq);
-
- return 0;
-}
+DEFINE_SEQLOCK(zonelist_update_seq);
/*
* Never wait for the writer, which an ALLOC_NOLOCK caller in NMI may have
@@ -4456,14 +4448,6 @@ static unsigned int zonelist_iter_sample(void)
return 0;
}
-static unsigned int check_retry_zonelist(unsigned int seq)
-{
- if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
- return read_seqretry(&zonelist_update_seq, seq);
-
- return 0;
-}
-
/* Perform direct synchronous page reclaim */
static unsigned long
__perform_reclaim(gfp_t gfp_mask, unsigned int order,
diff --git a/mm/page_alloc.h b/mm/page_alloc.h
index a9b72cb9520e1..2ae37ffdb623f 100644
--- a/mm/page_alloc.h
+++ b/mm/page_alloc.h
@@ -9,6 +9,7 @@
#include <linux/mm.h>
#include <linux/mmzone.h>
#include <linux/nodemask.h>
+#include <linux/seqlock.h>
#include <linux/types.h>
#define ALLOC_DEFAULT 0
@@ -267,6 +268,24 @@ extern void zone_pcp_disable(struct zone *zone);
extern void zone_pcp_enable(struct zone *zone);
extern void zone_pcp_init(struct zone *zone);
+extern seqlock_t zonelist_update_seq;
+
+static inline unsigned int zonelist_iter_begin(void)
+{
+ if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
+ return read_seqbegin(&zonelist_update_seq);
+
+ return 0;
+}
+
+static inline unsigned int check_retry_zonelist(unsigned int seq)
+{
+ if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG))
+ return read_seqretry(&zonelist_update_seq, seq);
+
+ return 0;
+}
+
enum fallback_result {
/* Found suitable migratetype, *mt_out is valid. */
FALLBACK_FOUND,
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 006/742] gve: Fix race between stats query and queue reconfig
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (4 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 005/742] mm/hugetlb: retry the pool walk when the zonelist is rebuilt Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 007/742] gve: Block invalid ring sizes when device options are 0 Greg Kroah-Hartman
` (720 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Debarghya Kundu, Pin-yen Lin,
Harshitha Ramamurthy, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pin-yen Lin <treapking@google.com>
[ Upstream commit 7de69da15088ac2add08eb2b5f5c0a79fd461c1e ]
Fix a concurrency bug where network statistics queries race with queue
reconfiguration or interface teardown, causing a Use-After-Free (UAF) or
NULL pointer dereference.
Currently, statistics queries access priv->tx and priv->rx without
locking. When an interface is brought down or reconfigured,
gve_queues_mem_remove() frees these arrays. A concurrent stats query
can dereference freed queue structures and crash the kernel.
This issue was discovered and actually triggered by the
drivers/net/stats.py selftest. When an interface was brought down,
querying per-queue statistics via Netlink caused a kernel NULL pointer
dereference in gve_get_rx_queue_stats():
BUG: kernel NULL pointer dereference, address: 00000000000000a0
RIP: 0010:gve_get_rx_queue_stats+0x17/0x50 [gve]
Call Trace:
<TASK>
netdev_stat_queue_sum+0x11c/0x250
netdev_nl_stats_by_netdev+0x21b/0x2d0
netdev_nl_qstats_get_dumpit+0xd2/0x220
genl_dumpit+0x32/0x90
netlink_dump+0x1d2/0x450
__netlink_dump_start+0x1db/0x2a0
genl_family_rcv_msg_dumpit+0x9b/0x100
...
The per-queue stats callbacks run under the netdev instance lock, so
this NULL dereference is not a race; it happens on any query while the
interface is down.
Additionally, concurrent stats queries during queue reconfiguration can
race with gve_queues_mem_remove(), causing a Use-After-Free.
This affects gve_get_stats(), which does not hold the instance lock.
gve_handle_report_stats() also runs without it; it is stopped before
queue teardown, but can still read priv->rx[idx] while the single-queue
restart path rewrites it.
Fix this by introducing stats_lock to serialize stats queries against
queue teardown. In gve_queues_mem_remove(), queue pointers are set to
NULL under stats_lock before freeing. Stats readers acquire the lock
and verify pointers are non-NULL before reading counters.
The per-queue stats callbacks already run under the instance lock, but
take stats_lock as well for consistency.
The single-queue restart path also rewrites priv->rx[idx] in place, so
gve_rx_queue_stop() and gve_rx_queue_start() do those writes under
stats_lock as well.
This change was tested using the DQO RDA queue format.
Cc: stable@vger.kernel.org
Fixes: f5cedc84a30d ("gve: Add transmit and receive support")
Fixes: 2e5e0932dff5 ("gve: add support for basic queue stats")
Co-developed-by: Debarghya Kundu <debarghyak@google.com>
Signed-off-by: Debarghya Kundu <debarghyak@google.com>
Signed-off-by: Pin-yen Lin <treapking@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
Link: https://patch.msgid.link/20261109182036.2910559-2-hramamurthy@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ sashal: Adjusted context in gve_queues_start() and gve_queues_mem_remove() because this tree sets the header-split and packet-buffer-size fields later in gve_queues_start(), so the unlock follows rx_pages_per_qpl. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/google/gve/gve.h | 5 +++
drivers/net/ethernet/google/gve/gve_main.c | 43 ++++++++++++++++++++--
2 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h
index c280ff35ee771..59c7fb32fda76 100644
--- a/drivers/net/ethernet/google/gve/gve.h
+++ b/drivers/net/ethernet/google/gve/gve.h
@@ -883,6 +883,11 @@ struct gve_priv {
struct workqueue_struct *gve_wq;
struct work_struct service_task;
struct work_struct stats_report_task;
+ /* Protects the priv->tx/priv->rx arrays, the in-place rewrite of
+ * priv->rx[idx] and the queue counts against stats readers that do
+ * not hold the netdev instance lock.
+ */
+ spinlock_t stats_lock;
unsigned long service_task_flags;
unsigned long state_flags;
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index a6c18e2431cc7..1bcc8318c9d9d 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -114,6 +114,7 @@ static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s)
int num_tx_queues;
int ring;
+ spin_lock_bh(&priv->stats_lock);
num_tx_queues = gve_num_tx_queues(priv);
if (priv->rx) {
for (ring = 0; ring < priv->rx_cfg.num_queues; ring++) {
@@ -141,6 +142,7 @@ static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s)
s->tx_bytes += bytes;
}
}
+ spin_unlock_bh(&priv->stats_lock);
}
static int gve_alloc_flow_rule_caches(struct gve_priv *priv)
@@ -1386,9 +1388,13 @@ static void gve_queues_mem_remove(struct gve_priv *priv)
struct gve_rx_alloc_rings_cfg rx_alloc_cfg = {0};
gve_get_curr_alloc_cfgs(priv, &tx_alloc_cfg, &rx_alloc_cfg);
- gve_queues_mem_free(priv, &tx_alloc_cfg, &rx_alloc_cfg);
+
+ spin_lock_bh(&priv->stats_lock);
priv->tx = NULL;
priv->rx = NULL;
+ spin_unlock_bh(&priv->stats_lock);
+
+ gve_queues_mem_free(priv, &tx_alloc_cfg, &rx_alloc_cfg);
}
/* The passed-in queue memory is stored into priv and the queues are made live.
@@ -1402,6 +1408,7 @@ static int gve_queues_start(struct gve_priv *priv,
int err;
/* Record new resources into priv */
+ spin_lock_bh(&priv->stats_lock);
priv->tx = tx_alloc_cfg->tx;
priv->rx = rx_alloc_cfg->rx;
@@ -1413,10 +1420,11 @@ static int gve_queues_start(struct gve_priv *priv,
priv->rx_desc_cnt = rx_alloc_cfg->ring_size;
priv->tx_pages_per_qpl = tx_alloc_cfg->pages_per_qpl;
priv->rx_pages_per_qpl = rx_alloc_cfg->pages_per_qpl;
+ gve_init_sync_stats(priv);
+ spin_unlock_bh(&priv->stats_lock);
gve_tx_start_rings(priv, gve_num_tx_queues(priv));
gve_rx_start_rings(priv, rx_alloc_cfg->qcfg_rx->num_queues);
- gve_init_sync_stats(priv);
err = netif_set_real_num_tx_queues(dev, priv->tx_cfg.num_queues);
if (err)
@@ -2296,6 +2304,7 @@ void gve_handle_report_stats(struct gve_priv *priv)
if (!gve_get_report_stats(priv))
return;
+ spin_lock_bh(&priv->stats_lock);
be64_add_cpu(&priv->stats_report->written_count, 1);
/* tx stats */
if (priv->tx) {
@@ -2360,6 +2369,7 @@ void gve_handle_report_stats(struct gve_priv *priv)
};
}
}
+ spin_unlock_bh(&priv->stats_lock);
}
/* Handle NIC status register changes, reset requests and report stats */
@@ -2668,8 +2678,10 @@ static int gve_rx_queue_stop(struct net_device *dev, void *per_q_mem, int idx)
gve_turnup_and_check_status(priv);
gve_per_q_mem = (struct gve_rx_ring *)per_q_mem;
+ spin_lock_bh(&priv->stats_lock);
*gve_per_q_mem = priv->rx[idx];
memset(&priv->rx[idx], 0, sizeof(priv->rx[idx]));
+ spin_unlock_bh(&priv->stats_lock);
return 0;
}
@@ -2723,7 +2735,9 @@ static int gve_rx_queue_start(struct net_device *dev,
return -EAGAIN;
gve_per_q_mem = (struct gve_rx_ring *)per_q_mem;
+ spin_lock_bh(&priv->stats_lock);
priv->rx[idx] = *gve_per_q_mem;
+ spin_unlock_bh(&priv->stats_lock);
/* Single-queue creation requires quiescence on all queues */
gve_turndown(priv);
@@ -2759,7 +2773,9 @@ static int gve_rx_queue_start(struct net_device *dev,
* which needs the rtnl lock, will not run till this func returns and
* its caller gives up the lock.
*/
+ spin_lock_bh(&priv->stats_lock);
memset(&priv->rx[idx], 0, sizeof(priv->rx[idx]));
+ spin_unlock_bh(&priv->stats_lock);
return err;
}
@@ -2775,9 +2791,15 @@ static void gve_get_rx_queue_stats(struct net_device *dev, int idx,
struct netdev_queue_stats_rx *rx_stats)
{
struct gve_priv *priv = netdev_priv(dev);
- struct gve_rx_ring *rx = &priv->rx[idx];
+ struct gve_rx_ring *rx;
unsigned int start;
+ spin_lock_bh(&priv->stats_lock);
+ if (!priv->rx)
+ goto unlock;
+
+ rx = &priv->rx[idx];
+
do {
start = u64_stats_fetch_begin(&rx->statss);
rx_stats->packets = rx->rpackets;
@@ -2785,20 +2807,32 @@ static void gve_get_rx_queue_stats(struct net_device *dev, int idx,
rx_stats->alloc_fail = rx->rx_skb_alloc_fail +
rx->rx_buf_alloc_fail;
} while (u64_stats_fetch_retry(&rx->statss, start));
+
+unlock:
+ spin_unlock_bh(&priv->stats_lock);
}
static void gve_get_tx_queue_stats(struct net_device *dev, int idx,
struct netdev_queue_stats_tx *tx_stats)
{
struct gve_priv *priv = netdev_priv(dev);
- struct gve_tx_ring *tx = &priv->tx[idx];
+ struct gve_tx_ring *tx;
unsigned int start;
+ spin_lock_bh(&priv->stats_lock);
+ if (!priv->tx)
+ goto unlock;
+
+ tx = &priv->tx[idx];
+
do {
start = u64_stats_fetch_begin(&tx->statss);
tx_stats->packets = tx->pkt_done;
tx_stats->bytes = tx->bytes_done;
} while (u64_stats_fetch_retry(&tx->statss, start));
+
+unlock:
+ spin_unlock_bh(&priv->stats_lock);
}
static void gve_get_base_stats(struct net_device *dev,
@@ -2915,6 +2949,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
}
INIT_WORK(&priv->service_task, gve_service_task);
INIT_WORK(&priv->stats_report_task, gve_stats_report_task);
+ spin_lock_init(&priv->stats_lock);
priv->tx_cfg.max_queues = max_tx_queues;
priv->rx_cfg.max_queues = max_rx_queues;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 007/742] gve: Block invalid ring sizes when device options are 0
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (5 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 006/742] gve: Fix race between stats query and queue reconfig Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 008/742] Bluetooth: L2CAP: Only accept LE responses to outstanding requests Greg Kroah-Hartman
` (719 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Pin-yen Lin, Joshua Washington,
Jordan Rhee, Harshitha Ramamurthy, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pin-yen Lin <treapking@google.com>
[ Upstream commit edc9a730ad3c98662047a76db2d7f26ea4350b2e ]
On older device versions, minimum ring sizes in the device option are
reported as 0. The driver imports these 0 values, allowing userspace
(`ethtool -G`) to request invalidly small ring sizes.
This issue was discovered and actually triggered by the
drivers/net/ring_reconfig.py selftest (ringparam test case). Halving the
ring size down to 1 triggered a kernel NULL pointer dereference in
gve_tx_alloc_rings_dqo():
BUG: kernel NULL pointer dereference, address: 0000000000000002
RIP: 0010:gve_tx_alloc_rings_dqo+0x1c4/0x510 [gve]
Call Trace:
<TASK>
gve_queues_mem_alloc+0x29/0xa0 [gve]
gve_adjust_config+0x1b/0x140 [gve]
gve_set_ringparam+0x1f4/0x250 [gve]
ethnl_set_rings+0x260/0x440
...
Fix this by falling back to the driver's default minimum ring sizes
(GVE_DEFAULT_MIN_RX_RING_SIZE and GVE_DEFAULT_MIN_TX_RING_SIZE) whenever
the device option reports minimum ring sizes as 0.
The device reports either both minimum ring sizes or neither, so a
single fallback for both is sufficient.
This change was tested using the DQO RDA queue format.
Cc: stable@vger.kernel.org
Fixes: ed4fb326947d ("gve: add support to read ring size ranges from the device")
Signed-off-by: Pin-yen Lin <treapking@google.com>
Reviewed-by: Joshua Washington <joshwash@google.com>
Reviewed-by: Jordan Rhee <jordanrhee@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
Link: https://patch.msgid.link/20261109182036.2910559-4-hramamurthy@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/google/gve/gve_adminq.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c
index f05f4895f4c74..5e2f91b633350 100644
--- a/drivers/net/ethernet/google/gve/gve_adminq.c
+++ b/drivers/net/ethernet/google/gve/gve_adminq.c
@@ -189,7 +189,9 @@ void gve_parse_device_option(struct gve_priv *priv,
*dev_op_modify_ring = (void *)(option + 1);
/* device has not provided min ring size */
- if (option_length == GVE_DEVICE_OPTION_NO_MIN_RING_SIZE)
+ if (option_length == GVE_DEVICE_OPTION_NO_MIN_RING_SIZE ||
+ be16_to_cpu((*dev_op_modify_ring)->min_rx_ring_size) == 0 ||
+ be16_to_cpu((*dev_op_modify_ring)->min_tx_ring_size) == 0)
priv->default_min_ring_size = true;
break;
case GVE_DEV_OPT_ID_FLOW_STEERING:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 008/742] Bluetooth: L2CAP: Only accept LE responses to outstanding requests
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (6 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 007/742] gve: Block invalid ring sizes when device options are 0 Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 009/742] ksmbd: pin parent dentries in SMB2 CREATE ACL path Greg Kroah-Hartman
` (718 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zhao Li, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <enderaoelyther@gmail.com>
[ Upstream commit f50b32aa233d4687af2d241ddcb572da969e8989 ]
The LE and ECRED response handlers match channels by identifier without
checking whether they sent the request. An incoming channel stores the
identifier chosen by the peer, so an unsolicited response can bypass
deferred setup, delete an established channel, or leave an unaccepted
socket and channel allocated after l2cap_chan_del().
Extend the BR/EDR lookup from commit a518b9a9ef6e ("Bluetooth: L2CAP:
Only accept connection responses to outstanding requests") to LE.
Require the matching connect-request flag and add a reconfigure-request
flag. Check reconfigure identifiers under the channel lock, since
BT_RCVMTU can replace a request without the connection lock. Match all
members of a rejected ECRED request, which share one identifier.
A reconfigure request can outlive close(). Complete it even in
BT_DISCONN, and call the close callback after deletion to release an
orphaned socket. Otherwise deletion cancels the timer and removes the
channel before the disconnect response or the channel timeout can close
it.
AI assistance was used.
Fixes: f1496dee9cbd ("Bluetooth: Add initial code for LE L2CAP Connect Request")
Fixes: 71fb419724fa ("Bluetooth: Fix handling of L2CAP Command Reject over LE")
Fixes: 15f02b910562 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode")
Cc: <stable@vger.kernel.org> # 5.7.x: a518b9a9ef6e: Bluetooth: L2CAP: Only accept connection responses to outstanding requests
Cc: <stable@vger.kernel.org> # 5.7.x
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ sashal: Dropped the lockdep_assert_held() and __must_hold() annotations, since this tree lacks them; the l2cap_le_command_rej() and l2cap_ecred_reconf_rsp() logic is otherwise unchanged. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/net/bluetooth/l2cap.h | 1 +
net/bluetooth/l2cap_core.c | 78 +++++++++++++++++------------------
2 files changed, 40 insertions(+), 39 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 84f557d354cae..b864d50bb5e59 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -749,6 +749,7 @@ enum {
FLAG_DEFER_SETUP,
FLAG_LE_CONN_REQ_SENT,
FLAG_ECRED_CONN_REQ_SENT,
+ FLAG_ECRED_RECONF_REQ_SENT,
FLAG_PENDING_SECURITY,
FLAG_HOLD_HCI_CONN,
FLAG_DEL,
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index fdf92a3d57455..7ac5dd0fb6fe4 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -139,23 +139,12 @@ static struct l2cap_chan *l2cap_get_chan_by_dcid(struct l2cap_conn *conn,
return c;
}
-static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn,
- u8 ident)
-{
- struct l2cap_chan *c;
-
- list_for_each_entry(c, &conn->chan_l, list) {
- if (c->ident == ident)
- return c;
- }
- return NULL;
-}
-
/* Our connection request has been sent and is still outstanding */
static bool l2cap_chan_connect_pending(struct l2cap_chan *chan)
{
return chan->state == BT_CONNECT &&
- test_bit(CONF_CONNECT_PEND, &chan->conf_state);
+ (test_bit(CONF_CONNECT_PEND, &chan->conf_state) ||
+ test_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags));
}
/* Other channels may hold the same ident for a response they still have
@@ -167,7 +156,7 @@ static struct l2cap_chan *__l2cap_get_connect_chan_by_ident(struct l2cap_conn *c
struct l2cap_chan *c;
list_for_each_entry(c, &conn->chan_l, list) {
- if (c->ident == ident && l2cap_chan_connect_pending(c))
+ if (l2cap_chan_connect_pending(c) && c->ident == ident)
return c;
}
return NULL;
@@ -4964,7 +4953,7 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn,
BT_DBG("dcid 0x%4.4x mtu %u mps %u credits %u result 0x%2.2x",
dcid, mtu, mps, credits, result);
- chan = __l2cap_get_chan_by_ident(conn, cmd->ident);
+ chan = __l2cap_get_connect_chan_by_ident(conn, cmd->ident);
if (!chan)
return -EBADSLT;
@@ -5501,9 +5490,10 @@ static inline int l2cap_ecred_conn_rsp(struct l2cap_conn *conn,
struct l2cap_chan *orig;
u16 dcid;
- if (chan->ident != cmd->ident ||
+ if (chan->state != BT_CONNECT ||
chan->mode != L2CAP_MODE_EXT_FLOWCTL ||
- chan->state == BT_CONNECTED)
+ !test_bit(FLAG_ECRED_CONN_REQ_SENT, &chan->flags) ||
+ chan->ident != cmd->ident)
continue;
l2cap_chan_hold(chan);
@@ -5718,23 +5708,24 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,
BT_DBG("result 0x%4.4x", result);
- if (!result) {
- list_for_each_entry(chan, &conn->chan_l, list) {
- if (chan->ident == cmd->ident)
- chan->ident = 0;
- }
- return 0;
- }
-
list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) {
- if (chan->ident != cmd->ident)
+ /* Reconfiguration updates ident with only chan->lock held. */
+ if (data_race(READ_ONCE(chan->ident)) != cmd->ident)
continue;
if (!l2cap_chan_hold_unless_zero(chan))
continue;
l2cap_chan_lock(chan);
- l2cap_chan_del(chan, ECONNRESET);
+ if (chan->ident == cmd->ident &&
+ test_and_clear_bit(FLAG_ECRED_RECONF_REQ_SENT, &chan->flags)) {
+ if (result) {
+ l2cap_chan_del(chan, ECONNRESET);
+ chan->ops->close(chan);
+ } else {
+ chan->ident = 0;
+ }
+ }
l2cap_chan_unlock(chan);
l2cap_chan_put(chan);
@@ -5748,25 +5739,33 @@ static inline int l2cap_le_command_rej(struct l2cap_conn *conn,
u8 *data)
{
struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data;
- struct l2cap_chan *chan;
+ struct l2cap_chan *chan, *tmp;
if (cmd_len < sizeof(*rej))
return -EPROTO;
- chan = __l2cap_get_chan_by_ident(conn, cmd->ident);
- if (!chan)
- goto done;
+ list_for_each_entry_safe(chan, tmp, &conn->chan_l, list) {
+ /* Reconfiguration updates ident with only chan->lock held. */
+ if (data_race(READ_ONCE(chan->ident)) != cmd->ident)
+ continue;
- chan = l2cap_chan_hold_unless_zero(chan);
- if (!chan)
- goto done;
+ if (!l2cap_chan_hold_unless_zero(chan))
+ continue;
- l2cap_chan_lock(chan);
- l2cap_chan_del(chan, ECONNREFUSED);
- l2cap_chan_unlock(chan);
- l2cap_chan_put(chan);
+ l2cap_chan_lock(chan);
+ if (chan->ident == cmd->ident &&
+ ((chan->state == BT_CONNECT &&
+ (test_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags) ||
+ test_bit(FLAG_ECRED_CONN_REQ_SENT, &chan->flags))) ||
+ test_bit(FLAG_ECRED_RECONF_REQ_SENT, &chan->flags))) {
+ l2cap_chan_del(chan, ECONNREFUSED);
+ chan->ops->close(chan);
+ }
+
+ l2cap_chan_unlock(chan);
+ l2cap_chan_put(chan);
+ }
-done:
return 0;
}
@@ -7628,6 +7627,7 @@ static void l2cap_ecred_reconfigure(struct l2cap_chan *chan)
pdu->scid[0] = cpu_to_le16(chan->scid);
chan->ident = l2cap_get_ident(conn);
+ set_bit(FLAG_ECRED_RECONF_REQ_SENT, &chan->flags);
l2cap_send_cmd(conn, chan->ident, L2CAP_ECRED_RECONF_REQ,
struct_size(pdu, scid, 1), pdu);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 009/742] ksmbd: pin parent dentries in SMB2 CREATE ACL path
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (7 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 008/742] Bluetooth: L2CAP: Only accept LE responses to outstanding requests Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 010/742] ksmbd: refuse to read a handle that is not open for reading Greg Kroah-Hartman
` (717 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, stable, Jiwoo Kim, Namjae Jeon,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiwoo Kim <arpe1618@gmail.com>
[ Upstream commit 0383a66dabd7aa06237b9b24713c03656abeffe4 ]
smb2_open() and smb_inherit_dacl() read a child's d_parent without a
dentry reference. A concurrent SMB request can move the child and
remove the parent while CREATE uses its inode for permission, status,
and ACL inheritance work. A remote SMB race with concurrent opener and
mover connections on a writable KSMBD acl_xattr share triggered an
8-byte slab-use-after-free read in get_cached_acl on tmpfs and ext4
KASAN guests. With oops=panic, it also caused an Oops and kernel panic
on an ext4 guest.
Take a parent dentry reference around each parent inode or ACL access
in these paths and release it when the operation completes. Treat a
negative parent dentry as -ENOENT for the affected operation.
On a tmpfs KASAN QEMU guest, two 3,000-round reproducer instances
completed without a KASAN report or Oops; SMB remained reachable. On
an ext4 non-KASAN QEMU guest with oops=panic, a 2,000-operation no-race
control and two 5,000-round reproducer instances completed without an
Oops or panic. An SMB health probe still succeeded.
OpenAI Codex assisted with finding the bug, generating the SMB race
reproducer, drafting this fix and changelog, and running the tests.
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@kernel.org
Signed-off-by: Jiwoo Kim <arpe1618@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
[ sashal: Dropped the kunit include and the const on idmap from the smbacl.c context lines, since this tree has neither, and kept only the fix's own changes. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/server/smb2pdu.c | 39 +++++++++++++++++++++++++++++++--------
fs/smb/server/smbacl.c | 9 ++++++++-
2 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 8f9773e0cf016..d6359702faa3e 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -4974,16 +4974,32 @@ int smb2_open(struct ksmbd_work *work)
if ((daccess & FILE_DELETE_LE) ||
(req->CreateOptions & FILE_DELETE_ON_CLOSE_LE)) {
- rc = inode_permission(idmap,
- d_inode(path.dentry->d_parent),
- MAY_EXEC | MAY_WRITE);
+ struct dentry *parent = dget_parent(path.dentry);
+ struct inode *parent_inode = d_inode(parent);
+
+ if (parent_inode)
+ rc = inode_permission(idmap, parent_inode,
+ MAY_EXEC | MAY_WRITE);
+ else
+ rc = -ENOENT;
+ dput(parent);
if (rc)
goto err_out;
}
}
}
- rc = ksmbd_query_inode_status(path.dentry->d_parent);
+ {
+ struct dentry *parent = dget_parent(path.dentry);
+
+ if (!d_inode(parent)) {
+ dput(parent);
+ rc = -ENOENT;
+ goto err_out;
+ }
+ rc = ksmbd_query_inode_status(parent);
+ dput(parent);
+ }
if (rc == KSMBD_INODE_STATUS_PENDING_DELETE) {
rc = -EBUSY;
goto err_out;
@@ -5066,10 +5082,17 @@ int smb2_open(struct ksmbd_work *work)
if (created) {
int posix_acl_rc;
struct inode *inode = d_inode(path.dentry);
-
- posix_acl_rc = ksmbd_vfs_inherit_posix_acl(idmap,
- &path,
- d_inode(path.dentry->d_parent));
+ struct inode *parent_inode;
+ struct dentry *parent;
+
+ parent = dget_parent(path.dentry);
+ parent_inode = d_inode(parent);
+ if (parent_inode)
+ posix_acl_rc = ksmbd_vfs_inherit_posix_acl(idmap, &path,
+ parent_inode);
+ else
+ posix_acl_rc = -ENOENT;
+ dput(parent);
if (posix_acl_rc)
ksmbd_debug(SMB, "inherit posix acl failed : %d\n", posix_acl_rc);
diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index c3be25f2db87b..27da571c96127 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -7,6 +7,7 @@
*/
#include <linux/fs.h>
+#include <linux/dcache.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/mnt_idmapping.h>
@@ -1200,7 +1201,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
struct smb_acl *parent_pdacl;
struct smb_ntsd *parent_pntsd = NULL;
struct smb_sid owner_sid, group_sid;
- struct dentry *parent = path->dentry->d_parent;
+ struct dentry *parent;
struct mnt_idmap *idmap = mnt_idmap(path->mnt);
int inherited_flags = 0, flags = 0, i, nt_size = 0, pdacl_size;
int rc = 0, pntsd_type, ppntsd_size, acl_len, aces_size;
@@ -1210,8 +1211,14 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
char *aces_base;
bool is_dir = S_ISDIR(d_inode(path->dentry)->i_mode);
+ parent = dget_parent(path->dentry);
+ if (!d_inode(parent)) {
+ dput(parent);
+ return -ENOENT;
+ }
ppntsd_size = ksmbd_vfs_get_sd_xattr(conn, idmap,
parent, &parent_pntsd);
+ dput(parent);
if (ppntsd_size <= 0)
return -ENOENT;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 010/742] ksmbd: refuse to read a handle that is not open for reading
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (8 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 009/742] ksmbd: pin parent dentries in SMB2 CREATE ACL path Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 011/742] comedi: comedi_bond: Fix leak of opened device references Greg Kroah-Hartman
` (716 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Wahid Khan, Ian Bridges, Namjae Jeon,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wahid Khan <wahidzk0091@gmail.com>
[ Upstream commit 2fd145f8865bb1a6c38a3dc68fa44290008789d8 ]
smb2_create_open_flags() picks the open mode from the read and write
bits of the desired access. FILE_EXECUTE and FILE_READ_ATTRIBUTES select
neither, so a request for FILE_WRITE_DATA | FILE_EXECUTE |
FILE_READ_ATTRIBUTES opens the file O_WRONLY.
smb2_read() accepts FILE_READ_ATTRIBUTES and ksmbd_vfs_read() accepts
FILE_EXECUTE, so a later READ on that handle passes both checks and
reaches __kernel_read() on a file that has no FMODE_READ:
WARNING: fs/read_write.c:518 at __kernel_read
__kernel_read
ksmbd_vfs_read
smb2_read
handle_ksmbd_work
Any client that can open a file with write access on a share, including
a guest session, can trigger it; with panic_on_warn it takes the machine
down.
Return STATUS_ACCESS_DENIED when the file is not readable.
Fixes: f44158485826 ("cifsd: add file operations")
Cc: stable@vger.kernel.org
Signed-off-by: Wahid Khan <wahidzk0091@gmail.com>
Reviewed-by: Ian Bridges <icb@fastmail.org>
Tested-by: Ian Bridges <icb@fastmail.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
[ sashal: adjusted context: the new FMODE_READ check is inserted before this tree's if (!work->tcon->posix_extensions) { line instead of upstream's if (!fp->is_posix_ctxt) {. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/server/vfs.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index f88daeb5ef873..d9b8714f01beb 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -366,6 +366,10 @@ int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,
if (ksmbd_stream_fd(fp))
return ksmbd_vfs_stream_read(fp, rbuf, pos, count);
+ /* The access granted on open can include FILE_EXECUTE for a write-only file */
+ if (!(filp->f_mode & FMODE_READ))
+ return -EACCES;
+
if (!work->tcon->posix_extensions) {
int ret;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 011/742] comedi: comedi_bond: Fix leak of opened device references
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (9 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 010/742] ksmbd: refuse to read a handle that is not open for reading Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 012/742] rust_binder: push BR_TRANSACTION_COMPLETE before BR_FAILED_REPLY Greg Kroah-Hartman
` (715 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, stable, Wentao Liang, Ian Abbott,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Abbott <abbotti@mev.co.uk>
commit fa0858523f07f8dd71d89b221f4422c3b8096d90 upstream.
bonding_attach() calls do_dev_config() to open other comedi devices
specified by the user and tries to make use of them as part of the
'bonding' device. If it successfully opens the other device but cannot
use it (either because it does not any subdevices of a type the
'bonding' device can use, or because of some error that occurs while
dealing with its subdevices) then it is left in the open state and the
fact that it is open does not get recorded by the 'bonding' device, so
the reference to the opened device gets lost. Fix it by closing the
opened device if it could not be bound to the 'bonding' device.
To match previous behavior, if the opened device is unsuitable then
ignore it (after closing it). The opened devices recorded by the
'bonding' device will eventually get closed by bonding_detach() even if
bonding_attach() returns an error.
Fixes: 3cf840f65ad5 ("Staging: comedi: add comedi_bond driver")
Cc: stable <stable@kernel.org>
Reported-by: Wentao Liang <vulab@iscas.ac.cn>
Link: https://lore.kernel.org/lkml/20261103063301.1025860-1-vulab@iscas.ac.cn
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Link: https://patch.msgid.link/20261103173610.89687-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit fa0858523f07f8dd71d89b221f4422c3b8096d90)
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/comedi/drivers/comedi_bond.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/comedi/drivers/comedi_bond.c b/drivers/comedi/drivers/comedi_bond.c
index 8e10ecab4f0dc..aeb34eaa6a0e7 100644
--- a/drivers/comedi/drivers/comedi_bond.c
+++ b/drivers/comedi/drivers/comedi_bond.c
@@ -182,7 +182,9 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
char file[sizeof("/dev/comediXXXXXX")];
int minor = it->options[i];
struct comedi_device *d;
- int sdev = -1, nchans;
+ int sdev = -1;
+ int nchans;
+ int nope = 1;
struct bonded_device *bdev;
struct bonded_device **devs;
@@ -221,11 +223,14 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
dev_err(dev->class_dev,
"comedi_get_n_channels() returned %d on minor %u subdev %d!\n",
nchans, minor, sdev);
- return -EINVAL;
+ nope = -EINVAL;
+ break;
}
bdev = kmalloc_obj(*bdev);
- if (!bdev)
- return -ENOMEM;
+ if (!bdev) {
+ nope = -ENOMEM;
+ break;
+ }
bdev->dev = d;
bdev->minor = minor;
@@ -246,10 +251,12 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
dev_err(dev->class_dev,
"Could not allocate memory. Out of memory?\n");
kfree(bdev);
- return -ENOMEM;
+ nope = -ENOMEM;
+ break;
}
devpriv->devs = devs;
devpriv->devs[devpriv->ndevs++] = bdev;
+ nope = 0; /* keeps the device open */
{
/* Append dev:subdev to devpriv->name */
char buf[20];
@@ -260,6 +267,13 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it)
sizeof(devpriv->name));
}
}
+
+ if (nope) {
+ /* Opened device cannot be used, so close it. */
+ comedi_close_from(d, dev->minor);
+ if (nope < 0)
+ return nope;
+ }
}
if (!devpriv->nchans) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 012/742] rust_binder: push BR_TRANSACTION_COMPLETE before BR_FAILED_REPLY
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (10 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 011/742] comedi: comedi_bond: Fix leak of opened device references Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 013/742] sched_ext: Reset task fields on exit of an SCX_TASK_READY task Greg Kroah-Hartman
` (714 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alice Ryhl, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Ryhl <aliceryhl@google.com>
commit ff9de8571f05e8f62f9cbe29f38e0aedda9389cf upstream.
When building a reply fails in Thread::reply_inner(), BR_FAILED_REPLY is
delivered to the caller before BR_TRANSACTION_COMPLETE is pushed to the
replying thread's work list.
In a nested transaction, the caller can wake up upon receiving
BR_FAILED_REPLY and send an outer reply to the replying thread before
BR_TRANSACTION_COMPLETE is queued. This causes the outer BR_REPLY to
arrive ahead of BR_TRANSACTION_COMPLETE, which is not legal. This leads
to userspace tripping on an assertion.
Thus, push BR_TRANSACTION_COMPLETE in Thread::reply_inner() before
delivering BR_FAILED_REPLY to the caller.
As a nice side effect, this lets us remove the now-unused
BR_TRANSACTION_COMPLETE error path in Thread::transaction().
Cc: stable@vger.kernel.org
Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Link: https://patch.msgid.link/20261028-binder-reply-fail-v1-1-8b71d4daaf1d@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[aliceryhl: resolve conflicts in Thread::transaction() and reply_inner()]
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/android/binder/error.rs | 1 -
drivers/android/binder/thread.rs | 68 +++++++++++++++-----------------
2 files changed, 32 insertions(+), 37 deletions(-)
diff --git a/drivers/android/binder/error.rs b/drivers/android/binder/error.rs
index 1296072c35d96..b9faf09566108 100644
--- a/drivers/android/binder/error.rs
+++ b/drivers/android/binder/error.rs
@@ -79,7 +79,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
BR_DEAD_REPLY => f.pad("BR_DEAD_REPLY"),
BR_FROZEN_REPLY => f.pad("BR_FROZEN_REPLY"),
BR_TRANSACTION_PENDING_FROZEN => f.pad("BR_TRANSACTION_PENDING_FROZEN"),
- BR_TRANSACTION_COMPLETE => f.pad("BR_TRANSACTION_COMPLETE"),
_ => match self.source.as_ref() {
Some(source) => source.fmt(f),
None => self.reply.fmt(f),
diff --git a/drivers/android/binder/thread.rs b/drivers/android/binder/thread.rs
index a1bef151c2c59..e1929f5739dfb 100644
--- a/drivers/android/binder/thread.rs
+++ b/drivers/android/binder/thread.rs
@@ -1309,37 +1309,36 @@ fn transaction(self: &Arc<Self>, cmd: u32, reader: &mut UserSliceReader) -> Resu
self.transaction_inner(&mut info)
};
+ // This runs when a transaction fails with an error returned to the caller.
if let Err(err) = ret {
self.push_return_work(err.reply);
- if err.reply != BR_TRANSACTION_COMPLETE {
- info.reply = err.reply;
- if let Some(source) = &err.source {
- info.errno = source.to_errno();
-
- {
- let mut inner = self.inner.lock();
- inner.extended_error =
- ExtendedError::new(info.debug_id as u32, err.reply, source.to_errno());
- }
-
- binder_debug!(
- FailedTransaction,
- "transaction {} to {}:{} failed {:?}, code {} size {}-{}",
- if info.is_reply {
- "reply"
- } else if info.is_oneway() {
- "async"
- } else {
- "call"
- },
- info.to_pid,
- info.to_tid,
- err,
- info.code,
- info.data_size,
- info.offsets_size
- );
+ info.reply = err.reply;
+ if let Some(source) = &err.source {
+ info.errno = source.to_errno();
+
+ {
+ let mut inner = self.inner.lock();
+ inner.extended_error =
+ ExtendedError::new(info.debug_id as u32, err.reply, source.to_errno());
}
+
+ binder_debug!(
+ FailedTransaction,
+ "transaction {} to {}:{} failed {:?}, code {} size {}-{}",
+ if info.is_reply {
+ "reply"
+ } else if info.is_oneway() {
+ "async"
+ } else {
+ "call"
+ },
+ info.to_pid,
+ info.to_tid,
+ err,
+ info.code,
+ info.data_size,
+ info.offsets_size
+ );
}
}
@@ -1416,7 +1415,7 @@ fn reply_inner(self: &Arc<Self>, info: &mut TransactionInfo) -> BinderResult {
info.to_pid = orig.from.process.task.pid();
// We need to complete the transaction even if we cannot complete building the reply.
- let out = (|| -> BinderResult<_> {
+ if let Err(err) = (|| -> BinderResult<_> {
let completion = DTRWrap::arc_try_new(DeliverCode::new(
BR_TRANSACTION_COMPLETE,
self.process.task.pid(),
@@ -1431,11 +1430,10 @@ fn reply_inner(self: &Arc<Self>, info: &mut TransactionInfo) -> BinderResult {
}
orig.from.deliver_reply(Ok(reply), &orig, None);
Ok(())
- })()
- .map_err(|mut err| {
+ })() {
// At this point we only return `BR_TRANSACTION_COMPLETE` to the caller, and we must let
// the sender know that the transaction has completed (with an error in this case).
-
+ self.push_return_work(BR_TRANSACTION_COMPLETE);
pr_warn!(
"{}:{} reply to {} failed: {err:?}",
info.from_pid,
@@ -1447,11 +1445,9 @@ fn reply_inner(self: &Arc<Self>, info: &mut TransactionInfo) -> BinderResult {
orig.from
.deliver_reply(Err(BR_FAILED_REPLY), &orig, Some(ee));
info.reply = BR_FAILED_REPLY;
- err.reply = BR_TRANSACTION_COMPLETE;
- err
- });
+ }
- out
+ Ok(())
}
fn oneway_transaction_inner(self: &Arc<Self>, info: &mut TransactionInfo) -> BinderResult {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 013/742] sched_ext: Reset task fields on exit of an SCX_TASK_READY task
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (11 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 012/742] rust_binder: push BR_TRANSACTION_COMPLETE before BR_FAILED_REPLY Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 014/742] sched_ext: make DSQ iterator stay drained after NULL Greg Kroah-Hartman
` (713 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Rahad Bhuiya, Tejun Heo,
Cheng-Yang Chou, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rahad Bhuiya <rahadbhuiya2021@gmail.com>
commit 564405c424f49d70b13debe7fe5b550234ad6b84 upstream.
Tasks in SCX_TASK_READY are attached to a scheduler but outside the ext
class, such as RT/DL tasks, or non-SCHED_EXT tasks under a partial switch.
The scheduler's BPF code can still update their dsq_vtime and slice (for
instance, via ops.cgroup_move() as done by scx_flatcg).
Because __scx_disable_and_exit_task() currently breaks out of the state
switch for SCX_TASK_READY without calling scx_reset_task_fields(), these
fields are not cleared when the task leaves the scheduler. If the task is
subsequently moved to another cgroup/sub-scheduler and later switches to
SCHED_NORMAL, the new scheduler's ops.enable() sees stale dsq_vtime from
the previous scheduler's clock.
Call scx_reset_task_fields() in the SCX_TASK_READY case of
__scx_disable_and_exit_task() to ensure SCX-managed fields are properly
reset when leaving the scheduler.
Fixes: 5771e79e461e ("sched_ext: Reset dsq_vtime and slice when a task leaves SCX")
Signed-off-by: Rahad Bhuiya <rahadbhuiya2021@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
[ chengyang: 7.3 lacks scx_reset_task_fields(), so factor it out of
scx_disable_task() ]
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/sched/ext/ext.c | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index cc8d09924fa13..1049a0914d600 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -4159,6 +4159,27 @@ void scx_enable_task(struct scx_sched *sch, struct task_struct *p)
scx_set_task_state(p, SCX_TASK_ENABLED);
}
+/*
+ * Reset the SCX-managed fields when @p leaves the BPF scheduler's control.
+ */
+static void scx_reset_task_fields(struct rq *rq, struct task_struct *p)
+{
+ lockdep_assert_rq_held(rq);
+
+ p->scx.dsq_vtime = 0;
+ scx_task_slice_ended(rq, p);
+ scx_set_task_slice(p, 0);
+ p->scx.reenq_cnt = 0;
+
+ /*
+ * If @p is runnable but not running, its wait started at runnable_at,
+ * which ops_dequeue() didn't reset. Leaving the scheduler ends the
+ * wait. Reset runnable_at the next time @p is enqueued on SCX, so that
+ * the watchdog doesn't count the time @p spends elsewhere.
+ */
+ p->scx.flags |= SCX_TASK_RESET_RUNNABLE_AT;
+}
+
static void scx_disable_task(struct scx_sched *sch, struct task_struct *p)
{
struct rq *rq = task_rq(p);
@@ -4172,22 +4193,8 @@ static void scx_disable_task(struct scx_sched *sch, struct task_struct *p)
SCX_CALL_OP_TASK(sch, disable, rq, p);
scx_set_task_state(p, SCX_TASK_READY);
- /*
- * Reset the SCX-managed fields when @p leaves the BPF scheduler's
- * control, after ops.disable() has observed their final values.
- */
- p->scx.dsq_vtime = 0;
- scx_task_slice_ended(rq, p);
- scx_set_task_slice(p, 0);
- p->scx.reenq_cnt = 0;
-
- /*
- * If @p is runnable but not running, its wait started at runnable_at,
- * which ops_dequeue() didn't reset. Leaving @sch ends the wait. Reset
- * runnable_at the next time @p is enqueued on SCX, so that the watchdog
- * doesn't count the time @p spends elsewhere.
- */
- p->scx.flags |= SCX_TASK_RESET_RUNNABLE_AT;
+ /* after ops.disable() has observed the final values */
+ scx_reset_task_fields(rq, p);
/*
* Verify the task is not in BPF scheduler's custody. If flag
@@ -4213,6 +4220,7 @@ void __scx_disable_and_exit_task(struct scx_sched *sch, struct task_struct *p)
args.cancelled = true;
break;
case SCX_TASK_READY:
+ scx_reset_task_fields(task_rq(p), p);
break;
case SCX_TASK_ENABLED:
scx_disable_task(sch, p);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 014/742] sched_ext: make DSQ iterator stay drained after NULL
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (12 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 013/742] sched_ext: Reset task fields on exit of an SCX_TASK_READY task Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:57 ` [PATCH 7.3 015/742] ipv6: Remove IPV6_ADDRFORM Greg Kroah-Hartman
` (712 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kang Chen, Tejun Heo,
Cheng-Yang Chou, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kang Chen <k.chen@smail.nju.edu.cn>
commit fcbff7b56a881bbe041b6c5ba12831a3c1ac1bb4 upstream.
nldsq_cursor_next_task() unlinks the iteration cursor when it reaches the
end of the DSQ. A later call sees list_empty(&cursor->node), starts
from the DSQ head again, and returns the first task of the same
iteration.
The verifier relies on the iterator contract that once next() returns
NULL it keeps returning NULL: process_iter_next_call() marks the
iterator DRAINED and treats the result of later next() calls as the
constant zero. A restarted DSQ iteration therefore hands the BPF
program a task pointer while the verifier believes R0 == 0.
Remember the drained state in the cursor flags and return NULL on every
later next() call. The cursor has spare flag bits and the BPF-visible
iterator layout is unchanged.
Fixes: 650ba21b131e ("sched_ext: Implement DSQ iterator")
Signed-off-by: Kang Chen <k.chen@smail.nju.edu.cn>
Signed-off-by: Tejun Heo <tj@kernel.org>
[ chengyang: drop __SCX_DSQ_ITER_HAS_REENQ, which 7.3 lacks ]
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/sched/ext/ext.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 1049a0914d600..6db6ca912bb37 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -492,11 +492,13 @@ enum scx_dsq_iter_flags {
/* iterate in the reverse dispatch order */
SCX_DSQ_ITER_REV = 1U << 16,
+ __SCX_DSQ_ITER_DRAINED = 1U << 28,
__SCX_DSQ_ITER_HAS_SLICE = 1U << 30,
__SCX_DSQ_ITER_HAS_VTIME = 1U << 31,
__SCX_DSQ_ITER_USER_FLAGS = SCX_DSQ_ITER_REV,
__SCX_DSQ_ITER_ALL_FLAGS = __SCX_DSQ_ITER_USER_FLAGS |
+ __SCX_DSQ_ITER_DRAINED |
__SCX_DSQ_ITER_HAS_SLICE |
__SCX_DSQ_ITER_HAS_VTIME,
};
@@ -10255,13 +10257,24 @@ __bpf_kfunc int bpf_iter_scx_dsq_new(struct bpf_iter_scx_dsq *it, u64 dsq_id,
__bpf_kfunc struct task_struct *bpf_iter_scx_dsq_next(struct bpf_iter_scx_dsq *it)
{
struct bpf_iter_scx_dsq_kern *kit = (void *)it;
+ struct task_struct *p;
- if (!kit->dsq)
+ if (!kit->dsq || (kit->cursor.flags & __SCX_DSQ_ITER_DRAINED))
return NULL;
guard(raw_spinlock_irqsave)(&kit->dsq->lock);
- return nldsq_cursor_next_task(&kit->cursor, kit->dsq);
+ p = nldsq_cursor_next_task(&kit->cursor, kit->dsq);
+ /*
+ * nldsq_cursor_next_task() unlinks the cursor and starts from the DSQ
+ * head when it is called again. The verifier relies on an iterator
+ * which returned NULL to keep returning NULL (see
+ * process_iter_next_call()), so remember the drained state.
+ */
+ if (!p)
+ kit->cursor.flags |= __SCX_DSQ_ITER_DRAINED;
+
+ return p;
}
/**
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 015/742] ipv6: Remove IPV6_ADDRFORM.
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (13 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 014/742] sched_ext: make DSQ iterator stay drained after NULL Greg Kroah-Hartman
@ 2026-12-04 9:57 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 016/742] kprobes: Switch ftrace ops when adding probe with post_handler Greg Kroah-Hartman
` (711 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:57 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Daehyeon Ko, Hyunwoo Kim,
Kuniyuki Iwashima, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <kuniyu@google.com>
[ Upstream commit 31c5ea8a3296e1486ac34bccea452bfe8c0bb1f9 ]
Recently, IPV6_ADDRFORM has received many AI-driven bug reports.
Fixing them properly would needlessly churn the fast paths in TCP
and UDP.
IPV6_ADDRFORM was initially introduced in RFC 2133 in 1997,
but only two years later, it was removed from RFC 2553 in 1999.
In 2026, modern applications natively support dual-stack sockets;
notably, systemd's socket activation does not use IPV6_ADDRFORM.
Also, getsockopt(IPV6_ADDRFORM) can be replaced with SO_DOMAIN.
Let's remove IPV6_ADDRFORM.
Later, we can remove sk->sk_prot_creator and revert commit
c26c192c3d48 ("udp: properly deal with xfrm encap and ADDRFORM").
Reported-by: Daehyeon Ko <4ncienth@gmail.com>
Closes: https://lore.kernel.org/netdev/20260902010408.1057857-1-4ncienth@gmail.com/
Reported-by: Hyunwoo Kim <imv4bel@gmail.com>
Closes: https://lore.kernel.org/netdev/20260824033331.1084971-1-imv4bel@gmail.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260904033543.2635540-3-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/net.h | 2 +-
net/core/sock.c | 4 +-
net/ipv4/af_inet.c | 3 --
net/ipv6/af_inet6.c | 4 --
net/ipv6/ipv6_sockglue.c | 87 ----------------------------------------
5 files changed, 2 insertions(+), 98 deletions(-)
diff --git a/include/linux/net.h b/include/linux/net.h
index 3d82966e2243b..470100ae71077 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -166,7 +166,7 @@ struct socket {
struct file *file;
struct sock *sk;
- const struct proto_ops *ops; /* Might change with IPV6_ADDRFORM or MPTCP. */
+ const struct proto_ops *ops; /* Might change with MPTCP. */
struct socket_wq wq;
};
diff --git a/net/core/sock.c b/net/core/sock.c
index f93ae40ef6bd7..43d2b4545db6e 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -772,7 +772,7 @@ bool sk_mc_loop(const struct sock *sk)
sk = sk_const_to_full_sk(sk);
if (!sk)
return true;
- /* IPV6_ADDRFORM can change sk->sk_family under us. */
+
switch (READ_ONCE(sk->sk_family)) {
case AF_INET:
return inet_test_bit(MC_LOOP, sk);
@@ -4023,7 +4023,6 @@ int sock_common_getsockopt(struct socket *sock, int level, int optname,
{
struct sock *sk = sock->sk;
- /* IPV6_ADDRFORM can change sk->sk_prot under us. */
return READ_ONCE(sk->sk_prot)->getsockopt(sk, level, optname, optval, optlen);
}
EXPORT_SYMBOL(sock_common_getsockopt);
@@ -4045,7 +4044,6 @@ int sock_common_setsockopt(struct socket *sock, int level, int optname,
{
struct sock *sk = sock->sk;
- /* IPV6_ADDRFORM can change sk->sk_prot under us. */
return READ_ONCE(sk->sk_prot)->setsockopt(sk, level, optname, optval, optlen);
}
EXPORT_SYMBOL(sock_common_setsockopt);
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index bc3bbb2366d81..09bf6e8aa058c 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -582,7 +582,6 @@ int inet_dgram_connect(struct socket *sock, struct sockaddr_unsized *uaddr,
if (addr_len < sizeof(uaddr->sa_family))
return -EINVAL;
- /* IPV6_ADDRFORM can change sk->sk_prot under us. */
prot = READ_ONCE(sk->sk_prot);
if (uaddr->sa_family == AF_UNSPEC)
@@ -791,7 +790,6 @@ int inet_accept(struct socket *sock, struct socket *newsock,
{
struct sock *sk1 = sock->sk, *sk2;
- /* IPV6_ADDRFORM can change sk->sk_prot under us. */
arg->err = -EINVAL;
sk2 = READ_ONCE(sk1->sk_prot)->accept(sk1, arg);
if (!sk2)
@@ -877,7 +875,6 @@ void inet_splice_eof(struct socket *sock)
if (unlikely(inet_send_prepare(sk)))
return;
- /* IPV6_ADDRFORM can change sk->sk_prot under us. */
prot = READ_ONCE(sk->sk_prot);
if (prot->splice_eof)
prot->splice_eof(sock);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 282912a119999..f0efdc13baf4e 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -429,7 +429,6 @@ int inet6_bind_sk(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len)
const struct proto *prot;
int err = 0;
- /* IPV6_ADDRFORM can change sk->sk_prot under us. */
prot = READ_ONCE(sk->sk_prot);
/* If the socket has its own bind function then use it. */
if (prot->bind)
@@ -567,7 +566,6 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case SIOCSIFDSTADDR:
return addrconf_set_dstaddr(net, argp);
default:
- /* IPV6_ADDRFORM can change sk->sk_prot under us. */
prot = READ_ONCE(sk->sk_prot);
if (!prot->ioctl)
return -ENOIOCTLCMD;
@@ -636,7 +634,6 @@ int inet6_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
if (unlikely(inet_send_prepare(sk)))
return -EAGAIN;
- /* IPV6_ADDRFORM can change sk->sk_prot under us. */
prot = READ_ONCE(sk->sk_prot);
return INDIRECT_CALL_2(prot->sendmsg, tcp_sendmsg, udpv6_sendmsg,
sk, msg, size);
@@ -651,7 +648,6 @@ int inet6_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
if (likely(!(flags & MSG_ERRQUEUE)))
sock_rps_record_flow(sk);
- /* IPV6_ADDRFORM can change sk->sk_prot under us. */
prot = READ_ONCE(sk->sk_prot);
return INDIRECT_CALL_2(prot->recvmsg, tcp_recvmsg, udpv6_recvmsg,
sk, msg, size, flags);
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index b4c977434c2e0..1f68fb64a43ef 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -547,86 +547,7 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
sockopt_lock_sock(sk);
- /* Another thread has converted the socket into IPv4 with
- * IPV6_ADDRFORM concurrently.
- */
- if (unlikely(sk->sk_family != AF_INET6))
- goto unlock;
-
switch (optname) {
-
- case IPV6_ADDRFORM:
- if (optlen < sizeof(int))
- goto e_inval;
- if (val == PF_INET) {
- if (sk->sk_type == SOCK_RAW)
- break;
-
- if (sk->sk_protocol == IPPROTO_UDP) {
- if (udp_sk(sk)->pending == AF_INET6) {
- retv = -EBUSY;
- break;
- }
- } else if (sk->sk_protocol == IPPROTO_TCP) {
- if (sk->sk_prot != &tcpv6_prot) {
- retv = -EBUSY;
- break;
- }
- } else {
- break;
- }
-
- if (sk->sk_state != TCP_ESTABLISHED) {
- retv = -ENOTCONN;
- break;
- }
-
- if (ipv6_only_sock(sk) ||
- !ipv6_addr_v4mapped(&sk->sk_v6_daddr)) {
- retv = -EADDRNOTAVAIL;
- break;
- }
-
- __ipv6_sock_mc_close(sk);
- __ipv6_sock_ac_close(sk);
-
- if (sk->sk_protocol == IPPROTO_TCP) {
- struct inet_connection_sock *icsk = inet_csk(sk);
-
- sock_prot_inuse_add(net, sk->sk_prot, -1);
- sock_prot_inuse_add(net, &tcp_prot, 1);
-
- /* Paired with READ_ONCE(sk->sk_prot) in inet6_stream_ops */
- WRITE_ONCE(sk->sk_prot, &tcp_prot);
- /* Paired with READ_ONCE() in tcp_(get|set)sockopt() */
- WRITE_ONCE(icsk->icsk_af_ops, &ipv4_specific);
- WRITE_ONCE(sk->sk_socket->ops, &inet_stream_ops);
- WRITE_ONCE(sk->sk_family, PF_INET);
- tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
- } else {
- sock_prot_inuse_add(net, sk->sk_prot, -1);
- sock_prot_inuse_add(net, &udp_prot, 1);
-
- /* Paired with READ_ONCE(sk->sk_prot) in inet6_dgram_ops */
- WRITE_ONCE(sk->sk_prot, &udp_prot);
- WRITE_ONCE(sk->sk_socket->ops, &inet_dgram_ops);
- WRITE_ONCE(sk->sk_family, PF_INET);
- }
-
- /* Disable all options not to allocate memory anymore,
- * but there is still a race. See the lockless path
- * in udpv6_sendmsg() and ipv6_local_rxpmtu().
- */
- np->rxopt.all = 0;
-
- inet6_cleanup_sock(sk);
-
- module_put(THIS_MODULE);
- retv = 0;
- break;
- }
- goto e_inval;
-
case IPV6_V6ONLY:
if (optlen < sizeof(int) ||
inet_sk(sk)->inet_num)
@@ -1088,14 +1009,6 @@ int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
if (copy_from_sockptr(&len, optlen, sizeof(int)))
return -EFAULT;
switch (optname) {
- case IPV6_ADDRFORM:
- if (sk->sk_protocol != IPPROTO_UDP &&
- sk->sk_protocol != IPPROTO_TCP)
- return -ENOPROTOOPT;
- if (sk->sk_state != TCP_ESTABLISHED)
- return -ENOTCONN;
- val = sk->sk_family;
- break;
case MCAST_MSFILTER:
if (in_compat_syscall())
return compat_ipv6_get_msfilter(sk, optval, optlen, len);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 016/742] kprobes: Switch ftrace ops when adding probe with post_handler
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (14 preceding siblings ...)
2026-12-04 9:57 ` [PATCH 7.3 015/742] ipv6: Remove IPV6_ADDRFORM Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 017/742] gve: Fix backward stats when interface goes down or configuration is adjusted Greg Kroah-Hartman
` (710 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
[ Upstream commit f60f98881b54b0cf36b61f41c91fbd93b76a2d9c ]
When an ftrace-based kprobe is registered without a post_handler, it is
armed using kprobe_ftrace_ops. If a second probe with a post_handler is
subsequently registered at the same address, register_aggr_kprobe() sets
ap->post_handler to aggr_post_handler, but leaves the probe armed using
kprobe_ftrace_ops.
When the probe is later disarmed or disabled, disarm_kprobe_ftrace()
checks whether p->post_handler is non-NULL and attempts to disarm from
kprobe_ipmodify_ops. This fails with -ENOENT, decrements
kprobe_ipmodify_enabled below zero, leaves the probe armed on
kprobe_ftrace_ops, and aborts unregistration, leading to a use-after-free
if the probe module is unloaded.
Switch the armed probe from kprobe_ftrace_ops to kprobe_ipmodify_ops in
register_aggr_kprobe() outside of text_mutex and cpus_read_lock to avoid
lockdep and deadlock issues when modifying ftrace code. Defer adding the
new probe onto ap->list until the ftrace ops switch completes so that the
new probe's handlers are not published prematurely while ap is still on
kprobe_ftrace_ops, and mark ap disabled if rollback re-arming fails.
Also restore ftrace ops registration and counter if ftrace_set_filter_ip()
fails in __disarm_kprobe_ftrace().
Link: https://lore.kernel.org/all/179440641120.328088.15542754095040659094.stgit@devnote2/
Fixes: 5dd7caf0bdc5 ("kprobes: Skip clearing aggrprobe's post_handler in kprobe-on-ftrace case")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/kprobes.c | 55 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 45 insertions(+), 10 deletions(-)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 2461116015805..0fd0d40a71ee2 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1200,9 +1200,14 @@ static int __disarm_kprobe_ftrace(struct kprobe *p, struct ftrace_ops *ops,
(*cnt)--;
ret = ftrace_set_filter_ip(ops, (unsigned long)p->addr, 1, 0);
- WARN_ONCE(ret < 0, "Failed to disarm kprobe-ftrace at %pS (error %d)\n",
- p->addr, ret);
- return ret;
+ if (WARN_ONCE(ret < 0, "Failed to disarm kprobe-ftrace at %pS (error %d)\n",
+ p->addr, ret)) {
+ if (*cnt == 0)
+ register_ftrace_function(ops);
+ (*cnt)++;
+ return ret;
+ }
+ return 0;
}
static int disarm_kprobe_ftrace(struct kprobe *p)
@@ -1331,16 +1336,12 @@ void kprobe_busy_end(void)
}
/* Add the new probe to 'ap->list'. */
-static int add_new_kprobe(struct kprobe *ap, struct kprobe *p)
+static void add_new_kprobe(struct kprobe *ap, struct kprobe *p)
{
if (p->post_handler)
unoptimize_kprobe(ap, true); /* Fall back to normal kprobe */
list_add_rcu(&p->list, &ap->list);
- if (p->post_handler && !ap->post_handler)
- ap->post_handler = aggr_post_handler;
-
- return 0;
}
/*
@@ -1373,6 +1374,8 @@ static int register_aggr_kprobe(struct kprobe *orig_p, struct kprobe *p)
{
int ret = 0;
struct kprobe *ap = orig_p;
+ bool reset_post_handler = false;
+ bool ftrace_switch_ops = false;
scoped_guard(cpus_read_lock) {
/* For preparing optimization, jump_label_text_reserved() is called */
@@ -1419,18 +1422,50 @@ static int register_aggr_kprobe(struct kprobe *orig_p, struct kprobe *p)
| KPROBE_FLAG_DISABLED;
}
+ if (p->post_handler && !ap->post_handler) {
+ reset_post_handler = true;
+ if (kprobe_ftrace(ap) && !kprobes_all_disarmed &&
+ !kprobe_disabled(ap))
+ ftrace_switch_ops = true;
+ else
+ ap->post_handler = aggr_post_handler;
+ }
+
/* Copy the insn slot of 'p' to 'ap'. */
copy_kprobe(ap, p);
- ret = add_new_kprobe(ap, p);
+ if (!ftrace_switch_ops)
+ add_new_kprobe(ap, p);
+ }
+
+ if (ftrace_switch_ops) {
+ /*
+ * Must switch ftrace ops outside of text_mutex and cpus_read_lock
+ * to prevent deadlocks when ftrace code modification acquires text_mutex.
+ */
+ ret = disarm_kprobe_ftrace(ap);
+ if (ret)
+ return ret;
+
+ ap->post_handler = aggr_post_handler;
+ ret = arm_kprobe_ftrace(ap);
+ if (ret) {
+ ap->post_handler = NULL;
+ if (arm_kprobe_ftrace(ap))
+ ap->flags |= KPROBE_FLAG_DISABLED;
+ return ret;
+ }
+ add_new_kprobe(ap, p);
}
- if (ret == 0 && kprobe_disabled(ap) && !kprobe_disabled(p)) {
+ if (kprobe_disabled(ap) && !kprobe_disabled(p)) {
ap->flags &= ~KPROBE_FLAG_DISABLED;
if (!kprobes_all_disarmed) {
/* Arm the breakpoint again. */
ret = arm_kprobe(ap);
if (ret) {
ap->flags |= KPROBE_FLAG_DISABLED;
+ if (reset_post_handler)
+ ap->post_handler = NULL;
list_del_rcu(&p->list);
synchronize_rcu();
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 017/742] gve: Fix backward stats when interface goes down or configuration is adjusted
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (15 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 016/742] kprobes: Switch ftrace ops when adding probe with post_handler Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 018/742] buffer: Document mmb_mark_buffer_dirty() Greg Kroah-Hartman
` (709 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Debarghya Kundu, Pin-yen Lin,
Harshitha Ramamurthy, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Debarghya Kundu <debarghyak@google.com>
[ Upstream commit 6752dfc316b94ce02998a79509df62a3aba51d1c ]
gve_get_base_stats() sets all the stats to 0, so the stats go backwards
when interface goes down or configuration is adjusted.
ndo_get_stats64 has the same problem, since gve_get_stats() only sums
the live rings, which are freed when the interface goes down.
This issue was discovered and actually triggered by the
drivers/net/stats.py selftest (check_down test case). Bringing down the
interface caused statistics counters to reset to 0, triggering selftest
assertion failures because netdevice stats must not go backwards.
Fix this by persisting baseline stats across queue teardown in
gve_queues_mem_remove() and single-queue stop in gve_rx_queue_stop().
The baseline is reported by both ndo_get_stats64 and
gve_get_base_stats().
Also report the live XDP TX ring counters in gve_get_base_stats(), as
those rings are not exposed as netdev queues.
This change was tested using the DQO RDA queue format.
Cc: stable@vger.kernel.org
Fixes: f5cedc84a30d ("gve: Add transmit and receive support")
Fixes: 2e5e0932dff5 ("gve: add support for basic queue stats")
Signed-off-by: Debarghya Kundu <debarghyak@google.com>
Co-developed-by: Pin-yen Lin <treapking@google.com>
Signed-off-by: Pin-yen Lin <treapking@google.com>
Signed-off-by: Harshitha Ramamurthy <hramamurthy@google.com>
Link: https://patch.msgid.link/20261109182036.2910559-3-hramamurthy@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/google/gve/gve.h | 7 ++
drivers/net/ethernet/google/gve/gve_main.c | 125 +++++++++++++++++----
2 files changed, 110 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/google/gve/gve.h
index 59c7fb32fda76..5fe8653883526 100644
--- a/drivers/net/ethernet/google/gve/gve.h
+++ b/drivers/net/ethernet/google/gve/gve.h
@@ -797,6 +797,10 @@ struct gve_ptp {
struct gve_priv *priv;
};
+struct gve_ring_err_stats {
+ u64 rx_alloc_fails;
+};
+
struct gve_priv {
struct net_device *dev;
struct gve_tx_ring *tx; /* array of tx_cfg.num_queues */
@@ -886,11 +890,14 @@ struct gve_priv {
/* Protects the priv->tx/priv->rx arrays, the in-place rewrite of
* priv->rx[idx] and the queue counts against stats readers that do
* not hold the netdev instance lock.
+ * Also protects base_net_stats and base_ring_err_stats.
*/
spinlock_t stats_lock;
unsigned long service_task_flags;
unsigned long state_flags;
+ struct gve_ring_err_stats base_ring_err_stats;
+ struct rtnl_link_stats64 base_net_stats;
struct gve_stats_report *stats_report;
u64 stats_report_len;
dma_addr_t stats_report_bus; /* dma address for the stats report */
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
index 1bcc8318c9d9d..af56a5bcc4e2a 100644
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -106,16 +106,44 @@ static netdev_tx_t gve_start_xmit(struct sk_buff *skb, struct net_device *dev)
return gve_tx_dqo(skb, dev);
}
-static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s)
+static void gve_add_base_stats(struct gve_priv *priv,
+ struct rtnl_link_stats64 *s)
+{
+ struct rtnl_link_stats64 *base_stats = &priv->base_net_stats;
+
+ s->rx_packets += base_stats->rx_packets;
+ s->rx_bytes += base_stats->rx_bytes;
+ s->tx_packets += base_stats->tx_packets;
+ s->tx_bytes += base_stats->tx_bytes;
+}
+
+static void gve_add_tx_ring_range_stats(struct gve_priv *priv, int start_ring,
+ int end_ring, u64 *packets, u64 *bytes)
+{
+ int ring;
+
+ for (ring = start_ring; ring < end_ring; ring++) {
+ struct gve_tx_ring *tx = &priv->tx[ring];
+ unsigned int start;
+ u64 pkts, byts;
+
+ do {
+ start = u64_stats_fetch_begin(&tx->statss);
+ pkts = tx->pkt_done;
+ byts = tx->bytes_done;
+ } while (u64_stats_fetch_retry(&tx->statss, start));
+ *packets += pkts;
+ *bytes += byts;
+ }
+}
+
+static void gve_get_ring_stats(struct gve_priv *priv,
+ struct rtnl_link_stats64 *s)
{
- struct gve_priv *priv = netdev_priv(dev);
unsigned int start;
u64 packets, bytes;
- int num_tx_queues;
int ring;
- spin_lock_bh(&priv->stats_lock);
- num_tx_queues = gve_num_tx_queues(priv);
if (priv->rx) {
for (ring = 0; ring < priv->rx_cfg.num_queues; ring++) {
do {
@@ -129,19 +157,41 @@ static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s)
s->rx_bytes += bytes;
}
}
- if (priv->tx) {
- for (ring = 0; ring < num_tx_queues; ring++) {
- do {
- start =
- u64_stats_fetch_begin(&priv->tx[ring].statss);
- packets = priv->tx[ring].pkt_done;
- bytes = priv->tx[ring].bytes_done;
- } while (u64_stats_fetch_retry(&priv->tx[ring].statss,
- start));
- s->tx_packets += packets;
- s->tx_bytes += bytes;
- }
+ if (priv->tx)
+ gve_add_tx_ring_range_stats(priv, 0, gve_num_tx_queues(priv),
+ &s->tx_packets, &s->tx_bytes);
+}
+
+static void gve_get_ring_err_stats(struct gve_priv *priv,
+ struct gve_ring_err_stats *err_stats)
+{
+ int ring;
+
+ if (!priv->rx)
+ return;
+
+ for (ring = 0; ring < priv->rx_cfg.num_queues; ring++) {
+ struct gve_rx_ring *rx = &priv->rx[ring];
+ unsigned int start;
+ u64 rx_alloc_fails;
+
+ do {
+ start = u64_stats_fetch_begin(&rx->statss);
+ rx_alloc_fails = rx->rx_skb_alloc_fail +
+ rx->rx_buf_alloc_fail;
+ } while (u64_stats_fetch_retry(&rx->statss, start));
+
+ err_stats->rx_alloc_fails += rx_alloc_fails;
}
+}
+
+static void gve_get_stats(struct net_device *dev, struct rtnl_link_stats64 *s)
+{
+ struct gve_priv *priv = netdev_priv(dev);
+
+ spin_lock_bh(&priv->stats_lock);
+ gve_get_ring_stats(priv, s);
+ gve_add_base_stats(priv, s);
spin_unlock_bh(&priv->stats_lock);
}
@@ -1390,6 +1440,9 @@ static void gve_queues_mem_remove(struct gve_priv *priv)
gve_get_curr_alloc_cfgs(priv, &tx_alloc_cfg, &rx_alloc_cfg);
spin_lock_bh(&priv->stats_lock);
+ gve_get_ring_stats(priv, &priv->base_net_stats);
+ gve_get_ring_err_stats(priv, &priv->base_ring_err_stats);
+
priv->tx = NULL;
priv->rx = NULL;
spin_unlock_bh(&priv->stats_lock);
@@ -2679,9 +2732,19 @@ static int gve_rx_queue_stop(struct net_device *dev, void *per_q_mem, int idx)
gve_per_q_mem = (struct gve_rx_ring *)per_q_mem;
spin_lock_bh(&priv->stats_lock);
+ priv->base_net_stats.rx_packets += priv->rx[idx].rpackets;
+ priv->base_net_stats.rx_bytes += priv->rx[idx].rbytes;
+ priv->base_ring_err_stats.rx_alloc_fails +=
+ priv->rx[idx].rx_skb_alloc_fail +
+ priv->rx[idx].rx_buf_alloc_fail;
*gve_per_q_mem = priv->rx[idx];
memset(&priv->rx[idx], 0, sizeof(priv->rx[idx]));
spin_unlock_bh(&priv->stats_lock);
+
+ gve_per_q_mem->rpackets = 0;
+ gve_per_q_mem->rbytes = 0;
+ gve_per_q_mem->rx_skb_alloc_fail = 0;
+ gve_per_q_mem->rx_buf_alloc_fail = 0;
return 0;
}
@@ -2839,12 +2902,30 @@ static void gve_get_base_stats(struct net_device *dev,
struct netdev_queue_stats_rx *rx,
struct netdev_queue_stats_tx *tx)
{
- rx->packets = 0;
- rx->bytes = 0;
- rx->alloc_fail = 0;
+ const struct gve_ring_err_stats *base_err_stats;
+ const struct rtnl_link_stats64 *base_stats;
+ struct gve_priv *priv;
- tx->packets = 0;
- tx->bytes = 0;
+ priv = netdev_priv(dev);
+ base_stats = &priv->base_net_stats;
+ base_err_stats = &priv->base_ring_err_stats;
+
+ spin_lock_bh(&priv->stats_lock);
+ rx->packets = base_stats->rx_packets;
+ rx->bytes = base_stats->rx_bytes;
+ rx->alloc_fail = base_err_stats->rx_alloc_fails;
+
+ tx->packets = base_stats->tx_packets;
+ tx->bytes = base_stats->tx_bytes;
+ /* XDP TX rings are not exposed as netdev queues, so report their live
+ * counters here to keep the device totals consistent with
+ * ndo_get_stats64.
+ */
+ if (priv->tx)
+ gve_add_tx_ring_range_stats(priv, priv->tx_cfg.num_queues,
+ gve_num_tx_queues(priv),
+ &tx->packets, &tx->bytes);
+ spin_unlock_bh(&priv->stats_lock);
}
static const struct netdev_stat_ops gve_stat_ops = {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 018/742] buffer: Document mmb_mark_buffer_dirty()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (16 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 017/742] gve: Fix backward stats when interface goes down or configuration is adjusted Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 019/742] fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty() Greg Kroah-Hartman
` (708 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Matthew Wilcox (Oracle), Jan Kara,
Christian Brauner (Amutable), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <willy@infradead.org>
[ Upstream commit 6c8b7651d06f635fe3d8789eda493eda3b4d13ef ]
Add kernel-doc for mmb_mark_buffer_dirty().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://patch.msgid.link/20260828205429.3678204-5-willy@infradead.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Stable-dep-of: d4fdde3257a5 ("fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/buffer.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/buffer.c b/fs/buffer.c
index ed966fa73b1ba..30e7f2cc2386f 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -618,6 +618,14 @@ void write_boundary_block(struct block_device *bdev,
}
}
+/**
+ * mmb_mark_buffer_dirty - Mark a metadata buffer dirty.
+ * @bh: The buffer to mark dirty.
+ * @mmb: The list of buffers to add the buffer to.
+ *
+ * Mark the buffer dirty and add it to the list if it is not already on
+ * a list.
+ */
void mmb_mark_buffer_dirty(struct buffer_head *bh,
struct mapping_metadata_bhs *mmb)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 019/742] fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (17 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 018/742] buffer: Document mmb_mark_buffer_dirty() Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 020/742] NFSv4/flexfiles: report the intended opnum when DS connection setup fails Greg Kroah-Hartman
` (707 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jan Kara,
Christian Brauner (Amutable), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <brauner@kernel.org>
[ Upstream commit d4fdde3257a577f184b4498d040f6fe20be72326 ]
ext2, ext4 without a journal, fat, udf and minix track the metadata
buffers of an inode in a mapping_metadata_bhs list and sync them from
->sync_inode_metadata() and ->evict_inode(). The inode block itself is
only tracked by I_METADATA_WRITEBACK which ->write_inode() sets after
copying the inode into its buffer.
Set the bit in mmb_mark_buffer_dirty() as well so that it covers all
the metadata an inode may still have to write out. Set it after the
buffer is on the list. An fsync() that sees the bit then also finds the
buffer when it walks the list, and one that cleared the bit before we
set it leaves it set for the next one.
The inode itself may never have been dirtied. fat for example tracks
the FAT buffers on a private inode that nothing marks dirty. So attach
the inode to a wb before setting the bit, the way ext4_mark_iloc_dirty()
does, or writeback_single_inode() has no wb to lock once evict() syncs
it.
That lets evict() write out everything the bit tracks in one place
instead of every ->evict_inode() calling mmb_sync() itself.
Suggested-by: Jan Kara <jack@suse.cz>
Cc: stable@vger.kernel.org # v7.3
Link: https://patch.msgid.link/20261109-work-inode-metadata_writeback-v3-8-91ac6c024018@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/buffer.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 30e7f2cc2386f..3f430fb824500 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -623,12 +623,15 @@ void write_boundary_block(struct block_device *bdev,
* @bh: The buffer to mark dirty.
* @mmb: The list of buffers to add the buffer to.
*
- * Mark the buffer dirty and add it to the list if it is not already on
- * a list.
+ * Mark the buffer dirty, add it to the list if it is not already on a list
+ * and set I_METADATA_WRITEBACK on the inode so that fsync() and eviction
+ * write it out.
*/
void mmb_mark_buffer_dirty(struct buffer_head *bh,
struct mapping_metadata_bhs *mmb)
{
+ struct inode *inode = mmb->mapping->host;
+
mark_buffer_dirty(bh);
if (!bh->b_mmb) {
spin_lock(&mmb->lock);
@@ -643,6 +646,15 @@ void mmb_mark_buffer_dirty(struct buffer_head *bh,
list_move_tail(&bh->b_assoc_buffers, &mmb->list);
spin_unlock(&mmb->lock);
}
+ /*
+ * The inode itself may never have been dirtied, so attach it to a wb
+ * before setting the bit or writeback_single_inode() has nothing to
+ * lock when evict() syncs it.
+ */
+ spin_lock(&inode->i_lock);
+ inode_attach_wb(inode, NULL);
+ inode_state_set(inode, I_METADATA_WRITEBACK);
+ spin_unlock(&inode->i_lock);
}
EXPORT_SYMBOL(mmb_mark_buffer_dirty);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 020/742] NFSv4/flexfiles: report the intended opnum when DS connection setup fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (18 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 019/742] fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty() Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 021/742] pNFS: allow layout drivers to cancel I/O to a single device Greg Kroah-Hartman
` (706 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Benjamin Coddington,
Tigran Mkrtchyan, Anna Schumaker, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <ben.coddington@hammerspace.com>
[ Upstream commit 3a612faba5c40a59257db50e3a2da30c02a8c969 ]
When nfs4_ff_layout_prepare_ds() cannot establish a connection to a
data server, it records a device error with opnum OP_ILLEGAL, since no
operation ever made it to the wire. But servers can use the ff_ioerr4
opnum to distinguish failed read-class operations from write-class
operations when deciding how to recover the affected mirror -- a mirror
that may have missed writes needs to be brought back in sync, while one
that merely failed to serve a read does not. OP_ILLEGAL gives the
server nothing to act on.
Every caller of nfs4_ff_layout_prepare_ds() knows which operation it
was preparing to send, and the existing fail_return argument already
divides the callers along the same boundary (false for READ, true for
WRITE and COMMIT). Replace the boolean with the intended opnum, derive
the layout return decision from it, and report it in the tracked device
error instead of OP_ILLEGAL.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Benjamin Coddington <bcodding@hammerspace.com>
Reviewed-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
Stable-dep-of: 9e28836b480c ("pNFS: avoid repeatedly cancelling I/O for the same lseg")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/nfs/flexfilelayout/flexfilelayout.c | 13 ++++++++-----
fs/nfs/flexfilelayout/flexfilelayout.h | 2 +-
fs/nfs/flexfilelayout/flexfilelayoutdev.c | 14 ++++++++------
3 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index a4ccd53c79e79..121c55f4a46d9 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -904,7 +904,7 @@ ff_layout_choose_ds_for_read(struct pnfs_layout_segment *lseg,
mirror_ds = ff_layout_get_mirror_ds(lseg->pls_layout, mirror,
*dss_id);
ds = nfs4_ff_layout_prepare_ds(lseg, mirror, mirror_ds,
- *dss_id, false);
+ *dss_id, OP_READ);
if (IS_ERR(ds)) {
nfs4_ff_layout_put_deviceid(mirror_ds);
ret = ERR_CAST(ds);
@@ -1183,7 +1183,7 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
mirror_ds = ff_layout_get_mirror_ds(pgio->pg_lseg->pls_layout,
mirror, dss_id);
ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, mirror,
- mirror_ds, dss_id, true);
+ mirror_ds, dss_id, OP_WRITE);
if (IS_ERR(ds)) {
nfs4_ff_layout_put_deviceid(mirror_ds);
if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg))
@@ -2277,7 +2277,8 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
mirror->dss_count,
offset);
mirror_ds = ff_layout_get_mirror_ds(lseg->pls_layout, mirror, dss_id);
- ds = nfs4_ff_layout_prepare_ds(lseg, mirror, mirror_ds, dss_id, false);
+ ds = nfs4_ff_layout_prepare_ds(lseg, mirror, mirror_ds, dss_id,
+ OP_READ);
if (IS_ERR(ds)) {
ds_fatal_error = nfs_error_is_fatal(PTR_ERR(ds));
goto out_failed;
@@ -2374,7 +2375,8 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
mirror->dss_count,
offset);
mirror_ds = ff_layout_get_mirror_ds(lseg->pls_layout, mirror, dss_id);
- ds = nfs4_ff_layout_prepare_ds(lseg, mirror, mirror_ds, dss_id, true);
+ ds = nfs4_ff_layout_prepare_ds(lseg, mirror, mirror_ds, dss_id,
+ OP_WRITE);
if (IS_ERR(ds)) {
ds_fatal_error = nfs_error_is_fatal(PTR_ERR(ds));
goto out_failed;
@@ -2481,7 +2483,8 @@ static int ff_layout_initiate_commit(struct nfs_commit_data *data, int how)
mirror = FF_LAYOUT_COMP(lseg, idx);
dss_id = calc_dss_id_from_commit(lseg, data->ds_commit_index);
mirror_ds = ff_layout_get_mirror_ds(lseg->pls_layout, mirror, dss_id);
- ds = nfs4_ff_layout_prepare_ds(lseg, mirror, mirror_ds, dss_id, true);
+ ds = nfs4_ff_layout_prepare_ds(lseg, mirror, mirror_ds, dss_id,
+ OP_COMMIT);
if (IS_ERR(ds))
goto out_err;
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h
index 24de108af2cf8..19b833f547416 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.h
+++ b/fs/nfs/flexfilelayout/flexfilelayout.h
@@ -269,7 +269,7 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
struct nfs4_ff_layout_mirror *mirror,
struct nfs4_ff_layout_ds *mirror_ds,
u32 dss_id,
- bool fail_return);
+ enum nfs_opnum4 opnum);
struct rpc_clnt *
nfs4_ff_find_or_create_ds_client(const struct nfs4_ff_layout_ds *mirror_ds,
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index 3cef6a4a51a70..fa4e9ddafea6f 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -378,7 +378,7 @@ ff_layout_get_mirror_ds(struct pnfs_layout_hdr *lo,
* @mirror_ds: referenced device node for the stripe, from
* ff_layout_get_mirror_ds() (may be an ERR_PTR)
* @dss_id: DS stripe id to select stripe to use
- * @fail_return: return layout on connect failure?
+ * @opnum: operation this connection is being prepared for
*
* Try to prepare a DS connection to accept an RPC call. This involves
* selecting a mirror to use and connecting the client to it if it's not
@@ -386,8 +386,10 @@ ff_layout_get_mirror_ds(struct pnfs_layout_hdr *lo,
*
* Since we only need a single functioning mirror to satisfy a read, we don't
* want to return the layout if there is one. For writes though, any down
- * mirror should result in a LAYOUTRETURN. @fail_return is how we distinguish
- * between the two cases.
+ * mirror should result in a LAYOUTRETURN. @opnum is how we distinguish
+ * between the two cases. On failure, @opnum is also reported in the tracked
+ * device error so that the server can tell which class of I/O the client
+ * was unable to send to the mirror.
*
* Returns a pointer to a connected DS object on success or NULL on failure.
*/
@@ -396,7 +398,7 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
struct nfs4_ff_layout_mirror *mirror,
struct nfs4_ff_layout_ds *mirror_ds,
u32 dss_id,
- bool fail_return)
+ enum nfs_opnum4 opnum)
{
struct nfs4_pnfs_ds *ds;
struct inode *ino = lseg->pls_layout->plh_inode;
@@ -443,9 +445,9 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout),
mirror, dss_id, lseg->pls_range.offset,
lseg->pls_range.length, NFS4ERR_NXIO,
- OP_ILLEGAL, GFP_NOIO);
+ opnum, GFP_NOIO);
ff_layout_send_layouterror(lseg);
- if (fail_return || !ff_layout_has_available_ds(lseg))
+ if (opnum != OP_READ || !ff_layout_has_available_ds(lseg))
pnfs_error_mark_layout_for_return(ino, lseg);
ds = ERR_PTR(status);
out:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 021/742] pNFS: allow layout drivers to cancel I/O to a single device
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (19 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 020/742] NFSv4/flexfiles: report the intended opnum when DS connection setup fails Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 022/742] pNFS: avoid repeatedly cancelling I/O for the same lseg Greg Kroah-Hartman
` (705 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Benjamin Coddington,
Tigran Mkrtchyan, Anna Schumaker, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <ben.coddington@hammerspace.com>
[ Upstream commit 94dc092b208ad324981caa85fcf8416b905ca593 ]
The ->cancel_io() layout operation cancels all in-flight I/O for a
layout segment that is being returned. When the return is triggered
by the failure of a single mirror instance, cancelling I/O to the
healthy mirrors is both unnecessary and harmful: requests that were
already transmitted cannot be un-sent, and will complete on the data
servers after the layout has been returned.
Give ->cancel_io() a device ID argument identifying the failed device,
and thread it through pnfs_error_mark_layout_for_return() and
pnfs_mark_matching_lsegs_return(). The flexfiles implementation
compares it against the raw device ID from the layout, so that it can
identify the failed mirror instance even when its device ID node was
never instantiated.
A NULL device ID preserves the existing cancel-everything behavior,
and all callers pass NULL for now, so this patch makes no change in
behavior.
Assisted-by: Claude:claude-fable-5
Signed-off-by: Benjamin Coddington <bcodding@hammerspace.com>
Reviewed-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
Stable-dep-of: 9e28836b480c ("pNFS: avoid repeatedly cancelling I/O for the same lseg")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/nfs/blocklayout/blocklayout.c | 6 +++--
fs/nfs/callback_proc.c | 2 +-
fs/nfs/filelayout/filelayout.c | 4 +--
fs/nfs/flexfilelayout/flexfilelayout.c | 16 +++++++-----
fs/nfs/flexfilelayout/flexfilelayoutdev.c | 2 +-
fs/nfs/pnfs.c | 32 ++++++++++++++---------
fs/nfs/pnfs.h | 14 ++++++----
7 files changed, 46 insertions(+), 30 deletions(-)
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index d54a141a89b3b..d86702e604f95 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -859,7 +859,8 @@ bl_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
if (pgio->pg_lseg &&
test_bit(NFS_LSEG_UNAVAILABLE, &pgio->pg_lseg->pls_flags)) {
- pnfs_error_mark_layout_for_return(pgio->pg_inode, pgio->pg_lseg);
+ pnfs_error_mark_layout_for_return(pgio->pg_inode, pgio->pg_lseg,
+ NULL);
pnfs_set_lo_fail(pgio->pg_lseg);
nfs_pageio_reset_read_mds(pgio);
}
@@ -921,7 +922,8 @@ bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
if (pgio->pg_lseg &&
test_bit(NFS_LSEG_UNAVAILABLE, &pgio->pg_lseg->pls_flags)) {
- pnfs_error_mark_layout_for_return(pgio->pg_inode, pgio->pg_lseg);
+ pnfs_error_mark_layout_for_return(pgio->pg_inode, pgio->pg_lseg,
+ NULL);
pnfs_set_lo_fail(pgio->pg_lseg);
nfs_pageio_reset_write_mds(pgio);
}
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 3fb10c8e42718..ddc8736100e11 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -292,7 +292,7 @@ static u32 initiate_file_draining(struct nfs_client *clp,
switch (pnfs_mark_matching_lsegs_return(lo, &free_me_list,
&args->cbl_range,
be32_to_cpu(args->cbl_stateid.seqid),
- args->cbl_layoutchanged)) {
+ args->cbl_layoutchanged, NULL)) {
case 0:
case -EBUSY:
/* There are layout segments that need to be returned */
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 727fe1270aab5..53808e42546a0 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -187,7 +187,7 @@ static int filelayout_async_handle_error(struct rpc_task *task,
dprintk("%s DS connection error %d\n", __func__,
task->tk_status);
nfs4_mark_deviceid_unavailable(devid);
- pnfs_error_mark_layout_for_return(inode, lseg);
+ pnfs_error_mark_layout_for_return(inode, lseg, NULL);
pnfs_set_lo_fail(lseg);
rpc_wake_up(&tbl->slot_tbl_waitq);
fallthrough;
@@ -857,7 +857,7 @@ fl_pnfs_update_layout(struct inode *ino,
status = filelayout_check_deviceid(lo, fl, gfp_flags);
if (status) {
- pnfs_error_mark_layout_for_return(ino, lseg);
+ pnfs_error_mark_layout_for_return(ino, lseg, NULL);
pnfs_set_lo_fail(lseg);
pnfs_put_lseg(lseg);
lseg = NULL;
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 121c55f4a46d9..9e1a78d7d6336 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -1333,7 +1333,7 @@ static void ff_layout_resend_pnfs_read(struct nfs_pgio_header *hdr)
mirror_ds = ff_layout_choose_any_ds_for_read(hdr->lseg, idx, &new_idx,
hdr->args.offset, &dss_id);
if (IS_ERR(mirror_ds)) {
- pnfs_error_mark_layout_for_return(hdr->inode, hdr->lseg);
+ pnfs_error_mark_layout_for_return(hdr->inode, hdr->lseg, NULL);
} else {
nfs4_ff_layout_put_deviceid(mirror_ds);
ff_layout_send_layouterror(hdr->lseg);
@@ -1346,7 +1346,7 @@ static void ff_layout_reset_read(struct nfs_pgio_header *hdr)
struct rpc_task *task = &hdr->task;
pnfs_layoutcommit_inode(hdr->inode, false);
- pnfs_error_mark_layout_for_return(hdr->inode, hdr->lseg);
+ pnfs_error_mark_layout_for_return(hdr->inode, hdr->lseg, NULL);
if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) {
dprintk("%s Reset task %5u for i/o through MDS "
@@ -1660,7 +1660,7 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg,
fallthrough;
default:
pnfs_error_mark_layout_for_return(lseg->pls_layout->plh_inode,
- lseg);
+ lseg, NULL);
}
out:
@@ -2342,7 +2342,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
* FF_FLAGS_NO_IO_THRU_MDS: force fresh LAYOUTGET,
* never fall through to MDS I/O.
*/
- pnfs_error_mark_layout_for_return(hdr->inode, lseg);
+ pnfs_error_mark_layout_for_return(hdr->inode, lseg, NULL);
return PNFS_TRY_AGAIN;
}
trace_pnfs_mds_fallback_read_pagelist(hdr->inode,
@@ -2442,7 +2442,7 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
* FF_FLAGS_NO_IO_THRU_MDS: force fresh LAYOUTGET,
* never fall through to MDS I/O.
*/
- pnfs_error_mark_layout_for_return(hdr->inode, lseg);
+ pnfs_error_mark_layout_for_return(hdr->inode, lseg, NULL);
return PNFS_TRY_AGAIN;
}
trace_pnfs_mds_fallback_write_pagelist(hdr->inode,
@@ -2570,7 +2570,8 @@ static bool ff_layout_match_io(const struct rpc_task *task, const void *data)
return false;
}
-static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg)
+static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg,
+ const struct nfs4_deviceid *devid)
{
struct nfs4_ff_layout_segment *flseg = FF_LAYOUT_LSEG(lseg);
struct nfs4_ff_layout_mirror *mirror;
@@ -2583,6 +2584,9 @@ static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg)
for (idx = 0; idx < flseg->mirror_array_cnt; idx++) {
mirror = flseg->mirror_array[idx];
for (dss_id = 0; dss_id < mirror->dss_count; dss_id++) {
+ if (devid && memcmp(&mirror->dss[dss_id].devid, devid,
+ sizeof(*devid)) != 0)
+ continue;
rcu_read_lock();
mirror_ds = rcu_dereference(mirror->dss[dss_id].mirror_ds);
if (IS_ERR_OR_NULL(mirror_ds) ||
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index fa4e9ddafea6f..b10c6de2f6d59 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -448,7 +448,7 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
opnum, GFP_NOIO);
ff_layout_send_layouterror(lseg);
if (opnum != OP_READ || !ff_layout_has_available_ds(lseg))
- pnfs_error_mark_layout_for_return(ino, lseg);
+ pnfs_error_mark_layout_for_return(ino, lseg, NULL);
ds = ERR_PTR(status);
out:
return ds;
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index ff85b82a1e222..0af3a02cea6fb 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -433,7 +433,7 @@ bool nfs4_layout_refresh_old_stateid(nfs4_stateid *dst,
}
/* Try to update the seqid to the most recent */
err = pnfs_mark_matching_lsegs_return(lo, &head, &range, 0,
- true);
+ true, NULL);
if (err != -EBUSY) {
dst->seqid = lo->plh_stateid.seqid;
*dst_range = range;
@@ -487,7 +487,8 @@ static int pnfs_mark_layout_stateid_return(struct pnfs_layout_hdr *lo,
.length = NFS4_MAX_UINT64,
};
- return pnfs_mark_matching_lsegs_return(lo, lseg_list, &range, seq, true);
+ return pnfs_mark_matching_lsegs_return(lo, lseg_list, &range, seq, true,
+ NULL);
}
static int
@@ -525,7 +526,7 @@ pnfs_layout_io_set_failed(struct pnfs_layout_hdr *lo, u32 iomode)
spin_lock(&inode->i_lock);
pnfs_layout_set_fail_bit(lo, pnfs_iomode_to_fail_bit(iomode));
- pnfs_mark_matching_lsegs_return(lo, &head, &range, 0, true);
+ pnfs_mark_matching_lsegs_return(lo, &head, &range, 0, true, NULL);
spin_unlock(&inode->i_lock);
pnfs_free_lseg_list(&head);
dprintk("%s Setting layout IOMODE_%s fail bit\n", __func__,
@@ -740,7 +741,7 @@ pnfs_mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo,
if (mark_lseg_invalid(lseg, tmp_list))
continue;
remaining++;
- pnfs_lseg_cancel_io(server, lseg);
+ pnfs_lseg_cancel_io(server, lseg, NULL);
}
dprintk("%s:Return %i\n", __func__, remaining);
return remaining;
@@ -1462,7 +1463,7 @@ _pnfs_return_layout(struct inode *ino)
}
valid_layout = pnfs_layout_is_valid(lo);
pnfs_clear_layoutcommit(ino, &tmp_list);
- pnfs_mark_matching_lsegs_return(lo, &tmp_list, &range, 0, true);
+ pnfs_mark_matching_lsegs_return(lo, &tmp_list, &range, 0, true, NULL);
/* Don't send a LAYOUTRETURN if list was initially empty */
@@ -2628,7 +2629,8 @@ pnfs_layout_process(struct nfs4_layoutget *lgp)
.iomode = IOMODE_ANY,
.length = NFS4_MAX_UINT64,
};
- pnfs_mark_matching_lsegs_return(lo, &free_me, &range, 0, true);
+ pnfs_mark_matching_lsegs_return(lo, &free_me, &range, 0, true,
+ NULL);
goto out_forget;
} else {
/* We have a completely new layout */
@@ -2661,6 +2663,7 @@ pnfs_layout_process(struct nfs4_layoutget *lgp)
* @return_range: describe layout segment ranges to be returned
* @seq: stateid seqid to match
* @cancel_io: signal io be cancelled
+ * @devid: only cancel io directed at this device (all devices if NULL)
*
* This function is mainly intended for use by layoutrecall. It attempts
* to free the layout segment immediately, or else to mark it for return
@@ -2675,7 +2678,8 @@ int
pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
struct list_head *tmp_list,
const struct pnfs_layout_range *return_range,
- u32 seq, bool cancel_io)
+ u32 seq, bool cancel_io,
+ const struct nfs4_deviceid *devid)
{
struct pnfs_layout_segment *lseg, *next;
struct nfs_server *server = NFS_SERVER(lo->plh_inode);
@@ -2702,7 +2706,7 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
remaining++;
set_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags);
if (cancel_io)
- pnfs_lseg_cancel_io(server, lseg);
+ pnfs_lseg_cancel_io(server, lseg, devid);
}
if (remaining) {
@@ -2720,7 +2724,8 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
static void
pnfs_mark_layout_for_return(struct inode *inode,
- const struct pnfs_layout_range *range)
+ const struct pnfs_layout_range *range,
+ const struct nfs4_deviceid *devid)
{
struct pnfs_layout_hdr *lo;
bool return_now = false;
@@ -2738,7 +2743,7 @@ pnfs_mark_layout_for_return(struct inode *inode,
* for how it works.
*/
if (pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs, range, 0,
- true) != -EBUSY) {
+ true, devid) != -EBUSY) {
const struct cred *cred;
nfs4_stateid stateid;
enum pnfs_iomode iomode;
@@ -2755,7 +2760,8 @@ pnfs_mark_layout_for_return(struct inode *inode,
}
void pnfs_error_mark_layout_for_return(struct inode *inode,
- struct pnfs_layout_segment *lseg)
+ struct pnfs_layout_segment *lseg,
+ const struct nfs4_deviceid *devid)
{
struct pnfs_layout_range range = {
.iomode = lseg->pls_range.iomode,
@@ -2763,7 +2769,7 @@ void pnfs_error_mark_layout_for_return(struct inode *inode,
.length = NFS4_MAX_UINT64,
};
- pnfs_mark_layout_for_return(inode, &range);
+ pnfs_mark_layout_for_return(inode, &range, devid);
}
EXPORT_SYMBOL_GPL(pnfs_error_mark_layout_for_return);
@@ -2853,7 +2859,7 @@ static int pnfs_layout_return_unused_byserver(struct nfs_server *server,
pnfs_get_layout_hdr(lo);
pnfs_set_plh_return_info(lo, range->iomode, 0);
if (pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs,
- range, 0, true) != 0 ||
+ range, 0, true, NULL) != 0 ||
!pnfs_prepare_layoutreturn(lo, &stateid, &cred, &iomode)) {
spin_unlock(&inode->i_lock);
rcu_read_unlock();
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 5725ea06efc2d..6638ffe877b32 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -178,7 +178,8 @@ struct pnfs_layoutdriver_type {
int (*prepare_layoutcommit) (struct nfs4_layoutcommit_args *args);
int (*prepare_layoutstats) (struct nfs42_layoutstat_args *args);
- void (*cancel_io)(struct pnfs_layout_segment *lseg);
+ void (*cancel_io)(struct pnfs_layout_segment *lseg,
+ const struct nfs4_deviceid *devid);
};
struct pnfs_commit_ops {
@@ -301,7 +302,8 @@ int pnfs_mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo,
int pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
struct list_head *tmp_list,
const struct pnfs_layout_range *recall_range,
- u32 seq, bool cancel_io);
+ u32 seq, bool cancel_io,
+ const struct nfs4_deviceid *devid);
int pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo,
struct list_head *lseg_list);
bool pnfs_roc(struct inode *ino, struct nfs4_layoutreturn_args *args,
@@ -351,7 +353,8 @@ int pnfs_read_done_resend_to_mds(struct nfs_pgio_header *);
int pnfs_write_done_resend_to_mds(struct nfs_pgio_header *);
struct nfs4_threshold *pnfs_mdsthreshold_alloc(void);
void pnfs_error_mark_layout_for_return(struct inode *inode,
- struct pnfs_layout_segment *lseg);
+ struct pnfs_layout_segment *lseg,
+ const struct nfs4_deviceid *devid);
void pnfs_layout_return_unused_byclid(struct nfs_client *clp,
enum pnfs_iomode iomode);
int pnfs_layout_handle_reboot(struct nfs_client *clp);
@@ -691,10 +694,11 @@ pnfs_lseg_request_intersecting(struct pnfs_layout_segment *lseg, struct nfs_page
}
static inline void pnfs_lseg_cancel_io(struct nfs_server *server,
- struct pnfs_layout_segment *lseg)
+ struct pnfs_layout_segment *lseg,
+ const struct nfs4_deviceid *devid)
{
if (server->pnfs_curr_ld->cancel_io)
- server->pnfs_curr_ld->cancel_io(lseg);
+ server->pnfs_curr_ld->cancel_io(lseg, devid);
}
extern unsigned int layoutstats_timer;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 022/742] pNFS: avoid repeatedly cancelling I/O for the same lseg
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (20 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 021/742] pNFS: allow layout drivers to cancel I/O to a single device Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 023/742] hwmon: (nct6775) Handle dual use registers Greg Kroah-Hartman
` (704 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tim Menninger, Anna Schumaker,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tim Menninger <tmenninger@everpuredata.com>
[ Upstream commit 9e28836b480c66cca4c3d391177f5b3a50927f7d ]
Commit b739a5bd9d9f ("NFSv4/flexfiles: Cancel I/O if the layout is
recalled or revoked") added I/O cancellation when a layout segment is
invalidated while outstanding references remain.
The invalid segment stays on the layout's segment list until those
references drain. Subsequent scans can find it again and repeatedly
invoke the layout driver's cancel_io() callback. For flexfiles, this
cancels matching RPC tasks and disconnects data server RPC clients.
During RPC/RDMA data server recovery, repeated cancellation can cause a
reconnect loop that consumes essentially all client CPU and prevents
forward progress.
Record cancellation requests per mirror stripe in the flexfiles layout
segment. Each stripe is cancelled at most once, regardless of how many
times the invalid segment is encountered. A per-stripe bitmap rather
than a single per-segment bit preserves the ability to cancel I/O to a
different device after an earlier device-specific cancellation.
Cancellation is best-effort. An RPC that has already passed the
layout-validity check may not yet be visible to the cancellation
scan. Such I/O retains its lseg reference and remains subject to
the normal RPC completion and recovery paths. Suppress repeated
cancellation and disconnect requests without changing the existing
lseg lifetime and deferred layout-return accounting.
This reproduced on 6.8.0, 7.0.0, and 7.4.0-rc1. It was tested on
7.4.0-rc1 with sustained pNFS/flexfiles I/O over RPC/RDMA while
restarting the NFS service on a data server. Without it, repeated
cancellation led to a reconnect loop and no workload recovery. With it,
the client recovered after the data server returned.
Fixes: b739a5bd9d9f ("NFSv4/flexfiles: Cancel I/O if the layout is recalled or revoked")
Cc: stable@vger.kernel.org
Signed-off-by: Tim Menninger <tmenninger@everpuredata.com>
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/nfs/flexfilelayout/flexfilelayout.c | 12 ++++++++++++
fs/nfs/flexfilelayout/flexfilelayout.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 9e1a78d7d6336..1c88bdc600ae7 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -11,6 +11,7 @@
#include <linux/nfs_mount.h>
#include <linux/nfs_page.h>
#include <linux/module.h>
+#include <linux/bitmap.h>
#include <linux/file.h>
#include <linux/sched/mm.h>
@@ -340,6 +341,7 @@ static void _ff_layout_free_lseg(struct nfs4_ff_layout_segment *fls)
{
if (fls) {
ff_layout_free_mirror_array(fls);
+ bitmap_free(fls->cancelled_stripes);
kfree(fls);
}
}
@@ -653,6 +655,12 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
fls->mirror_array[i]->report_interval = be32_to_cpup(p);
out_sort_mirrors:
+ fls->cancelled_stripes = bitmap_zalloc(
+ fls->mirror_array_cnt * dss_count, gfp_flags);
+ if (!fls->cancelled_stripes) {
+ rc = -ENOMEM;
+ goto out_err_free;
+ }
ff_layout_sort_mirrors(fls);
ret = &fls->generic_hdr;
dprintk("<-- %s (success)\n", __func__);
@@ -2587,6 +2595,10 @@ static void ff_layout_cancel_io(struct pnfs_layout_segment *lseg,
if (devid && memcmp(&mirror->dss[dss_id].devid, devid,
sizeof(*devid)) != 0)
continue;
+ /* Do not cancel a stripe again while this lseg drains. */
+ if (test_and_set_bit(idx * mirror->dss_count + dss_id,
+ flseg->cancelled_stripes))
+ continue;
rcu_read_lock();
mirror_ds = rcu_dereference(mirror->dss[dss_id].mirror_ds);
if (IS_ERR_OR_NULL(mirror_ds) ||
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h
index 19b833f547416..7b0d625b06a70 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.h
+++ b/fs/nfs/flexfilelayout/flexfilelayout.h
@@ -109,6 +109,7 @@ struct nfs4_ff_layout_segment {
u64 stripe_unit;
u32 flags;
u32 mirror_array_cnt;
+ unsigned long *cancelled_stripes;
struct nfs4_ff_layout_mirror *mirror_array[] __counted_by(mirror_array_cnt);
};
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 023/742] hwmon: (nct6775) Handle dual use registers
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (21 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 022/742] pNFS: avoid repeatedly cancelling I/O for the same lseg Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 024/742] s390/dasd: Fix typo immediatly -> immediately Greg Kroah-Hartman
` (703 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Anton Lundin, Guenter Roeck,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Lundin <glance@ac2.se>
[ Upstream commit ca1abdd1a9b9ce51713a18c8905bf10579533c3b ]
The REG_TARGET register has different meaning, depending on if pwm is in
thermal_cruise or speed_cruise.
This means we can't assume it's always word sized, so we need to handle
it differently depending on which mode we're in.
The code already does this, but the register was configured as word
sized for the speed_cruise mode, which would do the wrong thing in
thermal_cruise mode.
Fixes: 6c009501ff20 ("hwmon: (nct6775) Add support for NCT6102D/6106D")
Fixes: 29c7cb485b32 ("hwmon: (nct6775) Integrate new model nct6116")
Fixes: 437b3c2a4bdc ("hwmon: (nct6775) Add support for NCT6126D")
Cc: stable@vger.kernel.org
Signed-off-by: Anton Lundin <glance@ac2.se>
Link: https://patch.msgid.link/20261109082511.851377-2-glance@ac2.se
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hwmon/nct6775-core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
index 759ea3d1286e3..9096be35448bb 100644
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1153,14 +1153,12 @@ bool nct6775_reg_is_word_sized(struct nct6775_data *data, u16 reg)
case nct6106:
return reg == 0x20 || reg == 0x22 || reg == 0x24 ||
(reg >= 0x59 && reg < 0x69 && (reg & 1)) ||
- reg == 0xe0 || reg == 0xe2 || reg == 0xe4 ||
- reg == 0x111 || reg == 0x121 || reg == 0x131;
+ reg == 0xe0 || reg == 0xe2 || reg == 0xe4;
case nct6116:
return reg == 0x20 || reg == 0x22 || reg == 0x24 ||
reg == 0x26 || reg == 0x28 || reg == 0x59 || reg == 0x5b ||
reg == 0xe0 || reg == 0xe2 || reg == 0xe4 || reg == 0xe6 ||
- reg == 0xe8 || reg == 0x111 || reg == 0x121 || reg == 0x131 ||
- reg == 0x191 || reg == 0x1a1;
+ reg == 0xe8;
case nct6775:
return (((reg & 0xff00) == 0x100 ||
(reg & 0xff00) == 0x200) &&
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 024/742] s390/dasd: Fix typo immediatly -> immediately
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (22 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 023/742] hwmon: (nct6775) Handle dual use registers Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 025/742] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start Greg Kroah-Hartman
` (702 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jan Höppner,
Stefan Haberland, Jens Axboe, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Haberland <sth@linux.ibm.com>
[ Upstream commit ae6f19236b5ae4eef4df2780d51bee19add0eba8 ]
Fix typo in function name dasd_sleep_on_immediatly().
Suggested-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Link: https://patch.msgid.link/20261112102608.1057852-2-sth@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: 25cdc1f63227 ("s390/dasd: Re-initialize RCD buffer with "V1.0" before every start")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/s390/block/dasd.c | 4 ++--
drivers/s390/block/dasd_alias.c | 2 +-
drivers/s390/block/dasd_eckd.c | 14 +++++++-------
drivers/s390/block/dasd_int.h | 2 +-
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 2ffe404b890fd..d74ef737ae26a 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -2576,7 +2576,7 @@ static inline int _dasd_term_running_cqr(struct dasd_device *device)
return rc;
}
-int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
+int dasd_sleep_on_immediately(struct dasd_ccw_req *cqr)
{
struct dasd_device *device;
int rc;
@@ -2628,7 +2628,7 @@ int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
return rc;
}
-EXPORT_SYMBOL(dasd_sleep_on_immediatly);
+EXPORT_SYMBOL(dasd_sleep_on_immediately);
/*
* Cancels a request that was started with dasd_sleep_on_req.
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index 8d6c16d35c22a..1ffcfcfe4565f 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -750,7 +750,7 @@ static int reset_summary_unit_check(struct alias_lcu *lcu,
cqr->buildclk = get_tod_clock();
cqr->status = DASD_CQR_FILLED;
- rc = dasd_sleep_on_immediatly(cqr);
+ rc = dasd_sleep_on_immediately(cqr);
return rc;
}
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index d3de0d97cca21..73741873d42a4 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -922,7 +922,7 @@ static int dasd_eckd_read_conf_immediately(struct dasd_device *device,
set_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags);
cqr->retries = 5;
cqr->callback = read_conf_cb;
- rc = dasd_sleep_on_immediatly(cqr);
+ rc = dasd_sleep_on_immediately(cqr);
return rc;
}
@@ -6009,7 +6009,7 @@ __context_unsafe(/* Conditional locking */)
cqr->buildclk = get_tod_clock();
cqr->status = DASD_CQR_FILLED;
- rc = dasd_sleep_on_immediatly(cqr);
+ rc = dasd_sleep_on_immediately(cqr);
if (!rc)
clear_bit(DASD_FLAG_IS_RESERVED, &device->flags);
@@ -6065,7 +6065,7 @@ __context_unsafe(/* Conditional locking */)
cqr->buildclk = get_tod_clock();
cqr->status = DASD_CQR_FILLED;
- rc = dasd_sleep_on_immediatly(cqr);
+ rc = dasd_sleep_on_immediately(cqr);
if (!rc)
set_bit(DASD_FLAG_IS_RESERVED, &device->flags);
@@ -6120,7 +6120,7 @@ __context_unsafe(/* Conditional locking */)
cqr->buildclk = get_tod_clock();
cqr->status = DASD_CQR_FILLED;
- rc = dasd_sleep_on_immediatly(cqr);
+ rc = dasd_sleep_on_immediately(cqr);
if (!rc)
set_bit(DASD_FLAG_IS_RESERVED, &device->flags);
@@ -6184,7 +6184,7 @@ __context_unsafe(/* Conditional locking */)
cqr->status = DASD_CQR_FILLED;
cqr->lpm = usrparm.path_mask;
- rc = dasd_sleep_on_immediatly(cqr);
+ rc = dasd_sleep_on_immediately(cqr);
/* verify that I/O processing didn't modify the path mask */
if (!rc && usrparm.path_mask && (cqr->lpm != usrparm.path_mask))
rc = -EIO;
@@ -6816,7 +6816,7 @@ static int dasd_eckd_read_message_buffer(struct dasd_device *device,
cqr->block = NULL;
cqr->expires = 10 * HZ;
set_bit(DASD_CQR_VERIFY_PATH, &cqr->flags);
- /* dasd_sleep_on_immediatly does not do complex error
+ /* dasd_sleep_on_immediately does not do complex error
* recovery so clear erp flag and set retry counter to
* do basic erp */
clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
@@ -6848,7 +6848,7 @@ static int dasd_eckd_read_message_buffer(struct dasd_device *device,
cqr->buildclk = get_tod_clock();
cqr->status = DASD_CQR_FILLED;
- rc = dasd_sleep_on_immediatly(cqr);
+ rc = dasd_sleep_on_immediately(cqr);
if (rc == 0) {
prssdp = (struct dasd_psf_prssd_data *) cqr->data;
message_buf = (struct dasd_rssd_messages *)
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index ef4930432c098..26ecf9f47d2eb 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -998,7 +998,7 @@ void dasd_schedule_device_bh(struct dasd_device *);
void dasd_schedule_block_bh(struct dasd_block *);
int dasd_sleep_on(struct dasd_ccw_req *);
int dasd_sleep_on_queue(struct list_head *);
-int dasd_sleep_on_immediatly(struct dasd_ccw_req *);
+int dasd_sleep_on_immediately(struct dasd_ccw_req *);
int dasd_sleep_on_queue_interruptible(struct list_head *);
int dasd_sleep_on_interruptible(struct dasd_ccw_req *);
void dasd_device_set_timer(struct dasd_device *, int);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 025/742] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (23 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 024/742] s390/dasd: Fix typo immediatly -> immediately Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 026/742] sched_ext: Fix ops.enqueue/dispatch() calls before ops.cpu_online() Greg Kroah-Hartman
` (701 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jan Höppner, Stefan Haberland,
Jens Axboe, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Haberland <sth@linux.ibm.com>
[ Upstream commit 25cdc1f63227a1ea69a1ec823a8a860e33299169 ]
Under z/VM the Read Configuration Data (RCD) buffer has to start with
EBCDIC "V1.0" to request the virtual device SNEQ that carries the
minidisk UIT. The request and the response share the same buffer:
CP evaluates the magic on the way out and the RCD data is written into
the same buffer on the way back.
The magic is only written when the request is built and again in
read_conf_cb() when the original request fails.
Several restart paths do not run that callback:
- ERP use the same buffer and if the same error occurs again,
the ERP restarts the existing ERP request;
if a different error occurs, it adds another ERP request.
Neither re-initializes the magic.
- Terminated (timed out) ERP requests, killed requests and requests
requeued after the last path was gone are restarted without it.
- dasd_sleep_on_immediately() overwrites cqr->callback, so read_conf_cb()
never ran for dasd_eckd_read_conf_immediately(), and its fastpath
retries in dasd_int_handler() do not call a callback either.
If such a restart succeeds, z/VM omits the virtual device SNEQ, the UID
of that path is built without the UIT and the paths are reported as
"Not all channel paths lead to the same device" although they lead to
the same minidisk.
Every start of a request, whatever path led to it, goes through
dasd_start_IO(). Add an optional prepare_io function to the request
that dasd_start_IO() calls before every start of the request and of
its ERP requests, and use it to write the magic for RCD requests.
The ERP handling stays unchanged. read_conf_cb() is no longer needed
and is removed, which also gets rid of its memset() that only cleared
a single byte.
Fixes: 5915a873fcb1 ("[S390] dasd: re-initialize read_conf buffer for retries")
Cc: stable@vger.kernel.org
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Link: https://patch.msgid.link/20261112102608.1057852-3-sth@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/s390/block/dasd.c | 1 +
drivers/s390/block/dasd_eckd.c | 52 ++++++++++++----------------------
drivers/s390/block/dasd_int.h | 15 ++++++++++
3 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index d74ef737ae26a..3a55c937d0d64 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1396,6 +1396,7 @@ int dasd_start_IO(struct dasd_ccw_req *cqr)
cqr->status = DASD_CQR_ERROR;
return -EIO;
}
+ dasd_start_IO_prepare(cqr);
cqr->startclk = get_tod_clock();
cqr->starttime = jiffies;
cqr->retries--;
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 73741873d42a4..7e60d5b3b343c 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -845,20 +845,29 @@ static int dasd_eckd_compare_path_uid(struct dasd_device *device,
return memcmp(&device_uid, &path_uid, sizeof(struct dasd_uid));
}
+/*
+ * The RCD buffer has to start with EBCDIC "V1.0" to show support for
+ * virtual device SNEQ. The RCD data is written into the same buffer, so
+ * a failed attempt may already have overwritten the magic. Re-initialize
+ * it before every start, including restarts by ERP requests.
+ */
+static void dasd_eckd_rcd_prepare_io(struct dasd_ccw_req *cqr)
+{
+ struct ccw1 *ccw = cqr->cpaddr;
+ __u8 *rcd_buffer = dma32_to_virt(ccw->cda);
+
+ rcd_buffer[0] = 0xE5;
+ rcd_buffer[1] = 0xF1;
+ rcd_buffer[2] = 0x4B;
+ rcd_buffer[3] = 0xF0;
+}
+
static void dasd_eckd_fill_rcd_cqr(struct dasd_device *device,
struct dasd_ccw_req *cqr,
__u8 *rcd_buffer,
__u8 lpm)
{
struct ccw1 *ccw;
- /*
- * buffer has to start with EBCDIC "V1.0" to show
- * support for virtual device SNEQ
- */
- rcd_buffer[0] = 0xE5;
- rcd_buffer[1] = 0xF1;
- rcd_buffer[2] = 0x4B;
- rcd_buffer[3] = 0xF0;
ccw = cqr->cpaddr;
ccw->cmd_code = DASD_ECKD_CCW_RCD;
@@ -875,33 +884,10 @@ static void dasd_eckd_fill_rcd_cqr(struct dasd_device *device,
cqr->retries = 256;
cqr->buildclk = get_tod_clock();
cqr->status = DASD_CQR_FILLED;
+ cqr->prepare_io = dasd_eckd_rcd_prepare_io;
set_bit(DASD_CQR_VERIFY_PATH, &cqr->flags);
}
-/*
- * Wakeup helper for read_conf
- * if the cqr is not done and needs some error recovery
- * the buffer has to be re-initialized with the EBCDIC "V1.0"
- * to show support for virtual device SNEQ
- */
-static void read_conf_cb(struct dasd_ccw_req *cqr, void *data)
-{
- struct ccw1 *ccw;
- __u8 *rcd_buffer;
-
- if (cqr->status != DASD_CQR_DONE) {
- ccw = cqr->cpaddr;
- rcd_buffer = dma32_to_virt(ccw->cda);
- memset(rcd_buffer, 0, sizeof(*rcd_buffer));
-
- rcd_buffer[0] = 0xE5;
- rcd_buffer[1] = 0xF1;
- rcd_buffer[2] = 0x4B;
- rcd_buffer[3] = 0xF0;
- }
- dasd_wakeup_cb(cqr, data);
-}
-
static int dasd_eckd_read_conf_immediately(struct dasd_device *device,
struct dasd_ccw_req *cqr,
__u8 *rcd_buffer,
@@ -921,7 +907,6 @@ static int dasd_eckd_read_conf_immediately(struct dasd_device *device,
clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
set_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags);
cqr->retries = 5;
- cqr->callback = read_conf_cb;
rc = dasd_sleep_on_immediately(cqr);
return rc;
}
@@ -959,7 +944,6 @@ static int dasd_eckd_read_conf_lpm(struct dasd_device *device,
goto out_error;
}
dasd_eckd_fill_rcd_cqr(device, cqr, rcd_buf, lpm);
- cqr->callback = read_conf_cb;
ret = dasd_sleep_on(cqr);
/*
* on success we update the user input parms
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 26ecf9f47d2eb..53c450036fe10 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -147,6 +147,8 @@ struct dasd_ccw_req {
void *data; /* pointer to data area */
struct irb irb; /* device status in case of an error */
struct dasd_ccw_req *refers; /* ERP-chain queueing. */
+ /* optional prepare function called before every start_io, must not sleep */
+ void (*prepare_io)(struct dasd_ccw_req *cqr);
void *function; /* originating ERP action */
void *mem_chunk;
@@ -892,6 +894,19 @@ static inline void *dasd_get_callback_data(struct dasd_ccw_req *cqr)
return cqr->callback_data;
}
+/*
+ * Walk down the ERP chain to the original CQR and call its
+ * prepare_io function if set.
+ */
+static inline void dasd_start_IO_prepare(struct dasd_ccw_req *cqr)
+{
+ /* ERP requests use the prepare function of the original request */
+ while (cqr->refers)
+ cqr = cqr->refers;
+ if (cqr->prepare_io)
+ cqr->prepare_io(cqr);
+}
+
static inline bool dasd_req_conflict(struct dasd_ccw_req *cqr1,
struct dasd_ccw_req *cqr2)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 026/742] sched_ext: Fix ops.enqueue/dispatch() calls before ops.cpu_online()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (24 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 025/742] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 027/742] ksmbd: let the parents DACL grant DELETE and FILE_READ_ATTRIBUTES Greg Kroah-Hartman
` (700 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Tejun Heo, Andrea Righi, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <tj@kernel.org>
[ Upstream commit 2227a34ff7bfcf6112931039e3554f4b70b65ab9 ]
ops.cpu_online() documents that the cpu doesn't call ops.enqueue() or
ops.dispatch() before that op. Both are gated on SCX_RQ_ONLINE, which
follows the core's rq online state through the ext class's rq_online and
rq_offline hooks. On a runtime cpu up, sched_cpu_activate() runs:
1. set_cpu_active() marks the cpu active.
2. cpuset_cpu_active() rebuilds the sched domains synchronously, and
rq_attach_root() puts the rq online as the cpu is active now. The
rq_online hook sets SCX_RQ_ONLINE.
3. scx_rq_activate() calls the root's ops.cpu_online().
Between 2 and 3, ops.enqueue() can be called for tasks woken or migrated
onto the cpu, and ops.dispatch() can run on it.
The hooks can't call the ops. They run under the rq lock with IRQs off while
the ops can be sleepable BPF programs, and handle_hotplug() needs the
rebuilt sched domains for its idle topology update.
Track SCX_RQ_ONLINE in handle_hotplug() alone. Set it right after the root's
ops.cpu_online(). Clear it and move the cpu's tasks to its local DSQ when
the cpu goes down. Sched domain rebuilds, which take a live cpu's rq offline
and online again, no longer touch the flag, so a remote dispatch can't see
it cleared by a rebuild and bounce to the global DSQ.
Between 2 and 3, tasks that land on the cpu now go to its local DSQ without
ops.enqueue(), and with sub-schedulers a task whose scheduler lacks caps on
the cpu is admitted anyway and counted in SCX_EV_SUB_FORCED_ADMIT. Both
already happen between 1 and 2.
Fixes: 60c27fb59f6c ("sched_ext: Implement sched_ext_ops.cpu_online/offline()")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
[ sashal: Moved the SCX_RQ_ONLINE set/clear into handle_hotplug() and placed the ecaps reseed after it, dropping context lines for helpers and a flag this tree lacks and using the older comment wording. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/sched/ext/ext.c | 65 ++++++++++++++++++++++----------------
kernel/sched/ext/inlines.h | 2 +-
kernel/sched/ext/sub.c | 9 +++---
kernel/sched/sched.h | 8 +++--
4 files changed, 48 insertions(+), 36 deletions(-)
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 6db6ca912bb37..fbdf03214564d 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -1997,11 +1997,11 @@ static void direct_dispatch(struct scx_sched *sch, struct task_struct *p,
bool scx_rq_online(struct rq *rq)
{
/*
- * Test both cpu_active() and %SCX_RQ_ONLINE. %SCX_RQ_ONLINE indicates
- * the online state as seen from the BPF scheduler. cpu_active() test
- * guarantees that, if this function returns %true, %SCX_RQ_ONLINE will
- * stay set until the current scheduling operation is complete even if
- * we aren't locking @rq.
+ * Test both cpu_active() and %SCX_RQ_ONLINE. %SCX_RQ_ONLINE is set
+ * after the root's ops.cpu_online() and cleared when the cpu goes down.
+ * cpu_active() test guarantees that, if this function returns %true,
+ * %SCX_RQ_ONLINE will stay set until the current scheduling operation
+ * is complete even if we aren't locking @rq.
*/
return likely((rq->scx.flags & SCX_RQ_ONLINE) && cpu_active(cpu_of(rq)));
}
@@ -3825,6 +3825,13 @@ static void handle_hotplug(struct rq *rq, bool online)
s32 cpu = cpu_of(rq);
s32 cpu_or_cid = cpu;
+ if (!online) {
+ guard(rq_lock_irqsave)(rq);
+ update_rq_clock(rq);
+ rq->scx.flags &= ~SCX_RQ_ONLINE;
+ drain_offline_rq(rq);
+ }
+
atomic_long_inc(&scx_hotplug_seq);
/*
@@ -3832,15 +3839,19 @@ static void handle_hotplug(struct rq *rq, bool online)
* stable here. Note that we can't depend on scx_enabled() test as the
* hotplug ops need to be enabled before __scx_enabled is set.
*/
- if (unlikely(!sch))
+ if (unlikely(!sch)) {
+ /* no root to notify, set %SCX_RQ_ONLINE right away */
+ if (online) {
+ guard(rq_lock_irqsave)(rq);
+ rq->scx.flags |= SCX_RQ_ONLINE;
+ }
return;
+ }
if (scx_enabled())
scx_idle_update_selcpu_topology(&sch->ops);
- if (online)
- scx_online_ecaps(rq);
- else
+ if (!online)
scx_offline_ecaps(rq);
/*
@@ -3880,6 +3891,23 @@ static void handle_hotplug(struct rq *rq, bool online)
SCX_ECODE_ACT_RESTART | SCX_ECODE_RSN_HOTPLUG,
"cpu %d going %s, exiting scheduler", cpu,
online ? "online" : "offline");
+
+ if (online) {
+ /*
+ * The cpu must not call ops.enqueue() or ops.dispatch() before
+ * the root's ops.cpu_online(). The core's rq online state can't
+ * gate them, as the sched domain rebuild in
+ * sched_cpu_activate() can put @rq online before this function
+ * runs. Set %SCX_RQ_ONLINE here.
+ *
+ * scx_online_ecaps() queues a reseed whose ecaps ops run in
+ * dispatch context on the cpu and can insert into its local
+ * DSQ. Set the flag first.
+ */
+ scoped_guard (rq_lock_irqsave, rq)
+ rq->scx.flags |= SCX_RQ_ONLINE;
+ scx_online_ecaps(rq);
+ }
}
void scx_rq_activate(struct rq *rq)
@@ -3892,22 +3920,6 @@ void scx_rq_deactivate(struct rq *rq)
handle_hotplug(rq, false);
}
-static void rq_online_scx(struct rq *rq)
-{
- rq->scx.flags |= SCX_RQ_ONLINE;
-}
-
-static void rq_offline_scx(struct rq *rq)
-{
- rq->scx.flags &= ~SCX_RQ_ONLINE;
-
- /* sched domain rebuilds call rq_offline with the CPU staying alive */
- if (cpu_active(cpu_of(rq)))
- return;
-
- drain_offline_rq(rq);
-}
-
static bool check_rq_for_timeouts(struct rq *rq)
{
struct scx_sched *sch;
@@ -5287,9 +5299,6 @@ DEFINE_SCHED_CLASS(ext) = {
.task_woken = task_woken_scx,
.set_cpus_allowed = set_cpus_allowed_scx,
- .rq_online = rq_online_scx,
- .rq_offline = rq_offline_scx,
-
.task_tick = task_tick_scx,
.switching_to = switching_to_scx,
diff --git a/kernel/sched/ext/inlines.h b/kernel/sched/ext/inlines.h
index 5dce394e08134..8de281a5c9c6e 100644
--- a/kernel/sched/ext/inlines.h
+++ b/kernel/sched/ext/inlines.h
@@ -104,7 +104,7 @@ scx_dispatch_sched(struct scx_sched *sch, struct rq *rq,
/*
* scx_rq_online() can't be used. Its cpu_active() test goes false
* before CPU hotplug waits for an RCU grace period, and
- * rq_offline_scx() moves this CPU's tasks to the local DSQ only after
+ * handle_hotplug() moves this CPU's tasks to the local DSQ only after
* the wait. The grace period can depend on those tasks running.
*/
if (unlikely(!SCX_HAS_OP(sch, dispatch)) || !(rq->scx.flags & SCX_RQ_ONLINE))
diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
index 4dc3bb12aca3a..c06017429890c 100644
--- a/kernel/sched/ext/sub.c
+++ b/kernel/sched/ext/sub.c
@@ -883,10 +883,11 @@ struct scx_dispatch_q *scx_resolve_local_dsq(struct scx_sched *sch, struct rq *r
return &rq->scx.local_dsq;
/*
- * The task must run on this CPU regardless of caps: the rq is draining
- * offline (BPF scheduler bypassed), the task is migration-disabled, or a
- * migration is pending. Admit despite the missing caps and count it.
- * Refuse preemptions.
+ * The task must run on this CPU regardless of caps: ops.enqueue() is
+ * skipped while the CPU is going down or before the root's
+ * ops.cpu_online(), the task is migration-disabled, or a migration is
+ * pending. Admit despite the missing caps and count it. Refuse
+ * preemptions.
*/
if (unlikely(!scx_rq_online(rq) || is_migration_disabled(p) ||
p->migration_pending)) {
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 61b913032c640..80e72b01b718c 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -781,9 +781,11 @@ struct cfs_rq {
/* scx_rq->flags, protected by the rq lock */
enum scx_rq_flags {
/*
- * A hotplugged CPU starts scheduling before rq_online_scx(). Track
- * ops.cpu_on/offline() state so that ops.enqueue/dispatch() are called
- * only while the BPF scheduler considers the CPU to be online.
+ * Set right after the root's ops.cpu_online() when a cpu comes up and
+ * cleared when the cpu goes down, see handle_hotplug(). A hotplugged
+ * cpu starts scheduling before %SCX_RQ_ONLINE is set. ops.enqueue() and
+ * ops.dispatch() are called for the cpu only while the flag is set, see
+ * scx_rq_online() and scx_dispatch_sched().
*/
SCX_RQ_ONLINE = 1 << 0,
SCX_RQ_CAN_STOP_TICK = 1 << 1,
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 027/742] ksmbd: let the parents DACL grant DELETE and FILE_READ_ATTRIBUTES
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (25 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 026/742] sched_ext: Fix ops.enqueue/dispatch() calls before ops.cpu_online() Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 028/742] ksmbd: skip metadata-only opens in sharing checks Greg Kroah-Hartman
` (699 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ian Bridges, Namjae Jeon,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Bridges <icb@fastmail.org>
[ Upstream commit 4ab80fd4d1f1c4363b336ddb3d8818ea37c4997d ]
FILE_DELETE_CHILD on a directory can grant DELETE on its children.
FILE_LIST_DIRECTORY can similarly grant FILE_READ_ATTRIBUTES. Because
ksmbd checks only the child's DACL, it can refuse rename, deletion and
attribute opens that the parent permits.
When the child does not grant an explicitly requested DELETE or
FILE_READ_ATTRIBUTES, check the parent for FILE_DELETE_CHILD or
FILE_LIST_DIRECTORY. Use exact SID matching, evaluate group allows and
denies, and exclude guest and anonymous sessions from Authenticated
Users. Fail closed on non-inherit-only object deny ACEs, missing or
unreadable parent DACLs and the mount root.
For the strict parent check, let applicable group and OWNER RIGHTS ACEs
decide before the POSIX ACL fallback. Otherwise a POSIX ACL entry can
hide a FILE_DELETE_CHILD grant.
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Ian Bridges <icb@fastmail.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/server/smbacl.c | 99 ++++++++++++++++++++++++++++++++++--------
1 file changed, 81 insertions(+), 18 deletions(-)
diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 27da571c96127..50e6ef4240571 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -1494,6 +1494,11 @@ static bool smb_sid_is_owner_rights(const struct smb_sid *sid)
!compare_sids(sid, &sid_owner_rights);
}
+static unsigned int smb_parent_derived_rights(struct ksmbd_conn *conn,
+ const struct path *path, int uid,
+ bool authenticated,
+ unsigned int want);
+
int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
__le32 *pdaccess, __le32 raw_daccess, int uid,
bool authenticated, bool strict)
@@ -1514,16 +1519,19 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
unsigned int grp_allowed = 0, grp_denied = 0, bits;
struct smb_ace *others_ace = NULL;
bool or_ace = false, obj_deny = false, au_ace = false, member, counted;
+ bool grp_ace = false;
struct posix_acl_entry *pa_entry;
unsigned int sid_type = SIDOWNER;
unsigned short ace_size;
bool is_owner, owner_rights = false;
bool maximal = *pdaccess & FILE_MAXIMAL_ACCESS_LE;
/*
- * MAXIMUM_ALLOWED requests match every session against
- * Authenticated Users.
+ * MAXIMUM_ALLOWED requests that are not strict match every session
+ * against Authenticated Users and do not count ACEs for the
+ * caller's groups. Strict ones match SIDs as explicit requests do.
*/
- bool authusers = authenticated || maximal;
+ bool open_max = maximal && !strict;
+ bool authusers = authenticated || open_max;
vfsuid_t vfsuid;
ksmbd_debug(SMB, "check permission using windows acl\n");
@@ -1557,13 +1565,16 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
/*
* An empty (present, zero-ACE) DACL grants no access to
* anyone except the object owner's implicit READ_CONTROL
- * and WRITE_DAC (MS-DTYP 2.4.5). Deny every other caller,
- * deny the owner any access beyond those two bits, and do
- * not let trailing bytes after a zero-ACE DACL become an
- * implicit grant.
+ * and WRITE_DAC (MS-DTYP 2.5.3.2), besides what the parent
+ * grants. Deny every other right, and do not let trailing
+ * bytes after a zero-ACE DACL become an implicit grant.
*/
if (is_owner)
allowed = READ_CONTROL | WRITE_DAC;
+ if (!strict)
+ allowed |= smb_parent_derived_rights(conn, path, uid,
+ authenticated,
+ requested & ~allowed);
if (maximal)
requested |= allowed;
if (!allowed || requested & ~allowed)
@@ -1576,9 +1587,10 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
/*
* Evaluate the DACL in order (MS-DTYP 2.5.3.2). access_bits collects
* the result for the ACEs that apply to the caller, without its groups
- * for MAXIMUM_ALLOWED. grp_granted collects what ACEs for the caller's
- * groups, or OWNER RIGHTS for the owner, grant. It is used when the
- * SID lookup and POSIX ACL fallback below do not decide.
+ * for a MAXIMUM_ALLOWED request that is not strict. grp_granted
+ * collects what ACEs for the caller's groups, or OWNER RIGHTS for the
+ * owner, grant. It is used when the SID lookup and POSIX ACL fallback
+ * below do not decide.
*/
ace = (struct smb_ace *)((char *)pdacl + sizeof(struct smb_acl));
aces_size = pdacl_size - sizeof(struct smb_acl);
@@ -1623,8 +1635,8 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
compare_sids(&sid_owner_rights, &ace->sid) &&
!member))
goto next_ace;
- /* An explicit request counts only SIDs that match exactly */
- if (!maximal && !member &&
+ /* Other requests count only SIDs that match exactly */
+ if (!open_max && !member &&
!smb_sid_equal(&sid, &ace->sid) &&
!smb_sid_equal(&sid_everyone, &ace->sid) &&
!(authusers && smb_sid_equal(&sid_authusers, &ace->sid)) &&
@@ -1634,10 +1646,11 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
bits = le32_to_cpu(ace->access_req);
switch (ace->type) {
case ACCESS_ALLOWED_ACE_TYPE:
+ grp_ace |= counted;
if (counted)
grp_allowed |= bits;
- /* MAXIMUM_ALLOWED takes no group grants */
- if (maximal && member)
+ /* An open's MAXIMUM_ALLOWED takes no group grants */
+ if (open_max && member)
break;
if (counted)
grp_granted |= bits;
@@ -1645,10 +1658,11 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
break;
case ACCESS_DENIED_ACE_TYPE:
case ACCESS_DENIED_CALLBACK_ACE_TYPE:
+ grp_ace |= counted;
if (counted)
grp_denied |= ~grp_allowed & bits;
- /* MAXIMUM_ALLOWED takes no group denials either */
- if (!(maximal && member))
+ /* nor group denials */
+ if (!(open_max && member))
denied |= ~access_bits & bits;
break;
}
@@ -1663,6 +1677,9 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
access_bits |= READ_CONTROL | WRITE_DAC |
FILE_READ_ATTRIBUTES | DELETE;
access_bits &= ~denied;
+ /* An object deny ACE could deny the parent's rights */
+ if (!open_max && obj_deny)
+ access_bits = 0;
if ((raw_daccess & FILE_GENERIC_EXECUTE_LE) &&
S_ISREG(d_inode(path->dentry)->i_mode) &&
(access_bits & GENERIC_READ_FLAGS) == GENERIC_READ_FLAGS)
@@ -1719,10 +1736,13 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
posix_acls = get_inode_acl(d_inode(path->dentry), ACL_TYPE_ACCESS);
/*
* An Authenticated Users ACE keeps the POSIX ACL from deciding,
- * also for sessions that it does not match.
+ * also for sessions that it does not match. For a strict
+ * MAXIMUM_ALLOWED request, ACEs for the caller's groups or
+ * OWNER RIGHTS decide before the POSIX ACL, unless the DACL has
+ * an object deny ACE, which ksmbd does not parse.
*/
if (!IS_ERR_OR_NULL(posix_acls) && !found && !others_ace &&
- !au_ace) {
+ !au_ace && !(strict && maximal && grp_ace && !obj_deny)) {
unsigned int id = -1;
pa_entry = posix_acls->a_entries;
@@ -1783,6 +1803,10 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
*/
if (!obj_deny)
allowed |= grp_granted;
+ if (!strict)
+ allowed |= smb_parent_derived_rights(conn, path, uid,
+ authenticated,
+ requested & ~allowed);
if (maximal)
requested |= allowed;
if (!allowed || requested & ~allowed) {
@@ -1828,6 +1852,45 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
return rc;
}
+/*
+ * Return the rights in @want that @path gets from its parent directory:
+ * DELETE if the parent's DACL grants FILE_DELETE_CHILD, and
+ * FILE_READ_ATTRIBUTES if it grants FILE_LIST_DIRECTORY
+ * (MS-FSA 2.1.5.1.2.1). A parent with no DACL, or with one that ksmbd
+ * cannot read, gives nothing. Callers pass only rights that the request
+ * names.
+ */
+static unsigned int smb_parent_derived_rights(struct ksmbd_conn *conn,
+ const struct path *path, int uid,
+ bool authenticated,
+ unsigned int want)
+{
+ struct path parent = { .mnt = path->mnt };
+ __le32 granted = FILE_MAXIMAL_ACCESS_LE;
+ unsigned int rights = 0;
+ int rc;
+
+ if (!(want & (DELETE | FILE_READ_ATTRIBUTES)))
+ return 0;
+
+ /* The root of the mount, or a disconnected dentry, has no parent */
+ if (path->dentry == path->mnt->mnt_root || IS_ROOT(path->dentry))
+ return 0;
+
+ parent.dentry = dget_parent(path->dentry);
+ /* Strict, so the parent's own parent is not consulted */
+ rc = smb_check_perm_dacl(conn, &parent, &granted, 0, uid,
+ authenticated, true);
+ dput(parent.dentry);
+ if (rc || granted == FILE_MAXIMAL_ACCESS_LE)
+ return 0;
+ if (granted & FILE_DELETE_CHILD_LE)
+ rights |= DELETE;
+ if (granted & FILE_LIST_DIRECTORY_LE)
+ rights |= FILE_READ_ATTRIBUTES;
+ return rights & want;
+}
+
int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
const struct path *path, struct smb_ntsd *pntsd, int ntsd_len,
bool type_check, bool get_write)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 028/742] ksmbd: skip metadata-only opens in sharing checks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (26 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 027/742] ksmbd: let the parents DACL grant DELETE and FILE_READ_ATTRIBUTES Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 029/742] ksmbd: skip metadata-only stream opens in the delete check Greg Kroah-Hartman
` (698 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ian Bridges, Namjae Jeon,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Bridges <icb@fastmail.org>
[ Upstream commit 81fefb6c635489e71e286d1465b6dd1d0a27ceec ]
A READ_CONTROL open without sharing can block later reads, writes and
deletes even though it holds no data, execute or delete access.
Keep the existing attribute-only exception. For other pairs, require
both effective access masks to hold one of those rights. MS-FSA
2.1.5.1.2 grants FILE_WRITE_DATA when an open overwrites a file or
stream, or creates a named stream on an existing file. Use that granted
access for sharing checks while keeping the requested access on the
returned handle.
The Time Machine AFP_AfpInfo synthesis keeps its requested access.
ksmbd implements FILE_SUPERSEDE by truncating the file, so count it as
a write.
This also prevents an overwrite from truncating a file while another
open that holds data, execute or delete access does not share writing.
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Ian Bridges <icb@fastmail.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/server/smb2pdu.c | 30 ++++++++++++++++++++++--------
fs/smb/server/smb_common.c | 34 +++++++++++++++++++++++++++++++++-
fs/smb/server/smb_common.h | 5 +++++
fs/smb/server/vfs_cache.h | 2 ++
4 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index d6359702faa3e..c8e87c7c8bc21 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3537,7 +3537,8 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
static noinline int smb2_set_stream_name_xattr(const struct path *path,
struct ksmbd_file *fp,
- char *stream_name, int s_type)
+ char *stream_name, int s_type,
+ bool *created)
{
struct mnt_idmap *idmap = mnt_idmap(path->mnt);
size_t xattr_stream_size;
@@ -3601,6 +3602,8 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name, NULL, 0, 0, false);
if (rc < 0)
pr_err("Failed to store XATTR stream name :%d\n", rc);
+ else
+ *created = true;
return 0;
}
@@ -4419,6 +4422,7 @@ int smb2_open(struct ksmbd_work *work)
char *stream_name = NULL;
bool file_present = false, created = false, already_permitted = false;
bool app_instance_id_checked = false, app_instance_closed;
+ bool stream_created = false;
int share_ret, need_truncate = 0;
u64 time, alloc_size = 0;
umode_t posix_mode = 0;
@@ -5174,7 +5178,8 @@ int smb2_open(struct ksmbd_work *work)
rc = smb2_set_stream_name_xattr(&path,
fp,
stream_name,
- s_type);
+ s_type,
+ &stream_created);
if (rc)
goto err_out;
file_info = FILE_CREATED;
@@ -5182,12 +5187,24 @@ int smb2_open(struct ksmbd_work *work)
fp->attrib_only = !(req->DesiredAccess & ~(FILE_READ_ATTRIBUTES_LE |
FILE_WRITE_ATTRIBUTES_LE | FILE_SYNCHRONIZE_LE));
+ need_truncate = !S_ISDIR(file_inode(filp)->i_mode) &&
+ open_flags & O_TRUNC && !fp->attrib_only && !stream_name;
+ /*
+ * Count the FILE_WRITE_DATA that MS-FSA 2.1.5.1.2 grants an overwrite,
+ * supersede included, or a new named stream on an existing file.
+ * An attribute-only open of the file is not truncated, and the
+ * synthesized AFP_AfpInfo stream is not created by the client.
+ */
+ fp->implied_write = need_truncate ||
+ (stream_name &&
+ (open_flags & O_TRUNC ||
+ (file_present && stream_created)));
fp->is_posix_ctxt = posix_ctxt;
/* fp should be searchable through ksmbd_inode.m_fp_list
- * after daccess, saccess, attrib_only, and stream are
- * initialized.
+ * after daccess, saccess, attrib_only, implied_write, and
+ * stream are initialized.
*/
down_write(&fp->f_ci->m_lock);
list_add(&fp->node, &fp->f_ci->m_fp_list);
@@ -5208,11 +5225,8 @@ int smb2_open(struct ksmbd_work *work)
if (file_present || created)
path_put(&path);
- if (!S_ISDIR(file_inode(filp)->i_mode) && open_flags & O_TRUNC &&
- !fp->attrib_only && !stream_name) {
+ if (need_truncate)
smb_break_all_oplock(work, fp);
- need_truncate = 1;
- }
share_ret = ksmbd_smb_check_shared_mode(fp->filp, fp);
if (!test_share_config_flag(work->tcon->share_conf, KSMBD_SHARE_FLAG_OPLOCKS) ||
diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c
index 5ddefb5a7078c..9c962952082fb 100644
--- a/fs/smb/server/smb_common.c
+++ b/fs/smb/server/smb_common.c
@@ -695,10 +695,24 @@ static void smb_shared_mode_error(int error, struct ksmbd_file *prev_fp,
prev_fp->saccess, curr_fp->daccess);
}
+/*
+ * Sharing checks use fp->daccess plus the FILE_WRITE_DATA that MS-FSA
+ * grants an open that overwrites data or creates a named stream.
+ * fp->daccess keeps the open's own access.
+ */
+__le32 ksmbd_sharing_daccess(const struct ksmbd_file *fp)
+{
+ if (fp->implied_write)
+ return fp->daccess | FILE_WRITE_DATA_LE;
+ return fp->daccess;
+}
+
int ksmbd_smb_check_shared_mode(struct file *filp, struct ksmbd_file *curr_fp)
{
int rc = 0;
struct ksmbd_file *prev_fp;
+ __le32 curr_access = ksmbd_sharing_daccess(curr_fp);
+ __le32 access;
/*
* Lookup fp in master fp list, and check desired access and
@@ -719,6 +733,24 @@ int ksmbd_smb_check_shared_mode(struct file *filp, struct ksmbd_file *curr_fp)
if (prev_fp->attrib_only != curr_fp->attrib_only)
continue;
+ /*
+ * MS-FSA checks sharing per stream, so a named stream open's
+ * implied write is not a write against the primary stream.
+ * It still decides whether the pair is checked.
+ */
+ access = curr_access;
+ if (ksmbd_stream_fd(curr_fp) && !ksmbd_stream_fd(prev_fp))
+ access = curr_fp->daccess;
+
+ /*
+ * Two opens conflict only if both hold a right in
+ * FILE_SHARE_CHECKED_ACCESS_LE (MS-FSA 2.1.5.1.2.1 and
+ * 2.1.5.1.2.2)
+ */
+ if (!(ksmbd_sharing_daccess(prev_fp) & FILE_SHARE_CHECKED_ACCESS_LE) ||
+ !(curr_access & FILE_SHARE_CHECKED_ACCESS_LE))
+ continue;
+
if (!(prev_fp->saccess & FILE_SHARE_DELETE_LE) &&
curr_fp->daccess & FILE_DELETE_LE) {
smb_shared_mode_error(SHARE_DELETE_ERROR,
@@ -745,7 +777,7 @@ int ksmbd_smb_check_shared_mode(struct file *filp, struct ksmbd_file *curr_fp)
}
if (!(prev_fp->saccess & FILE_SHARE_WRITE_LE) &&
- curr_fp->daccess & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE)) {
+ access & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE)) {
smb_shared_mode_error(SHARE_WRITE_ERROR,
prev_fp,
curr_fp);
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index 7b9c5cfcb63b0..d481f02b365e8 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -69,6 +69,10 @@
FILE_EXECUTE | FILE_DELETE_CHILD | \
FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
+/* Rights that make an open take part in sharing checks */
+#define FILE_SHARE_CHECKED_ACCESS_LE (FILE_EXECUTE_LE | FILE_READ_DATA_LE | \
+ FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE | FILE_DELETE_LE)
+
#define SMB_COM_NEGOTIATE 0x72 /* See MS-CIFS 2.2.2.1 */
/* See MS-CIFS 2.2.3.1 */
@@ -186,6 +190,7 @@ int ksmbd_extract_shortname(struct ksmbd_conn *conn,
int ksmbd_smb_negotiate_common(struct ksmbd_work *work, unsigned int command);
+__le32 ksmbd_sharing_daccess(const struct ksmbd_file *fp);
int ksmbd_smb_check_shared_mode(struct file *filp, struct ksmbd_file *curr_fp);
int __ksmbd_override_fsids(struct ksmbd_work *work,
struct ksmbd_share_config *share);
diff --git a/fs/smb/server/vfs_cache.h b/fs/smb/server/vfs_cache.h
index 84ca73f483143..c35e4ba8432c0 100644
--- a/fs/smb/server/vfs_cache.h
+++ b/fs/smb/server/vfs_cache.h
@@ -119,6 +119,8 @@ struct ksmbd_file {
bool is_nt_open;
bool attrib_only;
+ /* writes data on open, see ksmbd_sharing_daccess() */
+ bool implied_write;
bool allocation_size_set;
char client_guid[16];
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 029/742] ksmbd: skip metadata-only stream opens in the delete check
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (27 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 028/742] ksmbd: skip metadata-only opens in sharing checks Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 030/742] gpio: mvebu: name regmaps to fix debugfs collisions Greg Kroah-Hartman
` (697 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ian Bridges, Namjae Jeon,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Bridges <icb@fastmail.org>
[ Upstream commit 2f14fe2d589583ce649b2bf1b449cc9839abda8b ]
A metadata-only named-stream open without FILE_SHARE_DELETE blocks a
later DELETE open of the file. It also blocks setting the file delete
pending.
Ignore a stream open unless its effective access includes data, execute
or delete access. Reuse the sharing-access helper so overwriting a
stream, or creating one on an existing file, still counts as
FILE_WRITE_DATA. The Time Machine AFP_AfpInfo synthesis keeps only its
requested access.
Fixes: 19043971c947 ("ksmbd: honor stream delete sharing for base file")
Cc: stable@vger.kernel.org
Signed-off-by: Ian Bridges <icb@fastmail.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/server/vfs_cache.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c
index c6999ed4e6d67..e0b78623d7b62 100644
--- a/fs/smb/server/vfs_cache.c
+++ b/fs/smb/server/vfs_cache.c
@@ -344,7 +344,12 @@ bool ksmbd_has_stream_without_delete_share(struct ksmbd_file *fp)
if (file_inode(fp->filp) != file_inode(prev_fp->filp))
continue;
- if (!(prev_fp->saccess & FILE_SHARE_DELETE_LE)) {
+ /*
+ * A stream open with no right in FILE_SHARE_CHECKED_ACCESS_LE,
+ * implied writes included, never conflicts.
+ */
+ if (!(prev_fp->saccess & FILE_SHARE_DELETE_LE) &&
+ ksmbd_sharing_daccess(prev_fp) & FILE_SHARE_CHECKED_ACCESS_LE) {
ret = true;
break;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 030/742] gpio: mvebu: name regmaps to fix debugfs collisions
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (28 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 029/742] ksmbd: skip metadata-only stream opens in the delete check Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 031/742] gpio: mvebu: fix sleeping-while-atomic in mvebu_gpio_level_irq_mask() Greg Kroah-Hartman
` (696 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Rosen Penev, Linus Walleij,
Bartosz Golaszewski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <rosenp@gmail.com>
[ Upstream commit 4d305c2273123119c27d6e4c822215e650c451e3 ]
Each marvell,armada-370-gpio node provides both 'gpio' and 'pwm'
register windows, and the driver creates one regmap per window on the
same platform device. The shared regmap_config was unnamed, so both
maps defaulted their debugfs directory to dev_name(), e.g.
debugfs: 'f1018100.gpio' already exists in 'regmap'
because the PWM regmap (and on Armada XP the per-CPU regmap) claimed
the same directory as the GPIO regmap.
Give each regmap a distinct .name so the debugfs directories become
'<dev>.gpio', '<dev>.percpu' and '<dev>.pwm'. This only affects
debugfs naming; register access is unchanged.
Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260905004334.177074-1-rosenp@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Stable-dep-of: 42269cdb3d3b ("gpio: mvebu: fix sleeping-while-atomic in mvebu_gpio_level_irq_mask()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpio-mvebu.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index a2796240fe14b..267e6d5bacd0d 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -599,6 +599,21 @@ static void mvebu_gpio_irq_handler(struct irq_desc *desc)
}
static const struct regmap_config mvebu_gpio_regmap_config = {
+ .name = "gpio",
+ .reg_bits = 32,
+ .reg_stride = 4,
+ .val_bits = 32,
+};
+
+static const struct regmap_config mvebu_gpio_percpu_regmap_config = {
+ .name = "percpu",
+ .reg_bits = 32,
+ .reg_stride = 4,
+ .val_bits = 32,
+};
+
+static const struct regmap_config mvebu_pwm_regmap_config = {
+ .name = "pwm",
.reg_bits = 32,
.reg_stride = 4,
.val_bits = 32,
@@ -868,7 +883,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
return PTR_ERR(base);
mvpwm->regs = devm_regmap_init_mmio(&pdev->dev, base,
- &mvebu_gpio_regmap_config);
+ &mvebu_pwm_regmap_config);
if (IS_ERR(mvpwm->regs))
return PTR_ERR(mvpwm->regs);
@@ -1135,7 +1150,7 @@ static int mvebu_gpio_probe_raw(struct platform_device *pdev,
mvchip->percpu_regs =
devm_regmap_init_mmio(&pdev->dev, base,
- &mvebu_gpio_regmap_config);
+ &mvebu_gpio_percpu_regmap_config);
if (IS_ERR(mvchip->percpu_regs))
return PTR_ERR(mvchip->percpu_regs);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 031/742] gpio: mvebu: fix sleeping-while-atomic in mvebu_gpio_level_irq_mask()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (29 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 030/742] gpio: mvebu: name regmaps to fix debugfs collisions Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 032/742] NFSv4: wake blocking lock waiters when a delegated lock is released Greg Kroah-Hartman
` (695 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Linus Walleij, Bartosz Golaszewski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
[ Upstream commit 42269cdb3d3b46ba6e80f31d0e00d0bdcff1d8d4 ]
mvebu_gpio_write_level_mask() is called with a raw spinlock taken but
the underlying regmap uses a standard spinlock which can sleep on
RT_PREEMPT kernels. Add the .use_raw_spinlock attribute to the
appropriate regmap config.
Cc: stable@vger.kernel.org
Fixes: 2233bf7a92e7 ("gpio: mvebu: switch to regmap for register access")
Fixes: 4d305c227312 ("gpio: mvebu: name regmaps to fix debugfs collisions")
Closes: https://sashiko.dev/#/bug/linux-6bee0c4f-384c-494c-868e-07c420195d13
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20261109-gpio-mvebu-sleeping-while-atomic-v2-1-41f070421e70@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpio-mvebu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 267e6d5bacd0d..92ce02441cc99 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -603,6 +603,7 @@ static const struct regmap_config mvebu_gpio_regmap_config = {
.reg_bits = 32,
.reg_stride = 4,
.val_bits = 32,
+ .use_raw_spinlock = true,
};
static const struct regmap_config mvebu_gpio_percpu_regmap_config = {
@@ -610,6 +611,7 @@ static const struct regmap_config mvebu_gpio_percpu_regmap_config = {
.reg_bits = 32,
.reg_stride = 4,
.val_bits = 32,
+ .use_raw_spinlock = true,
};
static const struct regmap_config mvebu_pwm_regmap_config = {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 032/742] NFSv4: wake blocking lock waiters when a delegated lock is released
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (30 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 031/742] gpio: mvebu: fix sleeping-while-atomic in mvebu_gpio_level_irq_mask() Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 033/742] ext4: dont track metadata buffers on an inode during fast commit replay Greg Kroah-Hartman
` (694 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Olga Kornievskaia, Anna Schumaker,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olga Kornievskaia <okorniev@redhat.com>
[ Upstream commit e8433473eca284bc561373d0a0fff632f76aa594 ]
When the client holds a delegation, _nfs4_proc_setlk() caches POSIX
locks locally and never sends a LOCK to the server. It has to strip
FL_SLEEP to do so, since that branch runs holding
sp->so_delegreturn_mutex and nfsi->rwsem and F_SETLKW can block
indefinitely. A contending waiter is therefore never placed on the VFS
blocked-lock list, and locks_wake_up_blocks() does not reach it when the
holder releases.
The waiter blocks in nfs4_retry_setlk() on clp->cl_lock_waitq instead,
whose only waker is nfs4_callback_notify_lock(). The server never saw a
LOCK for a cached lock, so it does not know anyone is waiting and will
never send a CB_NOTIFY_LOCK; nfs4_proc_unlck() returns early without
sending LOCKU for the same reason. The waiter sleeps out the full
NFS4_LOCK_MAXTIMEOUT of 30s before retrying a lock that is long free.
Wake cl_lock_waitq when releasing a cached lock. The releasing thread
cannot tell which waiter wants the lock, so the wakeup names only the
inode; make the owner comparison in nfs4_wake_lock_waiter() conditional
on cbnl_valid so that a CB_NOTIFY_LOCK still wakes exactly the owner it
names. The inode restriction matters: without it every blocked locker
for the server is woken, and those on non-delegated state each retry
with a LOCK RPC.
Fixes: a1d617d8f134 ("nfs: allow blocking locks to be awoken by lock callbacks")
Assisted-by: Claude Opus 5
Signed-off-by: Olga Kornievskaia <okorniev@redhat.com>
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/nfs/nfs4proc.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 2a27d17a86b11..bbf53366455b3 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -7292,8 +7292,15 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
if (status != 0)
goto out;
/* Is this a delegated lock? */
- if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) == 0)
+ if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) == 0) {
+ struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
+ struct cb_notify_lock_args cbnl = { .cbnl_valid = false };
+
+ /* The server never saw it, so it will not notify waiters */
+ nfs_copy_fh(&cbnl.cbnl_fh, NFS_FH(inode));
+ __wake_up(&clp->cl_lock_waitq, TASK_NORMAL, 0, &cbnl);
goto out;
+ }
alloc_seqid = NFS_SERVER(inode)->nfs_client->cl_mvops->alloc_seqid;
seqid = alloc_seqid(&lsp->ls_seqid, GFP_KERNEL);
status = -ENOMEM;
@@ -7713,8 +7720,14 @@ nfs4_wake_lock_waiter(wait_queue_entry_t *wait, unsigned int mode, int flags, vo
struct nfs_lowner *lowner = &cbnl->cbnl_owner,
*wowner = &waiter->owner;
- /* Only wake if the callback was for the same owner. */
- if (lowner->id != wowner->id || lowner->s_dev != wowner->s_dev)
+ /*
+ * Only wake the owner a CB_NOTIFY_LOCK names. A lock cached
+ * under a delegation is released locally, and the releasing
+ * thread cannot tell which waiter wants it, so those wakeups
+ * (cbnl_valid false) name only the inode and wake them all.
+ */
+ if (cbnl->cbnl_valid &&
+ (lowner->id != wowner->id || lowner->s_dev != wowner->s_dev))
return 0;
/* Make sure it's for the right inode */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 033/742] ext4: dont track metadata buffers on an inode during fast commit replay
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (31 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 032/742] NFSv4: wake blocking lock waiters when a delegated lock is released Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 034/742] ACPI: PM: Avoid initializing power management for absent devices Greg Kroah-Hartman
` (693 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Theodore Tso, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <tytso@mit.edu>
[ Upstream commit aceadbccd428fb8e6593b27a3091d961f80225d1 ]
Fast commit replay runs without a journal handle and before
EXT4_SB(sb)->s_journal is set, so it effectively runs in nojournal mode.
__ext4_handle_dirty_metadata() then hands every extent tree block and
directory block it dirties to mmb_mark_buffer_dirty().
Commit d4fdde3257a5 ("fs: set I_METADATA_WRITEBACK in
mmb_mark_buffer_dirty()") sets this flag on the inode, which can
trigger a NULL pointer dereference on a per-cpu pointer during the
fast commit replay. This is because the iput at the end of each fast
commit update triggers write_inode_now(), and with
I_METADATA_WRITEBACK set, writeback_single_inode() will end up calling
ext4_writepages(), before ext4_percpu_param_init() has initialized
s_writepages_rwsem.
A similar crash was fixed in commit 0ecd56573c1f ("ext4: Avoid
entering writeback paths during fastcommit replay") by not setting
this flag in ext4_mark_iloc_dirty(). This commit applies the same fix
to __ext4_handle_dirty_metadata().
Once the fast commit replay is complete, jbd2_journal_recover() syncs
and flushes the whole block device, o the buffer is still written out
before the mount proceeds.
Reproduced with generic/311 using "-O inline_data,fast_commit" (the
ext4/adv test configuration).
Fixes: d4fdde3257a5 ("fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()")
Cc: stable@vger.kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/ext4/ext4_jbd2.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index 53ddedb52a6f7..d81ce9b8a5407 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -412,7 +412,19 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
err);
}
} else {
- if (inode) {
+ /*
+ * Fast commit replay runs without a handle, before the
+ * writeback paths are set up. Don't track the buffer in the
+ * inode's metadata list then: mmb_mark_buffer_dirty() sets
+ * I_METADATA_WRITEBACK, and since the superblock isn't active
+ * yet the iput() ending the replay step writes the inode out
+ * and enters ext4_writepages() before s_writepages_rwsem is
+ * initialized. Journal recovery flushes the whole block
+ * device once replay is done, so the buffer still gets
+ * written.
+ */
+ if (inode && !(EXT4_SB(inode->i_sb)->s_mount_state &
+ EXT4_FC_REPLAY)) {
if (!ext4_i_metadata_bhs(inode))
ext4_inode_attach_mmb(inode);
mmb_mark_buffer_dirty(bh, ext4_i_metadata_bhs(inode));
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 034/742] ACPI: PM: Avoid initializing power management for absent devices
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (32 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 033/742] ext4: dont track metadata buffers on an inode during fast commit replay Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 035/742] Revert "ALSA: hda/realtek: Fix silent speaker on Higole F9B" Greg Kroah-Hartman
` (692 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alan Borzeszkowski,
Rafael J. Wysocki, Mika Westerberg, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ Upstream commit b91ad39f29ceeee3e3d37eedff6b7c912855623c ]
Commit 2f4ddf2bd1ba ("ACPI: scan: Stop calling acpi_bus_init_power()
early") removed a device presence check from acpi_bus_init_power() which
in some cases causes power management to be initialized for an ACPI
device object and never used going forward. That in turn may prevent
power management from working as expected for other devices.
Namely, if a given ACPI device object is not enabled according to its
_STA, find_child_checks() will return an error for it which will prevent
it from being used as an ACPI companion for a PCI device. Thus if
acpi_device_init_power() initializes power management for it and its
initial power state turns out to be different from D3cold, it may stay
in that power state forever. If it has power resources and they are
"on" during the initialization, they may be reference-counted and never
turned off. If they are shared with other devices, they will prevent
power from going down after attempting to put the other devices into
low-power states.
To prevent that from happening, restore the device presence check in
acpi_bus_init_power(), but also adjust find_child_checks() to return
an error for absent devices (instead of doing that for disabled devices)
in accordance with acpi_bus_init_power() and the existing check in
acpi_bus_attach().
Fixes: 2f4ddf2bd1ba ("ACPI: scan: Stop calling acpi_bus_init_power() early")
Reported-by: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
Tested-by: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Link: https://patch.msgid.link/13013440.O9o76ZdvQC@rafael.j.wysocki
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/acpi/device_pm.c | 15 +++++++++++++--
drivers/acpi/glue.c | 8 ++------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 76104f715efa1..d975700936e87 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -365,14 +365,25 @@ int acpi_bus_init_power(struct acpi_device *device)
* fails, ACPI power management will not be used for the device going
* forward.
*/
+ if (!acpi_device_is_present(device)) {
+ acpi_handle_debug(device->handle,
+ "Device not present, ACPI PM disabled\n");
+ result = -ENXIO;
+ goto fail;
+ }
+
result = acpi_device_init_power(device);
if (result) {
- device->flags.power_manageable = 0;
- device->power.state = ACPI_D_STATE_INVALID;
acpi_handle_info(device->handle,
"Initial power state undetermined, ACPI PM disabled\n");
+ goto fail;
}
+ return 0;
+
+fail:
+ device->flags.power_manageable = 0;
+ device->power.state = ACPI_D_STATE_INVALID;
return result;
}
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index e55daa4221da8..9348b98d93d85 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -105,14 +105,10 @@ static bool acpi_dev_has_children(struct acpi_device *adev)
static int find_child_checks(struct acpi_device *adev, bool check_children)
{
- unsigned long long sta;
- acpi_status status;
-
if (check_children && !acpi_dev_has_children(adev))
return -ENODEV;
- status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
- if (status == AE_NOT_FOUND) {
+ if (!acpi_has_method(adev->handle, METHOD_NAME__STA)) {
/*
* Special case: backlight device objects without _STA are
* preferred to other objects with the same _ADR value, because
@@ -124,7 +120,7 @@ static int find_child_checks(struct acpi_device *adev, bool check_children)
return FIND_CHILD_MIN_SCORE;
}
- if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED))
+ if (!acpi_device_is_present(adev))
return -ENODEV;
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 035/742] Revert "ALSA: hda/realtek: Fix silent speaker on Higole F9B"
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (33 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 034/742] ACPI: PM: Avoid initializing power management for absent devices Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 036/742] smb: client: remove commented-out cancel_*_requests() calls Greg Kroah-Hartman
` (691 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Cristian-Marian Fotache,
Takashi Iwai, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <tiwai@suse.de>
[ Upstream commit b9fd2f07df77076f83a58fe7a5640cbcbc5a61ff ]
This reverts commit 2a8ee6897302ca12ff39e8eb180503956797c60c.
We've received a regression report due to this commit, and it turned
out that the PCI SSID for this quirk entry is too generic (10ec:111e)
that may match with several different models.
Usually a workaround would be to apply the quirk for a more unique ID
such as codec SSID, but in this case, unfortunately, the codec SSID is
also 10ec:111e, so BIOS is in a premature state.
For addressing the regression, revert the change for now.
Fixes: 2a8ee6897302 ("ALSA: hda/realtek: Fix silent speaker on Higole F9B")
Reported-by: Cristian-Marian Fotache <cristianmarianfotache@gmail.com>
Closes: https://lore.kernel.org/CACGjpbf73XdwrG34ffjmYU3ZYuStPpFNXf9w+AGYcTmLyHCN_w@mail.gmail.com
Link: https://patch.msgid.link/20261123093436.48511-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/hda/codecs/realtek/alc269.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/sound/hda/codecs/realtek/alc269.c b/sound/hda/codecs/realtek/alc269.c
index c9b75def6732c..95d4db2b62b92 100644
--- a/sound/hda/codecs/realtek/alc269.c
+++ b/sound/hda/codecs/realtek/alc269.c
@@ -8120,7 +8120,6 @@ static const struct hda_quirk alc269_fixup_tbl[] = {
SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN),
SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE),
- SND_PCI_QUIRK(0x10ec, 0x111e, "Higole F9B", ALC290_FIXUP_MONO_SPEAKERS),
SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE),
SND_PCI_QUIRK(0x10ec, 0x119e, "Positivo SU C1400", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
SND_PCI_QUIRK(0x10ec, 0x11bc, "VAIO VJFE-IL", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 036/742] smb: client: remove commented-out cancel_*_requests() calls
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (34 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 035/742] Revert "ALSA: hda/realtek: Fix silent speaker on Higole F9B" Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 037/742] smb: client: dont fail writeback preparation if the task is dying Greg Kroah-Hartman
` (690 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Paulo Alcantara, David Howells,
Namjae Jeon, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey,
Bharath SM, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <pc@manguebit.org>
[ Upstream commit a40b17cc9ecaaa85c3615963ec21cfed1c734340 ]
Drop these leftover commented-out calls.
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Reviewed-by: David Howells <dhowells@redhat.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: Shyam Prasad N <sprasad@microsoft.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Bharath SM <bharathsm@microsoft.com>
Stable-dep-of: 9bd8ee0c1614 ("smb: client: don't replay handle reopens inside SMB2_open()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/client/cifsfs.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index 5a22796f2e957..5518a62549806 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -869,8 +869,6 @@ static void cifs_umount_begin(struct super_block *sb)
spin_unlock(&tcon->tc_lock);
spin_unlock(&cifs_tcp_ses_lock);
- /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
- /* cancel_notify_requests(tcon); */
if (tcon->ses && tcon->ses->server) {
cifs_dbg(FYI, "wake up tasks now - umount begin not complete\n");
wake_up_all(&tcon->ses->server->request_q);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 037/742] smb: client: dont fail writeback preparation if the task is dying
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (35 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 036/742] smb: client: remove commented-out cancel_*_requests() calls Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 038/742] smb: client: retry writeback after losing the connection, share or handle Greg Kroah-Hartman
` (689 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, David Howells, Paulo Alcantara,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <pc@manguebit.org>
[ Upstream commit 29ead886deaa1344a43ab68b1ea305ea2c86c378 ]
cifs_prepare_write() may need to reopen an invalidated handle and to wait
for credits, both from the context of the task doing writeback. A dying
task gets the reopen refused at send time and the killable credit wait
interrupted, so the subrequest is failed and, as with refused sends, its
folios end writeback clean and the data is lost.
For writeback in a dying task, skip both and prepare a credit-less
subrequest capped at SMB2_MAX_BUFFER_SIZE, as already done when the
server is low on credits. It gets issued from cifswritebackd, which
reopens the handle if needed and takes a single credit when sending,
neither of which can be interrupted there. Do the same when the reopen
or credit wait fails because a fatal signal arrived meanwhile.
cifs_begin_writeback() reopens the handle too when all the writable ones
got invalidated, e.g. by a reconnect. If that fails, there is no
upload stream, so netfs ends writeback of every folio clean with no
error recorded. Take an invalidated handle as is there and leave
reopening it to cifs_prepare_write(). If there is no writable handle at
all, record -EIO for the mapping, so that the loss gets reported.
Fixes: 3ee1a1fc3981 ("cifs: Cut over to using netfslib")
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
[ sashal: moved cifs_writeback_dying() above cifs_prepare_write() so the new calls compile, because the earlier backport had left it after that function. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/client/cifsglob.h | 1 +
fs/smb/client/file.c | 49 +++++++++++++++++++++++++++++-----------
2 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 68f56547ef721..c70c214ac7cc6 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1898,6 +1898,7 @@ enum cifs_find_flags {
FIND_NO_PENDING_DELETE = (1U << 2),
FIND_OPEN_FLAGS = (1U << 3),
FIND_NO_DIRECT = (1U << 4),
+ FIND_NO_REOPEN = (1U << 5),
};
#define MID_FREE 0
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 4da53f84196f1..e999d94ac44fb 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -94,6 +94,12 @@ static bool cifs_io_aborted(struct cifs_io_subrequest *subreq)
tcon->need_reconnect;
}
+static bool cifs_writeback_dying(struct netfs_io_subrequest *subreq)
+{
+ return subreq->rreq->origin == NETFS_WRITEBACK &&
+ fatal_signal_pending(current);
+}
+
/*
* Prepare a subrequest to upload to the server. We need to allocate credits
* so that we know the maximum amount of data that we can include in it.
@@ -129,12 +135,17 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
cifs_negotiate_wsize(server, cifs_sb->ctx,
tlink_tcon(req->cfile->tlink));
+ if (cifs_writeback_dying(subreq))
+ goto defer;
+
retry:
if (open_file->invalidHandle) {
rc = cifs_reopen_file(open_file, false);
if (rc < 0) {
if (rc == -EAGAIN)
goto retry;
+ if (cifs_writeback_dying(subreq))
+ goto defer;
subreq->error = rc;
return netfs_prepare_write_failed(subreq);
}
@@ -143,10 +154,17 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
rc = server->ops->wait_mtu_credits(server, wsize, &stream->sreq_max_len,
&wdata->credits);
if (rc < 0) {
+ if (cifs_writeback_dying(subreq))
+ goto defer;
subreq->error = rc;
return netfs_prepare_write_failed(subreq);
}
+ goto out;
+defer:
+ wdata->credits = (struct cifs_credits){};
+ stream->sreq_max_len = min_t(size_t, wsize, SMB2_MAX_BUFFER_SIZE);
+out:
wdata->credits.rreq_debug_id = subreq->rreq->debug_id;
wdata->credits.rreq_debug_index = subreq->debug_index;
wdata->credits.in_flight_check = 1;
@@ -167,12 +185,6 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
#endif
}
-static bool cifs_writeback_dying(struct netfs_io_subrequest *subreq)
-{
- return subreq->rreq->origin == NETFS_WRITEBACK &&
- fatal_signal_pending(current);
-}
-
/*
* Issue a subrequest to upload to the server.
*/
@@ -221,10 +233,15 @@ static void __cifs_issue_write(struct netfs_io_subrequest *subreq)
static void cifs_issue_write_worker(struct work_struct *work)
{
- struct netfs_io_subrequest *subreq;
+ struct cifs_io_subrequest *wdata;
+ struct cifsFileInfo *cfile;
- subreq = container_of(work, struct netfs_io_subrequest, work);
- __cifs_issue_write(subreq);
+ wdata = container_of(work, struct cifs_io_subrequest, subreq.work);
+ cfile = wdata->req->cfile;
+ while (cfile->invalidHandle &&
+ cifs_reopen_file(cfile, false) == -EAGAIN)
+ ;
+ __cifs_issue_write(&wdata->subreq);
}
static void cifs_issue_write(struct netfs_io_subrequest *subreq)
@@ -362,15 +379,17 @@ static void cifs_begin_writeback(struct netfs_io_request *wreq)
struct cifs_io_request *req = container_of(wreq, struct cifs_io_request, rreq);
int ret;
- ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_NO_DIRECT,
+ ret = cifs_get_writable_file(CIFS_I(wreq->inode),
+ FIND_NO_REOPEN | FIND_NO_DIRECT,
&req->cfile);
if (ret) {
- ret = cifs_get_writable_file(CIFS_I(wreq->inode), FIND_ANY,
- &req->cfile);
+ ret = cifs_get_writable_file(CIFS_I(wreq->inode),
+ FIND_NO_REOPEN, &req->cfile);
}
if (ret) {
cifs_dbg(VFS, "%s: couldn't find writable handle: %d\n",
__func__, ret);
+ mapping_set_error(wreq->mapping, -EIO);
return;
}
@@ -2841,7 +2860,7 @@ int __cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
}
if (test_bit(CIFS_INO_TMPFILE, &cifs_inode->flags))
- find_flags &= FIND_NO_DIRECT;
+ find_flags &= FIND_NO_REOPEN | FIND_NO_DIRECT;
cifs_sb = CIFS_SB(cifs_inode);
@@ -2901,6 +2920,10 @@ int __cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
spin_unlock(&cifs_inode->open_file_lock);
if (inv_file) {
+ if (find_flags & FIND_NO_REOPEN) {
+ *ret_file = inv_file;
+ return 0;
+ }
rc = cifs_reopen_file(inv_file, false);
if (!rc) {
*ret_file = inv_file;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 038/742] smb: client: retry writeback after losing the connection, share or handle
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (36 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 037/742] smb: client: dont fail writeback preparation if the task is dying Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 039/742] smb: client: let umount -f stop waiting for reconnects on hard mounts Greg Kroah-Hartman
` (688 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, David Howells, Paulo Alcantara,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <pc@manguebit.org>
[ Upstream commit 59d223256f5912263a1a8d2b5b0c5abf9542cf7d ]
Writeback still fails, dropping its data, when a write gets back an
error that only means the client lost track of the server for a while:
- -EHOSTDOWN from smb2_reconnect() when a soft mount's server stays
unreachable for longer than the reconnect wait, or from
STATUS_HOST_UNREACHABLE,
- -EREMCHG from STATUS_NETWORK_NAME_DELETED, for which the receive path
already marks the tcon for reconnect,
- -EBADF from STATUS_FILE_CLOSED or STATUS_INVALID_HANDLE, e.g. after
the server lost a durable handle,
- -ENETRESET and -ESHUTDOWN from STATUS_CONNECTION_RESET and
STATUS_REMOTE_DISCONNECT,
- any replayable error on SMB1, whose async write never retries them,
while it retries writes cut short by a reconnect forever, regardless
of soft mounts.
Reopening the handle needed by a read or write is worse:
cifs_prepare_write() and cifs_issue_read() retry cifs_reopen_file() only
on -EAGAIN, with no limit and no delay, and fail on anything else. A
server failing the reopen with a status mapped to -EAGAIN, such as
STATUS_INSUFFICIENT_RESOURCES, makes them spin forever, past umount -f
and, when netfs retries from a worker, with no signal to stop them,
while any of the errors above fails writeback right away.
Retry writeback failing with any of these, as already done for
interrupts and allocation failures, with backoff and giving up on umount
-f. On -EBADF, have the retry mark the handle invalid, so that it gets
reopened, unless it got reopened since the write was issued: a late
-EBADF would otherwise get the new handle replaced too, leaving it open
on the server along with any byte-range locks pushed to it. Subrequests
of the same request can fail -EBADF concurrently on different channels,
so record the bad reopen generation atomically (keeping the newest),
decide the invalidation under the handle lock, and have a reopen publish
its new fid before its generation so a -EBADF is attributed to the fid
that was actually sent.
When writeback finally gives up on any of these errors, record -EIO for
it instead, so that fsync(2) and close(2) don't return transient or
internal errors such as -EAGAIN or -ERESTARTSYS.
Retry reopens as the read or write needing them gets retried: as above
for writeback, otherwise per the hard and retrans mount options on
replayable errors, with backoff and giving up on umount -f. If any
channel of the session got reconnected meanwhile, retry once regardless,
as the reconnect may be what failed the reopen; the next attempt waits
for the reconnect to finish. Never retry reopens on interrupts or once
the task is dying, so that dying tasks don't spin there; for writeback,
issue the subrequest without credits instead, as done for dying tasks,
so that it gets retried from the netfs collector, where no signals are
pending.
Don't reopen for requests that predate a umount -f either, unless it is
a first attempt on a connected server, as with issuing them. Once a
reopen for writeback gives up, fail the other subrequests of the
request right away, rather than each waiting out a retry window of its
own.
Reopen handles for reads in prepare, before acquiring credits, as
already done for writes, so that reads don't hold credits across a
reopen. A read whose handle or credits went stale before it could be
sent is retried regardless of mount options, after the backoff, so that
prepare reopens and takes fresh credits; check a write's credits the
same way.
Fixes: 69c3c023af25 ("cifs: Implement netfslib hooks")
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
Stable-dep-of: 9bd8ee0c1614 ("smb: client: don't replay handle reopens inside SMB2_open()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/client/cifsglob.h | 4 +
fs/smb/client/cifssmb.c | 6 +-
fs/smb/client/file.c | 207 ++++++++++++++++++++++++++++++++++-----
3 files changed, 188 insertions(+), 29 deletions(-)
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index c70c214ac7cc6..6193340963845 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1462,6 +1462,7 @@ struct cifsFileInfo {
int count;
spinlock_t file_info_lock; /* protects four flag/count fields above */
struct mutex fh_mutex; /* prevents reopen race after dead ses*/
+ unsigned int reopens;
struct cifs_search_info srch_inf;
struct work_struct oplock_break; /* work for oplock breaks */
struct work_struct put; /* work for the final part of _put */
@@ -1487,6 +1488,8 @@ struct cifs_io_request {
struct cifsFileInfo *cfile;
pid_t pid;
int umount_aborts;
+ bool reopen_gave_up;
+ atomic_t bad_reopens; /* 0 or bad gen + 1 */
};
/* asynchronous read support */
@@ -1501,6 +1504,7 @@ struct cifs_io_subrequest {
int result;
bool have_xid;
bool replay;
+ unsigned int reopens;
unsigned int retries; /* number of retries so far */
unsigned int cur_sleep; /* time to sleep before replay */
unsigned long retry_deadline;
diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c
index 8283a7ac44c00..ae81d00fddd9d 100644
--- a/fs/smb/client/cifssmb.c
+++ b/fs/smb/client/cifssmb.c
@@ -1949,12 +1949,14 @@ cifs_writev_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid)
break;
case MID_REQUEST_SUBMITTED:
trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_req_submitted);
- __set_bit(NETFS_SREQ_NEED_RETRY, &wdata->subreq.flags);
+ if (wdata->rreq->origin != NETFS_WRITEBACK)
+ __set_bit(NETFS_SREQ_NEED_RETRY, &wdata->subreq.flags);
result = -EAGAIN;
break;
case MID_RETRY_NEEDED:
trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_retry_needed);
- __set_bit(NETFS_SREQ_NEED_RETRY, &wdata->subreq.flags);
+ if (wdata->rreq->origin != NETFS_WRITEBACK)
+ __set_bit(NETFS_SREQ_NEED_RETRY, &wdata->subreq.flags);
result = -EAGAIN;
break;
case MID_RESPONSE_MALFORMED:
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index e999d94ac44fb..2f073088f5700 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -94,12 +94,135 @@ static bool cifs_io_aborted(struct cifs_io_subrequest *subreq)
tcon->need_reconnect;
}
+static bool cifs_writeback_transient(int rc)
+{
+ if (is_replayable_error(rc) || is_interrupt_error(rc))
+ return true;
+
+ switch (rc) {
+ case -ENOMEM:
+ case -EHOSTDOWN:
+ case -ENETRESET:
+ case -ESHUTDOWN:
+ case -EREMCHG:
+ case -EBADF:
+ return true;
+ }
+ return false;
+}
+
+static int cifs_writeback_error(struct netfs_io_subrequest *subreq, int rc)
+{
+ if (subreq->rreq->origin == NETFS_WRITEBACK &&
+ cifs_writeback_transient(rc))
+ return -EIO;
+ return rc;
+}
+
static bool cifs_writeback_dying(struct netfs_io_subrequest *subreq)
{
return subreq->rreq->origin == NETFS_WRITEBACK &&
fatal_signal_pending(current);
}
+static unsigned int cifs_ses_reconnects(struct cifs_ses *ses)
+{
+ unsigned int n = 0;
+
+ guard(spinlock)(&ses->chan_lock);
+ for (size_t i = 0; i < ses->chan_count; i++) {
+ struct TCP_Server_Info *server = ses->chans[i].server;
+
+ if (server)
+ n += READ_ONCE(server->reconnect_instance);
+ }
+ return n;
+}
+
+static bool cifs_tcon_reconnecting(struct cifs_tcon *tcon)
+{
+ struct cifs_ses *ses = tcon->ses;
+
+ if (tcon->need_reconnect)
+ return true;
+
+ guard(spinlock)(&ses->chan_lock);
+ for (size_t i = 0; i < ses->chan_count; i++) {
+ struct TCP_Server_Info *server = ses->chans[i].server;
+
+ if (server && READ_ONCE(server->tcpStatus) == CifsNeedReconnect)
+ return true;
+ }
+ return false;
+}
+
+static int cifs_reopen_file_retry(struct cifsFileInfo *cfile, bool can_flush,
+ struct cifs_io_subrequest *subreq)
+{
+ bool writeback = subreq->rreq->origin == NETFS_WRITEBACK;
+ struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
+ struct cifs_ses *ses = tcon->ses;
+ unsigned int reconnects;
+ bool free_retry = true;
+ bool retrying = false;
+ int rc;
+
+ if (writeback && READ_ONCE(subreq->req->reopen_gave_up))
+ return -EIO;
+
+ for (;;) {
+ if ((retrying && cifs_io_stopped(subreq)) ||
+ cifs_io_aborted(subreq))
+ return -EIO;
+ retrying = true;
+ reconnects = cifs_ses_reconnects(ses);
+ rc = cifs_reopen_file(cfile, can_flush);
+ if (!rc || is_interrupt_error(rc) ||
+ cifs_writeback_dying(&subreq->subreq))
+ return rc;
+ if (!is_replayable_error(rc) &&
+ !(writeback && cifs_writeback_transient(rc)))
+ return rc;
+ if (free_retry && !cifs_io_stopped(subreq) &&
+ (cifs_ses_reconnects(ses) != reconnects ||
+ cifs_tcon_reconnecting(tcon))) {
+ free_retry = false;
+ continue;
+ }
+ if (!cifs_io_should_replay(subreq)) {
+ if (writeback)
+ WRITE_ONCE(subreq->req->reopen_gave_up, true);
+ return rc;
+ }
+ msleep(subreq->cur_sleep);
+ }
+}
+
+/*
+ * Record, as generation + 1 (0 means none), the newest reopen generation of a
+ * handle that a writeback subrequest found bad (-EBADF). Subrequests of the
+ * same request can fail concurrently on different channels, so keep the newest.
+ */
+static void cifs_mark_bad_handle(struct cifs_io_request *req, unsigned int gen)
+{
+ int cur = atomic_read(&req->bad_reopens);
+ int want = gen + 1;
+
+ while (want > cur && !atomic_try_cmpxchg(&req->bad_reopens, &cur, want))
+ ;
+}
+
+static void cifs_invalidate_bad_handle(struct cifs_io_request *req)
+{
+ struct cifsFileInfo *cfile = req->cfile;
+ unsigned int bad;
+
+ guard(mutex)(&cfile->fh_mutex);
+ bad = atomic_read(&req->bad_reopens);
+ if (bad && bad - 1 == cfile->reopens)
+ cfile->invalidHandle = true;
+}
+
/*
* Prepare a subrequest to upload to the server. We need to allocate credits
* so that we know the maximum amount of data that we can include in it.
@@ -138,15 +261,16 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
if (cifs_writeback_dying(subreq))
goto defer;
-retry:
+ cifs_invalidate_bad_handle(req);
+
if (open_file->invalidHandle) {
- rc = cifs_reopen_file(open_file, false);
+ rc = cifs_reopen_file_retry(open_file, false, wdata);
if (rc < 0) {
- if (rc == -EAGAIN)
- goto retry;
- if (cifs_writeback_dying(subreq))
+ if (subreq->rreq->origin == NETFS_WRITEBACK &&
+ (is_interrupt_error(rc) ||
+ fatal_signal_pending(current)))
goto defer;
- subreq->error = rc;
+ subreq->error = cifs_writeback_error(subreq, rc);
return netfs_prepare_write_failed(subreq);
}
}
@@ -156,7 +280,7 @@ static void cifs_prepare_write(struct netfs_io_subrequest *subreq)
if (rc < 0) {
if (cifs_writeback_dying(subreq))
goto defer;
- subreq->error = rc;
+ subreq->error = cifs_writeback_error(subreq, rc);
return netfs_prepare_write_failed(subreq);
}
goto out;
@@ -208,13 +332,18 @@ static void __cifs_issue_write(struct netfs_io_subrequest *subreq)
if (rc)
goto fail;
- rc = -EAGAIN;
- if (wdata->req->cfile->invalidHandle)
- goto fail;
-
if (wdata->replay && wdata->cur_sleep)
msleep(wdata->cur_sleep);
+ rc = -EAGAIN;
+ if (wdata->req->cfile->invalidHandle ||
+ (wdata->credits.value &&
+ wdata->credits.instance !=
+ READ_ONCE(wdata->server->reconnect_instance)))
+ goto fail;
+
+ /* pairs with smp_store_release() in cifs_reopen_file() */
+ wdata->reopens = smp_load_acquire(&wdata->req->cfile->reopens);
wdata->server->ops->async_writev(wdata);
out:
return;
@@ -235,12 +364,19 @@ static void cifs_issue_write_worker(struct work_struct *work)
{
struct cifs_io_subrequest *wdata;
struct cifsFileInfo *cfile;
+ int rc = 0;
wdata = container_of(work, struct cifs_io_subrequest, subreq.work);
cfile = wdata->req->cfile;
- while (cfile->invalidHandle &&
- cifs_reopen_file(cfile, false) == -EAGAIN)
- ;
+ cifs_invalidate_bad_handle(wdata->req);
+ if (cfile->invalidHandle)
+ rc = cifs_reopen_file_retry(cfile, false, wdata);
+ if (rc) {
+ add_credits_and_wake_if(wdata->server, &wdata->credits, 0);
+ cifs_write_subrequest_terminated(wdata,
+ cifs_writeback_error(&wdata->subreq, rc));
+ return;
+ }
__cifs_issue_write(&wdata->subreq);
}
@@ -289,6 +425,12 @@ static int cifs_prepare_read(struct netfs_io_subrequest *subreq)
cifs_negotiate_rsize(server, cifs_sb->ctx,
tlink_tcon(req->cfile->tlink));
+ if (req->cfile->invalidHandle) {
+ rc = cifs_reopen_file_retry(req->cfile, true, rdata);
+ if (rc)
+ return rc;
+ }
+
rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
&size, &rdata->credits);
if (rc)
@@ -341,29 +483,32 @@ static void cifs_issue_read(struct netfs_io_subrequest *subreq)
rc = adjust_credits(server, rdata, cifs_trace_rw_credits_issue_read_adjust);
if (rc)
- goto failed;
+ goto not_sent;
- if (req->cfile->invalidHandle) {
- do {
- rc = cifs_reopen_file(req->cfile, true);
- } while (rc == -EAGAIN);
- if (rc)
- goto failed;
- }
+ if (rdata->replay && rdata->cur_sleep)
+ msleep(rdata->cur_sleep);
+
+ rc = -EAGAIN;
+ if (req->cfile->invalidHandle ||
+ (rdata->credits.value &&
+ rdata->credits.instance != READ_ONCE(server->reconnect_instance)))
+ goto not_sent;
if (subreq->rreq->origin != NETFS_UNBUFFERED_READ &&
subreq->rreq->origin != NETFS_DIO_READ)
__set_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags);
- if (rdata->replay && rdata->cur_sleep)
- msleep(rdata->cur_sleep);
-
trace_netfs_sreq(subreq, netfs_sreq_trace_submit);
rc = rdata->server->ops->async_readv(rdata);
if (rc)
goto failed;
return;
+not_sent:
+ if (rc == -EAGAIN) {
+ trace_netfs_sreq(subreq, netfs_sreq_trace_retry);
+ __set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags);
+ }
failed:
add_credits_and_wake_if(rdata->server, &rdata->credits, 0);
subreq->error = rc;
@@ -1541,6 +1686,8 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
reopen_success:
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
+ /* pairs with smp_load_acquire() in __cifs_issue_write() */
+ smp_store_release(&cfile->reopens, cfile->reopens + 1);
cfile->invalidHandle = false;
mutex_unlock(&cfile->fh_mutex);
cinode = CIFS_I(inode);
@@ -2759,14 +2906,20 @@ void cifs_write_subrequest_terminated(struct cifs_io_subrequest *wdata, ssize_t
spin_unlock(&inode->i_lock);
}
- if ((is_interrupt_error(result) || result == -ENOMEM) &&
- wreq->origin == NETFS_WRITEBACK && cifs_io_should_replay(wdata)) {
+ if (wreq->origin == NETFS_WRITEBACK &&
+ !test_bit(NETFS_SREQ_NEED_RETRY, &wdata->subreq.flags) &&
+ cifs_writeback_transient(result) && cifs_io_should_replay(wdata)) {
+ if (result == -EBADF)
+ cifs_mark_bad_handle(wdata->req, wdata->reopens);
wdata->replay = true;
trace_netfs_sreq(&wdata->subreq,
netfs_sreq_trace_io_retry_needed);
__set_bit(NETFS_SREQ_NEED_RETRY, &wdata->subreq.flags);
}
+ if (result < 0 &&
+ !test_bit(NETFS_SREQ_NEED_RETRY, &wdata->subreq.flags))
+ result = cifs_writeback_error(&wdata->subreq, result);
netfs_write_subrequest_terminated(&wdata->subreq, result);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 039/742] smb: client: let umount -f stop waiting for reconnects on hard mounts
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (37 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 038/742] smb: client: retry writeback after losing the connection, share or handle Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 040/742] smb: client: dont replay handle reopens inside SMB2_open() Greg Kroah-Hartman
` (687 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Paulo Alcantara, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <pc@manguebit.org>
[ Upstream commit f8ea398448ce4adf32493649ab6665ab1f858d10 ]
Requests waiting in smb2_reconnect() or cifs_reconnect_tcon() for a
reconnect wait for as long as it takes on hard mounts. With the server
gone, writeback stuck there keeps umount -f hanging in sync_filesystem()
while it waits for that writeback, even though retries of reads and
writes started before it now give up.
Count umount -f attempts per tcon and stop waiting for reconnects, as on
soft mounts, once one is made after the request started waiting, waking
up such requests on all channels right away. Do this for the master
tcon and for the per-user tcons of a multiuser mount, skipping tcons
another mount still uses. Count the references mounts hold on a tcon
for that, rather than relying on tc_count, which internal references
such as a reconnect worker also raise: one per tlink in a superblock's
tree, dropped when the tlink leaves it, and decide under the tree lock so
that pruning or building a tlink can't skew it. Have a handle reopen
started before umount -f stop short of a reconnect it would otherwise
wait for afterwards, and have a retried read check for umount -f again
after backing off. Requests started after umount -f are unaffected.
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
Stable-dep-of: 9bd8ee0c1614 ("smb: client: don't replay handle reopens inside SMB2_open()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/client/cifsfs.c | 115 ++++++++++++++++++++++++++++----------
fs/smb/client/cifsglob.h | 8 +++
fs/smb/client/cifsproto.h | 4 +-
fs/smb/client/cifssmb.c | 9 ++-
fs/smb/client/connect.c | 69 +++++++++++++++++++----
fs/smb/client/file.c | 35 ++++++++++--
fs/smb/client/misc.c | 16 +++++-
fs/smb/client/smb2pdu.c | 9 ++-
8 files changed, 211 insertions(+), 54 deletions(-)
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index 5518a62549806..b912717668f4b 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -295,6 +295,64 @@ cifs_read_super(struct super_block *sb)
return rc;
}
+struct cifs_tcon_ref {
+ struct list_head list;
+ struct tcon_link *tlink;
+ struct cifs_tcon *tcon;
+ bool shared;
+};
+
+static bool used_by_other_mounts(struct cifs_tcon *tcon,
+ struct list_head *tcons)
+{
+ struct cifs_tcon_ref *ref;
+ int n = 0;
+
+ list_for_each_entry(ref, tcons, list)
+ n += ref->tcon == tcon;
+
+ guard(spinlock)(&tcon->tc_lock);
+ return tcon->mnt_refs - tcon->mnt_unlinked > n;
+}
+
+static void get_sb_tcons(struct cifs_sb_info *cifs_sb, struct list_head *tcons)
+{
+ struct rb_root *root = &cifs_sb->tlink_tree;
+ struct cifs_tcon_ref *ref;
+ struct tcon_link *tlink;
+ struct cifs_tcon *tcon;
+ struct rb_node *node;
+
+ guard(spinlock)(&cifs_sb->tlink_tree_lock);
+ for (node = rb_first(root); node; node = rb_next(node)) {
+ tlink = rb_entry(node, struct tcon_link, tl_rbnode);
+ tcon = tlink_tcon(tlink);
+ if (IS_ERR_OR_NULL(tcon))
+ continue;
+
+ ref = kmalloc_obj(struct cifs_tcon_ref, GFP_ATOMIC);
+ if (!ref)
+ break;
+
+ ref->tlink = cifs_get_tlink(tlink);
+ ref->tcon = tcon;
+ list_add_tail(&ref->list, tcons);
+ }
+ list_for_each_entry(ref, tcons, list)
+ ref->shared = used_by_other_mounts(ref->tcon, tcons);
+}
+
+static void put_sb_tcons(struct list_head *tcons)
+{
+ struct cifs_tcon_ref *ref, *tmp;
+
+ list_for_each_entry_safe(ref, tmp, tcons, list) {
+ cifs_put_tlink(ref->tlink);
+ list_del(&ref->list);
+ kfree(ref);
+ }
+}
+
static void cifs_kill_sb(struct super_block *sb)
{
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
@@ -839,47 +897,46 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
return 0;
}
+static void abort_reconnect(struct cifs_tcon *tcon)
+{
+ scoped_guard(spinlock, &tcon->tc_lock)
+ trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
+ netfs_trace_tcon_ref_see_umount);
+
+ atomic_inc(&tcon->umount_aborts);
+ if (tcon->ses && tcon->ses->server) {
+ cifs_dbg(FYI, "wake up tasks now - umount begin not complete\n");
+ cifs_wake_ses_waiters(tcon->ses);
+ msleep(1); /* yield */
+ /* we have to kick the requests once more */
+ cifs_wake_ses_waiters(tcon->ses);
+ msleep(1);
+ }
+}
+
static void cifs_umount_begin(struct super_block *sb)
{
struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
- struct cifs_tcon *tcon;
+ struct cifs_tcon_ref *ref;
+ LIST_HEAD(tcons);
if (cifs_sb == NULL)
return;
atomic_inc(&cifs_sb->umount_aborts);
- tcon = cifs_sb_master_tcon(cifs_sb);
- spin_lock(&cifs_tcp_ses_lock);
- spin_lock(&tcon->tc_lock);
- trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
- netfs_trace_tcon_ref_see_umount);
- if ((tcon->tc_count > 1) || (tcon->status == TID_EXITING)) {
- /* we have other mounts to same share or we have
- already tried to umount this and woken up
- all waiting network requests, nothing to do */
- spin_unlock(&tcon->tc_lock);
- spin_unlock(&cifs_tcp_ses_lock);
- return;
- }
/*
- * can not set tcon->status to TID_EXITING yet since we don't know if umount -f will
- * fail later (e.g. due to open files). TID_EXITING will be set just before tdis req sent
+ * Abort the reconnect waits of the master tcon and of any per-user
+ * tcons of a multiuser mount that no other mount uses, pinning their
+ * tlinks so that they stay alive, and aren't pruned, while we abort and
+ * sleep outside the tree lock.
*/
- spin_unlock(&tcon->tc_lock);
- spin_unlock(&cifs_tcp_ses_lock);
-
- if (tcon->ses && tcon->ses->server) {
- cifs_dbg(FYI, "wake up tasks now - umount begin not complete\n");
- wake_up_all(&tcon->ses->server->request_q);
- wake_up_all(&tcon->ses->server->response_q);
- msleep(1); /* yield */
- /* we have to kick the requests once more */
- wake_up_all(&tcon->ses->server->response_q);
- msleep(1);
+ get_sb_tcons(cifs_sb, &tcons);
+ list_for_each_entry(ref, &tcons, list) {
+ if (!ref->shared)
+ abort_reconnect(ref->tcon);
}
-
- return;
+ put_sb_tcons(&tcons);
}
static int cifs_freeze(struct super_block *sb)
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 6193340963845..219f991fe435a 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1199,6 +1199,9 @@ struct cifs_tcon {
struct list_head tcon_list;
int debug_id; /* Debugging for tracing */
int tc_count;
+ int mnt_refs; /* refs held by mounts, under tc_lock */
+ int mnt_unlinked; /* mnt_refs of tlinks being built */
+ atomic_t umount_aborts; /* nr of umount -f attempts */
struct list_head rlist; /* reconnect list */
spinlock_t tc_lock; /* protect anything here that is not protected */
atomic_t num_local_opens; /* num of all opens including disconnected */
@@ -2386,6 +2389,11 @@ static inline void cifs_reset_oplock(struct cifsInodeInfo *cinode)
WRITE_ONCE(cinode->oplock, 0);
}
+static inline bool cifs_tcon_retry(struct cifs_tcon *tcon, int aborts)
+{
+ return tcon->retry && atomic_read(&tcon->umount_aborts) == aborts;
+}
+
static inline bool cifs_forced_shutdown(const struct cifs_sb_info *sbi)
{
return cifs_sb_flags(sbi) & CIFS_MOUNT_SHUTDOWN;
diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
index 5b41af529955f..515ca0698d4ab 100644
--- a/fs/smb/client/cifsproto.h
+++ b/fs/smb/client/cifsproto.h
@@ -440,7 +440,9 @@ static inline int cifs_create_options(struct cifs_sb_info *cifs_sb, int options)
return options;
}
-int cifs_wait_for_server_reconnect(struct TCP_Server_Info *server, bool retry);
+void cifs_wake_ses_waiters(struct cifs_ses *ses);
+int cifs_wait_for_server_reconnect(struct TCP_Server_Info *server,
+ struct cifs_tcon *tcon, int aborts);
static inline void cifs_put_smb_ses(struct cifs_ses *ses)
{
diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c
index ae81d00fddd9d..ff9bf20088b12 100644
--- a/fs/smb/client/cifssmb.c
+++ b/fs/smb/client/cifssmb.c
@@ -73,6 +73,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
{
struct TCP_Server_Info *server;
struct cifs_ses *ses;
+ int aborts;
int rc;
/*
@@ -83,6 +84,8 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
if (!tcon)
return 0;
+ aborts = atomic_read(&tcon->umount_aborts);
+
ses = tcon->ses;
server = ses->server;
@@ -102,7 +105,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
spin_unlock(&tcon->tc_lock);
again:
- rc = cifs_wait_for_server_reconnect(server, tcon->retry);
+ rc = cifs_wait_for_server_reconnect(server, tcon, aborts);
if (rc)
return rc;
@@ -127,7 +130,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
case CifsNeedReconnect:
spin_unlock(&server->srv_lock);
mutex_unlock(&ses->session_mutex);
- if (!tcon->retry)
+ if (!cifs_tcon_retry(tcon, aborts))
return -EHOSTDOWN;
goto again;
default:
@@ -159,7 +162,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
rc = cifs_negotiate_protocol(0, ses, server);
if (rc) {
mutex_unlock(&ses->session_mutex);
- if (!tcon->retry)
+ if (!cifs_tcon_retry(tcon, aborts))
return -EHOSTDOWN;
goto again;
}
diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index 1878a880e1662..9c41515044473 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -2591,7 +2591,8 @@ static int match_tcon(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
}
static struct cifs_tcon *
-cifs_find_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
+cifs_find_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx,
+ bool unlinked)
{
struct cifs_tcon *tcon;
@@ -2603,6 +2604,8 @@ cifs_find_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
continue;
}
++tcon->tc_count;
+ ++tcon->mnt_refs;
+ tcon->mnt_unlinked += unlinked;
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
netfs_trace_tcon_ref_get_find);
spin_unlock(&tcon->tc_lock);
@@ -2676,10 +2679,44 @@ cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace)
#endif
}
+void cifs_wake_ses_waiters(struct cifs_ses *ses)
+{
+ guard(spinlock)(&ses->chan_lock);
+ for (size_t i = 0; i < ses->chan_count; i++) {
+ struct TCP_Server_Info *server = ses->chans[i].server;
+
+ if (!server)
+ continue;
+ wake_up_all(&server->request_q);
+ wake_up_all(&server->response_q);
+ }
+}
+
+static void drop_mnt_ref(struct cifs_tcon *tcon)
+{
+ guard(spinlock)(&tcon->tc_lock);
+ tcon->mnt_refs--;
+}
+
+static void put_mnt_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace)
+{
+ drop_mnt_ref(tcon);
+ cifs_put_tcon(tcon, trace);
+}
+
+static void erase_tlink(struct cifs_sb_info *cifs_sb, struct tcon_link *tlink)
+{
+ clear_bit(TCON_LINK_IN_TREE, &tlink->tl_flags);
+ rb_erase(&tlink->tl_rbnode, &cifs_sb->tlink_tree);
+ if (!IS_ERR(tlink_tcon(tlink)))
+ drop_mnt_ref(tlink_tcon(tlink));
+}
+
/**
* cifs_get_tcon - get a tcon matching @ctx data from @ses
* @ses: smb session to issue the request on
* @ctx: the superblock configuration context to use for building the
+ * @unlinked: the mount reference is for a tlink not yet in a superblock's tree
*
* - tcon refcount is the number of mount points using the tcon.
* - ses refcount is the number of tcon using the session.
@@ -2699,13 +2736,13 @@ cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace)
* decrement the ses refcount.
*/
static struct cifs_tcon *
-cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
+cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx, bool unlinked)
{
struct cifs_tcon *tcon;
bool nohandlecache;
int rc, xid;
- tcon = cifs_find_tcon(ses, ctx);
+ tcon = cifs_find_tcon(ses, ctx, unlinked);
if (tcon) {
/*
* tcon has refcount already incremented but we need to
@@ -2731,6 +2768,8 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
rc = -ENOMEM;
goto out_fail;
}
+ tcon->mnt_refs = 1;
+ tcon->mnt_unlinked = unlinked;
tcon->nohandlecache = nohandlecache;
if (ctx->snapshot_time) {
@@ -3558,7 +3597,7 @@ void cifs_mount_put_conns(struct cifs_mount_ctx *mnt_ctx)
int rc = 0;
if (mnt_ctx->tcon)
- cifs_put_tcon(mnt_ctx->tcon, netfs_trace_tcon_ref_put_mnt_ctx);
+ put_mnt_tcon(mnt_ctx->tcon, netfs_trace_tcon_ref_put_mnt_ctx);
else if (mnt_ctx->ses)
cifs_put_smb_ses(mnt_ctx->ses);
else if (mnt_ctx->server)
@@ -3638,7 +3677,7 @@ int cifs_mount_get_tcon(struct cifs_mount_ctx *mnt_ctx)
cifs_sb = mnt_ctx->cifs_sb;
/* search for existing tcon to this server share */
- tcon = cifs_get_tcon(mnt_ctx->ses, ctx);
+ tcon = cifs_get_tcon(mnt_ctx->ses, ctx, false);
if (IS_ERR(tcon)) {
rc = PTR_ERR(tcon);
tcon = NULL;
@@ -4014,8 +4053,7 @@ cifs_umount(struct cifs_sb_info *cifs_sb)
while ((node = rb_first(root))) {
tlink = rb_entry(node, struct tcon_link, tl_rbnode);
cifs_get_tlink(tlink);
- clear_bit(TCON_LINK_IN_TREE, &tlink->tl_flags);
- rb_erase(node, root);
+ erase_tlink(cifs_sb, tlink);
spin_unlock(&cifs_sb->tlink_tree_lock);
cifs_put_tlink(tlink);
@@ -4305,7 +4343,7 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
}
#endif
- tcon = cifs_get_tcon(ses, ctx);
+ tcon = cifs_get_tcon(ses, ctx, true);
if (IS_ERR(tcon)) {
cifs_put_smb_ses(ses);
goto out;
@@ -4408,6 +4446,7 @@ cifs_sb_tlink(struct cifs_sb_info *cifs_sb)
{
struct tcon_link *tlink, *newtlink;
kuid_t fsuid = current_fsuid();
+ struct cifs_tcon *tcon;
int err;
if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_MULTIUSER))
@@ -4465,7 +4504,16 @@ cifs_sb_tlink(struct cifs_sb_info *cifs_sb)
goto wait_for_construction;
}
- tlink->tl_tcon = cifs_construct_tcon(cifs_sb, fsuid);
+ tcon = cifs_construct_tcon(cifs_sb, fsuid);
+ scoped_guard(spinlock, &cifs_sb->tlink_tree_lock) {
+ tlink->tl_tcon = tcon;
+ if (!IS_ERR(tcon)) {
+ scoped_guard(spinlock, &tcon->tc_lock)
+ tcon->mnt_unlinked--;
+ if (!test_bit(TCON_LINK_IN_TREE, &tlink->tl_flags))
+ drop_mnt_ref(tcon);
+ }
+ }
clear_bit(TCON_LINK_PENDING, &tlink->tl_flags);
wake_up_bit(&tlink->tl_flags, TCON_LINK_PENDING);
@@ -4514,8 +4562,7 @@ cifs_prune_tlinks(struct work_struct *work)
continue;
cifs_get_tlink(tlink);
- clear_bit(TCON_LINK_IN_TREE, &tlink->tl_flags);
- rb_erase(tmp, root);
+ erase_tlink(cifs_sb, tlink);
spin_unlock(&cifs_sb->tlink_tree_lock);
cifs_put_tlink(tlink);
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 2f073088f5700..ac2fd53e27f2e 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -485,8 +485,12 @@ static void cifs_issue_read(struct netfs_io_subrequest *subreq)
if (rc)
goto not_sent;
- if (rdata->replay && rdata->cur_sleep)
+ if (rdata->replay && rdata->cur_sleep) {
msleep(rdata->cur_sleep);
+ rc = -EIO;
+ if (cifs_io_aborted(rdata))
+ goto failed;
+ }
rc = -EAGAIN;
if (req->cfile->invalidHandle ||
@@ -1549,6 +1553,16 @@ cifs_relock_file(struct cifsFileInfo *cfile)
return rc;
}
+static bool reopen_aborted(struct cifs_tcon *tcon, int aborts)
+{
+ struct TCP_Server_Info *server;
+
+ if (atomic_read(&tcon->umount_aborts) == aborts)
+ return false;
+ server = cifs_pick_channel(tcon->ses);
+ return server && READ_ONCE(server->tcpStatus) == CifsNeedReconnect;
+}
+
static int
cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
{
@@ -1567,7 +1581,10 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
int create_options = CREATE_NOT_DIR;
struct cifs_open_parms oparms;
int rdwr_for_fscache = 0;
+ int aborts;
+ tcon = tlink_tcon(cfile->tlink);
+ aborts = atomic_read(&tcon->umount_aborts);
xid = get_xid();
mutex_lock(&cfile->fh_mutex);
if (!cfile->invalidHandle) {
@@ -1575,10 +1592,14 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
free_xid(xid);
return 0;
}
+ if (reopen_aborted(tcon, aborts)) {
+ mutex_unlock(&cfile->fh_mutex);
+ free_xid(xid);
+ return -EHOSTDOWN;
+ }
inode = d_inode(cfile->dentry);
cifs_sb = CIFS_SB(inode->i_sb);
- tcon = tlink_tcon(cfile->tlink);
server = tcon->ses->server;
/*
@@ -1660,10 +1681,16 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
* version of file size can be stale. If we knew for sure that inode was
* not dirty locally we could do this.
*/
- rc = server->ops->open(xid, &oparms, &oplock, NULL);
+ if (reopen_aborted(tcon, aborts))
+ rc = -EHOSTDOWN;
+ else
+ rc = server->ops->open(xid, &oparms, &oplock, NULL);
if (rc == -ENOENT && oparms.reconnect == false) {
/* durable handle timeout is expired - open the file again */
- rc = server->ops->open(xid, &oparms, &oplock, NULL);
+ if (reopen_aborted(tcon, aborts))
+ rc = -EHOSTDOWN;
+ else
+ rc = server->ops->open(xid, &oparms, &oplock, NULL);
/* indicate that we need to relock the file */
oparms.reconnect = true;
}
diff --git a/fs/smb/client/misc.c b/fs/smb/client/misc.c
index 05168284f2051..71a233adade31 100644
--- a/fs/smb/client/misc.c
+++ b/fs/smb/client/misc.c
@@ -1075,7 +1075,15 @@ int cifs_inval_name_dfs_link_error(const unsigned int xid,
}
#endif
-int cifs_wait_for_server_reconnect(struct TCP_Server_Info *server, bool retry)
+static bool reco_wait_done(struct TCP_Server_Info *server,
+ struct cifs_tcon *tcon, int aborts)
+{
+ return server->tcpStatus != CifsNeedReconnect ||
+ atomic_read(&tcon->umount_aborts) != aborts;
+}
+
+int cifs_wait_for_server_reconnect(struct TCP_Server_Info *server,
+ struct cifs_tcon *tcon, int aborts)
{
int timeout = 10;
int rc;
@@ -1098,7 +1106,9 @@ int cifs_wait_for_server_reconnect(struct TCP_Server_Info *server, bool retry)
*/
do {
rc = wait_event_interruptible_timeout(server->response_q,
- (server->tcpStatus != CifsNeedReconnect),
+ reco_wait_done(server,
+ tcon,
+ aborts),
timeout * HZ);
if (rc < 0) {
cifs_dbg(FYI, "%s: aborting reconnect due to received signal\n",
@@ -1113,7 +1123,7 @@ int cifs_wait_for_server_reconnect(struct TCP_Server_Info *server, bool retry)
return 0;
}
spin_unlock(&server->srv_lock);
- } while (retry);
+ } while (cifs_tcon_retry(tcon, aborts));
cifs_dbg(FYI, "%s: gave up waiting on reconnect\n", __func__);
return -EHOSTDOWN;
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 3c7e42a47a5ae..679ab668051cb 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -253,6 +253,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
bool hold_server_ref = false;
struct cifs_ses *ses;
int rc = 0;
+ int aborts;
int xid;
/*
@@ -263,6 +264,8 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
if (tcon == NULL)
return 0;
+ aborts = atomic_read(&tcon->umount_aborts);
+
if (smb2_command == SMB2_TREE_CONNECT)
return 0;
@@ -319,7 +322,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
spin_unlock(&server->srv_lock);
again:
- rc = cifs_wait_for_server_reconnect(server, tcon->retry);
+ rc = cifs_wait_for_server_reconnect(server, tcon, aborts);
if (rc)
return rc;
@@ -347,7 +350,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
case CifsNeedReconnect:
spin_unlock(&server->srv_lock);
mutex_unlock(&ses->session_mutex);
- if (!tcon->retry)
+ if (!cifs_tcon_retry(tcon, aborts))
return -EHOSTDOWN;
goto again;
default:
@@ -378,7 +381,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
rc = cifs_negotiate_protocol(0, ses, server);
if (rc) {
mutex_unlock(&ses->session_mutex);
- if (!tcon->retry)
+ if (!cifs_tcon_retry(tcon, aborts))
return -EHOSTDOWN;
goto again;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 040/742] smb: client: dont replay handle reopens inside SMB2_open()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (38 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 039/742] smb: client: let umount -f stop waiting for reconnects on hard mounts Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 041/742] w1: w1_therm: lock the list of slaves for the bulk read Greg Kroah-Hartman
` (686 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Paulo Alcantara, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <pc@manguebit.org>
[ Upstream commit 9bd8ee0c16146a3d0a401b39dc4cb1a84144c956 ]
cifs_reopen_file_retry() reopens a read's or write's handle with backoff,
per the hard and retrans mount options, giving up on umount -f. It calls
cifs_reopen_file() -> SMB2_open(), which replays replayable errors on its
own, also per hard and retrans. So each reopen is retried at both
layers: up to (retrans + 1)^2 opens on a soft mount, and, on a hard
mount, forever inside SMB2_open() without ever returning to
cifs_reopen_file_retry() to notice umount -f - a worker doing writeback
then can't be stopped.
Have cifs_reopen_file_retry() tell SMB2_open() not to replay, so these
reopens are bounded and stopped only by cifs_reopen_file_retry(). Other
callers of cifs_reopen_file() keep SMB2_open()'s replay; SMB1 opens are
unchanged.
A reopen reconnects the durable handle or, if the server lost it, opens
the file afresh. Without SMB2_open()'s loop, a retry must open afresh
again rather than reconnect, which the server would reject, and replay
its last create, with the same GUID and access and keeping its access
fallbacks, if that create may have been processed, or it leaks or loses
a handle. Track both on the open file under fh_mutex, so concurrent
reopens agree: replay only after a create that SMB2_open() built and
that failed with no answer from the server, or only a retryable one to
its replay, and leave the state alone after an attempt that was
interrupted or never built.
SMB2_open()'s own loop retried a failed durable reconnect as a fresh open
with a stale GUID, and smb2_open_file()'s retry without
FILE_READ_ATTRIBUTES as a fresh open, skipping the relock; have both
reissue the same create, only replay a create that was built, and don't
leave SMB2_open()'s own replay state behind for the caller's next create.
Fixes: 69c3c023af25 ("cifs: Implement netfslib hooks")
Fixes: 4f1fffa23769 ("cifs: commands that are retried should have replay flag set")
Fixes: 79520587fe42 ("cifs: update the same create_guid on replay")
Fixes: e255612b5ed9 ("cifs: Add fallback for SMB2 CREATE without FILE_READ_ATTRIBUTES")
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/client/cifsglob.h | 5 +++++
fs/smb/client/file.c | 45 ++++++++++++++++++++++++++++++----------
fs/smb/client/smb2file.c | 18 +++++++++++-----
fs/smb/client/smb2pdu.c | 45 +++++++++++++++++++++++++++++++++-------
4 files changed, 89 insertions(+), 24 deletions(-)
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 219f991fe435a..db0e9fc14fb28 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1414,6 +1414,8 @@ struct cifs_open_parms {
umode_t mode;
bool reconnect:1;
bool replay:1; /* indicates that this open is for a replay */
+ bool no_replay:1; /* don't replay this open internally */
+ bool pending:1; /* in/out: last built create had no answer */
struct kvec *ea_cctx;
__le32 lease_flags;
};
@@ -1466,6 +1468,9 @@ struct cifsFileInfo {
spinlock_t file_info_lock; /* protects four flag/count fields above */
struct mutex fh_mutex; /* prevents reopen race after dead ses*/
unsigned int reopens;
+ bool reopen_fresh; /* durable handle gone: reopen opens afresh */
+ bool reopen_replay; /* reopen replays its last create */
+ int reopen_access; /* desired access of that create */
struct cifs_search_info srch_inf;
struct work_struct oplock_break; /* work for oplock breaks */
struct work_struct put; /* work for the final part of _put */
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index ac2fd53e27f2e..f2ab7618034e8 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -37,7 +37,11 @@
#include "cached_dir.h"
#include <trace/events/netfs.h>
-static int cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush);
+/* flags for cifs_reopen_file() */
+#define CIFS_REOPEN_BOUND BIT(0) /* caller bounds the retries */
+
+static int cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush,
+ unsigned int flags);
bool cifs_io_stopped(struct cifs_io_subrequest *subreq)
{
@@ -176,7 +180,7 @@ static int cifs_reopen_file_retry(struct cifsFileInfo *cfile, bool can_flush,
return -EIO;
retrying = true;
reconnects = cifs_ses_reconnects(ses);
- rc = cifs_reopen_file(cfile, can_flush);
+ rc = cifs_reopen_file(cfile, can_flush, CIFS_REOPEN_BOUND);
if (!rc || is_interrupt_error(rc) ||
cifs_writeback_dying(&subreq->subreq))
return rc;
@@ -1564,7 +1568,7 @@ static bool reopen_aborted(struct cifs_tcon *tcon, int aborts)
}
static int
-cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
+cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush, unsigned int flags)
{
int rc = -EACCES;
unsigned int xid;
@@ -1582,6 +1586,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
struct cifs_open_parms oparms;
int rdwr_for_fscache = 0;
int aborts;
+ bool fresh;
tcon = tlink_tcon(cfile->tlink);
aborts = atomic_read(&tcon->umount_aborts);
@@ -1655,6 +1660,10 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
if (cifs_fscache_enabled(inode) && (cfile->f_flags & O_ACCMODE) == O_WRONLY)
rdwr_for_fscache = 1;
+ if (cfile->reopen_replay && rdwr_for_fscache == 1 &&
+ !(cfile->reopen_access & GENERIC_READ))
+ rdwr_for_fscache = 2;
+
desired_access = cifs_convert_flags(cfile->f_flags, rdwr_for_fscache);
create_options |= cifs_open_create_options(cfile->f_flags,
create_options);
@@ -1663,15 +1672,20 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
server->ops->get_lease_key(inode, &cfile->fid);
retry_open:
+ fresh = cfile->reopen_fresh;
oparms = (struct cifs_open_parms) {
.tcon = tcon,
.cifs_sb = cifs_sb,
- .desired_access = desired_access,
+ .desired_access = cfile->reopen_replay ?
+ cfile->reopen_access : desired_access,
.create_options = cifs_create_options(cifs_sb, create_options),
.disposition = disposition,
.path = full_path,
.fid = &cfile->fid,
- .reconnect = true,
+ .reconnect = !fresh,
+ .replay = cfile->reopen_replay,
+ .pending = cfile->reopen_replay,
+ .no_replay = !!(flags & CIFS_REOPEN_BOUND),
};
/*
@@ -1685,16 +1699,24 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
rc = -EHOSTDOWN;
else
rc = server->ops->open(xid, &oparms, &oplock, NULL);
- if (rc == -ENOENT && oparms.reconnect == false) {
+ if (rc == -ENOENT && !fresh && !oparms.reconnect && !oparms.pending) {
/* durable handle timeout is expired - open the file again */
+ fresh = true;
+ oparms.desired_access = desired_access;
+ oparms.replay = false;
if (reopen_aborted(tcon, aborts))
rc = -EHOSTDOWN;
else
rc = server->ops->open(xid, &oparms, &oplock, NULL);
- /* indicate that we need to relock the file */
- oparms.reconnect = true;
}
- if (rc == -EACCES && rdwr_for_fscache == 1) {
+ cfile->reopen_fresh = rc && fresh;
+ cfile->reopen_replay = rc && oparms.pending;
+ if (cfile->reopen_replay)
+ cfile->reopen_access = oparms.desired_access;
+ /* indicate that we need to relock the file */
+ if (fresh)
+ oparms.reconnect = true;
+ if (rc == -EACCES && rdwr_for_fscache == 1 && !oparms.pending) {
desired_access = cifs_convert_flags(cfile->f_flags, 0);
rdwr_for_fscache = 2;
goto retry_open;
@@ -1874,7 +1896,8 @@ cifs_reopen_persistent_handles(struct cifs_tcon *tcon)
spin_unlock(&tcon->open_file_lock);
list_for_each_entry_safe(open_file, tmp, &tmp_list, rlist) {
- if (cifs_reopen_file(open_file, false /* do not flush */))
+ /* do not flush */
+ if (cifs_reopen_file(open_file, false, 0))
tcon->need_reopen_files = true;
list_del_init(&open_file->rlist);
cifsFileInfo_put(open_file);
@@ -3104,7 +3127,7 @@ int __cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
*ret_file = inv_file;
return 0;
}
- rc = cifs_reopen_file(inv_file, false);
+ rc = cifs_reopen_file(inv_file, false, 0);
if (!rc) {
*ret_file = inv_file;
return 0;
diff --git a/fs/smb/client/smb2file.c b/fs/smb/client/smb2file.c
index fb2fccbe86677..764cfd894ad09 100644
--- a/fs/smb/client/smb2file.c
+++ b/fs/smb/client/smb2file.c
@@ -175,6 +175,7 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
struct cifs_fid *fid = oparms->fid;
struct network_resiliency_req nr_ioctl_req;
bool retry_without_read_attributes = false;
+ bool reconnect = oparms->reconnect;
smb2_path = cifs_convert_path_to_utf16(oparms->path, oparms->cifs_sb);
if (smb2_path == NULL)
@@ -186,23 +187,30 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
* FILE_READ_ATTRIBUTES when not needed and prevent calling code path
* for retry_without_read_attributes.
*/
- if (!(oparms->desired_access & FILE_READ_ATTRIBUTES) &&
- !(oparms->desired_access & GENERIC_READ) &&
+ if (!(oparms->desired_access & GENERIC_READ) &&
!(oparms->desired_access & GENERIC_EXECUTE) &&
!(oparms->desired_access & GENERIC_ALL) &&
!(oparms->desired_access & MAXIMUM_ALLOWED)) {
- oparms->desired_access |= FILE_READ_ATTRIBUTES;
- retry_without_read_attributes = true;
+ if (oparms->replay) {
+ retry_without_read_attributes =
+ oparms->desired_access & FILE_READ_ATTRIBUTES;
+ } else if (!(oparms->desired_access & FILE_READ_ATTRIBUTES)) {
+ oparms->desired_access |= FILE_READ_ATTRIBUTES;
+ retry_without_read_attributes = true;
+ }
}
smb2_oplock = SMB2_OPLOCK_LEVEL_BATCH;
rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, data, NULL, &err_iov,
&err_buftype);
- if (rc == -EACCES && retry_without_read_attributes) {
+ if (rc == -EACCES && retry_without_read_attributes &&
+ !oparms->pending) {
free_rsp_buf(err_buftype, err_iov.iov_base);
memset(&err_iov, 0, sizeof(err_iov));
err_buftype = CIFS_NO_BUFFER;
oparms->desired_access &= ~FILE_READ_ATTRIBUTES;
+ oparms->reconnect = reconnect;
+ oparms->replay = false;
rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, data, NULL, &err_iov,
&err_buftype);
}
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 679ab668051cb..4fd6fe8f6d742 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -3363,14 +3363,25 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
int flags = 0;
int retries = 0, cur_sleep = 0;
struct smb2_file_all_info *file_info = buf ? &buf->fi : NULL;
+ bool reconnect = oparms->reconnect;
+ bool replay = oparms->replay;
+ bool unanswered = replay;
+ bool answered;
+ bool sent;
replay_again:
/* reinitialize for possible replay */
+ answered = false;
+ sent = false;
resp_buftype = CIFS_NO_BUFFER;
memset(&rsp_iov, 0, sizeof(rsp_iov));
flags = 0;
server = cifs_pick_channel(ses);
- oparms->replay = !!(retries);
+ /* reissue the same create: a durable reconnect clears ->reconnect */
+ oparms->reconnect = reconnect;
+ /* with no_replay the caller owns oparms->replay */
+ if (!oparms->no_replay)
+ oparms->replay = unanswered;
cifs_dbg(FYI, "create/open\n");
if (!ses || !server)
@@ -3388,21 +3399,22 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
&rqst, oplock, oparms, path);
if (rc)
goto creat_exit;
+ sent = true;
trace_smb3_open_enter(xid, tcon->tid, tcon->ses->Suid, oparms->path,
oparms->create_options, oparms->desired_access);
- if (retries) {
- /* Back-off before retry */
- if (cur_sleep)
- msleep(cur_sleep);
+ /* Back-off before retry */
+ if (cur_sleep)
+ msleep(cur_sleep);
+ if (oparms->replay)
smb2_set_replay(server, &rqst);
- }
rc = cifs_send_recv(xid, ses, server,
&rqst, &resp_buftype, flags,
&rsp_iov);
rsp = (struct smb2_create_rsp *)rsp_iov.iov_base;
+ answered = rsp;
if (rc != 0) {
cifs_stats_fail_inc(tcon, SMB2_CREATE_HE);
@@ -3459,10 +3471,27 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
SMB2_open_free(&rqst);
free_rsp_buf(resp_buftype, rsp);
- if (is_replayable_error(rc) &&
- smb2_should_replay(tcon, &retries, &cur_sleep))
+ if (sent) {
+ if (!rc || (answered && (!oparms->replay ||
+ !is_replayable_error(rc))))
+ unanswered = false;
+ else if (!answered && !is_interrupt_error(rc))
+ unanswered = true;
+ oparms->pending = unanswered;
+ }
+
+ if (!oparms->no_replay && is_replayable_error(rc) &&
+ smb2_should_replay(tcon, &retries, &cur_sleep)) {
+ if (err_iov && answered && !rsp) {
+ free_rsp_buf(*buftype, err_iov->iov_base);
+ *err_iov = (struct kvec){};
+ *buftype = CIFS_NO_BUFFER;
+ }
goto replay_again;
+ }
+ if (!oparms->no_replay)
+ oparms->replay = replay;
return rc;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 041/742] w1: w1_therm: lock the list of slaves for the bulk read
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (39 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 040/742] smb: client: dont replay handle reopens inside SMB2_open() Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 042/742] ipvs: read flags and seqs in master atomically Greg Kroah-Hartman
` (685 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, stable, Josef Bacik,
Krzysztof Kozlowski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <josef@toxicpanda.com>
[ Upstream commit 1e46334d38e0217f5d255dc6fd63243593052f8e ]
The callbacks of the file therm_bulk_read walk the list of the slaves of
the master, trigger_bulk_read() three times and therm_bulk_read_show()
once, without the list_mutex which protects it. In the meantime the
thread of the master may find out that a sensor has gone:
write to therm_bulk_read w1_process()
trigger_bulk_read() w1_slave_detach()
list_for_each_entry(sl, ...) w1_unref_slave()
bulk_read_slave(sl) list_del()
w1_therm_remove_slave()
kfree(sl->family_data)
kfree(sl)
SLAVE_CONVERT_TRIGGERED(sl) = 1
The walk reads, and writes to, memory which has been freed, and follows
the poisoned list pointers.
Take list_mutex around each of the four walks. No pointer to a slave is
kept from one walk to the next.
This could not be done as long as w1_unref_slave() held the mutex while
it waited, in w1_therm_remove_slave(), for these very callbacks and for
the readers of the sensor, who need the bus_mutex which
trigger_bulk_read() holds around its second walk. Now nothing is waited
for with list_mutex held, and none of the other mutexes of the subsystem
is taken under it, so it can be nested inside bus_mutex.
Fixes: 57c76221d5af ("w1_therm: adding bulk read support to trigger multiple conversion on bus")
Cc: stable <stable@kernel.org>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/20261027-llm-char-misc-w1-v1-8-d2e6bfafb6a4@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/w1/slaves/w1_therm.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index fed45ad4e4e78..d8751b29f4205 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -1508,6 +1508,7 @@ static int trigger_bulk_read(struct w1_master *dev_master)
* and compute duration of conversion for these devices
* so we can apply a strong pullup if required
*/
+ mutex_lock(&dev_master->list_mutex);
list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
if (bulk_read_slave(sl)) {
int t_cur = conversion_time(sl);
@@ -1519,6 +1520,7 @@ static int trigger_bulk_read(struct w1_master *dev_master)
w1_strong_pullup));
}
}
+ mutex_unlock(&dev_master->list_mutex);
/*
* t_conv is the max conversion time required on the bus
@@ -1545,11 +1547,13 @@ static int trigger_bulk_read(struct w1_master *dev_master)
w1_write_8(dev_master, W1_CONVERT_TEMP);
/* set a flag to instruct that converT pending */
+ mutex_lock(&dev_master->list_mutex);
list_for_each_entry(sl,
&dev_master->slist, w1_slave_entry) {
if (bulk_read_slave(sl))
SLAVE_CONVERT_TRIGGERED(sl) = -1;
}
+ mutex_unlock(&dev_master->list_mutex);
if (strong_pullup) { /* some device need pullup */
sleep_rem = msleep_interruptible(t_conv);
@@ -1575,10 +1579,12 @@ static int trigger_bulk_read(struct w1_master *dev_master)
mutex_unlock(&dev_master->bus_mutex);
set_flag:
/* set a flag to register convsersion is done */
+ mutex_lock(&dev_master->list_mutex);
list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
if (bulk_read_slave(sl))
SLAVE_CONVERT_TRIGGERED(sl) = 1;
}
+ mutex_unlock(&dev_master->list_mutex);
error:
return ret;
}
@@ -1943,6 +1949,7 @@ static ssize_t therm_bulk_read_show(struct device *device,
struct w1_slave *sl = NULL;
int ret = 0;
+ mutex_lock(&dev_master->list_mutex);
list_for_each_entry(sl, &dev_master->slist, w1_slave_entry) {
if (bulk_read_slave(sl)) {
if (SLAVE_CONVERT_TRIGGERED(sl) == -1) {
@@ -1955,6 +1962,7 @@ static ssize_t therm_bulk_read_show(struct device *device,
}
}
show_result:
+ mutex_unlock(&dev_master->list_mutex);
return sprintf(buf, "%d\n", ret);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 042/742] ipvs: read flags and seqs in master atomically
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (40 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 041/742] w1: w1_therm: lock the list of slaves for the bulk read Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 043/742] ipvs: honor the overload state and do not enter it forever Greg Kroah-Hartman
` (684 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Julian Anastasov, Pablo Neira Ayuso,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <ja@ssi.bg>
[ Upstream commit aa9afc79f57ba5ef4385aa85cfb7dd50d5c484f6 ]
After we fixed the double read of cp->flags in the master with
commit 3e3fe49e8678 ("ipvs: fix buffer overflow when sending sync messages")
Sashiko reports that we should also read the cp->flags and the seqs
atomically. So if the SEQ_MASK is set, re-read the flags and the
seqs under cp->lock to provide a snapshot when sending the sync
message.
Fixes: 3e3fe49e8678 ("ipvs: fix buffer overflow when sending sync messages")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260927220816.268206-1-pablo%40netfilter.org
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/netfilter/ipvs/ip_vs_sync.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index 1a30817fbbafe..05096de1cc956 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -539,6 +539,7 @@ static int ip_vs_sync_conn_needed(struct netns_ipvs *ipvs,
static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,
int pkts)
{
+ struct ip_vs_sync_conn_options opts;
struct ip_vs_sync_mesg_v0 *m;
struct ip_vs_sync_conn_v0 *s;
struct ip_vs_sync_buff *buff;
@@ -557,6 +558,14 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,
if (!ip_vs_sync_conn_needed(ipvs, cp, pkts))
return;
+ if (flags & IP_VS_CONN_F_SEQ_MASK) {
+ /* Take atomic snapshot of flags and seqs */
+ spin_lock_bh(&cp->lock);
+ flags = cp->flags;
+ memcpy(&opts, &cp->sync_conn_opt, sizeof(opts));
+ spin_unlock_bh(&cp->lock);
+ }
+
spin_lock_bh(&ipvs->sync_buff_lock);
if (!(ipvs->sync_state & IP_VS_STATE_MASTER)) {
spin_unlock_bh(&ipvs->sync_buff_lock);
@@ -604,7 +613,7 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,
if (seq_mask) {
struct ip_vs_sync_conn_options *opt =
(struct ip_vs_sync_conn_options *)&s[1];
- memcpy(opt, &cp->sync_conn_opt, sizeof(*opt));
+ memcpy(opt, &opts, sizeof(*opt));
}
m->nr_conns++;
@@ -630,6 +639,7 @@ static void ip_vs_sync_conn_v0(struct netns_ipvs *ipvs, struct ip_vs_conn *cp,
*/
void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)
{
+ struct ip_vs_sync_conn_options opts;
struct ip_vs_sync_mesg *m;
union ip_vs_sync_conn *s;
struct ip_vs_sync_buff *buff;
@@ -651,6 +661,13 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)
if (!ip_vs_sync_conn_needed(ipvs, cp, pkts))
goto control;
flags = READ_ONCE(cp->flags);
+ if (flags & IP_VS_CONN_F_SEQ_MASK) {
+ /* Take atomic snapshot of flags and seqs */
+ spin_lock_bh(&cp->lock);
+ flags = cp->flags;
+ memcpy(&opts, &cp->sync_conn_opt, sizeof(opts));
+ spin_unlock_bh(&cp->lock);
+ }
/* Sanity checks */
pe_name_len = 0;
@@ -752,9 +769,9 @@ void ip_vs_sync_conn(struct netns_ipvs *ipvs, struct ip_vs_conn *cp, int pkts)
if (seq_mask) {
*(p++) = IPVS_OPT_SEQ_DATA;
*(p++) = sizeof(struct ip_vs_sync_conn_options);
- hton_seq(&cp->in_seq, (struct ip_vs_seq *)p);
+ hton_seq(&opts.in_seq, (struct ip_vs_seq *)p);
p += sizeof(struct ip_vs_seq);
- hton_seq(&cp->out_seq, (struct ip_vs_seq *)p);
+ hton_seq(&opts.out_seq, (struct ip_vs_seq *)p);
p += sizeof(struct ip_vs_seq);
}
/* Handle pe data */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 043/742] ipvs: honor the overload state and do not enter it forever
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (41 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 042/742] ipvs: read flags and seqs in master atomically Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 044/742] btrfs: fix the fsverity callback where unexpected range is verified Greg Kroah-Hartman
` (683 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Julian Anastasov, Pablo Neira Ayuso,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <ja@ssi.bg>
[ Upstream commit 567ca80d77baf4c9ab635865375956084c8bb52a ]
Sashiko warns that we may enter the dest overload state forever
if setting the u_threshold to 1 races with the ip_vs_unbind_dest()
call for the last connection for dest. The problem is that we
prefer ip_vs_unbind_dest() to avoid using locks while reading the
threshold.
To avoid the race, add a smp_mb() in __ip_vs_dest_update_overload()
that is paired with the atomic_fetch_dec() in ip_vs_unbind_dest()
which allows to re-read the totalconns and to leave the overload
state if we are below l_threshold_val.
Also, remove the overload parameter from ip_vs_dest_update_overload()
because we just need to know the current state while deciding
which threshold ranges to use. This ip_vs_dest_is_overloaded() check
can be in __ip_vs_dest_update_overload() instead.
To avoid ip_vs_bind_dest() to enter lock just to initialize
u_threshold_val to INT_MAX, do it in ip_vs_new_dest().
The LBLC and LBLCR schedulers do not honor the global overload state
for cached dests, so add a ip_vs_dest_is_overloaded() check for
the situations where we may fallback from overloaded dest (LBLC and
LBLCR) or when we hit a cached dest (LBLC).
Also, move the ip_vs_dest_set_min() call in LBLCR after the
ip_vs_dest_set_erase() call that removes the most-loaded
server because due to races we may work with dest that is
in process of removing, i.e. ip_vs_dest_set_min() and
ip_vs_dest_set_max() may return same dest.
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261019150249.1879516-2-pablo%40netfilter.org
Fixes: 3ba20137287f ("ipvs: fix more races around the overload flag")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/net/ip_vs.h | 2 +-
net/netfilter/ipvs/ip_vs_conn.c | 4 ++--
net/netfilter/ipvs/ip_vs_ctl.c | 30 ++++++++++++++++++------------
net/netfilter/ipvs/ip_vs_lblc.c | 8 +++++---
net/netfilter/ipvs/ip_vs_lblcr.c | 13 +++++++------
5 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 9a83bff32569d..53d680ba8790f 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -1923,7 +1923,7 @@ static inline void ip_vs_dest_put_and_free(struct ip_vs_dest *dest)
kfree(dest);
}
-void ip_vs_dest_update_overload(struct ip_vs_dest *dest, bool overload);
+void ip_vs_dest_update_overload(struct ip_vs_dest *dest);
/* Check if dest is in overloaded state */
static inline bool ip_vs_dest_is_overloaded(const struct ip_vs_dest *dest)
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 94f25fb7d87e4..6998872634345 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -1154,7 +1154,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
atomic_inc(&dest->activeconns);
tc = atomic_inc_return(&dest->totalconns);
if (tc >= READ_ONCE(dest->u_threshold_val))
- ip_vs_dest_update_overload(dest, true);
+ ip_vs_dest_update_overload(dest);
} else {
/* It is a persistent connection/template, so increase
the persistent connection counter */
@@ -1247,7 +1247,7 @@ static inline void ip_vs_unbind_dest(struct ip_vs_conn *cp)
atomic_dec(&dest->activeconns);
tc = atomic_fetch_dec(&dest->totalconns);
if (tc <= READ_ONCE(dest->l_threshold_val))
- ip_vs_dest_update_overload(dest, false);
+ ip_vs_dest_update_overload(dest);
} else {
/* It is a persistent connection/template, so decrease
the persistent connection counter */
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 3003547dcabe5..2d005d3cd2de7 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -1304,12 +1304,12 @@ void ip_vs_stats_free(struct ip_vs_stats *stats)
}
}
-/* Update overload flag based on number of dest conns and lower/upper
+/* Update overload state based on number of dest conns and lower/upper
* connection thresholds:
- * - conns reach u_threshold and exceed it: set the flag
- * - conns go below l_threshold (or 75% of u_threshold): clear the flag
+ * - conns reach u_threshold and exceed it: set the overload state
+ * - conns go below l_threshold (or 75% of u_threshold): clear the state
*/
-static void __ip_vs_dest_update_overload(struct ip_vs_dest *dest, bool overload)
+static void __ip_vs_dest_update_overload(struct ip_vs_dest *dest)
{
int conns;
u32 l, u;
@@ -1320,10 +1320,18 @@ static void __ip_vs_dest_update_overload(struct ip_vs_dest *dest, bool overload)
/* Low threshold defaults to 75% of upper threshold */
l = READ_ONCE(dest->l_threshold) ? : (u - (u >> 2));
conns = atomic_read(&dest->totalconns);
- if (conns >= (overload ? l : u)) {
+ if (conns >= (ip_vs_dest_is_overloaded(dest) ? l : u)) {
WRITE_ONCE(dest->u_threshold_val, INT_MAX);
WRITE_ONCE(dest->l_threshold_val, l);
- return;
+ /* Commit thresholds before repeating the check,
+ * it is paired with atomic_fetch_dec() in
+ * ip_vs_unbind_dest() to avoid entering the
+ * overload state forever.
+ */
+ smp_mb();
+ conns = atomic_read(&dest->totalconns);
+ if (conns >= l)
+ return;
}
}
@@ -1331,10 +1339,10 @@ static void __ip_vs_dest_update_overload(struct ip_vs_dest *dest, bool overload)
WRITE_ONCE(dest->l_threshold_val, 0);
}
-void ip_vs_dest_update_overload(struct ip_vs_dest *dest, bool overload)
+void ip_vs_dest_update_overload(struct ip_vs_dest *dest)
{
spin_lock_bh(&dest->dst_lock);
- __ip_vs_dest_update_overload(dest, overload);
+ __ip_vs_dest_update_overload(dest);
spin_unlock_bh(&dest->dst_lock);
}
@@ -1406,13 +1414,10 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
if (READ_ONCE(dest->u_threshold) != udest->u_threshold ||
READ_ONCE(dest->l_threshold) != udest->l_threshold) {
- bool overload;
-
spin_lock_bh(&dest->dst_lock);
WRITE_ONCE(dest->u_threshold, udest->u_threshold);
WRITE_ONCE(dest->l_threshold, udest->l_threshold);
- overload = ip_vs_dest_is_overloaded(dest);
- __ip_vs_dest_update_overload(dest, overload);
+ __ip_vs_dest_update_overload(dest);
spin_unlock_bh(&dest->dst_lock);
}
@@ -1477,6 +1482,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest)
if (ret < 0)
goto err_stats;
+ dest->u_threshold_val = INT_MAX;
dest->af = udest->af;
dest->protocol = svc->protocol;
dest->vaddr = svc->addr;
diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
index e1111c3b27211..f5ce1f2afb860 100644
--- a/net/netfilter/ipvs/ip_vs_lblc.c
+++ b/net/netfilter/ipvs/ip_vs_lblc.c
@@ -467,10 +467,11 @@ is_overloaded(struct ip_vs_dest *dest, struct ip_vs_service *svc)
struct ip_vs_dest *d;
list_for_each_entry_rcu(d, &svc->destinations, n_list) {
- if (atomic_read(&d->activeconns)*2
- < atomic_read(&d->weight)) {
+ if (ip_vs_dest_is_overloaded(d))
+ continue;
+ if (atomic_read(&d->activeconns) * 2 <
+ atomic_read(&d->weight))
return 1;
- }
}
}
return 0;
@@ -507,6 +508,7 @@ ip_vs_lblc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,
dest = en->dest;
if ((dest->cflags & IP_VS_DEST_CF_AVAILABLE) &&
+ !ip_vs_dest_is_overloaded(dest) &&
atomic_read(&dest->weight) > 0 && !is_overloaded(dest, svc))
goto out;
}
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
index dfb5bf83750db..4046608922e7c 100644
--- a/net/netfilter/ipvs/ip_vs_lblcr.c
+++ b/net/netfilter/ipvs/ip_vs_lblcr.c
@@ -630,10 +630,11 @@ is_overloaded(struct ip_vs_dest *dest, struct ip_vs_service *svc)
struct ip_vs_dest *d;
list_for_each_entry_rcu(d, &svc->destinations, n_list) {
- if (atomic_read(&d->activeconns)*2
- < atomic_read(&d->weight)) {
+ if (ip_vs_dest_is_overloaded(d))
+ continue;
+ if (atomic_read(&d->activeconns) * 2 <
+ atomic_read(&d->weight))
return 1;
- }
}
}
return 0;
@@ -658,9 +659,6 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,
if (en) {
en->lastuse = jiffies;
- /* Get the least loaded destination */
- dest = ip_vs_dest_set_min(&en->set);
-
/* More than one destination + enough time passed by, cleanup */
if (atomic_read(&en->set.size) > 1 &&
time_after(jiffies, en->set.lastmod +
@@ -676,6 +674,9 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,
spin_unlock_bh(&svc->sched_lock);
}
+ /* Get the least loaded destination */
+ dest = ip_vs_dest_set_min(&en->set);
+
/* If the destination is not overloaded, use it */
if (dest && !is_overloaded(dest, svc))
goto out;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 044/742] btrfs: fix the fsverity callback where unexpected range is verified
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (42 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 043/742] ipvs: honor the overload state and do not enter it forever Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 045/742] usb: xhci: fix typos in comments Greg Kroah-Hartman
` (682 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Roger Alasà, Eric Biggers,
Tito Duarte, Qu Wenruo, David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <wqu@suse.com>
[ Upstream commit 254e15591ee4590064e0c55285cdcb4f4519133c ]
[BUG]
There is a bug report that on v7.2 kernel, compressed extents with
fsverity enabled can lead to warnings like the following:
fs-verity (dm-3, inode 257): FILE CORRUPTED! pos=7471104, level=-1, want_hash=sha256:bedf0e7bc93b48694db719001a8d3e79229cc58ee638b41d4149193505090774, real_hash=sha256:ad7facb2586fc6e966c004d7d1d16b024f5805ff7cb47c7a85dabd8b48892ca7
The read itself eventually succeeds, and no read error is returned to
user space.
[CAUSE]
Since v7.2 btrfs has enabled large data folio support, now a folio can
contain multiple blocks even if the page size matches the fs block size.
And even before that, btrfs already has block size < page size support,
thus all involved code should assume a folio can contain multiple
blocks.
However the function btrfs_verify_folio() calls fsverity_verify_folio(),
which verifies the whole folio, even if the read range only covers part
of the folio.
This forces fsverity to verify garbage data that is not yet read from
disk, and causes verification failure.
This is a long-standing bug, but previously it only affected bs < ps
cases which is not that common.
Now with the large folio support, it's much easier to trigger with bs ==
ps cases.
[FIX]
Instead of calling fsverity_verify_folio(), call
fsverity_verify_blocks() to verify only the read range.
Reported-by: Roger Alasà <vonbloom@gmail.com>
Link: https://lore.kernel.org/linux-btrfs/CAELqY9==Ter2XQPRp=gjW5T75T+7kcZCXpn5roF2L6tY6mQNxw@mail.gmail.com/
Fixes: 146054090b08 ("btrfs: initial fsverity support")
Tested-by: Roger Alasà <vonbloom@gmail.com>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Tested-by: Tito Duarte <duartito@gmail.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/extent_io.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index d7600e5fa3d95..fe4c87dc61ba8 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -504,7 +504,7 @@ static bool btrfs_verify_folio(struct fsverity_info *vi, struct folio *folio,
if (!vi || btrfs_folio_test_uptodate(fs_info, folio, start, len))
return true;
- return fsverity_verify_folio(vi, folio);
+ return fsverity_verify_blocks(vi, folio, len, offset_in_folio(folio, start));
}
static void end_folio_read(struct fsverity_info *vi, struct folio *folio,
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 045/742] usb: xhci: fix typos in comments
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (43 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 044/742] btrfs: fix the fsverity callback where unexpected range is verified Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 046/742] xhci: give back TDs and clean up ep0 after disconnect Greg Kroah-Hartman
` (681 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zain Aboobacker, Mathias Nyman,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zain Aboobacker <zainaboobacker33@gmail.com>
[ Upstream commit d7458590f585aea58f24047195f163adc6ecb045 ]
Fix various spelling mistakes in comments found by codespell.
Assisted-by: Claude:claude-opus-5-5 codespell
Signed-off-by: Zain Aboobacker <zainaboobacker33@gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20261009151624.618967-4-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: 6895dbdc19d9 ("xhci: give back TDs and clean up ep0 after disconnect")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/host/xhci-ring.c | 14 +++++++-------
drivers/usb/host/xhci.c | 14 +++++++-------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index fffd901b59e7f..aedb2af01e2f7 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -243,7 +243,7 @@ static void inc_enq_past_link(struct xhci_hcd *xhci, struct xhci_ring *ring, u32
* fixed in the 0.96 specification errata, but we have to assume that all 0.95
* xHCI hardware can't handle the chain bit being cleared on a link TRB.
*
- * On 0.95 and some 0.96 HCs the chain bit is set once at segment initalization
+ * On 0.95 and some 0.96 HCs the chain bit is set once at segment initialization
* and never changed here. On all others, modify it as requested by the caller.
*/
if (!xhci_link_chain_quirk(xhci, ring->type)) {
@@ -661,7 +661,7 @@ struct xhci_ring *xhci_triad_to_transfer_ring(struct xhci_hcd *xhci,
* Get the hw dequeue pointer xHC stopped on, either directly from the
* endpoint context, or if streams are in use from the stream context.
* The returned hw_dequeue contains the lowest four bits with cycle state
- * and possbile stream context type.
+ * and possible stream context type.
*/
static u64 xhci_get_hw_deq(struct xhci_hcd *xhci, struct xhci_virt_device *vdev,
unsigned int ep_index, unsigned int stream_id)
@@ -989,7 +989,7 @@ static int xhci_handle_halted_endpoint(struct xhci_hcd *xhci,
int err;
/*
- * Avoid resetting endpoint if link is inactive or device disonnected.
+ * Avoid resetting endpoint if link is inactive or device disconnected.
* Can cause host hang.
* Device will be reset to recover an inactive link, so don't do anything
*/
@@ -1384,7 +1384,7 @@ static void xhci_kill_endpoint_urbs(struct xhci_hcd *xhci,
* held for the URBs to finish during device disconnect, blocking host remove.
*
* Call with xhci->lock held.
- * lock is relased and re-acquired while giving back urb.
+ * lock is released and re-acquired while giving back urb.
*/
void xhci_hc_died(struct xhci_hcd *xhci)
{
@@ -1969,7 +1969,7 @@ static void handle_device_notification(struct xhci_hcd *xhci,
}
/*
- * Quirk hanlder for errata seen on Cavium ThunderX2 processor XHCI
+ * Quirk handler for errata seen on Cavium ThunderX2 processor XHCI
* Controller.
* As per ThunderX2errata-129 USB 2 device may come up as USB 1
* If a connection to a USB 1 device is followed by another connection
@@ -3087,7 +3087,7 @@ static void xhci_clear_interrupt_pending(struct xhci_interrupter *ir)
/*
* Handle all OS-owned events on an interrupter event ring. It may drop
- * and reaquire xhci->lock between event processing.
+ * and reacquire xhci->lock between event processing.
*/
static int xhci_handle_events(struct xhci_hcd *xhci, struct xhci_interrupter *ir,
bool skip_events)
@@ -3798,7 +3798,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
/*
* If next available TRB is the Link TRB in the ring segment then
* enqueue a No Op TRB, this can prevent the Setup and Data Stage
- * TRB to be breaked by the Link TRB.
+ * TRB to be broken by the Link TRB.
*/
if (last_trb_on_seg(ep_ring->enq_seg, ep_ring->enqueue + 1)) {
field = TRB_TYPE(TRB_TR_NOOP) | ep_ring->cycle_state;
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index ec9ae4e15b5b8..d6dc696b385ac 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -406,7 +406,7 @@ static void compliance_mode_recovery(struct timer_list *t)
* The quirk creates a timer that polls every 2 seconds the link state of
* each host controller's port and recovers it by issuing a Warm reset
* if Compliance mode is detected, otherwise the port will become "dead" (no
- * device connections or disconnections will be detected anymore). Becasue no
+ * device connections or disconnections will be detected anymore). Because no
* status event is generated when entering compliance mode (per xhci spec),
* this quirk is needed on systems that have the failing hardware installed.
*/
@@ -796,7 +796,7 @@ static void xhci_save_registers(struct xhci_hcd *xhci)
xhci->s3.config_reg = readl(&xhci->op_regs->config_reg);
/* save both primary and all secondary interrupters */
- /* fixme, shold we lock to prevent race with remove secondary interrupter? */
+ /* fixme, should we lock to prevent race with remove secondary interrupter? */
for (i = 0; i < xhci->max_interrupters; i++) {
ir = xhci->interrupters[i];
if (!ir)
@@ -2047,7 +2047,7 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
/*
* Configuration and alternate setting changes must be done in
- * process context, not interrupt context (or so documenation
+ * process context, not interrupt context (or so documentation
* for usb_set_interface() and usb_set_configuration() claim).
*/
if (xhci_endpoint_init(xhci, virt_dev, udev, ep, GFP_NOIO) < 0) {
@@ -3303,7 +3303,7 @@ static void xhci_endpoint_disable(struct usb_hcd *hcd,
* state. For software that wishes to reset the data toggle or sequence number
* of an endpoint that isn't in the halted state this function will issue a
* configure endpoint command with the Drop and Add bits set for the target
- * endpoint. Refer to the additional note in xhci spcification section 4.6.8.
+ * endpoint. Refer to the additional note in xhci specification section 4.6.8.
*
* vdev may be lost due to xHC restore error and re-initialization during S3/S4
* resume. A new vdev will be allocated later by xhci_discover_or_reset_device()
@@ -4297,7 +4297,7 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
pm_runtime_get_noresume(hcd->self.controller);
/* Is this a LS or FS device under a HS hub? */
- /* Hub or peripherial? */
+ /* Hub or peripheral? */
return 1;
disable_slot:
@@ -4516,7 +4516,7 @@ static int xhci_enable_device(struct usb_hcd *hcd, struct usb_device *udev)
/*
* Transfer the port index into real index in the HW port status
- * registers. Caculate offset between the port's PORTSC register
+ * registers. Calculate offset between the port's PORTSC register
* and port status base. Divide the number of per port register
* to get the real index. The raw port number bases 1.
*/
@@ -5398,7 +5398,7 @@ static void xhci_hcd_init_usb3_data(struct xhci_hcd *xhci, struct usb_hcd *hcd)
/*
* Early xHCI 1.1 spec did not mention USB 3.1 capable hosts
* should return 0x31 for sbrn, or that the minor revision
- * is a two digit BCD containig minor and sub-minor numbers.
+ * is a two digit BCD containing minor and sub-minor numbers.
* This was later clarified in xHCI 1.2.
*
* Some USB 3.1 capable hosts therefore have sbrn 0x30, and
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 046/742] xhci: give back TDs and clean up ep0 after disconnect
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (44 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 045/742] usb: xhci: fix typos in comments Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 047/742] xhci: keep port link_inactive and connected flags in sync when polled Greg Kroah-Hartman
` (680 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, stable, Yiyu Zhou, Dennis Wissel,
Mathias Nyman, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yiyu Zhou <yiyu@yiyuzhou.io>
[ Upstream commit 6895dbdc19d927a2872bd4f111e1911874d5dce4 ]
Fix a regression in v7.3 introduced by the commits in the Fixes tags.
Those patches avoid endpoint recovery and rapid state changes after
the root port link is lost.
This caused a regression in device enumeration.
It turns out that a subset of USB HID devices briefly disconnect during
enumeration. USB core manages to resuscitate these devices without
reallocating them, and thus continue using the same udev, xhci vdev and
default control endpoint (ep0) of the device.
xhci didn't give back or clean up halted TDs behind disconnected ports
as it assumed that the disconnect cancels all URBs, and drops and frees
all endpoints.
This is not the case, so cancel and give back TDs on halted endpoint
behind disconnected ports, make sure ep0 is cleared and in a proper state
to continue working even after a link error or disconnect is detected.
Also prevent new URBs until device is reset.
One issue related to the TDs not being given back was seen on a PFU
HHKB Professional HYBRID Type-S keyboard (04fe:0021).
It drops off the bus about 300 ms after its first enumeration, while
usbhid is still probing its third interface. The probe runs in hub_wq,
so the disconnect is not handled until the probe returns.
On a root port the HID descriptor request and its four retries in
hid_get_class_descriptor() each wait for the full 5 second
USB_CTRL_GET_TIMEOUT:
[57685.006036] usb 3-2: new full-speed USB device number 24 using xhci_hcd
...
[57685.291304] hid-generic 0003:04FE:0021.0017: input,hidraw1: USB HID v1.11 Keyboard [PFU Limited HHKB-Hybrid] on usb-0000:00:14.0-2/input1
[57711.221083] usbhid 3-2:1.2: can't add hid device: -110
[57711.221613] usbhid 3-2:1.2: probe with driver usbhid failed with error -110
[57711.221842] usb 3-2: USB disconnect, device number 24
[mn: merge EP_DROP_PENDING and link_inactive checks in xhci_urb_enqueue(),
return TDs and clean up ep0 on disconnect, rewrite commit message]
Fixes: 042aad8d0db6 ("xhci: prevent endpoint recovery after roothub disconnect")
Fixes: 7e0ef4332ed9 ("xhci: avoid xHC endpoint changes after disconnect or link error.")
Cc: stable <stable@kernel.org>
Closes: https://lore.kernel.org/all/20261010071811.20483-1-yiyu@yiyuzhou.io/
Closes: https://lore.kernel.org/linux-usb/4MjB9K-2SoiA85WbI9iEig@dsine.de/
Tested-by: Yiyu Zhou <yiyu@yiyuzhou.io>
Tested-by: Dennis Wissel <dennis@dsine.de>
Signed-off-by: Yiyu Zhou <yiyu@yiyuzhou.io>
Co-developed-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20261029204324.658845-2-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/host/xhci-ring.c | 73 ++++++++++++++++++++++++++++++------
drivers/usb/host/xhci.c | 13 ++++---
2 files changed, 69 insertions(+), 17 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index aedb2af01e2f7..2a8585581aa8a 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -65,6 +65,7 @@
static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
u32 field1, u32 field2,
u32 field3, u32 field4, bool command_must_succeed);
+static void xhci_kill_endpoint_urbs(struct xhci_hcd *xhci, int slot_id, int ep_index);
/*
* Returns zero if the TRB isn't in this segment, otherwise it returns the DMA
@@ -955,6 +956,24 @@ static void xhci_giveback_invalidated_tds(struct xhci_hcd *xhci, struct xhci_vir
}
}
+static void xhci_cancel_ring_tds(struct xhci_hcd *xhci, struct xhci_virt_ep *ep,
+ struct xhci_ring *ring, int td_status)
+{
+ struct xhci_td *tmp_td;
+ struct xhci_td *td;
+
+ /* Add all TDs on ring to cancelled td list */
+ list_for_each_entry_safe(td, tmp_td, &ring->td_list, td_list) {
+ if (list_empty(&td->cancelled_td_list)) {
+ list_add_tail(&td->cancelled_td_list,
+ &ep->cancelled_td_list);
+ td->cancel_status = TD_DIRTY;
+ if (!td->status)
+ td->status = td_status;
+ }
+ }
+}
+
static int xhci_reset_halted_ep(struct xhci_hcd *xhci, unsigned int slot_id,
unsigned int ep_index, enum xhci_ep_reset_type reset_type)
{
@@ -986,25 +1005,53 @@ static int xhci_handle_halted_endpoint(struct xhci_hcd *xhci,
{
struct xhci_port *rhub_port = ep->vdev->rhub_port;
unsigned int slot_id = ep->vdev->slot_id;
+ bool disconnected = false;
+ struct xhci_ring *ring;
int err;
- /*
- * Avoid resetting endpoint if link is inactive or device disconnected.
- * Can cause host hang.
- * Device will be reset to recover an inactive link, so don't do anything
- */
+ /* link is inactive or device disconnected */
if (rhub_port->link_inactive || !rhub_port->connected) {
ep->ep_state |= EP_DROP_PENDING;
- return -ENODEV;
+ disconnected = true;
+ if (!td && ep->ep_index != 0) {
+ xhci_kill_endpoint_urbs(xhci, slot_id, ep->ep_index);
+ return -ENODEV;
+ }
}
- /* add td to cancelled list and let reset ep handler take care of it */
- if (reset_type == EP_HARD_RESET) {
- ep->ep_state |= EP_HARD_CLEAR_TOGGLE;
+ /* Add halted td to cancelled list and let reset ep handler take care of it */
+ if (reset_type == EP_HARD_RESET || disconnected) {
if (td && list_empty(&td->cancelled_td_list)) {
list_add_tail(&td->cancelled_td_list, &ep->cancelled_td_list);
td->cancel_status = TD_HALTED;
+ if (disconnected && !td->status)
+ td->status = -EPROTO;
+ }
+ }
+
+ /*
+ * Avoid resetting non-ep0 endpoints if link is inactive or device
+ * disconnected. Can cause host hang.
+ * Endpoints other than ep0 won't restart before the device is reset or
+ * the endpoint is dropped, so cancel all TDs, and give back non-ep0 TDs
+ * now instead of letting them time out. Ep0 can survive a short device
+ * disconnect during enumeration so reset ep0 normally and clean it up.
+ */
+ if (disconnected) {
+ ring = td ? xhci_urb_to_transfer_ring(xhci, td->urb) : ep->ring;
+ xhci_cancel_ring_tds(xhci, ep, ring, -ESHUTDOWN);
+ if (ep->ep_index != 0) {
+ xhci_dbg(xhci, "Not resetting ep %u slot %u after disconnect\n",
+ ep->ep_index, slot_id);
+
+ xhci_process_cancelled_tds(xhci, ep);
+ xhci_kill_endpoint_urbs(xhci, slot_id, ep->ep_index);
+ return -ENODEV;
}
+ /* hard-reset a halted disconnected ep0 */
+ xhci_dbg(xhci, "Reset and clean up ep0 slot %u after disconnect\n",
+ slot_id);
+ reset_type = EP_HARD_RESET;
}
if (ep->ep_state & EP_HALTED) {
@@ -1013,6 +1060,9 @@ static int xhci_handle_halted_endpoint(struct xhci_hcd *xhci,
return 0;
}
+ if (reset_type == EP_HARD_RESET)
+ ep->ep_state |= EP_HARD_CLEAR_TOGGLE;
+
err = xhci_reset_halted_ep(xhci, slot_id, ep->ep_index, reset_type);
if (err)
return err;
@@ -1063,8 +1113,9 @@ static int xhci_invalidate_cancelled_tds(struct xhci_hcd *xhci, struct xhci_virt
continue;
}
- /* device disconnected or link error, ep will be dropped */
- if (ep->ep_state & EP_DROP_PENDING) {
+ /* device disconnected or link error, non-ep0 endpoints will be dropped */
+ if (ep->ep_state & EP_DROP_PENDING && ep->ep_index != 0) {
+ td_to_noop(xhci, ep, td, false);
td->cancel_status = TD_CLEARED;
continue;
}
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index d6dc696b385ac..c5000b82b1078 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1666,12 +1666,6 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
goto free_priv;
}
- if (xhci->devs[slot_id]->rhub_port->link_inactive) {
- xhci_dbg(xhci, "Can't queue urb, port error, link inactive\n");
- ret = -ENODEV;
- goto free_priv;
- }
-
if (xhci->xhc_state & XHCI_STATE_DYING) {
xhci_dbg(xhci, "Ep 0x%x: URB %p submitted for non-responsive xHCI host.\n",
urb->ep->desc.bEndpointAddress, urb);
@@ -1681,6 +1675,13 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag
ep_state = &xhci->devs[slot_id]->eps[ep_index].ep_state;
+ if (xhci->devs[slot_id]->rhub_port->link_inactive ||
+ *ep_state & EP_DROP_PENDING) {
+ xhci_dbg(xhci, "Can't queue urb, port disconnect or link inactive\n");
+ ret = -ENODEV;
+ goto free_priv;
+ }
+
if (*ep_state & (EP_GETTING_STREAMS | EP_GETTING_NO_STREAMS)) {
xhci_warn(xhci, "WARN: Can't enqueue URB, ep in streams transition state %x\n",
*ep_state);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 047/742] xhci: keep port link_inactive and connected flags in sync when polled
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (45 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 046/742] xhci: give back TDs and clean up ep0 after disconnect Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 048/742] Revert "wifi: ath10k: Stop unanswered temperature reads" Greg Kroah-Hartman
` (679 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, stable, Mathias Nyman, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <mathias.nyman@linux.intel.com>
[ Upstream commit bb261776d1a29768b8fd84eb4f42d99dafa29c93 ]
Update port 'link_inactive' and 'connected' flags even if xHC isn't
generating port change events.
xHC only generates port change events on port changes after old port
change bits are cleared. Hub driver is often kept up to date
by polling the port status.
Sashiko reported a possible case where all port changes after a port
reset take place before hub driver clears the reset change bit.
This way the port can end up connected and fully running with link
in u0 without a port event clearing the 'link_inactive' or setting
the 'connected' flags.
A protocol STALL in this state would set EP_DROP_PENDING, and
prevent all future URBs for the endpoint.
Fix this by also updating the flags during get_port_status(), when
hub driver is polling the port state.
Fixes: 6895dbdc19d9 ("xhci: give back TDs and clean up ep0 after disconnect")
Link: https://lore.kernel.org/linux-usb/sashiko-outbox-190046@kernel.org/
Cc: stable <stable@kernel.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20261105175106.241182-2-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/host/xhci-hub.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 470bafe1802be..55430b673f1e9 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -1166,6 +1166,12 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, struct xhci_bus_state *bus_
if (portsc & PORT_RESET)
status |= USB_PORT_STAT_RESET;
+ /* track connect and link error status when hub is polling */
+ if (!(portsc & PORT_RESET)) {
+ port->link_inactive = (portsc & PORT_PLS_MASK) == XDEV_INACTIVE;
+ port->connected = !!(portsc & PORT_CONNECT);
+ }
+
/* USB2 and USB3 specific bits, including Port Link State */
if (hcd->speed >= HCD_USB3)
xhci_get_usb3_port_status(port, &status, portsc);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 048/742] Revert "wifi: ath10k: Stop unanswered temperature reads"
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (46 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 047/742] xhci: keep port link_inactive and connected flags in sync when polled Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 049/742] tpm: Call cmd_ready/go_idle for each command transmission Greg Kroah-Hartman
` (678 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Jeff Johnson
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
commit b1ed5a45b994a6473ca1cf34f35a1bf87f1d8e2a upstream.
As reported by Nicolas Escande [1] this will break some setups where
temperature reporting is supported but there are occasional requests where
there isn't a response. Revert this implementation where a single
unreported temperature read at any time will stop all future requests.
Alternate solutions are being discussed.
Link: https://lore.kernel.org/all/DMRPC2GCD51O.S4DMHZFDKRFG@gmail.com/ # [1]
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/wireless/ath/ath10k/core.c | 1 -
drivers/net/wireless/ath/ath10k/thermal.c | 9 +--------
drivers/net/wireless/ath/ath10k/thermal.h | 2 --
3 files changed, 1 insertion(+), 11 deletions(-)
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -2985,7 +2985,6 @@ int ath10k_core_start(struct ath10k *ar,
clear_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags);
ar->running_fw = fw;
- ar->thermal.broken = false;
if (!test_bit(ATH10K_FW_FEATURE_NON_BMI,
ar->running_fw->fw_file.fw_features)) {
--- a/drivers/net/wireless/ath/ath10k/thermal.c
+++ b/drivers/net/wireless/ath/ath10k/thermal.c
@@ -75,12 +75,6 @@ static ssize_t ath10k_thermal_show_temp(
goto out;
}
- /* Don't stall every read on firmware that never answers */
- if (ar->thermal.broken) {
- ret = -EOPNOTSUPP;
- goto out;
- }
-
reinit_completion(&ar->thermal.wmi_sync);
ret = ath10k_wmi_pdev_get_temperature(ar);
if (ret) {
@@ -96,8 +90,7 @@ static ssize_t ath10k_thermal_show_temp(
time_left = wait_for_completion_timeout(&ar->thermal.wmi_sync,
ATH10K_THERMAL_SYNC_TIMEOUT_HZ);
if (!time_left) {
- ath10k_warn(ar, "failed to synchronize thermal read, not asking again until the firmware restarts\n");
- ar->thermal.broken = true;
+ ath10k_warn(ar, "failed to synchronize thermal read\n");
ret = -ETIMEDOUT;
goto out;
}
--- a/drivers/net/wireless/ath/ath10k/thermal.h
+++ b/drivers/net/wireless/ath/ath10k/thermal.h
@@ -19,8 +19,6 @@ struct ath10k_thermal {
/* protected by conf_mutex */
u32 throttle_state;
u32 quiet_period;
- /* the running firmware did not answer a temperature request */
- bool broken;
/* temperature value in Celsius degree
* protected by data_lock
*/
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 049/742] tpm: Call cmd_ready/go_idle for each command transmission
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (47 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 048/742] Revert "wifi: ath10k: Stop unanswered temperature reads" Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 050/742] firmware: arm_scmi: Update ARM_SCMI_HAVE_TRANSPORT rationale Greg Kroah-Hartman
` (677 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Mario Limonciello, Jarkko Sakkinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <mario.limonciello@amd.com>
commit 313acd594a799d6b4b3af937eaca7bf4a1803c4a upstream.
Some TPM implementations, particularly fTPM using the CRB interface,
require the TPM to transition through idle and ready states for each
command rather than once per session.
The current implementation calls cmd_ready once during tpm_chip_start()
and go_idle once during tpm_chip_stop(). For fTPM, when multiple commands
are sent without per-command idle transitions, subsequent commands timeout
as the TPM is waiting for the transition.
Fix this by calling cmd_ready before each command and go_idle on all exit
paths in tpm_try_transmit(). For TPM implementations that don't require
per-command transitions, the callbacks return immediately based on the
start method.
Remove the now-redundant per-session calls from tpm_chip_start() and
tpm_chip_stop() along with their helpers.
This resolves timeout errors during TPM initialization on systems where
BIOS has already performed TPM startup.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lore.kernel.org/r/20260901213723.3017371-1-mario.limonciello@amd.com
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/char/tpm/tpm-chip.c | 24 ------------------------
drivers/char/tpm/tpm-interface.c | 22 ++++++++++++++++++++++
2 files changed, 22 insertions(+), 24 deletions(-)
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -66,22 +66,6 @@ static void tpm_relinquish_locality(stru
chip->locality = -1;
}
-static int tpm_cmd_ready(struct tpm_chip *chip)
-{
- if (!chip->ops->cmd_ready)
- return 0;
-
- return chip->ops->cmd_ready(chip);
-}
-
-static int tpm_go_idle(struct tpm_chip *chip)
-{
- if (!chip->ops->go_idle)
- return 0;
-
- return chip->ops->go_idle(chip);
-}
-
static void tpm_clk_enable(struct tpm_chip *chip)
{
if (chip->ops->clk_enable)
@@ -116,13 +100,6 @@ int tpm_chip_start(struct tpm_chip *chip
}
}
- ret = tpm_cmd_ready(chip);
- if (ret) {
- tpm_relinquish_locality(chip);
- tpm_clk_disable(chip);
- return ret;
- }
-
return 0;
}
EXPORT_SYMBOL_GPL(tpm_chip_start);
@@ -137,7 +114,6 @@ EXPORT_SYMBOL_GPL(tpm_chip_start);
*/
void tpm_chip_stop(struct tpm_chip *chip)
{
- tpm_go_idle(chip);
tpm_relinquish_locality(chip);
tpm_clk_disable(chip);
}
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -19,6 +19,7 @@
* calls to msleep.
*/
+#include <linux/cleanup.h>
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/mutex.h>
@@ -89,8 +90,17 @@ static bool tpm_transmit_completed(u8 st
return status_masked == chip->ops->req_complete_val;
}
+static void tpm_go_idle(struct tpm_chip *chip)
+{
+ if (chip->ops->go_idle)
+ chip->ops->go_idle(chip);
+}
+
+DEFINE_FREE(tpm_go_idle, struct tpm_chip *, if (_T) tpm_go_idle(_T))
+
static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
{
+ struct tpm_chip *chip_idle __free(tpm_go_idle) = NULL;
struct tpm_header *header = buf;
int rc;
ssize_t len = 0;
@@ -113,6 +123,18 @@ static ssize_t tpm_try_transmit(struct t
return -E2BIG;
}
+ if (chip->ops->cmd_ready) {
+ rc = chip->ops->cmd_ready(chip);
+ if (rc) {
+ dev_err(&chip->dev,
+ "%s: cmd_ready(): error %d\n", __func__, rc);
+ return rc;
+ }
+ }
+
+ /* Ensure go_idle() is called on every exit path from here on. */
+ chip_idle = chip;
+
rc = chip->ops->send(chip, buf, bufsiz, count);
if (rc < 0) {
if (rc != -EPIPE)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 050/742] firmware: arm_scmi: Update ARM_SCMI_HAVE_TRANSPORT rationale
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (48 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 049/742] tpm: Call cmd_ready/go_idle for each command transmission Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 051/742] arm64: dts: arm: corstone1000-a320: Fix GIC redistributor region size Greg Kroah-Hartman
` (676 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Geert Uytterhoeven, Sudeep Holla,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <geert+renesas@glider.be>
[ Upstream commit e637b774416775d09540070ceecf972c59070d90 ]
Not enabling any transports no longer breaks the build.
Fixes: c0397c85b53d0bc6 ("firmware: arm_scmi: Use WARN_ON() to check configured transports")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/48c4bed8036dcb55f554f513ce2ae61807c5677d.1790684637.git.geert+renesas@glider.be
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/firmware/arm_scmi/transports/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/transports/Kconfig b/drivers/firmware/arm_scmi/transports/Kconfig
index 57eccf316e26b..66b10f511827c 100644
--- a/drivers/firmware/arm_scmi/transports/Kconfig
+++ b/drivers/firmware/arm_scmi/transports/Kconfig
@@ -5,7 +5,7 @@ config ARM_SCMI_HAVE_TRANSPORT
bool
help
This declares whether at least one SCMI transport has been configured.
- Used to trigger a build bug when trying to build SCMI without any
+ Used to trigger a runtime warning when enabling SCMI without any
configured transport.
config ARM_SCMI_HAVE_SHMEM
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 051/742] arm64: dts: arm: corstone1000-a320: Fix GIC redistributor region size
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (49 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 050/742] firmware: arm_scmi: Update ARM_SCMI_HAVE_TRANSPORT rationale Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 052/742] firmware: arm_ffa: Compare notify_id when looking up notifier callbacks Greg Kroah-Hartman
` (675 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Liviu Dudau, Rob Herring (Arm),
Sudeep Holla, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring (Arm) <robh@kernel.org>
[ Upstream commit 5ac351938cae58c5cd1b356f9d0aae2e243c11ad ]
The Arm Corstone1000-A320 has a GICv4 which means the redistributor
region should be 4x256KB rather than 512KB. This issue didn't become
apparent as SMP was disabled as a work-around in early versions of the
FVP.
Fixes: 87599f1843d3 ("arm64: dts: arm/corstone1000: Add corstone-1000-a320")
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20261005210506.2118052-2-robh@kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm64/boot/dts/arm/corstone1000-a320.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/arm/corstone1000-a320.dtsi b/arch/arm64/boot/dts/arm/corstone1000-a320.dtsi
index f0937914350c5..f895a024fc920 100644
--- a/arch/arm64/boot/dts/arm/corstone1000-a320.dtsi
+++ b/arch/arm64/boot/dts/arm/corstone1000-a320.dtsi
@@ -73,7 +73,7 @@ gic: interrupt-controller@1c000000 {
#size-cells = <1>;
interrupt-controller;
reg = <0x1c000000 0x10000>,
- <0x1c040000 0x80000>;
+ <0x1c040000 0x100000>;
interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_LOW>;
};
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 052/742] firmware: arm_ffa: Compare notify_id when looking up notifier callbacks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (50 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 051/742] arm64: dts: arm: corstone1000-a320: Fix GIC redistributor region size Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 053/742] firmware: smccc: Provide stubs for HAVE_ARM_SMCCC_DISCOVERY=n Greg Kroah-Hartman
` (674 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, David Cemin, Sudeep Holla,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Cemin <dcemin@nvidia.com>
[ Upstream commit 8ab2e426762d199ce8b799d029edafbfb981f5c6 ]
The notifier callbacks are kept in a hash table keyed by notification ID,
but struct notifier_cb_info does not store the ID and none of the lookup
helpers compare it. hash_for_each_possible() walks the whole bucket, so
any two IDs that hash to the same bucket are treated as the same
registration.
With the 64-bucket table, hash_32() maps IDs 2 and 36 to the same
bucket. A driver that requests notifications sequentially therefore
fails at the 37th request:
ARM FF-A: Failed to register callback for 36 - -22
because update_notifier_cb() finds the node registered for ID 2 and
rejects the new registration as a duplicate. The same lookup is used on
the delivery path, so a notification for a colliding ID can also be
dispatched to the callback registered for the other ID.
Store the notification ID in the node and compare it in all three
lookup helpers.
This was found on an arm64 laptop whose embedded controller partition
declares 38 notifications: the EC driver failed to probe and every
EC event (AC, battery, lid, hotkeys) was lost.
Fixes: e0573444edbf ("firmware: arm_ffa: Add interfaces to request notification callbacks")
Fixes: c10debfe7f02 ("firmware: arm_ffa: Add support for {un,}registration of framework notifications")
Signed-off-by: David Cemin <dcemin@nvidia.com>
Link: https://patch.msgid.link/20261020220902.611138-1-dcemin@nvidia.com
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/firmware/arm_ffa/driver.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 28abc808fd32d..ae8cc3a2ba2e7 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -1223,6 +1223,7 @@ struct notifier_cb_info {
ffa_fwk_notifier_cb fwk_cb;
ffa_notifier_cb cb;
void *cb_data;
+ u16 notify_id;
};
static int
@@ -1302,7 +1303,8 @@ notifier_hnode_get_by_vmid(u16 notify_id, int vmid)
struct notifier_cb_info *node;
hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id)
- if (node->fwk_cb && vmid == node->dev->vm_id)
+ if (node->notify_id == notify_id && node->fwk_cb &&
+ vmid == node->dev->vm_id)
return node;
return NULL;
@@ -1317,7 +1319,8 @@ notifier_hnode_get_by_vmid_uuid(u16 notify_id, int vmid, const uuid_t *uuid)
return notifier_hnode_get_by_vmid(notify_id, vmid);
hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id)
- if (node->fwk_cb && vmid == node->dev->vm_id &&
+ if (node->notify_id == notify_id && node->fwk_cb &&
+ vmid == node->dev->vm_id &&
uuid_equal(&node->dev->uuid, uuid))
return node;
@@ -1330,7 +1333,8 @@ notifier_hnode_get_by_type(u16 notify_id, enum notify_type type)
struct notifier_cb_info *node;
hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id)
- if (node->cb && type == ffa_notify_type_get(node->dev->vm_id))
+ if (node->notify_id == notify_id && node->cb &&
+ type == ffa_notify_type_get(node->dev->vm_id))
return node;
return NULL;
@@ -1422,6 +1426,7 @@ static int __ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu,
cb_info->dev = dev;
cb_info->cb_data = cb_data;
+ cb_info->notify_id = notify_id;
if (is_framework)
cb_info->fwk_cb = cb;
else
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 053/742] firmware: smccc: Provide stubs for HAVE_ARM_SMCCC_DISCOVERY=n
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (51 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 052/742] firmware: arm_ffa: Compare notify_id when looking up notifier callbacks Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 054/742] irqchip/gic-v3: Select HAVE_ARM_SMCCC_DISCOVERY only on arm64 Greg Kroah-Hartman
` (673 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Marc Zyngier, Julian Braha,
Sudeep Holla, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Braha <julianbraha@gmail.com>
[ Upstream commit 6cc03818814aa98c3584a346b82165f1b561f2b7 ]
Add fallbacks for callers to avoid needing #ifdef guards when
HAVE_ARM_SMCCC_DISCOVERY is disabled (32-bit arm).
Fixes: 35727af2b15d ("irqchip/gicv3: Workaround for NVIDIA erratum T241-FABRIC-4")
Suggested-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Julian Braha <julianbraha@gmail.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://patch.msgid.link/20261020222817.1231643-2-julianbraha@gmail.com
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/arm-smccc.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
index 4de81848fe2ee..75f9d3f1723b5 100644
--- a/include/linux/arm-smccc.h
+++ b/include/linux/arm-smccc.h
@@ -324,6 +324,7 @@ enum arm_smccc_conduit {
SMCCC_CONDUIT_HVC,
};
+#ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY
/**
* arm_smccc_1_1_get_conduit()
*
@@ -363,6 +364,12 @@ s32 arm_smccc_get_soc_id_version(void);
* When ARM_SMCCC_ARCH_SOC_ID is not present, returns SMCCC_RET_NOT_SUPPORTED.
*/
s32 arm_smccc_get_soc_id_revision(void);
+#else /* CONFIG_HAVE_ARM_SMCCC_DISCOVERY */
+#define arm_smccc_1_1_get_conduit() SMCCC_CONDUIT_NONE
+#define arm_smccc_get_version() 0
+#define arm_smccc_get_soc_id_version() SMCCC_RET_NOT_SUPPORTED
+#define arm_smccc_get_soc_id_revision() SMCCC_RET_NOT_SUPPORTED
+#endif /* CONFIG_HAVE_ARM_SMCCC_DISCOVERY */
#ifndef __ASSEMBLY__
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 054/742] irqchip/gic-v3: Select HAVE_ARM_SMCCC_DISCOVERY only on arm64
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (52 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 053/742] firmware: smccc: Provide stubs for HAVE_ARM_SMCCC_DISCOVERY=n Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 055/742] HID: vivaldi: Extract feature report value directly in vivaldi_feature_mapping() Greg Kroah-Hartman
` (672 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Marc Zyngier, Thomas Gleixner,
Julian Braha, Sudeep Holla, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Braha <julianbraha@gmail.com>
[ Upstream commit 40b097fdfd00516ba9a568ccc10e9f166358ddca ]
ARM_PSCI_FW is always enabled for arm64, and the GICv3 driver only
uses HAVE_ARM_SMCCC_DISCOVERY to identify the NVIDIA T241, which is
arm64 anyway.
For ARM_GIC_V3, let's only select HAVE_ARM_SMCCC_DISCOVERY on arm64.
Fixes: 35727af2b15d ("irqchip/gicv3: Workaround for NVIDIA erratum T241-FABRIC-4")
Suggested-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Acked-by: Thomas Gleixner <tglx@kernel.org>
Signed-off-by: Julian Braha <julianbraha@gmail.com>
Link: https://patch.msgid.link/20261020222817.1231643-3-julianbraha@gmail.com
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/irqchip/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 01f8415f62fc7..0f3bbf14c8432 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -37,7 +37,7 @@ config ARM_GIC_V3
bool
select IRQ_DOMAIN_HIERARCHY
select GENERIC_IRQ_EFFECTIVE_AFF_MASK if SMP
- select HAVE_ARM_SMCCC_DISCOVERY
+ select HAVE_ARM_SMCCC_DISCOVERY if ARM64
select IRQ_MSI_IOMMU
config ARM_GIC_ITS_PARENT
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 055/742] HID: vivaldi: Extract feature report value directly in vivaldi_feature_mapping()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (53 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 054/742] irqchip/gic-v3: Select HAVE_ARM_SMCCC_DISCOVERY only on arm64 Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 056/742] HID: vivaldi: avoid redundant feature report reads per usage Greg Kroah-Hartman
` (671 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dmitry Torokhov, Tzung-Bi Shih,
Sean OBrien, Shashikirana H K, Benjamin Tissoires, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shashikirana H K <shashikiranah@chromium.org>
[ Upstream commit 8dbf66b011135422a28ee32da1d6aacbe08ddd7a ]
Currently vivaldi_feature_mapping() passes the raw buffer returned by
hid_hw_raw_request() to hid_report_raw_event() with the descriptor-declared
report_len just to populate field->value[usage->usage_index].
Since vivaldi_feature_mapping() already has the target report, field, and
usage in hand, and nothing else consumes field->value[] for this report,
verify that hid_hw_raw_request() returns the expected report_len, ensure
usage->usage_index is within field->report_count, and extract the value
directly using hid_field_extract(). Also use __free(kfree) to simplify
buffer cleanup.
Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Fixes: 33bbe04a15f2 ("HID: google: extract Vivaldi hid feature mapping for use in hid-hammer")
Cc: Tzung-Bi Shih <tzungbi@chromium.org>
Cc: Sean O'Brien <seobrien@chromium.org>
Signed-off-by: Shashikirana H K <shashikiranah@chromium.org>
Link: https://patch.msgid.link/20261013-upstream-vivaldi-fix-v2-1-ecc20329d24c@chromium.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-vivaldi-common.c | 72 ++++++++++++--------------------
1 file changed, 26 insertions(+), 46 deletions(-)
diff --git a/drivers/hid/hid-vivaldi-common.c b/drivers/hid/hid-vivaldi-common.c
index b12bb5cc091aa..1359a107e63bd 100644
--- a/drivers/hid/hid-vivaldi-common.c
+++ b/drivers/hid/hid-vivaldi-common.c
@@ -5,11 +5,13 @@
* Copyright (C) 2022 Google, Inc
*/
+#include <linux/cleanup.h>
#include <linux/export.h>
#include <linux/hid.h>
#include <linux/input/vivaldi-fmap.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/slab.h>
#include <linux/types.h>
#include "hid-vivaldi-common.h"
@@ -33,13 +35,14 @@ void vivaldi_feature_mapping(struct hid_device *hdev,
{
struct vivaldi_data *data = hid_get_drvdata(hdev);
struct hid_report *report = field->report;
- u8 *report_data, *buf;
- u32 report_len;
unsigned int fn_key;
+ unsigned int offset;
+ u32 report_len;
int ret;
if (field->logical != HID_USAGE_FN_ROW_PHYSMAP ||
- (usage->hid & HID_USAGE_PAGE) != HID_UP_ORDINAL)
+ (usage->hid & HID_USAGE_PAGE) != HID_UP_ORDINAL ||
+ usage->usage_index >= field->report_count)
return;
fn_key = usage->hid & HID_USAGE;
@@ -49,54 +52,31 @@ void vivaldi_feature_mapping(struct hid_device *hdev,
if (fn_key > data->num_function_row_keys)
data->num_function_row_keys = fn_key;
- report_data = buf = hid_alloc_report_buf(report, GFP_KERNEL);
- if (!report_data)
+ u8 *buf __free(kfree) = hid_alloc_report_buf(report, GFP_KERNEL);
+ if (!buf)
return;
- report_len = hid_report_len(report);
- if (!report->id) {
- /*
- * hid_hw_raw_request() will stuff report ID (which will be 0)
- * into the first byte of the buffer even for unnumbered
- * reports, so we need to account for this to avoid getting
- * -EOVERFLOW in return.
- * Note that hid_alloc_report_buf() adds 7 bytes to the size
- * so we can safely say that we have space for an extra byte.
- */
- report_len++;
- }
-
- ret = hid_hw_raw_request(hdev, report->id, report_data,
- report_len, HID_FEATURE_REPORT,
- HID_REQ_GET_REPORT);
- if (ret < 0) {
- dev_warn(&hdev->dev, "failed to fetch feature %d\n",
- field->report->id);
- goto out;
- }
-
- if (!report->id) {
- /*
- * Undo the damage from hid_hw_raw_request() for unnumbered
- * reports.
- */
- report_data++;
- report_len--;
- }
-
- ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, report_data,
- report_len, report_len, 0);
- if (ret) {
- dev_warn(&hdev->dev, "failed to report feature %d\n",
- field->report->id);
- goto out;
+ /*
+ * hid_hw_raw_request() will stuff report ID (which will be 0)
+ * into the first byte of the buffer even for unnumbered
+ * reports, so we need to account for this to avoid getting
+ * -EOVERFLOW in return.
+ * Note that hid_alloc_report_buf() adds 7 bytes to the size
+ * so we can safely say that we have space for an extra byte.
+ */
+ report_len = hid_report_len(report) + !report->id;
+
+ ret = hid_hw_raw_request(hdev, report->id, buf, report_len,
+ HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
+ if (ret != report_len) {
+ dev_warn(&hdev->dev, "failed to fetch feature %d: %d\n",
+ report->id, ret);
+ return;
}
+ offset = field->report_offset + usage->usage_index * field->report_size;
data->function_row_physmap[fn_key - MIN_FN_ROW_KEY] =
- field->value[usage->usage_index];
-
-out:
- kfree(buf);
+ hid_field_extract(hdev, buf + 1, offset, field->report_size);
}
EXPORT_SYMBOL_GPL(vivaldi_feature_mapping);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 056/742] HID: vivaldi: avoid redundant feature report reads per usage
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (54 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 055/742] HID: vivaldi: Extract feature report value directly in vivaldi_feature_mapping() Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 057/742] firmware: arm_scmi: imx: Track copied syslog words Greg Kroah-Hartman
` (670 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zhengping Jiang, Benjamin Tissoires,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhengping Jiang <jiangzp@google.com>
[ Upstream commit 720806515cb6921ab05caaa6f470f7054b56385e ]
vivaldi_feature_mapping() is invoked by report_features() in ascending
usage_index order for each usage in the top-row physical keymap field.
Because fetching the feature report at usage_index == 0 already reads
the entire report from hardware, calling hid_hw_raw_request() again for
subsequent usages redundantly reads the same report N times (e.g., 12
sequential BLE GATT reads taking ~2s on Vivaldi BLE keyboards).
Bail out immediately when usage->usage_index != 0, fetch the feature
report once at usage_index == 0, and iterate over all usages in the
field to populate data->function_row_physmap[].
Fixes: 33bbe04a15f2 ("HID: google: extract Vivaldi hid feature mapping for use in hid-hammer")
Signed-off-by: Zhengping Jiang <jiangzp@google.com>
Link: https://patch.msgid.link/20261015064223.1939367-1-jiangzp@google.com
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-vivaldi-common.c | 33 +++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/drivers/hid/hid-vivaldi-common.c b/drivers/hid/hid-vivaldi-common.c
index 1359a107e63bd..973393d093561 100644
--- a/drivers/hid/hid-vivaldi-common.c
+++ b/drivers/hid/hid-vivaldi-common.c
@@ -39,19 +39,11 @@ void vivaldi_feature_mapping(struct hid_device *hdev,
unsigned int offset;
u32 report_len;
int ret;
+ int i;
- if (field->logical != HID_USAGE_FN_ROW_PHYSMAP ||
- (usage->hid & HID_USAGE_PAGE) != HID_UP_ORDINAL ||
- usage->usage_index >= field->report_count)
+ if (field->logical != HID_USAGE_FN_ROW_PHYSMAP || usage->usage_index)
return;
- fn_key = usage->hid & HID_USAGE;
- if (fn_key < MIN_FN_ROW_KEY || fn_key > MAX_FN_ROW_KEY)
- return;
-
- if (fn_key > data->num_function_row_keys)
- data->num_function_row_keys = fn_key;
-
u8 *buf __free(kfree) = hid_alloc_report_buf(report, GFP_KERNEL);
if (!buf)
return;
@@ -74,9 +66,24 @@ void vivaldi_feature_mapping(struct hid_device *hdev,
return;
}
- offset = field->report_offset + usage->usage_index * field->report_size;
- data->function_row_physmap[fn_key - MIN_FN_ROW_KEY] =
- hid_field_extract(hdev, buf + 1, offset, field->report_size);
+ for (i = 0; i < field->maxusage && i < field->report_count; i++) {
+ usage = &field->usage[i];
+
+ if ((usage->hid & HID_USAGE_PAGE) != HID_UP_ORDINAL)
+ continue;
+
+ fn_key = usage->hid & HID_USAGE;
+ if (fn_key < MIN_FN_ROW_KEY || fn_key > MAX_FN_ROW_KEY)
+ continue;
+
+ if (fn_key > data->num_function_row_keys)
+ data->num_function_row_keys = fn_key;
+
+ offset = field->report_offset + i * field->report_size;
+ data->function_row_physmap[fn_key - MIN_FN_ROW_KEY] =
+ hid_field_extract(hdev, buf + 1, offset,
+ field->report_size);
+ }
}
EXPORT_SYMBOL_GPL(vivaldi_feature_mapping);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 057/742] firmware: arm_scmi: imx: Track copied syslog words
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (55 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 056/742] HID: vivaldi: avoid redundant feature report reads per usage Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 058/742] firmware: arm_scmi: imx: Validate MISC control response size Greg Kroah-Hartman
` (669 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Peng Fan, Sudeep Holla,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <sudeep.holla@kernel.org>
[ Upstream commit 3baf579ba76613f65b03f43a2f2642340e5fb717 ]
The MISC syslog iterator records the number of returned words plus
firmware-reported remaining words in the caller's size output.
The debugfs consumer uses that value to dump its fixed-size buffer. A
malformed or inconsistent response can therefore make it read beyond
the copied data and allocation.
Return the accumulated number of words copied into the caller's buffer
instead. The generic iterator bounds this count to the initial buffer
capacity before processing each response.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-67e325a9-473e-450a-a2a0-bf4c0c720624
Fixes: 4fa62e80c7db ("firmware: arm_scmi: imx: Support getting syslog of MISC protocol")
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20261028130502.2999676-1-sudeep.holla@kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
index 637973fb45e65..0c708b2dd4967 100644
--- a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
+++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
@@ -438,7 +438,7 @@ static int iter_misc_syslog_update_state(struct scmi_iterator_state *st,
st->num_returned = RETURNED(r->numlogflags);
st->num_remaining = REMAINING(r->numlogflags);
- *p->size = st->num_returned + st->num_remaining;
+ *p->size = st->desc_index + st->num_returned;
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 058/742] firmware: arm_scmi: imx: Validate MISC control response size
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (56 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 057/742] firmware: arm_scmi: imx: Track copied syslog words Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 059/742] firmware: arm_scmi: Unregister notifier on enable failure Greg Kroah-Hartman
` (668 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Peng Fan, Sudeep Holla,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <sudeep.holla@kernel.org>
[ Upstream commit 4e3652a0ac715ba7387b072b72eaff76e761aaf9 ]
scmi_imx_misc_ctrl_get() uses @num to report the number of
values returned by firmware, but it did not retain the caller's value
as the capacity of @val.
A response with more values than the caller allocated was copied into
@val unchecked. For example, the MQS regmap callback supplies storage
for one value. Retain the input capacity and reject responses exceeding
it before copying, then update @num only after a successful copy.
Document the in/out @num contract of the exported helper.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-6897b44a-57fb-4964-95f8-447d0ce526e4
Fixes: 61c9f03e22fc ("firmware: arm_scmi: Add initial support for i.MX MISC protocol")
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20261028130502.2999676-2-sudeep.holla@kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../firmware/arm_scmi/vendors/imx/imx-sm-misc.c | 16 ++++++++++++----
include/linux/firmware/imx/sm.h | 6 ++++++
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
index 0c708b2dd4967..f00f7acba845a 100644
--- a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
+++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
@@ -273,10 +273,16 @@ static int scmi_imx_misc_ctrl_get(const struct scmi_protocol_handle *ph,
{
struct scmi_imx_misc_ctrl_get_out *out;
struct scmi_xfer *t;
+ u32 num_values, max_values;
int ret, i;
int max_msg_size = ph->hops->get_max_msg_size(ph);
int max_num = (max_msg_size - sizeof(*out)) / sizeof(__le32);
+ if (!num || !val || !*num)
+ return -EINVAL;
+
+ max_values = *num;
+
ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id);
if (ret)
return ret;
@@ -290,16 +296,18 @@ static int scmi_imx_misc_ctrl_get(const struct scmi_protocol_handle *ph,
ret = ph->xops->do_xfer(ph, t);
if (!ret) {
out = t->rx.buf;
- *num = le32_to_cpu(out->num);
+ num_values = le32_to_cpu(out->num);
- if (*num >= max_num ||
- *num * sizeof(__le32) > t->rx.len - sizeof(__le32)) {
+ if (num_values > max_values || num_values >= max_num ||
+ num_values * sizeof(__le32) > t->rx.len - sizeof(__le32)) {
ph->xops->xfer_put(ph, t);
return -EINVAL;
}
- for (i = 0; i < *num; i++)
+ for (i = 0; i < num_values; i++)
val[i] = le32_to_cpu(out->val[i]);
+
+ *num = num_values;
}
ph->xops->xfer_put(ph, t);
diff --git a/include/linux/firmware/imx/sm.h b/include/linux/firmware/imx/sm.h
index ba5d93bd6158f..0aec7da0ae784 100644
--- a/include/linux/firmware/imx/sm.h
+++ b/include/linux/firmware/imx/sm.h
@@ -29,6 +29,12 @@
#define SCMI_IMX952_CTRL_BYPASS_AUDMIX 8U /* WAKE AUDMIX */
#if IS_ENABLED(CONFIG_IMX_SCMI_MISC_DRV)
+/**
+ * scmi_imx_misc_ctrl_get() - Read an i.MX MISC control
+ * @id: Control identifier
+ * @num: On entry, capacity of @val in words; on return, words read
+ * @val: Buffer for the control value
+ */
int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val);
int scmi_imx_misc_ctrl_set(u32 id, u32 val);
#else
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 059/742] firmware: arm_scmi: Unregister notifier on enable failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (57 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 058/742] firmware: arm_scmi: imx: Validate MISC control response size Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 060/742] firmware: arm_scmi: Free mailbox state on mapping failure Greg Kroah-Hartman
` (667 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Peng Fan, Sudeep Holla,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <sudeep.holla@kernel.org>
[ Upstream commit b9bb2eb88037a3823e7abd096b54d0a07d428f90 ]
scmi_notifier_register() adds the caller's notifier block before
enabling the corresponding event at the platform.
If enablement fails, the caller receives an error and can free its
notifier block. A concurrent registration can retain and later enable
the handler, leaving the failed caller's block in its notification
chain. Event delivery can then dereference the freed block.
Remove the notifier block before dropping the handler reference when
event enablement fails.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-c3c9437c-ba1a-4db6-837f-cb0950d89018
Fixes: e7c215f358a3 ("firmware: arm_scmi: Add notification callbacks-registration")
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20261028130502.2999676-3-sudeep.holla@kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/firmware/arm_scmi/notify.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c
index fb60fb07c0ed1..e5de0d29c3460 100644
--- a/drivers/firmware/arm_scmi/notify.c
+++ b/drivers/firmware/arm_scmi/notify.c
@@ -1395,8 +1395,10 @@ static int scmi_notifier_register(const struct scmi_handle *handle,
/* Enable events for not pending handlers */
if (!IS_HNDL_PENDING(hndl)) {
ret = scmi_event_handler_enable_events(hndl);
- if (ret)
+ if (ret) {
+ blocking_notifier_chain_unregister(&hndl->chain, nb);
scmi_put_handler(ni, hndl);
+ }
}
return ret;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 060/742] firmware: arm_scmi: Free mailbox state on mapping failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (58 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 059/742] firmware: arm_scmi: Unregister notifier on enable failure Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 061/742] drm/msm: Fix GMEM_BASE on a8xx Greg Kroah-Hartman
` (666 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Sudeep Holla, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sudeep Holla <sudeep.holla@kernel.org>
[ Upstream commit 38b6268eae651de1ca31c48b912a55ae3e706b94 ]
mailbox_chan_setup() allocates its private state from the SCMI base
device before mapping the shared-memory area. If mapping fails while
setting up an optional RX channel, the core ignores the RX failure and
keeps the base device bound, retaining that devres allocation.
Release the private mailbox state before returning the mapping error.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-fda9bcb5-8255-4157-bbf7-d720bbd86605
Fixes: 1ebc28e9357c ("firmware: arm_scmi: Introduce setup_shmem_iomap")
Link: https://patch.msgid.link/20261028153203.3305067-1-sudeep.holla@kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/firmware/arm_scmi/transports/mailbox.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/arm_scmi/transports/mailbox.c b/drivers/firmware/arm_scmi/transports/mailbox.c
index 308736c3ead9c..237e04c1a0f43 100644
--- a/drivers/firmware/arm_scmi/transports/mailbox.c
+++ b/drivers/firmware/arm_scmi/transports/mailbox.c
@@ -201,8 +201,11 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
smbox->shmem = core->shmem->setup_iomap(cinfo, dev, tx, NULL,
&smbox->io_ops);
- if (IS_ERR(smbox->shmem))
- return PTR_ERR(smbox->shmem);
+ if (IS_ERR(smbox->shmem)) {
+ ret = PTR_ERR(smbox->shmem);
+ devm_kfree(dev, smbox);
+ return ret;
+ }
cl = &smbox->cl;
cl->dev = cdev;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 061/742] drm/msm: Fix GMEM_BASE on a8xx
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (59 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 060/742] firmware: arm_scmi: Free mailbox state on mapping failure Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 062/742] soundwire: qcom: disable the interrupt before gating the clock Greg Kroah-Hartman
` (665 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Connor Abbott, Konrad Dybcio,
Rob Clark, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Connor Abbott <cwabbott0@gmail.com>
[ Upstream commit 6036663be30a411b895d4ce9ba4625abbec5943b ]
This was missed during initial bringup because GMEM_BASE is not used
anymore for textures on a8xx. However other things such as mesh shading
still use the GMEM aperture. Fix it to match the value programmed into
the registers.
Fixes: 288a93200892 ("drm/msm/adreno: Introduce A8x GPU Support")
Signed-off-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/764371/
Message-ID: <20261029-drm-msm-gmem-base-fix-v2-1-26b338471b46@gmail.com>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/msm/adreno/adreno_gpu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index dadfe4c694384..f7882bb8028d8 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -382,7 +382,9 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_context *ctx,
*value = adreno_gpu->gmem;
return 0;
case MSM_PARAM_GMEM_BASE:
- if (adreno_gpu->info->family >= ADRENO_6XX_GEN3)
+ if (adreno_gpu->info->family >= ADRENO_8XX_GEN1)
+ *value = SZ_64M;
+ else if (adreno_gpu->info->family >= ADRENO_6XX_GEN3)
*value = 0;
else
*value = 0x100000;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 062/742] soundwire: qcom: disable the interrupt before gating the clock
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (60 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 061/742] drm/msm: Fix GMEM_BASE on a8xx Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 063/742] memory: tegra: Shut down Tegra210 EMC timers before teardown Greg Kroah-Hartman
` (664 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Oleg Keri, Dmitry Baryshkov,
Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Keri <okerixx@gmail.com>
[ Upstream commit 6c067677192f054bbfa815caf04f536bb8dcdee2 ]
swrm_runtime_suspend() gates hclk straight after the ClockStopNow
broadcast, while the interrupt thread that completed it is still
clearing the status and CLK_STOP_FINISHED is about to fire. Both touch
registers with the clock going away; on x1e80100 and glymur hclk is the
SoundWire clock itself. The next clock-stop exit then fails at random
(bus clash, parity errors, AUTO_ENUM_FAILED) and one side of the
speakers stays detached until reboot.
Disable the interrupt before gating the clock and enable it again once
the clock is back.
Fixes: 74e79da9fd46 ("soundwire: qcom: add runtime pm support")
Signed-off-by: Oleg Keri <okerixx@gmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://patch.msgid.link/20261009082639.22662-1-okerixx@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/soundwire/qcom.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 55678a30cd4a1..c5e48e8a84429 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -1730,6 +1730,7 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
}
clk_prepare_enable(ctrl->hclk);
+ enable_irq(ctrl->irq);
if (ctrl->clock_stop_not_supported) {
reinit_completion(&ctrl->enumeration);
@@ -1813,6 +1814,7 @@ static int __maybe_unused swrm_runtime_suspend(struct device *dev)
}
}
+ disable_irq(ctrl->irq);
clk_disable_unprepare(ctrl->hclk);
usleep_range(300, 305);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 063/742] memory: tegra: Shut down Tegra210 EMC timers before teardown
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (61 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 062/742] soundwire: qcom: disable the interrupt before gating the clock Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 064/742] memory: tegra: fix device_node leak in tegra186_mc_probe_device() Greg Kroah-Hartman
` (663 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ijae Kim, Myeonghun Pak, Sashiko,
Krzysztof Kozlowski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <mhun512@gmail.com>
[ Upstream commit c5f343c189aa30285e7c73dbf2f185720467794b ]
The training and refresh timers can outlive the EMC state on removal
or probe failure after clock attachment, causing use-after-free.
Shut down both timers before detaching the clock provider and releasing
the timing tables to wait for callbacks and prevent rearming. Initialize
them before clock attachment, since set_rate() can start training.
Fixes: 10de21148f7d ("memory: tegra: Add EMC scaling support code for Tegra210")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-47538f77-fb50-4a06-b49b-92dbee8b538b
Link: https://patch.msgid.link/20261015002852.2159841-1-mhun512@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/memory/tegra/tegra210-emc-core.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/memory/tegra/tegra210-emc-core.c b/drivers/memory/tegra/tegra210-emc-core.c
index e8d4cd8fdec26..044ec6f1bc321 100644
--- a/drivers/memory/tegra/tegra210-emc-core.c
+++ b/drivers/memory/tegra/tegra210-emc-core.c
@@ -1946,12 +1946,6 @@ static int tegra210_emc_probe(struct platform_device *pdev)
config->same_freq = true;
}
- err = tegra210_clk_emc_attach(emc->clk, &emc->provider);
- if (err < 0) {
- dev_err(&pdev->dev, "failed to attach to EMC clock: %d\n", err);
- goto release;
- }
-
emc->clkchange_delay = 100;
emc->training_interval = 100;
dev_set_drvdata(emc->dev, emc);
@@ -1963,6 +1957,12 @@ static int tegra210_emc_probe(struct platform_device *pdev)
timer_setup(&emc->training, tegra210_emc_train, 0);
+ err = tegra210_clk_emc_attach(emc->clk, &emc->provider);
+ if (err < 0) {
+ dev_err(&pdev->dev, "failed to attach to EMC clock: %d\n", err);
+ goto release;
+ }
+
tegra210_emc_debugfs_init(emc);
cd = devm_thermal_of_child_cooling_device_register(emc->dev, np, "emc", emc,
@@ -1978,6 +1978,8 @@ static int tegra210_emc_probe(struct platform_device *pdev)
detach:
debugfs_remove_recursive(emc->debugfs.root);
+ timer_shutdown_sync(&emc->training);
+ timer_shutdown_sync(&emc->refresh_timer);
tegra210_clk_emc_detach(emc->clk);
release:
of_reserved_mem_device_release(emc->dev);
@@ -1990,6 +1992,8 @@ static void tegra210_emc_remove(struct platform_device *pdev)
struct tegra210_emc *emc = platform_get_drvdata(pdev);
debugfs_remove_recursive(emc->debugfs.root);
+ timer_shutdown_sync(&emc->training);
+ timer_shutdown_sync(&emc->refresh_timer);
tegra210_clk_emc_detach(emc->clk);
of_reserved_mem_device_release(emc->dev);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 064/742] memory: tegra: fix device_node leak in tegra186_mc_probe_device()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (62 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 063/742] memory: tegra: Shut down Tegra210 EMC timers before teardown Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 065/742] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them Greg Kroah-Hartman
` (662 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Selby Mashiki, Krzysztof Kozlowski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selby Mashiki <mashikiselby@gmail.com>
[ Upstream commit 21250426a8469d3bc43c2f0c69ed5497ee9ff7d4 ]
tegra186_mc_probe_device() iterates over the "interconnects" phandles
using of_parse_phandle_with_args(), which increments the reference count
of args.np on each successful call, but never drops the reference with
of_node_put(args.np).
Call of_node_put(args.np) at the end of each loop iteration.
Fixes: fe3b082a6eb8 ("memory: tegra: Add SID override programming for MC clients")
Signed-off-by: Selby Mashiki <mashikiselby@gmail.com>
Link: https://patch.msgid.link/20261025190322.449324-1-mashikiselby@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/memory/tegra/tegra186.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c
index 442edb2b033e2..0df5b56586e89 100644
--- a/drivers/memory/tegra/tegra186.c
+++ b/drivers/memory/tegra/tegra186.c
@@ -146,6 +146,7 @@ static int tegra186_mc_probe_device(struct tegra_mc *mc, struct device *dev)
}
}
+ of_node_put(args.np);
index++;
}
#endif
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 065/742] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (63 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 064/742] memory: tegra: fix device_node leak in tegra186_mc_probe_device() Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 066/742] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure Greg Kroah-Hartman
` (661 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Yuan Yao, Fuad Tabba, Marc Zyngier,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <fuad.tabba@linux.dev>
[ Upstream commit 861bebd1fac5f5a25c11e40aec3c3291542045d1 ]
The GICv4 allocation and teardown paths free their irq domains and
fwnodes but leave the pointers set, and the allocation error paths test
those pointers before removing them. struct its_vm and struct its_vpe
are embedded in KVM's per-VM and per-vCPU state, so nothing re-zeroes
them between two attempts, and an error path taken after an earlier one
already freed the domain calls irq_domain_remove() on freed memory.
Reaching this takes two allocation failures, one to leave the stale
pointer behind and one to send the next attempt down the error path.
Fixes: 7de5c0af9c7c ("irqchip/gic-v4: Add per-VM VPE domain creation")
Fixes: 6d31b6ff985d ("irqchip/gic-v4.1: Add VSGI allocation/teardown")
Reviewed-by: Yuan Yao <yaoyuan@linux.alibaba.com>
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
Link: https://patch.msgid.link/20260921072958.2918477-2-fuad.tabba@linux.dev
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/irqchip/irq-gic-v4.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
index 8455b4a5fbb0d..754839e409f88 100644
--- a/drivers/irqchip/irq-gic-v4.c
+++ b/drivers/irqchip/irq-gic-v4.c
@@ -147,10 +147,14 @@ static int its_alloc_vcpu_sgis(struct its_vpe *vpe, int idx)
return 0;
err:
- if (vpe->sgi_domain)
+ if (vpe->sgi_domain) {
irq_domain_remove(vpe->sgi_domain);
- if (vpe->fwnode)
+ vpe->sgi_domain = NULL;
+ }
+ if (vpe->fwnode) {
irq_domain_free_fwnode(vpe->fwnode);
+ vpe->fwnode = NULL;
+ }
kfree(name);
return -ENOMEM;
}
@@ -191,10 +195,14 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
return 0;
err:
- if (vm->domain)
+ if (vm->domain) {
irq_domain_remove(vm->domain);
- if (vm->fwnode)
+ vm->domain = NULL;
+ }
+ if (vm->fwnode) {
irq_domain_free_fwnode(vm->fwnode);
+ vm->fwnode = NULL;
+ }
return -ENOMEM;
}
@@ -215,6 +223,8 @@ static void its_free_sgi_irqs(struct its_vm *vm)
irq_domain_free_irqs(irq, 16);
irq_domain_remove(vm->vpes[i]->sgi_domain);
irq_domain_free_fwnode(vm->vpes[i]->fwnode);
+ vm->vpes[i]->sgi_domain = NULL;
+ vm->vpes[i]->fwnode = NULL;
}
}
@@ -224,6 +234,8 @@ void its_free_vcpu_irqs(struct its_vm *vm)
irq_domain_free_irqs(vm->vpes[0]->irq, vm->nr_vpes);
irq_domain_remove(vm->domain);
irq_domain_free_fwnode(vm->fwnode);
+ vm->domain = NULL;
+ vm->fwnode = NULL;
}
static int its_send_vpe_cmd(struct its_vpe *vpe, struct its_cmd_info *info)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 066/742] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (64 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 065/742] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 067/742] reset: scmi: Set the device for the reset controller Greg Kroah-Hartman
` (660 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Yuan Yao, Fuad Tabba, Marc Zyngier,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <fuad.tabba@linux.dev>
[ Upstream commit fd86d69c951765e24e89a162c53dfe33a8aba976 ]
A failure in the its_alloc_vcpu_sgis() loop leaves behind both the SGI
domains created for the vPEs below the failing index and the vPE irqs
allocated before the loop, since irq_domain_remove() frees neither. Each
leaked vPE takes its ITS state with it, a vpe_id and an LPI pending
table.
Free both from a second label before the existing unwind. With the
freed pointers now cleared, its_free_sgi_irqs() can skip a vPE with no
SGI domain and be reused there. The check has to precede the lookup:
irq_find_mapping(NULL, 0) falls back to irq_default_domain, and the
live irq it returns would then be freed.
Fixes: 6d31b6ff985d ("irqchip/gic-v4.1: Add VSGI allocation/teardown")
Reviewed-by: Yuan Yao <yaoyuan@linux.alibaba.com>
Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
Link: https://patch.msgid.link/20260921072958.2918477-3-fuad.tabba@linux.dev
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/irqchip/irq-gic-v4.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
index 754839e409f88..f707a3cb281aa 100644
--- a/drivers/irqchip/irq-gic-v4.c
+++ b/drivers/irqchip/irq-gic-v4.c
@@ -159,6 +159,8 @@ static int its_alloc_vcpu_sgis(struct its_vpe *vpe, int idx)
return -ENOMEM;
}
+static void its_free_sgi_irqs(struct its_vm *vm);
+
int its_alloc_vcpu_irqs(struct its_vm *vm)
{
int vpe_base_irq, i;
@@ -189,11 +191,14 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
vm->vpes[i]->irq = vpe_base_irq + i;
ret = its_alloc_vcpu_sgis(vm->vpes[i], i);
if (ret)
- goto err;
+ goto err_free_irqs;
}
return 0;
+err_free_irqs:
+ its_free_sgi_irqs(vm);
+ irq_domain_free_irqs(vpe_base_irq, vm->nr_vpes);
err:
if (vm->domain) {
irq_domain_remove(vm->domain);
@@ -215,8 +220,13 @@ static void its_free_sgi_irqs(struct its_vm *vm)
return;
for (i = 0; i < vm->nr_vpes; i++) {
- unsigned int irq = irq_find_mapping(vm->vpes[i]->sgi_domain, 0);
+ unsigned int irq;
+
+ /* irq_find_mapping() falls back to the default domain on NULL. */
+ if (!vm->vpes[i]->sgi_domain)
+ continue;
+ irq = irq_find_mapping(vm->vpes[i]->sgi_domain, 0);
if (WARN_ON(!irq))
continue;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 067/742] reset: scmi: Set the device for the reset controller
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (65 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 066/742] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 068/742] irqchip/gic-v4: Use a separate lockdep class for vPE doorbell IRQs Greg Kroah-Hartman
` (659 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kunihiko Hayashi, Sudeep Holla,
Philipp Zabel, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
[ Upstream commit e3e068a457cebe2e475535685c325d5ca305f44a ]
SCMI reset driver does not set rcdev.dev when registering its reset
controller.
If rcdev.of_node is not available, the reset core tries to obtain
the firmware node from rcdev.dev. However, rcdev.dev is also NULL,
causing a NULL pointer dereference.
Set rcdev.dev to the SCMI device.
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Reviewed-by: Sudeep Holla <sudeep.holla@kernel.org>
Fixes: c8ae9c2da1cc ("reset: Add support for resets provided by SCMI")
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/reset/reset-scmi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/reset/reset-scmi.c b/drivers/reset/reset-scmi.c
index 4335811e0cfaa..0fdf593b09e24 100644
--- a/drivers/reset/reset-scmi.c
+++ b/drivers/reset/reset-scmi.c
@@ -107,6 +107,7 @@ static int scmi_reset_probe(struct scmi_device *sdev)
data->rcdev.ops = &scmi_reset_ops;
data->rcdev.owner = THIS_MODULE;
+ data->rcdev.dev = dev;
data->rcdev.of_node = np;
data->rcdev.nr_resets = reset_ops->num_domains_get(ph);
data->ph = ph;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 068/742] irqchip/gic-v4: Use a separate lockdep class for vPE doorbell IRQs
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (66 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 067/742] reset: scmi: Set the device for the reset controller Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 069/742] reset: spacemit: Fix the RCPU2 PWM reset registers Greg Kroah-Hartman
` (658 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Colton Lewis, Marc Zyngier,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colton Lewis <coltonlewis@google.com>
[ Upstream commit 7100185bdc1162eb2eca1dd20a036314e27f1561 ]
By default, init_desc() assigns the shared irq_desc_lock_class lockdep
key to desc->lock for every struct irq_desc. Device drivers that
register an IRQ affinity notifier establish a lock dependency chain of
&irq_desc_lock_class --> &pool->lock --> &p->pi_lock --> &rq->__lock
when irq_set_affinity_locked() calls schedule_work() while holding
desc->lock.
On GICv4 systems, scheduling out a KVM vCPU calls kvm_sched_out() ->
kvm_arch_vcpu_put() -> vgic_v3_put() -> vgic_v4_put() ->
its_make_vpe_non_resident() -> irq_set_vcpu_affinity() while holding the
scheduler runqueue lock (&rq->__lock). Acquiring the vPE doorbell IRQ's
desc->lock establishes &rq->__lock --> &irq_desc_lock_class, triggering
a lockdep circular locking splat:
WARNING: possible circular locking dependency detected
------------------------------------------------------
VCPU-0/109705 is trying to acquire lock:
ffff0001e41e4cc8 (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0x5c/0xb0
but task is already holding lock:
ffff00dad15fd260 (&rq->__lock){-.-.}-{2:2}, at: __schedule+0x23c/0x1850
which lock already depends on the new lock.
Chain exists of:
&irq_desc_lock_class --> &p->pi_lock --> &rq->__lock
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&rq->__lock);
lock(&p->pi_lock);
lock(&rq->__lock);
lock(&irq_desc_lock_class);
GICv4 vPE doorbell IRQs are internal to KVM and GICv4, set
IRQ_NO_BALANCING, and never register an affinity notifier or queue work
under desc->lock. However, under forced IRQ threading (threadirqs or
CONFIG_PREEMPT_RT), request_irq() creates an IRQ thread for the doorbell
handler, causing irq_set_affinity() -> irq_set_thread_affinity() in
vgic_v4_load() to call wake_up_process() under desc->lock and establish
a real desc->lock --> &p->pi_lock --> &rq->__lock dependency on the vPE
doorbell IRQ itself.
Mark vPE doorbell IRQs with irq_set_nothread() so they are never
force-threaded, and assign them a dedicated lockdep class in
its_alloc_vcpu_irqs() via irq_set_lockdep_class().
Fixes: 8e01d9a396e6 ("KVM: arm64: vgic-v4: Move the GICv4 residency flow to be driven by vcpu_load/put")
Signed-off-by: Colton Lewis <coltonlewis@google.com>
Link: https://patch.msgid.link/20261027180610.2840837-1-coltonlewis@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/irqchip/irq-gic-v4.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
index f707a3cb281aa..019aa0ded1bf9 100644
--- a/drivers/irqchip/irq-gic-v4.c
+++ b/drivers/irqchip/irq-gic-v4.c
@@ -163,6 +163,8 @@ static void its_free_sgi_irqs(struct its_vm *vm);
int its_alloc_vcpu_irqs(struct its_vm *vm)
{
+ static struct lock_class_key vpe_irq_lock_class;
+ static struct lock_class_key vpe_irq_request_class;
int vpe_base_irq, i;
vm->fwnode = irq_domain_alloc_named_id_fwnode("GICv4-vpe",
@@ -189,6 +191,9 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
for (i = 0; i < vm->nr_vpes; i++) {
int ret;
vm->vpes[i]->irq = vpe_base_irq + i;
+ irq_set_lockdep_class(vm->vpes[i]->irq, &vpe_irq_lock_class,
+ &vpe_irq_request_class);
+ irq_set_nothread(vm->vpes[i]->irq);
ret = its_alloc_vcpu_sgis(vm->vpes[i], i);
if (ret)
goto err_free_irqs;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 069/742] reset: spacemit: Fix the RCPU2 PWM reset registers
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (67 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 068/742] irqchip/gic-v4: Use a separate lockdep class for vPE doorbell IRQs Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 070/742] reset: Fix reset_control leak when put after controller unregister Greg Kroah-Hartman
` (657 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Hung-Chun Tseng, Yixun Lan,
Troy Mitchell, Philipp Zabel, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hung-Chun Tseng <alan.tseng.cs@gmail.com>
[ Upstream commit 168cae7e87463c34758db2b51537937a29b753f1 ]
Every entry in k1_rcpu2_resets[] uses RCPU2_PWM9_CLK_RST, so asserting
or deasserting the reset of any RCPU2 PWM from 0 to 8 acts on PWM9
instead. Each PWM has its own register, RCPU2_PWMn_CLK_RST at offset
4 * n, as k1-syscon.h already defines.
On a Milk-V Jupiter running the vendor kernel, which uses RCPU2 PWM2
for the fan, the RCPU2 registers read:
0x00: 0x4 0x04: 0x4 0x08: 0x1 0x0c: 0x4 ... 0x24: 0x4
Only PWM2's register has its reset deasserted, which matches one
register per PWM.
Use the matching register for each reset. No in-tree device tree uses
the RCPU2 PWMs yet, so this has no effect on current boards, but it
would break the first one that does.
Build-tested only (riscv defconfig, W=1); the fix could not be tested
at runtime, as mainline has no RCPU2 PWM node to exercise it.
Fixes: c479d7cf06c3 ("reset: spacemit: add support for SpacemiT CCU resets")
Signed-off-by: Hung-Chun Tseng <alan.tseng.cs@gmail.com>
Reviewed-by: Yixun Lan <dlan@kernel.org>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/reset/spacemit/reset-spacemit-k1.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/reset/spacemit/reset-spacemit-k1.c b/drivers/reset/spacemit/reset-spacemit-k1.c
index 8f3b5329ea5f6..dbd783c138b1b 100644
--- a/drivers/reset/spacemit/reset-spacemit-k1.c
+++ b/drivers/reset/spacemit/reset-spacemit-k1.c
@@ -154,15 +154,15 @@ static const struct ccu_reset_controller_data k1_rcpu_reset_data = {
};
static const struct ccu_reset_data k1_rcpu2_resets[] = {
- [RESET_RCPU2_PWM0] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)),
- [RESET_RCPU2_PWM1] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)),
- [RESET_RCPU2_PWM2] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)),
- [RESET_RCPU2_PWM3] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)),
- [RESET_RCPU2_PWM4] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)),
- [RESET_RCPU2_PWM5] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)),
- [RESET_RCPU2_PWM6] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)),
- [RESET_RCPU2_PWM7] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)),
- [RESET_RCPU2_PWM8] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)),
+ [RESET_RCPU2_PWM0] = RESET_DATA(RCPU2_PWM0_CLK_RST, BIT(2), BIT(0)),
+ [RESET_RCPU2_PWM1] = RESET_DATA(RCPU2_PWM1_CLK_RST, BIT(2), BIT(0)),
+ [RESET_RCPU2_PWM2] = RESET_DATA(RCPU2_PWM2_CLK_RST, BIT(2), BIT(0)),
+ [RESET_RCPU2_PWM3] = RESET_DATA(RCPU2_PWM3_CLK_RST, BIT(2), BIT(0)),
+ [RESET_RCPU2_PWM4] = RESET_DATA(RCPU2_PWM4_CLK_RST, BIT(2), BIT(0)),
+ [RESET_RCPU2_PWM5] = RESET_DATA(RCPU2_PWM5_CLK_RST, BIT(2), BIT(0)),
+ [RESET_RCPU2_PWM6] = RESET_DATA(RCPU2_PWM6_CLK_RST, BIT(2), BIT(0)),
+ [RESET_RCPU2_PWM7] = RESET_DATA(RCPU2_PWM7_CLK_RST, BIT(2), BIT(0)),
+ [RESET_RCPU2_PWM8] = RESET_DATA(RCPU2_PWM8_CLK_RST, BIT(2), BIT(0)),
[RESET_RCPU2_PWM9] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)),
};
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 070/742] reset: Fix reset_control leak when put after controller unregister
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (68 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 069/742] reset: spacemit: Fix the RCPU2 PWM reset registers Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 071/742] reset: Fix circular locking dependency in reset_controller_unregister() Greg Kroah-Hartman
` (656 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tzung-Bi Shih, Philipp Zabel,
Bartosz Golaszewski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tzung-Bi Shih <tzungbi@kernel.org>
[ Upstream commit f06482ceb314c8dc19f3d084b29c27af237556b5 ]
After commit 8c91302a29bc ("reset: protect struct reset_control with its
own mutex"), reset_control_put_internal() returns early if `rcdev` is
NULL.
When a reset controller is unregistered while consumers still hold
reset_control handles, reset_controller_unregister() sets `rstc->rcdev`
to NULL. When consumers later release their handles via
reset_control_put(), the early return skips kref_put(), resulting in
leaking resources.
Call kref_put() in reset_control_put_internal() even if `rcdev` is NULL.
Fixes: 8c91302a29bc ("reset: protect struct reset_control with its own mutex")
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/reset/core.c | 47 ++++++++++++++++++++++++++++++++------------
1 file changed, 34 insertions(+), 13 deletions(-)
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 38e189d04d09b..f0ab09795ae1b 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -160,6 +160,9 @@ int reset_controller_register(struct reset_controller_dev *rcdev)
}
EXPORT_SYMBOL_GPL(reset_controller_register);
+static void __reset_control_release(struct kref *kref);
+static void __reset_control_free(struct reset_control *rstc);
+
static void reset_controller_remove(struct reset_controller_dev *rcdev,
struct reset_control *rstc)
{
@@ -185,11 +188,18 @@ void reset_controller_unregister(struct reset_controller_dev *rcdev)
/*
* Numb but don't free the remaining reset control handles that are
* still held by consumers.
+ *
+ * Hold a temporary reference on rstc before clearing rstc->rcdev:
+ * once rstc->rcdev is NULL, a concurrent reset_control_put_internal()
+ * will not acquire rcdev->lock and could otherwise free rstc.
*/
list_for_each_entry_safe(rstc, pos, &rcdev->reset_control_head, list) {
+ kref_get(&rstc->refcnt);
rcu_assign_pointer(rstc->rcdev, NULL);
synchronize_srcu(&rstc->srcu);
reset_controller_remove(rcdev, rstc);
+ if (kref_put(&rstc->refcnt, __reset_control_release))
+ __reset_control_free(rstc);
}
}
@@ -886,14 +896,16 @@ __reset_control_get_internal(struct reset_controller_dev *rcdev,
return rstc;
}
+/*
+ * Detaches rstc from rcdev (if still attached) when refcnt reaches 0.
+ * If rstc is still attached, the caller must hold rcdev->lock.
+ */
static void __reset_control_release(struct kref *kref)
{
struct reset_control *rstc = container_of(kref, struct reset_control,
refcnt);
struct reset_controller_dev *rcdev;
- lockdep_assert_held(&rstc->srcu);
-
rcdev = rcu_replace_pointer(rstc->rcdev, NULL, true);
if (rcdev) {
lockdep_assert_held(&rcdev->lock);
@@ -903,6 +915,17 @@ static void __reset_control_release(struct kref *kref)
mutex_destroy(&rstc->lock);
}
+/*
+ * Must be called outside the rstc->srcu read-side critical section after
+ * kref_put(..., __reset_control_release) returns true.
+ */
+static void __reset_control_free(struct reset_control *rstc)
+{
+ synchronize_srcu(&rstc->srcu);
+ cleanup_srcu_struct(&rstc->srcu);
+ kfree(rstc);
+}
+
static void reset_control_put_internal(struct reset_control *rstc)
{
struct reset_controller_dev *rcdev;
@@ -913,19 +936,17 @@ static void reset_control_put_internal(struct reset_control *rstc)
scoped_guard(srcu, &rstc->srcu) {
rcdev = srcu_dereference(rstc->rcdev, &rstc->srcu);
- if (!rcdev)
- /* Already released. */
- return;
-
- guard(mutex)(&rcdev->lock);
- ret = kref_put(&rstc->refcnt, __reset_control_release);
+ if (rcdev) {
+ guard(mutex)(&rcdev->lock);
+ ret = kref_put(&rstc->refcnt, __reset_control_release);
+ } else {
+ /* Already detached from rcdev. */
+ ret = kref_put(&rstc->refcnt, __reset_control_release);
+ }
}
- if (ret) {
- synchronize_srcu(&rstc->srcu);
- cleanup_srcu_struct(&rstc->srcu);
- kfree(rstc);
- }
+ if (ret)
+ __reset_control_free(rstc);
}
static void reset_gpio_aux_device_release(struct device *dev)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 071/742] reset: Fix circular locking dependency in reset_controller_unregister()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (69 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 070/742] reset: Fix reset_control leak when put after controller unregister Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 072/742] drm/msm/gem: Fix VM_BIND range check Greg Kroah-Hartman
` (655 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tzung-Bi Shih, Philipp Zabel,
Bartosz Golaszewski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tzung-Bi Shih <tzungbi@kernel.org>
[ Upstream commit d1f583c1eab5e4432c7ad48a8abd27cffbc8a549 ]
reset_control_acquire() and reset_control_put_internal() acquire
`rcdev->lock` inside the `rstc->srcu` read-side critical section
(`rstc->srcu` -> `rcdev->lock`).
However, reset_controller_unregister() holds `rcdev->lock` while calling
synchronize_srcu(&rstc->srcu) (`rcdev->lock` -> `rstc->srcu`), causing a
lockdep circular locking dependency warning and a potential ABBA
deadlock.
Run synchronize_srcu() outside `rcdev->lock`.
Fixes: 44a0acb2caca ("reset: protect struct reset_controller_dev with its own mutex")
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/reset/core.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index f0ab09795ae1b..4a582721782f4 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -163,11 +163,15 @@ EXPORT_SYMBOL_GPL(reset_controller_register);
static void __reset_control_release(struct kref *kref);
static void __reset_control_free(struct reset_control *rstc);
+/*
+ * Removes rstc from its list and drops the references on rcdev's owner module
+ * and device. The caller must ensure rstc->list access is serialized (e.g.,
+ * by holding rcdev->lock or moving rstc to a private list) and that no
+ * operations on rcdev via rstc are in flight.
+ */
static void reset_controller_remove(struct reset_controller_dev *rcdev,
struct reset_control *rstc)
{
- lockdep_assert_held(&rcdev->lock);
-
list_del(&rstc->list);
module_put(rcdev->owner);
put_device(rcdev->dev);
@@ -180,6 +184,7 @@ static void reset_controller_remove(struct reset_controller_dev *rcdev,
void reset_controller_unregister(struct reset_controller_dev *rcdev)
{
struct reset_control *rstc, *pos;
+ LIST_HEAD(reset_control_head);
scoped_guard(mutex, &reset_list_mutex)
list_del(&rcdev->list);
@@ -196,13 +201,22 @@ void reset_controller_unregister(struct reset_controller_dev *rcdev)
list_for_each_entry_safe(rstc, pos, &rcdev->reset_control_head, list) {
kref_get(&rstc->refcnt);
rcu_assign_pointer(rstc->rcdev, NULL);
- synchronize_srcu(&rstc->srcu);
- reset_controller_remove(rcdev, rstc);
- if (kref_put(&rstc->refcnt, __reset_control_release))
- __reset_control_free(rstc);
+ list_move(&rstc->list, &reset_control_head);
}
}
+ /*
+ * Run synchronize_srcu() outside rcdev->lock to avoid a circular
+ * locking dependency with paths that acquire rcdev->lock inside
+ * the rstc->srcu read-side critical section.
+ */
+ list_for_each_entry_safe(rstc, pos, &reset_control_head, list) {
+ synchronize_srcu(&rstc->srcu);
+ reset_controller_remove(rcdev, rstc);
+ if (kref_put(&rstc->refcnt, __reset_control_release))
+ __reset_control_free(rstc);
+ }
+
mutex_destroy(&rcdev->lock);
}
EXPORT_SYMBOL_GPL(reset_controller_unregister);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 072/742] drm/msm/gem: Fix VM_BIND range check
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (70 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 071/742] reset: Fix circular locking dependency in reset_controller_unregister() Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 073/742] drm/msm/gem: Disallow nr_bos for VM_BIND contexts Greg Kroah-Hartman
` (654 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Konrad Dybcio, Dmitry Baryshkov,
Rob Clark, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <robin.clark@oss.qualcomm.com>
[ Upstream commit 4f0af27c3aef5a9480712cbac4bee14f7509ae5f ]
Use size_add() to guard against overflow.
Reported-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Fixes: 3a3bef68a6c1 ("drm/msm: Fix missing VM_BIND offset/range validation")
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/765329/
Message-ID: <20261102172001.508440-2-robin.clark@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/msm/msm_gem_vma.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c
index 1badec3caa7b8..67de27c3ae550 100644
--- a/drivers/gpu/drm/msm/msm_gem_vma.c
+++ b/drivers/gpu/drm/msm/msm_gem_vma.c
@@ -1012,10 +1012,10 @@ lookup_op(struct msm_vm_bind_job *job, const struct drm_msm_vm_bind_op *op)
if (invalid_alignment(op->iova))
ret = UERR(EINVAL, dev, "invalid address: %016llx\n", op->iova);
- if (invalid_alignment(op->obj_offset))
+ if (invalid_alignment(op->obj_offset) || (op->obj_offset > SIZE_MAX))
ret = UERR(EINVAL, dev, "invalid bo_offset: %016llx\n", op->obj_offset);
- if (invalid_alignment(op->range))
+ if (invalid_alignment(op->range) || (op->range > SIZE_MAX) || !op->range)
ret = UERR(EINVAL, dev, "invalid range: %016llx\n", op->range);
if (!drm_gpuvm_range_valid(job->vm, op->iova, op->range))
@@ -1118,7 +1118,7 @@ vm_bind_job_lookup_ops(struct msm_vm_bind_job *job, struct drm_msm_vm_bind *args
op->obj = obj;
cnt++;
- if ((op->range + op->obj_offset) > obj->size) {
+ if (size_add(op->range, op->obj_offset) > obj->size) {
ret = UERR(EINVAL, dev, "invalid range: %016llx + %016llx > %016zx\n",
op->range, op->obj_offset, obj->size);
goto out_unlock;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 073/742] drm/msm/gem: Disallow nr_bos for VM_BIND contexts
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (71 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 072/742] drm/msm/gem: Fix VM_BIND range check Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 074/742] drm/msm/gem: Decrement loop idx if handle lookup fails Greg Kroah-Hartman
` (653 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dmitry Baryshkov, Rob Clark,
Konrad Dybcio, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <robin.clark@oss.qualcomm.com>
[ Upstream commit b3b44f7508c7f01273ba773595b7787883ceb4e0 ]
If using VM_BIND, it is invalid to attach BOs to a GEM_SUBMIT ioctl.
Only the VM_BIND ioctl should be used for binding objects.
Fixes: 2e6a8a1fe2b2 ("drm/msm: Add VM_BIND ioctl")
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/765330/
Message-ID: <20261102172001.508440-3-robin.clark@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/msm/msm_gem_submit.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index 5862db05297a7..c03410c568a5a 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -272,7 +272,7 @@ static int submit_lock_objects_vmbind(struct msm_gem_submit *submit)
struct drm_exec *exec = &submit->exec;
int ret = 0;
- drm_exec_init(&submit->exec, flags, submit->nr_bos);
+ drm_exec_init(&submit->exec, flags, 0);
submit->has_exec = true;
drm_exec_until_all_locked (&submit->exec) {
@@ -589,6 +589,9 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
return -EINVAL;
}
+ if (msm_context_is_vmbind(ctx) && args->nr_bos)
+ return UERR(EINVAL, dev, "invalid nr_bos, must be zero for VM_BIND contexts");
+
queue = msm_submitqueue_get(ctx, args->queueid);
if (!queue)
return -ENOENT;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 074/742] drm/msm/gem: Decrement loop idx if handle lookup fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (72 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 073/742] drm/msm/gem: Disallow nr_bos for VM_BIND contexts Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:58 ` [PATCH 7.3 075/742] drm/msm/gem: Clear nr_ops in lookup_ops() failure path Greg Kroah-Hartman
` (652 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Rob Clark, Konrad Dybcio,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <robin.clark@oss.qualcomm.com>
[ Upstream commit 31708945d3647ad29f91def9d40dafa149ac66f1 ]
In the out_unlock unlock loop, we should skip the op which still has the
gem handle instead of gem obj ptr.
Fixes: 2e6a8a1fe2b2 ("drm/msm: Add VM_BIND ioctl")
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/765328/
Message-ID: <20261102172001.508440-4-robin.clark@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/msm/msm_gem_vma.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c
index 67de27c3ae550..f8892d78f37d2 100644
--- a/drivers/gpu/drm/msm/msm_gem_vma.c
+++ b/drivers/gpu/drm/msm/msm_gem_vma.c
@@ -1110,6 +1110,7 @@ vm_bind_job_lookup_ops(struct msm_vm_bind_job *job, struct drm_msm_vm_bind *args
obj = idr_find(&file->object_idr, op->handle);
if (!obj) {
ret = UERR(EINVAL, dev, "invalid handle %u at index %u\n", op->handle, i);
+ i--;
goto out_unlock;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 075/742] drm/msm/gem: Clear nr_ops in lookup_ops() failure path
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (73 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 074/742] drm/msm/gem: Decrement loop idx if handle lookup fails Greg Kroah-Hartman
@ 2026-12-04 9:58 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 076/742] drm/msm: Fix a lock leak in msm_ioctl_gem_info_set_metadata() Greg Kroah-Hartman
` (651 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:58 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Rob Clark, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <robin.clark@oss.qualcomm.com>
[ Upstream commit b22f5d783eadbebe90481db0c48cecf719e71dad ]
We've already dropped the references taken in the handle lookup loop, so
we don't want to drop them again in msm_vma_job_free().
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Fixes: 2e6a8a1fe2b2 ("drm/msm: Add VM_BIND ioctl")
Patchwork: https://patchwork.freedesktop.org/patch/765324/
Message-ID: <20261102172001.508440-5-robin.clark@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/msm/msm_gem_vma.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c
index f8892d78f37d2..c92ae0bfb66e3 100644
--- a/drivers/gpu/drm/msm/msm_gem_vma.c
+++ b/drivers/gpu/drm/msm/msm_gem_vma.c
@@ -1088,7 +1088,6 @@ vm_bind_job_lookup_ops(struct msm_vm_bind_job *job, struct drm_msm_vm_bind *args
}
if (ret) {
- job->nr_ops = 0;
goto out;
}
@@ -1143,6 +1142,9 @@ vm_bind_job_lookup_ops(struct msm_vm_bind_job *job, struct drm_msm_vm_bind *args
}
}
out:
+ if (ret)
+ job->nr_ops = 0;
+
return ret;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 076/742] drm/msm: Fix a lock leak in msm_ioctl_gem_info_set_metadata()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (74 preceding siblings ...)
2026-12-04 9:58 ` [PATCH 7.3 075/742] drm/msm/gem: Clear nr_ops in lookup_ops() failure path Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 077/742] selftests: drivers/s390x: Select uvdevice tests using the target architecture Greg Kroah-Hartman
` (650 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Bart Van Assche, Rob Clark,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <bvanassche@acm.org>
[ Upstream commit 1e59855738454b14021b64115f0090eafc7526ae ]
If krealloc() fails, msm_ioctl_gem_info_set_metadata() returns without
unlocking the GEM object. Fix this by jumping to a new label that
unlocks the GEM object before the buffer is freed. This bug has been
detected by the Clang thread-safety analyzer.
Fixes: 1c8c354098ea ("drm/msm: Add error handling for krealloc in metadata setup")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Patchwork: https://patchwork.freedesktop.org/patch/763272/
Message-ID: <9671164f87138a0caf5c69b66129bbd6faf932f8.1793044688.git.bvanassche@acm.org>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/msm/msm_drv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index f3d2eaa04f142..0227f46a4963a 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -498,13 +498,14 @@ static int msm_ioctl_gem_info_set_metadata(struct drm_gem_object *obj,
krealloc(msm_obj->metadata, metadata_size, GFP_KERNEL);
if (!new_metadata) {
ret = -ENOMEM;
- goto out;
+ goto unlock;
}
msm_obj->metadata = new_metadata;
msm_obj->metadata_size = metadata_size;
memcpy(msm_obj->metadata, buf, metadata_size);
+unlock:
msm_gem_unlock(obj);
out:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 077/742] selftests: drivers/s390x: Select uvdevice tests using the target architecture
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (75 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 076/742] drm/msm: Fix a lock leak in msm_ioctl_gem_info_set_metadata() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 078/742] phy: ingenic: fix unbalanced regulator disable in exit Greg Kroah-Hartman
` (649 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sasha Levin, Steffen Eiden,
Christian Borntraeger
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sasha Levin <sashal@kernel.org>
[ Upstream commit 62aef2c04e0e69a9b88affa74ff699ce5c4e8652 ]
The uvdevice Makefile decides whether to build its test from uname -m,
which describes the build host. A cross build for s390 on another host
therefore silently omits the test, while the non-s390 branch provides
no-op build and installation targets but no emit_tests target.
Select the test from the target ARCH when it is given and from the
host's SUBARCH otherwise, accepting both the s390 and s390x spellings,
and include lib.mk unconditionally so that other architectures build,
install and emit an empty runlist. ARCH itself is left unset so that a
native LLVM=1 build keeps using the compiler's native target.
Drop the include path derived from tools/arch/$(ARCH): the test only
needs asm/uvdevice.h from the installed kernel headers, and the path
does not exist for the s390x spelling.
Fixes: cbac924200b8 ("selftests: drivers/s390x: Add uvdevice tests")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../selftests/drivers/s390x/uvdevice/Makefile | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/drivers/s390x/uvdevice/Makefile b/tools/testing/selftests/drivers/s390x/uvdevice/Makefile
index 755d164384c46..586a9aa6fb158 100644
--- a/tools/testing/selftests/drivers/s390x/uvdevice/Makefile
+++ b/tools/testing/selftests/drivers/s390x/uvdevice/Makefile
@@ -1,20 +1,13 @@
include ../../../../../build/Build.include
-UNAME_M := $(shell uname -m)
-
-ifneq ($(UNAME_M),s390x)
-nothing:
-.PHONY: all clean run_tests install
-.SILENT:
-else
+top_srcdir ?= ../../../../../..
+include $(top_srcdir)/scripts/subarch.include
+ARCH_PROCESSED := $(or $(ARCH),$(SUBARCH))
+ifneq (,$(filter s390 s390x,$(ARCH_PROCESSED)))
TEST_GEN_PROGS := test_uvdevice
-top_srcdir ?= ../../../../../..
-LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
-
-CFLAGS += -Wall -Werror -static $(KHDR_INCLUDES) -I$(LINUX_TOOL_ARCH_INCLUDE)
+CFLAGS += -Wall -Werror -static $(KHDR_INCLUDES)
+endif
include ../../../lib.mk
-
-endif
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 078/742] phy: ingenic: fix unbalanced regulator disable in exit
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (76 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 077/742] selftests: drivers/s390x: Select uvdevice tests using the target architecture Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 080/742] phy: ti: pipe3: Fix clock resource leak on probe errors Greg Kroah-Hartman
` (648 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Felix Gu, Manivannan Sadhasivam,
Paul Cercueil, Olivier Louvignes, H. Nikolaus Schaller,
Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <ustc.gu@gmail.com>
[ Upstream commit 71c1be5cc4e083852c8437bd6afcb99ee3050e8e ]
exit() and power_off() both disable vcc_supply, so the regulator
gets disabled twice for every power cycle, causing an unbalanced
disable WARN.
Drop the regulator_disable() call from the exit callback and leave
the regulator to the power_on/power_off pair.
Fixes: 31de313dfdcf ("PHY: Ingenic: Add USB PHY driver using generic PHY framework.")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Tested-by: Olivier Louvignes <olivier@mgcrea.io>
Reviewed-By: H. Nikolaus Schaller <hns@goldelico.com>
Link: https://patch.msgid.link/20260906-ingenic-v1-1-2311f3df8ddc@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/phy/ingenic/phy-ingenic-usb.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/phy/ingenic/phy-ingenic-usb.c b/drivers/phy/ingenic/phy-ingenic-usb.c
index 7e62d46850fda..d8e5ef302b748 100644
--- a/drivers/phy/ingenic/phy-ingenic-usb.c
+++ b/drivers/phy/ingenic/phy-ingenic-usb.c
@@ -124,7 +124,6 @@ static int ingenic_usb_phy_exit(struct phy *phy)
struct ingenic_usb_phy *priv = phy_get_drvdata(phy);
clk_disable_unprepare(priv->clk);
- regulator_disable(priv->vcc_supply);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 080/742] phy: ti: pipe3: Fix clock resource leak on probe errors
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (77 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 078/742] phy: ingenic: fix unbalanced regulator disable in exit Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 081/742] phy: ti-pipe3: Fix EPROBE_DEFER handling for clock resources Greg Kroah-Hartman
` (647 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Hongling Zeng, Manivannan Sadhasivam,
Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <zenghongling@kylinos.cn>
[ Upstream commit 6dc01e3516d79cf4d690d892499a0bd08a14285b ]
When devm_phy_create() or devm_of_phy_provider_register() fails,
the refclk that was enabled earlier is not disabled, causing a
resource leak.
Fix this by adding an error handling path to disable the clock
when these functions fail.
Fixes: 234738ea3390 ("phy: ti-pipe3: move clk initialization to a separate function")
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/20260909122630.1313205-3-zenghongling@kylinos.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/phy/ti/phy-ti-pipe3.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index 0e3bc92187338..021657cbce481 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -834,21 +834,39 @@ static int ti_pipe3_probe(struct platform_device *pdev)
*/
if (phy->mode == PIPE3_MODE_SATA) {
if (!IS_ERR(phy->refclk)) {
- clk_prepare_enable(phy->refclk);
+ ret = clk_prepare_enable(phy->refclk);
+ if (ret) {
+ dev_err(dev, "Failed to enable refclk %d\n", ret);
+ goto err_pm_disable;
+ }
phy->sata_refclk_enabled = true;
}
}
generic_phy = devm_phy_create(dev, NULL, &ops);
- if (IS_ERR(generic_phy))
- return PTR_ERR(generic_phy);
+ if (IS_ERR(generic_phy)) {
+ ret = PTR_ERR(generic_phy);
+ goto err_clk_disable;
+ }
phy_set_drvdata(generic_phy, phy);
ti_pipe3_power_off(generic_phy);
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
- return PTR_ERR_OR_ZERO(phy_provider);
+ if (IS_ERR(phy_provider)) {
+ ret = PTR_ERR(phy_provider);
+ goto err_clk_disable;
+ }
+
+ return 0;
+
+err_clk_disable:
+ if (phy->sata_refclk_enabled)
+ clk_disable_unprepare(phy->refclk);
+err_pm_disable:
+ pm_runtime_disable(dev);
+ return ret;
}
static void ti_pipe3_remove(struct platform_device *pdev)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 081/742] phy: ti-pipe3: Fix EPROBE_DEFER handling for clock resources
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (78 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 080/742] phy: ti: pipe3: Fix clock resource leak on probe errors Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 083/742] Revert "phy: qcom: qmp-pcie: Skip PHY reset if already up" Greg Kroah-Hartman
` (646 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Manivannan Sadhasivam, Hongling Zeng,
Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <zenghongling@kylinos.cn>
[ Upstream commit aeb637c73631851de0965514151f7ff7bc13f940 ]
ti_pipe3_get_clk() has two issues with -EPROBE_DEFER error handling:
1. When devm_clk_get() for sysclk fails, the function returns -EINVAL
instead of propagating the actual error code. This masks -EPROBE_DEFER
to -EINVAL, breaking the probe deferral mechanism and causing permanent
driver initialization failure on systems with non-deterministic probe
ordering.
2. For SATA PHY refclk, the function ignores all errors to support older
DTBs missing the refclk property. However, this incorrectly ignores
-EPROBE_DEFER as well, causing the driver to proceed without waiting
for the clock provider to become available.
Fix both issues:
- Return PTR_ERR(phy->sys_clk) instead of -EINVAL to propagate all
error codes including -EPROBE_DEFER
- Use devm_clk_get_optional() for SATA refclk to handle optional
clocks while propagating -EPROBE_DEFER and other errors
Fixes: a70143bbef6b ("drivers: phy: usb3/pipe3: Adapt pipe3 driver to Generic PHY Framework")
Fixes: 7f33912d2978 ("phy: ti-pipe3: Fix SATA across suspend/resume")
Suggested-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/20260909122630.1313205-4-zenghongling@kylinos.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/phy/ti/phy-ti-pipe3.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index 021657cbce481..fdd81c935e5f3 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -608,14 +608,20 @@ static int ti_pipe3_get_clk(struct ti_pipe3 *phy)
struct clk *clk;
struct device *dev = phy->dev;
- phy->refclk = devm_clk_get(dev, "refclk");
+ /*
+ * refclk is optional for SATA PHY to support older DTBs, but
+ * required for other modes. Use devm_clk_get_optional() for SATA
+ * which returns NULL for -ENOENT, allowing us to propagate all
+ * other errors including -EPROBE_DEFER.
+ */
+ if (phy->mode == PIPE3_MODE_SATA)
+ phy->refclk = devm_clk_get_optional(dev, "refclk");
+ else
+ phy->refclk = devm_clk_get(dev, "refclk");
+
if (IS_ERR(phy->refclk)) {
- dev_err(dev, "unable to get refclk\n");
- /* older DTBs have missing refclk in SATA PHY
- * so don't bail out in case of SATA PHY.
- */
- if (phy->mode != PIPE3_MODE_SATA)
- return PTR_ERR(phy->refclk);
+ return dev_err_probe(dev, PTR_ERR(phy->refclk),
+ "unable to get refclk\n");
}
if (phy->mode != PIPE3_MODE_SATA) {
@@ -631,8 +637,8 @@ static int ti_pipe3_get_clk(struct ti_pipe3 *phy)
if (phy->mode != PIPE3_MODE_PCIE || phy->phy_power_syscon) {
phy->sys_clk = devm_clk_get(dev, "sysclk");
if (IS_ERR(phy->sys_clk)) {
- dev_err(dev, "unable to get sysclk\n");
- return -EINVAL;
+ return dev_err_probe(dev, PTR_ERR(phy->sys_clk),
+ "unable to get sysclk\n");
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 083/742] Revert "phy: qcom: qmp-pcie: Skip PHY reset if already up"
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (79 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 081/742] phy: ti-pipe3: Fix EPROBE_DEFER handling for clock resources Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 084/742] phy: rockchip: naneng-combphy: Fix overwritten PLL SSC control bit Greg Kroah-Hartman
` (645 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Michael Burch, Manivannan Sadhasivam,
Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Burch <me@michaelburch.net>
[ Upstream commit 9a07dfa7f6fe34e230de183c02a8180529091649 ]
This reverts commit 910b828b22b7b91054b3bd4be676a017444b0e00.
That commit skips the no-csr reset assert/deassert (and the 200-300us
settle) whenever the bootloader already brought the PCIe QMP PHY up:
skip_reset = qmp->skip_init &&
!qphy_checkbits(pcs, cfg->regs[QPHY_PCS_STATUS],
cfg->phy_status);
and states its own assumption explicitly: "This relies on the assumption
that when skip_init is enabled and the PHY is reported as up, the
bootloader has already configured the PHY correctly and the link is in a
usable state."
That assumption does not hold on the Dell XPS 13 9345 (X1E80100). UEFI
boots from the NVMe behind pcie6a, so the PHY is always already started
when Linux takes over, skip_init is true, and the reset is skipped. The
link then never retrains and the root port comes up with no endpoint:
qcom-pcie 1bf8000.pcie: Device found, but not active
pci 0006:00:00.0: [17cb:0111] type 01 class 0x060400 PCIe Root Port
(no 0006:01:00.0, no nvme at all)
"Device found, but not active" is dw_pcie_wait_for_link() reporting LTSSM
stuck in POLL.Active/POLL.Compliance -- receiver detected, training never
completes -- so the machine cannot find its root filesystem and drops to
a dracut emergency shell. v7.2 is unaffected because it always performed
the reset.
The commit was applied on its own as patch 1/4 of "PCI: qcom: Add link
retention support"; 2/4-4/4 have not landed. Without them,
qcom_pcie_host_init() still asserts PERST# and resets the controller
before qcom_pcie_phy_power_on(), so the link is down while
QPHY_PCS_STATUS still reports the bootloader's state, and the skip's
precondition never holds. Revert it until the rest of the series lands.
Fixes: 910b828b22b7 ("phy: qcom: qmp-pcie: Skip PHY reset if already up")
Signed-off-by: Michael Burch <me@michaelburch.net>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/20261013-qmp-pcie-skip-reset-revert-v1@michaelburch.net
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 31 ++++++++----------------
1 file changed, 10 insertions(+), 21 deletions(-)
diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
index da83358c97ead..17c53ae62fac7 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
@@ -5677,7 +5677,6 @@ static int qmp_pcie_init(struct phy *phy)
struct qmp_pcie *qmp = phy_get_drvdata(phy);
const struct qmp_phy_cfg *cfg = qmp->cfg;
void __iomem *pcs = qmp->pcs;
- bool skip_reset;
int ret;
/*
@@ -5693,9 +5692,6 @@ static int qmp_pcie_init(struct phy *phy)
qphy_checkbits(pcs, cfg->regs[QPHY_START_CTRL], SERDES_START | PCS_START) &&
qphy_checkbits(pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], cfg->pwrdn_ctrl);
- skip_reset = qmp->skip_init && !qphy_checkbits(pcs, cfg->regs[QPHY_PCS_STATUS],
- cfg->phy_status);
-
if (!qmp->skip_init && !cfg->tbls.serdes_num) {
dev_err(qmp->dev, "Init sequence not available\n");
return -ENODATA;
@@ -5719,16 +5715,14 @@ static int qmp_pcie_init(struct phy *phy)
}
}
- if (!skip_reset) {
- ret = reset_control_assert(qmp->nocsr_reset);
- if (ret) {
- dev_err(qmp->dev, "no-csr reset assert failed\n");
- goto err_assert_reset;
- }
-
- usleep_range(200, 300);
+ ret = reset_control_assert(qmp->nocsr_reset);
+ if (ret) {
+ dev_err(qmp->dev, "no-csr reset assert failed\n");
+ goto err_assert_reset;
}
+ usleep_range(200, 300);
+
if (!qmp->skip_init) {
ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets);
if (ret) {
@@ -5777,11 +5771,8 @@ static int qmp_pcie_power_on(struct phy *phy)
void __iomem *pcs = qmp->pcs;
void __iomem *status;
unsigned int mask, val;
- bool skip_reset;
int ret;
- skip_reset = qmp->skip_init && !qphy_checkbits(pcs, cfg->regs[QPHY_PCS_STATUS],
- cfg->phy_status);
/*
* Write CSR register for PHY that doesn't support no_csr reset or has not
* been initialized.
@@ -5805,12 +5796,10 @@ static int qmp_pcie_power_on(struct phy *phy)
if (ret)
return ret;
- if (!skip_reset) {
- ret = reset_control_deassert(qmp->nocsr_reset);
- if (ret) {
- dev_err(qmp->dev, "no-csr reset deassert failed\n");
- goto err_disable_pipe_clk;
- }
+ ret = reset_control_deassert(qmp->nocsr_reset);
+ if (ret) {
+ dev_err(qmp->dev, "no-csr reset deassert failed\n");
+ goto err_disable_pipe_clk;
}
if (qmp->skip_init)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 084/742] phy: rockchip: naneng-combphy: Fix overwritten PLL SSC control bit
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (80 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 083/742] Revert "phy: qcom: qmp-pcie: Skip PHY reset if already up" Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 085/742] phy: PHY_GOOGLE_USB should depend on ARCH_GOOGLE Greg Kroah-Hartman
` (644 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Shawn Lin, Manivannan Sadhasivam,
Sebastian Reichel, Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shawn Lin <shawn.lin@rock-chips.com>
[ Upstream commit 96246dc6c16a5e5a6b4b9fde8f4ab9cdeb201088 ]
rk_combphy_common_cfg_ssc() first sets RK3568_PHYREG33_PLL_SSC_CTRL on the
RK3588 and RK3576 SoCs, then, for PCIe at 24MHz, programs the PLL KVCO
adjust field. The latter used a plain writel() of the FIELD_PREP() value,
which cleared all the other bits of RK3568_PHYREG33, including the
PLL_SSC_CTRL bit that had just been set a few lines above.
Use rockchip_combphy_updatel() so that only the KVCO field is updated and
the SSC control bit is preserved, as the comment and the pre-consolidation
code intended.
Fixes: 0b31f297557f ("phy: rockchip: naneng-combphy: Consolidate SSC configuration")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://patch.msgid.link/1792036787-37927-1-git-send-email-shawn.lin@rock-chips.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/phy/rockchip/phy-rockchip-naneng-combphy.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c
index 3102a99128f62..b6cc010327831 100644
--- a/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c
+++ b/drivers/phy/rockchip/phy-rockchip-naneng-combphy.c
@@ -526,7 +526,8 @@ static void rk_combphy_common_cfg_ssc(struct rockchip_combphy_priv *priv, unsign
val = FIELD_PREP(RK3568_PHYREG33_PLL_KVCO_MASK,
RK3576_PHYREG33_PLL_KVCO_VALUE);
- writel(val, priv->mmio + RK3568_PHYREG33);
+ rockchip_combphy_updatel(priv, RK3568_PHYREG33_PLL_KVCO_MASK,
+ val, RK3568_PHYREG33);
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 085/742] phy: PHY_GOOGLE_USB should depend on ARCH_GOOGLE
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (81 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 084/742] phy: rockchip: naneng-combphy: Fix overwritten PLL SSC control bit Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 086/742] ksmbd: sign the last response of a compound that ends early Greg Kroah-Hartman
` (643 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Geert Uytterhoeven,
Manivannan Sadhasivam, Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <geert+renesas@glider.be>
[ Upstream commit 518d5bc7a636696969e3f4a7f9c66483e4f35e1e ]
The Google Tensor SoC USB PHY is only present on Google Tensor G5
(Laguna) SoCs. Hence add a dependency on ARCH_GOOGLE, to prevent asking
the user about this driver when configuring a kernel without Google
Tensor SoC support.
Fixes: cbce66669c82ee9a ("phy: Add Google Tensor SoC USB PHY driver")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Link: https://patch.msgid.link/90a172c2980073a09b4f01c21a251c3d0d2d6fe5.1792499240.git.geert+renesas@glider.be
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/phy/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 19f3b7d12b7d4..d142e16bb1562 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -93,6 +93,7 @@ config PHY_ECONET_PCIE
config PHY_GOOGLE_USB
tristate "Google Tensor SoC USB PHY driver"
+ depends on ARCH_GOOGLE || COMPILE_TEST
select GENERIC_PHY
depends on TYPEC
help
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 086/742] ksmbd: sign the last response of a compound that ends early
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (82 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 085/742] phy: PHY_GOOGLE_USB should depend on ARCH_GOOGLE Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 087/742] wifi: iwlwifi: mvm: correctly check the API version Greg Kroah-Hartman
` (642 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Michail Andreas Michalopoulos,
Ian Bridges, Namjae Jeon, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michail Andreas Michalopoulos <mike.michalo@gmail.com>
[ Upstream commit 3d322b98b56628ee69e4528a52cc1f445880fa17 ]
is_chained_smb2_message() ends a compound early when the next command
does not fit in the request, or its response would not fit in the
response buffer. Since commit e2b76ab8b5c9 ("ksmbd: add support for
read compound"), __handle_ksmbd_work() then signs ksmbd_resp_buf_curr(),
which is_chained_smb2_message() only moves to the response of the
command just processed when it chains to the next command or reaches
the last one. On an early end it returns without moving it, so for a
command after the first, the previous command's response was signed
again, over the iovecs of both responses, and the response of this
command was left unsigned. Neither signature verifies at the client.
Handle an early end as the end of the compound: pad the response to 8
bytes and make it the current one. smb2_allocate_rsp_buf() leaves room
for that padding in the response buffer of a compound.
Only a compound whose NextCommand points past the end of the message,
or whose responses fill the response buffer, takes this path. Sashiko
pointed it out in its review of an unrelated series.
An AI assistant was used to draft the patch and as an independent
reviewer.
Fixes: e2b76ab8b5c9 ("ksmbd: add support for read compound")
Signed-off-by: Michail Andreas Michalopoulos <mike.michalo@gmail.com>
Reviewed-by: Ian Bridges <icb@fastmail.org>
Tested-by: Ian Bridges <icb@fastmail.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/smb/server/smb2pdu.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index c8e87c7c8bc21..213310bc41a18 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -702,7 +702,7 @@ bool is_chained_smb2_message(struct ksmbd_work *work)
get_rfc1002_len(work->request_buf)) {
pr_err("next command(%u) offset exceeds smb msg size\n",
next_cmd);
- return false;
+ goto last_rsp;
}
/*
@@ -719,16 +719,21 @@ bool is_chained_smb2_message(struct ksmbd_work *work)
if ((u64)ALIGN(get_rfc1002_len(work->response_buf), 8) +
next_rsp_sz > work->response_sz) {
pr_err("next response offset exceeds response buffer size\n");
- return false;
+ goto last_rsp;
}
ksmbd_debug(SMB, "got SMB2 chained command\n");
init_chained_smb2_rsp(work);
return true;
- } else if (work->next_smb2_rcv_hdr_off) {
+ }
+
+last_rsp:
+ if (work->next_smb2_rcv_hdr_off) {
/*
- * This is last request in chained command,
- * align response to 8 byte
+ * This is the last response of a compound, also when the
+ * compound ends early because the next command does not fit.
+ * Align it to 8 bytes and make it the current response, which
+ * is the one the caller signs.
*/
len = ALIGN(get_rfc1002_len(work->response_buf), 8);
len = len - get_rfc1002_len(work->response_buf);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 087/742] wifi: iwlwifi: mvm: correctly check the API version
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (83 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 086/742] ksmbd: sign the last response of a compound that ends early Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 088/742] wifi: ath9k: make sure we stop the wmi tasklet on init fail Greg Kroah-Hartman
` (641 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Miri Korenblit, Sasha Levin,
Chris Bainbridge
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miri Korenblit <miriam.rachel.korenblit@intel.com>
[ Upstream commit 06cfbf21b33772266a03a580182b74233f41f2b2 ]
The check for the firmware version for the reset handshake
was wrong. mvm->fw->ucode_ver is the major number itself.
No need to mask it with IWL_UCODE_MAJOR.
We could look at the major number from IWL_UCODE_TLV_FW_VERSION
but we don't remember that number and looking at fw->ucode_ver
is good enough.
Fixes: 0eaa1f245ac0 ("wifi: iwlwifi: mvm: don't support the reset handshake for old firmwares")
Reported-and-tested-by: Chris Bainbridge <chris.bainbridge@gmail.com>
Link: https://lore.kernel.org/linux-wireless/amzVtgQb2p-_nShU@debian.local/
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20261114193144.ab54bc9717fc.I8cda260e2ef7aedd790915a17cb6832010f82aa4@changeid
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index 1dd27292af9b8..c59644f258e13 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -1413,15 +1413,13 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_rf_cfg *cfg,
sizeof(mvm->hw->wiphy->fw_version),
"%.31s", fw->fw_version);
- trans->conf.fw_reset_handshake =
- fw_has_capa(&mvm->fw->ucode_capa,
- IWL_UCODE_TLV_CAPA_FW_RESET_HANDSHAKE);
-
- /* Those firmware versions claim to support the fw_reset_handshake
+ /* Some firmware versions claim to support the fw_reset_handshake
* but they are buggy.
*/
- if (IWL_UCODE_MAJOR(mvm->fw->ucode_ver) <= 77)
- trans->conf.fw_reset_handshake = false;
+ trans->conf.fw_reset_handshake =
+ fw_has_capa(&mvm->fw->ucode_capa,
+ IWL_UCODE_TLV_CAPA_FW_RESET_HANDSHAKE) &&
+ mvm->fw->ucode_ver > 77;
trans->conf.queue_alloc_cmd_ver =
iwl_fw_lookup_cmd_ver(mvm->fw,
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 088/742] wifi: ath9k: make sure we stop the wmi tasklet on init fail
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (84 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 087/742] wifi: iwlwifi: mvm: correctly check the API version Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 089/742] scsi: lpfc: Fix race conditions in ELS retry handling Greg Kroah-Hartman
` (640 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, syzbot+e91dc13b1b37759b3d9f,
Toke Høiland-Jørgensen, Eduard Zateev, Johannes Berg,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Toke Høiland-Jørgensen <toke@toke.dk>
[ Upstream commit ec95877e2ea1c655e914c34fa23fd51e32315fec ]
The ath9k_wmi_event_tasklet() reschedules itself until device
initialisation is complete, but if the initialisation fails it is never
interrupted. Syzbot triggered a use-after-free in tasklet_action_common
because of this.
Add a guard to the reschedule logic so it aborts if wmi->stopped is set,
and add a call to ath9k_wmi_event_drain() in ath9k_stop_wmi(), so we are
sure that the queue is drained and the tasklet is stopped on teardown.
Fixes: 1af8dc9ca726 ("wifi: ath9k: Clean up device initialisation guards")
Reported-by: syzbot+e91dc13b1b37759b3d9f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e91dc13b1b37759b3d9f
Tested-by: syzbot+e91dc13b1b37759b3d9f@syzkaller.appspotmail.com
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Tested-by: Eduard Zateev <hackerowskiy@gmail.com>
Link: https://patch.msgid.link/20261021120237.481898-1-toke@toke.dk
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/wireless/ath/ath9k/wmi.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c
index 44e91815a1594..520bb2347dfcd 100644
--- a/drivers/net/wireless/ath/ath9k/wmi.c
+++ b/drivers/net/wireless/ath/ath9k/wmi.c
@@ -118,6 +118,8 @@ void ath9k_stop_wmi(struct ath9k_htc_priv *priv)
mutex_lock(&wmi->op_mutex);
wmi->stopped = true;
mutex_unlock(&wmi->op_mutex);
+
+ ath9k_wmi_event_drain(priv);
}
void ath9k_destroy_wmi(struct ath9k_htc_priv *priv)
@@ -148,7 +150,8 @@ void ath9k_wmi_event_tasklet(struct tasklet_struct *t)
/* Check if ath9k_init_device() completed. */
if (!smp_load_acquire(&priv->initialized)) {
- tasklet_schedule(t);
+ if (!READ_ONCE(wmi->stopped))
+ tasklet_schedule(t);
return;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 089/742] scsi: lpfc: Fix race conditions in ELS retry handling
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (85 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 088/742] wifi: ath9k: make sure we stop the wmi tasklet on init fail Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 090/742] scsi: ch: Remove the minor from ch_index_idr after device_destroy() Greg Kroah-Hartman
` (639 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kyle Mahlkuch, Hannes Reinecke,
Paul Ely, Martin K. Petersen (Oracle), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Mahlkuch <kmahlkuc@linux.ibm.com>
[ Upstream commit 7470a1f2a84d68d177560b78388e640771b6b94a ]
This patch addresses a race condition in the lpfc driver's ELS retry event
handling that can lead to a use-after-free in the
lpfc_cancel_retry_delay_tmo(), where the NLP_DELAY_TMO flag is cleared
before acquiring the lock to check if the retry event is queued. This
creates a window where the timer can be rescheduled and fire, causing both
the cancel path and the worker thread to release the same reference,
resulting in a double-put and use-after-free.
Moved capture ndlp and clear evt_arg1 under hbalock while dequeuing
LPFC_EVT_ELS_RETRY in lpfc_work_list_done().
Signed-off-by: Kyle Mahlkuch <kmahlkuc@linux.ibm.com>
Fixes: e47c9093531d ("[SCSI] lpfc 8.2.5 : Correct ndlp referencing issues")
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Paul Ely <pely@broadcom.com>
Link: https://patch.msgid.link/dcea48dd-f76c-4bb0-9275-c12ef9bd78a2@linux.ibm.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/lpfc/lpfc_els.c | 29 +++++++++++++++++++++++------
drivers/scsi/lpfc/lpfc_hbadisc.c | 11 ++++++++++-
2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 52fc5058976d9..176dccd4b6347 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -4477,18 +4477,35 @@ lpfc_issue_els_edc(struct lpfc_vport *vport, uint8_t retry)
void
lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct lpfc_nodelist *nlp)
{
- struct lpfc_work_evt *evtp;
+ struct lpfc_hba *phba = vport->phba;
+ struct lpfc_work_evt *evtp = &nlp->els_retry_evt;
+ struct lpfc_nodelist *arg_ndlp = NULL;
+ unsigned long flags;
if (!test_and_clear_bit(NLP_DELAY_TMO, &nlp->nlp_flag))
return;
timer_delete_sync(&nlp->nlp_delayfunc);
nlp->nlp_last_elscmd = 0;
- if (!list_empty(&nlp->els_retry_evt.evt_listp)) {
- list_del_init(&nlp->els_retry_evt.evt_listp);
- /* Decrement nlp reference count held for the delayed retry */
- evtp = &nlp->els_retry_evt;
- lpfc_nlp_put((struct lpfc_nodelist *)evtp->evt_arg1);
+
+ /*
+ * If retry event is queued, remove it under lock and consume
+ * its payload to prevent double-put. The event holds a reference
+ * to the nodelist that must be released exactly once.
+ */
+ spin_lock_irqsave(&phba->hbalock, flags);
+ if (!list_empty(&evtp->evt_listp)) {
+ list_del_init(&evtp->evt_listp);
+ /* Take local copy and clear to prevent reuse */
+ arg_ndlp = (struct lpfc_nodelist *)evtp->evt_arg1;
+ evtp->evt_arg1 = NULL;
+ smp_wmb(); /* Ensure NULL visible before unlock */
}
+ spin_unlock_irqrestore(&phba->hbalock, flags);
+
+ /* Drop the event-held reference outside the lock */
+ if (arg_ndlp)
+ lpfc_nlp_put(arg_ndlp);
+
if (test_and_clear_bit(NLP_NPR_2B_DISC, &nlp->nlp_flag)) {
if (vport->num_disc_nodes) {
if (vport->port_state < LPFC_VPORT_READY) {
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index c9b02d2c63054..d105b8eb53faa 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -840,12 +840,21 @@ lpfc_work_list_done(struct lpfc_hba *phba)
while (!list_empty(&phba->work_list)) {
list_remove_head((&phba->work_list), evtp, typeof(*evtp),
evt_listp);
+ /*
+ * The ELS retry event can be requeued by lpfc_els_retry_delay()
+ * as soon as hbalock is dropped. Consume the payload within the
+ * hbalock to prevent reuse or double-put.
+ */
+ if (evtp->evt == LPFC_EVT_ELS_RETRY) {
+ ndlp = (struct lpfc_nodelist *)(evtp->evt_arg1);
+ evtp->evt_arg1 = NULL;
+ }
spin_unlock_irq(&phba->hbalock);
hba_pci_err = test_bit(HBA_PCI_ERR, &phba->bit_flags);
free_evt = 1;
switch (evtp->evt) {
case LPFC_EVT_ELS_RETRY:
- ndlp = (struct lpfc_nodelist *) (evtp->evt_arg1);
+ /* ndlp was already captured under hbalock */
if (!hba_pci_err) {
lpfc_els_retry_delay_handler(ndlp);
free_evt = 0; /* evt is part of ndlp */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 090/742] scsi: ch: Remove the minor from ch_index_idr after device_destroy()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (86 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 089/742] scsi: lpfc: Fix race conditions in ELS retry handling Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 091/742] Bluetooth: L2CAP: return LE credits from recvmsg under the conn lock Greg Kroah-Hartman
` (638 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Changyul Lee, Laurence Oberman,
Martin K. Petersen (Oracle), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Changyul Lee <lcy8047@gmail.com>
[ Upstream commit 9f9e0b1e5399045982788a954d3461de894e40c7 ]
ch_remove() removes the minor from ch_index_idr before device_destroy()
removes the "sch<N>" device. A changer probed in between can get the same
minor, and its device_create() fails:
sysfs: cannot create duplicate filename '/class/scsi_changer/sch0'
...
ch 1:0:0:0: ch0: device_create failed
The new changer is then not attached.
Replace the IDR entry with NULL instead, so that ch_open() still fails with
-ENXIO for the changer being removed, and remove the minor after
device_destroy().
Fixes: da707c54c342 ("[SCSI] ch: fix device minor number management bug")
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
Reviewed-by: Laurence Oberman <loberman@redhat.com>
Link: https://patch.msgid.link/20261109160651.986356-1-lcy8047@gmail.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/ch.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index cc4532c7782f1..6474929f86a67 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -961,11 +961,15 @@ static void ch_remove(struct scsi_device *sd)
scsi_changer *ch = dev_get_drvdata(dev);
spin_lock(&ch_index_lock);
- idr_remove(&ch_index_idr, ch->minor);
+ idr_replace(&ch_index_idr, NULL, ch->minor);
dev_set_drvdata(dev, NULL);
spin_unlock(&ch_index_lock);
device_destroy(&ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR, ch->minor));
+
+ spin_lock(&ch_index_lock);
+ idr_remove(&ch_index_idr, ch->minor);
+ spin_unlock(&ch_index_lock);
scsi_device_put(ch->device);
kref_put(&ch->ref, ch_destroy);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 091/742] Bluetooth: L2CAP: return LE credits from recvmsg under the conn lock
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (87 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 090/742] scsi: ch: Remove the minor from ch_index_idr after device_destroy() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 092/742] Bluetooth: L2CAP: Use a reserved ident for L2CAP_LE_CREDITS Greg Kroah-Hartman
` (637 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, syzbot+9dc8780713b11155dd74,
Nguyen Ngoc Thang, Luiz Augusto von Dentz, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
[ Upstream commit 5beb86f98c3d45f6d64be5b6d6c77480487b41b4 ]
l2cap_chan_le_send_credits() allocates an ident from conn->tx_ida, sends
L2CAP_LE_CREDITS and frees the ident right away, since the command has
no response. The RX path frees idents in l2cap_put_ident() under
conn->lock. That only works if the credits path holds conn->lock too,
so that no response can be processed between the allocation and the
free.
The RX path does, but l2cap_sock_recvmsg() calls l2cap_publish_rx_avail()
-> l2cap_chan_rx_avail() -> l2cap_chan_le_send_credits() with only the
socket lock held. If the remote answers the credits packet with
L2CAP_COMMAND_REJ, l2cap_put_ident() can free the ident first, and the
credits path then frees it again:
ida_free called for id=3 which is not allocated.
WARNING: lib/idr.c:594 at ida_free+0x24c/0x2d4 lib/idr.c:594
Call trace:
ida_free+0x24c/0x2d4 lib/idr.c:594
l2cap_chan_le_send_credits+0x17c/0x29c net/bluetooth/l2cap_core.c:7113
l2cap_chan_rx_avail+0xb4/0x134 net/bluetooth/l2cap_core.c:7126
l2cap_publish_rx_avail+0x110/0x168 net/bluetooth/l2cap_sock.c
l2cap_sock_recvmsg+0x280/0x7b8 net/bluetooth/l2cap_sock.c:1317
The same unlocked call also updates chan->rx_credits and reads chan->sdu
concurrently with the RX path.
Publish rx_avail from recvmsg under conn->lock and chan->lock, taken with
l2cap_chan_lock_conn() as l2cap_sock_defer() already does, before taking
the socket lock to keep the conn->lock -> chan->lock -> sk_lock order.
Assert conn->lock in l2cap_chan_le_send_credits() so that an unlocked
caller is caught by lockdep.
Fixes: 6e1930ece855 ("Bluetooth: L2CAP: fix tx ident leak for commands without a response")
Reported-by: syzbot+9dc8780713b11155dd74@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=9dc8780713b11155dd74
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stable-dep-of: 06b6fbe05f5c ("Bluetooth: L2CAP: Use a reserved ident for L2CAP_LE_CREDITS")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/l2cap_core.c | 3 +++
net/bluetooth/l2cap_sock.c | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 7ac5dd0fb6fe4..eeeddb3ced8cd 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -6967,6 +6967,9 @@ static void l2cap_chan_le_send_credits(struct l2cap_chan *chan)
pkt.cid = cpu_to_le16(chan->scid);
pkt.credits = cpu_to_le16(return_credits);
+ /* Keeps l2cap_put_ident() from releasing ident before we do */
+ lockdep_assert_held(&conn->lock);
+
ident = l2cap_get_ident(conn);
l2cap_send_cmd(conn, ident, L2CAP_LE_CREDITS, sizeof(pkt), &pkt);
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index f413e5beab9e4..c7fe12445df42 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1292,6 +1292,7 @@ static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
{
struct sock *sk = sock->sk;
struct l2cap_pinfo *pi = l2cap_pi(sk);
+ bool have_conn;
int err;
if (unlikely(flags & MSG_ERRQUEUE))
@@ -1312,9 +1313,12 @@ static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
pi->chan->mode != L2CAP_MODE_EXT_FLOWCTL)
return err;
- lock_sock(sk);
-
+ /* Returning credits must be serialized with the RX path */
+ have_conn = l2cap_chan_lock_conn(pi->chan);
l2cap_publish_rx_avail(pi->chan);
+ l2cap_chan_unlock_conn(pi->chan, have_conn);
+
+ lock_sock(sk);
/* Attempt to put pending rx data in the socket buffer */
while (!list_empty(&pi->rx_busy)) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 092/742] Bluetooth: L2CAP: Use a reserved ident for L2CAP_LE_CREDITS
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (88 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 091/742] Bluetooth: L2CAP: return LE credits from recvmsg under the conn lock Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 093/742] kho: do not expose incoming sub-blob contents in debugfs Greg Kroah-Hartman
` (636 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, syzbot+9dc8780713b11155dd74,
Nguyen Ngoc Thang, Luiz Augusto von Dentz, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
[ Upstream commit 06b6fbe05f5c81654815ec8d864d792a226cbdac ]
L2CAP_LE_CREDITS has no response, so an ident taken from conn->tx_ida for
it is never released by l2cap_put_ident() and l2cap_chan_le_send_credits()
has to free it right away after sending, otherwise the range is exhausted
after 254 packets and credits would be sent with the invalid ident 0, which
some remote stacks ignore, stalling the channel.
tx_ida only exists to track requests awaiting a response, so a command
without one has no business in it: every credit update allocates and
frees an ident, and the ident is visible in tx_ida while the credits are
in flight, so an answer to them (a L2CAP_COMMAND_REJ) is processed by
l2cap_put_ident() like the answer to a request.
Using a counter that doesn't consult tx_ida is not an option either, it can
return the ident of a request still outstanding, and a reject of the
credits would then release that request's ident and close its channel in
l2cap_le_command_rej().
Reserve ident 255 for L2CAP_LE_CREDITS instead: l2cap_get_ident() never
returns it (the BR/EDR range already ends at 128), so it can't collide with
any request, it doesn't have to be tracked in conn->tx_ida, and a reject of
it matches no outstanding request.
Fixes: 6e1930ece855 ("Bluetooth: L2CAP: fix tx ident leak for commands without a response")
Reported-by: syzbot+9dc8780713b11155dd74@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=9dc8780713b11155dd74
Signed-off-by: Nguyen Ngoc Thang <ngocthang2710.1999@gmail.com>
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/net/bluetooth/l2cap.h | 5 +++++
net/bluetooth/l2cap_core.c | 28 +++++++++++-----------------
2 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index b864d50bb5e59..9dc7fc5b2a275 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -45,6 +45,11 @@
#define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF
#define L2CAP_BREDR_MAX_PAYLOAD 1019 /* 3-DH5 packet */
#define L2CAP_LE_MIN_MTU 23
+
+/* Identifier used by L2CAP_LE_CREDITS, it has no response so it is not
+ * tracked in conn->tx_ida and is never allocated for any other command.
+ */
+#define L2CAP_IDENT_LE_CREDITS 255
#define L2CAP_ECRED_CONN_SCID_MAX 5
#define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index eeeddb3ced8cd..59ae6ee4ff345 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1022,9 +1022,11 @@ static int l2cap_get_ident(struct l2cap_conn *conn)
u8 max;
int ident;
- /* LE link does not support tools like l2ping so use the full range */
+ /* LE link does not support tools like l2ping so use the full range,
+ * except for L2CAP_IDENT_LE_CREDITS which is reserved.
+ */
if (conn->hcon->type == LE_LINK)
- max = 255;
+ max = L2CAP_IDENT_LE_CREDITS - 1;
/* Get next available identificator.
* 1 - 128 are used by kernel.
* 129 - 199 are reserved.
@@ -6949,7 +6951,6 @@ static void l2cap_chan_le_send_credits(struct l2cap_chan *chan)
struct l2cap_conn *conn = chan->conn;
struct l2cap_le_credits pkt;
u16 return_credits = l2cap_le_rx_credits(chan);
- int ident;
if (chan->mode != L2CAP_MODE_LE_FLOWCTL &&
chan->mode != L2CAP_MODE_EXT_FLOWCTL)
@@ -6967,21 +6968,14 @@ static void l2cap_chan_le_send_credits(struct l2cap_chan *chan)
pkt.cid = cpu_to_le16(chan->scid);
pkt.credits = cpu_to_le16(return_credits);
- /* Keeps l2cap_put_ident() from releasing ident before we do */
- lockdep_assert_held(&conn->lock);
-
- ident = l2cap_get_ident(conn);
-
- l2cap_send_cmd(conn, ident, L2CAP_LE_CREDITS, sizeof(pkt), &pkt);
-
- /* L2CAP_LE_CREDITS has no response so the ident is never released by
- * l2cap_put_ident() - release it right away, otherwise the tx_ida
- * range is exhausted after 254 packets and from then on credits are
- * sent with the invalid ident 0, which some remote stacks ignore,
- * stalling the channel.
+ /* L2CAP_LE_CREDITS has no response so it uses the reserved ident rather
+ * than one from conn->tx_ida, which would have to be released right
+ * away or would be exhausted after 254 packets, and could otherwise
+ * collide with the ident of a request still outstanding. A reject of it
+ * can't match any request either.
*/
- if (ident > 0)
- ida_free(&conn->tx_ida, ident);
+ l2cap_send_cmd(conn, L2CAP_IDENT_LE_CREDITS, L2CAP_LE_CREDITS,
+ sizeof(pkt), &pkt);
}
void l2cap_chan_rx_avail(struct l2cap_chan *chan, ssize_t rx_avail)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 093/742] kho: do not expose incoming sub-blob contents in debugfs
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (89 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 092/742] Bluetooth: L2CAP: Use a reserved ident for L2CAP_LE_CREDITS Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 094/742] phy: rockchip: snps-pcie3: Raise the SRAM init timeout Greg Kroah-Hartman
` (635 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Pasha Tatashin, Long Wei,
Pratyush Yadav, Mike Rapoport (Microsoft), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Long Wei <longwei27@huawei.com>
[ Upstream commit fa1c0f103fd68558613d3df76e222463c6e4fc37 ]
Incoming sub-blob pages are owned by their consumers and have independent
lifetimes. Some consumers, such as LUO, restore and free their state in
early_initcall, i.e. before kho_init() (fs_initcall) builds the debugfs
view:
early_initcall: luo_early_startup()
-> kho_retrieve_subtree("LUO")
-> kho_restore_free(luo_ser) /* page is freed */
fs_initcall: kho_init()
-> kho_in_debugfs_init()
-> phys_to_virt(luo_ser_phys)
-> debugfs_create_blob("LUO", ...)
debugfs therefore ends up pointing at a page that was already handed back
to the page allocator, and reading the file triggers a use-after-free:
# cat /sys/kernel/debug/kho/in/sub_fdts/LUO
==================================================================
BUG: KASAN: use-after-free in _copy_to_user+0x37/0x60
Read of size 32 at addr ffff88810309c000 by task cat/27436
Call Trace:
<TASK>
kasan_report+0xb9/0xf0
kasan_check_range+0x100/0x1b0
_copy_to_user+0x37/0x60
simple_read_from_buffer+0x77/0xd0
read_file_blob+0x75/0xa0
vfs_read+0x12d/0x520
ksys_read+0xc3/0x160
do_syscall_64+0x97/0x4b0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
</TASK>
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x1fd
pfn:0x10309c
flags: 0x17ffffc0000000(node=0|zone=2|lastcpupid=0x1fffff)
page_type: f0(buddy)
==================================================================
The page is already in the buddy allocator (page_type: f0(buddy),
refcount 0), which confirms it was freed before the debugfs view was
created.
KHO does not own these pages, so it cannot safely expose their contents at
all. Drop the in/sub_fdts directory. The incoming FDT is reserved by KHO
and remains exposed as in/fdt, where the same metadata is available.
The incoming sub-blob debugfs directory is gone, so remove its description
from the KHO admin guide as well.
Note that in/sub_fdts has exposed memory KHO does not own since
commit c609c144b0e8 ("kexec: add KHO parsing support"), but the
use-after-free only became reachable after commit d376e4b55c9a0
("liveupdate: centralize state management into struct luo_ser") which
added kho_restore_free()
Fixes: d376e4b55c9a0 ("liveupdate: centralize state management into struct luo_ser")
Acked-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: Long Wei <longwei27@huawei.com>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Link: https://patch.msgid.link/20261119095937.826980-1-longwei27@huawei.com
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Documentation/admin-guide/mm/kho.rst | 4 --
kernel/liveupdate/kexec_handover_debugfs.c | 47 +---------------------
2 files changed, 2 insertions(+), 49 deletions(-)
diff --git a/Documentation/admin-guide/mm/kho.rst b/Documentation/admin-guide/mm/kho.rst
index 2c26e560bd78a..2f339cf152812 100644
--- a/Documentation/admin-guide/mm/kho.rst
+++ b/Documentation/admin-guide/mm/kho.rst
@@ -117,7 +117,3 @@ stabilized.
kernel's state is in this file in the format of flattened
device tree. This file may disappear when all consumers of
it finished to interpret their metadata.
-
-``/sys/kernel/debug/kho/in/sub_fdts/``
- Similar to ``kho/out/sub_fdts/``, but contains sub blobs
- of KHO producers passed from the old kernel.
diff --git a/kernel/liveupdate/kexec_handover_debugfs.c b/kernel/liveupdate/kexec_handover_debugfs.c
index 257ee8a52be66..cb330c1a01ac5 100644
--- a/kernel/liveupdate/kexec_handover_debugfs.c
+++ b/kernel/liveupdate/kexec_handover_debugfs.c
@@ -10,7 +10,6 @@
#define pr_fmt(fmt) "KHO: " fmt
#include <linux/init.h>
-#include <linux/io.h>
#include <linux/libfdt.h>
#include <linux/mm.h>
#include <linux/kho/abi/kexec_handover.h>
@@ -97,8 +96,8 @@ DEFINE_SHOW_ATTRIBUTE(scratch_len);
__init void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt)
{
- struct dentry *dir, *sub_fdt_dir;
- int err, child;
+ struct dentry *dir;
+ int err;
INIT_LIST_HEAD(&dbg->fdt_list);
@@ -108,54 +107,12 @@ __init void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt)
goto err_out;
}
- sub_fdt_dir = debugfs_create_dir("sub_fdts", dir);
- if (IS_ERR(sub_fdt_dir)) {
- err = PTR_ERR(sub_fdt_dir);
- goto err_rmdir;
- }
-
err = __kho_debugfs_blob_add(&dbg->fdt_list, dir, "fdt", fdt,
fdt_totalsize(fdt));
if (err)
goto err_rmdir;
- fdt_for_each_subnode(child, fdt, 0) {
- int len = 0;
- const char *name = fdt_get_name(fdt, child, NULL);
- const u64 *blob_phys;
- const u64 *blob_size;
- void *blob;
-
- blob_phys = fdt_getprop(fdt, child,
- KHO_SUB_TREE_PROP_NAME, &len);
- if (!blob_phys)
- continue;
- if (len != sizeof(*blob_phys)) {
- pr_warn("node %s prop %s has invalid length: %d\n",
- name, KHO_SUB_TREE_PROP_NAME, len);
- continue;
- }
-
- blob_size = fdt_getprop(fdt, child,
- KHO_SUB_TREE_SIZE_PROP_NAME, &len);
- if (!blob_size || len != sizeof(*blob_size)) {
- pr_warn("node %s missing or invalid %s property\n",
- name, KHO_SUB_TREE_SIZE_PROP_NAME);
- continue;
- }
-
- blob = phys_to_virt(*blob_phys);
- err = __kho_debugfs_blob_add(&dbg->fdt_list, sub_fdt_dir, name,
- blob, *blob_size);
- if (err) {
- pr_warn("failed to add blob %s to debugfs: %pe\n",
- name, ERR_PTR(err));
- continue;
- }
- }
-
dbg->dir = dir;
- dbg->sub_fdt_dir = sub_fdt_dir;
return;
err_rmdir:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 094/742] phy: rockchip: snps-pcie3: Raise the SRAM init timeout
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (90 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 093/742] kho: do not expose incoming sub-blob contents in debugfs Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 095/742] Bluetooth: mgmt: Fix read_index_list() buffer overflow Greg Kroah-Hartman
` (634 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sebastian Reichel,
Manivannan Sadhasivam, Shawn Lin, Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shawn Lin <shawn.lin@rock-chips.com>
[ Upstream commit 7c2a2268bd3ddf3b2c674ebb7557ae24c22309d7 ]
The SRAM initialization of the PCIe3 PHY may take longer than the 500us
currently allowed, especially on a slow power-up such as at low
temperature. In that case the driver reports
lock failed 0x..., check input refclk and power supply
even though the input refclk and power supply are fine.
Raise the timeout to 20ms and use a named constant for it, applied to
both the RK3568 and RK3588 paths.
A non-zero sleep interval (1ms) is passed to the polling helpers so the
CPU is yielded between reads. With sleep_us == 0 the helpers tight-loop,
which would otherwise burn the CPU during the now much longer wait.
Fixes: 2e9bffc4f713 ("phy: rockchip: Support PCIe v3")
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Link: https://patch.msgid.link/20261102005129.3745527-1-shawn.lin@rock-chips.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/phy/rockchip/phy-rockchip-snps-pcie3.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c b/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c
index 4e8ffd173096a..ce7d8db2a7c5f 100644
--- a/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c
+++ b/drivers/phy/rockchip/phy-rockchip-snps-pcie3.c
@@ -18,6 +18,9 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset.h>
+#include <linux/units.h>
+
+#define RK_PCIE_SRAM_INIT_TIMEOUT_US (20 * USEC_PER_MSEC)
/* Register for RK3568 */
#define GRF_PCIE30PHY_CON1 0x4
@@ -127,7 +130,7 @@ static int rockchip_p3phy_rk3568_init(struct rockchip_p3phy_priv *priv)
ret = regmap_read_poll_timeout(priv->phy_grf,
GRF_PCIE30PHY_STATUS0,
reg, SRAM_INIT_DONE(reg),
- 0, 500);
+ 1000, RK_PCIE_SRAM_INIT_TIMEOUT_US);
if (ret)
dev_err(&priv->phy->dev, "%s: lock failed 0x%x, check input refclk and power supply\n",
__func__, reg);
@@ -187,11 +190,11 @@ static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv)
ret = regmap_read_poll_timeout(priv->phy_grf,
RK3588_PCIE3PHY_GRF_PHY0_STATUS1,
reg, RK3588_SRAM_INIT_DONE(reg),
- 0, 500);
+ 1000, RK_PCIE_SRAM_INIT_TIMEOUT_US);
ret |= regmap_read_poll_timeout(priv->phy_grf,
RK3588_PCIE3PHY_GRF_PHY1_STATUS1,
reg, RK3588_SRAM_INIT_DONE(reg),
- 0, 500);
+ 1000, RK_PCIE_SRAM_INIT_TIMEOUT_US);
if (ret)
dev_err(&priv->phy->dev, "lock failed 0x%x, check input refclk and power supply\n",
reg);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 095/742] Bluetooth: mgmt: Fix read_index_list() buffer overflow
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (91 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 094/742] phy: rockchip: snps-pcie3: Raise the SRAM init timeout Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 096/742] Bluetooth: hci_core: Take req_sync lock in hci_power_on() Greg Kroah-Hartman
` (633 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit cfdd650c5dabbd2f59a0e916aa8ef3f1965a3b4b ]
The first pass counts only configured controllers, but HCI_UNCONFIGURED
can change before the second pass, which may then write more entries than
were allocated. Size the buffer from the total number of controllers as
read_unconf_index_list() already does.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-7841362e-9b8f-465f-aa22-e99c315231e2
Fixes: 73d1df2a7a10 ("Bluetooth: Add support for Read Unconfigured Index List command")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/mgmt.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a287dd4bb26e3..d7f54056d0918 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -444,10 +444,8 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
read_lock(&hci_dev_list_lock);
count = 0;
- list_for_each_entry(d, &hci_dev_list, list) {
- if (!hci_dev_test_flag(d, HCI_UNCONFIGURED))
- count++;
- }
+ list_for_each_entry(d, &hci_dev_list, list)
+ count++;
rp_len = sizeof(*rp) + (2 * count);
rp = kmalloc(rp_len, GFP_ATOMIC);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 096/742] Bluetooth: hci_core: Take req_sync lock in hci_power_on()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (92 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 095/742] Bluetooth: mgmt: Fix read_index_list() buffer overflow Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 097/742] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync() Greg Kroah-Hartman
` (632 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 6a296a4658124490d7dddd2b751e5f9ae5c5aec7 ]
hci_powered_update_sync() issues synchronous HCI commands but was called
without hci_req_sync_lock(), racing with other request users.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-1baf7393-3aeb-4fa5-806f-19cea743b9f3
Fixes: cf75ad8b41d2 ("Bluetooth: hci_sync: Convert MGMT_SET_POWERED")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/hci_core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8784c28297ac2..6433c388050fa 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -915,7 +915,9 @@ static void hci_power_on(struct work_struct *work)
hci_dev_test_flag(hdev, HCI_MGMT) &&
hci_dev_test_and_clear_flag(hdev, HCI_AUTO_OFF)) {
cancel_delayed_work(&hdev->power_off);
+ hci_req_sync_lock(hdev);
err = hci_powered_update_sync(hdev);
+ hci_req_sync_unlock(hdev);
mgmt_power_on(hdev, err);
return;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 097/742] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (93 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 096/742] Bluetooth: hci_core: Take req_sync lock in hci_power_on() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 098/742] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync() Greg Kroah-Hartman
` (631 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 8984b72f9508b2d03c58a82d73881b5e1e5f5bc4 ]
hci_disable_ext_adv_instance_sync() calls hci_find_adv_instance() and
dereferences the instance without hdev->lock, racing with the removal of
the instance. Look the instance up under the lock and only use the values
copied while it is held.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-a364929c-cd00-492a-a83c-5425d042b09f
Fixes: cba6b758711c ("Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/hci_sync.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 8f90e5ffebd47..6227a07fc9566 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -1224,16 +1224,26 @@ static int hci_disable_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)
struct hci_cp_ext_adv_set *set;
u8 data[sizeof(*cp) + sizeof(*set) * 1];
u8 size;
- struct adv_info *adv = NULL;
+ u8 handle = instance;
/* If request specifies an instance that doesn't exist, fail */
if (instance > 0) {
+ struct adv_info *adv;
+ bool enabled = false;
+
+ hci_dev_lock(hdev);
adv = hci_find_adv_instance(hdev, instance);
+ if (adv) {
+ enabled = adv->enabled;
+ handle = adv->handle;
+ }
+ hci_dev_unlock(hdev);
+
if (!adv)
return -EINVAL;
/* If not enabled there is nothing to do */
- if (!adv->enabled)
+ if (!enabled)
return 0;
}
@@ -1246,7 +1256,7 @@ static int hci_disable_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)
cp->num_of_sets = !!instance;
cp->enable = 0x00;
- set->handle = adv ? adv->handle : instance;
+ set->handle = handle;
size = sizeof(*cp) + sizeof(*set) * cp->num_of_sets;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 098/742] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (94 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 097/742] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 099/742] Bluetooth: SMP: Serialize link key updates from smp_notify_keys() Greg Kroah-Hartman
` (630 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit c592dfe9637c65eeaff4c9f6fd869f39ad7ae472 ]
The advertising instance returned by hci_find_adv_instance() was
dereferenced without hdev->lock and could be freed concurrently.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-616b1f8e-06ec-4634-a907-5eb4e82f66df
Fixes: cba6b758711c ("Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/hci_sync.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 6227a07fc9566..adae6e2fee1e1 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -2129,9 +2129,13 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
if (hdev->adv_instance_timeout)
return -EBUSY;
+ hci_dev_lock(hdev);
+
adv = hci_find_adv_instance(hdev, instance);
- if (!adv)
+ if (!adv) {
+ hci_dev_unlock(hdev);
return -ENOENT;
+ }
/* A zero timeout means unlimited advertising. As long as there is
* only one instance, duration should be ignored. We still set a timeout
@@ -2161,6 +2165,8 @@ int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
secs_to_jiffies(timeout));
}
+ hci_dev_unlock(hdev);
+
/* If we're just re-scheduling the same instance again then do not
* execute any HCI commands. This happens when a single instance is
* being advertised.
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 099/742] Bluetooth: SMP: Serialize link key updates from smp_notify_keys()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (95 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 098/742] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 100/742] Bluetooth: SMP: Check smp_data before using SMP_DEV() Greg Kroah-Hartman
` (629 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit e428ab70fb3398e835e5d70ba4839e7c06583b83 ]
smp_notify_keys() runs from the L2CAP RX path without hdev->lock, yet
hci_add_link_key() and the debug key removal modify hdev->link_keys and
dereference entries returned by hci_find_link_key(), so a concurrent
unpair or Load Link Keys can free the entry being updated.
hdev->lock can't be taken there since it is ordered before the l2cap
channel lock held by the SMP receive path (see smp_user_confirm_reply()).
Add a dedicated link_keys_lock protecting the writers of hdev->link_keys
(add, remove and clear). SMP holds it while it adds the key, notifies
mgmt and removes a debug key, so the key can't go away meanwhile, and
the debug key removed by hci_link_key_notify_evt() is deleted by
reference with hci_del_link_key() since a lookup by address skips the
keys that are blocked.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-7482a666-d2a0-44a4-9e0d-05354860a5fa
Fixes: 6a77083af57f ("Bluetooth: Add support for LE SC key generation")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/net/bluetooth/hci_core.h | 6 ++++
net/bluetooth/hci_core.c | 62 +++++++++++++++++++++++++++++---
net/bluetooth/hci_event.c | 3 +-
net/bluetooth/smp.c | 11 ++++--
4 files changed, 74 insertions(+), 8 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 3a1169e19eb80..d8aa1f763f5b4 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -560,6 +560,8 @@ struct hci_dev {
struct list_head accept_list;
struct list_head uuids;
struct list_head link_keys;
+ /* Serializes the writers of link_keys, see hci_add_link_key() */
+ struct mutex link_keys_lock;
struct list_head long_term_keys;
struct list_head identity_resolving_keys;
struct mutex remote_oob_lock;
@@ -1874,6 +1876,10 @@ struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list,
void hci_uuids_clear(struct hci_dev *hdev);
void hci_link_keys_clear(struct hci_dev *hdev);
+struct link_key *__hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
+ bdaddr_t *bdaddr, u8 *val, u8 type,
+ u8 pin_len, bool *persistent);
+void hci_del_link_key(struct hci_dev *hdev, struct link_key *key);
u8 *hci_conn_key_enc_size(struct hci_conn *conn);
struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 6433c388050fa..ed9a83777af0d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1017,10 +1017,14 @@ void hci_link_keys_clear(struct hci_dev *hdev)
{
struct link_key *key, *tmp;
+ mutex_lock(&hdev->link_keys_lock);
+
list_for_each_entry_safe(key, tmp, &hdev->link_keys, list) {
list_del_rcu(&key->list);
kfree_rcu(key, rcu);
}
+
+ mutex_unlock(&hdev->link_keys_lock);
}
void hci_smp_ltks_clear(struct hci_dev *hdev)
@@ -1237,13 +1241,16 @@ struct smp_irk *hci_find_irk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr,
return irk_to_return;
}
-struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
- bdaddr_t *bdaddr, u8 *val, u8 type,
- u8 pin_len, bool *persistent)
+/* This function requires the caller holds hdev->link_keys_lock */
+struct link_key *__hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
+ bdaddr_t *bdaddr, u8 *val, u8 type,
+ u8 pin_len, bool *persistent)
{
struct link_key *key, *old_key;
u8 old_key_type;
+ lockdep_assert_held(&hdev->link_keys_lock);
+
old_key = hci_find_link_key(hdev, bdaddr);
if (old_key) {
old_key_type = old_key->type;
@@ -1286,6 +1293,26 @@ struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
return key;
}
+/* The writers of hdev->link_keys are serialized with hdev->link_keys_lock
+ * so the list can be modified without hdev->lock (e.g. from SMP, where it
+ * can't be taken after the l2cap channel lock). The returned key is only
+ * safe to use while hdev->lock is held, callers without it must use
+ * __hci_add_link_key() and keep hdev->link_keys_lock while using the key.
+ */
+struct link_key *hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn,
+ bdaddr_t *bdaddr, u8 *val, u8 type,
+ u8 pin_len, bool *persistent)
+{
+ struct link_key *key;
+
+ mutex_lock(&hdev->link_keys_lock);
+ key = __hci_add_link_key(hdev, conn, bdaddr, val, type, pin_len,
+ persistent);
+ mutex_unlock(&hdev->link_keys_lock);
+
+ return key;
+}
+
struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 addr_type, u8 type, u8 authenticated,
u8 tk[16], u8 enc_size, __le16 ediv, __le64 rand)
@@ -1347,18 +1374,44 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
{
struct link_key *key;
+ mutex_lock(&hdev->link_keys_lock);
+
key = hci_find_link_key(hdev, bdaddr);
- if (!key)
+ if (!key) {
+ mutex_unlock(&hdev->link_keys_lock);
return -ENOENT;
+ }
BT_DBG("%s removing %pMR", hdev->name, bdaddr);
list_del_rcu(&key->list);
kfree_rcu(key, rcu);
+ mutex_unlock(&hdev->link_keys_lock);
+
return 0;
}
+/* Remove a key previously returned by hci_add_link_key(), unlike
+ * hci_remove_link_key() this also works for keys that are blocked.
+ */
+void hci_del_link_key(struct hci_dev *hdev, struct link_key *key)
+{
+ struct link_key *k;
+
+ mutex_lock(&hdev->link_keys_lock);
+
+ list_for_each_entry(k, &hdev->link_keys, list) {
+ if (k == key) {
+ list_del_rcu(&key->list);
+ kfree_rcu(key, rcu);
+ break;
+ }
+ }
+
+ mutex_unlock(&hdev->link_keys_lock);
+}
+
int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type)
{
struct smp_ltk *k, *tmp;
@@ -2501,6 +2554,7 @@ struct hci_dev *hci_alloc_dev_priv(int sizeof_priv)
hdev->def_page_scan_window = 0x0012;
mutex_init(&hdev->lock);
+ mutex_init(&hdev->link_keys_lock);
mutex_init(&hdev->req_lock);
mutex_init(&hdev->mgmt_pending_lock);
mutex_init(&hdev->remote_oob_lock);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index fd5c185bb10bf..91e3c2ad3898c 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -4957,8 +4957,7 @@ static void hci_link_key_notify_evt(struct hci_dev *hdev, void *data,
*/
if (key->type == HCI_LK_DEBUG_COMBINATION &&
!hci_dev_test_flag(hdev, HCI_KEEP_DEBUG_KEYS)) {
- list_del_rcu(&key->list);
- kfree_rcu(key, rcu);
+ hci_del_link_key(hdev, key);
goto unlock;
}
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 4af7fa7f4a8e1..152ce3cfa0090 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1090,8 +1090,13 @@ static void smp_notify_keys(struct l2cap_conn *conn)
else
type = HCI_LK_UNAUTH_COMBINATION_P256;
- key = hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst,
- smp->link_key, type, 0, &persistent);
+ /* hdev->lock can't be taken here since it is ordered before
+ * the l2cap channel lock held by the caller.
+ */
+ mutex_lock(&hdev->link_keys_lock);
+
+ key = __hci_add_link_key(hdev, smp->conn->hcon, &hcon->dst,
+ smp->link_key, type, 0, &persistent);
if (key) {
mgmt_new_link_key(hdev, key, persistent);
@@ -1104,6 +1109,8 @@ static void smp_notify_keys(struct l2cap_conn *conn)
kfree_rcu(key, rcu);
}
}
+
+ mutex_unlock(&hdev->link_keys_lock);
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 100/742] Bluetooth: SMP: Check smp_data before using SMP_DEV()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (96 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 099/742] Bluetooth: SMP: Serialize link key updates from smp_notify_keys() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 101/742] Bluetooth: SMP: Dont create the BR/EDR channel while unregistered Greg Kroah-Hartman
` (628 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit e8764a6946341e9ee809393386e7b815179c5f5f ]
hdev->smp_data is NULL when the SMP channel could not be registered, so
receiving a Pairing Request/Response with the OOB flag set would
dereference NULL through SMP_DEV().
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-9bc9da90-02a8-4a87-a603-87d0a4cf464c
Fixes: 94f14e472812 ("Bluetooth: SMP: Fix trying to use non-existent local OOB data")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/smp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 152ce3cfa0090..ae71a754d176a 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -1759,7 +1759,8 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
* successfully received our local OOB data - therefore set the
* flag to indicate that local OOB is in use.
*/
- if (req->oob_flag == SMP_OOB_PRESENT && SMP_DEV(hdev)->local_oob)
+ if (req->oob_flag == SMP_OOB_PRESENT && hdev->smp_data &&
+ SMP_DEV(hdev)->local_oob)
set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags);
/* SMP over BR/EDR requires special treatment */
@@ -1945,7 +1946,8 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
* successfully received our local OOB data - therefore set the
* flag to indicate that local OOB is in use.
*/
- if (rsp->oob_flag == SMP_OOB_PRESENT && SMP_DEV(hdev)->local_oob)
+ if (rsp->oob_flag == SMP_OOB_PRESENT && hdev->smp_data &&
+ SMP_DEV(hdev)->local_oob)
set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags);
smp->prsp[0] = SMP_CMD_PAIRING_RSP;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 101/742] Bluetooth: SMP: Dont create the BR/EDR channel while unregistered
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (97 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 100/742] Bluetooth: SMP: Check smp_data before using SMP_DEV() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 102/742] Bluetooth: hci_event: Validate sent command length in LE Set Ext Adv Enable Greg Kroah-Hartman
` (627 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 8a119ba64f33dd9ab265d3b978f7811a80b7fe8a ]
smp_force_bredr() created a BR/EDR SMP channel even when the controller
was powered off or not LE capable, leaving a stale channel that
smp_register() later warns about and leaks. Only create it when SMP is
registered and guard the removal; smp_register() creates it on power on
if the flag is set. Since smp_unregister() runs with hdev->lock take it
around smp_register() as well so they can't race with each other nor with
smp_force_bredr().
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-a921c99c-0b41-485c-91a4-1c6e54b45b0b
Fixes: 300acfdec916 ("Bluetooth: Introduce force_bredr_smp debugfs option for testing")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/hci_sync.c | 2 ++
net/bluetooth/smp.c | 20 ++++++++++++++------
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index adae6e2fee1e1..970e16e64461f 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -3814,7 +3814,9 @@ int hci_powered_update_sync(struct hci_dev *hdev)
* registration is required so that LE SMP can clearly decide if
* the public address or static address is used.
*/
+ hci_dev_lock(hdev);
smp_register(hdev);
+ hci_dev_unlock(hdev);
err = hci_write_ssp_mode_sync(hdev, 0x01);
if (err)
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index ae71a754d176a..ae94d33d020fa 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -3368,20 +3368,28 @@ int smp_force_bredr(struct hci_dev *hdev, bool enable)
if (enable == hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP))
return -EALREADY;
+ /* The channels are only registered while the controller is powered
+ * and LE capable. Otherwise just record the flag, smp_register() will
+ * create the BR/EDR channel on the next power on.
+ */
if (enable) {
struct l2cap_chan *chan;
- chan = smp_add_cid(hdev, L2CAP_CID_SMP_BREDR);
- if (IS_ERR(chan))
- return PTR_ERR(chan);
+ if (hdev->smp_data && !hdev->smp_bredr_data) {
+ chan = smp_add_cid(hdev, L2CAP_CID_SMP_BREDR);
+ if (IS_ERR(chan))
+ return PTR_ERR(chan);
- hdev->smp_bredr_data = chan;
+ hdev->smp_bredr_data = chan;
+ }
} else {
struct l2cap_chan *chan;
chan = hdev->smp_bredr_data;
- hdev->smp_bredr_data = NULL;
- smp_del_chan(chan);
+ if (chan) {
+ hdev->smp_bredr_data = NULL;
+ smp_del_chan(chan);
+ }
}
hci_dev_change_flag(hdev, HCI_FORCE_BREDR_SMP);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 102/742] Bluetooth: hci_event: Validate sent command length in LE Set Ext Adv Enable
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (98 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 101/742] Bluetooth: SMP: Dont create the BR/EDR channel while unregistered Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 103/742] s390/cert_store: Hold keyring->sem while reading the keyring Greg Kroah-Hartman
` (626 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit ad7c1f067df2772d73a3a34218a8f5db57ceb41c ]
hci_cc_le_set_ext_adv_enable() read num_of_sets and the set entries from
the last sent command without checking its length.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-42bcc244-62e6-4295-802c-f9a512ca49a3
Fixes: de181e887ac2 ("Bluetooth: Impmlement extended adv enable")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/hci_event.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 91e3c2ad3898c..6450f8f5a5ab8 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1671,14 +1671,16 @@ static u8 hci_cc_le_set_ext_adv_enable(struct hci_dev *hdev, void *data,
struct hci_cp_ext_adv_set *set;
struct adv_info *adv = NULL, *n;
struct hci_ev_status *rp = data;
+ size_t len;
bt_dev_dbg(hdev, "status 0x%2.2x", rp->status);
if (rp->status)
return rp->status;
- cp = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE);
- if (!cp)
+ cp = hci_sent_cmd_data_len(hdev, HCI_OP_LE_SET_EXT_ADV_ENABLE, &len);
+ if (!cp || len < sizeof(*cp) ||
+ len < sizeof(*cp) + cp->num_of_sets * sizeof(*set))
return rp->status;
set = (void *)cp->data;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 103/742] s390/cert_store: Hold keyring->sem while reading the keyring
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (99 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 102/742] Bluetooth: hci_event: Validate sent command length in LE Set Ext Adv Enable Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 104/742] s390/cert_store: Fix return code handling in invalidate_keyring_keys() Greg Kroah-Hartman
` (625 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Jarkko Sakkinen,
Heiko Carstens, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <jarkko@kernel.org>
[ Upstream commit 008b903f55eb4bdb1af77070bb93e6e1dfa9145d ]
invalidate_keyring_keys() does not hold keyring->sem while calling
keyring_read(), which is contrary to what keyring assumes from its callers,
and can lead to recurring bugs.
KEY_FLAG_KEEP alone does not protect from e.g. the following call path:
1. keyctl_keyring_move()
2. key_move()
3. __key_unlink()
Address the issue by guarding the critical section.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index dc1992a675dee..7c8f694731bef 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -18,6 +18,7 @@
#include <linux/keyctl.h>
#include <linux/kobject.h>
#include <linux/module.h>
+#include <linux/rwsem.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
@@ -320,13 +321,17 @@ static int invalidate_keyring_keys(struct key *keyring)
struct key *current_key;
int rc;
- keyring_payload_len = key_type_keyring.read(keyring, NULL, 0);
- num_keys = keyring_payload_len / sizeof(key_serial_t);
- key_array = kzalloc_objs(key_serial_t, num_keys);
- if (!key_array)
- return -ENOMEM;
+ scoped_guard(rwsem_read, &keyring->sem) {
+ keyring_payload_len = key_type_keyring.read(keyring, NULL, 0);
+ num_keys = keyring_payload_len / sizeof(key_serial_t);
+
+ key_array = kzalloc_objs(key_serial_t, num_keys);
+ if (!key_array)
+ return -ENOMEM;
+
+ rc = key_type_keyring.read(keyring, (char *)key_array, keyring_payload_len);
+ }
- rc = key_type_keyring.read(keyring, (char *)key_array, keyring_payload_len);
if (rc != keyring_payload_len) {
pr_dbf_msg("Couldn't read keyring payload");
goto out;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 104/742] s390/cert_store: Fix return code handling in invalidate_keyring_keys()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (100 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 103/742] s390/cert_store: Hold keyring->sem while reading the keyring Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 105/742] s390/cert_store: Fix potential use-after-free " Greg Kroah-Hartman
` (624 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
Alexander Gordeev, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 1be070c4dc6edbfb015e72156fadb49fbaef47b9 ]
Add missing error handling in case key_type_keyring.read() returns an
error.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 7c8f694731bef..71f112c414460 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -316,15 +316,16 @@ static struct key *get_user_session_keyring(void)
static int invalidate_keyring_keys(struct key *keyring)
{
unsigned long num_keys, key_index;
- size_t keyring_payload_len;
+ long keyring_payload_len, rc;
key_serial_t *key_array;
struct key *current_key;
- int rc;
scoped_guard(rwsem_read, &keyring->sem) {
keyring_payload_len = key_type_keyring.read(keyring, NULL, 0);
- num_keys = keyring_payload_len / sizeof(key_serial_t);
+ if (keyring_payload_len <= 0)
+ return keyring_payload_len;
+ num_keys = keyring_payload_len / sizeof(key_serial_t);
key_array = kzalloc_objs(key_serial_t, num_keys);
if (!key_array)
return -ENOMEM;
@@ -334,6 +335,7 @@ static int invalidate_keyring_keys(struct key *keyring)
if (rc != keyring_payload_len) {
pr_dbf_msg("Couldn't read keyring payload");
+ rc = rc < 0 ? rc : -EINVAL;
goto out;
}
@@ -345,7 +347,7 @@ static int invalidate_keyring_keys(struct key *keyring)
key_put(current_key);
rc = key_unlink(keyring, current_key);
if (rc) {
- pr_dbf_msg("Couldn't unlink key %08x: %d", current_key->serial, rc);
+ pr_dbf_msg("Couldn't unlink key %08x: %ld", current_key->serial, rc);
break;
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 105/742] s390/cert_store: Fix potential use-after-free in invalidate_keyring_keys()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (101 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 104/742] s390/cert_store: Fix return code handling in invalidate_keyring_keys() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 106/742] s390/cert_store: Check key_lookup() return code " Greg Kroah-Hartman
` (623 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
Alexander Gordeev, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 69e0c49331475082e0b92cbf320e3e5a1deb889e ]
Drop the refcount of current_key behind all users of current_key which
dereference it, like e.g. error logging.
Fixes a potential use-after-free bug.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 71f112c414460..e00d8766ffe1f 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -344,12 +344,12 @@ static int invalidate_keyring_keys(struct key *keyring)
pr_dbf_msg("Invalidating key %08x", current_key->serial);
key_invalidate(current_key);
- key_put(current_key);
rc = key_unlink(keyring, current_key);
- if (rc) {
+ if (rc)
pr_dbf_msg("Couldn't unlink key %08x: %ld", current_key->serial, rc);
+ key_put(current_key);
+ if (rc)
break;
- }
}
out:
kfree(key_array);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 106/742] s390/cert_store: Check key_lookup() return code in invalidate_keyring_keys()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (102 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 105/742] s390/cert_store: Fix potential use-after-free " Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 107/742] s390/cert_store: Unlink before invalidate " Greg Kroah-Hartman
` (622 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
Alexander Gordeev, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 2a102f513a68ef6771e1cf107c7f98985686ad71 ]
keyring->sem is released after writing the key serial numbers into
key_array. Keys corresponding to those serial numbers may have been
removed before key_lookup() is called.
Therefore check the return code of key_lookup() before dereferencing it.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index e00d8766ffe1f..87aced367a61f 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -339,8 +339,11 @@ static int invalidate_keyring_keys(struct key *keyring)
goto out;
}
+ rc = 0;
for (key_index = 0; key_index < num_keys; key_index++) {
current_key = key_lookup(key_array[key_index]);
+ if (IS_ERR(current_key))
+ continue;
pr_dbf_msg("Invalidating key %08x", current_key->serial);
key_invalidate(current_key);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 107/742] s390/cert_store: Unlink before invalidate in invalidate_keyring_keys()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (103 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 106/742] s390/cert_store: Check key_lookup() return code " Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 108/742] s390/cert_store: Fix cs_keyring reference leak in fill_cs_keyring() Greg Kroah-Hartman
` (621 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
Alexander Gordeev, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit a1e3a45cac3d847e8ae81cc7e9db1b7b2c547a0e ]
If a key is invalidated, the key garbage collector may remove its link
from the keyring at any time. If that happens the subsequent key_unlink()
fails.
invalidate_keyring_keys() would then incorrectly return an error, which
would lead to unregistering the cert_store key type.
Unlink the key first and invalidate it afterwards to avoid this race.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 87aced367a61f..a142f46cc82b8 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -346,10 +346,10 @@ static int invalidate_keyring_keys(struct key *keyring)
continue;
pr_dbf_msg("Invalidating key %08x", current_key->serial);
- key_invalidate(current_key);
rc = key_unlink(keyring, current_key);
if (rc)
pr_dbf_msg("Couldn't unlink key %08x: %ld", current_key->serial, rc);
+ key_invalidate(current_key);
key_put(current_key);
if (rc)
break;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 108/742] s390/cert_store: Fix cs_keyring reference leak in fill_cs_keyring()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (104 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 107/742] s390/cert_store: Unlink before invalidate " Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 109/742] s390/cert_store: Fix potential use-after-free caused by find_cs_keyring() Greg Kroah-Hartman
` (620 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
Alexander Gordeev, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit f992716c4c767a89b6be32e24ee6e4e41ad99da4 ]
create_cs_keyring() returns cs_keyring with a reference held. On the
success path fill_cs_keyring() never drops it, leaking the reference.
The keyring is kept alive by its link to the session keyring.
Drop the reference after add_certificates_to_keyring() returns.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index a142f46cc82b8..39545f2f3d2ea 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -723,6 +723,7 @@ static int fill_cs_keyring(void)
if (rc)
goto cleanup_cs_keyring;
+ key_put(cs_keyring);
goto out;
cleanup_cs_keyring:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 109/742] s390/cert_store: Fix potential use-after-free caused by find_cs_keyring()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (105 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 108/742] s390/cert_store: Fix cs_keyring reference leak in fill_cs_keyring() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 110/742] s390/cert_store: Remove unnecessary static specifier in create_cs_keyring() Greg Kroah-Hartman
` (619 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
Alexander Gordeev, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 92d377a611766f6ab7b9a63a530aa7bbd434abbb ]
find_cs_keyring() drops the refcount of cs_keyring before returning it.
Which means that callers operate on potentially already freed memory.
Let find_cs_keyring() return cs_keyring with a reference. Since
cleanup_cs_keys() now performs a balanced put via find_cs_keyring(),
remove the separate cleanup_cs_keyring error label in fill_cs_keyring()
and drop the reference unconditionally instead.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 39545f2f3d2ea..6ff926ca039a2 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -367,17 +367,13 @@ static struct key *find_cs_keyring(void)
cs_keyring_ref = keyring_search(make_key_ref(get_user_session_keyring(), true),
&key_type_keyring, CERT_STORE_KEYRING_NAME,
false);
- if (!IS_ERR(cs_keyring_ref)) {
- cs_keyring = key_ref_to_ptr(cs_keyring_ref);
- key_ref_put(cs_keyring_ref);
- goto found;
- }
+ if (!IS_ERR(cs_keyring_ref))
+ return key_ref_to_ptr(cs_keyring_ref);
+
/* Search default locations: thread, process, session keyrings */
cs_keyring = request_key(&key_type_keyring, CERT_STORE_KEYRING_NAME, NULL);
if (IS_ERR(cs_keyring))
return NULL;
- key_put(cs_keyring);
-found:
return cs_keyring;
}
@@ -720,14 +716,12 @@ static int fill_cs_keyring(void)
goto cleanup_keys;
rc = add_certificates_to_keyring(vcssb, cs_keyring);
+ key_put(cs_keyring);
if (rc)
- goto cleanup_cs_keyring;
+ goto cleanup_keys;
- key_put(cs_keyring);
goto out;
-cleanup_cs_keyring:
- key_put(cs_keyring);
cleanup_keys:
cleanup_cs_keys();
out:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 110/742] s390/cert_store: Remove unnecessary static specifier in create_cs_keyring()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (106 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 109/742] s390/cert_store: Fix potential use-after-free caused by find_cs_keyring() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 111/742] s390/cert_store: Fix error handling of get_user_session_keyring() Greg Kroah-Hartman
` (618 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
Alexander Gordeev, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 1a58d930c82fcaf3a6a9e9daf21c7ae9ee088d7e ]
The local variable cs_keyring in create_cs_keyring() never reuses its
assigned value, therefore remove the static specifier. Callers are
serialized by cs_refresh_lock, so this does not fix a bug.
Even though this is not a bug fix, this contains a Fixes tag since other
commits require this as a prereq.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 6ff926ca039a2..0e084fb79aa26 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -401,7 +401,7 @@ static void cleanup_cs_keys(void)
static struct key *create_cs_keyring(void)
{
- static struct key *cs_keyring;
+ struct key *cs_keyring;
/* Cleanup previous cs_keyring and all associated keys if any. */
cleanup_cs_keys();
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 111/742] s390/cert_store: Fix error handling of get_user_session_keyring()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (107 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 110/742] s390/cert_store: Remove unnecessary static specifier in create_cs_keyring() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 112/742] s390/cert_store: Fix keyring refcount handling in get_user_session_keyring() Greg Kroah-Hartman
` (617 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
Alexander Gordeev, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 8256791b74e701361398a8d0e43c55bdabadc5ca ]
create_cs_keyring(), cleanup_cs_keys(), and find_cs_keyring() all pass
the return value of get_user_session_keyring() to other functions without
checking it. This can lead to dereferencing an error pointer.
Check the return value before using it.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 0e084fb79aa26..5c1140b20012d 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -361,15 +361,18 @@ static int invalidate_keyring_keys(struct key *keyring)
static struct key *find_cs_keyring(void)
{
+ struct key *cs_keyring, *us_keyring;
key_ref_t cs_keyring_ref;
- struct key *cs_keyring;
-
- cs_keyring_ref = keyring_search(make_key_ref(get_user_session_keyring(), true),
- &key_type_keyring, CERT_STORE_KEYRING_NAME,
- false);
- if (!IS_ERR(cs_keyring_ref))
- return key_ref_to_ptr(cs_keyring_ref);
+ us_keyring = get_user_session_keyring();
+ if (!IS_ERR(us_keyring)) {
+ cs_keyring_ref = keyring_search(make_key_ref(us_keyring, true),
+ &key_type_keyring,
+ CERT_STORE_KEYRING_NAME,
+ false);
+ if (!IS_ERR(cs_keyring_ref))
+ return key_ref_to_ptr(cs_keyring_ref);
+ }
/* Search default locations: thread, process, session keyrings */
cs_keyring = request_key(&key_type_keyring, CERT_STORE_KEYRING_NAME, NULL);
if (IS_ERR(cs_keyring))
@@ -379,7 +382,7 @@ static struct key *find_cs_keyring(void)
static void cleanup_cs_keys(void)
{
- struct key *cs_keyring;
+ struct key *cs_keyring, *us_keyring;
cs_keyring = find_cs_keyring();
if (!cs_keyring)
@@ -395,21 +398,26 @@ static void cleanup_cs_keys(void)
keyring_clear(cs_keyring);
key_invalidate(cs_keyring);
+ us_keyring = get_user_session_keyring();
+ if (!IS_ERR(us_keyring))
+ key_unlink(us_keyring, cs_keyring);
key_put(cs_keyring);
- key_unlink(get_user_session_keyring(), cs_keyring);
}
static struct key *create_cs_keyring(void)
{
- struct key *cs_keyring;
+ struct key *cs_keyring, *us_keyring;
/* Cleanup previous cs_keyring and all associated keys if any. */
cleanup_cs_keys();
+ us_keyring = get_user_session_keyring();
+ if (IS_ERR(us_keyring))
+ return NULL;
cs_keyring = keyring_alloc(CERT_STORE_KEYRING_NAME, GLOBAL_ROOT_UID,
GLOBAL_ROOT_GID, current_cred(),
(KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW | KEY_USR_READ,
KEY_ALLOC_NOT_IN_QUOTA | KEY_ALLOC_SET_KEEP,
- NULL, get_user_session_keyring());
+ NULL, us_keyring);
if (IS_ERR(cs_keyring)) {
pr_dbf_msg("Can't allocate cert_store keyring");
return NULL;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 112/742] s390/cert_store: Fix keyring refcount handling in get_user_session_keyring()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (108 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 111/742] s390/cert_store: Fix error handling of get_user_session_keyring() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 113/742] s390/cert_store: Do not search the process keyrings for the cert_store keyring Greg Kroah-Hartman
` (616 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
Alexander Gordeev, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit aa7ee9e9cf17fcc7b0af55424aba6f0abd065fa7 ]
get_user_session_keyring() drops the reference of the looked up keyring
before returning it. Callers therefore use the keyring without holding a
reference.
Return the keyring with the reference and let callers drop the reference.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 5c1140b20012d..789edf58fa2cb 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -308,7 +308,6 @@ static struct key *get_user_session_keyring(void)
PTR_ERR(us_keyring_ref));
return ERR_PTR(-ENOKEY);
}
- key_ref_put(us_keyring_ref);
return key_ref_to_ptr(us_keyring_ref);
}
@@ -370,6 +369,7 @@ static struct key *find_cs_keyring(void)
&key_type_keyring,
CERT_STORE_KEYRING_NAME,
false);
+ key_put(us_keyring);
if (!IS_ERR(cs_keyring_ref))
return key_ref_to_ptr(cs_keyring_ref);
}
@@ -399,8 +399,10 @@ static void cleanup_cs_keys(void)
keyring_clear(cs_keyring);
key_invalidate(cs_keyring);
us_keyring = get_user_session_keyring();
- if (!IS_ERR(us_keyring))
+ if (!IS_ERR(us_keyring)) {
key_unlink(us_keyring, cs_keyring);
+ key_put(us_keyring);
+ }
key_put(cs_keyring);
}
@@ -418,6 +420,7 @@ static struct key *create_cs_keyring(void)
(KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW | KEY_USR_READ,
KEY_ALLOC_NOT_IN_QUOTA | KEY_ALLOC_SET_KEEP,
NULL, us_keyring);
+ key_put(us_keyring);
if (IS_ERR(cs_keyring)) {
pr_dbf_msg("Can't allocate cert_store keyring");
return NULL;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 113/742] s390/cert_store: Do not search the process keyrings for the cert_store keyring
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (109 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 112/742] s390/cert_store: Fix keyring refcount handling in get_user_session_keyring() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 114/742] s390/cert_store: Validate hash length in check_certificate_valid() Greg Kroah-Hartman
` (615 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Heiko Carstens, Jarkko Sakkinen,
Alexander Gordeev, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 5ac71bb84e34337d7be280d2c06ff9cae77b7bcf ]
find_cs_keyring() first searches the user session keyring for the
cert_store keyring, and falls back to request_key(), which searches the
thread, process and session keyrings of the calling task. Any keyring
named "cert_store" found this way is accepted.
cleanup_cs_keys() then invalidates and unlinks all of its keys, and
clears and invalidates the keyring itself, without checking permissions.
If the refresh is triggered by a task which inherited a session keyring
that contains a keyring named "cert_store" not created by this code, this
keyring and its keys are destroyed.
create_cs_keyring() always links the keyring into the user session
keyring, so the first search is sufficient. Remove the request_key()
fallback.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 789edf58fa2cb..1014f62b82a0a 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -360,7 +360,7 @@ static int invalidate_keyring_keys(struct key *keyring)
static struct key *find_cs_keyring(void)
{
- struct key *cs_keyring, *us_keyring;
+ struct key *us_keyring;
key_ref_t cs_keyring_ref;
us_keyring = get_user_session_keyring();
@@ -373,11 +373,7 @@ static struct key *find_cs_keyring(void)
if (!IS_ERR(cs_keyring_ref))
return key_ref_to_ptr(cs_keyring_ref);
}
- /* Search default locations: thread, process, session keyrings */
- cs_keyring = request_key(&key_type_keyring, CERT_STORE_KEYRING_NAME, NULL);
- if (IS_ERR(cs_keyring))
- return NULL;
- return cs_keyring;
+ return NULL;
}
static void cleanup_cs_keys(void)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 114/742] s390/cert_store: Validate hash length in check_certificate_valid()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (110 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 113/742] s390/cert_store: Do not search the process keyrings for the cert_store keyring Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 115/742] s390/cert_store: Fix max_vcxe_length output in pr_dbf_vcssb() Greg Kroah-Hartman
` (614 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Heiko Carstens,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 8b4e340f7742c8c3b12353e882ad5d4d25c7acc9 ]
Validate that vc_hash_length is SHA256_DIGEST_SIZE before checking the
hash and use sizeof(hash) in memcmp(). This avoids an out-of-bounds
read if vc_hash_length is incorrect.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 1014f62b82a0a..56a16b71a8d7d 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -261,13 +261,11 @@ static int diag320(unsigned long subcode, void *addr)
static int check_certificate_hash(const struct vce *vce)
{
u8 hash[SHA256_DIGEST_SIZE];
- u16 vc_hash_length;
u8 *vce_hash;
vce_hash = (u8 *)vce + vce->vce_hdr.vc_hash_offset;
- vc_hash_length = vce->vce_hdr.vc_hash_length;
sha256((u8 *)vce + vce->vce_hdr.vc_offset, vce->vce_hdr.vc_length, hash);
- if (memcmp(vce_hash, hash, vc_hash_length) == 0)
+ if (memcmp(vce_hash, hash, sizeof(hash)) == 0)
return 0;
pr_dbf_msg("SHA256 hash of received certificate does not match");
@@ -293,6 +291,10 @@ static int check_certificate_valid(const struct vce *vce)
pr_dbf_msg("Hash type is not supported");
return -EINVAL;
}
+ if (vce->vce_hdr.vc_hash_length != SHA256_DIGEST_SIZE) {
+ pr_dbf_msg("Hash length is not supported");
+ return -EINVAL;
+ }
return check_certificate_hash(vce);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 115/742] s390/cert_store: Fix max_vcxe_length output in pr_dbf_vcssb()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (111 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 114/742] s390/cert_store: Validate hash length in check_certificate_valid() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 116/742] s390/cert_store: Fix out-of-bounds read in pr_dbf_vce() Greg Kroah-Hartman
` (613 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Heiko Carstens,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 9d263bd8ddc31c9c3ebe3612df575d70848f5772 ]
Print the correct value for max_vcxe_length.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 56a16b71a8d7d..8b7216710e187 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -225,7 +225,7 @@ static void pr_dbf_vcssb(const struct vcssb *s)
pr_dbf_msg("total_vc_index_count: %u", s->total_vc_index_count);
pr_dbf_msg("max_vc_index_count: %u", s->max_vc_index_count);
pr_dbf_msg("max_vce_length: %u", s->max_vce_length);
- pr_dbf_msg("max_vcxe_length: %u", s->max_vce_length);
+ pr_dbf_msg("max_vcxe_length: %u", s->max_vcxe_length);
pr_dbf_msg("max_single_vcb_length: %u", s->max_single_vcb_length);
pr_dbf_msg("total_vcb_length: %u", s->total_vcb_length);
pr_dbf_msg("max_single_vcxb_length: %u", s->max_single_vcxb_length);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 116/742] s390/cert_store: Fix out-of-bounds read in pr_dbf_vce()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (112 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 115/742] s390/cert_store: Fix max_vcxe_length output in pr_dbf_vcssb() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 117/742] s390/cert_store: Initialize ism array in query_diag320_subcodes() Greg Kroah-Hartman
` (612 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Heiko Carstens,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 539cf27f0b090d84438b7da9045a271a947192ed ]
pr_dbf_vce() dumps the last 128 bytes of the certificate data of a
Verification Certificate Entry (VCE) into a debug area.
However the address calculation is wrong: vce_length is the length of
the whole entry including the header, while cert_data_buf starts
behind the header. Therefore the dump starts at the end of the entry
and starts reading behind it.
Dump the last 128 bytes of the entry like intended. Limit dumps to the
data length.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 8b7216710e187..ec5d82aee1c20 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -181,6 +181,7 @@ static void pr_dbf_vce(const struct vce *e)
{
unsigned char vc_name[VC_NAME_LEN_BYTES + 1];
char log_string[VC_NAME_LEN_BYTES + 40];
+ u32 data_len = 0;
pr_dbf_msg("VCE Header:");
pr_dbf_msg("vce_hdr.vce_length: %d", e->vce_hdr.vce_length);
@@ -206,11 +207,13 @@ static void pr_dbf_vce(const struct vce *e)
debug_text_event(cert_store_hexdump, 3, log_string);
/* Certificate data. */
+ if (e->vce_hdr.vce_length > sizeof(e->vce_hdr))
+ data_len = e->vce_hdr.vce_length - sizeof(e->vce_hdr);
debug_text_event(cert_store_hexdump, 3, "VCE: Certificate data start");
- debug_event(cert_store_hexdump, 3, (u8 *)e->cert_data_buf, 128);
+ debug_event(cert_store_hexdump, 3, (u8 *)e->cert_data_buf, min(data_len, 128U));
debug_text_event(cert_store_hexdump, 3, "VCE: Certificate data end");
- debug_event(cert_store_hexdump, 3,
- (u8 *)e->cert_data_buf + e->vce_hdr.vce_length - 128, 128);
+ if (data_len > 128)
+ debug_event(cert_store_hexdump, 3, (u8 *)e + e->vce_hdr.vce_length - 128, 128);
}
static void pr_dbf_vcssb(const struct vcssb *s)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 117/742] s390/cert_store: Initialize ism array in query_diag320_subcodes()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (113 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 116/742] s390/cert_store: Fix out-of-bounds read in pr_dbf_vce() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 118/742] Bluetooth: mgmt: Reject zero multi advertising rotation duration Greg Kroah-Hartman
` (611 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Heiko Carstens,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <hca@linux.ibm.com>
[ Upstream commit 2c1f57bce05244165f406e45982bbcd036071d3b ]
The Installed Subcode Block returned by DIAG 320 subcode 0 may be smaller
than the ism array. Initialize it to avoid copying uninitialized data to
the debug area.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index ec5d82aee1c20..375035da755cf 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -670,7 +670,7 @@ static int add_certificates_to_keyring(struct vcssb *vcssb, struct key *keyring)
*/
static int query_diag320_subcodes(void)
{
- unsigned long ism[ISM_LEN_DWORDS];
+ unsigned long ism[ISM_LEN_DWORDS] = {};
int rc;
rc = diag320(0, ism);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 118/742] Bluetooth: mgmt: Reject zero multi advertising rotation duration
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (114 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 117/742] s390/cert_store: Initialize ism array in query_diag320_subcodes() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 119/742] Bluetooth: L2CAP: Dont use uninitialized EFS in l2cap_parse_conf_rsp() Greg Kroah-Hartman
` (610 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 4e0dc0523bd98adbd45ce1c66dd1a96d4f6a3ec9 ]
A zero def_multi_adv_rotation_duration makes
hci_schedule_adv_instance_sync() requeue itself with no delay, spinning
the request workqueue. Reject it in Set Default System Configuration.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-24ecb695-0c5c-408a-a016-a980c3115e95
Fixes: 17896406ff35 ("Bluetooth: implement read/set default system parameters mgmt")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/mgmt_config.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/bluetooth/mgmt_config.c b/net/bluetooth/mgmt_config.c
index fdcc752c6f13f..ef1b8da539903 100644
--- a/net/bluetooth/mgmt_config.c
+++ b/net/bluetooth/mgmt_config.c
@@ -224,6 +224,14 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
MGMT_STATUS_INVALID_PARAMS);
}
+ /* A zero rotation duration would make the advertising instance
+ * scheduler requeue itself with no delay.
+ */
+ if (type == 0x000c && !TLV_GET_LE16(buffer))
+ return mgmt_cmd_status(sk, hdev->id,
+ MGMT_OP_SET_DEF_SYSTEM_CONFIG,
+ MGMT_STATUS_INVALID_PARAMS);
+
buffer_left -= exp_len;
buffer += exp_len;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 119/742] Bluetooth: L2CAP: Dont use uninitialized EFS in l2cap_parse_conf_rsp()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (115 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 118/742] Bluetooth: mgmt: Reject zero multi advertising rotation duration Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 120/742] Bluetooth: mgmt: Fix mesh transmission locking and lifetime Greg Kroah-Hartman
` (609 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit cb3251457da29ac1118f130bf45ac696421594a8 ]
The local EFS values were copied from an on-stack struct even when the
response carried no EFS option. Track whether it was received.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-089f015e-6251-4fea-85ef-7d6761e8c457
Fixes: 66af7aaf9edf ("Bluetooth: EFS: parse L2CAP config response")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/l2cap_core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 59ae6ee4ff345..6eb919f943b49 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3805,6 +3805,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
unsigned long val;
struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC };
struct l2cap_conf_efs efs;
+ bool remote_efs = false;
BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data);
@@ -3860,6 +3861,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
if (olen != sizeof(efs))
break;
memcpy(&efs, (void *)val, olen);
+ remote_efs = true;
if (chan->local_stype != L2CAP_SERV_NOTRAFIC &&
efs.stype != L2CAP_SERV_NOTRAFIC &&
efs.stype != chan->local_stype)
@@ -3898,7 +3900,8 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
chan->ack_win = min_t(u16, chan->ack_win,
rfc.txwin_size);
- if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) {
+ if (remote_efs &&
+ test_bit(FLAG_EFS_ENABLE, &chan->flags)) {
chan->local_msdu = le16_to_cpu(efs.msdu);
chan->local_sdu_itime =
le32_to_cpu(efs.sdu_itime);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 120/742] Bluetooth: mgmt: Fix mesh transmission locking and lifetime
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (116 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 119/742] Bluetooth: L2CAP: Dont use uninitialized EFS in l2cap_parse_conf_rsp() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 121/742] Bluetooth: MGMT: Fix use-after-free in mgmt_powering_down() Greg Kroah-Hartman
` (608 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 1d7a527788584e4a88ccc532ed73bfdacd0b1e74 ]
The mesh_pending list is modified under hdev->lock by Mesh Send, but the
cmd_sync callbacks and Mesh Send Cancel add/remove entries and touch
hdev->adv_instances without it, which corrupts the list and the advertising
instances. In addition the queued mesh_send_sync entry holds a raw pointer
to the mesh_tx which a cancel of the transmission can free while the entry
is running, leading to use-after-free.
Fix this by:
- taking hdev->lock around every mesh_pending/adv_instances access in the
cmd_sync callbacks and Mesh Send Cancel, but never across HCI commands;
- queueing the cmd_sync entries with the transmission handle and looking
it up under the lock instead of passing the pointer;
- always sending the first transmission, tracked by HCI_MESH_SENDING which
is only cleared together with the removal of the transmission so Mesh
Send can't start another one in between, and making sure none is left
stranded if queueing fails;
- cancelling a transmission by dequeuing its entry, and the done entry if
it is the one in progress, stopping the done timer, which is queued
with hdev->lock held so a cancel can't miss it;
- not taking hdev->lock from callbacks invoked with -ECANCELED since
those run with the cmd_sync lock held, the transmission is removed by
whoever cancelled the entry;
- flushing the transmissions left, dequeuing the entries still queued for
them and clearing HCI_MESH_SENDING, when the controller is closed (also
when auto powered off) or the index is removed, as nothing is going to
send them and the stale entries would act on the ones started after
the controller is powered on again, and not accepting Mesh Send while
the controller is not powered so none can be left behind;
- not reporting the completion of a transmission that failed to be queued
by Mesh Send itself since userspace wasn't told about its handle;
- not reusing the handle of a transmission still pending when the handle
counter wraps around, now that it is what identifies a transmission.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-4ab89465-fc27-4d91-a870-a8ed49b22e91
Link: https://sashiko.dev/#/bug/linux-ab941894-dbe1-49da-8bac-c52efda6eaee
Link: https://sashiko.dev/#/bug/linux-4016f774-7ac7-4b8a-916f-587ec9d597d4
Fixes: b338d91703fa ("Bluetooth: Implement support for Mesh")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_sync.c | 5 +
net/bluetooth/mgmt.c | 301 +++++++++++++++++++++++++------
net/bluetooth/mgmt_util.c | 23 ++-
4 files changed, 267 insertions(+), 63 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index d8aa1f763f5b4..4d984ff3ba3a0 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -2469,6 +2469,7 @@ void mgmt_index_removed(struct hci_dev *hdev);
void mgmt_set_powered_failed(struct hci_dev *hdev, int err);
void mgmt_power_on(struct hci_dev *hdev, int err);
void __mgmt_power_off(struct hci_dev *hdev);
+void mgmt_mesh_flush(struct hci_dev *hdev);
void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
bool persistent);
void mgmt_device_connected(struct hci_dev *hdev, struct hci_conn *conn,
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 970e16e64461f..012ee0b6cc01c 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -5782,6 +5782,11 @@ int hci_dev_close_sync(struct hci_dev *hdev)
auto_off = hci_dev_test_and_clear_flag(hdev, HCI_AUTO_OFF);
+ /* Nothing is going to send the mesh transmissions left, whether or not
+ * mgmt is told about the controller being powered off.
+ */
+ mgmt_mesh_flush(hdev);
+
if (!auto_off && !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
hci_dev_test_flag(hdev, HCI_MGMT))
__mgmt_power_off(hdev);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index d7f54056d0918..83a1454b85b4d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1081,6 +1081,7 @@ static void discov_off(struct work_struct *work)
static int send_settings_rsp(struct sock *sk, u16 opcode, struct hci_dev *hdev);
+/* This function requires the caller holds hdev->lock */
static void mesh_send_complete(struct hci_dev *hdev,
struct mgmt_mesh_tx *mesh_tx, bool silent)
{
@@ -1093,37 +1094,95 @@ static void mesh_send_complete(struct hci_dev *hdev,
mgmt_mesh_remove(mesh_tx);
}
-static int mesh_send_done_sync(struct hci_dev *hdev, void *data)
+/* The cmd_sync entries identify the transmission by handle rather than by
+ * pointer since the mesh_tx can be removed while the entry is queued or
+ * running.
+ */
+#define MESH_TX_DATA(_handle) ((void *)(unsigned long)(_handle))
+#define MESH_TX_HANDLE(_data) ((u8)(unsigned long)(_data))
+
+static int mesh_send_sync(struct hci_dev *hdev, void *data);
+static void mesh_send_start_complete(struct hci_dev *hdev, void *data, int err);
+
+/* Start sending the first transmission unless one is already in progress,
+ * HCI_MESH_SENDING is set while the first transmission is being sent.
+ * Completion is not reported for @new, the handle of a transmission userspace
+ * wasn't told about yet.
+ *
+ * This function requires the caller holds hdev->lock.
+ */
+static void __mesh_next(struct hci_dev *hdev, u8 new)
{
struct mgmt_mesh_tx *mesh_tx;
+ int err;
- hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
- if (list_empty(&hdev->adv_instances))
- hci_disable_advertising_sync(hdev);
- mesh_tx = mgmt_mesh_next(hdev, NULL);
-
- if (mesh_tx)
- mesh_send_complete(hdev, mesh_tx, false);
+ while (!hci_dev_test_flag(hdev, HCI_MESH_SENDING)) {
+ mesh_tx = mgmt_mesh_next(hdev, NULL);
+ if (!mesh_tx)
+ return;
- return 0;
+ err = hci_cmd_sync_queue(hdev, mesh_send_sync,
+ MESH_TX_DATA(mesh_tx->handle),
+ mesh_send_start_complete);
+ if (err < 0)
+ mesh_send_complete(hdev, mesh_tx,
+ mesh_tx->handle == new);
+ else
+ hci_dev_set_flag(hdev, HCI_MESH_SENDING);
+ }
}
-static int mesh_send_sync(struct hci_dev *hdev, void *data);
-static void mesh_send_start_complete(struct hci_dev *hdev, void *data, int err);
static void mesh_next(struct hci_dev *hdev, void *data, int err)
{
- struct mgmt_mesh_tx *mesh_tx = mgmt_mesh_next(hdev, NULL);
-
- if (!mesh_tx)
+ /* The entry is being cancelled with the cmd_sync lock held, which
+ * can't be taken before hdev->lock.
+ */
+ if (err == -ECANCELED)
return;
- err = hci_cmd_sync_queue(hdev, mesh_send_sync, mesh_tx,
- mesh_send_start_complete);
+ hci_dev_lock(hdev);
+ __mesh_next(hdev, 0);
+ hci_dev_unlock(hdev);
+}
- if (err < 0)
+static int mesh_send_done_sync(struct hci_dev *hdev, void *data)
+{
+ struct mgmt_mesh_tx *mesh_tx;
+ u8 handle;
+ bool disable;
+
+ hci_dev_lock(hdev);
+
+ mesh_tx = mgmt_mesh_next(hdev, NULL);
+ if (!mesh_tx || !hci_dev_test_flag(hdev, HCI_MESH_SENDING)) {
+ hci_dev_unlock(hdev);
+ return 0;
+ }
+
+ handle = mesh_tx->handle;
+ disable = list_empty(&hdev->adv_instances);
+
+ hci_dev_unlock(hdev);
+
+ if (disable)
+ hci_disable_advertising_sync(hdev);
+
+ hci_dev_lock(hdev);
+
+ /* The transmission can be cancelled meanwhile, in which case whoever
+ * did so already moved on to the next one. HCI_MESH_SENDING is only
+ * cleared with the transmission removed so Mesh Send doesn't start
+ * another one in between.
+ */
+ mesh_tx = mgmt_mesh_find(hdev, handle);
+ if (mesh_tx) {
mesh_send_complete(hdev, mesh_tx, false);
- else
- hci_dev_set_flag(hdev, HCI_MESH_SENDING);
+ hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
+ }
+
+ hci_dev_unlock(hdev);
+
+ return 0;
}
static void mesh_send_done(struct work_struct *work)
@@ -1137,6 +1196,33 @@ static void mesh_send_done(struct work_struct *work)
hci_cmd_sync_queue(hdev, mesh_send_done_sync, NULL, mesh_next);
}
+/* Nothing is going to send the transmissions left, e.g. when the controller
+ * is powered off.
+ *
+ * This function requires the caller holds hdev->lock.
+ */
+static void mesh_flush(struct hci_dev *hdev, bool silent)
+{
+ struct mgmt_mesh_tx *mesh_tx;
+
+ /* Stop the timer first, it checks HCI_MESH_SENDING without hdev->lock
+ * so once it is clear and the work is not running anymore nothing can
+ * queue mesh_send_done_sync behind the dequeue below.
+ */
+ hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
+ cancel_delayed_work_sync(&hdev->mesh_send_done);
+
+ /* Entries still queued would otherwise run after the controller is
+ * powered on again and act on the transmissions started by then. The
+ * destroy callbacks don't take hdev->lock when cancelled.
+ */
+ hci_cmd_sync_dequeue(hdev, mesh_send_sync, NULL, NULL);
+ hci_cmd_sync_dequeue(hdev, mesh_send_done_sync, NULL, NULL);
+
+ while ((mesh_tx = mgmt_mesh_next(hdev, NULL)))
+ mesh_send_complete(hdev, mesh_tx, silent);
+}
+
static void mgmt_init_hdev(struct sock *sk, struct hci_dev *hdev)
{
if (hci_dev_test_flag(hdev, HCI_MGMT))
@@ -2304,38 +2390,71 @@ static int set_mesh(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
static void mesh_send_start_complete(struct hci_dev *hdev, void *data, int err)
{
- struct mgmt_mesh_tx *mesh_tx = data;
- struct mgmt_cp_mesh_send *send = (void *)mesh_tx->param;
- unsigned long mesh_send_interval;
+ struct mgmt_mesh_tx *mesh_tx;
+ struct mgmt_cp_mesh_send *send;
u8 mgmt_err = mgmt_status(err);
+ /* The entry is being cancelled with the cmd_sync lock held, which
+ * can't be taken before hdev->lock, so leave the removal of the
+ * transmission, and HCI_MESH_SENDING, to whoever cancelled it or to
+ * mgmt_power_off() if the controller is going down.
+ */
+ if (err == -ECANCELED)
+ return;
+
+ hci_dev_lock(hdev);
+
+ /* Cancelled while the entry was running, whoever did so already moved
+ * on to the next transmission.
+ */
+ mesh_tx = mgmt_mesh_find(hdev, MESH_TX_HANDLE(data));
+ if (!mesh_tx) {
+ hci_dev_unlock(hdev);
+ return;
+ }
+
/* Report any errors here, but don't report completion */
if (mgmt_err) {
- hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
/* Send Complete Error Code for handle */
mesh_send_complete(hdev, mesh_tx, false);
- if (err != -ECANCELED)
- mesh_next(hdev, NULL, 0);
+ hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
+ __mesh_next(hdev, 0);
+ hci_dev_unlock(hdev);
return;
}
- mesh_send_interval = msecs_to_jiffies((send->cnt) * 25);
+ /* Queued with hdev->lock held so a cancel can't miss it */
+ send = (void *)mesh_tx->param;
queue_delayed_work(hdev->req_workqueue, &hdev->mesh_send_done,
- mesh_send_interval);
+ msecs_to_jiffies((send->cnt) * 25));
+
+ hci_dev_unlock(hdev);
}
static int mesh_send_sync(struct hci_dev *hdev, void *data)
{
- struct mgmt_mesh_tx *mesh_tx = data;
- struct mgmt_cp_mesh_send *send = (void *)mesh_tx->param;
+ struct mgmt_mesh_tx *mesh_tx;
+ struct mgmt_cp_mesh_send *send;
struct adv_info *adv, *next_instance;
u8 instance = hdev->le_num_of_adv_sets + 1;
u16 timeout, duration;
int err = 0;
- if (hdev->le_num_of_adv_sets <= hdev->adv_instance_cnt)
+ hci_dev_lock(hdev);
+
+ mesh_tx = mgmt_mesh_find(hdev, MESH_TX_HANDLE(data));
+ if (!mesh_tx) {
+ hci_dev_unlock(hdev);
+ return -ENOENT;
+ }
+
+ send = (void *)mesh_tx->param;
+
+ if (hdev->le_num_of_adv_sets <= hdev->adv_instance_cnt) {
+ hci_dev_unlock(hdev);
return MGMT_STATUS_BUSY;
+ }
timeout = 1000;
duration = send->cnt * INTERVAL_TO_MS(hdev->le_adv_max_interval);
@@ -2373,6 +2492,8 @@ static int mesh_send_sync(struct hci_dev *hdev, void *data)
instance = 0;
}
+ hci_dev_unlock(hdev);
+
if (instance)
return hci_schedule_adv_instance_sync(hdev, instance, true);
@@ -2416,37 +2537,80 @@ static int mesh_features(struct sock *sk, struct hci_dev *hdev,
return 0;
}
+/* Cancel a single transmission, the handle is looked up again after the
+ * entry has been dequeued since it may be gone or have completed meanwhile.
+ */
+static void mesh_cancel_tx(struct hci_dev *hdev, u8 handle)
+{
+ struct mgmt_mesh_tx *mesh_tx;
+ bool in_progress;
+
+ hci_cmd_sync_dequeue(hdev, mesh_send_sync, MESH_TX_DATA(handle), NULL);
+
+ hci_dev_lock(hdev);
+ mesh_tx = mgmt_mesh_find(hdev, handle);
+ in_progress = mesh_tx && hci_dev_test_flag(hdev, HCI_MESH_SENDING) &&
+ mesh_tx == mgmt_mesh_next(hdev, NULL);
+ hci_dev_unlock(hdev);
+
+ /* The done timer may have fired already and be waiting to complete
+ * the transmission in progress, which is being cancelled.
+ */
+ if (in_progress)
+ hci_cmd_sync_dequeue(hdev, mesh_send_done_sync, NULL, NULL);
+
+ hci_dev_lock(hdev);
+
+ mesh_tx = mgmt_mesh_find(hdev, handle);
+ if (mesh_tx) {
+ /* If it is the transmission in progress make sure the timer
+ * doesn't complete the next one in its place.
+ */
+ if (hci_dev_test_flag(hdev, HCI_MESH_SENDING) &&
+ mesh_tx == mgmt_mesh_next(hdev, NULL)) {
+ cancel_delayed_work(&hdev->mesh_send_done);
+ hci_dev_clear_flag(hdev, HCI_MESH_SENDING);
+ }
+
+ mesh_send_complete(hdev, mesh_tx, false);
+ }
+
+ hci_dev_unlock(hdev);
+}
+
static int send_cancel(struct hci_dev *hdev, void *data)
{
struct mgmt_pending_cmd *cmd = data;
struct mgmt_cp_mesh_send_cancel *cancel = (void *)cmd->param;
struct mgmt_mesh_tx *mesh_tx;
+ u8 handle;
if (!cancel->handle) {
- do {
+ for (;;) {
+ hci_dev_lock(hdev);
mesh_tx = mgmt_mesh_next(hdev, cmd->sk);
+ handle = mesh_tx ? mesh_tx->handle : 0;
+ hci_dev_unlock(hdev);
- if (mesh_tx) {
- if (!hci_cmd_sync_dequeue(hdev, mesh_send_sync,
- mesh_tx, NULL))
- mesh_send_complete(hdev, mesh_tx, false);
- }
- } while (mesh_tx);
+ if (!mesh_tx)
+ break;
+
+ mesh_cancel_tx(hdev, handle);
+ }
} else {
+ hci_dev_lock(hdev);
mesh_tx = mgmt_mesh_find(hdev, cancel->handle);
+ handle = mesh_tx && mesh_tx->sk == cmd->sk ? mesh_tx->handle : 0;
+ hci_dev_unlock(hdev);
- if (mesh_tx && mesh_tx->sk == cmd->sk) {
- if (!hci_cmd_sync_dequeue(hdev, mesh_send_sync,
- mesh_tx, NULL))
- mesh_send_complete(hdev, mesh_tx, false);
- }
+ if (handle)
+ mesh_cancel_tx(hdev, handle);
}
mgmt_cmd_complete(cmd->sk, hdev->id, MGMT_OP_MESH_SEND_CANCEL,
0, NULL, 0);
- if (!hci_dev_test_flag(hdev, HCI_MESH_SENDING))
- mesh_next(hdev, NULL, 0);
+ mesh_next(hdev, NULL, 0);
return 0;
}
@@ -2497,7 +2661,6 @@ static int mesh_send(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
struct mgmt_cp_mesh_send *send = data;
struct mgmt_rp_mesh_read_features rp;
u16 expected_len;
- bool sending;
int err = 0;
if (!lmp_le_capable(hdev) ||
@@ -2519,6 +2682,15 @@ static int mesh_send(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
hci_dev_lock(hdev);
+ /* Transmissions are flushed when the controller is closed, which is
+ * serialized with this by hdev->lock, so none can be left behind.
+ */
+ if (!hdev_is_powered(hdev)) {
+ err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND,
+ MGMT_STATUS_NOT_POWERED);
+ goto done;
+ }
+
memset(&rp, 0, sizeof(rp));
rp.max_handles = MESH_HANDLES_MAX;
@@ -2530,27 +2702,27 @@ static int mesh_send(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
goto done;
}
- sending = hci_dev_test_flag(hdev, HCI_MESH_SENDING);
mesh_tx = mgmt_mesh_add(sk, hdev, send, len);
-
- if (!mesh_tx)
+ if (!mesh_tx) {
err = -ENOMEM;
- else if (!sending)
- err = hci_cmd_sync_queue(hdev, mesh_send_sync, mesh_tx,
- mesh_send_start_complete);
+ } else {
+ u8 handle = mesh_tx->handle;
+
+ /* The first transmission is the one queued, which may not be
+ * the one just added.
+ */
+ __mesh_next(hdev, handle);
+
+ /* Queueing failed, the transmission was removed */
+ if (!mgmt_mesh_find(hdev, handle))
+ err = -EIO;
+ }
if (err < 0) {
bt_dev_err(hdev, "Send Mesh Failed %d", err);
err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND,
MGMT_STATUS_FAILED);
-
- if (mesh_tx) {
- if (sending)
- mgmt_mesh_remove(mesh_tx);
- }
} else {
- hci_dev_set_flag(hdev, HCI_MESH_SENDING);
-
mgmt_cmd_complete(sk, hdev->id, MGMT_OP_MESH_SEND, 0,
&mesh_tx->handle, 1);
}
@@ -9914,7 +10086,8 @@ void mgmt_index_removed(struct hci_dev *hdev)
cancel_delayed_work_sync(&hdev->discov_off);
cancel_delayed_work_sync(&hdev->service_cache);
cancel_delayed_work_sync(&hdev->rpa_expired);
- cancel_delayed_work_sync(&hdev->mesh_send_done);
+
+ mesh_flush(hdev, true);
}
void mgmt_power_on(struct hci_dev *hdev, int err)
@@ -9941,6 +10114,16 @@ void mgmt_power_on(struct hci_dev *hdev, int err)
hci_dev_unlock(hdev);
}
+/* This function requires the caller holds hdev->lock */
+void mgmt_mesh_flush(struct hci_dev *hdev)
+{
+ /* The mesh work is only initialized once mgmt is used */
+ if (!hci_dev_test_flag(hdev, HCI_MGMT))
+ return;
+
+ mesh_flush(hdev, false);
+}
+
void __mgmt_power_off(struct hci_dev *hdev)
{
struct cmd_lookup match = { NULL, hdev };
diff --git a/net/bluetooth/mgmt_util.c b/net/bluetooth/mgmt_util.c
index 6ea107c0e0543..d502e6b933e81 100644
--- a/net/bluetooth/mgmt_util.c
+++ b/net/bluetooth/mgmt_util.c
@@ -409,16 +409,31 @@ struct mgmt_mesh_tx *mgmt_mesh_add(struct sock *sk, struct hci_dev *hdev,
void *data, u16 len)
{
struct mgmt_mesh_tx *mesh_tx;
+ u8 handle = hdev->mesh_send_ref;
+ int i;
+
+ /* The handle is all that identifies a transmission, so it must not be
+ * in use by one still pending when the counter wraps around.
+ */
+ for (i = 0; i < 255; i++) {
+ handle++;
+ if (!handle)
+ handle++;
+
+ if (!mgmt_mesh_find(hdev, handle))
+ break;
+ }
+
+ if (i == 255)
+ return NULL;
mesh_tx = kzalloc_obj(*mesh_tx);
if (!mesh_tx)
return NULL;
- hdev->mesh_send_ref++;
- if (!hdev->mesh_send_ref)
- hdev->mesh_send_ref++;
+ hdev->mesh_send_ref = handle;
- mesh_tx->handle = hdev->mesh_send_ref;
+ mesh_tx->handle = handle;
mesh_tx->index = hdev->id;
memcpy(mesh_tx->param, data, len);
mesh_tx->param_len = len;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 121/742] Bluetooth: MGMT: Fix use-after-free in mgmt_powering_down()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (117 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 120/742] Bluetooth: mgmt: Fix mesh transmission locking and lifetime Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 122/742] Bluetooth: MSFT: Protect the event prefix with hdev->lock Greg Kroah-Hartman
` (607 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 7c8dcf322b0d978c80001632c1206d5fe1ee9ba7 ]
mgmt_powering_down() looked up the Set Powered command and read its
parameters after mgmt_pending_find() dropped mgmt_pending_lock, so the
command could be unlinked and freed in between. Do the lookup and read the
parameters while holding the lock.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-e45413fa-48a6-43f1-90be-638841567534
Fixes: 302a1f674c00 ("Bluetooth: MGMT: Fix possible UAFs")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/mgmt.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 83a1454b85b4d..502f6deb54446 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -10399,19 +10399,27 @@ bool mgmt_powering_down(struct hci_dev *hdev)
{
struct mgmt_pending_cmd *cmd;
struct mgmt_mode *cp;
+ bool powering_down = false;
if (hci_dev_test_flag(hdev, HCI_POWERING_DOWN))
return true;
- cmd = pending_find(MGMT_OP_SET_POWERED, hdev);
- if (!cmd)
- return false;
+ mutex_lock(&hdev->mgmt_pending_lock);
- cp = cmd->param;
- if (!cp->val)
- return true;
+ list_for_each_entry(cmd, &hdev->mgmt_pending, list) {
+ if (hci_sock_get_channel(cmd->sk) != HCI_CHANNEL_CONTROL ||
+ cmd->opcode != MGMT_OP_SET_POWERED)
+ continue;
- return false;
+ /* cmd can only be freed after it is unlinked under the lock */
+ cp = cmd->param;
+ powering_down = !cp->val;
+ break;
+ }
+
+ mutex_unlock(&hdev->mgmt_pending_lock);
+
+ return powering_down;
}
u8 hci_to_mgmt_reason(u8 err)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 122/742] Bluetooth: MSFT: Protect the event prefix with hdev->lock
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (118 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 121/742] Bluetooth: MGMT: Fix use-after-free in mgmt_powering_down() Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 123/742] Bluetooth: hci_debugfs: Fix racy toggling of debugfs controlled flags Greg Kroah-Hartman
` (606 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 0434cd10518c1b58ca3f5366341f0b1c469afbca ]
msft_vendor_evt() read msft->evt_prefix_len and compared evt_prefix before
taking hdev->lock, while msft_do_open() (and the supported features
reply) free and reallocate the prefix without it, so an event received
while the controller is being opened could access freed memory. Take
hdev->lock for the whole event processing and while updating the prefix.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-246df501-f32c-46fd-8779-7fa755ed7f9d
Fixes: 5031ffcc79b8 ("Bluetooth: Keep MSFT ext info throughout a hci_dev's life cycle")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/msft.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index 2559c5b1bef02..ab63fee3ef597 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -170,11 +170,16 @@ static bool read_supported_features(struct hci_dev *hdev,
goto failed;
}
+ /* The event prefix is used by msft_vendor_evt() with hdev->lock held */
+ hci_dev_lock(hdev);
+
if (rp->evt_prefix_len > 0) {
msft->evt_prefix = kmemdup(rp->evt_prefix, rp->evt_prefix_len,
GFP_KERNEL);
- if (!msft->evt_prefix)
+ if (!msft->evt_prefix) {
+ hci_dev_unlock(hdev);
goto failed;
+ }
}
msft->evt_prefix_len = rp->evt_prefix_len;
@@ -183,6 +188,8 @@ static bool read_supported_features(struct hci_dev *hdev,
if (msft->features & MSFT_FEATURE_MASK_CURVE_VALIDITY)
hdev->msft_curve_validity = true;
+ hci_dev_unlock(hdev);
+
kfree_skb(skb);
return true;
@@ -648,10 +655,12 @@ void msft_do_open(struct hci_dev *hdev)
bt_dev_dbg(hdev, "Initialize MSFT extension");
/* Reset existing MSFT data before re-reading */
+ hci_dev_lock(hdev);
kfree(msft->evt_prefix);
msft->evt_prefix = NULL;
msft->evt_prefix_len = 0;
msft->features = 0;
+ hci_dev_unlock(hdev);
if (!read_supported_features(hdev, msft)) {
hci_dev_lock(hdev);
@@ -1078,12 +1087,15 @@ static void msft_monitor_device_evt(struct hci_dev *hdev, struct sk_buff *skb)
void msft_vendor_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb)
{
- struct msft_data *msft = hdev->msft_data;
+ struct msft_data *msft;
u8 *evt_prefix;
u8 *evt;
+ hci_dev_lock(hdev);
+
+ msft = hdev->msft_data;
if (!msft)
- return;
+ goto unlock;
/* When the extension has defined an event prefix, check that it
* matches, and otherwise just return.
@@ -1091,23 +1103,21 @@ void msft_vendor_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb)
if (msft->evt_prefix_len > 0) {
evt_prefix = msft_skb_pull(hdev, skb, 0, msft->evt_prefix_len);
if (!evt_prefix)
- return;
+ goto unlock;
if (memcmp(evt_prefix, msft->evt_prefix, msft->evt_prefix_len))
- return;
+ goto unlock;
}
/* Every event starts at least with an event code and the rest of
* the data is variable and depends on the event code.
*/
if (skb->len < 1)
- return;
+ goto unlock;
evt = msft_skb_pull(hdev, skb, 0, sizeof(*evt));
if (!evt)
- return;
-
- hci_dev_lock(hdev);
+ goto unlock;
switch (*evt) {
case MSFT_EV_LE_MONITOR_DEVICE:
@@ -1121,6 +1131,7 @@ void msft_vendor_evt(struct hci_dev *hdev, void *data, struct sk_buff *skb)
break;
}
+unlock:
hci_dev_unlock(hdev);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 123/742] Bluetooth: hci_debugfs: Fix racy toggling of debugfs controlled flags
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (119 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 122/742] Bluetooth: MSFT: Protect the event prefix with hdev->lock Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 124/742] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors Greg Kroah-Hartman
` (605 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit b49abf5f92ea0e03ebc0fe41ce4af87b094fe9b5 ]
The debugfs writers checked the current state of the flag, then blindly
inverted it with hci_dev_change_flag(). Two concurrent writers both pass
the check and the second inversion undoes the first one, leaving the flag
out of sync with the actual controller/SMP channel state (e.g. DUT mode
flag vs controller, or the BR/EDR SMP channel being leaked or removed
twice).
Set or clear the flag explicitly instead, redo the dut_mode check under
hci_req_sync_lock() and serialize smp_force_bredr() with hdev->lock. The
same applies to the quirk attributes.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-442108d5-76ce-44a1-a84d-16b44d6a26a6
Fixes: 4b4148e9acc1 ("Bluetooth: Add support for setting DUT mode")
Fixes: b55d1abf568c ("Bluetooth: Expose quirks through debugfs")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/hci_debugfs.c | 32 +++++++++++++++++++++++++-------
net/bluetooth/smp.c | 25 +++++++++++++++++++------
2 files changed, 44 insertions(+), 13 deletions(-)
diff --git a/net/bluetooth/hci_debugfs.c b/net/bluetooth/hci_debugfs.c
index cd5ef398f2382..1af68bfc2257a 100644
--- a/net/bluetooth/hci_debugfs.c
+++ b/net/bluetooth/hci_debugfs.c
@@ -59,7 +59,7 @@ static ssize_t __name ## _write(struct file *file, \
if (enable == test_bit(__quirk, hdev->quirk_flags)) \
return -EALREADY; \
\
- change_bit(__quirk, hdev->quirk_flags); \
+ assign_bit(__quirk, hdev->quirk_flags, enable); \
\
return count; \
} \
@@ -777,7 +777,10 @@ static ssize_t force_static_address_write(struct file *file,
if (enable == hci_dev_test_flag(hdev, HCI_FORCE_STATIC_ADDR))
return -EALREADY;
- hci_dev_change_flag(hdev, HCI_FORCE_STATIC_ADDR);
+ if (enable)
+ hci_dev_set_flag(hdev, HCI_FORCE_STATIC_ADDR);
+ else
+ hci_dev_clear_flag(hdev, HCI_FORCE_STATIC_ADDR);
return count;
}
@@ -1177,7 +1180,10 @@ static ssize_t force_no_mitm_write(struct file *file,
if (enable == hci_dev_test_flag(hdev, HCI_FORCE_NO_MITM))
return -EALREADY;
- hci_dev_change_flag(hdev, HCI_FORCE_NO_MITM);
+ if (enable)
+ hci_dev_set_flag(hdev, HCI_FORCE_NO_MITM);
+ else
+ hci_dev_clear_flag(hdev, HCI_FORCE_NO_MITM);
return count;
}
@@ -1303,20 +1309,32 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf,
return -EALREADY;
hci_req_sync_lock(hdev);
+
+ /* Check again now that concurrent writers are excluded */
+ if (enable == hci_dev_test_flag(hdev, HCI_DUT_MODE)) {
+ hci_req_sync_unlock(hdev);
+ return -EALREADY;
+ }
+
if (enable)
skb = __hci_cmd_sync(hdev, HCI_OP_ENABLE_DUT_MODE, 0, NULL,
HCI_CMD_TIMEOUT);
else
skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL,
HCI_CMD_TIMEOUT);
- hci_req_sync_unlock(hdev);
-
- if (IS_ERR(skb))
+ if (IS_ERR(skb)) {
+ hci_req_sync_unlock(hdev);
return PTR_ERR(skb);
+ }
kfree_skb(skb);
- hci_dev_change_flag(hdev, HCI_DUT_MODE);
+ if (enable)
+ hci_dev_set_flag(hdev, HCI_DUT_MODE);
+ else
+ hci_dev_clear_flag(hdev, HCI_DUT_MODE);
+
+ hci_req_sync_unlock(hdev);
return count;
}
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index ae94d33d020fa..33445d1988a26 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -3365,8 +3365,14 @@ static void smp_del_chan(struct l2cap_chan *chan)
int smp_force_bredr(struct hci_dev *hdev, bool enable)
{
- if (enable == hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP))
- return -EALREADY;
+ int err = 0;
+
+ hci_dev_lock(hdev);
+
+ if (enable == hci_dev_test_flag(hdev, HCI_FORCE_BREDR_SMP)) {
+ err = -EALREADY;
+ goto unlock;
+ }
/* The channels are only registered while the controller is powered
* and LE capable. Otherwise just record the flag, smp_register() will
@@ -3377,8 +3383,10 @@ int smp_force_bredr(struct hci_dev *hdev, bool enable)
if (hdev->smp_data && !hdev->smp_bredr_data) {
chan = smp_add_cid(hdev, L2CAP_CID_SMP_BREDR);
- if (IS_ERR(chan))
- return PTR_ERR(chan);
+ if (IS_ERR(chan)) {
+ err = PTR_ERR(chan);
+ goto unlock;
+ }
hdev->smp_bredr_data = chan;
}
@@ -3392,9 +3400,14 @@ int smp_force_bredr(struct hci_dev *hdev, bool enable)
}
}
- hci_dev_change_flag(hdev, HCI_FORCE_BREDR_SMP);
+ if (enable)
+ hci_dev_set_flag(hdev, HCI_FORCE_BREDR_SMP);
+ else
+ hci_dev_clear_flag(hdev, HCI_FORCE_BREDR_SMP);
- return 0;
+unlock:
+ hci_dev_unlock(hdev);
+ return err;
}
int smp_register(struct hci_dev *hdev)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 124/742] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (120 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 123/742] Bluetooth: hci_debugfs: Fix racy toggling of debugfs controlled flags Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 125/742] Bluetooth: MSFT: Free the response of the monitor commands Greg Kroah-Hartman
` (604 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 7f08b6ef44fa17f1a5ad3926663ddb5abe6ff68a ]
hci_remove_single_adv_monitor() and hci_remove_all_adv_monitor() only
require hci_req_sync_lock, yet they look up and free monitors, modifying
hdev->adv_monitors_idr and adv_monitors_cnt, which Read Advertisement
Monitor Features iterates under hdev->lock. Take hdev->lock around the
IDR accesses and the freeing, but not across the HCI commands sent to the
controller.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-8b358899-5ac9-4687-af16-58420a4d9bba
Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/hci_core.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index ed9a83777af0d..110d2ec51f411 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2028,7 +2028,10 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev,
if (status == -ENOENT)
bt_dev_warn(hdev, "Removing monitor with no matching handle %d",
monitor->handle);
+
+ hci_dev_lock(hdev);
hci_free_adv_monitor(hdev, monitor);
+ hci_dev_unlock(hdev);
return status;
}
@@ -2036,7 +2039,11 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev,
/* This function requires the caller holds hci_req_sync_lock */
int hci_remove_single_adv_monitor(struct hci_dev *hdev, u16 handle)
{
- struct adv_monitor *monitor = idr_find(&hdev->adv_monitors_idr, handle);
+ struct adv_monitor *monitor;
+
+ hci_dev_lock(hdev);
+ monitor = idr_find(&hdev->adv_monitors_idr, handle);
+ hci_dev_unlock(hdev);
if (!monitor)
return -EINVAL;
@@ -2052,7 +2059,10 @@ int hci_remove_all_adv_monitor(struct hci_dev *hdev)
int status = 0;
while (1) {
+ hci_dev_lock(hdev);
monitor = idr_get_next(&hdev->adv_monitors_idr, &idr_next_id);
+ hci_dev_unlock(hdev);
+
if (!monitor)
break;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 125/742] Bluetooth: MSFT: Free the response of the monitor commands
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (121 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 124/742] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 126/742] Bluetooth: hci_core: Dont fail removing a monitor unknown to the controller Greg Kroah-Hartman
` (603 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 775eca0c3df2f0272f21ebc8c812ad010fd47243 ]
msft_add_monitor_sync() and msft_remove_monitor_sync() send the MSFT
command with __hci_cmd_sync() and pass the returned skb to the callbacks,
which only parse it, so it is never freed. Free it once the callback
returns.
While at it initialize the RSSI fields of the handle data when it is
created instead of after the command completed, so they are never exposed
uninitialized, and do the lookup of the handle map in
msft_remove_monitor_sync() with hdev->lock held.
Found by the sashiko.dev review of the previous revision of this series.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20261117185737.3758255-1-luiz.dentz%40gmail.com
Fixes: b747a83690c8 ("Bluetooth: hci_sync: Refactor add Adv Monitor")
Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/msft.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index ab63fee3ef597..7a06c2b8974b7 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -297,6 +297,10 @@ static int msft_le_monitor_advertisement_cb(struct hci_dev *hdev, u16 opcode,
handle_data->mgmt_handle = monitor->handle;
handle_data->msft_handle = rp->handle;
handle_data->cond_type = MSFT_MONITOR_ADVERTISEMENT_TYPE_PATTERN;
+ handle_data->rssi_high = monitor->rssi.high_threshold;
+ handle_data->rssi_low = monitor->rssi.low_threshold;
+ handle_data->rssi_low_interval = (u8)monitor->rssi.low_threshold_timeout;
+ handle_data->rssi_sampling_period = monitor->rssi.sampling_period;
INIT_LIST_HEAD(&handle_data->list);
list_add(&handle_data->list, &msft->handle_map);
@@ -438,23 +442,30 @@ static int msft_remove_monitor_sync(struct hci_dev *hdev,
struct msft_cp_le_cancel_monitor_advertisement cp;
struct msft_monitor_advertisement_handle_data *handle_data;
struct sk_buff *skb;
+ int err;
+ hci_dev_lock(hdev);
handle_data = msft_find_handle_data(hdev, monitor->handle, true);
+ if (handle_data)
+ cp.handle = handle_data->msft_handle;
+ hci_dev_unlock(hdev);
/* If no matched handle, just remove without telling controller */
if (!handle_data)
return -ENOENT;
cp.sub_opcode = MSFT_OP_LE_CANCEL_MONITOR_ADVERTISEMENT;
- cp.handle = handle_data->msft_handle;
skb = __hci_cmd_sync(hdev, hdev->msft_opcode, sizeof(cp), &cp,
HCI_CMD_TIMEOUT);
if (IS_ERR(skb))
return PTR_ERR(skb);
- return msft_le_cancel_monitor_advertisement_cb(hdev, hdev->msft_opcode,
- monitor, skb);
+ err = msft_le_cancel_monitor_advertisement_cb(hdev, hdev->msft_opcode,
+ monitor, skb);
+ kfree_skb(skb);
+
+ return err;
}
/* This function requires the caller holds hci_req_sync_lock */
@@ -519,7 +530,6 @@ static int msft_add_monitor_sync(struct hci_dev *hdev,
{
struct msft_cp_le_monitor_advertisement *cp;
struct msft_le_monitor_advertisement_pattern_data *pattern_data;
- struct msft_monitor_advertisement_handle_data *handle_data;
struct msft_le_monitor_advertisement_pattern *pattern;
struct adv_pattern *entry;
size_t total_size = sizeof(*cp) + sizeof(*pattern_data);
@@ -571,19 +581,7 @@ static int msft_add_monitor_sync(struct hci_dev *hdev,
err = msft_le_monitor_advertisement_cb(hdev, hdev->msft_opcode,
monitor, skb);
- if (err)
- goto out_free;
-
- handle_data = msft_find_handle_data(hdev, monitor->handle, true);
- if (!handle_data) {
- err = -ENODATA;
- goto out_free;
- }
-
- handle_data->rssi_high = cp->rssi_high;
- handle_data->rssi_low = cp->rssi_low;
- handle_data->rssi_low_interval = cp->rssi_low_interval;
- handle_data->rssi_sampling_period = cp->rssi_sampling_period;
+ kfree_skb(skb);
out_free:
kfree(cp);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 126/742] Bluetooth: hci_core: Dont fail removing a monitor unknown to the controller
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (122 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 125/742] Bluetooth: MSFT: Free the response of the monitor commands Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 127/742] Bluetooth: hci_sync: Fix remaining advertising instance UAFs Greg Kroah-Hartman
` (602 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 8d3e5e6fe6d0be5634b28788abf5685d571b13a4 ]
hci_remove_adv_monitor() frees the monitor when the controller has no
matching handle for it but still returned -ENOENT, so callers took it for
a failure of a monitor that is gone, and hci_remove_all_adv_monitor()
stopped at the first one leaving the others behind. Return success since
the monitor was removed.
Found by the sashiko.dev review of the previous revision of this series.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20261117185737.3758255-1-luiz.dentz%40gmail.com
Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/hci_core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 110d2ec51f411..4b8538f8eca1c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2033,7 +2033,10 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev,
hci_free_adv_monitor(hdev, monitor);
hci_dev_unlock(hdev);
- return status;
+ /* The monitor is gone, not having been known by the controller is not
+ * an error for the caller.
+ */
+ return status == -ENOENT ? 0 : status;
}
/* This function requires the caller holds hci_req_sync_lock */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 127/742] Bluetooth: hci_sync: Fix remaining advertising instance UAFs
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (123 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 126/742] Bluetooth: hci_core: Dont fail removing a monitor unknown to the controller Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 128/742] Bluetooth: hci_sync: Use controller handles for periodic advertising Greg Kroah-Hartman
` (601 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Cen Zhang, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <zzzccc427@gmail.com>
[ Upstream commit d7e77168da348d8ac0fdb3b3aa7ce1ccc83208a7 ]
hci_enable_ext_advertising_sync() looks up the advertising instance
without hdev->lock and then reads it, while HCI event processing can
free the instance under the lock:
Request work HCI event work
hci_enable_ext_advertising_sync()
adv = hci_find_adv_instance()
hci_cc_le_clear_adv_sets()
hci_dev_lock(hdev)
hci_remove_adv_instance()
kfree(adv)
hci_dev_unlock(hdev)
reads adv->enabled
Since the conversion to hci_sync, the advertising request paths run
without hdev->lock, and the periodic advertising, advertising timeout
and mesh code added later does the same, while management commands and
HCI event processing still add and free instances under the lock. The
same unlocked use exists in:
- hci_set_adv_data_sync(), hci_disable_ext_adv_instance_sync(),
the periodic advertising enable
and disable helpers, hci_schedule_adv_instance_sync(),
adv_expire_sync() and set_advertising_complete()
- hci_enable_advertising_sync() and hci_start_per_adv_sync(), which
keep the instance across HCI commands
- hci_remove_advertising_sync() and hci_clear_adv_instance_sync(),
which keep the next instance as a pointer
- mesh_send_sync(), which adds the mesh instance
- the walks of hdev->adv_instances in hci_dev_open_sync(),
hci_dev_close_sync(), hci_resume_advertising_sync() and
hci_powered_update_adv_sync()
Fix them as commit cdc36db204ff ("Bluetooth: hci_sync: Fix advertising
data UAFs") does for the extended advertising data paths: look the
instance up under hdev->lock, copy what is needed, and release the lock
before a command is sent, since command completion handlers take it.
Keep the next instance as an instance number. Walks that send no command
hold the lock, as hci_clear_adv_sync() does. The resume and power on
walks send a command per instance and cannot hold it, so they copy the
instance numbers under the lock into a fixed stack array first. Instance
identifiers are nonzero u8 values, so 255 bytes cover the whole
namespace. This preserves list order without adding an allocation
failure after the resume path consumes its pause state.
Use a u32 for the timeout-to-milliseconds conversion before converting
to the controller's 10 ms units, and clamp the result to U16_MAX. The
old u16 intermediate wrapped timeouts longer than 65 seconds.
KASAN report as below:
BUG: KASAN: slab-use-after-free in
hci_enable_ext_advertising_sync+0x2fd/0x330
Read of size 1 at addr ffff88811673b810 by task kworker/u17:0/492
Workqueue: hci0 hci_cmd_sync_work
Call Trace:
hci_enable_ext_advertising_sync+0x2fd/0x330
add_ext_adv_data_sync+0x1f8/0x250
hci_cmd_sync_work+0x1b3/0x450
Allocated by task 490:
hci_add_adv_instance+0x627/0x960
add_ext_adv_params+0x4d4/0xaf0
hci_sock_sendmsg+0x128b/0x22e0
Freed by task 495:
kfree+0x307/0x580
hci_remove_adv_instance+0x226/0x4f0
hci_cc_le_clear_adv_sets+0x2a5/0x400
hci_cmd_complete_evt+0x373/0xab0
hci_event_packet+0x4e8/0xc70
hci_rx_work+0x367/0xf00
The buggy address belongs to the object at ffff88811673b800
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 16 bytes inside of
freed 1024-byte region [ffff88811673b800, ffff88811673bc00)
Fixes: cba6b758711c ("Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2")
Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
Fixes: c249ea9b4309 ("Bluetooth: Move Adv Instance timer to hci_sync")
Fixes: b338d91703fa ("Bluetooth: Implement support for Mesh")
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/hci_sync.c | 245 +++++++++++++++++++++++++++++----------
net/bluetooth/mgmt.c | 29 +++--
2 files changed, 203 insertions(+), 71 deletions(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 012ee0b6cc01c..d1f2929bb8772 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -499,7 +499,8 @@ static void cancel_adv_timeout(struct hci_dev *hdev)
int hci_clear_adv_instance_sync(struct hci_dev *hdev, struct sock *sk,
u8 instance, bool force)
{
- struct adv_info *adv_instance, *n, *next_instance = NULL;
+ struct adv_info *adv_instance, *n;
+ u8 next_instance = 0;
int err;
u8 rem_inst;
@@ -507,12 +508,20 @@ int hci_clear_adv_instance_sync(struct hci_dev *hdev, struct sock *sk,
if (!instance || hdev->cur_adv_instance == instance)
cancel_adv_timeout(hdev);
+ /* This is safe as long as there is no command send while the
+ * lock is held.
+ */
+ hci_dev_lock(hdev);
+
/* Get the next instance to advertise BEFORE we remove
* the current one. This can be the same instance again
* if there is only one instance.
*/
- if (instance && hdev->cur_adv_instance == instance)
- next_instance = hci_get_next_instance(hdev, instance);
+ if (instance && hdev->cur_adv_instance == instance) {
+ adv_instance = hci_get_next_instance(hdev, instance);
+ if (adv_instance)
+ next_instance = adv_instance->instance;
+ }
if (instance == 0x00) {
list_for_each_entry_safe(adv_instance, n, &hdev->adv_instances,
@@ -531,9 +540,8 @@ int hci_clear_adv_instance_sync(struct hci_dev *hdev, struct sock *sk,
if (force || (adv_instance && adv_instance->timeout &&
!adv_instance->remaining_time)) {
/* Don't advertise a removed instance. */
- if (next_instance &&
- next_instance->instance == instance)
- next_instance = NULL;
+ if (next_instance == instance)
+ next_instance = 0;
err = hci_remove_adv_instance(hdev, instance);
if (!err)
@@ -541,12 +549,13 @@ int hci_clear_adv_instance_sync(struct hci_dev *hdev, struct sock *sk,
}
}
+ hci_dev_unlock(hdev);
+
if (!hdev_is_powered(hdev) || hci_dev_test_flag(hdev, HCI_ADVERTISING))
return 0;
if (next_instance && !ext_adv_capable(hdev))
- return hci_schedule_adv_instance_sync(hdev,
- next_instance->instance,
+ return hci_schedule_adv_instance_sync(hdev, next_instance,
false);
return 0;
@@ -1394,14 +1403,21 @@ static int hci_set_ext_adv_data_sync(struct hci_dev *hdev, u8 instance)
}
static int hci_set_adv_data_sync(struct hci_dev *hdev, u8 instance)
+ __context_unsafe(/* conditional locking */)
{
struct hci_cp_le_set_adv_data cp;
u8 len;
memset(&cp, 0, sizeof(cp));
+ if (instance)
+ hci_dev_lock(hdev);
+
len = eir_create_adv_data(hdev, instance, cp.data, sizeof(cp.data));
+ if (instance)
+ hci_dev_unlock(hdev);
+
/* There's nothing to do if the data hasn't changed */
if (hdev->adv_data_len == len &&
memcmp(cp.data, hdev->adv_data, len) == 0)
@@ -1690,17 +1706,33 @@ int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance)
struct hci_cp_le_set_ext_adv_enable *cp;
struct hci_cp_ext_adv_set *set;
u8 data[sizeof(*cp) + sizeof(*set) * 1];
- struct adv_info *adv;
+ u8 handle = instance;
+ u32 duration = 0;
if (instance > 0) {
+ struct adv_info *adv;
+
+ hci_dev_lock(hdev);
adv = hci_find_adv_instance(hdev, instance);
- if (!adv)
+ if (!adv) {
+ hci_dev_unlock(hdev);
return -EINVAL;
+ }
/* If already enabled there is nothing to do */
- if (adv->enabled)
+ if (adv->enabled) {
+ hci_dev_unlock(hdev);
return 0;
- } else {
- adv = NULL;
+ }
+
+ handle = adv->handle;
+
+ /* Set duration per instance since controller is
+ * responsible for scheduling it.
+ */
+ if (adv->timeout)
+ duration = adv->mesh ? adv->timeout :
+ adv->timeout * MSEC_PER_SEC;
+ hci_dev_unlock(hdev);
}
cp = (void *)data;
@@ -1713,18 +1745,10 @@ int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance)
memset(set, 0, sizeof(*set));
- set->handle = adv ? adv->handle : instance;
-
- /* Set duration per instance since controller is responsible for
- * scheduling it.
- */
- if (adv && adv->timeout) {
- u16 duration = adv->mesh ? adv->timeout :
- adv->timeout * MSEC_PER_SEC;
+ set->handle = handle;
- /* Time = N * 10 ms */
- set->duration = cpu_to_le16(duration / 10);
- }
+ /* Time = N * 10 ms */
+ set->duration = cpu_to_le16(min_t(u32, duration / 10, U16_MAX));
/* Track which instance owns the advertising set since the handle
* alone is ambiguous when instances share handle 0x00, see
@@ -1756,11 +1780,15 @@ int hci_start_ext_adv_sync(struct hci_dev *hdev, u8 instance)
int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
{
struct hci_cp_le_set_per_adv_enable cp;
- struct adv_info *adv = NULL;
+ struct adv_info *adv;
+ bool enabled;
/* If periodic advertising already disabled there is nothing to do. */
+ hci_dev_lock(hdev);
adv = hci_find_adv_instance(hdev, instance);
- if (!adv || !adv->periodic_enabled)
+ enabled = adv && adv->periodic_enabled;
+ hci_dev_unlock(hdev);
+ if (!enabled)
return 0;
memset(&cp, 0, sizeof(cp));
@@ -1829,11 +1857,15 @@ static int hci_set_per_adv_data_sync(struct hci_dev *hdev, u8 instance)
static int hci_enable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
{
struct hci_cp_le_set_per_adv_enable cp;
- struct adv_info *adv = NULL;
+ struct adv_info *adv;
+ bool enabled;
/* If periodic advertising already enabled there is nothing to do. */
+ hci_dev_lock(hdev);
adv = hci_find_adv_instance(hdev, instance);
- if (adv && adv->periodic_enabled)
+ enabled = adv && adv->periodic_enabled;
+ hci_dev_unlock(hdev);
+ if (enabled)
return 0;
memset(&cp, 0, sizeof(cp));
@@ -1848,25 +1880,36 @@ static int hci_enable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
/* Checks if periodic advertising data contains a Basic Announcement and if it
* does generates a Broadcast ID and add Broadcast Announcement.
*/
-static int hci_adv_bcast_annoucement(struct hci_dev *hdev, struct adv_info *adv)
+static int hci_adv_bcast_annoucement(struct hci_dev *hdev, u8 instance)
{
+ struct adv_info *adv;
u8 bid[3];
u8 ad[HCI_MAX_EXT_AD_LENGTH];
u8 len;
+ int err = 0;
- /* Skip if NULL adv as instance 0x00 is used for general purpose
+ /* Skip if instance 0x00 as it is used for general purpose
* advertising so it cannot used for the likes of Broadcast Announcement
* as it can be overwritten at any point.
*/
- if (!adv)
+ if (!instance)
return 0;
+ hci_dev_lock(hdev);
+
+ /* The instance may have been removed while waiting for the
+ * controller, in which case there is nothing to announce.
+ */
+ adv = hci_find_adv_instance(hdev, instance);
+ if (!adv)
+ goto unlock;
+
/* Check if PA data doesn't contains a Basic Audio Announcement then
* there is nothing to do.
*/
if (!eir_get_service_data(adv->per_adv_data, adv->per_adv_data_len,
0x1851, NULL))
- return 0;
+ goto unlock;
/* Check if advertising data already has a Broadcast Announcement since
* the process may want to control the Broadcast ID directly and in that
@@ -1874,34 +1917,44 @@ static int hci_adv_bcast_annoucement(struct hci_dev *hdev, struct adv_info *adv)
*/
if (eir_get_service_data(adv->adv_data, adv->adv_data_len, 0x1852,
NULL))
- return 0;
+ goto unlock;
/* Generate Broadcast ID */
get_random_bytes(bid, sizeof(bid));
len = eir_append_service_data(ad, 0, 0x1852, bid, sizeof(bid));
if (adv->adv_data_len > sizeof(ad) - len) {
bt_dev_err(hdev, "No room for Broadcast Announcement");
- return -EINVAL;
+ err = -EINVAL;
+ goto unlock;
}
memcpy(ad + len, adv->adv_data, adv->adv_data_len);
- hci_set_adv_instance_data(hdev, adv->instance, len + adv->adv_data_len,
+ hci_set_adv_instance_data(hdev, instance, len + adv->adv_data_len,
ad, 0, NULL);
- return hci_update_adv_data_sync(hdev, adv->instance);
+ hci_dev_unlock(hdev);
+
+ return hci_update_adv_data_sync(hdev, instance);
+
+unlock:
+ hci_dev_unlock(hdev);
+ return err;
}
int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 sid,
u8 data_len, u8 *data, u32 flags, u16 min_interval,
u16 max_interval, u16 sync_interval)
{
- struct adv_info *adv = NULL;
+ struct adv_info *adv;
+ u8 bcast_instance = 0;
int err;
bool added = false;
hci_disable_per_advertising_sync(hdev, instance);
if (instance) {
+ hci_dev_lock(hdev);
+
adv = hci_find_adv_instance(hdev, instance);
if (adv) {
if (sid != HCI_SID_INVALID && adv->sid != sid) {
@@ -1910,6 +1963,7 @@ int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 sid,
*/
adv = hci_find_adv_sid(hdev, sid);
if (!adv) {
+ hci_dev_unlock(hdev);
bt_dev_err(hdev,
"Unable to find adv_info");
return -EINVAL;
@@ -1928,11 +1982,17 @@ int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 sid,
data_len, data,
sync_interval,
sync_interval);
- if (IS_ERR(adv))
+ if (IS_ERR(adv)) {
+ hci_dev_unlock(hdev);
return PTR_ERR(adv);
+ }
adv->pending = false;
added = true;
}
+
+ bcast_instance = adv->instance;
+
+ hci_dev_unlock(hdev);
}
/* Start advertising */
@@ -1940,7 +2000,7 @@ int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 sid,
if (err < 0)
goto fail;
- err = hci_adv_bcast_annoucement(hdev, adv);
+ err = hci_adv_bcast_annoucement(hdev, bcast_instance);
if (err < 0)
goto fail;
@@ -1960,8 +2020,11 @@ int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 sid,
return 0;
fail:
- if (added)
+ if (added) {
+ hci_dev_lock(hdev);
hci_remove_adv_instance(hdev, instance);
+ hci_dev_unlock(hdev);
+ }
return err;
}
@@ -1991,6 +2054,7 @@ int hci_enable_advertising_sync(struct hci_dev *hdev)
u8 own_addr_type, enable = 0x01;
bool connectable;
u16 adv_min_interval, adv_max_interval;
+ bool scannable;
u32 flags;
u8 status;
@@ -1998,8 +2062,25 @@ int hci_enable_advertising_sync(struct hci_dev *hdev)
return hci_enable_ext_advertising_sync(hdev,
hdev->cur_adv_instance);
+ /* Snapshot the instance under hdev->lock since it may be removed
+ * while waiting for the commands below to complete.
+ */
+ hci_dev_lock(hdev);
+
flags = hci_adv_instance_flags(hdev, hdev->cur_adv_instance);
+ scannable = hci_adv_instance_is_scannable(hdev,
+ hdev->cur_adv_instance);
+
adv_instance = hci_find_adv_instance(hdev, hdev->cur_adv_instance);
+ if (adv_instance) {
+ adv_min_interval = adv_instance->min_interval;
+ adv_max_interval = adv_instance->max_interval;
+ } else {
+ adv_min_interval = hdev->le_adv_min_interval;
+ adv_max_interval = hdev->le_adv_max_interval;
+ }
+
+ hci_dev_unlock(hdev);
/* If the "connectable" instance flag was not set, then choose between
* ADV_IND and ADV_NONCONN_IND based on the global connectable setting.
@@ -2033,18 +2114,10 @@ int hci_enable_advertising_sync(struct hci_dev *hdev)
memset(&cp, 0, sizeof(cp));
- if (adv_instance) {
- adv_min_interval = adv_instance->min_interval;
- adv_max_interval = adv_instance->max_interval;
- } else {
- adv_min_interval = hdev->le_adv_min_interval;
- adv_max_interval = hdev->le_adv_max_interval;
- }
-
if (connectable) {
cp.type = LE_ADV_IND;
} else {
- if (hci_adv_instance_is_scannable(hdev, hdev->cur_adv_instance))
+ if (scannable)
cp.type = LE_ADV_SCAN_IND;
else
cp.type = LE_ADV_NONCONN_IND;
@@ -2264,7 +2337,7 @@ static int hci_remove_adv_sync(struct hci_dev *hdev, u8 instance,
int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk,
u8 instance, bool force)
{
- struct adv_info *next = NULL;
+ u8 next_instance = 0;
int err;
/* Cancel any timeout concerning the removed instance(s). */
@@ -2275,20 +2348,34 @@ int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk,
* the current one. This can be the same instance again
* if there is only one instance.
*/
- if (hdev->cur_adv_instance == instance)
+ if (hdev->cur_adv_instance == instance) {
+ struct adv_info *next;
+
+ hci_dev_lock(hdev);
next = hci_get_next_instance(hdev, instance);
+ if (next)
+ next_instance = next->instance;
+ hci_dev_unlock(hdev);
+ }
if (!instance) {
err = hci_clear_adv_sync(hdev, sk, force);
if (err)
return err;
} else {
- struct adv_info *adv = hci_find_adv_instance(hdev, instance);
+ struct adv_info *adv;
+ bool remove;
- if (force || (adv && adv->timeout && !adv->remaining_time)) {
+ hci_dev_lock(hdev);
+ adv = hci_find_adv_instance(hdev, instance);
+ remove = force ||
+ (adv && adv->timeout && !adv->remaining_time);
+ hci_dev_unlock(hdev);
+
+ if (remove) {
/* Don't advertise a removed instance. */
- if (next && next->instance == instance)
- next = NULL;
+ if (next_instance == instance)
+ next_instance = 0;
err = hci_remove_adv_sync(hdev, instance, sk);
if (err)
@@ -2299,8 +2386,8 @@ int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk,
if (!hdev_is_powered(hdev) || hci_dev_test_flag(hdev, HCI_ADVERTISING))
return 0;
- if (next && !ext_adv_capable(hdev))
- hci_schedule_adv_instance_sync(hdev, next->instance, false);
+ if (next_instance && !ext_adv_capable(hdev))
+ hci_schedule_adv_instance_sync(hdev, next_instance, false);
return 0;
}
@@ -2765,10 +2852,28 @@ static int hci_pause_advertising_sync(struct hci_dev *hdev)
return 0;
}
+/* Copy the instance identifiers in list order under hdev->lock.
+ * There are at most U8_MAX instances, with identifiers 1..U8_MAX.
+ * Callers can then wait for commands without retaining list pointers.
+ */
+static size_t adv_instance_list_copy(struct hci_dev *hdev, u8 *ids)
+{
+ struct adv_info *adv;
+ size_t n = 0;
+
+ hci_dev_lock(hdev);
+
+ list_for_each_entry(adv, &hdev->adv_instances, list)
+ ids[n++] = adv->instance;
+
+ hci_dev_unlock(hdev);
+
+ return n;
+}
+
/* This function enables all user advertising instances */
static int hci_resume_advertising_sync(struct hci_dev *hdev)
{
- struct adv_info *adv, *tmp;
int err = 0;
/* If advertising has not been paused there is nothing to do. */
@@ -2785,15 +2890,20 @@ static int hci_resume_advertising_sync(struct hci_dev *hdev)
bt_dev_dbg(hdev, "Resuming advertising instances");
if (ext_adv_capable(hdev)) {
+ u8 ids[U8_MAX];
+ size_t i, n;
+
+ n = adv_instance_list_copy(hdev, ids);
+
/* Call for each tracked instance to be re-enabled */
- list_for_each_entry_safe(adv, tmp, &hdev->adv_instances, list) {
+ for (i = 0; i < n; i++) {
err = hci_enable_ext_advertising_sync(hdev,
- adv->instance);
+ ids[i]);
if (!err)
continue;
/* If the instance cannot be resumed remove it */
- hci_remove_ext_adv_instance_sync(hdev, adv->instance,
+ hci_remove_ext_adv_instance_sync(hdev, ids[i],
NULL);
}
@@ -3618,7 +3728,8 @@ int hci_write_le_host_supported_sync(struct hci_dev *hdev, u8 le, u8 simul)
static int hci_powered_update_adv_sync(struct hci_dev *hdev)
{
- struct adv_info *adv, *tmp;
+ u8 ids[U8_MAX];
+ size_t i, n;
int err;
if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED))
@@ -3654,9 +3765,11 @@ static int hci_powered_update_adv_sync(struct hci_dev *hdev)
hci_enable_advertising_sync(hdev);
}
+ n = adv_instance_list_copy(hdev, ids);
+
/* Call for each tracked instance to be scheduled */
- list_for_each_entry_safe(adv, tmp, &hdev->adv_instances, list)
- hci_schedule_adv_instance_sync(hdev, adv->instance, true);
+ for (i = 0; i < n; i++)
+ hci_schedule_adv_instance_sync(hdev, ids[i], true);
return 0;
}
@@ -5608,7 +5721,9 @@ int hci_dev_open_sync(struct hci_dev *hdev)
if (!ret) {
hci_dev_hold(hdev);
hci_dev_set_flag(hdev, HCI_RPA_EXPIRED);
+ hci_dev_lock(hdev);
hci_adv_instances_set_rpa_expired(hdev, true);
+ hci_dev_unlock(hdev);
set_bit(HCI_UP, &hdev->flags);
hci_sock_dev_event(hdev, HCI_DEV_UP);
hci_leds_update_powered(hdev, true);
@@ -5767,8 +5882,10 @@ int hci_dev_close_sync(struct hci_dev *hdev)
cancel_delayed_work_sync(&hdev->rpa_expired);
+ hci_dev_lock(hdev);
list_for_each_entry(adv_instance, &hdev->adv_instances, list)
cancel_delayed_work_sync(&adv_instance->rpa_expired_cb);
+ hci_dev_unlock(hdev);
}
/* Avoid potential lockdep warnings from the *_flush() calls by
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 502f6deb54446..2e696787aeab8 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4183,22 +4183,34 @@ static int user_passkey_neg_reply(struct sock *sk, struct hci_dev *hdev,
static int adv_expire_sync(struct hci_dev *hdev, u32 flags)
{
struct adv_info *adv_instance;
+ u8 instance;
+
+ hci_dev_lock(hdev);
adv_instance = hci_find_adv_instance(hdev, hdev->cur_adv_instance);
if (!adv_instance)
- return 0;
+ goto unlock;
/* stop if current instance doesn't need to be changed */
if (!(adv_instance->flags & flags))
- return 0;
+ goto unlock;
cancel_adv_timeout(hdev);
adv_instance = hci_get_next_instance(hdev, adv_instance->instance);
if (!adv_instance)
- return 0;
+ goto unlock;
- hci_schedule_adv_instance_sync(hdev, adv_instance->instance, true);
+ instance = adv_instance->instance;
+
+ hci_dev_unlock(hdev);
+
+ hci_schedule_adv_instance_sync(hdev, instance, true);
+
+ return 0;
+
+unlock:
+ hci_dev_unlock(hdev);
return 0;
}
@@ -6797,12 +6809,15 @@ static void set_advertising_complete(struct hci_dev *hdev, void *data, int err)
instance = hdev->cur_adv_instance;
if (!instance) {
+ hci_dev_lock(hdev);
adv_instance = list_first_entry_or_null(&hdev->adv_instances,
struct adv_info, list);
- if (!adv_instance)
- return;
+ if (adv_instance)
+ instance = adv_instance->instance;
+ hci_dev_unlock(hdev);
- instance = adv_instance->instance;
+ if (!instance)
+ return;
}
err = hci_schedule_adv_instance_sync(hdev, instance, true);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 128/742] Bluetooth: hci_sync: Use controller handles for periodic advertising
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (124 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 127/742] Bluetooth: hci_sync: Fix remaining advertising instance UAFs Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 129/742] HID: corsair: use disable_work_sync() to tear down the LED workers Greg Kroah-Hartman
` (600 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Cen Zhang, Luiz Augusto von Dentz,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <zzzccc427@gmail.com>
[ Upstream commit a7d2c94ba2995b5fb766d5ec7086f5e6a2774745 ]
Management instance numbers and controller advertising handles differ on
controllers with a single set: instance 1 uses handle 0x00. Periodic
advertising data already sends adv->handle, but the parameters and
enable commands send the instance number. The completion handler also
treats the command's handle as an instance number:
Request worker Controller / completion
create instance 1 on handle 0
send periodic parameters for 1
Unknown Advertising Identifier
Snapshot the handle under hdev->lock for periodic parameters, enable and
disable. For instance 1 using handle 0, update periodic_enabled under
the mutex after the command succeeds. Its completion handler cannot
distinguish that instance from global advertising by the handle alone;
keep the software instance number in the request, as the existing
remove-set and random-address paths do. Use the same mapping for the
advertising set in periodic transfer and both BIG creation commands,
which obtain the instance number from the same broadcast QoS field as
hci_start_per_adv_sync(). Keep the instance number in software state,
and send no HCI command with the mutex held.
Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/hci_sync.c | 68 +++++++++++++++++++++++++++++++++++-----
1 file changed, 61 insertions(+), 7 deletions(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index d1f2929bb8772..54ecb0a79f946 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -1782,11 +1782,15 @@ int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
struct hci_cp_le_set_per_adv_enable cp;
struct adv_info *adv;
bool enabled;
+ u8 handle = instance;
+ int err;
/* If periodic advertising already disabled there is nothing to do. */
hci_dev_lock(hdev);
adv = hci_find_adv_instance(hdev, instance);
enabled = adv && adv->periodic_enabled;
+ if (adv)
+ handle = adv->handle;
hci_dev_unlock(hdev);
if (!enabled)
return 0;
@@ -1794,10 +1798,39 @@ int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
memset(&cp, 0, sizeof(cp));
cp.enable = 0x00;
- cp.handle = instance;
+ cp.handle = handle;
- return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_PER_ADV_ENABLE,
- sizeof(cp), &cp, HCI_CMD_TIMEOUT);
+ err = __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_PER_ADV_ENABLE,
+ sizeof(cp), &cp, HCI_CMD_TIMEOUT);
+ if (err || handle == instance)
+ return err;
+
+ /* Handle 0 is shared with global advertising, so the completion
+ * cannot identify the software instance from the command alone.
+ */
+ hci_dev_lock(hdev);
+ adv = hci_find_adv_instance(hdev, instance);
+ if (adv)
+ adv->periodic_enabled = false;
+ hci_dev_unlock(hdev);
+
+ return 0;
+}
+
+/* Map a management instance number to its controller handle. */
+static u8 hci_adv_instance_handle(struct hci_dev *hdev, u8 instance)
+ __must_not_hold(&hdev->lock)
+{
+ struct adv_info *adv;
+ u8 handle = instance;
+
+ hci_dev_lock(hdev);
+ adv = hci_find_adv_instance(hdev, instance);
+ if (adv)
+ handle = adv->handle;
+ hci_dev_unlock(hdev);
+
+ return handle;
}
static int hci_set_per_adv_params_sync(struct hci_dev *hdev, u8 instance,
@@ -1813,7 +1846,7 @@ static int hci_set_per_adv_params_sync(struct hci_dev *hdev, u8 instance,
if (!max_interval)
max_interval = DISCOV_LE_PER_ADV_INT_MAX;
- cp.handle = instance;
+ cp.handle = hci_adv_instance_handle(hdev, instance);
cp.min_interval = cpu_to_le16(min_interval);
cp.max_interval = cpu_to_le16(max_interval);
cp.periodic_properties = 0x0000;
@@ -1859,11 +1892,15 @@ static int hci_enable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
struct hci_cp_le_set_per_adv_enable cp;
struct adv_info *adv;
bool enabled;
+ u8 handle = instance;
+ int err;
/* If periodic advertising already enabled there is nothing to do. */
hci_dev_lock(hdev);
adv = hci_find_adv_instance(hdev, instance);
enabled = adv && adv->periodic_enabled;
+ if (adv)
+ handle = adv->handle;
hci_dev_unlock(hdev);
if (enabled)
return 0;
@@ -1871,10 +1908,23 @@ static int hci_enable_per_advertising_sync(struct hci_dev *hdev, u8 instance)
memset(&cp, 0, sizeof(cp));
cp.enable = 0x01;
- cp.handle = instance;
+ cp.handle = handle;
- return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_PER_ADV_ENABLE,
- sizeof(cp), &cp, HCI_CMD_TIMEOUT);
+ err = __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_PER_ADV_ENABLE,
+ sizeof(cp), &cp, HCI_CMD_TIMEOUT);
+ if (err || handle == instance)
+ return err;
+
+ /* Handle 0 is shared with global advertising, so the completion
+ * cannot identify the software instance from the command alone.
+ */
+ hci_dev_lock(hdev);
+ adv = hci_find_adv_instance(hdev, instance);
+ if (adv)
+ adv->periodic_enabled = true;
+ hci_dev_unlock(hdev);
+
+ return 0;
}
/* Checks if periodic advertising data contains a Basic Announcement and if it
@@ -8152,6 +8202,7 @@ static int hci_le_past_set_info_sync(struct hci_dev *hdev, void *data)
{
struct past_data *past = data;
struct hci_cp_le_past_set_info cp;
+ struct adv_info *adv;
hci_dev_lock(hdev);
@@ -8164,6 +8215,9 @@ static int hci_le_past_set_info_sync(struct hci_dev *hdev, void *data)
memset(&cp, 0, sizeof(cp));
cp.handle = cpu_to_le16(past->le->handle);
cp.adv_handle = past->conn->iso_qos.bcast.bis;
+ adv = hci_find_adv_instance(hdev, cp.adv_handle);
+ if (adv)
+ cp.adv_handle = adv->handle;
hci_dev_unlock(hdev);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 129/742] HID: corsair: use disable_work_sync() to tear down the LED workers
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (125 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 128/742] Bluetooth: hci_sync: Use controller handles for periodic advertising Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 130/742] HID: magicmouse: disable the multitouch work on removal Greg Kroah-Hartman
` (599 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, syzbot+abcedffc9201f2bb66c2,
Danish Khateeb, Chen Changcheng, Jiri Kosina, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Danish Khateeb <danishkhateeb03@gmail.com>
[ Upstream commit cc8d022e8679e34b4892fa6c0a3fa2db917a6283 ]
Tearing down the K90 LEDs races with their brightness workers in two
different ways, and swapping cancel_work_sync() and
led_classdev_unregister() around only trades one for the other.
Cancelling before the unregister, as k90_cleanup_backlight() and
k90_cleanup_macro_functions() have done since
commit eb51c9f8cb4f ("HID: corsair: cancel worker before
unregistering LED to fix use-after-free"), leaves
led_classdev_unregister() free to re-arm the worker: it calls
led_set_brightness(led_cdev, LED_OFF), which reaches
k90_brightness_set() and schedule_work()s the item again. The structure
holding that work is then freed while it is still linked into the
worklist:
BUG: KASAN: slab-use-after-free in __list_add_valid_or_report+0x186/0x210
Read of size 8 at addr ffff888102a1ead0 by task kworker/0:1/11
__queue_work+0xade/0x1350
queue_work_on+0xb6/0xc0
led_classdev_unregister+0x26b/0x340
corsair_remove+0x1c2/0x2d0
hid_device_remove+0xba/0x1e0
usbhid_disconnect+0xa0/0xe0
Allocated by task 129:
corsair_probe+0x560/0xd50
Freed by task 11:
corsair_remove+0xec/0x2d0
Cancelling after the unregister avoids that, but reintroduces precisely
the use-after-free that commit set out to fix: a worker that has
already tested led->removed and found it false goes on to dereference
led->cdev.dev, which led_classdev_unregister() has meanwhile freed via
device_unregister().
Use disable_work_sync(), which provides both halves at once. It waits
for a worker that is already executing, so nothing can be sitting
between the led->removed test and the led->cdev.dev dereference when the
device goes away, and it makes the subsequent schedule_work() from the
LED_OFF callback fail rather than queue, so nothing is left on the
worklist to be freed. The ordering then stops mattering. The removed
flag is left alone; it is redundant for these paths now but harmless.
The fail_sysfs error path in k90_init_macro_functions() unregisters
before cancelling, and so still carries the dereference-after-free that
was fixed in the teardown paths, so convert it too.
Fixes: eb51c9f8cb4f ("HID: corsair: cancel worker before unregistering LED to fix use-after-free")
Reported-by: syzbot+abcedffc9201f2bb66c2@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=abcedffc9201f2bb66c2
Assisted-by: LLM
Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com>
Reviewed-by: Chen Changcheng <chenchangcheng@kylinos.cn>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-corsair.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-corsair.c b/drivers/hid/hid-corsair.c
index 278c6efb565df..f966005d69dd6 100644
--- a/drivers/hid/hid-corsair.c
+++ b/drivers/hid/hid-corsair.c
@@ -507,8 +507,8 @@ static int k90_init_macro_functions(struct hid_device *dev)
fail_sysfs:
k90->record_led.removed = true;
+ disable_work_sync(&k90->record_led.work);
led_classdev_unregister(&k90->record_led.cdev);
- cancel_work_sync(&k90->record_led.work);
fail_record_led:
kfree(k90->record_led.cdev.name);
fail_record_led_alloc:
@@ -524,7 +524,7 @@ static void k90_cleanup_backlight(struct hid_device *dev)
if (drvdata->backlight) {
drvdata->backlight->removed = true;
- cancel_work_sync(&drvdata->backlight->work);
+ disable_work_sync(&drvdata->backlight->work);
led_classdev_unregister(&drvdata->backlight->cdev);
kfree(drvdata->backlight->cdev.name);
kfree(drvdata->backlight);
@@ -540,7 +540,7 @@ static void k90_cleanup_macro_functions(struct hid_device *dev)
sysfs_remove_group(&dev->dev.kobj, &k90_attr_group);
k90->record_led.removed = true;
- cancel_work_sync(&k90->record_led.work);
+ disable_work_sync(&k90->record_led.work);
led_classdev_unregister(&k90->record_led.cdev);
kfree(k90->record_led.cdev.name);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 130/742] HID: magicmouse: disable the multitouch work on removal
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (126 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 129/742] HID: corsair: use disable_work_sync() to tear down the LED workers Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 131/742] HID: sensor-hub: Synchronize callback removal with raw events Greg Kroah-Hartman
` (598 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ijae Kim, Myeonghun Pak, Jiri Kosina,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <mhun512@gmail.com>
[ Upstream commit 348597b22005a8f20d267cdcc503a41dcc658acf ]
During USB runtime reset-resume, usbhid can call magicmouse_reset_resume()
without serialization against HID driver unbind. The USB interface
remains bound to usbhid, so this callback can queue msc->work after
magicmouse_remove() cancels it. The delayed work can then run after
devres frees msc.
Use disable_delayed_work_sync() to drain the work and reject later
queueing. Probe initializes fresh work on rebind.
Found by a static analysis tool under development.
Fixes: 4253fe22b137 ("HID: magicmouse: re-enable multitouch after reset-resume")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-magicmouse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index e6d4d49305268..0448cb2d07115 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -1032,7 +1032,7 @@ static void magicmouse_remove(struct hid_device *hdev)
struct magicmouse_sc *msc = hid_get_drvdata(hdev);
if (msc) {
- cancel_delayed_work_sync(&msc->work);
+ disable_delayed_work_sync(&msc->work);
if (is_usb_magicmouse2(hdev->vendor, hdev->product) ||
is_usb_magictrackpad2(hdev->vendor, hdev->product))
timer_delete_sync(&msc->battery_timer);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 131/742] HID: sensor-hub: Synchronize callback removal with raw events
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (127 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 130/742] HID: magicmouse: disable the multitouch work on removal Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 133/742] HID: sensor: custom: Disable sensor before hub close on removal Greg Kroah-Hartman
` (597 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Joshua Crofts,
Zhang Lixu, Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ Upstream commit abe10ad9c5fd868553b1262df403d5aaea3eff64 ]
Raw-event processing holds pdata->lock across callback lookup and
invocation, and takes dyn_callback_lock during lookup. Removal must
prevent both active callbacks and future lookups before client state can
be released.
Take pdata->lock before dyn_callback_lock, matching raw-event order,
and unlink the callback while holding both locks. This ensures active
raw-event callbacks have finished and prevents future lookups.
Fixes: 401ca24fb34a ("HID: sensors: introduce sensor framework")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Reviewed-by: Joshua Crofts <crofts@kernel.org>
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-sensor-hub.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 6470a290ebfc5..0c4884c5821fd 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -173,7 +173,9 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev,
struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev);
unsigned long flags;
- spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
+ /* Serialize callback removal with raw-event callback execution. */
+ spin_lock_irqsave(&pdata->lock, flags);
+ spin_lock(&pdata->dyn_callback_lock);
list_for_each_entry(callback, &pdata->dyn_callback_list, list)
if (callback->usage_id == usage_id &&
callback->hsdev == hsdev) {
@@ -181,7 +183,8 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev,
kfree(callback);
break;
}
- spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
+ spin_unlock(&pdata->dyn_callback_lock);
+ spin_unlock_irqrestore(&pdata->lock, flags);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 133/742] HID: sensor: custom: Disable sensor before hub close on removal
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (128 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 131/742] HID: sensor-hub: Synchronize callback removal with raw events Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 134/742] xsk: reject TX checksum requests that overflow skb->csum_start Greg Kroah-Hartman
` (596 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Joshua Crofts,
Zhang Lixu, Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ Upstream commit 6e66d69837cf07a00cbcdeb6198e08332b422b6c ]
When removing an enabled sensor, set its power and reporting states to
off before closing the hub. Keep the field descriptors alive until the
state update has completed, and release the hub's open reference.
Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Reviewed-by: Joshua Crofts <crofts@kernel.org>
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-sensor-custom.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index 72e5639cb1d9a..8375697b459da 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -1053,6 +1053,13 @@ static void hid_sensor_custom_remove(struct platform_device *pdev)
/* Remove enable_sensor first as it uses fields via power_state/report_state. */
sysfs_remove_group(&sensor_inst->pdev->dev.kobj,
&enable_sensor_attr_group);
+ mutex_lock(&sensor_inst->mutex);
+ if (sensor_inst->enable) {
+ set_power_report_state(sensor_inst, false);
+ sensor_hub_device_close(hsdev);
+ sensor_inst->enable = false;
+ }
+ mutex_unlock(&sensor_inst->mutex);
hid_sensor_custom_remove_attributes(sensor_inst);
sensor_hub_remove_callback(hsdev, hsdev->usage);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 134/742] xsk: reject TX checksum requests that overflow skb->csum_start
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (129 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 133/742] HID: sensor: custom: Disable sensor before hub close on removal Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 9:59 ` [PATCH 7.3 135/742] fbnic: Wait for in-flight PTP timestamps before treating Tx as idle Greg Kroah-Hartman
` (595 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Tianyi Gao,
Stanislav Fomichev, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianyi Gao <tianyi@cloudflare.com>
[ Upstream commit 4fdfed6d0990c82ce3c268814ba1b2c6ad0ce49d ]
xsk_skb_metadata() sets the u16 skb->csum_start to hr + csum_start. With
64K pages, csum_start can be close to U16_MAX, so the sum can overflow.
The checksum offset then becomes negative. With XDP_UMEM_TX_SW_CSUM,
skb_checksum_help() triggers a warning. Without it, the device gets a
CHECKSUM_PARTIAL skb with a negative offset.
Reject this with -EINVAL. Use the limit of skb_partial_csum_set(), which
also rejects U16_MAX, the "not set" value of transport_header. That
helper cannot be used here, as the skb built for an IFF_TX_SKB_NO_LINEAR
device has no linear data.
Fixes: 48eb03dd2630 ("xsk: Add TX timestamp and TX checksum offload support")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/all/sashiko-outbox-203545@kernel.org/
Signed-off-by: Tianyi Gao <tianyi@cloudflare.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20261116162834.30087-1-tianyi@cloudflare.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/xdp/xsk.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 7d31e06cc0d1e..c4ba5b98bd816 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -1005,7 +1005,8 @@ static int xsk_skb_metadata(struct sk_buff *skb, void *buffer,
csum_offset = READ_ONCE(meta->request.csum_offset);
if (unlikely(csum_start + csum_offset +
- sizeof(__sum16) > desc->len))
+ sizeof(__sum16) > desc->len ||
+ hr + csum_start >= U16_MAX))
return -EINVAL;
skb->csum_start = hr + csum_start;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 135/742] fbnic: Wait for in-flight PTP timestamps before treating Tx as idle
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (130 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 134/742] xsk: reject TX checksum requests that overflow skb->csum_start Greg Kroah-Hartman
@ 2026-12-04 9:59 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 136/742] fbnic: Cover all of the HW stats with the stats lock Greg Kroah-Hartman
` (594 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 9:59 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexander Duyck, Jakub Kicinski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Duyck <alexanderduyck@fb.com>
[ Upstream commit 6ada0c2769666140dff8e808ff21e8f9544ddc99 ]
The fbnic_wait_all_queues_idle function treats the Tx path as idle once
the QM idle registers report every queue idle. Those registers do not
cover the TMI completion path, so they can report idle while a PTP
timestamp request is still outstanding in the MAC or queued in the TMI
completion FIFO.
The check can then pass without a flush, and the completion arrives
after the rings have been flushed, where the fbnic_clean_tsq function
either reports "Tx timestamp without matching packet" or, if the
interface has come back up and a new timestamped frame is already
waiting, matches the stale completion to that frame and hands an
SO_TIMESTAMPING user the wrong Tx timestamp. After a forced flush it can
also turn FBNIC_TMI_DROP_CTRL_CMPL_DIS back off before the queued
completions have drained, as the completion FIFO is only drained while
that bit is set.
Split the Tx wait out into the fbnic_wait_tx_idle function and have its
idle check require the TCE PTP in-flight count to read zero in addition
to the QM idle registers. The count tracks each timestamp request from
when its frame enters the TCE until its completion leaves the TMI
completion FIFO, so the Tx path is only treated as idle once none are
outstanding, and a forced flush keeps the completion disable set until
they have drained. The Rx wait still checks only the QM idle registers.
The count is printed with the other Tx idle registers on failure.
Waiting on the in-flight count means the Tx idle check can now keep
reading the full set of QM idle registers for the whole timeout, and the
poll timeout only counts the delay between polls, not the time spent in
the register reads. Raise the delay between polls of the Tx and Rx waits
from 2us to 20us so the PCIe read latency stays a small part of each
interval and the 500ms timeout stays close to wall time.
Define the register inside the TCE CSR section and move
FBNIC_CSR_END_TCE to the last register of the TCE block (0x040B4,
TCE_SPARE2 in the CSR map), so that the ethtool register dump covers it.
The section previously ended at 0x04050, short of the TXB, PTP and TCAM
status registers. Per the CSR map, every register in the added range is
read-only or read/write, so reading them for the dump has no side
effects.
A device that has dropped off the bus, or whose CSR access the driver
has disabled after a failed read, reads all ones. The QM idle bits treat
that as idle, and so does the in-flight check: the count is bounded by
the timestamp requests the Tx path can hold and can never reach all
ones, so teardown of a lost device, or during DPC recovery, does not
wait out the idle timeouts.
The issue was found by code review and confirmed against the RTL.
Fixes: ad3d9f8bc66c ("eth: fbnic: add TX packets timestamping support")
Fixes: 7d4568edce74 ("fbnic: Disable PTP completions during the Tx force-flush")
Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
Link: https://patch.msgid.link/179460248693.8819.282933709034208845.stgit@ahduyck-xeon-server.home.arpa
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 3 +-
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 73 ++++++++++++++++----
2 files changed, 62 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h
index 85ad53829bef8..d65dfb1d73329 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_csr.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_csr.h
@@ -440,7 +440,8 @@ enum {
#define FBNIC_TCE_TXB_NTWRK_DWRR_CTRL_EXT \
0x0404E /* 0x10138 */
#define FBNIC_TCE_TXB_BMC_DWRR_CTRL_EXT 0x0404F /* 0x1013c */
-#define FBNIC_CSR_END_TCE 0x04050 /* CSR section delimiter */
+#define FBNIC_TCE_PTP_INFLIGHT 0x040A7 /* 0x1029c */
+#define FBNIC_CSR_END_TCE 0x040B4 /* CSR section delimiter */
/* TCE RAM registers */
#define FBNIC_CSR_START_TCE_RAM 0x04200 /* CSR section delimiter */
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
index c869b88db81ac..17d75ec6e3342 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
@@ -2358,38 +2358,85 @@ static void fbnic_idle_dump(struct fbnic_dev *fbd,
fbnic_rd32(fbd, regs[i].reg_base + j));
}
-int fbnic_wait_all_queues_idle(struct fbnic_dev *fbd, bool may_fail)
+/* The poll timeout only accounts for the delay between polls, not for
+ * the time spent in the poll itself, and each poll is a series of
+ * non-posted PCIe register reads that take on the order of a
+ * microsecond each. Space the polls out so that the reads stay a small
+ * part of each interval and the timeout stays close to wall time.
+ */
+#define FBNIC_IDLE_POLL_US 20
+#define FBNIC_IDLE_TIMEOUT_US 500000
+
+static bool fbnic_tx_idle(struct fbnic_dev *fbd,
+ const struct fbnic_idle_regs *regs,
+ unsigned int nregs)
+{
+ u32 inflight;
+
+ if (!fbnic_all_idle(fbd, regs, nregs))
+ return false;
+
+ /* The QM idle bits do not cover the TMI completion path, so a
+ * timestamp request can still be waiting on its completion. The
+ * count is bounded by the timestamp requests the Tx path can hold,
+ * so all ones is a failed read, as for the idle bits, not a count.
+ */
+ inflight = fbnic_rd32(fbd, FBNIC_TCE_PTP_INFLIGHT);
+
+ return !inflight || !~inflight;
+}
+
+static int fbnic_wait_tx_idle(struct fbnic_dev *fbd)
{
static const struct fbnic_idle_regs tx[] = {
{ FBNIC_QM_TWQ_IDLE(0), FBNIC_QM_TWQ_IDLE_CNT, },
{ FBNIC_QM_TQS_IDLE(0), FBNIC_QM_TQS_IDLE_CNT, },
{ FBNIC_QM_TDE_IDLE(0), FBNIC_QM_TDE_IDLE_CNT, },
{ FBNIC_QM_TCQ_IDLE(0), FBNIC_QM_TCQ_IDLE_CNT, },
- }, rx[] = {
- { FBNIC_QM_HPQ_IDLE(0), FBNIC_QM_HPQ_IDLE_CNT, },
- { FBNIC_QM_PPQ_IDLE(0), FBNIC_QM_PPQ_IDLE_CNT, },
- { FBNIC_QM_RCQ_IDLE(0), FBNIC_QM_RCQ_IDLE_CNT, },
};
bool idle;
int err;
- err = read_poll_timeout_atomic(fbnic_all_idle, idle, idle, 2, 500000,
- false, fbd, tx, ARRAY_SIZE(tx));
+ err = read_poll_timeout_atomic(fbnic_tx_idle, idle, idle,
+ FBNIC_IDLE_POLL_US,
+ FBNIC_IDLE_TIMEOUT_US, false,
+ fbd, tx, ARRAY_SIZE(tx));
if (err == -ETIMEDOUT) {
fbnic_tx_flush(fbd);
- err = read_poll_timeout_atomic(fbnic_all_idle, idle, idle,
- 2, 500000, false,
+ err = read_poll_timeout_atomic(fbnic_tx_idle, idle, idle,
+ FBNIC_IDLE_POLL_US,
+ FBNIC_IDLE_TIMEOUT_US, false,
fbd, tx, ARRAY_SIZE(tx));
fbnic_tx_flush_off(fbd);
}
if (err) {
fbnic_idle_dump(fbd, tx, ARRAY_SIZE(tx), "Tx", err);
- if (may_fail)
- return err;
+ netdev_err(fbd->netdev, "0x%04x: %08x\n",
+ FBNIC_TCE_PTP_INFLIGHT,
+ fbnic_rd32(fbd, FBNIC_TCE_PTP_INFLIGHT));
}
- err = read_poll_timeout_atomic(fbnic_all_idle, idle, idle, 2, 500000,
- false, fbd, rx, ARRAY_SIZE(rx));
+ return err;
+}
+
+int fbnic_wait_all_queues_idle(struct fbnic_dev *fbd, bool may_fail)
+{
+ static const struct fbnic_idle_regs rx[] = {
+ { FBNIC_QM_HPQ_IDLE(0), FBNIC_QM_HPQ_IDLE_CNT, },
+ { FBNIC_QM_PPQ_IDLE(0), FBNIC_QM_PPQ_IDLE_CNT, },
+ { FBNIC_QM_RCQ_IDLE(0), FBNIC_QM_RCQ_IDLE_CNT, },
+ };
+ bool idle;
+ int err;
+
+ err = fbnic_wait_tx_idle(fbd);
+ if (err && may_fail)
+ return err;
+
+ err = read_poll_timeout_atomic(fbnic_all_idle, idle, idle,
+ FBNIC_IDLE_POLL_US,
+ FBNIC_IDLE_TIMEOUT_US, false,
+ fbd, rx, ARRAY_SIZE(rx));
if (err)
fbnic_idle_dump(fbd, rx, ARRAY_SIZE(rx), "Rx", err);
return err;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 136/742] fbnic: Cover all of the HW stats with the stats lock
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (131 preceding siblings ...)
2026-12-04 9:59 ` [PATCH 7.3 135/742] fbnic: Wait for in-flight PTP timestamps before treating Tx as idle Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 137/742] fbnic: Initialize and reset the HW stats before they can be read Greg Kroah-Hartman
` (593 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexander Duyck, Jakub Kicinski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Duyck <alexanderduyck@fb.com>
[ Upstream commit 52a64e64230e03b45c13c615d7cdf0aeea39b210 ]
The hw_stats lock covers the PHY, TMI, TTI, RPC, RXB, queue and PCIe
stats, but the MAC stats are left to RTNL: the fbnic_reset_hw_stats
function resets them outside the lock and asserts RTNL, on the grounds
that the ethtool API is their only other user and holds RTNL. That is no
longer the case. ethtool only takes RTNL on the Netlink path for the
operations a driver lists in op_needs_rtnl, and fbnic lists only the
pause getter among the stats ones, so the eth-mac, eth-ctrl and rmon
getters update the MAC stats with only the netdev instance lock held,
racing each other and the reset.
Take the stats lock around the MAC stats updates in those getters and in
the reset, and drop the RTNL assertion. Take it in the pause getter as
well: it still runs under RTNL, but that no longer serializes it against
the reset once the reset does not rely on RTNL. The PCIe stats debugfs
read never needed RTNL, as the fbnic_get_hw_stats function updates those
stats under the stats lock, so drop it there too. The values are printed
from their 64-bit fields without the lock, as the counters keep changing
during the read anyway.
The issue was found by code review.
Fixes: 45079e00133e ("net: ethtool: optionally skip rtnl_lock on Netlink path for GET ops")
Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
Link: https://patch.msgid.link/179460250360.8819.2203630667210523871.stgit@ahduyck-xeon-server.home.arpa
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c | 3 ---
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c | 8 ++++++++
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c | 13 +------------
3 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c b/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
index 6edfa0aa69f11..0ad6707777941 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
@@ -3,7 +3,6 @@
#include <linux/debugfs.h>
#include <linux/pci.h>
-#include <linux/rtnetlink.h>
#include <linux/seq_file.h>
#include "fbnic.h"
@@ -606,7 +605,6 @@ static int fbnic_dbg_pcie_stats_show(struct seq_file *s, void *v)
{
struct fbnic_dev *fbd = s->private;
- rtnl_lock();
fbnic_get_hw_stats(fbd);
seq_printf(s, "ob_rd_tlp: %llu\n", fbd->hw_stats.pcie.ob_rd_tlp.value);
@@ -625,7 +623,6 @@ static int fbnic_dbg_pcie_stats_show(struct seq_file *s, void *v)
fbd->hw_stats.pcie.ob_rd_no_cpl_cred.value);
seq_printf(s, "ob_rd_no_np_cred: %llu\n",
fbd->hw_stats.pcie.ob_rd_no_np_cred.value);
- rtnl_unlock();
return 0;
}
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
index 76e9a545bb165..cb4258bd20538 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
@@ -1855,12 +1855,14 @@ fbnic_get_pause_stats(struct net_device *netdev,
mac_stats = &fbd->hw_stats.mac;
+ spin_lock(&fbd->hw_stats.lock);
fbd->mac->get_pause_stats(fbd, false, &mac_stats->pause);
pause_stats->tx_pause_frames = mac_stats->pause.tx_pause_frames.value;
pause_stats->rx_pause_frames = mac_stats->pause.rx_pause_frames.value;
tx_ps_events = mac_stats->pause.tx_pause_storm_events.value;
pause_stats->tx_pause_storm_events = tx_ps_events;
+ spin_unlock(&fbd->hw_stats.lock);
}
static void
@@ -1916,6 +1918,7 @@ fbnic_get_eth_mac_stats(struct net_device *netdev,
mac_stats = &fbd->hw_stats.mac;
mac = fbd->mac;
+ spin_lock(&fbd->hw_stats.lock);
mac->get_eth_mac_stats(fbd, false, &mac_stats->eth_mac);
fbnic_set_counter(ð_mac_stats->FramesTransmittedOK,
@@ -1944,6 +1947,7 @@ fbnic_get_eth_mac_stats(struct net_device *netdev,
&mac_stats->eth_mac.BroadcastFramesReceivedOK);
fbnic_set_counter(ð_mac_stats->FrameTooLongErrors,
&mac_stats->eth_mac.FrameTooLongErrors);
+ spin_unlock(&fbd->hw_stats.lock);
}
static void
@@ -1956,12 +1960,14 @@ fbnic_get_eth_ctrl_stats(struct net_device *netdev,
mac_stats = &fbd->hw_stats.mac;
+ spin_lock(&fbd->hw_stats.lock);
fbd->mac->get_eth_ctrl_stats(fbd, false, &mac_stats->eth_ctrl);
eth_ctrl_stats->MACControlFramesReceived =
mac_stats->eth_ctrl.MACControlFramesReceived.value;
eth_ctrl_stats->MACControlFramesTransmitted =
mac_stats->eth_ctrl.MACControlFramesTransmitted.value;
+ spin_unlock(&fbd->hw_stats.lock);
}
static const struct ethtool_rmon_hist_range fbnic_rmon_ranges[] = {
@@ -1991,6 +1997,7 @@ fbnic_get_rmon_stats(struct net_device *netdev,
mac_stats = &fbd->hw_stats.mac;
+ spin_lock(&fbd->hw_stats.lock);
fbd->mac->get_rmon_stats(fbd, false, &mac_stats->rmon);
rmon_stats->undersize_pkts =
@@ -2006,6 +2013,7 @@ fbnic_get_rmon_stats(struct net_device *netdev,
rmon_stats->hist[i] = mac_stats->rmon.hist[i].value;
rmon_stats->hist_tx[i] = mac_stats->rmon.hist_tx[i].value;
}
+ spin_unlock(&fbd->hw_stats.lock);
*ranges = fbnic_rmon_ranges;
}
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
index 8b9b2076beecd..c3b9e8fae396f 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) Meta Platforms, Inc. and affiliates. */
-#include <linux/rtnetlink.h>
-
#include "fbnic.h"
static void fbnic_hw_stat_rst32(struct fbnic_dev *fbd, u32 reg,
@@ -551,17 +549,8 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
fbnic_reset_rxb_stats(fbd, &fbd->hw_stats.rxb);
fbnic_reset_hw_rxq_stats(fbd, fbd->hw_stats.hw_q);
fbnic_reset_pcie_stats_asic(fbd, &fbd->hw_stats.pcie);
- spin_unlock(&fbd->hw_stats.lock);
-
- /* Once registered, the only other access to MAC stats is via the
- * ethtool API which is protected by the rtnl_lock. The call to
- * fbnic_reset_hw_stats() during PCI recovery is also protected
- * by the rtnl_lock hence, we don't need the spinlock to access
- * the MAC stats.
- */
- if (fbd->netdev)
- ASSERT_RTNL();
fbnic_reset_hw_mac_stats(fbd, &fbd->hw_stats.mac);
+ spin_unlock(&fbd->hw_stats.lock);
}
void fbnic_init_hw_stats(struct fbnic_dev *fbd)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 137/742] fbnic: Initialize and reset the HW stats before they can be read
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (132 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 136/742] fbnic: Cover all of the HW stats with the stats lock Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 138/742] cxgb4: allocate the full ethtool filter location array Greg Kroah-Hartman
` (592 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexander Duyck, Jakub Kicinski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Duyck <alexanderduyck@fb.com>
[ Upstream commit 4b5153b389627d81f80eef49a5f27032c36378f6 ]
The HW stats are kept as running totals that advance by the difference
between each counter and the value last read, so the last values have
to be captured before the first read, and rebased whenever the hardware
counters are reset. Three paths get the ordering wrong.
The fbnic_probe function creates the debugfs directory, including the
pcie_stats file, before it calls the fbnic_init_hw_stats function. A
read in that window takes the stats lock before it has been initialized,
and accumulates deltas against baselines that have not been captured.
On resume, the __fbnic_pm_attach function rebases the stats only after
it has returned early for a device in init failure mode, though such a
device still exposes the PCIe stats through debugfs. And during PCI
error recovery it runs from the resume callback, after the
__fbnic_pm_resume function has already restored MMIO access from the
slot_reset callback, so a debugfs read in between takes its delta
against the values from before the reset and the totals jump by close
to the full width of each counter.
Initialize the stats before the debugfs directory and the devlink
instance are registered. Rebase them in the __fbnic_pm_resume function,
in the same stats lock section that restores MMIO access, so no read can
see the reset counters first, ahead of its init failure check.
The issue was found by code review, and the recovery case confirmed by
hardware testing with forced AER/DPC recovery.
Fixes: 25ba596d137d ("eth: fbnic: add PCIe hardware statistics")
Fixes: 9f61eb2d185b ("eth: fbnic: add locking support for hw stats")
Fixes: 05ec5504ff69 ("fbnic: Fix service task races with ndo_stop and PM suspend")
Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
Link: https://patch.msgid.link/179460251204.8819.12233374584808838528.stgit@ahduyck-xeon-server.home.arpa
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c | 11 +++++++++--
drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h | 1 +
drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 16 ++++++++++------
3 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
index c3b9e8fae396f..076bfcac47d67 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.c
@@ -539,9 +539,10 @@ static void fbnic_reset_hw_mac_stats(struct fbnic_dev *fbd,
mac->get_rmon_stats(fbd, true, &mac_stats->rmon);
}
-void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
+void __fbnic_reset_hw_stats(struct fbnic_dev *fbd)
{
- spin_lock(&fbd->hw_stats.lock);
+ lockdep_assert_held(&fbd->hw_stats.lock);
+
fbnic_reset_phy_stats(fbd, &fbd->hw_stats.phy);
fbnic_reset_tmi_stats(fbd, &fbd->hw_stats.tmi);
fbnic_reset_tti_stats(fbd, &fbd->hw_stats.tti);
@@ -550,6 +551,12 @@ void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
fbnic_reset_hw_rxq_stats(fbd, fbd->hw_stats.hw_q);
fbnic_reset_pcie_stats_asic(fbd, &fbd->hw_stats.pcie);
fbnic_reset_hw_mac_stats(fbd, &fbd->hw_stats.mac);
+}
+
+void fbnic_reset_hw_stats(struct fbnic_dev *fbd)
+{
+ spin_lock(&fbd->hw_stats.lock);
+ __fbnic_reset_hw_stats(fbd);
spin_unlock(&fbd->hw_stats.lock);
}
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
index caea4be46762a..5eb1e8b29ef9d 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
@@ -154,6 +154,7 @@ struct fbnic_hw_stats {
u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset);
+void __fbnic_reset_hw_stats(struct fbnic_dev *fbd);
void fbnic_reset_hw_stats(struct fbnic_dev *fbd);
void fbnic_init_hw_stats(struct fbnic_dev *fbd);
void fbnic_get_hw_q_stats(struct fbnic_dev *fbd,
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
index 1335310a1cc18..51a1acc5fca17 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_pci.c
@@ -347,13 +347,13 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
*/
fbnic_fw_log_enable(fbd, true);
+ /* Capture snapshot of hardware stats so netdev can calculate delta */
+ fbnic_init_hw_stats(fbd);
+
fbnic_devlink_register(fbd);
fbnic_devlink_otp_check(fbd, "error detected during probe");
fbnic_dbg_fbd_init(fbd);
- /* Capture snapshot of hardware stats so netdev can calculate delta */
- fbnic_init_hw_stats(fbd);
-
fbnic_hwmon_register(fbd);
if (!fbd->dsn) {
@@ -495,10 +495,16 @@ static int __fbnic_pm_resume(struct device *dev)
struct fbnic_net *fbn;
int err;
- /* Restore MMIO access */
+ /* Restore MMIO access and rebase the HW stats in one step, so that
+ * no stats read can take its delta from counters the reset cleared
+ * against the values read before it.
+ */
iomap_table = pcim_iomap_table(to_pci_dev(dev));
+ spin_lock(&fbd->hw_stats.lock);
fbd->uc_addr0 = iomap_table[0];
fbd->uc_addr4 = iomap_table[4];
+ __fbnic_reset_hw_stats(fbd);
+ spin_unlock(&fbd->hw_stats.lock);
/* Rerequest the IRQs */
err = fbnic_alloc_irqs(fbd);
@@ -579,8 +585,6 @@ static void __fbnic_pm_attach(struct device *dev)
rtnl_lock();
netdev_lock(netdev);
- fbnic_reset_hw_stats(fbd);
-
if (netif_running(netdev))
fbnic_up(fbn);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 138/742] cxgb4: allocate the full ethtool filter location array
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (133 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 137/742] fbnic: Initialize and reset the HW stats before they can be read Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 139/742] net: bcm4908_enet: fix the TX ring wrap Greg Kroah-Hartman
` (591 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Artemii Mashanov,
Potnuri Bharat Teja, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Artemii Mashanov <ralerrdirsardx@gmail.com>
[ Upstream commit ad2c7240a3981fd5f0142b61ca913b02ab476ede ]
The ethtool filter location array stores nentries u32 values, but
cxgb4_init_ethtool_filters() passes nentries to kvzalloc() as a byte
count. The insertion and lookup paths allow indices below nentries,
which can address memory beyond the requested allocation.
Allocate nentries elements with kvcalloc() and the element size.
The array remains compatible with the existing kvfree() calls.
The size mismatch was found by reviewing the allocation, the array
declaration and the indexed accesses in the filter handlers.
Fixes: d915c299f1da ("cxgb4: add skeleton for ethtool n-tuple filters")
Signed-off-by: Artemii Mashanov <ralerrdirsardx@gmail.com>
Reviewed-by: Potnuri Bharat Teja <bharat@chelsio.com>
Link: https://patch.msgid.link/20261117090608.33178-1-ralerrdirsardx@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
index 0092bc16f8870..c72c0bcd45c80 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
@@ -2269,7 +2269,9 @@ int cxgb4_init_ethtool_filters(struct adapter *adap)
eth_filter->nentries = nentries;
for (i = 0; i < adap->params.nports; i++) {
- eth_filter->port[i].loc_array = kvzalloc(nentries, GFP_KERNEL);
+ eth_filter->port[i].loc_array =
+ kvcalloc(nentries, sizeof(*eth_filter->port[i].loc_array),
+ GFP_KERNEL);
if (!eth_filter->port[i].loc_array) {
ret = -ENOMEM;
goto free_eth_finfo;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 139/742] net: bcm4908_enet: fix the TX ring wrap
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (134 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 138/742] cxgb4: allocate the full ethtool filter location array Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 140/742] net: bcm4908_enet: drop a TX frame whose DMA mapping failed Greg Kroah-Hartman
` (590 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli,
Kordian Chmielewski, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kordian Chmielewski <kudzo51@gmail.com>
[ Upstream commit 4f8b1a7cf7548ebefae959486c3acc33799d1116 ]
start_xmit() wraps write_idx at length - 1 and sets WRAP on the
descriptor at length - 2, while poll_tx() wraps read_idx at length,
and the free descriptor count is taken from length. With read_idx at 0
and write_idx at length - 2 the count comes out as 2, the frame is
queued and write_idx wraps to 0 == read_idx: a full ring looks empty.
The following frames overwrite slots whose skbs were never unmapped
or freed, their bytes stay in BQL, and the queue stops for good with
nothing left to wake it.
On a TP-Link Archer AX6000 this stopped everything the CPU sent to the
switch under sustained TX load (about 1.3 Gbit/s through the switch's
CPU port): tx_packets froze, nothing was logged, and BQL showed about
185 KB in flight against a limit of about 10 KB.
The same mismatch also lets poll_tx() step onto slot length - 1, which
start_xmit() never fills: once per lap it completes that slot,
unmapping address 0 with length 0 and counting a packet that was never
sent. That one is from reading the code.
Use every descriptor, with WRAP on the last one, wrap both indexes at
length and keep one descriptor free, so that read_idx == write_idx can
only mean an empty ring. Stop and wake the queue with the
netdev_queues.h helpers: start_xmit() stops it when the ring is full,
also when it finds the ring full on entry, and poll_tx() wakes it once
there is room again.
Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-2-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bcm4908_enet.c | 57 ++++++++++++--------
1 file changed, 35 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index fd2715f84af97..60f711e8ce189 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -13,6 +13,7 @@
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/string.h>
+#include <net/netdev_queues.h>
#include "bcm4908_enet.h"
#include "unimac.h"
@@ -518,30 +519,34 @@ static int bcm4908_enet_stop(struct net_device *netdev)
return 0;
}
+/* One descriptor always stays unused, so read_idx == write_idx can only
+ * mean an empty ring
+ */
+static int bcm4908_enet_tx_free_descs(struct bcm4908_enet_dma_ring *ring)
+{
+ int free = READ_ONCE(ring->read_idx) - READ_ONCE(ring->write_idx) - 1;
+
+ return free < 0 ? free + ring->length : free;
+}
+
static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_device *netdev)
{
+ struct netdev_queue *txq = netdev_get_tx_queue(netdev, 0);
struct bcm4908_enet *enet = netdev_priv(netdev);
struct bcm4908_enet_dma_ring *ring = &enet->tx_ring;
struct bcm4908_enet_dma_ring_slot *slot;
struct device *dev = enet->dev;
struct bcm4908_enet_dma_ring_bd *buf_desc;
- int free_buf_descs;
u32 tmp;
/* Free transmitted skbs */
if (enet->irq_tx < 0 &&
- !(le32_to_cpu(ring->buf_desc[ring->read_idx].ctl) & DMA_CTL_STATUS_OWN))
+ !(le32_to_cpu(ring->buf_desc[READ_ONCE(ring->read_idx)].ctl) &
+ DMA_CTL_STATUS_OWN))
napi_schedule(&enet->tx_ring.napi);
- /* Don't use the last empty buf descriptor */
- if (ring->read_idx <= ring->write_idx)
- free_buf_descs = ring->read_idx - ring->write_idx + ring->length;
- else
- free_buf_descs = ring->read_idx - ring->write_idx;
- if (free_buf_descs < 2) {
- netif_stop_queue(netdev);
+ if (!netif_txq_maybe_stop(txq, bcm4908_enet_tx_free_descs(ring), 1, 1))
return NETDEV_TX_BUSY;
- }
/* Hardware removes OWN bit after sending data */
buf_desc = &ring->buf_desc[ring->write_idx];
@@ -562,7 +567,7 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
tmp |= DMA_CTL_STATUS_SOP;
tmp |= DMA_CTL_STATUS_EOP;
tmp |= DMA_CTL_STATUS_APPEND_CRC;
- if (ring->write_idx + 1 == ring->length - 1)
+ if (ring->write_idx == ring->length - 1)
tmp |= DMA_CTL_STATUS_WRAP;
netdev_sent_queue(enet->netdev, skb->len);
@@ -572,8 +577,13 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
bcm4908_enet_dma_tx_ring_enable(enet, &enet->tx_ring);
- if (++ring->write_idx == ring->length - 1)
- ring->write_idx = 0;
+ if (ring->write_idx == ring->length - 1)
+ WRITE_ONCE(ring->write_idx, 0);
+ else
+ WRITE_ONCE(ring->write_idx, ring->write_idx + 1);
+
+ /* poll_tx() wakes the queue once there is room again */
+ netif_txq_maybe_stop(txq, bcm4908_enet_tx_free_descs(ring), 1, 1);
return NETDEV_TX_OK;
}
@@ -652,17 +662,19 @@ static int bcm4908_enet_poll_tx(struct napi_struct *napi, int weight)
{
struct bcm4908_enet_dma_ring *tx_ring = container_of(napi, struct bcm4908_enet_dma_ring, napi);
struct bcm4908_enet *enet = container_of(tx_ring, struct bcm4908_enet, tx_ring);
+ struct netdev_queue *txq = netdev_get_tx_queue(enet->netdev, 0);
struct bcm4908_enet_dma_ring_bd *buf_desc;
struct bcm4908_enet_dma_ring_slot *slot;
struct device *dev = enet->dev;
+ int read_idx = tx_ring->read_idx;
unsigned int bytes = 0;
int handled = 0;
- while (handled < weight && tx_ring->read_idx != tx_ring->write_idx) {
- buf_desc = &tx_ring->buf_desc[tx_ring->read_idx];
+ while (handled < weight && read_idx != READ_ONCE(tx_ring->write_idx)) {
+ buf_desc = &tx_ring->buf_desc[read_idx];
if (le32_to_cpu(buf_desc->ctl) & DMA_CTL_STATUS_OWN)
break;
- slot = &tx_ring->slots[tx_ring->read_idx];
+ slot = &tx_ring->slots[read_idx];
dma_unmap_single(dev, slot->dma_addr, slot->len, DMA_TO_DEVICE);
dev_kfree_skb(slot->skb);
@@ -670,22 +682,23 @@ static int bcm4908_enet_poll_tx(struct napi_struct *napi, int weight)
handled++;
bytes += slot->len;
- if (++tx_ring->read_idx == tx_ring->length)
- tx_ring->read_idx = 0;
+ if (++read_idx == tx_ring->length)
+ read_idx = 0;
}
+ WRITE_ONCE(tx_ring->read_idx, read_idx);
- netdev_completed_queue(enet->netdev, handled, bytes);
enet->netdev->stats.tx_packets += handled;
enet->netdev->stats.tx_bytes += bytes;
+ /* Reports to BQL, and wakes the queue if start_xmit() stopped it */
+ netif_txq_completed_wake(txq, handled, bytes,
+ bcm4908_enet_tx_free_descs(tx_ring), 1);
+
if (handled < weight) {
napi_complete_done(napi, handled);
bcm4908_enet_dma_ring_intrs_on(enet, tx_ring);
}
- if (netif_queue_stopped(enet->netdev))
- netif_wake_queue(enet->netdev);
-
return handled;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 140/742] net: bcm4908_enet: drop a TX frame whose DMA mapping failed
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (135 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 139/742] net: bcm4908_enet: fix the TX ring wrap Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 141/742] net: bcm4908_enet: release the TX ring on stop Greg Kroah-Hartman
` (589 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli,
Kordian Chmielewski, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kordian Chmielewski <kudzo51@gmail.com>
[ Upstream commit e1d4683fb4cb9d7f45a17c43a56ba2d26ab91ec6 ]
When dma_map_single() fails, start_xmit() returns NETDEV_TX_BUSY with
the queue still running, after it has already stored the skb in the
slot. Documentation/networking/driver.rst treats NETDEV_TX_BUSY under
normal circumstances as a hard error, and a driver that returns it must
not keep any reference to the skb. Here the stack requeues the frame
and retries it while the slot still points at it. Drop the frame
instead: free the skb, count it as dropped and return NETDEV_TX_OK.
Map the buffer before the slot is touched.
Found by reading the code.
Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-3-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bcm4908_enet.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index 60f711e8ce189..b1738d954b91a 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -537,6 +537,7 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
struct bcm4908_enet_dma_ring_slot *slot;
struct device *dev = enet->dev;
struct bcm4908_enet_dma_ring_bd *buf_desc;
+ dma_addr_t dma_addr;
u32 tmp;
/* Free transmitted skbs */
@@ -555,12 +556,17 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
return NETDEV_TX_BUSY;
}
+ dma_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
+ if (unlikely(dma_mapping_error(dev, dma_addr))) {
+ dev_kfree_skb_any(skb);
+ netdev->stats.tx_dropped++;
+ return NETDEV_TX_OK;
+ }
+
slot = &ring->slots[ring->write_idx];
slot->skb = skb;
slot->len = skb->len;
- slot->dma_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
- if (unlikely(dma_mapping_error(dev, slot->dma_addr)))
- return NETDEV_TX_BUSY;
+ slot->dma_addr = dma_addr;
tmp = skb->len << DMA_CTL_LEN_DESC_BUFLENGTH_SHIFT;
tmp |= DMA_CTL_STATUS_OWN;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 141/742] net: bcm4908_enet: release the TX ring on stop
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (136 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 140/742] net: bcm4908_enet: drop a TX frame whose DMA mapping failed Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 142/742] net: bcm4908_enet: unmap the buffer of a dropped RX frame Greg Kroah-Hartman
` (588 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kordian Chmielewski, Jakub Kicinski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kordian Chmielewski <kudzo51@gmail.com>
[ Upstream commit e2785f0ff0a210158933221e86ea5bd066992870 ]
bcm4908_enet_stop() disables the TX DMA but leaves the ring as it is:
the skbs that poll_tx() has not freed yet stay mapped and are never
freed, and the descriptors the DMA has not sent yet keep
DMA_CTL_STATUS_OWN. The skbs, the socket memory they hold and their
mappings leak. The next open starts the indexes from 0 again over
those descriptors, so the DMA may send stale frames from before the
stop, and if the first descriptor still has OWN, start_xmit() stops
the queue before it enables the DMA, with nothing left to wake it.
Wait for the TX DMA channel to stop, as is already done for RX, then
unmap and free the skbs between read_idx and write_idx and leave the
ring empty, so that nothing can free them a second time. If the
channel does not stop in time, leave the skbs alone rather than free
them while the DMA may still read them. Clear the TX descriptors when
the ring is initialised. A descriptor that start_xmit() is about to
use then never carries OWN, so drop the check that stopped the queue
on one. The RX helper's timeout warning said TX; make it say RX.
Found by reading the code; I have not seen these on the hardware.
Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-4-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bcm4908_enet.c | 55 ++++++++++++++++----
1 file changed, 44 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index b1738d954b91a..bb42b6ecde16a 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -7,6 +7,7 @@
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/interrupt.h>
+#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_net.h>
@@ -313,6 +314,11 @@ static void bcm4908_enet_dma_ring_init(struct bcm4908_enet *enet,
enet_write(enet, ring->st_ram_block + ENET_DMA_CH_STATE_RAM_BASE_DESC_PTR,
(uint32_t)ring->dma_addr);
+ /* A descriptor the stopped DMA never completed still carries OWN */
+ if (ring->is_tx)
+ memset(ring->buf_desc, 0,
+ ring->length * sizeof(*ring->buf_desc));
+
ring->read_idx = 0;
ring->write_idx = 0;
}
@@ -362,10 +368,22 @@ static void bcm4908_enet_dma_tx_ring_enable(struct bcm4908_enet *enet,
enet_write(enet, ring->cfg_block + ENET_DMA_CH_CFG, ENET_DMA_CH_CFG_ENABLE);
}
-static void bcm4908_enet_dma_tx_ring_disable(struct bcm4908_enet *enet,
- struct bcm4908_enet_dma_ring *ring)
+static int bcm4908_enet_dma_tx_ring_disable(struct bcm4908_enet *enet,
+ struct bcm4908_enet_dma_ring *ring)
{
+ u32 tmp;
+ int err;
+
enet_write(enet, ring->cfg_block + ENET_DMA_CH_CFG, 0);
+
+ /* Wait for the channel to stop, as for RX, before freeing buffers */
+ err = read_poll_timeout(enet_read, tmp, !(tmp & ENET_DMA_CH_CFG_ENABLE),
+ 10, 2000, false, enet,
+ ring->cfg_block + ENET_DMA_CH_CFG);
+ if (err)
+ dev_warn(enet->dev, "Timeout waiting for DMA TX stop\n");
+
+ return err;
}
static void bcm4908_enet_dma_rx_ring_enable(struct bcm4908_enet *enet,
@@ -391,7 +409,7 @@ static void bcm4908_enet_dma_rx_ring_disable(struct bcm4908_enet *enet,
usleep_range(10, 30);
} while (!time_after_eq(jiffies, deadline));
- dev_warn(enet->dev, "Timeout waiting for DMA TX stop\n");
+ dev_warn(enet->dev, "Timeout waiting for DMA RX stop\n");
}
/***
@@ -496,6 +514,25 @@ static int bcm4908_enet_open(struct net_device *netdev)
return 0;
}
+static void bcm4908_enet_tx_ring_clean(struct bcm4908_enet *enet)
+{
+ struct bcm4908_enet_dma_ring *tx_ring = &enet->tx_ring;
+ struct device *dev = enet->dev;
+ int i;
+
+ for (i = tx_ring->read_idx; i != tx_ring->write_idx;
+ i = i == tx_ring->length - 1 ? 0 : i + 1) {
+ struct bcm4908_enet_dma_ring_slot *slot = &tx_ring->slots[i];
+
+ dma_unmap_single(dev, slot->dma_addr, slot->len, DMA_TO_DEVICE);
+ dev_kfree_skb_any(slot->skb);
+ }
+
+ /* Leave the ring empty, so that nothing frees these skbs again */
+ tx_ring->read_idx = 0;
+ tx_ring->write_idx = 0;
+}
+
static int bcm4908_enet_stop(struct net_device *netdev)
{
struct bcm4908_enet *enet = netdev_priv(netdev);
@@ -509,8 +546,10 @@ static int bcm4908_enet_stop(struct net_device *netdev)
netdev_reset_queue(netdev);
bcm4908_enet_dma_rx_ring_disable(enet, &enet->rx_ring);
- bcm4908_enet_dma_tx_ring_disable(enet, &enet->tx_ring);
+ /* Leave the TX buffers alone if the channel may still read them */
+ if (!bcm4908_enet_dma_tx_ring_disable(enet, &enet->tx_ring))
+ bcm4908_enet_tx_ring_clean(enet);
bcm4908_enet_dma_uninit(enet);
free_irq(enet->irq_tx, enet);
@@ -549,13 +588,6 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
if (!netif_txq_maybe_stop(txq, bcm4908_enet_tx_free_descs(ring), 1, 1))
return NETDEV_TX_BUSY;
- /* Hardware removes OWN bit after sending data */
- buf_desc = &ring->buf_desc[ring->write_idx];
- if (unlikely(le32_to_cpu(buf_desc->ctl) & DMA_CTL_STATUS_OWN)) {
- netif_stop_queue(netdev);
- return NETDEV_TX_BUSY;
- }
-
dma_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
if (unlikely(dma_mapping_error(dev, dma_addr))) {
dev_kfree_skb_any(skb);
@@ -563,6 +595,7 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
return NETDEV_TX_OK;
}
+ buf_desc = &ring->buf_desc[ring->write_idx];
slot = &ring->slots[ring->write_idx];
slot->skb = skb;
slot->len = skb->len;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 142/742] net: bcm4908_enet: unmap the buffer of a dropped RX frame
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (137 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 141/742] net: bcm4908_enet: release the TX ring on stop Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 143/742] net: bcm4908_enet: unmap RX buffers on stop with their mapped size Greg Kroah-Hartman
` (587 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli,
Kordian Chmielewski, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kordian Chmielewski <kudzo51@gmail.com>
[ Upstream commit 1b48d619448c8425bd907722784f08e4e8fa4c5b ]
When poll_rx() drops a frame (too short, or not in a single buffer),
it frees the buffer without unmapping it first, so the memory goes
back to the page allocator while still mapped for the device. Unmap it
as the path for good frames does.
Found by reading the code.
Fixes: 4dc7f09b8bec ("net: broadcom: bcm4908_enet: fix RX path possible mem leak")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-5-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bcm4908_enet.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index bb42b6ecde16a..03de65d9bbfd6 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -661,6 +661,8 @@ static int bcm4908_enet_poll_rx(struct napi_struct *napi, int weight)
if (len < ETH_ZLEN ||
(ctl & (DMA_CTL_STATUS_SOP | DMA_CTL_STATUS_EOP)) != (DMA_CTL_STATUS_SOP | DMA_CTL_STATUS_EOP)) {
+ dma_unmap_single(dev, slot.dma_addr,
+ ENET_RX_BUF_DMA_SIZE, DMA_FROM_DEVICE);
skb_free_frag(slot.buf);
enet->netdev->stats.rx_dropped++;
break;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 143/742] net: bcm4908_enet: unmap RX buffers on stop with their mapped size
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (138 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 142/742] net: bcm4908_enet: unmap the buffer of a dropped RX frame Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 144/742] net: bcm4908_enet: publish the buffer address before OWN Greg Kroah-Hartman
` (586 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli,
Kordian Chmielewski, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kordian Chmielewski <kudzo51@gmail.com>
[ Upstream commit 1da02595e8d2647a04c2cdd4f668dee0b8ac1ae9 ]
Since the switch to build_skb() the RX buffers are mapped with
ENET_RX_BUF_DMA_SIZE and slot->len is no longer set for them, but
bcm4908_enet_dma_uninit() still unmaps them with slot->len. Use the
size they were mapped with.
Found by reading the code.
Fixes: 3a1cc23a75ab ("net: broadcom: bcm4908_enet: use build_skb()")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-6-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bcm4908_enet.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index 03de65d9bbfd6..4065769da9660 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -334,7 +334,8 @@ static void bcm4908_enet_dma_uninit(struct bcm4908_enet *enet)
slot = &rx_ring->slots[i];
if (!slot->buf)
continue;
- dma_unmap_single(dev, slot->dma_addr, slot->len, DMA_FROM_DEVICE);
+ dma_unmap_single(dev, slot->dma_addr, ENET_RX_BUF_DMA_SIZE,
+ DMA_FROM_DEVICE);
skb_free_frag(slot->buf);
slot->buf = NULL;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 144/742] net: bcm4908_enet: publish the buffer address before OWN
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (139 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 143/742] net: bcm4908_enet: unmap RX buffers on stop with their mapped size Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 145/742] net: bcm4908_enet: order the TX ring index accesses Greg Kroah-Hartman
` (585 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli,
Kordian Chmielewski, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kordian Chmielewski <kudzo51@gmail.com>
[ Upstream commit 4d47e6c2f3ceb638d4ea5c21e304b20f526255bd ]
bcm4908_enet_dma_alloc_rx_buf() hands a descriptor to the DMA by
writing its control word, with DMA_CTL_STATUS_OWN, first and the new
buffer address second. If the DMA read the descriptor between the two
stores, it would write the next frame into the old buffer, which
poll_rx() is turning into an skb. start_xmit() writes the address
first, but nothing orders the two stores, and the descriptors live in
coherent memory, where arm64 may make them visible in either order.
Write the address first on both paths and order it before the control
word with dma_wmb(). In poll_rx(), read what the DMA wrote only after
seeing OWN clear (dma_rmb()), as Documentation/memory-barriers.txt
describes for descriptors shared with a device.
Found by reading the code; I have no test that shows the DMA reading a
descriptor while it is being refilled.
Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-7-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bcm4908_enet.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index 4065769da9660..4139dad3a18d0 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -291,8 +291,10 @@ static int bcm4908_enet_dma_alloc_rx_buf(struct bcm4908_enet *enet, unsigned int
tmp |= DMA_CTL_STATUS_OWN;
if (idx == enet->rx_ring.length - 1)
tmp |= DMA_CTL_STATUS_WRAP;
- buf_desc->ctl = cpu_to_le32(tmp);
buf_desc->addr = cpu_to_le32(slot->dma_addr);
+ /* Hand the descriptor to the DMA only once it holds the new buffer */
+ dma_wmb();
+ buf_desc->ctl = cpu_to_le32(tmp);
return 0;
}
@@ -613,6 +615,8 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
netdev_sent_queue(enet->netdev, skb->len);
buf_desc->addr = cpu_to_le32((uint32_t)slot->dma_addr);
+ /* The DMA must not see OWN before the buffer address */
+ dma_wmb();
buf_desc->ctl = cpu_to_le32(tmp);
bcm4908_enet_dma_tx_ring_enable(enet, &enet->tx_ring);
@@ -647,6 +651,8 @@ static int bcm4908_enet_poll_rx(struct napi_struct *napi, int weight)
ctl = le32_to_cpu(buf_desc->ctl);
if (ctl & DMA_CTL_STATUS_OWN)
break;
+ /* Read the rest only after the DMA gave the descriptor back */
+ dma_rmb();
slot = enet->rx_ring.slots[enet->rx_ring.read_idx];
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 145/742] net: bcm4908_enet: order the TX ring index accesses
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (140 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 144/742] net: bcm4908_enet: publish the buffer address before OWN Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 146/742] scsi: pm8001: Offset hardware queue index for MSI-X pre-vector Greg Kroah-Hartman
` (584 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kordian Chmielewski, Jakub Kicinski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kordian Chmielewski <kudzo51@gmail.com>
[ Upstream commit ebe31472ad0a08e19a31a6647b99c6b51f90026c ]
Since the TX interrupt was added, poll_tx() runs in its own NAPI and
does not take the TX queue lock, so it and start_xmit() share the TX
ring with only the two indexes between them. Nothing orders the
accesses around those indexes:
- poll_tx() reads write_idx, then the descriptor and the slot. On arm64
the later loads may be satisfied first, so poll_tx() may see the new
write_idx together with the previous lap's descriptor, which has no
OWN, and the previous lap's slot. It would then unmap and free a
frame the DMA has not sent yet, or free the old skb a second time.
- poll_tx() publishes read_idx once it is done with the slots it
freed, but that store is not ordered after its loads from those
slots, so start_xmit() may refill a slot before poll_tx() has read
it.
Publish each index with smp_store_release() and read the other side's
index with smp_load_acquire() before touching the slots. start_xmit()
now publishes write_idx right after the descriptor, before the MMIO
write that kicks the DMA rather than after it, which narrows the window
in which the DMA can complete a frame that poll_tx() cannot see yet.
Sashiko's review of the previous version of this series pointed this
out; I have not seen it on the hardware.
Fixes: 12bb508bfe5a ("net: broadcom: bcm4908_enet: support TX interrupt")
Signed-off-by: Kordian Chmielewski <kudzo51@gmail.com>
Link: https://patch.msgid.link/20261113235847.517308-8-kudzo51@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bcm4908_enet.c | 26 ++++++++++++++------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm4908_enet.c b/drivers/net/ethernet/broadcom/bcm4908_enet.c
index 4139dad3a18d0..8bc620de2ef0d 100644
--- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
@@ -566,7 +566,9 @@ static int bcm4908_enet_stop(struct net_device *netdev)
*/
static int bcm4908_enet_tx_free_descs(struct bcm4908_enet_dma_ring *ring)
{
- int free = READ_ONCE(ring->read_idx) - READ_ONCE(ring->write_idx) - 1;
+ /* Pairs with smp_store_release() in bcm4908_enet_poll_tx() */
+ int free = smp_load_acquire(&ring->read_idx) -
+ READ_ONCE(ring->write_idx) - 1;
return free < 0 ? free + ring->length : free;
}
@@ -619,12 +621,14 @@ static netdev_tx_t bcm4908_enet_start_xmit(struct sk_buff *skb, struct net_devic
dma_wmb();
buf_desc->ctl = cpu_to_le32(tmp);
- bcm4908_enet_dma_tx_ring_enable(enet, &enet->tx_ring);
+ /* Publish the slot and the descriptor before the index; pairs with
+ * smp_load_acquire() in bcm4908_enet_poll_tx()
+ */
+ smp_store_release(&ring->write_idx,
+ ring->write_idx < ring->length - 1 ?
+ ring->write_idx + 1 : 0);
- if (ring->write_idx == ring->length - 1)
- WRITE_ONCE(ring->write_idx, 0);
- else
- WRITE_ONCE(ring->write_idx, ring->write_idx + 1);
+ bcm4908_enet_dma_tx_ring_enable(enet, &enet->tx_ring);
/* poll_tx() wakes the queue once there is room again */
netif_txq_maybe_stop(txq, bcm4908_enet_tx_free_descs(ring), 1, 1);
@@ -718,7 +722,10 @@ static int bcm4908_enet_poll_tx(struct napi_struct *napi, int weight)
unsigned int bytes = 0;
int handled = 0;
- while (handled < weight && read_idx != READ_ONCE(tx_ring->write_idx)) {
+ while (handled < weight) {
+ /* Pairs with the release in bcm4908_enet_start_xmit() */
+ if (read_idx == smp_load_acquire(&tx_ring->write_idx))
+ break;
buf_desc = &tx_ring->buf_desc[read_idx];
if (le32_to_cpu(buf_desc->ctl) & DMA_CTL_STATUS_OWN)
break;
@@ -733,7 +740,10 @@ static int bcm4908_enet_poll_tx(struct napi_struct *napi, int weight)
if (++read_idx == tx_ring->length)
read_idx = 0;
}
- WRITE_ONCE(tx_ring->read_idx, read_idx);
+ /* Be done with the slots before start_xmit() may reuse them; pairs
+ * with smp_load_acquire() in bcm4908_enet_tx_free_descs()
+ */
+ smp_store_release(&tx_ring->read_idx, read_idx);
enet->netdev->stats.tx_packets += handled;
enet->netdev->stats.tx_bytes += bytes;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 146/742] scsi: pm8001: Offset hardware queue index for MSI-X pre-vector
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (141 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 145/742] net: bcm4908_enet: order the TX ring index accesses Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 147/742] net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state Greg Kroah-Hartman
` (583 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Terrence Adams, Bart Van Assche,
Martin K. Petersen (Oracle), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Terrence Adams <tadamsjr@google.com>
[ Upstream commit 3ad578b22f7a34a2391ca8910dfc931b01cc94f6 ]
When MSI-X interrupt vectors are configured in pm8001_setup_msix(), the
driver requests vector affinity with .pre_vectors = 1 to reserve Vector 0
for non-affinitized housekeeping interrupts.
blk_mq_map_hw_queues() maps hardware queues (hwq 0 to nr_hw_queues - 1)
with an offset of 1, mapping hwq 0 to Vector 1, hwq 1 to Vector 2, etc.
However, pm80xx_chip_get_q_index() retrieves the queue index directly from
blk_mq_unique_tag_to_hwq(tag) without adding 1 for the pre-vector
offset. Consequently, commands on hwq 0 are issued with responseQueue 0
(firing unmanaged Vector 0 on CPU 0), while hwq k fires Vector k (the CPU
affinitized to hwq k-1).
This results in 100% of I/O completion interrupts being delivered to the
wrong CPU core, causing heavy cross-CPU IPIs, cache line bouncing, and
increased kernel and IRQ CPU processing overhead.
Define PM8001_PRE_VECTORS for the reserved housekeeping vector and use it
consistently across MSI-X vector allocation, hardware queue setup and
mapping, and queue index lookup. Update pm80xx_chip_get_q_index() to accept
pm8001_ha and add PM8001_PRE_VECTORS to blk_mq_unique_tag_to_hwq() whenever
multi-queue is enabled (number_of_intr > PM8001_PRE_VECTORS), routing
completion interrupts to their affinitized CPU cores.
Note that offsetting completions by PM8001_PRE_VECTORS routes the highest
hardware queue to outbound queue max_q_num - 1, which pm80xx_chip_init()
also programs as the fatal error interrupt vector. As a result,
process_oq() now reads MSGU_SCRATCH_PAD_1 (and MSGU_SCRATCH_PAD_RSVD_0 when
no fatal error is reported) on every interrupt for that queue, matching the
behavior before commit 42f22fe36d51 ("scsi: pm8001: Expose hardware queues
for pm80xx").
Fixes: 42f22fe36d51 ("scsi: pm8001: Expose hardware queues for pm80xx")
Signed-off-by: Terrence Adams <tadamsjr@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20261118180344.1159617-1-tadamsjr@google.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/pm8001/pm8001_defs.h | 1 +
drivers/scsi/pm8001/pm8001_init.c | 15 +++++++++------
drivers/scsi/pm8001/pm80xx_hwi.c | 13 +++++++++----
3 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/pm8001/pm8001_defs.h b/drivers/scsi/pm8001/pm8001_defs.h
index a9605ca317f34..9b37a76d8b744 100644
--- a/drivers/scsi/pm8001/pm8001_defs.h
+++ b/drivers/scsi/pm8001/pm8001_defs.h
@@ -178,6 +178,7 @@ enum port_type {
#define PM8001_MAX_INB_NUM 64
#define PM8001_MAX_OUTB_NUM 64
#define PM8001_CAN_QUEUE 508 /* SCSI Queue depth */
+#define PM8001_PRE_VECTORS 1 /* non-affinitized housekeeping vector */
/* Inbound/Outbound queue size */
#define IOMB_SIZE_SPC 64
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index 5af81c73a8f87..b1788788b7ed9 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -104,8 +104,9 @@ static void pm8001_map_queues(struct Scsi_Host *shost)
struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT];
- if (pm8001_ha->number_of_intr > 1) {
- blk_mq_map_hw_queues(qmap, &pm8001_ha->pdev->dev, 1);
+ if (pm8001_ha->number_of_intr > PM8001_PRE_VECTORS) {
+ blk_mq_map_hw_queues(qmap, &pm8001_ha->pdev->dev,
+ PM8001_PRE_VECTORS);
return;
}
@@ -977,10 +978,11 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha)
* include in the affinity spreading.
*/
struct irq_affinity desc = {
- .pre_vectors = 1,
+ .pre_vectors = PM8001_PRE_VECTORS,
};
rc = pci_alloc_irq_vectors_affinity(
- pm8001_ha->pdev, 2, PM8001_MAX_MSIX_VEC,
+ pm8001_ha->pdev, PM8001_PRE_VECTORS + 1,
+ PM8001_MAX_MSIX_VEC,
PCI_IRQ_MSIX | PCI_IRQ_AFFINITY, &desc);
}
@@ -1183,8 +1185,9 @@ static int pm8001_pci_probe(struct pci_dev *pdev,
PM8001_CHIP_DISP->chip_post_init(pm8001_ha);
- if (pm8001_ha->number_of_intr > 1) {
- shost->nr_hw_queues = pm8001_ha->number_of_intr - 1;
+ if (pm8001_ha->number_of_intr > PM8001_PRE_VECTORS) {
+ shost->nr_hw_queues = pm8001_ha->number_of_intr -
+ PM8001_PRE_VECTORS;
/*
* For now, ensure we're not sent too many commands by setting
* host_tagset. This is also required if we start using request
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 659dbd603a033..7cf24b2f09f6f 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -4326,14 +4326,19 @@ static int check_enc_sat_cmd(struct sas_task *task)
return ret;
}
-static u32 pm80xx_chip_get_q_index(struct sas_task *task)
+static u32 pm80xx_chip_get_q_index(struct pm8001_hba_info *pm8001_ha,
+ struct sas_task *task)
{
struct request *rq = sas_task_find_rq(task);
if (!rq)
return 0;
- return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(rq));
+ if (pm8001_ha->number_of_intr > PM8001_PRE_VECTORS)
+ return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(rq)) +
+ PM8001_PRE_VECTORS;
+
+ return 0;
}
/**
@@ -4369,7 +4374,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_attr & 7);
memcpy(ssp_cmd.ssp_iu.cdb, task->ssp_task.cmd->cmnd,
task->ssp_task.cmd->cmd_len);
- q_index = pm80xx_chip_get_q_index(task);
+ q_index = pm80xx_chip_get_q_index(pm8001_ha, task);
/* Check if encryption is set */
if (pm8001_ha->chip->encrypt &&
@@ -4508,7 +4513,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
u32 opc = OPC_INB_SATA_HOST_OPSTART;
memset(&sata_cmd, 0, sizeof(sata_cmd));
- q_index = pm80xx_chip_get_q_index(task);
+ q_index = pm80xx_chip_get_q_index(pm8001_ha, task);
if (task->data_dir == DMA_NONE && !task->ata_task.use_ncq) {
ATAP = 0x04; /* no data*/
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 147/742] net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (142 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 146/742] scsi: pm8001: Offset hardware queue index for MSI-X pre-vector Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 148/742] tcp: initialize ir_rmt_addr and ir_loc_addr in cookie_v6_check() Greg Kroah-Hartman
` (582 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tariq Toukan, Gal Pressman,
Cosmin Ratiu, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tariq Toukan <tariqt@nvidia.com>
[ Upstream commit e421df3c838692c0c3503768ec3c9183f6df77aa ]
HW-GRO (SHAMPO) sessions are not terminated by HW when the kTLS RX
offload indication in the CQE changes. The driver applies the offload
metadata of the first packet in the session only, so ciphertext and
plaintext can end up in the same skb under a single skb->decrypted
indication, and resync requests carried by non-first packets are lost.
Do not merge a CQE whose decryption state differs from skb->decrypted,
which the first packet of the session sets. Never merge a CQE that
carries a resync request or a TLS error, so that each of them starts a
session and is handled.
The failure was reproduced on ConnectX-7 with HW GRO and kTLS RX offload
on and 0.3% loss added by netem on the sender's egress: TlsDecryptError
increased and the receiving sockets failed with EBADMSG. With this
patch, TlsDecryptError stays 0.
Fixes: 92552d3abd32 ("net/mlx5e: HW_GRO cqe handler implementation")
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Link: https://patch.msgid.link/20261118144042.1916204-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../mellanox/mlx5/core/en_accel/en_accel.h | 5 +++--
.../mellanox/mlx5/core/en_accel/ktls_txrx.h | 21 +++++++++++++++++++
.../net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +-
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h
index 5a340f1435e6b..554c225f73767 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h
@@ -219,9 +219,10 @@ static inline void mlx5e_accel_tx_finish(struct mlx5e_txqsq *sq,
}
static inline bool
-mlx5e_accel_shampo_can_merge(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
+mlx5e_accel_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
{
- return mlx5e_psp_shampo_can_merge(rq->hw_gro_data->skb, cqe);
+ return mlx5e_psp_shampo_can_merge(skb, cqe) &&
+ mlx5e_ktls_shampo_can_merge(skb, cqe);
}
static inline int mlx5e_accel_init_rx(struct mlx5e_priv *priv)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h
index 93bd383a23d8c..20e5dc6a718e1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h
@@ -60,6 +60,21 @@ mlx5e_ktls_handle_tx_wqe(struct mlx5_wqe_ctrl_seg *cseg,
{
cseg->tis_tir_num = cpu_to_be32(state->tls_tisn << 8);
}
+
+/* The first CQE of a HW-GRO session sets skb->decrypted. A resync request or
+ * a TLS error is handled on the first CQE only, so it starts a new session.
+ */
+static inline bool
+mlx5e_ktls_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
+{
+ u8 tls_offload = get_cqe_tls_offload(cqe);
+
+ if (unlikely(tls_offload > CQE_TLS_OFFLOAD_DECRYPTED))
+ return false;
+
+ return (tls_offload == CQE_TLS_OFFLOAD_DECRYPTED) ==
+ skb_is_decrypted(skb);
+}
#else
static inline bool
mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
@@ -93,6 +108,12 @@ static inline void mlx5e_ktls_handle_rx_skb(struct mlx5e_rq *rq,
u32 *cqe_bcnt)
{
}
+
+static inline bool
+mlx5e_ktls_shampo_can_merge(struct sk_buff *skb, struct mlx5_cqe64 *cqe)
+{
+ return true;
+}
#endif /* CONFIG_MLX5_EN_TLS */
#endif /* __MLX5E_TLS_TXRX_H__ */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index d49f26323b1e2..ffcb6ec760a57 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -2271,7 +2271,7 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cq
if (*skb &&
!(match &&
mlx5e_hw_gro_skb_has_enough_space(*skb, data_bcnt, page_size) &&
- mlx5e_accel_shampo_can_merge(rq, cqe))) {
+ mlx5e_accel_shampo_can_merge(*skb, cqe))) {
match = false;
mlx5e_shampo_flush_skb(rq, cqe, match);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 148/742] tcp: initialize ir_rmt_addr and ir_loc_addr in cookie_v6_check()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (143 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 147/742] net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 149/742] tcp: accecn: initialize AccECN fields in syncookie path Greg Kroah-Hartman
` (581 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Thaison Phan, Eric Dumazet,
Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thaison Phan <thaisonphan@google.com>
[ Upstream commit 7411fb1929075884648e9db0b9ec7e424c095185 ]
Commit a3a128f611a9 ("inet: consolidate inet_csk_clone_lock()") moved
the LOOPBACK4_IPV6 initialization for passive IPv6 TCP sockets from
tcp_v6_syn_recv_sock() to tcp_v6_init_req().
IPv6 SYN cookie connections allocate a fresh request_sock without
__GFP_ZERO and call tcp_v6_syn_recv_sock() without tcp_v6_init_req(),
leaving ireq->ir_rmt_addr and ireq->ir_loc_addr uninitialized in
cookie_v6_check(). inet_csk_clone_lock() then copies uninitialized slab
bytes into sk_daddr, sk_rcv_saddr, and inet_saddr, exposing them to
tracepoints and bpf_sock and causing inet_daddr != LOOPBACK4_IPV6 checks
(such as IP_OPTIONS in do_ip_setsockopt()) to misclassify native IPv6
child sockets as IPv4-mapped.
This was originally noticed via an out-of-tree socket hook observing
inet_sk(sk)->inet_saddr != LOOPBACK4_IPV6 on KASAN test runs. KASAN
enables SLUB_RCU_DEBUG by default, introducing an RCU grace period that
prevents cookie_v6_check() from reusing the warm request_sock initialized
during the initial SYN. Upstream, with tcp_syncookies=2,
SLUB_RCU_DEBUG=y, and slub_debug=P, sock:inet_sock_set_state shows slab
poison instead of 127.0.0.6:
... sock:inet_sock_set_state: family=AF_INET6 protocol=IPPROTO_TCP \
sport=59839 dport=41050 \
saddr=90.90.90.90 daddr=90.90.90.90 \
saddrv6=::1 daddrv6=::1 \
oldstate=TCP_LISTEN newstate=TCP_SYN_RECV
Initialize ireq->ir_rmt_addr and ireq->ir_loc_addr to LOOPBACK4_IPV6 in
cookie_v6_check() to match tcp_v6_init_req(). Tested against a QEMU
reproducer checking inet_sock_set_state and IP_OPTIONS, as well as the
packetdrill syncookie selftests.
Fixes: a3a128f611a9 ("inet: consolidate inet_csk_clone_lock()")
Signed-off-by: Thaison Phan <thaisonphan@google.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261118210933.2477423-2-thaisonphan@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ipv6/syncookies.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index b581cb1ee2e8a..b33011b71fff6 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -17,6 +17,7 @@
#include <net/ipv6.h>
#include <net/tcp.h>
#include <net/tcp_ecn.h>
+#include <net/transp_v6.h>
#define COOKIEBITS 24 /* Upper bits store count */
#define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
@@ -205,6 +206,8 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
+ ireq->ir_rmt_addr = LOOPBACK4_IPV6;
+ ireq->ir_loc_addr = LOOPBACK4_IPV6;
if (security_inet_conn_request(sk, skb, req)) {
SKB_DR_SET(reason, SECURITY_HOOK);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 149/742] tcp: accecn: initialize AccECN fields in syncookie path
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (144 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 148/742] tcp: initialize ir_rmt_addr and ir_loc_addr in cookie_v6_check() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 150/742] dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend Greg Kroah-Hartman
` (580 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Thaison Phan, Matthieu Baerts (NGI0),
Eric Dumazet, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thaison Phan <thaisonphan@google.com>
[ Upstream commit ce28b1a4d137842e428a578269c35d6c84109438 ]
cookie_tcp_reqsk_alloc() and bpf_sk_assign_tcp_reqsk() allocate struct
request_sock without __GFP_ZERO, leaving saw_accecn_opt,
accecn_fail_mode, syn_ect_rcv, and syn_ect_snt uninitialized. When
accecn_ok is negotiated in cookie_{v4,v6}_check(),
tcp_ecn_openreq_child() reads all four fields to initialize the child
socket's AccECN state.
In addition, because the temporary request_sock used to send a cookie
SYN-ACK is immediately freed, treq->syn_ect_snt is lost. For AccECN
connections where the listener marks ECT on the SYN-ACK, leaving
syn_ect_snt as 0 causes tcp_accecn_third_ack() to see a mismatch between
the expected Not-ECT and the peer's reflected ECT in the ACE field,
erroneously flagging TCP_ACCECN_ACE_FAIL_RECV in accecn_fail_mode. Refer
to Table 4 of RFC 9768 for more details.
Initialize the AccECN fields in cookie_tcp_reqsk_init() to match
tcp_openreq_init(). For kernel-generated cookies (!req->syncookie), set
syn_ect_snt from the listener's TOS/tclass in cookie_{v4,v6}_check() to
match tcp_{v4,v6}_send_synack(); for BPF custom syncookies
(req->syncookie), leave syn_ect_snt at 0 (Not-ECT) since the SYN-ACK was
built by the BPF program rather than the kernel and bpf_tcp_req_attrs
does not report the SYN-ACK ECN codepoint.
Found by AI-assisted code inspection comparing tcp_openreq_init() and
cookie_tcp_reqsk_init() while investigating the cookie_v6_check()
LOOPBACK4_IPV6 bug. Reproduced in a QEMU VM with tcp_syncookies=2,
tcp_ecn=3, SLUB_RCU_DEBUG=y, and slub_debug=P, observing bogus
tcpi_accecn_fail_mode and tcpi_accecn_opt_seen values in TCP_INFO on the
accepted child socket (and tcpi_accecn_fail_mode=0x2 on ECT(0)
listeners), and tested with packetdrill AccECN and syncookie selftests.
Fixes: 3cae34274c79 ("tcp: accecn: AccECN negotiation")
Fixes: b40671b5ee58 ("tcp: accecn: AccECN option failure handling")
Signed-off-by: Thaison Phan <thaisonphan@google.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261118210933.2477423-3-thaisonphan@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ipv4/syncookies.c | 7 +++++++
net/ipv6/syncookies.c | 3 +++
2 files changed, 10 insertions(+)
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 4e0ff3b820627..89169c82431c1 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -290,6 +290,10 @@ static int cookie_tcp_reqsk_init(struct sock *sk, struct sk_buff *skb,
*/
treq->txhash = treq->snt_isn;
treq->syn_tos = TCP_SKB_CB(skb)->ip_dsfield;
+ treq->saw_accecn_opt = TCP_ACCECN_OPT_NOT_SEEN;
+ treq->accecn_fail_mode = 0;
+ treq->syn_ect_rcv = 0;
+ treq->syn_ect_snt = 0;
#if IS_ENABLED(CONFIG_MPTCP)
treq->is_mptcp = sk_is_mptcp(sk);
@@ -502,6 +506,9 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
ireq->rcv_wscale = rcv_wscale;
ireq->ecn_ok &= cookie_ecn_ok(net, &rt->dst);
treq->accecn_ok = ireq->ecn_ok && cookie_accecn_ok(th);
+ /* SYN-ACK was not sent by the kernel if req->syncookie is set. */
+ if (!req->syncookie)
+ treq->syn_ect_snt = READ_ONCE(inet_sk(sk)->tos) & INET_ECN_MASK;
ret = tcp_get_cookie_sock(sk, skb, req, &rt->dst);
/* ip_queue_xmit() depends on our flow being setup
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index b33011b71fff6..e8d45a627ca26 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -276,6 +276,9 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
ireq->rcv_wscale = rcv_wscale;
ireq->ecn_ok &= cookie_ecn_ok(net, dst);
tcp_rsk(req)->accecn_ok = ireq->ecn_ok && cookie_accecn_ok(th);
+ /* SYN-ACK was not sent by the kernel if req->syncookie is set. */
+ if (!req->syncookie)
+ tcp_rsk(req)->syn_ect_snt = READ_ONCE(np->tclass) & INET_ECN_MASK;
ret = tcp_get_cookie_sock(sk, skb, req, dst);
if (!ret) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 150/742] dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (145 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 149/742] tcp: accecn: initialize AccECN fields in syncookie path Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 151/742] dmaengine: idxd: Free the minor number when cdev setup fails Greg Kroah-Hartman
` (579 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Xiangwu Lai, Frank Li,
Amelie Delaunay, Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
[ Upstream commit 34c8c2ea213aab7b452df93e5b7547f4459a49e9 ]
stm32_mdma_pm_suspend() increments the runtime PM usage counter with
pm_runtime_resume_and_get(), but when a channel is still enabled it
returns -EBUSY directly without dropping the reference. The matching
pm_runtime_put_sync() only runs on the success path.
Each failed suspend attempt therefore leaks one runtime PM reference,
so the device can never runtime suspend afterwards. Drop the
reference before returning -EBUSY.
Fixes: 7cb819c856d9 ("dmaengine: stm32-mdma: add suspend/resume power management support")
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://patch.msgid.link/20261102104432.873-1-laixiangwu@cmss.chinamobile.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/dma/stm32/stm32-mdma.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
index e3bbdc9ee36ed..fe1ff4a009fd3 100644
--- a/drivers/dma/stm32/stm32-mdma.c
+++ b/drivers/dma/stm32/stm32-mdma.c
@@ -1785,6 +1785,7 @@ static int stm32_mdma_pm_suspend(struct device *dev)
ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(id));
if (ccr & STM32_MDMA_CCR_EN) {
dev_warn(dev, "Suspend is prevented by Chan %i\n", id);
+ pm_runtime_put_sync(dev);
return -EBUSY;
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 151/742] dmaengine: idxd: Free the minor number when cdev setup fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (146 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 150/742] dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 152/742] dmaengine: rcar-dmac: Fix PM usage counter imbalance Greg Kroah-Hartman
` (578 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, SeungUk Nam, Frank Li, Vinod Koul,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: SeungUk Nam <tmddnr49449@gmail.com>
[ Upstream commit 56cbd7f69ce6037738410a5c50efb7cacf52b0ae ]
idxd_wq_add_cdev() allocates a minor number from cdev_ctx->minor_ida for
the new struct idxd_cdev. When dev_set_name() or cdev_device_add()
fails, the error path calls put_device(), and the release callback
idxd_cdev_dev_release() only frees idxd_cdev, so the minor number is
never returned to the ida. Leaked numbers accumulate across bind/unbind
cycles, up to MINORMASK, for as long as the module stays loaded.
Free the minor number before put_device() drops the last reference on
that path.
Fixes: c311f5e92484 ("dmaengine: idxd: Fix freeing the allocated ida too late")
Signed-off-by: SeungUk Nam <tmddnr49449@gmail.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260910074832.15729-1-tmddnr49449@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/dma/idxd/cdev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
index 82b07cf942ef8..f1af7f0d25d34 100644
--- a/drivers/dma/idxd/cdev.c
+++ b/drivers/dma/idxd/cdev.c
@@ -573,6 +573,7 @@ int idxd_wq_add_cdev(struct idxd_wq *wq)
return 0;
err:
+ ida_free(&cdev_ctx->minor_ida, minor);
put_device(dev);
wq->idxd_cdev = NULL;
return rc;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 152/742] dmaengine: rcar-dmac: Fix PM usage counter imbalance
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (147 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 151/742] dmaengine: idxd: Free the minor number when cdev setup fails Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 153/742] dmaengine: rcar-dmac: Add missing dma_descriptor_unmap() Greg Kroah-Hartman
` (577 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zhang Shurong, Geert Uytterhoeven,
Frank Li, Laurent Pinchart, Wolfram Sang, Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Shurong <zhang_shurong@foxmail.com>
[ Upstream commit d3c108c095712a3b7eab292ef7ea9a57ff5cd5d7 ]
pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here. We
fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.
Fixes: 87244fe5abdf ("dmaengine: rcar-dmac: Add Renesas R-Car Gen2 DMA Controller (DMAC) driver")
Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://patch.msgid.link/20261012123020.11320-6-wsa+renesas@sang-engineering.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/dma/sh/rcar-dmac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 44eab2d21d54f..2d2baa36feeae 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1068,7 +1068,7 @@ static int rcar_dmac_alloc_chan_resources(struct dma_chan *chan)
if (ret < 0)
return -ENOMEM;
- return pm_runtime_get_sync(chan->device->dev);
+ return pm_runtime_resume_and_get(chan->device->dev);
}
static void rcar_dmac_free_chan_resources(struct dma_chan *chan)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 153/742] dmaengine: rcar-dmac: Add missing dma_descriptor_unmap()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (148 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 152/742] dmaengine: rcar-dmac: Fix PM usage counter imbalance Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 154/742] usb: gadget: f_hid: fix report_list entries leak Greg Kroah-Hartman
` (576 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Koichiro Den, Wolfram Sang, Frank Li,
Vinod Koul, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Koichiro Den <den@valinux.co.jp>
[ Upstream commit 0ca154b10168d8874b871edf5510640c51b326c3 ]
Call dma_descriptor_unmap() right before dma_cookie_complete() in the
threaded IRQ completion path. Without this, streaming DMA mappings
attached to the descriptor are never released and may eventually exhaust
DMA mapping resources (e.g. IOVA with an IOMMU or bounce-buffer slots
with SWIOTLB), leading to dma_map_* failures.
Also ensure dma_descriptor_unmap() is called in rcar_dmac_chan_reinit()
(error/terminate path) to avoid the same type of leaks.
Fixes: 87244fe5abdf ("dmaengine: rcar-dmac: Add Renesas R-Car Gen2 DMA Controller (DMAC) driver")
Signed-off-by: Koichiro Den <den@valinux.co.jp>
[wsa: moved unmap before cookie completion, added Fixes tag]
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20261012123020.11320-7-wsa+renesas@sang-engineering.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/dma/sh/rcar-dmac.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 2d2baa36feeae..8d9fcb0bd809a 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -842,6 +842,7 @@ static void rcar_dmac_chan_reinit(struct rcar_dmac_chan *chan)
list_for_each_entry_safe(desc, _desc, &descs, node) {
list_del(&desc->node);
+ dma_descriptor_unmap(&desc->async_tx);
rcar_dmac_desc_put(chan, desc);
}
}
@@ -1651,6 +1652,7 @@ static irqreturn_t rcar_dmac_isr_channel_thread(int irq, void *dev)
while (!list_empty(&chan->desc.done)) {
desc = list_first_entry(&chan->desc.done, struct rcar_dmac_desc,
node);
+ dma_descriptor_unmap(&desc->async_tx);
dma_cookie_complete(&desc->async_tx);
list_del(&desc->node);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 154/742] usb: gadget: f_hid: fix report_list entries leak
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (149 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 153/742] dmaengine: rcar-dmac: Add missing dma_descriptor_unmap() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 155/742] usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response Greg Kroah-Hartman
` (575 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Shunbo Shi, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shunbo Shi <shishunbo@cmss.chinamobile.com>
[ Upstream commit 19e8981057fb5947697f99a3c6a3f6ff4a2d85a1 ]
Each GADGET_HID_WRITE_GET_REPORT ioctl for a report ID that is not
yet in hidg->report_list allocates a report_entry and adds it to
the list. hidg_release() frees report_desc and set_report_buf, but
never walks report_list, so every accumulated entry leaks on
function destroy (e.g. when the HID gadget is unbound and the
device is removed).
Free the entries in hidg_release(). This is safe without extra
locking: at release time the function is unbound (the workqueue is
already destroyed and userspace has no way to reach the ioctl).
Fixes: a139c98f760e ("USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL")
Signed-off-by: Shunbo Shi <shishunbo@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261117125051.5646-2-shishunbo@cmss.chinamobile.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/gadget/function/f_hid.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index 3c6b43d06a6d1..670ae7959bbd7 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -121,6 +121,12 @@ static inline struct f_hidg *func_to_hidg(struct usb_function *f)
static void hidg_release(struct device *dev)
{
struct f_hidg *hidg = container_of(dev, struct f_hidg, dev);
+ struct report_entry *entry, *tmp;
+
+ list_for_each_entry_safe(entry, tmp, &hidg->report_list, node) {
+ list_del(&entry->node);
+ kfree(entry);
+ }
kfree(hidg->report_desc);
kfree(hidg->set_report_buf);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 155/742] usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (150 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 154/742] usb: gadget: f_hid: fix report_list entries leak Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 156/742] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails Greg Kroah-Hartman
` (574 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Shunbo Shi, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shunbo Shi <shishunbo@cmss.chinamobile.com>
[ Upstream commit 07ec204e8aecbfee425008832b18d5d720daca6d ]
The GET_REPORT response is served by pointing get_req->buf at the
data[] array of a report_list entry and calling usb_ep_queue().
The request completes asynchronously, so the controller may still
be reading the entry's buffer after get_report_workqueue_handler()
drops get_report_spinlock.
At the same time, userspace can update that same entry via the
GADGET_HID_WRITE_GET_REPORT ioctl: f_hidg_get_report() copies new
report data into the entry while holding the spinlock, but the
transfer reading the entry is not serialized against that update
(the lock was already released by the work handler).
The result is that the host can receive a GET_REPORT response that
mixes bytes of the old and the new report (a torn write), with no
memory-safety violation but corrupted report data on the wire.
Serve the response from a dedicated buffer allocated once in
hidg_alloc() and freed in hidg_release().
This also removes the now unused get_report member from struct
f_hidg.
Fixes: a139c98f760e ("USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL")
Signed-off-by: Shunbo Shi <shishunbo@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261117125051.5646-3-shishunbo@cmss.chinamobile.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/gadget/function/f_hid.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index 670ae7959bbd7..e29e7d1da924a 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -94,7 +94,7 @@ struct f_hidg {
/* get report */
struct usb_request *get_req;
- struct usb_hidg_report get_report;
+ void *get_req_buf;
bool get_report_returned;
int get_report_req_report_id;
int get_report_req_report_length;
@@ -128,6 +128,7 @@ static void hidg_release(struct device *dev)
kfree(entry);
}
+ kfree(hidg->get_req_buf);
kfree(hidg->report_desc);
kfree(hidg->set_report_buf);
kfree(hidg);
@@ -587,7 +588,7 @@ static void get_report_workqueue_handler(struct work_struct *work)
ptr = f_hidg_search_for_report(hidg, hidg->get_report_req_report_id);
if (ptr && !ptr->report_data.userspace_req) {
/* Report exists in list and it is to be used for immediate response */
- req->buf = ptr->report_data.data;
+ memcpy(req->buf, ptr->report_data.data, req->length);
status = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC);
hidg->get_report_returned = true;
spin_unlock_irqrestore(&hidg->get_report_spinlock, flags);
@@ -622,10 +623,9 @@ static void get_report_workqueue_handler(struct work_struct *work)
* Either get an updated response just serviced by userspace
* or send the latest response in the list
*/
- req->buf = ptr->report_data.data;
+ memcpy(req->buf, ptr->report_data.data, req->length);
} else {
/* If there are no prevoiusly sent reports send empty report */
- req->buf = hidg->get_report.data;
memset(req->buf, 0x0, req->length);
}
@@ -1161,6 +1161,15 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
if (!hidg->get_req)
return -ENOMEM;
+ /*
+ * The GET_REPORT response is served from a dedicated buffer
+ * (allocated in hidg_alloc()), not from the report_list
+ * entries: userspace may update an entry while the controller
+ * is still reading the previous response, which would corrupt
+ * the data on the wire.
+ */
+ hidg->get_req->buf = hidg->get_req_buf;
+
hidg->get_req->zero = 0;
hidg->get_req->complete = hidg_get_report_complete;
hidg->get_req->context = hidg;
@@ -1647,6 +1656,18 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)
}
hidg->use_out_ep = !opts->no_out_endpoint;
+ /*
+ * Dedicated buffer for GET_REPORT responses, allocated once for
+ * the whole lifetime of this function instance: hidg_release()
+ * is the only safe free point, as it runs after all USB
+ * activity has ceased and all file references are gone.
+ */
+ hidg->get_req_buf = kmalloc(MAX_REPORT_LENGTH, GFP_KERNEL);
+ if (!hidg->get_req_buf) {
+ ret = -ENOMEM;
+ goto err_put_device;
+ }
+
++opts->refcnt;
mutex_unlock(&opts->lock);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 156/742] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (151 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 155/742] usb: gadget: f_hid: fix race between userspace report update and GET_REPORT response Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 157/742] HID: sensor: custom: Fix state lifetime during removal Greg Kroah-Hartman
` (573 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Shunbo Shi, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shunbo Shi <shishunbo@cmss.chinamobile.com>
[ Upstream commit f11175ece1250557ec595ea7a2854f0391cab53d ]
In hidg_bind(), hidg->get_req is allocated early; if
usb_gstrings_attach() subsequently fails, the function returns
directly without freeing the request, leaking it. Unwind through
the fail path instead.
Fixes: a139c98f760e ("USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL")
Signed-off-by: Shunbo Shi <shishunbo@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261117125051.5646-4-shishunbo@cmss.chinamobile.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/gadget/function/f_hid.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index e29e7d1da924a..53ea214280b95 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -1178,8 +1178,10 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)
/* maybe allocate device-global string IDs, and patch descriptors */
us = usb_gstrings_attach(c->cdev, ct_func_strings,
ARRAY_SIZE(ct_func_string_defs));
- if (IS_ERR(us))
- return PTR_ERR(us);
+ if (IS_ERR(us)) {
+ status = PTR_ERR(us);
+ goto fail;
+ }
hidg_interface_desc.iInterface = us[CT_FUNC_HID_IDX].id;
/* allocate instance-specific interface IDs, and patch descriptors */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 157/742] HID: sensor: custom: Fix state lifetime during removal
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (152 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 156/742] usb: gadget: f_hid: fix get_req leak when usb_gstrings_attach() fails Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 158/742] HID: sensor: custom: Serialize misc device reads Greg Kroah-Hartman
` (572 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Zhang Lixu,
Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ Upstream commit ac6c19392c7996ac8135dba6907c391a4be5beaf ]
Open misc device files can outlive platform-device removal. Since the
devm-allocated state can be freed while a reader is queued on its wait
queue, subsequent file operations may access freed memory.
Allocate the state independently of devres and give every open
file a reference to keep the FIFO and state alive after removal.
On removal, mark the device as disconnected and wake readers; make reads
return -ENODEV and polls report hangup and error. Free the FIFO and state
when the final reference is released. Unregister the sensor hub callback
before tearing down the interface so in-flight raw-event processing
finishes before the sensor state can be freed.
Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-sensor-custom.c | 82 ++++++++++++++++++++++-----------
1 file changed, 56 insertions(+), 26 deletions(-)
diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index 8375697b459da..c940630d76db5 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -11,6 +11,7 @@
#include <linux/init.h>
#include <linux/miscdevice.h>
#include <linux/kfifo.h>
+#include <linux/kref.h>
#include <linux/sched.h>
#include <linux/wait.h>
#include <linux/poll.h>
@@ -37,6 +38,8 @@ struct hid_sensor_custom_field {
struct hid_sensor_custom {
struct mutex mutex;
+ struct kref ref;
+ bool removed;
struct platform_device *pdev;
struct hid_sensor_hub_device *hsdev;
struct hid_sensor_hub_callbacks callbacks;
@@ -643,6 +646,15 @@ static void hid_sensor_custom_remove_attributes(struct hid_sensor_custom *
kfree(sensor_inst->fields);
}
+static void hid_sensor_custom_free(struct kref *ref)
+{
+ struct hid_sensor_custom *sensor_inst =
+ container_of(ref, struct hid_sensor_custom, ref);
+
+ kfifo_free(&sensor_inst->data_fifo);
+ kfree(sensor_inst);
+}
+
static ssize_t hid_sensor_custom_read(struct file *file, char __user *buf,
size_t count, loff_t *f_ps)
{
@@ -656,22 +668,27 @@ static ssize_t hid_sensor_custom_read(struct file *file, char __user *buf,
if (count < sizeof(struct hid_sensor_sample))
return -EINVAL;
- do {
- if (kfifo_is_empty(&sensor_inst->data_fifo)) {
- if (file->f_flags & O_NONBLOCK)
- return -EAGAIN;
+ for (;;) {
+ if (READ_ONCE(sensor_inst->removed))
+ return -ENODEV;
- ret = wait_event_interruptible(sensor_inst->wait,
- !kfifo_is_empty(&sensor_inst->data_fifo));
- if (ret)
- return ret;
- }
ret = kfifo_to_user(&sensor_inst->data_fifo, buf, count,
&copied);
+ if (ret || copied)
+ break;
+
+ if (file->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ ret = wait_event_interruptible(sensor_inst->wait,
+ READ_ONCE(sensor_inst->removed) ||
+ !kfifo_is_empty(&sensor_inst->data_fifo));
if (ret)
return ret;
+ }
- } while (copied == 0);
+ if (ret)
+ return ret;
return copied;
}
@@ -684,6 +701,7 @@ static int hid_sensor_custom_release(struct inode *inode, struct file *file)
struct hid_sensor_custom, custom_dev);
clear_bit(0, &sensor_inst->misc_opened);
+ kref_put(&sensor_inst->ref, hid_sensor_custom_free);
return 0;
}
@@ -691,14 +709,25 @@ static int hid_sensor_custom_release(struct inode *inode, struct file *file)
static int hid_sensor_custom_open(struct inode *inode, struct file *file)
{
struct hid_sensor_custom *sensor_inst;
+ int ret;
sensor_inst = container_of(file->private_data,
struct hid_sensor_custom, custom_dev);
+ if (READ_ONCE(sensor_inst->removed))
+ return -ENODEV;
+
/* We essentially have single reader and writer */
if (test_and_set_bit(0, &sensor_inst->misc_opened))
return -EBUSY;
- return stream_open(inode, file);
+ kref_get(&sensor_inst->ref);
+ ret = stream_open(inode, file);
+ if (ret) {
+ clear_bit(0, &sensor_inst->misc_opened);
+ kref_put(&sensor_inst->ref, hid_sensor_custom_free);
+ }
+
+ return ret;
}
static __poll_t hid_sensor_custom_poll(struct file *file,
@@ -712,6 +741,9 @@ static __poll_t hid_sensor_custom_poll(struct file *file,
poll_wait(file, &sensor_inst->wait, wait);
+ if (READ_ONCE(sensor_inst->removed))
+ return EPOLLHUP | EPOLLERR;
+
if (!kfifo_is_empty(&sensor_inst->data_fifo))
mask = EPOLLIN | EPOLLRDNORM;
@@ -741,21 +773,15 @@ static int hid_sensor_custom_dev_if_add(struct hid_sensor_custom *sensor_inst)
sensor_inst->custom_dev.minor = MISC_DYNAMIC_MINOR;
sensor_inst->custom_dev.name = dev_name(&sensor_inst->pdev->dev);
sensor_inst->custom_dev.fops = &hid_sensor_custom_fops;
- ret = misc_register(&sensor_inst->custom_dev);
- if (ret) {
- kfifo_free(&sensor_inst->data_fifo);
- return ret;
- }
- return 0;
+ return misc_register(&sensor_inst->custom_dev);
}
static void hid_sensor_custom_dev_if_remove(struct hid_sensor_custom
*sensor_inst)
{
- wake_up(&sensor_inst->wait);
+ WRITE_ONCE(sensor_inst->removed, true);
+ wake_up_interruptible_all(&sensor_inst->wait);
misc_deregister(&sensor_inst->custom_dev);
- kfifo_free(&sensor_inst->data_fifo);
-
}
/*
@@ -978,8 +1004,7 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
int ret;
const struct hid_sensor_custom_match *match;
- sensor_inst = devm_kzalloc(&pdev->dev, sizeof(*sensor_inst),
- GFP_KERNEL);
+ sensor_inst = kzalloc(sizeof(*sensor_inst), GFP_KERNEL);
if (!sensor_inst)
return -ENOMEM;
@@ -989,6 +1014,7 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
sensor_inst->hsdev = hsdev;
sensor_inst->pdev = pdev;
mutex_init(&sensor_inst->mutex);
+ kref_init(&sensor_inst->ref);
platform_set_drvdata(pdev, sensor_inst);
ret = hid_sensor_custom_get_known(hsdev, &match);
@@ -1000,7 +1026,7 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
if (ret) {
dev_err(&pdev->dev,
"register_platform_device failed\n");
- return ret;
+ goto err_put;
}
return 0;
@@ -1010,7 +1036,7 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
&sensor_inst->callbacks);
if (ret < 0) {
dev_err(&pdev->dev, "callback reg failed\n");
- return ret;
+ goto err_put;
}
ret = hid_sensor_custom_add_attributes(sensor_inst);
@@ -1035,6 +1061,8 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
hid_sensor_custom_remove_attributes(sensor_inst);
err_remove_callback:
sensor_hub_remove_callback(hsdev, hsdev->usage);
+err_put:
+ kref_put(&sensor_inst->ref, hid_sensor_custom_free);
return ret;
}
@@ -1046,9 +1074,10 @@ static void hid_sensor_custom_remove(struct platform_device *pdev)
if (sensor_inst->custom_pdev) {
platform_device_unregister(sensor_inst->custom_pdev);
- return;
+ goto out;
}
+ sensor_hub_remove_callback(hsdev, hsdev->usage);
hid_sensor_custom_dev_if_remove(sensor_inst);
/* Remove enable_sensor first as it uses fields via power_state/report_state. */
sysfs_remove_group(&sensor_inst->pdev->dev.kobj,
@@ -1061,7 +1090,8 @@ static void hid_sensor_custom_remove(struct platform_device *pdev)
}
mutex_unlock(&sensor_inst->mutex);
hid_sensor_custom_remove_attributes(sensor_inst);
- sensor_hub_remove_callback(hsdev, hsdev->usage);
+out:
+ kref_put(&sensor_inst->ref, hid_sensor_custom_free);
}
static const struct platform_device_id hid_sensor_custom_ids[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 158/742] HID: sensor: custom: Serialize misc device reads
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (153 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 157/742] HID: sensor: custom: Fix state lifetime during removal Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 159/742] HID: sensor: custom: Register enable attribute after misc device Greg Kroah-Hartman
` (571 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Zhang Lixu,
Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ Upstream commit fecb7895fbb1b7891e81a033f0dd1f5f7876dc07 ]
The misc device permits only one open file, but threads sharing that
file can still read concurrently. Serialize readers to preserve the
single-reader assumption of the FIFO while keeping removal independent
of a stalled user copy.
Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-sensor-custom.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index c940630d76db5..f9e604920ea76 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -38,6 +38,7 @@ struct hid_sensor_custom_field {
struct hid_sensor_custom {
struct mutex mutex;
+ struct mutex read_mutex;
struct kref ref;
bool removed;
struct platform_device *pdev;
@@ -668,25 +669,39 @@ static ssize_t hid_sensor_custom_read(struct file *file, char __user *buf,
if (count < sizeof(struct hid_sensor_sample))
return -EINVAL;
+ if (file->f_flags & O_NONBLOCK) {
+ if (!mutex_trylock(&sensor_inst->read_mutex))
+ return -EAGAIN;
+ } else {
+ ret = mutex_lock_interruptible(&sensor_inst->read_mutex);
+ if (ret)
+ return ret;
+ }
+
for (;;) {
- if (READ_ONCE(sensor_inst->removed))
- return -ENODEV;
+ if (READ_ONCE(sensor_inst->removed)) {
+ ret = -ENODEV;
+ break;
+ }
ret = kfifo_to_user(&sensor_inst->data_fifo, buf, count,
&copied);
if (ret || copied)
break;
- if (file->f_flags & O_NONBLOCK)
- return -EAGAIN;
+ if (file->f_flags & O_NONBLOCK) {
+ ret = -EAGAIN;
+ break;
+ }
ret = wait_event_interruptible(sensor_inst->wait,
READ_ONCE(sensor_inst->removed) ||
!kfifo_is_empty(&sensor_inst->data_fifo));
if (ret)
- return ret;
+ break;
}
+ mutex_unlock(&sensor_inst->read_mutex);
if (ret)
return ret;
@@ -1014,6 +1029,7 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
sensor_inst->hsdev = hsdev;
sensor_inst->pdev = pdev;
mutex_init(&sensor_inst->mutex);
+ mutex_init(&sensor_inst->read_mutex);
kref_init(&sensor_inst->ref);
platform_set_drvdata(pdev, sensor_inst);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 159/742] HID: sensor: custom: Register enable attribute after misc device
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (154 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 158/742] HID: sensor: custom: Serialize misc device reads Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 160/742] HID: sensor-hub: Remove clients before stopping hardware Greg Kroah-Hartman
` (570 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Zhang Lixu,
Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ Upstream commit c6ebe27e3ba09edf956139c741b38e8432be3f67 ]
Register the enable_sensor sysfs group only after misc-device setup
succeeds. This prevents userspace from opening the sensor hub while
probe can still fail, which would otherwise leave the hub open reference
unbalanced on unwind.
Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-sensor-custom.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index f9e604920ea76..4d7cb7994dd81 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -1059,20 +1059,19 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
if (ret)
goto err_remove_callback;
- ret = sysfs_create_group(&sensor_inst->pdev->dev.kobj,
- &enable_sensor_attr_group);
+ ret = hid_sensor_custom_dev_if_add(sensor_inst);
if (ret)
goto err_remove_attributes;
- ret = hid_sensor_custom_dev_if_add(sensor_inst);
+ ret = sysfs_create_group(&sensor_inst->pdev->dev.kobj,
+ &enable_sensor_attr_group);
if (ret)
- goto err_remove_group;
+ goto err_remove_dev_if;
return 0;
-err_remove_group:
- sysfs_remove_group(&sensor_inst->pdev->dev.kobj,
- &enable_sensor_attr_group);
+err_remove_dev_if:
+ hid_sensor_custom_dev_if_remove(sensor_inst);
err_remove_attributes:
hid_sensor_custom_remove_attributes(sensor_inst);
err_remove_callback:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 160/742] HID: sensor-hub: Remove clients before stopping hardware
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (155 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 159/742] HID: sensor: custom: Register enable attribute after misc device Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 161/742] HID: letsketch: skip string descriptors the firmware does not implement Greg Kroah-Hartman
` (569 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Semyon Maryasin, Zhang Lixu,
Srinivas Pandruvada, Jonathan Cameron, Jiri Kosina, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[ Upstream commit 41cb3076a221afba052ae1624ccf62e500706b20 ]
Remove MFD clients before stopping the HID hardware so their close calls
remain valid. Runtime-PM teardown may cancel a pending autosuspend without
running the client suspend callback, leaving hub references after child
removal.
Clients share one HID open while ref_cnt is nonzero. After removing the
children, drain any remaining references and call hid_hw_close() once if
the count is nonzero. Then stop the HID hardware. This avoids both a
leaked open and the underflow caused by an unconditional close.
The pending-request walk runs before hid_hw_stop() disconnects HID-core
children such as hidraw. Skip non-platform children and platform children
without sensor-hub data before checking pending request state.
Fixes: 1df3a401154a ("HID: Delay opening HID device")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-sensor-hub.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 0c4884c5821fd..e9d6eb3b38314 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -10,6 +10,7 @@
#include <linux/slab.h>
#include <linux/mfd/core.h>
#include <linux/list.h>
+#include <linux/platform_device.h>
#include <linux/hid-sensor-ids.h>
#include <linux/hid-sensor-hub.h>
#include "hid-ids.h"
@@ -806,7 +807,14 @@ static int sensor_hub_probe(struct hid_device *hdev,
static int sensor_hub_finalize_pending_fn(struct device *dev, void *data)
{
- struct hid_sensor_hub_device *hsdev = dev->platform_data;
+ struct hid_sensor_hub_device *hsdev;
+
+ if (!dev_is_platform(dev))
+ return 0;
+
+ hsdev = to_platform_device(dev)->dev.platform_data;
+ if (!hsdev)
+ return 0;
if (hsdev->pending.status)
complete(&hsdev->pending.ready);
@@ -820,8 +828,6 @@ static void sensor_hub_remove(struct hid_device *hdev)
unsigned long flags;
hid_dbg(hdev, " hardware removed\n");
- hid_hw_close(hdev);
- hid_hw_stop(hdev);
spin_lock_irqsave(&data->lock, flags);
device_for_each_child(&hdev->dev, NULL,
@@ -829,6 +835,14 @@ static void sensor_hub_remove(struct hid_device *hdev)
spin_unlock_irqrestore(&data->lock, flags);
mfd_remove_devices(&hdev->dev);
+ /* Clients share one HID open; release it if references remain. */
+ mutex_lock(&data->mutex);
+ if (data->ref_cnt) {
+ data->ref_cnt = 0;
+ hid_hw_close(hdev);
+ }
+ mutex_unlock(&data->mutex);
+ hid_hw_stop(hdev);
mutex_destroy(&data->mutex);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 161/742] HID: letsketch: skip string descriptors the firmware does not implement
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (156 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 160/742] HID: sensor-hub: Remove clients before stopping hardware Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 162/742] HID: Intel-thc-hid: Fix REGMAP dependency Greg Kroah-Hartman
` (568 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Eren Çakar, Hans de Goede,
Jiri Kosina, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eren Çakar <hey@erencakar.com>
[ Upstream commit f2f69bbddd34801cbf6af2e89235ca427f3811c5 ]
The Starcom GC-422 is a rebranded LetSketch WP9620C with the same USB
ID (6161:4d15), so it binds to this driver. Its firmware
("Vision_V201_180530") does not implement every string descriptor index
that the raw mode handshake reads. For those indices usb_string() keeps
returning an empty string or -EPIPE, letsketch_get_string() gives up
after its retries, and the probe fails:
letsketch ...: probe with driver letsketch failed with error -5
The tablet then does not work at all.
The handshake only needs the reads to happen, not their contents. Once
the retries are used up, report an index that still reads as empty or
STALLs as missing with -ENOENT, and let the probe skip it. Other errors
still fail the probe as before, and the retries stay in place, so
firmware that only fails a read now and then behaves as it did.
With this change the GC-422 completes the handshake, switches to raw
mode and reports pen position, pressure and the five pad buttons.
The change and this message were written with the help of an AI coding
assistant (Claude Code); I reviewed them and tested the result on the
hardware.
Fixes: 33a5c2793451 ("HID: Add new Letsketch tablet driver")
Signed-off-by: Eren Çakar <hey@erencakar.com>
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-letsketch.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-letsketch.c b/drivers/hid/hid-letsketch.c
index b52e93a91ae54..6a93245b7ac1e 100644
--- a/drivers/hid/hid-letsketch.c
+++ b/drivers/hid/hid-letsketch.c
@@ -213,6 +213,12 @@ static int letsketch_raw_event(struct hid_device *hdev,
* string descriptors. But the firmware is buggy and does not like it if
* we do this too fast. Even if we go slow sometimes the usb_string() call
* fails. Ignore errors and retry it a couple of times if necessary.
+ *
+ * Some firmware revisions (e.g. "Vision_V201_180530", sold as the Starcom
+ * GC-422) do not implement every string descriptor index the handshake
+ * reads. For those indices usb_string() keeps returning an empty string or
+ * -EPIPE (STALL). Report such an index as missing with -ENOENT once the
+ * retries are used up, so that the caller can skip it.
*/
static int letsketch_get_string(struct usb_device *udev, int index, char *buf, int size)
{
@@ -225,9 +231,14 @@ static int letsketch_get_string(struct usb_device *udev, int index, char *buf, i
return 0;
}
+ if (ret == 0 || ret == -EPIPE) {
+ dev_dbg(&udev->dev, "String descriptor %d not implemented\n", index);
+ return -ENOENT;
+ }
+
dev_err(&udev->dev, "Max retries (%d) exceeded reading string descriptor %d\n",
LETSKETCH_GET_STRING_RETRIES, index);
- return ret ? ret : -EIO;
+ return ret;
}
static int letsketch_probe(struct hid_device *hdev, const struct hid_device_id *id)
@@ -256,6 +267,8 @@ static int letsketch_probe(struct hid_device *hdev, const struct hid_device_id *
*/
for (i = LETSKETCH_INFO_STR_IDX_BEGIN; i <= LETSKETCH_INFO_STR_IDX_END; i++) {
ret = letsketch_get_string(udev, i, buf, sizeof(buf));
+ if (ret == -ENOENT)
+ continue;
if (ret)
return ret;
@@ -264,16 +277,16 @@ static int letsketch_probe(struct hid_device *hdev, const struct hid_device_id *
for (i = 1; i <= 250; i++) {
ret = letsketch_get_string(udev, i, buf, sizeof(buf));
- if (ret)
+ if (ret && ret != -ENOENT)
return ret;
}
ret = letsketch_get_string(udev, 0x64, buf, sizeof(buf));
- if (ret)
+ if (ret && ret != -ENOENT)
return ret;
ret = letsketch_get_string(udev, LETSKETCH_INFO_STR_IDX_BEGIN, buf, sizeof(buf));
- if (ret)
+ if (ret && ret != -ENOENT)
return ret;
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 162/742] HID: Intel-thc-hid: Fix REGMAP dependency
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (157 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 161/742] HID: letsketch: skip string descriptors the firmware does not implement Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 163/742] HID: nintendo: release the player ID when LED setup fails Greg Kroah-Hartman
` (567 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Mathias Krause, Even Xu, Jiri Kosina,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Krause <minipli@grsecurity.net>
[ Upstream commit 914d46521de1bdd999fb4c6263172c13b2164218 ]
intel-thc-{dev,dma}.c make use of the regmap API and related data
structures, breaking the build if CONFIG_REGMAP isn't set.
Fix that by forcibly enabling REGMAP when this driver gets build.
Fixes: 1b2d05384c29 ("HID: intel-thc-hid: Add basic THC driver skeleton")
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
Reviewed-by: Even Xu <even.xu@intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/intel-thc-hid/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hid/intel-thc-hid/Kconfig b/drivers/hid/intel-thc-hid/Kconfig
index 9d74e53b8c62b..57a1e51cb512e 100644
--- a/drivers/hid/intel-thc-hid/Kconfig
+++ b/drivers/hid/intel-thc-hid/Kconfig
@@ -8,6 +8,7 @@ config INTEL_THC_HID
tristate "Intel Touch Host Controller"
depends on ACPI
select SGL_ALLOC
+ select REGMAP
help
THC (Touch Host Controller) is the name of the IP block in PCH that
interfaces with Touch Devices (ex: touchscreen, touchpad etc.). It
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 163/742] HID: nintendo: release the player ID when LED setup fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (158 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 162/742] HID: Intel-thc-hid: Fix REGMAP dependency Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 164/742] usb: cdns3: report endpoint reset timeout Greg Kroah-Hartman
` (566 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Changyul Lee, Sang-Hoon Choi,
Jiri Kosina, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <csh0052@gmail.com>
[ Upstream commit 10bc1d627c297097cfdc099377f8a13efdfffd86 ]
joycon_leds_create() allocates a player ID before allocating the LED
names and registering the LEDs. If one of those later steps fails,
nintendo_hid_probe() jumps to err_io_stop and skips the ID cleanup.
The failed probe leaves the allocated ID in nintendo_player_id_allocator.
Use err_ida for this failure, as the power supply and input setup error
paths already do. If the ID allocation itself failed, player_id is
U32_MAX and ida_free() leaves the allocator untouched.
Fixes: 5307de63d71d ("HID: nintendo: use ida for LED player id")
Reported-by: Changyul Lee <lcy8047@gmail.com>
Assisted-by: LLM
Signed-off-by: Sang-Hoon Choi <csh0052@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-nintendo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
index b1fcf3e5767ba..23b836a766f30 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -2784,7 +2784,7 @@ static int nintendo_hid_probe(struct hid_device *hdev,
ret = joycon_leds_create(ctlr);
if (ret) {
hid_err(hdev, "Failed to create leds; ret=%d\n", ret);
- goto err_io_stop;
+ goto err_ida;
}
/* Initialize the battery power supply */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 164/742] usb: cdns3: report endpoint reset timeout
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (159 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 163/742] HID: nintendo: release the player ID when LED setup fails Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 165/742] Bluetooth: MSFT: Record the filter state on Command Disallowed Greg Kroah-Hartman
` (565 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Jiale Yao, Peter Chen, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <yaojiale02@163.com>
[ Upstream commit 8f51823de3c9184fd8b7a4430a030eb071f39dae ]
cdns3_gadget_ep_disable() discards the endpoint reset poll result and
then tests ret, which is still zero. A reset timeout is therefore
neither reported nor returned to the caller.
Store the poll result in ret so the existing diagnostic and return path
expose the timeout.
Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Add: stable@kernel.org
Acked-by: Peter Chen <peter.chen@kernel.org>
Link: https://patch.msgid.link/20261003081152.433499-1-yaojiale02@163.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/cdns3/cdns3-gadget.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 0d272e9c556ca..e79340e1d2471 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -2530,9 +2530,9 @@ static int cdns3_gadget_ep_disable(struct usb_ep *ep)
!(val & EP_STS_DBUSY), 1, 10);
writel(EP_CMD_EPRST, &priv_dev->regs->ep_cmd);
- readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val,
- !(val & (EP_CMD_CSTALL | EP_CMD_EPRST)),
- 1, 1000);
+ ret = readl_poll_timeout_atomic(&priv_dev->regs->ep_cmd, val,
+ !(val & (EP_CMD_CSTALL | EP_CMD_EPRST)),
+ 1, 1000);
if (unlikely(ret))
dev_err(priv_dev->dev, "Timeout: %s resetting failed.\n",
priv_ep->name);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 165/742] Bluetooth: MSFT: Record the filter state on Command Disallowed
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (160 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 164/742] usb: cdns3: report endpoint reset timeout Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 166/742] Bluetooth: MSFT: Only enable the advertisement filter with monitors Greg Kroah-Hartman
` (564 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Thomas de Gruijter,
Luiz Augusto von Dentz, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas de Gruijter <thomasdegruijter@pm.me>
[ Upstream commit 75d6b9d82c35d35dad9fdd783975be1edd32fe2f ]
msft_le_set_advertisement_filter_enable_cb() treats status 0x0C (Command
Disallowed) as success: a controller returns it when the advertisement
filter is already in the requested state, and some controllers start
with the filter enabled.
Since commit 493ea69970e2 ("Bluetooth: Convert MSFT filter HCI cmd to
hci_sync") the callback is passed the return value of
__hci_cmd_sync_status() instead of the HCI status. That function reports
Command Disallowed as -EBUSY, so the 0x0C branch is never taken and
msft->filter_enabled keeps its old value whenever the filter was already
in the requested state. msft_set_filter_enable() also always returns 0,
hiding real errors from its callers.
Pass the error code to the callback, treat -EBUSY as the filter already
being in the requested state, and return real errors from
msft_set_filter_enable(). Nothing reads msft->filter_enabled yet, but
the next patch relies on it to decide when to change the filter state.
The problem was found, with the help of an AI coding assistant
(Claude Code with Claude Opus 5.5).
Fixes: 493ea69970e2 ("Bluetooth: Convert MSFT filter HCI cmd to hci_sync")
Signed-off-by: Thomas de Gruijter <thomasdegruijter@pm.me>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/msft.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index 7a06c2b8974b7..f372df9a98311 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -1142,26 +1142,27 @@ __u64 msft_get_features(struct hci_dev *hdev)
static void msft_le_set_advertisement_filter_enable_cb(struct hci_dev *hdev,
void *user_data,
- u8 status)
+ int err)
{
struct msft_cp_le_set_advertisement_filter_enable *cp = user_data;
struct msft_data *msft = hdev->msft_data;
- /* Error 0x0C would be returned if the filter enabled status is
+ /* Error 0x0C (Command Disallowed), which __hci_cmd_sync_status()
+ * reports as -EBUSY, would be returned if the filter enabled status is
* already set to whatever we were trying to set.
* Although the default state should be disabled, some controller set
* the initial value to enabled. Because there is no way to know the
* actual initial value before sending this command, here we also treat
* error 0x0C as success.
*/
- if (status != 0x00 && status != 0x0C)
+ if (err && err != -EBUSY)
return;
hci_dev_lock(hdev);
msft->filter_enabled = cp->enable;
- if (status == 0x0C)
+ if (err == -EBUSY)
bt_dev_warn(hdev, "MSFT filter_enable is already %s",
cp->enable ? "on" : "off");
@@ -1212,7 +1213,7 @@ int msft_set_filter_enable(struct hci_dev *hdev, bool enable)
msft_le_set_advertisement_filter_enable_cb(hdev, &cp, err);
- return 0;
+ return err == -EBUSY ? 0 : err;
}
bool msft_curve_validity(struct hci_dev *hdev)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 166/742] Bluetooth: MSFT: Only enable the advertisement filter with monitors
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (161 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 165/742] Bluetooth: MSFT: Record the filter state on Command Disallowed Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 167/742] Bluetooth: btintel_pcie: Set only MAC_INIT in btintel_pcie_mac_init() Greg Kroah-Hartman
` (563 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Thomas de Gruijter,
Luiz Augusto von Dentz, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas de Gruijter <thomasdegruijter@pm.me>
[ Upstream commit 4a8f9b7fb4f503f48e2ccfc67caa8b07d303f8a8 ]
msft_do_open() unconditionally enables the MSFT LE advertisement filter
on every power on, whether or not any advertisement monitor is
registered.
On MediaTek MT7922 (USB 0e8d:0616, firmware build 20260724) the
controller then drops every LE advertisement: LE Set Extended Scan
Enable succeeds, but no LE Extended Advertising Report is ever
delivered, so LE discovery and passive scanning find nothing. BR/EDR
inquiry is not affected. Sending LE Set Advertisement Filter Enable with
Enable set to 0x00 restores reporting immediately. The Microsoft HCI
extension specification defines the filter as disabled by default and
does not specify what a controller reports while the filter is enabled
without any monitor condition.
Only enable the filter while at least one monitor is offloaded to the
controller, and update it after a monitor is added or removed and after
the monitors are re-registered on power on and resume. Like the
monitors, the filter state does not survive a power off, so reset the
tracked state in msft_do_close() instead of sending a redundant disable
on power on. A command is only sent when the wanted state differs from
msft->filter_enabled, so this depends on the previous patch keeping
that state accurate when the controller reports the filter as already
being in the requested state.
Fixes: 394566bf1e37 ("Bluetooth: advmon offload MSFT handle filter enablement")
Signed-off-by: Thomas de Gruijter <thomasdegruijter@pm.me>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/bluetooth/msft.c | 46 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 43 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
index f372df9a98311..db7b40ab5fc16 100644
--- a/net/bluetooth/msft.c
+++ b/net/bluetooth/msft.c
@@ -468,6 +468,30 @@ static int msft_remove_monitor_sync(struct hci_dev *hdev,
return err;
}
+/* Keep the advertisement filter enabled only while at least one monitor is
+ * offloaded to the controller. With the filter enabled and no monitors, some
+ * controllers (e.g. MediaTek MT7922) drop every advertisement, which breaks
+ * LE discovery and passive scanning entirely.
+ *
+ * This function requires the caller holds hci_req_sync_lock
+ */
+static void msft_update_filter_enable(struct hci_dev *hdev)
+{
+ struct msft_data *msft = hdev->msft_data;
+ bool enable, update;
+
+ if (!msft)
+ return;
+
+ hci_dev_lock(hdev);
+ enable = !list_empty(&msft->handle_map);
+ update = enable != msft->filter_enabled;
+ hci_dev_unlock(hdev);
+
+ if (update)
+ msft_set_filter_enable(hdev, enable);
+}
+
/* This function requires the caller holds hci_req_sync_lock */
int msft_suspend_sync(struct hci_dev *hdev)
{
@@ -493,6 +517,8 @@ int msft_suspend_sync(struct hci_dev *hdev)
/* All monitors have been removed */
msft->suspending = false;
+ msft_update_filter_enable(hdev);
+
return 0;
}
@@ -633,6 +659,7 @@ int msft_resume_sync(struct hci_dev *hdev)
hci_dev_unlock(hdev);
reregister_monitor(hdev);
+ msft_update_filter_enable(hdev);
return 0;
}
@@ -670,11 +697,11 @@ void msft_do_open(struct hci_dev *hdev)
if (msft_monitor_supported(hdev)) {
msft->resuming = true;
- msft_set_filter_enable(hdev, true);
/* Monitors get removed on power off, so we need to explicitly
* tell the controller to re-monitor.
*/
reregister_monitor(hdev);
+ msft_update_filter_enable(hdev);
}
}
@@ -706,6 +733,11 @@ void msft_do_close(struct hci_dev *hdev)
kfree(handle_data);
}
+ /* The advertisement filter is back to its default, disabled state
+ * after power off as well.
+ */
+ msft->filter_enabled = false;
+
hci_dev_unlock(hdev);
mutex_lock(&msft->filter_lock);
@@ -1173,6 +1205,7 @@ static void msft_le_set_advertisement_filter_enable_cb(struct hci_dev *hdev,
int msft_add_monitor_pattern(struct hci_dev *hdev, struct adv_monitor *monitor)
{
struct msft_data *msft = hdev->msft_data;
+ int err;
if (!msft)
return -EOPNOTSUPP;
@@ -1180,13 +1213,17 @@ int msft_add_monitor_pattern(struct hci_dev *hdev, struct adv_monitor *monitor)
if (msft->resuming || msft->suspending)
return -EBUSY;
- return msft_add_monitor_sync(hdev, monitor);
+ err = msft_add_monitor_sync(hdev, monitor);
+ msft_update_filter_enable(hdev);
+
+ return err;
}
/* This function requires the caller holds hci_req_sync_lock */
int msft_remove_monitor(struct hci_dev *hdev, struct adv_monitor *monitor)
{
struct msft_data *msft = hdev->msft_data;
+ int err;
if (!msft)
return -EOPNOTSUPP;
@@ -1194,7 +1231,10 @@ int msft_remove_monitor(struct hci_dev *hdev, struct adv_monitor *monitor)
if (msft->resuming || msft->suspending)
return -EBUSY;
- return msft_remove_monitor_sync(hdev, monitor);
+ err = msft_remove_monitor_sync(hdev, monitor);
+ msft_update_filter_enable(hdev);
+
+ return err;
}
int msft_set_filter_enable(struct hci_dev *hdev, bool enable)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 167/742] Bluetooth: btintel_pcie: Set only MAC_INIT in btintel_pcie_mac_init()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (162 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 166/742] Bluetooth: MSFT: Only enable the advertisement filter with monitors Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 168/742] Bluetooth: btintel_pcie: Fold MAC_INIT into btintel_pcie_get_mac_access() Greg Kroah-Hartman
` (562 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Paul Menzel, Kiran K,
Luiz Augusto von Dentz, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <kiran.k@intel.com>
[ Upstream commit b535edbf51782cc38acc2e7a6f5ff590ab865c27 ]
btintel_pcie_mac_init() is called prior to reading device memory via
target access. To acquire MAC access, only the MAC_INIT and
MAC_ACCESS_REQ bits in the function control register need to be
programmed.
Currently, btintel_pcie_mac_init() also modifies FUNC_ENA, FUNC_INIT,
BUS_MASTER_DISCON, and SW_RESET, which are not relevant to MAC access
(though doing so had no observed side effects). Leave those bits
untouched and only set MAC_INIT if it is not already set.
Fixes: b9465e6670a2 ("Bluetooth: btintel_pcie: Read hardware exception data")
Assisted-by: Copilot:Gemini 4 Argon
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/bluetooth/btintel_pcie.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 85141532de602..7dcb515cf0f26 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -589,14 +589,11 @@ static void btintel_pcie_mac_init(struct btintel_pcie_data *data)
{
u32 reg;
- /* Set MAC_INIT bit to start primary bootloader */
reg = btintel_pcie_rd_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG);
- reg &= ~(BTINTEL_PCIE_CSR_FUNC_CTRL_FUNC_INIT |
- BTINTEL_PCIE_CSR_FUNC_CTRL_BUS_MASTER_DISCON |
- BTINTEL_PCIE_CSR_FUNC_CTRL_SW_RESET);
- reg |= (BTINTEL_PCIE_CSR_FUNC_CTRL_FUNC_ENA |
- BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT);
- btintel_pcie_wr_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG, reg);
+ if (!(reg & BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT)) {
+ reg |= BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT;
+ btintel_pcie_wr_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG, reg);
+ }
}
static int btintel_pcie_get_mac_access(struct btintel_pcie_data *data)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 168/742] Bluetooth: btintel_pcie: Fold MAC_INIT into btintel_pcie_get_mac_access()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (163 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 167/742] Bluetooth: btintel_pcie: Set only MAC_INIT in btintel_pcie_mac_init() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 169/742] ALSA: pcm: Fix potential ABBA deadlock at snd_pcm_action_nonatomic() Greg Kroah-Hartman
` (561 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Paul Menzel, Kiran K,
Luiz Augusto von Dentz, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <kiran.k@intel.com>
[ Upstream commit 4fe38719e6738feaa90486e36b0790dd5d960a96 ]
MAC_INIT and MAC_ACCESS_REQ are the function control register bits
required to acquire MAC access for target reads. Currently, MAC_INIT is
set separately by btintel_pcie_mac_init(), which is called right before
btintel_pcie_read_device_mem() in btintel_parse_mbox_tlv(),
btintel_pcie_read_hwexp() and btintel_pcie_dump_fwtrigger_event().
btintel_pcie_dump_traces() also reads device memory under MAC access,
but it never called btintel_pcie_mac_init(), so MAC_INIT was missing on
the coredump path.
Fold the MAC_INIT handling into btintel_pcie_get_mac_access() so that
every user of MAC access programs MAC_INIT. Set MAC_INIT and
MAC_ACCESS_REQ with a single register write when either bit is not
already set. Drop btintel_pcie_mac_init() along with its three call
sites. This also fixes btintel_pcie_dump_traces().
Fixes: 07e6bddb54b4 ("Bluetooth: btintel_pcie: Add support for device coredump")
Assisted-by: Copilot:Gemini 4 Argon
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/bluetooth/btintel_pcie.c | 28 ++++++----------------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 7dcb515cf0f26..a1331ced0cc61 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -585,28 +585,18 @@ static int btintel_pcie_reset_bt(struct btintel_pcie_data *data)
return reg == 0 ? 0 : -ENODEV;
}
-static void btintel_pcie_mac_init(struct btintel_pcie_data *data)
-{
- u32 reg;
-
- reg = btintel_pcie_rd_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG);
- if (!(reg & BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT)) {
- reg |= BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT;
- btintel_pcie_wr_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG, reg);
- }
-}
-
static int btintel_pcie_get_mac_access(struct btintel_pcie_data *data)
{
- u32 reg;
+ u32 reg, val;
int retry = 15;
+ const u32 req = BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_INIT |
+ BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ;
reg = btintel_pcie_rd_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG);
- if (!(reg & BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ)) {
- reg |= BTINTEL_PCIE_CSR_FUNC_CTRL_MAC_ACCESS_REQ;
- btintel_pcie_wr_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG, reg);
- }
+ val = reg | req;
+ if (val != reg)
+ btintel_pcie_wr_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG, val);
do {
reg = btintel_pcie_rd_reg32(data, BTINTEL_PCIE_CSR_FUNC_CTRL_REG);
@@ -1034,8 +1024,6 @@ static int btintel_parse_mbox_tlv(struct btintel_pcie_data *data)
if (!buffer)
return -ENOMEM;
- btintel_pcie_mac_init(data);
-
err = btintel_pcie_read_device_mem(data, buffer, tbl_addr,
buffer_len);
if (err)
@@ -1660,8 +1648,6 @@ static void btintel_pcie_read_hwexp(struct btintel_pcie_data *data)
if (!buf)
goto exit_on_error;
- btintel_pcie_mac_init(data);
-
err = btintel_pcie_read_device_mem(data, buf, addr, len);
if (err)
goto exit_on_error;
@@ -1749,8 +1735,6 @@ static int btintel_pcie_dump_fwtrigger_event(struct btintel_pcie_data *data)
if (!buf)
return -ENOMEM;
- btintel_pcie_mac_init(data);
-
err = btintel_pcie_read_device_mem(data, buf, data->debug_evt_addr,
len);
if (err)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 169/742] ALSA: pcm: Fix potential ABBA deadlock at snd_pcm_action_nonatomic()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (164 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 168/742] Bluetooth: btintel_pcie: Fold MAC_INIT into btintel_pcie_get_mac_access() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 170/742] ALSA: usb-audio: Ignore trailing whitespace in quirk_flags Greg Kroah-Hartman
` (560 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, sashiko-bot, Takashi Iwai,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <tiwai@suse.de>
[ Upstream commit bedefcbb8a0827e2758d6fc4a0601756eba7c248 ]
snd_pcm_action_nonatomic() is called for PCM PREPARE and other
operations, and the function takes snd_pcm_buffer_access_lock() of the
given substream (that takes runtime->buffer_mutex internally) at
first, followed by the call of snd_pcm_action_group() that takes
buffer_mutex of other substreams in the same link group again.
Recently Sashiko suggested it may lead to an ABBA deadlock when two
different substreams in the same PCM link call it concurrently:
CPU0 CPU1
---- ----
lock(&A->runtime->buffer_mutex)
lock(&B->runtime->buffer_mutex)
lock(&B->runtime->buffer_mutex)
lock(&A->runtime->buffer_mutex)
This patch tries to address the potential deadlock. Instead of taking
the buffer_mutex of the target substream at first and processing the
rest in the loop, take the whole buffer_mutex for each in the loop.
This assures the order of the nested mutexes -- the linked list itself
is kept intact by the read_rwsem() around snd_pcm_action_nonatomic().
Also, this changes the action in the snd_pcm_action_group() loop from
the direct call of mutex_lock(buffer_mutex) to
snd_pcm_buffer_access_lock(). This prevents the unexpected state
transition or the buffer access during the action, too.
Since the target substream is no longer locked before the loop, the
lockdep subclass for buffer_mutex in the loop now starts from 0, so
that a link group of N substreams uses the subclasses 0..N-1 as
before. The subclass for the stream lock case still starts from 1,
as the caller holds the target stream lock at subclass 0.
Note that this change might have a slight side-effect, though: when
some concurrent operations happen during the PREPARE or RESET, now it
may return -EBUSY. But this can be seen rather as an expected
behavior that was overlooked before the fix.
Fixes: 3c3201f8c7bb ("ALSA: pcm: Fix races among concurrent prepare and hw_params/hw_free calls")
Reported-by: sashiko-bot@kernel.org
Closes: https://lore.kernel.org/sashiko-outbox-221145@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20261119122356.2134523-2-tiwai@suse.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/core/pcm_native.c | 63 +++++++++++++++++++++++++++--------------
1 file changed, 41 insertions(+), 22 deletions(-)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index f64ff3add229a..2bf38ba6950a3 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -741,14 +741,20 @@ static int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm,
/* acquire buffer_mutex; if it's in r/w operation, return -EBUSY, otherwise
* block the further r/w operations
*/
-static int snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime)
+static int __snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime,
+ int depth)
{
if (!atomic_dec_unless_positive(&runtime->buffer_accessing))
return -EBUSY;
- mutex_lock(&runtime->buffer_mutex);
+ mutex_lock_nested(&runtime->buffer_mutex, depth);
return 0; /* keep buffer_mutex, unlocked by below */
}
+static int snd_pcm_buffer_access_lock(struct snd_pcm_runtime *runtime)
+{
+ return __snd_pcm_buffer_access_lock(runtime, 0);
+}
+
/* release buffer_mutex and clear r/w access flag */
static void snd_pcm_buffer_access_unlock(struct snd_pcm_runtime *runtime)
{
@@ -1278,26 +1284,38 @@ struct action_ops {
* this functions is core for handling of linked stream
* Note: the stream state might be changed also on failure
* Note2: call with calling stream lock + link lock
+ *
+ * Locking:
+ * When @stream_lock is false, it takes buffer-access lock for all substreams.
+ * OTOH, when @stream_lock is true, takes substream lock except for the
+ * target substream (that should have taken its lock before calling this).
*/
static int snd_pcm_action_group(const struct action_ops *ops,
struct snd_pcm_substream *substream,
snd_pcm_state_t state,
bool stream_lock)
{
- struct snd_pcm_substream *s = NULL;
- struct snd_pcm_substream *s1;
- int res = 0, depth = 1;
+ struct snd_pcm_substream *s, *s1, *last;
+ int res = 0, depth;
+ /* the caller already holds the target stream lock at depth 0 */
+ depth = stream_lock ? 1 : 0;
+
+ last = NULL;
snd_pcm_group_for_each_entry(s, substream) {
- if (s != substream) {
- if (!stream_lock)
- mutex_lock_nested(&s->runtime->buffer_mutex, depth);
- else if (s->pcm->nonatomic)
+ if (!stream_lock) {
+ res = __snd_pcm_buffer_access_lock(s->runtime, depth);
+ if (res < 0)
+ goto _unlock;
+ depth++;
+ } else if (s != substream) {
+ if (s->pcm->nonatomic)
mutex_lock_nested(&s->self_group.mutex, depth);
else
spin_lock_nested(&s->self_group.lock, depth);
depth++;
}
+ last = s;
res = ops->pre_action(s, state);
if (res < 0)
goto _unlock;
@@ -1312,7 +1330,6 @@ static int snd_pcm_action_group(const struct action_ops *ops,
ops->undo_action(s1, state);
}
}
- s = NULL; /* unlock all */
goto _unlock;
}
}
@@ -1320,17 +1337,19 @@ static int snd_pcm_action_group(const struct action_ops *ops,
ops->post_action(s, state);
}
_unlock:
+ if (!last)
+ return res;
/* unlock streams */
- snd_pcm_group_for_each_entry(s1, substream) {
- if (s1 != substream) {
- if (!stream_lock)
- mutex_unlock(&s1->runtime->buffer_mutex);
- else if (s1->pcm->nonatomic)
- mutex_unlock(&s1->self_group.mutex);
+ snd_pcm_group_for_each_entry(s, substream) {
+ if (!stream_lock) {
+ snd_pcm_buffer_access_unlock(s->runtime);
+ } else if (s != substream) {
+ if (s->pcm->nonatomic)
+ mutex_unlock(&s->self_group.mutex);
else
- spin_unlock(&s1->self_group.lock);
+ spin_unlock(&s->self_group.lock);
}
- if (s1 == s) /* end */
+ if (s == last) /* end */
break;
}
return res;
@@ -1457,13 +1476,13 @@ static int snd_pcm_action_nonatomic(const struct action_ops *ops,
/* Guarantee the group members won't change during non-atomic action */
guard(rwsem_read)(&snd_pcm_link_rwsem);
+ if (snd_pcm_stream_linked(substream))
+ return snd_pcm_action_group(ops, substream, state, false);
+
res = snd_pcm_buffer_access_lock(substream->runtime);
if (res < 0)
return res;
- if (snd_pcm_stream_linked(substream))
- res = snd_pcm_action_group(ops, substream, state, false);
- else
- res = snd_pcm_action_single(ops, substream, state);
+ res = snd_pcm_action_single(ops, substream, state);
snd_pcm_buffer_access_unlock(substream->runtime);
return res;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 170/742] ALSA: usb-audio: Ignore trailing whitespace in quirk_flags
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (165 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 169/742] ALSA: pcm: Fix potential ABBA deadlock at snd_pcm_action_nonatomic() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 171/742] af_packet: avoid waiting for TPACKET_V3 copies at retirement Greg Kroah-Hartman
` (559 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christopher Snowhill, Takashi Iwai,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: chris@kode54.net <chris@kode54.net>
[ Upstream commit 9d30450b6ac8cfc827be3d38f4f5ee86f68687ad ]
Writing a flag name to the quirk_flags module parameter through sysfs
with echo leaves a trailing newline on the string. The parser keeps it
as part of the last flag name, so a valid flag is rejected:
snd_usb_audio: unknown flag SKIP_IFACE_SETUP
while parsing param quirk_flags
Numeric flags are not affected because kstrtou64() accepts a trailing
newline. Strip leading and trailing whitespace before parsing.
Fixes: ffd586126a82 ("ALSA: usb-audio: improve module param quirk_flags")
Assisted-by: AI
Signed-off-by: Christopher Snowhill <chris@kode54.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20261120120356.10909-2-chris@kode54.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/usb/quirks.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index fbda7fa543ab0..263ae8c9851a1 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -2776,7 +2776,7 @@ void snd_usb_init_quirk_flags_parse_string(struct snd_usb_audio *chip,
if (!val)
return;
- for (p = val; p && *p;) {
+ for (p = strim(val); p && *p;) {
/* Each entry consists of VID:PID:flags */
field = strsep(&p, ":");
if (!field)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 171/742] af_packet: avoid waiting for TPACKET_V3 copies at retirement
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (166 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 170/742] ALSA: usb-audio: Ignore trailing whitespace in quirk_flags Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 172/742] ipv6, calipso: fix data-race in calipso_cache_add() bucketsize check Greg Kroah-Hartman
` (558 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jingxuan Xie, Willem de Bruijn,
Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jingxuan Xie <jingxuanxie@deeproute.ai>
[ Upstream commit d7f2d9b6c7d0ff0af7d19d889810d35dfe07da90 ]
TPACKET_V3 retires a full or expired block while holding
sk_receive_queue.lock. prb_retire_current_block() takes
blk_fill_in_prog_lock for write to wait for in-flight skb_copy_bits()
before publishing the block.
On PREEMPT_RT a read lock can be held by a task that has been
preempted or is running on another CPU. The packet path or the
retirement timer then blocks on the write lock while holding
sk_receive_queue.lock, and the receive path resumes only after the
copy completes. This was observed as a receive stall of hundreds of
milliseconds in a PREEMPT_RT deployment; manual inspection found the
same unconditional write_lock() in both the full-block and the timer
retirement paths.
Try to take the write lock without blocking on PREEMPT_RT. If a copy
is still in progress, leave the current block and its metadata
untouched:
- the retirement timer re-arms itself and retries after the configured
interval;
- packet allocation returns NULL, so tpacket_rcv() drops this capture
record and accounts it in tp_drops, while the original packet remains
in the network stack;
- a later packet can retire the block once the copier has finished.
Do not dispatch the next block while the current block is still open.
The existing lock order and completion ordering are preserved, and no
new state or worker is introduced. The trade-off is a higher capture
drop rate while a copy is in progress; original traffic is unaffected.
Non-PREEMPT_RT kernels keep the unconditional write_lock(): there
read_lock() disables preemption, so the writer only waits for the copy
to finish, not for a scheduled-out task to run again.
The stall was reproduced on QEMU arm64 SMP PREEMPT_RT by delaying a
copier after frame reservation: without this change the next sender
blocks until the copier is released, with this change only that
capture record is dropped.
Fixes: 632ca50f2cbd ("af_packet: TPACKET_V3: replace busy-wait loop")
Signed-off-by: Jingxuan Xie <jingxuanxie@deeproute.ai>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20261118135443.24767-1-jingxuanxie@deeproute.ai
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/packet/af_packet.c | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 515a3e8dc38bd..6958ef5771455 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -200,7 +200,7 @@ static void packet_increment_head(struct packet_ring_buffer *buff);
static int prb_curr_blk_in_use(struct tpacket_block_desc *);
static void *prb_dispatch_next_block(struct tpacket_kbdq_core *,
struct packet_sock *);
-static void prb_retire_current_block(struct tpacket_kbdq_core *,
+static bool prb_retire_current_block(struct tpacket_kbdq_core *,
struct packet_sock *, unsigned int status);
static int prb_queue_frozen(struct tpacket_kbdq_core *);
static void prb_open_block(struct tpacket_kbdq_core *,
@@ -669,6 +669,24 @@ static void init_prb_bdqc(struct packet_sock *po,
prb_open_block(p1, pbd);
}
+/*
+ * Wait for an in-flight skb_copy_bits() before retiring the current block.
+ * On PREEMPT_RT the read lock can be held by a task that has been preempted
+ * or is running on another CPU, so do not block while holding
+ * sk_receive_queue.lock; return false and let the caller retry.
+ */
+static bool prb_wait_for_copy_bits(struct tpacket_kbdq_core *pkc)
+{
+ if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
+ if (!write_trylock(&pkc->blk_fill_in_prog_lock))
+ return false;
+ } else {
+ write_lock(&pkc->blk_fill_in_prog_lock);
+ }
+ write_unlock(&pkc->blk_fill_in_prog_lock);
+ return true;
+}
+
/*
* With a 1MB block-size, on a 1Gbps line, it will take
* i) ~8 ms to fill a block + ii) memcpy etc.
@@ -703,9 +721,9 @@ static enum hrtimer_restart prb_retire_rx_blk_timer_expired(struct hrtimer *t)
*
*/
if (BLOCK_NUM_PKTS(pbd)) {
- /* Waiting for skb_copy_bits to finish... */
- write_lock(&pkc->blk_fill_in_prog_lock);
- write_unlock(&pkc->blk_fill_in_prog_lock);
+ /* Retry later if a packet copy is still in progress. */
+ if (!prb_wait_for_copy_bits(pkc))
+ goto refresh_timer;
}
if (!frozen) {
@@ -730,6 +748,7 @@ static enum hrtimer_restart prb_retire_rx_blk_timer_expired(struct hrtimer *t)
}
}
+refresh_timer:
hrtimer_forward_now(&pkc->retire_blk_timer, pkc->interval_ktime);
spin_unlock(&po->sk.sk_receive_queue.lock);
return HRTIMER_RESTART;
@@ -938,7 +957,7 @@ static void *prb_dispatch_next_block(struct tpacket_kbdq_core *pkc,
return (void *)pkc->nxt_offset;
}
-static void prb_retire_current_block(struct tpacket_kbdq_core *pkc,
+static bool prb_retire_current_block(struct tpacket_kbdq_core *pkc,
struct packet_sock *po, unsigned int status)
{
struct tpacket_block_desc *pbd = GET_CURR_PBLOCK_DESC_FROM_CORE(pkc);
@@ -955,13 +974,13 @@ static void prb_retire_current_block(struct tpacket_kbdq_core *pkc,
* the timer-handler already handled this case.
*/
if (!(status & TP_STATUS_BLK_TMO)) {
- /* Waiting for skb_copy_bits to finish... */
- write_lock(&pkc->blk_fill_in_prog_lock);
- write_unlock(&pkc->blk_fill_in_prog_lock);
+ /* Do not wait for copies while holding the queue lock. */
+ if (!prb_wait_for_copy_bits(pkc))
+ return false;
}
prb_close_block(pkc, pbd, po, status);
- return;
}
+ return true;
}
static int prb_curr_blk_in_use(struct tpacket_block_desc *pbd)
@@ -1089,7 +1108,8 @@ static void *__packet_lookup_frame_in_block(struct packet_sock *po,
}
/* Ok, close the current block */
- prb_retire_current_block(pkc, po, 0);
+ if (!prb_retire_current_block(pkc, po, 0))
+ return NULL;
/* Now, try to dispatch the next block */
curr = (char *)prb_dispatch_next_block(pkc, po);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 172/742] ipv6, calipso: fix data-race in calipso_cache_add() bucketsize check
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (167 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 171/742] af_packet: avoid waiting for TPACKET_V3 copies at retirement Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 173/742] net: marvell: prestera: disable port before changing its MAC mode Greg Kroah-Hartman
` (557 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jiayuan Chen, Paul Moore,
Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <jiayuan.chen@linux.dev>
[ Upstream commit 18a7abf1a0b168ea6a50f08562de2f286d6f5a86 ]
Issue found by sashiko when reviewing my data-races patch [1]. This is
not a plain READ_ONCE() annotation like the rest of that series but a
real fix, so it is sent separately.
calipso_cache_add() reads calipso_cache_bucketsize twice: the "<= 0"
guard on entry, then the "size < bucketsize" test after taking the
bucket lock. A writer can flip it to 0 in between:
CPU0 CPU1
calipso_cache_add()
calipso_cache_bucketsize == 10 (> 0)
proc_dointvec()
calipso_cache_bucketsize = 0
spin_lock_bh(&bucket.lock)
size(0) < calipso_cache_bucketsize(0) -> false
-> else branch, but the bucket is empty
On an empty bucket the else branch takes list.prev (the list head
itself), list_del()s it and then list_add()s through the now poisoned
head:
Oops: general protection fault, probably for non-canonical address
0xdead000000000108
RIP: 0010:calipso_cache_add+0x2f0/0x380
Call Trace:
<IRQ>
calipso_cache_add+0x4c/0x70
netlbl_cache_add+0x4a/0xa0
selinux_netlbl_skbuff_getsid+0x1ac/0x280
selinux_skb_peerlbl_sid+0x7d/0x100
selinux_socket_sock_rcv_skb+0x2d3/0x460
security_sock_rcv_skb+0x86/0x150
sk_filter_trim_cap+0x56/0x730
sock_queue_rcv_skb_reason+0x1e/0x80
rawv6_rcv+0x679/0xb20
raw6_local_deliver+0x1f0/0x5b0
ip6_protocol_deliver_rcu+0x215/0x9a0
ip6_input_finish+0xb0/0x1b0
ip6_input+0xa8/0x250
ipv6_rcv+0x14b/0x1c0
__netif_receive_skb_one_core+0x8f/0xe0
__netif_receive_skb+0x23/0xb0
process_backlog+0x27a/0x950
__napi_poll.constprop.0+0x61/0x2c0
net_rx_action+0x372/0x800
handle_softirqs+0x109/0x570
__do_softirq+0x10/0x18
do_softirq.part.0+0x47/0xd0
</IRQ>
<TASK>
__local_bh_enable_ip+0xf0/0x120
__dev_queue_xmit+0x578/0x23f0
neigh_resolve_output+0x278/0x3c0
ip6_finish_output2+0x4b1/0xcb0
ip6_finish_output+0x2b6/0x6b0
ip6_output+0x122/0x400
ip6_local_out+0x61/0xb0
ip6_send_skb+0xa0/0x260
ip6_push_pending_frames+0x2b/0x40
rawv6_sendmsg+0x1b7a/0x2750
inet_sendmsg+0xa1/0xb0
__sys_sendto+0x2fe/0x350
__x64_sys_sendto+0x7f/0xb0
do_syscall_64+0xe1/0x450
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Snapshot the sysctl into a local once and use it for both tests, like
cipso_v4_cache_add() has since commit dd44f04b9214 ("cipso: Fix
data-races around sysctl.").
[1] https://lore.kernel.org/netdev/179428999963.994134.16904544500890053668@kernel.org/
Fixes: 4fee5242bf41 ("calipso: Add a label cache.")
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Acked-by: Paul Moore <paul@paul-moore.com>
Link: https://patch.msgid.link/20261115144508.71543-1-jiayuan.chen@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ipv6/calipso.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
index 4cd0ae9313b32..d7838451db095 100644
--- a/net/ipv6/calipso.c
+++ b/net/ipv6/calipso.c
@@ -263,13 +263,14 @@ static int calipso_cache_check(const unsigned char *key,
static int calipso_cache_add(const unsigned char *calipso_ptr,
const struct netlbl_lsm_secattr *secattr)
{
+ int bkt_size = READ_ONCE(calipso_cache_bucketsize);
int ret_val = -EPERM;
u32 bkt;
struct calipso_map_cache_entry *entry = NULL;
struct calipso_map_cache_entry *old_entry = NULL;
u32 calipso_ptr_len;
- if (!calipso_cache_enabled || calipso_cache_bucketsize <= 0)
+ if (!calipso_cache_enabled || bkt_size <= 0)
return 0;
calipso_ptr_len = calipso_ptr[1];
@@ -289,7 +290,7 @@ static int calipso_cache_add(const unsigned char *calipso_ptr,
bkt = entry->hash & (CALIPSO_CACHE_BUCKETS - 1);
spin_lock_bh(&calipso_cache[bkt].lock);
- if (calipso_cache[bkt].size < calipso_cache_bucketsize) {
+ if (calipso_cache[bkt].size < bkt_size) {
list_add(&entry->list, &calipso_cache[bkt].list);
calipso_cache[bkt].size += 1;
} else {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 173/742] net: marvell: prestera: disable port before changing its MAC mode
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (168 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 172/742] ipv6, calipso: fix data-race in calipso_cache_add() bucketsize check Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 174/742] net/mlx5e: Release FIB event work flows before dropping RTNL Greg Kroah-Hartman
` (556 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Imre Kaloz, Elad Nachman,
Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Kaloz <kaloz@kernel.org>
[ Upstream commit fdb6fcabdbb8247f1647d54fb1b9dc3575d7fcc8 ]
prestera_pcs_config() writes a new mode, speed or inband setting to an
enabled port. The firmware can then report link down until the port is
disabled and enabled again.
Disable the port before such a write. 2500BASE-X and SGMII share one MAC
mode, so SGMII sets its own speed and the speed is compared as well.
Exercising this needs a link partner, so no in-tree test covers it.
Before this patch, the SFP+ ports (S-RJ01 module in sfp-52) on
a Delta TN48M (98DX3265) with firmware 4.1.0 come up in 21 of 30
attempts. 30 out of 30 with the patch.
Fixes: 52323ef75414 ("net: marvell: prestera: add phylink support")
Signed-off-by: Imre Kaloz <kaloz@kernel.org>
Reviewed-by: Elad Nachman <enachman@marvell.com>
Link: https://patch.msgid.link/20261115230812.29644-1-kaloz@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../ethernet/marvell/prestera/prestera_main.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
index a82e7a8029851..3173145573600 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
@@ -307,13 +307,14 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
bool permit_pause_to_mac)
{
struct prestera_port *port = prestera_pcs_to_port(pcs);
- struct prestera_port_mac_config cfg_mac;
+ struct prestera_port_mac_config cfg_mac, old;
int err;
err = prestera_port_cfg_mac_read(port, &cfg_mac);
if (err)
return err;
+ old = cfg_mac;
cfg_mac.admin = true;
cfg_mac.fec = PRESTERA_PORT_FEC_OFF;
cfg_mac.inband = neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED;
@@ -329,6 +330,7 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
cfg_mac.mode = PRESTERA_MAC_MODE_SGMII;
break;
case PHY_INTERFACE_MODE_SGMII:
+ cfg_mac.speed = SPEED_1000;
cfg_mac.mode = PRESTERA_MAC_MODE_SGMII;
break;
case PHY_INTERFACE_MODE_1000BASEX:
@@ -339,6 +341,19 @@ static int prestera_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
break;
}
+ /* Firmware may not report link up after the mode, speed or inband
+ * setting of an enabled port changes until the port is disabled and
+ * re-enabled.
+ */
+ if (old.admin && (old.mode != cfg_mac.mode ||
+ old.speed != cfg_mac.speed ||
+ old.inband != cfg_mac.inband)) {
+ old.admin = false;
+ err = prestera_port_cfg_mac_write(port, &old);
+ if (err)
+ return err;
+ }
+
err = prestera_port_cfg_mac_write(port, &cfg_mac);
if (err)
return err;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 174/742] net/mlx5e: Release FIB event work flows before dropping RTNL
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (169 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 173/742] net: marvell: prestera: disable port before changing its MAC mode Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 175/742] net: clear skb->mac_len in skb_unset_mac_header() Greg Kroah-Hartman
` (555 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Gal Pressman, Jianbo Liu,
Tariq Toukan, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <gal@nvidia.com>
[ Upstream commit bfccb4e44e4725270ccef366078d7b6063920ff3 ]
The FIB event work, neigh update work and the neigh stats work all use
flow->tmp_list to hold the encap flows they work on, while RTNL is what
keeps them from using it at the same time.
mlx5e_tc_fib_event_work() drops RTNL before it is done with its list.
A neigh work can then take the same flows while the FIB work is still
walking them, and the two overwrite each other's list.
Release the flow list before dropping RTNL.
The issue was hit once in our regression testing (OVS connection
tracking with the VXLAN endpoint on a VF, KASAN build):
BUG: KASAN: stack-out-of-bounds in mlx5e_flow_put+0x23/0x80 [mlx5_core]
Write of size 4 at addr ffff8881226d7b20 by task kworker/u40:1/20171
Workqueue: mlx5e mlx5e_tc_fib_event_work [mlx5_core]
Call Trace:
mlx5e_flow_put+0x23/0x80 [mlx5_core]
mlx5e_put_flow_list+0x82/0xe0 [mlx5_core]
mlx5e_tc_fib_event_work+0x704/0x1fb0 [mlx5_core]
process_one_work+0x8df/0x1660
The race was also reproduced with an msleep() inserted between
rtnl_unlock() and mlx5e_put_flow_list() to widen the window, a VXLAN
encap rule whose endpoint IP is on a VF, and route churn on the endpoint
address.
Fixes: 8914add2c9e5 ("net/mlx5e: Handle FIB events to update tunnel endpoint device")
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Jianbo Liu <jianbol@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20261118143653.1915247-1-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
index 8b827201935eb..e6e2535e533a6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c
@@ -1721,9 +1721,9 @@ static void mlx5e_tc_fib_event_work(struct work_struct *work)
r->flags |= MLX5E_ROUTE_ENTRY_VALID;
out:
mutex_unlock(&esw->offloads.encap_tbl_lock);
+ mlx5e_put_flow_list(priv, &flow_list);
rtnl_unlock();
- mlx5e_put_flow_list(priv, &flow_list);
mlx5e_route_put(priv, event_data->r);
dev_put(event_data->ul_dev);
kfree(event_data);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 175/742] net: clear skb->mac_len in skb_unset_mac_header()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (170 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 174/742] net/mlx5e: Release FIB event work flows before dropping RTNL Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 176/742] net/mlx5: HWS, Handle NULL in vport destination action creation Greg Kroah-Hartman
` (554 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Piyus Kedia, Kapil Vaswani,
Eric Dumazet, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <edumazet@kernel.org>
[ Upstream commit 7a505bb0168a132c2a3ab4efff4c6d6474ca3aa1 ]
skb_unset_mac_header() marks the mac header as unset but leaves
skb->mac_len alone, so an skb can end up with no mac header and a
non-zero mac_len. Code that uses mac_len to decide whether a mac
header is present is then misled.
end_dt_vrf_rcv() (SRv6 End.DT4/End.DT6) unsets the mac header of the
decapsulated packet so that the VRF device can rebuild it. The VRF
device only does so when a packet sniffer is attached, so without one
the skb continues up the stack with mac_len == 14. In
xfrm4_remove_tunnel_encap() and xfrm6_remove_tunnel_encap(),
skb_mac_header_rebuild() is a no-op for such an skb, and the following
if (skb->mac_len)
eth_hdr(skb)->h_proto = skb->protocol;
writes two bytes at skb->head + 0xffff + offsetof(struct ethhdr, h_proto):
BUG: KASAN: slab-out-of-bounds in xfrm4_remove_tunnel_encap+0x17d/0x220
Write of size 2 at addr ffff88805f85800b by task syz-executor/10831
xfrm4_remove_tunnel_encap
xfrm_input
xfrm4_esp_rcv
ip_protocol_deliver_rcu
ip_local_deliver_finish
seg6_local_input_core
lwtunnel_input
__netif_receive_skb
netif_receive_skb
tun_rx_batched
tun_get_user
__input_process_payload() in net/xfrm/xfrm_iptfs.c has the same three
lines and reported as a use-after-free rather than an out-of-bounds. The
address written is fixed relative to skb->head, so what it lands in is
whatever the allocator placed sixteen pages past the skb: a live object
gives slab-out-of-bounds, a freed one or a page back on the buddy free
list gives use-after-free, and a different live object gives no report at
all. Clearing mac_len at the source makes the guard false at all three
sites.
Clear mac_len in skb_unset_mac_header() so that all callers leave the
skb in a consistent state, and remove the now redundant assignment in
skb_carve_reset_headers(). The other callers are on egress paths
(__bpf_redirect_neigh(), bpf_lwt_push_ip_encap()) or only reach the
helper when the mac header was already unset (bpf_update_srh_state()),
and do not read mac_len afterwards. vrf_prepare_mac_header(), the rebuild
end_dt_vrf_rcv() unsets the header for, pushes ETH_HLEN and then calls
skb_reset_mac_header() and skb_reset_mac_len(), so it recomputes mac_len
itself and never reads the stale value.
The issue was reported on the list by Piyus Kedia and Kapil Vaswani,
who found it by fuzzing with AI assistance and reproduced the KASAN
splat on v7.4-rc3. Their reproducer was not published.
Fixes: 664d6f86868b ("seg6: add support for the SRv6 End.DT4 behavior")
Reported-by: Piyus Kedia <piyus@iiitd.ac.in>
Reported-by: Kapil Vaswani <kapil@presceralabs.ai>
Closes: https://lore.kernel.org/netdev/20261116174531.2540348-2-piyus@iiitd.ac.in/
Suggested-by: Kapil Vaswani <kapil@presceralabs.ai>
Suggested-by: Piyus Kedia <piyus@iiitd.ac.in>
Tested-by: Piyus Kedia <piyus@iiitd.ac.in>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Piyus Kedia <piyus@iiitd.ac.in>
Link: https://patch.msgid.link/20261117143612.95112-1-piyus@iiitd.ac.in
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/skbuff.h | 1 +
net/core/skbuff.c | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 707082f68f210..5e6ae9598b141 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3177,6 +3177,7 @@ static inline u32 skb_mac_header_len(const struct sk_buff *skb)
static inline void skb_unset_mac_header(struct sk_buff *skb)
{
skb->mac_header = (typeof(skb->mac_header))~0U;
+ skb->mac_len = 0;
}
static inline void skb_reset_mac_header(struct sk_buff *skb)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e685964654df5..1856aecd5558c 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -6905,7 +6905,6 @@ static void skb_carve_reset_headers(struct sk_buff *skb)
skb_unset_mac_header(skb);
skb_unset_transport_header(skb);
skb_reset_network_header(skb);
- skb->mac_len = 0;
/* Inner offsets have no "unset" marker, zero them so that
* skb_inner_network_header_was_set() becomes false and no
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 176/742] net/mlx5: HWS, Handle NULL in vport destination action creation
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (171 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 175/742] net: clear skb->mac_len in skb_unset_mac_header() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 178/742] eth: fbnic: wait on the correct queues in fbnic_queue_stop() Greg Kroah-Hartman
` (553 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Yevgeny Kliteynik, Alex Vesker,
Erez Shitrit, Tariq Toukan, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yevgeny Kliteynik <kliteyn@nvidia.com>
[ Upstream commit c0ec15a586556c11583d8e336c3963c231c379c3 ]
mlx5hws_action_create_dest_vport() can return NULL. If this
happens, xa_insert() will insert a NULL entry into the xarray.
The next mlx5hws_action_create_dest_vport() failure will try to
insert NULL again, but xa_insert() will return -EBUSY, because
we already have NULL entry. In such case the code will go into
error flow of action creation, and eventually will cause NULL
dereference at hws_action_destroy_hws().
The issue was discovered by code inspection.
Fixes: 8e2e08a6d1e0 ("net/mlx5: fs, add support for dest vport HWS action")
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Signed-off-by: Alex Vesker <valex@nvidia.com>
Reviewed-by: Erez Shitrit <erezsh@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20261118173227.1957670-2-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
index 4b29d7183c4ad..ee3a6e011cad7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
@@ -441,6 +441,8 @@ mlx5_fs_get_dest_action_vport(struct mlx5_fs_hws_context *fs_ctx,
dest = mlx5hws_action_create_dest_vport(ctx, vport_num, vhca_id_valid,
dest_attr->vport.vhca_id, flags);
+ if (!dest)
+ return NULL;
err = xa_insert(dests_xa, idx, dest, GFP_KERNEL);
if (err) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 178/742] eth: fbnic: wait on the correct queues in fbnic_queue_stop()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (172 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 176/742] net/mlx5: HWS, Handle NULL in vport destination action creation Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 179/742] eth: fbnic: skip disabled Tx rings when setting the queue NAPI Greg Kroah-Hartman
` (552 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dimitri Daskalakis,
Björn Töpel, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dimitri Daskalakis <daskald@meta.com>
[ Upstream commit 7bc16d84facd37b44ff508d4970bac6636329eb9 ]
fbnic_queue_stop() waits for every queue of the NAPI vector to go idle
before tearing it down, using sub0.q_idx as the queue index. We set
q_idx on submission queues for Tx, and completion queues on Rx, so
this waits on queue 0 for every Rx queue.
For non-combined channels, stopping an Rx queue always stops/wakes
Tx queue 0.
Set the queue id on Tx completion rings so we don't have to distinguish
between ring types to get the correct queue id, and don't stop/wake
disabled rings.
This bug was found by AI and verified on HW.
Reproduced by binding a devmem dmabuf to one Rx queue (netdev bind-rx).
Added a printk to fbnic_wait_queue_idle(), and traced Tx queue stop/wake
with bpftrace.
combined 79, bind rxq 1:
before:
netif_stop_subqueue(1)
fbnic_wait_queue_idle(tx, 1)
fbnic_wait_queue_idle(rx, 0)
netif_wake_subqueue(1)
after:
netif_stop_subqueue(1)
fbnic_wait_queue_idle(tx, 1)
fbnic_wait_queue_idle(rx, 1)
netif_wake_subqueue(1)
rx 34 tx 34, bind rxq 5:
before:
netif_stop_subqueue(0)
fbnic_wait_queue_idle(tx, 0)
fbnic_wait_queue_idle(rx, 0)
netif_wake_subqueue(0)
after:
fbnic_wait_queue_idle(tx, 39)
fbnic_wait_queue_idle(rx, 5)
^ no more stop/wake of Tx queue 0
(tx 39 is the XDP Tx queue of rxq 5's vector,
Rx queues always get an XDP Tx queue)
Fixes: da43127a8edc ("eth: fbnic: support queue ops / zero-copy Rx")
Signed-off-by: Dimitri Daskalakis <daskald@meta.com>
Reviewed-by: Björn Töpel <bjorn@kernel.org>
Link: https://patch.msgid.link/20261117215416.1901246-2-dimitri.daskalakis1@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
index 17d75ec6e3342..4d78d5423d608 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
@@ -1739,7 +1739,7 @@ static int fbnic_alloc_napi_vector(struct fbnic_dev *fbd, struct fbnic_net *fbn,
/* Configure Tx completion queue */
db = &uc_addr[FBNIC_QUEUE(txq_idx) + FBNIC_QUEUE_TCQ_HEAD];
- fbnic_ring_init(&qt->cmpl, db, 0, 0);
+ fbnic_ring_init(&qt->cmpl, db, txq_idx, 0);
/* Update Tx queue index */
txt_count--;
@@ -2974,8 +2974,11 @@ static void __fbnic_nv_restart(struct fbnic_net *fbn,
fbnic_wr32(fbd, FBNIC_INTR_SET(nv->v_idx / 32), BIT(nv->v_idx % 32));
fbnic_wrfl(fbd);
- for (i = 0; i < nv->txt_count; i++)
+ for (i = 0; i < nv->txt_count; i++) {
+ if (nv->qt[i].sub0.flags & FBNIC_RING_F_DISABLED)
+ continue;
netif_wake_subqueue(fbn->netdev, nv->qt[i].sub0.q_idx);
+ }
fbnic_dbg_nv_init(nv);
}
@@ -3016,13 +3019,16 @@ static int fbnic_queue_stop(struct net_device *dev, void *qmem, int idx)
napi_disable_locked(&nv->napi);
fbnic_nv_irq_disable(nv);
- for (i = 0; i < nv->txt_count; i++)
+ for (i = 0; i < nv->txt_count; i++) {
+ if (nv->qt[i].sub0.flags & FBNIC_RING_F_DISABLED)
+ continue;
netif_stop_subqueue(dev, nv->qt[i].sub0.q_idx);
+ }
fbnic_nv_disable(fbn, nv);
for (t = 0; t < nv->txt_count + nv->rxt_count; t++) {
err = fbnic_wait_queue_idle(fbn, t >= nv->txt_count,
- nv->qt[t].sub0.q_idx);
+ nv->qt[t].cmpl.q_idx);
if (err)
goto err_restart;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 179/742] eth: fbnic: skip disabled Tx rings when setting the queue NAPI
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (173 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 178/742] eth: fbnic: wait on the correct queues in fbnic_queue_stop() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 180/742] eth: fbnic: skip freed Tx rings in fbnic_get_ts_stats() Greg Kroah-Hartman
` (551 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dimitri Daskalakis,
Björn Töpel, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dimitri Daskalakis <daskald@meta.com>
[ Upstream commit 561175f45a23527d2853e2b745d40bf963e87dce ]
When Rx and Tx channels are not combined, each Rx vector gets a Tx
triad whose sub0 is disabled with a q_idx of 0. fbnic_set_netif_napi()
and fbnic_reset_netif_napi() don't skip it, so every Rx vector
associates Tx queue 0 with its own NAPI, and the netlink queue info
reports the wrong NAPI for Tx queue 0.
This bug was found by AI and verified on HW.
Reproduced with "ethtool -L eth0 combined 0 rx 34 tx 34", and reading
the NAPI IDs with "ynl --family netdev --dump queue-get":
before: tx 0 napi-id 580, tx 1 napi-id 514, rx 33 napi-id 580
^^^ rx 33's NAPI, not vector 0's
after: tx 0 napi-id 513, tx 1 napi-id 514, rx 33 napi-id 580
Fixes: cf4facfb132a ("eth: fbnic: Add support for XDP queues")
Signed-off-by: Dimitri Daskalakis <daskald@meta.com>
Reviewed-by: Björn Töpel <bjorn@kernel.org>
Link: https://patch.msgid.link/20261117215416.1901246-3-dimitri.daskalakis1@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/meta/fbnic/fbnic_txrx.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
index 4d78d5423d608..e5072085cdb71 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
@@ -2144,6 +2144,9 @@ static void fbnic_set_netif_napi(struct fbnic_napi_vector *nv)
for (i = 0; i < nv->txt_count; i++) {
struct fbnic_q_triad *qt = &nv->qt[i];
+ if (qt->sub0.flags & FBNIC_RING_F_DISABLED)
+ continue;
+
netif_queue_set_napi(nv->napi.dev, qt->sub0.q_idx,
NETDEV_QUEUE_TYPE_TX, &nv->napi);
}
@@ -2165,6 +2168,9 @@ static void fbnic_reset_netif_napi(struct fbnic_napi_vector *nv)
for (i = 0; i < nv->txt_count; i++) {
struct fbnic_q_triad *qt = &nv->qt[i];
+ if (qt->sub0.flags & FBNIC_RING_F_DISABLED)
+ continue;
+
netif_queue_set_napi(nv->napi.dev, qt->sub0.q_idx,
NETDEV_QUEUE_TYPE_TX, NULL);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 180/742] eth: fbnic: skip freed Tx rings in fbnic_get_ts_stats()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (174 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 179/742] eth: fbnic: skip disabled Tx rings when setting the queue NAPI Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 181/742] scsi: ufs-mediatek: Use devm_regulator_get() for the va09 regulator Greg Kroah-Hartman
` (550 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dimitri Daskalakis,
Björn Töpel, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dimitri Daskalakis <daskald@meta.com>
[ Upstream commit 729f807b58f6ed646b81cf7fd7939b2271daa33f ]
fbnic_stop() frees the NAPI vectors, which clears fbn->tx[] while
num_tx_queues is left unchanged. fbnic_get_ts_stats() walks fbn->tx[]
without checking for NULL, so asking for timestamping statistics while
the interface is down dereferences a NULL ring.
This was found by AI and reproduced on HW.
# ip link set dev eth0 down; ethtool -I -T eth0
BUG: kernel NULL pointer dereference, address: 0000000000000050
RIP: 0010:fbnic_get_ts_stats+0x38/0x60
Call Trace:
tsinfo_prepare_data+0x82/0xb0
ethnl_default_doit+0x213/0x470
genl_family_rcv_msg_doit+0xdd/0x110
...
Fixes: 96f358f75d1a ("eth: fbnic: add ethtool timestamping statistics")
Signed-off-by: Dimitri Daskalakis <daskald@meta.com>
Reviewed-by: Björn Töpel <bjorn@kernel.org>
Link: https://patch.msgid.link/20261117215416.1901246-4-dimitri.daskalakis1@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
index cb4258bd20538..ae32b5d55d139 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
@@ -1728,6 +1728,9 @@ static void fbnic_get_ts_stats(struct net_device *netdev,
ts_stats->lost = fbn->tx_stats.twq.ts_lost;
for (i = 0; i < fbn->num_tx_queues; i++) {
ring = fbn->tx[i];
+ if (!ring)
+ continue;
+
do {
start = u64_stats_fetch_begin(&ring->stats.syncp);
ts_packets = ring->stats.twq.ts_packets;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 181/742] scsi: ufs-mediatek: Use devm_regulator_get() for the va09 regulator
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (175 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 180/742] eth: fbnic: skip freed Tx rings in fbnic_get_ts_stats() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 182/742] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails Greg Kroah-Hartman
` (549 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Peter Wang, Xiangwu Lai,
Martin K. Petersen (Oracle), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
[ Upstream commit def1745a6a8bc44b39e8670c737c27fd38b3595c ]
ufs_mtk_init_va09_pwr_ctrl() obtains the va09 regulator with
regulator_get() but the reference is never released with regulator_put(),
neither on driver unbind nor on probe failure. The other regulators handled
by this driver (dvfsrc-vcore) are already obtained with
devm_regulator_get_optional().
Use devm_regulator_get() so that the reference is released automatically
when the UFS device is detached.
This alone is not enough, though: ufs_mtk_init() powers the M-PHY on, which
enables the va09 regulator, and nothing powers it off again on the way out.
The variant operations have no .exit callback and ufshcd_pltfrm_remove()
only resumes the device. The devm release would then hit
WARN_ON(regulator->enable_count) in _regulator_put() and leak the enable
reference.
Balance the use count by adding an .exit callback which powers the M-PHY
off, in the same spirit as the .exit callbacks of ufs-exynos and ufs-qcom.
ufshcd_hba_exit() invokes it both on driver unbind and on ufshcd_init()
failure after the variant init, so the enable count is always balanced by
the time devm releases the regulator. It relies on the state tracking in
ufs_mtk_mphy_power_on() and is a no-op if the M-PHY was never powered on.
Fixes: cf137b3ea49a ("scsi: ufs-mediatek: Support VA09 regulator operations")
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261119071611.117-2-laixiangwu@cmss.chinamobile.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ufs/host/ufs-mediatek.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index ff0a661c14305..1a854a706c9ba 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -692,7 +692,7 @@ static void ufs_mtk_init_va09_pwr_ctrl(struct ufs_hba *hba)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
- host->reg_va09 = regulator_get(hba->dev, "va09");
+ host->reg_va09 = devm_regulator_get(hba->dev, "va09");
if (IS_ERR(host->reg_va09))
dev_info(hba->dev, "failed to get va09");
else
@@ -1331,6 +1331,14 @@ static int ufs_mtk_init(struct ufs_hba *hba)
return err;
}
+static void ufs_mtk_exit(struct ufs_hba *hba)
+{
+ struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+
+ if (host)
+ ufs_mtk_mphy_power_on(hba, false);
+}
+
static int ufs_mtk_negotiate_pwr_mode(struct ufs_hba *hba,
const struct ufs_pa_layer_attr *dev_max_params,
struct ufs_pa_layer_attr *dev_req_params)
@@ -2353,6 +2361,7 @@ static void ufs_mtk_config_scsi_dev(struct scsi_device *sdev)
static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
.name = "mediatek.ufshci",
.init = ufs_mtk_init,
+ .exit = ufs_mtk_exit,
.get_ufs_hci_version = ufs_mtk_get_ufs_hci_version,
.setup_clocks = ufs_mtk_setup_clocks,
.hce_enable_notify = ufs_mtk_hce_enable_notify,
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 182/742] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (176 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 181/742] scsi: ufs-mediatek: Use devm_regulator_get() for the va09 regulator Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 183/742] net: qrtr: ns: keep notifying local servers after a failed send Greg Kroah-Hartman
` (548 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Peter Wang, Xiangwu Lai,
Martin K. Petersen (Oracle), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
[ Upstream commit 71b5da0b45fb83b590f1ec3df5361c7754b0e113 ]
In ufs_mtk_mphy_power_on(), the power-off path tears the M-PHY down in two
steps before regulator_disable() is called: phy_power_off() puts the PHY
PLL and its clocks down, and ufs_mtk_va09_pwr_ctrl() asks the firmware to
drop the VA09 supply. If regulator_disable() then fails, the M-PHY stays
physically off while host->mphy_powered_on is left set, so the next
power-on attempt bails out through the !(on ^ host->mphy_powered_on) check
and never powers the M-PHY back up, leaving the UFS host with an unpowered
PHY (I/O timeouts, controller lockups).
Simply forcing mphy_powered_on to false would trade this for two more
problems. First, the regulator core drops the consumer enable count only
after a successful disable, so the count stays at 1, the next power-on
raises it to 2 and it never returns to zero: va09 is then never physically
disabled and the devm-acquired regulator would hit WARN_ON(enable_count)
again on release. Second, when the power-off fails during
ufs_mtk_suspend(), the error recovery in __ufshcd_wl_suspend() runs
ufshcd_host_reset_and_restore() without powering the M-PHY back on, which
would run against an unpowered PHY. (Both points were raised by the
Sashiko AI review of v2.)
Since the va09 regulator stays enabled when its disable fails, restore the
M-PHY power state instead: power the PHY back on through
ufs_mtk_va09_pwr_ctrl() and phy_power_on() and leave mphy_powered_on set.
The next power-off attempt then retries the full sequence and the enable
count stays balanced.
Found by code inspection while reviewing the va09 error paths of the
driver; the failure has not been observed on real hardware.
Suggested-by: Peter Wang <peter.wang@mediatek.com>
Link: https://lore.kernel.org/r/sashiko-outbox-220026@kernel.org
Fixes: cf137b3ea49a ("scsi: ufs-mediatek: Support VA09 regulator operations")
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/20261119071611.117-3-laixiangwu@cmss.chinamobile.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/ufs/host/ufs-mediatek.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index 1a854a706c9ba..4f5a396dd795f 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -541,6 +541,16 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on)
if (ufs_mtk_is_va09_supported(hba)) {
ufs_mtk_va09_pwr_ctrl(res, 0);
ret = regulator_disable(host->reg_va09);
+ if (ret) {
+ /*
+ * The va09 regulator stays enabled, so
+ * bring the M-PHY back up to keep the
+ * software state in sync with the
+ * hardware.
+ */
+ ufs_mtk_va09_pwr_ctrl(res, 1);
+ phy_power_on(mphy);
+ }
}
}
out:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 183/742] net: qrtr: ns: keep notifying local servers after a failed send
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (177 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 182/742] scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 184/742] riscv: efi: Map runtime MMIO with device attributes Greg Kroah-Hartman
` (547 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Igor Opaniuk, Jakub Kicinski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
[ Upstream commit d5b89d55a322b632e2b465b392a4c1d9d338db9c ]
ctrl_cmd_bye() and ctrl_cmd_del_client() forward the event to every
local server, but stop at the first failed send. Each send goes to a
different socket, so a single server with a full receive queue
(-ENOSPC) hides the event from all servers after it.
Log the failure and carry on. Likewise, keep notifying local lookups
when the NEW_SERVER broadcast fails, which can only happen on -ENOMEM.
Tested on the Arduino UNO Q (QRB2210).
Fixes: 0c2204a4ad71 ("net: qrtr: Migrate nameservice to kernel from userspace")
Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Link: https://patch.msgid.link/20261114-upstream-qrtr-hello-gate-fix_b4-v2-1-2fb62c2853bb@oss.qualcomm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/qrtr/ns.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c
index bcb090ee79d49..8209573221a5f 100644
--- a/net/qrtr/ns.c
+++ b/net/qrtr/ns.c
@@ -374,11 +374,11 @@ static int ctrl_cmd_bye(struct sockaddr_qrtr *from)
msg.msg_name = (struct sockaddr *)&sq;
msg.msg_namelen = sizeof(sq);
+ /* A server that cannot take it must not hide it from the rest */
ret = kernel_sendmsg(qrtr_ns.sock, &msg, &iv, 1, sizeof(pkt));
- if (ret < 0 && ret != -ENODEV) {
- pr_err("failed to send bye cmd\n");
- goto delete_node;
- }
+ if (ret < 0 && ret != -ENODEV)
+ pr_err_ratelimited("failed to send bye cmd to %u:%u: %d\n",
+ srv->node, srv->port, ret);
}
/* Ignore -ENODEV */
@@ -458,11 +458,11 @@ static int ctrl_cmd_del_client(struct sockaddr_qrtr *from,
msg.msg_name = (struct sockaddr *)&sq;
msg.msg_namelen = sizeof(sq);
+ /* A server that cannot take it must not hide it from the rest */
ret = kernel_sendmsg(qrtr_ns.sock, &msg, &iv, 1, sizeof(pkt));
- if (ret < 0 && ret != -ENODEV) {
- pr_err("failed to send del client cmd\n");
- return ret;
- }
+ if (ret < 0 && ret != -ENODEV)
+ pr_err_ratelimited("failed to send del client cmd to %u:%u: %d\n",
+ srv->node, srv->port, ret);
}
return 0;
}
@@ -487,11 +487,10 @@ static int ctrl_cmd_new_server(struct sockaddr_qrtr *from,
return -EINVAL;
if (srv->node == qrtr_ns.local_node) {
+ /* The lookups below still need to hear about the server */
ret = service_announce_new(&qrtr_ns.bcast_sq, srv);
- if (ret < 0) {
+ if (ret < 0)
pr_err("failed to announce new service\n");
- return ret;
- }
}
/* Notify any potential lookups about the new server */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 184/742] riscv: efi: Map runtime MMIO with device attributes
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (178 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 183/742] net: qrtr: ns: keep notifying local servers after a failed send Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 185/742] net: do not run out of frags in alloc_skb_with_frags() Greg Kroah-Hartman
` (546 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Han Gao, Ard Biesheuvel, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Han Gao <gaohan@iscas.ac.cn>
[ Upstream commit 7d49d6e0898680925ea410cbb9d1a6a0e6441462 ]
EFI_MEMORY_MAPPED_IO regions are mapped with PAGE_KERNEL, so device
registers end up mapped as normal memory.
On Milk-V Pioneer, GetTime() reads the clock controller registers and
faults:
Oops - load access fault [#1]
Workqueue: efi_runtime efi_call_rts
status: 0000000200000120 badaddr: 0000007030012000 cause: 0000000000000005
Use PAGE_KERNEL_IO for these regions.
Fixes: b91540d52a08 ("RISC-V: Add EFI runtime services")
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/riscv/kernel/efi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/efi.c b/arch/riscv/kernel/efi.c
index 2d3cc57b45352..11e85d0ebc911 100644
--- a/arch/riscv/kernel/efi.c
+++ b/arch/riscv/kernel/efi.c
@@ -22,7 +22,7 @@ static __init pgprot_t efimem_to_pgprot_map(efi_memory_desc_t *md)
u32 type = md->type;
if (type == EFI_MEMORY_MAPPED_IO)
- return PAGE_KERNEL;
+ return PAGE_KERNEL_IO;
/* R-- */
if ((attr & (EFI_MEMORY_XP | EFI_MEMORY_RO)) ==
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 185/742] net: do not run out of frags in alloc_skb_with_frags()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (179 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 184/742] riscv: efi: Map runtime MMIO with device attributes Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 190/742] tools/bootconfig: Use the registered global tracing parameter names Greg Kroah-Hartman
` (545 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Haishuang Yan, Jakub Kicinski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
[ Upstream commit 5924465bb4e986eae6809c899ddaf38d3897f55d ]
alloc_skb_with_frags() can need more than MAX_SKB_FRAGS frags for a
data_len that passed its size check, and then fails with -ENOBUFS:
- the tail is split into one frag per bit set in its page count;
- after a failed high-order allocation, the order is lowered without
checking that the frags left can hold the rest.
tun hits this with large GSO packets from a vhost-net guest.
Use one larger page for the tail when splitting it would not fit. Only
lower the order if the rest still fits, else retry the same order with
direct reclaim. If that retry fails too, the allocation still fails.
Found while prototyping >64K TSO in a virtio-net guest. Tested with that
guest, page allocation fault injection and the KUnit test in patch 2.
Fixes: 09c2c90705bb ("net: allow alloc_skb_with_frags() to allocate bigger packets")
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261116115620.18151-2-yanhaishuang@cmss.chinamobile.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/skbuff.c | 33 ++++++++++++++++++++++++++++-----
1 file changed, 28 insertions(+), 5 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 1856aecd5558c..d87fe0ad9c103 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -6861,17 +6861,40 @@ struct sk_buff *alloc_skb_with_frags(unsigned long header_len,
while (data_len) {
if (nr_frags == MAX_SKB_FRAGS)
goto failure;
- while (order && PAGE_ALIGN(data_len) < (PAGE_SIZE << order))
- order--;
+ if (order && PAGE_ALIGN(data_len) < (PAGE_SIZE << order)) {
+ unsigned long pages = DIV_ROUND_UP(data_len, PAGE_SIZE);
+
+ /* If splitting the rest into smaller pages would need
+ * more frags than we have left, use one larger page.
+ */
+ if (hweight_long(pages) > MAX_SKB_FRAGS - nr_frags)
+ order = order_base_2(pages);
+ else
+ order = ilog2(pages);
+ }
if (order) {
page = alloc_pages((gfp_mask & ~__GFP_DIRECT_RECLAIM) |
__GFP_COMP |
__GFP_NOWARN,
order);
- if (!page) {
- order--;
- continue;
+ if (unlikely(!page)) {
+ unsigned int shift = PAGE_SHIFT + order - 1;
+
+ /* Can smaller pages hold the rest? */
+ if (((data_len - 1) >> shift) + 1 <=
+ MAX_SKB_FRAGS - nr_frags) {
+ order--;
+ continue;
+ }
+ /* No, retry this order with direct reclaim. */
+ if (!gfpflags_allow_blocking(gfp_mask))
+ goto failure;
+ page = alloc_pages(gfp_mask | __GFP_COMP |
+ __GFP_NOWARN | __GFP_NORETRY,
+ order);
+ if (!page)
+ goto failure;
}
} else {
page = alloc_page(gfp_mask);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 190/742] tools/bootconfig: Use the registered global tracing parameter names
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (180 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 185/742] net: do not run out of frags in alloc_skb_with_frags() Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 191/742] tracing/fprobe: Do not let KASAN check the $stackN read Greg Kroah-Hartman
` (544 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Eduardo Mucelli Rezende Oliveira,
Masami Hiramatsu (Google), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
[ Upstream commit 51934668ca98f1b23c51ce4edea3c61018da342c ]
The boot-time tracing guide lists four kernel.* keys that do not match
the parameters registered by the tracing code. For example,
ftrace2bconf.sh emits kernel.fgraph_max_depth, which bootconfig passes
as fgraph_max_depth on the kernel command line. The function-graph
tracer registers ftrace_graph_max_depth.
Use the registered names in the guide and the exporter. Teach
bconf2ftrace.sh to read those names, with the previous script keys as
fallbacks so existing replay configurations still work.
Link: https://lore.kernel.org/all/fecf6e33d4f7e2ddf031526e7a1abef27e28f754.1795307698.git.edumucelli@gmail.com/
Fixes: 47781947947a ("Documentation: tracing: Add boot-time tracing document")
Fixes: 7e66ef0046cc ("tools/bootconfig: Add a script to generate ftrace shell-command from bootconfig")
Fixes: 2b86062a34a8 ("tools/bootconfig: Add a script to generates bootconfig from ftrace")
Signed-off-by: Eduardo Mucelli Rezende Oliveira <edumucelli@gmail.com>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Documentation/trace/boottime-trace.rst | 8 ++++----
tools/bootconfig/scripts/bconf2ftrace.sh | 21 ++++++++++++++++-----
tools/bootconfig/scripts/ftrace2bconf.sh | 5 +++--
3 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/Documentation/trace/boottime-trace.rst b/Documentation/trace/boottime-trace.rst
index 2c3c1fedb92cc..68fd6152cd0fd 100644
--- a/Documentation/trace/boottime-trace.rst
+++ b/Documentation/trace/boottime-trace.rst
@@ -36,20 +36,20 @@ these options are passed as a part of kernel legacy command line.
kernel.tp_printk
Output trace-event data on printk buffer too.
-kernel.dump_on_oops [= MODE]
+kernel.ftrace_dump_on_oops [= MODE]
Dump ftrace on Oops. If MODE = 1 or omitted, dump trace buffer
on all CPUs. If MODE = 2, dump a buffer on a CPU which kicks Oops.
kernel.traceoff_on_warning
Stop tracing if WARN_ON() occurs.
-kernel.fgraph_max_depth = MAX_DEPTH
+kernel.ftrace_graph_max_depth = MAX_DEPTH
Set MAX_DEPTH to maximum depth of fgraph tracer.
-kernel.fgraph_filters = FILTER[, FILTER2...]
+kernel.ftrace_graph_filter = FILTER[, FILTER2...]
Add fgraph tracing function filters.
-kernel.fgraph_notraces = FILTER[, FILTER2...]
+kernel.ftrace_graph_notrace = FILTER[, FILTER2...]
Add fgraph non-tracing function filters.
diff --git a/tools/bootconfig/scripts/bconf2ftrace.sh b/tools/bootconfig/scripts/bconf2ftrace.sh
index 850c2073433e1..ba29f7411f62a 100755
--- a/tools/bootconfig/scripts/bconf2ftrace.sh
+++ b/tools/bootconfig/scripts/bconf2ftrace.sh
@@ -275,15 +275,26 @@ setup_instance() { # [instance]
}
# ftrace global configs (kernel.*)
-if xbc_has_key "kernel.dump_on_oops"; then
- dump_mode=`xbc_get_val "kernel.dump_on_oops" 1`
+# Prefer the kernel parameter names and accept the old script keys as fallbacks.
+dump_key=kernel.ftrace_dump_on_oops
+xbc_has_key "$dump_key" || dump_key=kernel.dump_on_oops
+if xbc_has_key "$dump_key"; then
+ dump_mode=`xbc_get_val "$dump_key" 1`
[ "$dump_mode" ] && dump_mode=`eval echo $dump_mode` || dump_mode=1
run_cmd "echo \"$dump_mode\" > /proc/sys/kernel/ftrace_dump_on_oops"
fi
-set_value_of kernel.fgraph_max_depth $TRACEFS/max_graph_depth
-set_array_of kernel.fgraph_filters $TRACEFS/set_graph_function
-set_array_of kernel.fgraph_notraces $TRACEFS/set_graph_notrace
+graph_depth_key=kernel.ftrace_graph_max_depth
+xbc_has_key "$graph_depth_key" || graph_depth_key=kernel.fgraph_max_depth
+set_value_of "$graph_depth_key" $TRACEFS/max_graph_depth
+
+graph_filter_key=kernel.ftrace_graph_filter
+xbc_has_key "$graph_filter_key" || graph_filter_key=kernel.fgraph_filters
+set_array_of "$graph_filter_key" $TRACEFS/set_graph_function
+
+graph_notrace_key=kernel.ftrace_graph_notrace
+xbc_has_key "$graph_notrace_key" || graph_notrace_key=kernel.fgraph_notraces
+set_array_of "$graph_notrace_key" $TRACEFS/set_graph_notrace
# Per-instance/per-event configs
if ! xbc_has_branch "ftrace" ; then
diff --git a/tools/bootconfig/scripts/ftrace2bconf.sh b/tools/bootconfig/scripts/ftrace2bconf.sh
index 8eed445c295e3..f62372adbfd59 100755
--- a/tools/bootconfig/scripts/ftrace2bconf.sh
+++ b/tools/bootconfig/scripts/ftrace2bconf.sh
@@ -46,10 +46,11 @@ emit_kv() { # key =|+= value
global_options() {
val=`cat $TRACEFS/max_graph_depth`
- [ $val != 0 ] && emit_kv kernel.fgraph_max_depth = $val
+ [ $val != 0 ] && emit_kv kernel.ftrace_graph_max_depth = $val
if grep -qv "^#" $TRACEFS/set_graph_function $TRACEFS/set_graph_notrace ; then
cat 1>&2 << EOF
-# WARN: kernel.fgraph_filters and kernel.fgraph_notrace are not supported, since the wild card expression was expanded and lost from memory.
+# WARN: Cannot export kernel.ftrace_graph_filter and kernel.ftrace_graph_notrace.
+# Only the expanded function list is available.
EOF
fi
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 191/742] tracing/fprobe: Do not let KASAN check the $stackN read
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (181 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 190/742] tools/bootconfig: Use the registered global tracing parameter names Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 192/742] ttm/pool: Dont leak LRU list on shutdown Greg Kroah-Hartman
` (543 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Yifan Feng,
Masami Hiramatsu (Google), Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yifan Feng <evanfengff@gmail.com>
[ Upstream commit 49276f7c85ba1c140b2605b816a2596d02b36ba4 ]
ftrace_regs_get_kernel_stack_nth() reads the Nth entry of the kernel
stack for the $stackN argument of fprobe and tracepoint probe events.
That entry can be in the redzone of another stack frame, so with
CONFIG_KASAN_STACK every hit of such an event is reported:
# echo 'f:fp_read vfs_read $stack10' >> dynamic_events
# echo 1 > events/fprobes/fp_read/enable
BUG: KASAN: stack-out-of-bounds in process_fetch_insn+0xac9/0xcb0
Use READ_ONCE_NOCHECK(), as arm64 does in regs_get_kernel_stack_nth()
for kprobe events.
Link: https://lore.kernel.org/all/20261118003205.59804-1-evanfengff@gmail.com/
Fixes: 0566cefe73b9 ("tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS")
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/ftrace.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 1c2056a1a68b3..bdb6ee6bc3b9e 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -270,7 +270,7 @@ ftrace_regs_get_kernel_stack_nth(struct ftrace_regs *fregs, unsigned int nth)
stackp = (unsigned long *)ftrace_regs_get_stack_pointer(fregs);
if (((unsigned long)(stackp + nth) & ~(THREAD_SIZE - 1)) ==
((unsigned long)stackp & ~(THREAD_SIZE - 1)))
- return *(stackp + nth);
+ return READ_ONCE_NOCHECK(*(stackp + nth));
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 192/742] ttm/pool: Dont leak LRU list on shutdown
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (182 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 191/742] tracing/fprobe: Do not let KASAN check the $stackN read Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 193/742] bit_spinlock: Fix the __bitlock() macro definition Greg Kroah-Hartman
` (542 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ian Forbes, Christian König,
Dave Airlie, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Forbes <ian.forbes@broadcom.com>
[ Upstream commit 5ffdc8f8361387a1b11553e5c95cd589c67a51f2 ]
TTM pool was changed from a regular list to an lru list in the
referenced fixes commit. list_lru_init allocates state and it needs to
be freed unlike a simple list.
Found using the igt@core_hotunplug and kmemleak.
Fixes: 444e2a19d7fd ("ttm/pool: port to list_lru. (v2)")
Signed-off-by: Ian Forbes <ian.forbes@broadcom.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20260527202018.1223912-1-ian.forbes@broadcom.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/ttm/ttm_pool.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
index 1bf37023fed66..0076594b00683 100644
--- a/drivers/gpu/drm/ttm/ttm_pool.c
+++ b/drivers/gpu/drm/ttm/ttm_pool.c
@@ -421,6 +421,7 @@ static void ttm_pool_type_fini(struct ttm_pool_type *pt)
list_lru_walk(&pt->pages, pool_move_to_dispose_list, &dispose, LONG_MAX);
ttm_pool_dispose_list(pt, &dispose);
+ list_lru_destroy(&pt->pages);
}
/* Return the pool_type to use for the given caching and order */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 193/742] bit_spinlock: Fix the __bitlock() macro definition
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (183 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 192/742] ttm/pool: Dont leak LRU list on shutdown Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 194/742] srcu: Make the srcu_dereference_check() reader lock check conditional Greg Kroah-Hartman
` (541 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Bart Van Assche,
Peter Zijlstra (Intel), Ingo Molnar, Marco Elver, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <bvanassche@acm.org>
[ Upstream commit af1a4ab4bf3bcb969ad5ee9e7fca1d23703adf32 ]
Surround the 'bitnum' argument and the entire __bitlock() macro expansion
with parentheses because 'bitnum' could be an expression that includes an
operator with a lower precedence than the addition operator (e.g. the
exclusive-or operator) and to prevent operator precedence issues in
callers.
Fixes: eb7d96a13bf4 ("bit_spinlock: Support Clang's context analysis")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Marco Elver <elver@google.com>
Link: https://patch.msgid.link/38cdec9322fa710f84c018e0b318894c6234c411.1795043161.git.bvanassche@acm.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/bit_spinlock.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h
index 7869a6e59b6a6..c31d4f4d09ee4 100644
--- a/include/linux/bit_spinlock.h
+++ b/include/linux/bit_spinlock.h
@@ -17,7 +17,7 @@
* static analysis can use.
*/
context_lock_struct(__context_bitlock) { };
-#define __bitlock(bitnum, addr) (struct __context_bitlock *)(bitnum + (addr))
+#define __bitlock(bitnum, addr) ((struct __context_bitlock *)((bitnum) + (addr)))
/*
* bit-based spin_lock()
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 194/742] srcu: Make the srcu_dereference_check() reader lock check conditional
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (184 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 193/742] bit_spinlock: Fix the __bitlock() macro definition Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:00 ` [PATCH 7.3 195/742] tun: complete the zerocopy buffer of packets consumed by XDP Greg Kroah-Hartman
` (540 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Paul E. McKenney, Bart Van Assche,
Peter Zijlstra (Intel), Ingo Molnar, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <bvanassche@acm.org>
[ Upstream commit e2652119b5944e7732ff856ba8057afaa28f5ac8 ]
Users of srcu_dereference_check() must either hold an SRCU reader lock
or satisfy the lockdep condition 'c', e.g. by holding the update-side
lock. However, srcu_dereference_check() calls
__srcu_read_lock_must_hold(), which tells the Clang context analyzer
that the SRCU reader lock must be held. That requirement is too strict
for update-side callers. Hence, only call __srcu_read_lock_must_hold()
from srcu_dereference_check() if 'c' is the compile-time constant 0,
i.e. if there is no update-side protection. Keep the fake RCU acquire
and release around __rcu_dereference_check() and also keep the runtime
lockdep check in srcu_dereference_check().
Use const_true() instead of __builtin_constant_p() to test whether 'c'
is the constant 0. const_true() is based on __is_constexpr(), a
sizeof() trick that the compiler front end always evaluates, so the
Clang context analysis sees an integer constant expression. If 'c' is
a plain variable, function argument or structure member, Clang may
leave __builtin_constant_p(c) for the optimizer to decide. The context
analysis then considers the __srcu_read_lock_must_hold() call
reachable and reports a false positive. Additionally, const_true()
never evaluates a non-constant 'c' at runtime, so the runtime behavior
does not change.
srcu_dereference() passes 0 as 'c' and hence gets the compile-time
check automatically. srcu_dereference_notrace() does not accept a
lockdep condition and hence may only be used by SRCU readers. Since it
passes 1 as 'c', call __srcu_read_lock_must_hold() explicitly from
srcu_dereference_notrace() such that the Clang context analysis keeps
verifying at compile time that its callers hold the SRCU reader lock.
Fixes: f0b7ce22d718 ("srcu: Support Clang's context analysis")
Suggested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Link: https://patch.msgid.link/459250d4f2a6aa38ebab3fb51f6d4a63815bb4a1.1795043161.git.bvanassche@acm.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/srcu.h | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/linux/srcu.h b/include/linux/srcu.h
index 1c221861ba43f..834d075f4ad5d 100644
--- a/include/linux/srcu.h
+++ b/include/linux/srcu.h
@@ -265,6 +265,10 @@ static inline int srcu_read_lock_held(const struct srcu_struct *ssp)
* with __guarded_by(ssp) as it would complicate annotations for writers, we
* choose the following strategy: srcu_dereference_check() calls this helper
* that checks that the passed ssp is held, and then fake-acquires 'RCU'.
+ * srcu_dereference_check() only calls this helper if @c is the compile-time
+ * constant 0 because otherwise its callers may satisfy the condition @c
+ * instead of holding ssp, e.g. on the update side. srcu_dereference_notrace()
+ * passes 1 as @c and hence calls this helper explicitly.
*/
static inline void __srcu_read_lock_must_hold(const struct srcu_struct *ssp) __must_hold_shared(ssp) { }
@@ -282,7 +286,8 @@ static inline void __srcu_read_lock_must_hold(const struct srcu_struct *ssp) __m
*/
#define srcu_dereference_check(p, ssp, c) \
({ \
- __srcu_read_lock_must_hold(ssp); \
+ if (const_true(!(c))) \
+ __srcu_read_lock_must_hold(ssp); \
__acquire_shared_ctx_lock(RCU); \
__auto_type __v = __rcu_dereference_check((p), __UNIQUE_ID(rcu), \
(c) || srcu_read_lock_held(ssp), __rcu); \
@@ -308,7 +313,11 @@ static inline void __srcu_read_lock_must_hold(const struct srcu_struct *ssp) __m
* @ssp: pointer to the srcu_struct, which is used to check that we
* really are in an SRCU read-side critical section.
*/
-#define srcu_dereference_notrace(p, ssp) srcu_dereference_check((p), (ssp), 1)
+#define srcu_dereference_notrace(p, ssp) \
+({ \
+ __srcu_read_lock_must_hold(ssp); \
+ srcu_dereference_check((p), (ssp), 1); \
+})
/**
* srcu_read_lock - register a new reader for an SRCU-protected structure.
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 195/742] tun: complete the zerocopy buffer of packets consumed by XDP
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (185 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 194/742] srcu: Make the srcu_dereference_check() reader lock check conditional Greg Kroah-Hartman
@ 2026-12-04 10:00 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 196/742] tools: gpio-hammer: Accept the maximum number of line offsets Greg Kroah-Hartman
` (539 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:00 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Antonio Quartulli, Paolo Abeni,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antonio Quartulli <antonio@mandelbit.com>
[ Upstream commit 3896ae4adf5ffc11ffd0f7f42c3923e8dc195e75 ]
When vhost-net passes a zerocopy buffer that tun_get_user() does not use,
because the packet spans too many pages, the packet is copied and the
buffer completed. If the copy goes through build_skb() and native XDP
consumes the packet (DROP, TX or REDIRECT), tun_get_user() returns
without completing it: vhost-net never gets the descriptor back, and
closing the vhost-net device then blocks forever.
Complete it in that case too, as copied.
Reproducer: vhost-net with experimental_zcopytx=1 on a tap device with a
native XDP_DROP program; send one 806-byte packet as 40 descriptors, each
in its own page. The descriptor is never returned and close() of the
vhost-net fd does not return. With the patch it is returned.
Tested in an x86-64 VM with the reproducer and the tun kselftest.
Found by the Sashiko AI review bot, as a pre-existing issue while
reviewing an unrelated tun patch, and confirmed with the reproducer.
Link: https://sashiko.dev/#/bug/linux-f9997fb6-303f-41d6-93e2-60c392b1856f
Fixes: 761876c857cb ("tap: XDP support")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Link: https://patch.msgid.link/20261113232843.2338734-1-antonio@mandelbit.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/tun.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 092adb497dc76..970788939ac54 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1871,8 +1871,15 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
err = PTR_ERR_OR_ZERO(skb);
if (err)
goto drop;
- if (!skb)
+ if (!skb) {
+ /* consumed by XDP, after copying */
+ if (msg_control) {
+ struct ubuf_info *uarg = msg_control;
+
+ uarg->ops->complete(NULL, uarg, false);
+ }
return total_len;
+ }
} else {
if (!zerocopy) {
copylen = len;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 196/742] tools: gpio-hammer: Accept the maximum number of line offsets
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (186 preceding siblings ...)
2026-12-04 10:00 ` [PATCH 7.3 195/742] tun: complete the zerocopy buffer of packets consumed by XDP Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 197/742] tools: gpio: Preserve device listing errors in lsgpio Greg Kroah-Hartman
` (538 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zhu Jun, Bartosz Golaszewski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Jun <zhujun2@cmss.chinamobile.com>
[ Upstream commit 0b3f1876d6db7fad0391ce714b315269b0dd5758 ]
The offset count is incremented for every -o option, but the final
check rejects the maximum itself and reports one extra offset. Only
reject counts above the maximum and report the actual count.
Fixes: d1ee7e1f5c91 ("tools: gpio-hammer: Avoid potential overflow in main")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261120061827.98066-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/gpio/gpio-hammer.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/gpio/gpio-hammer.c b/tools/gpio/gpio-hammer.c
index ba0866eb35814..1b33691a68a36 100644
--- a/tools/gpio/gpio-hammer.c
+++ b/tools/gpio/gpio-hammer.c
@@ -159,10 +159,10 @@ int main(int argc, char **argv)
}
}
- if (i >= GPIOHANDLES_MAX) {
+ if (i > GPIOHANDLES_MAX) {
fprintf(stderr,
"Only %d occurrences of '-o' are allowed, %d were found\n",
- GPIOHANDLES_MAX, i + 1);
+ GPIOHANDLES_MAX, i);
return -1;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 197/742] tools: gpio: Preserve device listing errors in lsgpio
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (187 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 196/742] tools: gpio-hammer: Accept the maximum number of line offsets Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 198/742] tools: gpio: Return success after monitoring requested events Greg Kroah-Hartman
` (537 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zhu Jun, Bartosz Golaszewski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Jun <zhujun2@cmss.chinamobile.com>
[ Upstream commit 809117fc28453aafa7164ad45ea853f900974d08 ]
When no chip is selected, lsgpio breaks out of the directory scan on a
list_device() failure, then unconditionally resets ret to zero. A chip
that cannot be opened or queried is therefore reported as success.
Initialize ret to zero before scanning instead, so an empty scan still
succeeds and errors from list_device() reach the caller.
Fixes: 6d591c46bce0 ("tools/gpio: create GPIO tools")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261120062053.98356-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/gpio/lsgpio.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/gpio/lsgpio.c b/tools/gpio/lsgpio.c
index 52a0be45410c9..de2eccc134796 100644
--- a/tools/gpio/lsgpio.c
+++ b/tools/gpio/lsgpio.c
@@ -205,7 +205,7 @@ int main(int argc, char **argv)
goto error_out;
}
- ret = -ENOENT;
+ ret = 0;
while (ent = readdir(dp), ent) {
if (check_prefix(ent->d_name, "gpiochip")) {
ret = list_device(ent->d_name);
@@ -214,7 +214,6 @@ int main(int argc, char **argv)
}
}
- ret = 0;
if (closedir(dp) == -1) {
perror("scanning devices: Failed to close directory");
ret = -errno;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 198/742] tools: gpio: Return success after monitoring requested events
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (188 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 197/742] tools: gpio: Preserve device listing errors in lsgpio Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 199/742] s390/cert_store: Allocate keyring with link restriction Greg Kroah-Hartman
` (536 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zhu Jun, Bartosz Golaszewski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Jun <zhujun2@cmss.chinamobile.com>
[ Upstream commit 1eaf27d99938dd30ea7855174b65e37a2503a349 ]
After reading the requested number of events, monitor_device() returns
the positive byte count left in ret by read(). main() passes this value
through as the exit status, so a successful invocation with -c reports
failure.
Clear ret when the event limit is reached, keeping read failures on their
existing error paths.
Fixes: 97f69747d8b1 ("tools/gpio: add the gpio-event-mon tool")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261120062107.98391-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/gpio/gpio-event-mon.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c
index b70813b0bf8ef..af223e254bc98 100644
--- a/tools/gpio/gpio-event-mon.c
+++ b/tools/gpio/gpio-event-mon.c
@@ -124,8 +124,10 @@ int monitor_device(const char *device_name,
fprintf(stdout, "\n");
i++;
- if (i == loops)
+ if (i == loops) {
+ ret = 0;
break;
+ }
}
exit_line_close:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 199/742] s390/cert_store: Allocate keyring with link restriction
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (189 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 198/742] tools: gpio: Return success after monitoring requested events Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 200/742] s390/cert_store: Only allow the kernel to create cert_store_key keys Greg Kroah-Hartman
` (535 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Anastasia Eskova, Jarkko Sakkinen,
Heiko Carstens, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anastasia Eskova <anastasia.eskova@ibm.com>
[ Upstream commit 602af7b1c19309330a36ffe787336cb95e040ab1 ]
The keyring is linked into the user session keyring on allocation, but
keyring_restrict() is only called after all certificates were added.
Until then a possessor of the keyring can link arbitrary keys into it.
If keyring_restrict() fails, the error is only logged and the keyring
stays writable.
Allocate the keyring with a restriction which rejects all links, create
the certificate keys with KEY_ALLOC_BYPASS_RESTRICTION and drop the late
keyring_restrict() call.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Anastasia Eskova <anastasia.eskova@ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 375035da755cf..523c14796b095 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -409,6 +409,7 @@ static void cleanup_cs_keys(void)
static struct key *create_cs_keyring(void)
{
+ struct key_restriction *restriction;
struct key *cs_keyring, *us_keyring;
/* Cleanup previous cs_keyring and all associated keys if any. */
@@ -416,13 +417,21 @@ static struct key *create_cs_keyring(void)
us_keyring = get_user_session_keyring();
if (IS_ERR(us_keyring))
return NULL;
+ restriction = kzalloc_obj(*restriction);
+ if (!restriction) {
+ key_put(us_keyring);
+ return NULL;
+ }
+ /* Reject all links, the kernel bypasses the restriction. */
+ restriction->check = restrict_link_reject;
cs_keyring = keyring_alloc(CERT_STORE_KEYRING_NAME, GLOBAL_ROOT_UID,
GLOBAL_ROOT_GID, current_cred(),
(KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW | KEY_USR_READ,
KEY_ALLOC_NOT_IN_QUOTA | KEY_ALLOC_SET_KEEP,
- NULL, us_keyring);
+ restriction, us_keyring);
key_put(us_keyring);
if (IS_ERR(cs_keyring)) {
+ kfree(restriction);
pr_dbf_msg("Can't allocate cert_store keyring");
return NULL;
}
@@ -485,7 +494,7 @@ static int create_key_from_vce(struct vcssb *vcssb, struct vce *vce,
desc, (u8 *)vce + vce->vce_hdr.vc_offset,
vce->vce_hdr.vc_length,
(KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW | KEY_USR_READ,
- KEY_ALLOC_NOT_IN_QUOTA);
+ KEY_ALLOC_NOT_IN_QUOTA | KEY_ALLOC_BYPASS_RESTRICTION);
rc = PTR_ERR_OR_ZERO(newkey);
if (rc) {
@@ -653,14 +662,6 @@ static int add_certificates_to_keyring(struct vcssb *vcssb, struct key *keyring)
pr_info("Added %d of %d keys to cert_store keyring", added, count);
- /*
- * Do not allow to link more keys to certificate store keyring after all
- * the VCEs were processed.
- */
- rc = keyring_restrict(make_key_ref(keyring, true), NULL, NULL);
- if (rc)
- pr_dbf_msg("Failed to set restriction to cert_store keyring (%d)", rc);
-
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 200/742] s390/cert_store: Only allow the kernel to create cert_store_key keys
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (190 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 199/742] s390/cert_store: Allocate keyring with link restriction Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 201/742] chardev: GPIO common access methods: repair non-kernel-doc comment Greg Kroah-Hartman
` (534 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Anastasia Eskova, Jarkko Sakkinen,
Heiko Carstens, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anastasia Eskova <anastasia.eskova@ibm.com>
[ Upstream commit 23a04cb4f2bdbfc87fc4e1c15450e7f8cfc9842a ]
Keys of type cert_store_key can be created by any user with add_key() in
any keyring, as the key type has no vet_description() callback. The type
is registered whenever CONFIG_CERT_STORE is enabled, even if the machine
has no DIAG 320 support.
cert_store_key_describe() expects a description in the format created by
get_key_description(), i.e. a 64 byte key name followed by the VCE index
and the certificate store token. If a key with a shorter description is
created, seq_puts() may read beyond the end of the description
allocation. Reading /proc/keys may then disclose adjacent kernel heap
memory to the user space. Also, a consumer which trusts keys by type can
be fooled by keys that were not created from the certificate store.
Add a vet_description() callback which only accepts the task currently
executing refresh_store(), which creates all valid keys of this type.
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Anastasia Eskova <anastasia.eskova@ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/s390/kernel/cert_store.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 523c14796b095..6e042f7028e6f 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -46,6 +46,9 @@
static debug_info_t *cert_store_dbf;
static debug_info_t *cert_store_hexdump;
+/* Task currently running refresh_store(). Written under cs_refresh_lock. */
+static struct task_struct *cs_refresh_task;
+
#define pr_dbf_msg(fmt, ...) \
debug_sprintf_event(cert_store_dbf, 3, fmt "\n", ## __VA_ARGS__)
@@ -148,12 +151,24 @@ static void cert_store_key_describe(const struct key *key, struct seq_file *m)
seq_printf(m, ": %u", key->datalen);
}
+/*
+ * Only the kernel may create keys of this type. Accept the task which runs
+ * refresh_store(), as it cannot execute userspace during the refresh.
+ */
+static int cert_store_key_vet_description(const char *description)
+{
+ if (READ_ONCE(cs_refresh_task) != current)
+ return -EPERM;
+ return 0;
+}
+
/*
* Certificate store key type takes over properties of
* user key but cannot be updated.
*/
static struct key_type key_type_cert_store_key = {
.name = CERT_STORE_KEY_TYPE_NAME,
+ .vet_description = cert_store_key_vet_description,
.preparse = user_preparse,
.free_preparse = user_free_preparse,
.instantiate = generic_key_instantiate,
@@ -768,6 +783,7 @@ static ssize_t refresh_store(struct kobject *kobj, struct kobj_attribute *attr,
if (rc)
return rc;
+ WRITE_ONCE(cs_refresh_task, current);
for (retries = 0; retries < DIAG_MAX_RETRIES; retries++) {
/* Request certificates from certificate store. */
rc = fill_cs_keyring();
@@ -776,6 +792,7 @@ static ssize_t refresh_store(struct kobject *kobj, struct kobj_attribute *attr,
if (rc != -EAGAIN)
break;
}
+ WRITE_ONCE(cs_refresh_task, NULL);
cs_status_val = rc;
mutex_unlock(&cs_refresh_lock);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 201/742] chardev: GPIO common access methods: repair non-kernel-doc comment
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (191 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 200/742] s390/cert_store: Only allow the kernel to create cert_store_key keys Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 202/742] tun: flush uc and mc addresses in TUNSETLINK Greg Kroah-Hartman
` (533 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Randy Dunlap, Jim Cromie,
Linus Walleij, Bartosz Golaszewski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <rdunlap@infradead.org>
[ Upstream commit d4dc896fa2bdfd7d1a78911598a0fa3e3c831d92 ]
Change a "/**" non-kernel-doc comment to a plain C comment "/*"
to avoid 21 warnings like these:
Warning: ./include/linux/nsc_gpio.h:2 Cannot find identifier on line:
nsc_gpio.c
Warning: ./include/linux/nsc_gpio.h:4 Cannot find identifier on line:
National Semiconductor GPIO common access methods.
Warning: ./include/linux/nsc_gpio.h:6 Cannot find identifier on line:
struct nsc_gpio_ops abstracts the low-level access
Fixes: fe3a168a2ce1 ("[PATCH] chardev: GPIO for SCx200 & PC-8736x: add gpio-ops vtable")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Jim Cromie <jim.cromie@gmail.com>
Acked-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20261123004501.1771603-1-rdunlap@infradead.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/nsc_gpio.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/nsc_gpio.h b/include/linux/nsc_gpio.h
index d7a04a6e3783a..342ce97975e8a 100644
--- a/include/linux/nsc_gpio.h
+++ b/include/linux/nsc_gpio.h
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0 */
-/**
+/*
nsc_gpio.c
National Semiconductor GPIO common access methods.
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 202/742] tun: flush uc and mc addresses in TUNSETLINK
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (192 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 201/742] chardev: GPIO common access methods: repair non-kernel-doc comment Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 203/742] btrfs: send: fix missing hole punching during incremental send Greg Kroah-Hartman
` (532 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Willem de Bruijn,
Paolo Abeni, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <edumazet@kernel.org>
[ Upstream commit 5677cf0e039b3cabf79d5aa10facbdb54aea93c6 ]
TUNSETLINK changes dev->type and dev->addr_len, but leaves
dev->uc and dev->mc untouched.
Entries added with the old addr_len stay in lists and rb-trees
that are now searched and dumped with the new addr_len.
When addr_len grows (eg ARPHRD_NONE -> ARPHRD_IP6GRE), dumps like
/proc/net/dev_mcast and RTM_GETMULTICAST expose bytes of
netdev_hw_addr that were never initialized.
bonding and team already call dev_uc_flush() and dev_mc_flush()
between NETDEV_PRE_TYPE_CHANGE and the type change. Do the same
in tun, but only when addr_len changes: if it does not, existing
entries are still valid and there is no reason to drop them.
Fixes: cca8ea3b05c9 ("net: tun: set tun->dev->addr_len during TUNSETLINK processing")
Link: https://lore.kernel.org/netdev/20261116024056.1274402-1-bsdhenrymartin@gmail.com/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20261118125443.1137177-1-edumazet@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/tun.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 970788939ac54..8fa495a2787ae 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -3383,6 +3383,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
(unsigned short)arg == ARPHRD_6LOWPAN) {
ret = -EINVAL;
} else {
+ unsigned char addr_len = tun_get_addr_len(arg);
+
ret = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE,
tun->dev);
ret = notifier_to_errno(ret);
@@ -3391,8 +3393,13 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
"Refused to change device type\n");
break;
}
+ /* Addresses were added with the old dev->addr_len. */
+ if (addr_len != tun->dev->addr_len) {
+ dev_uc_flush(tun->dev);
+ dev_mc_flush(tun->dev);
+ }
tun->dev->type = (int) arg;
- tun->dev->addr_len = tun_get_addr_len(tun->dev->type);
+ tun->dev->addr_len = addr_len;
netif_info(tun, drv, tun->dev, "linktype set to %d\n",
tun->dev->type);
call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE,
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 203/742] btrfs: send: fix missing hole punching during incremental send
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (193 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 202/742] tun: flush uc and mc addresses in TUNSETLINK Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 204/742] btrfs: send: fix invalid access to inline extents in clone_range() Greg Kroah-Hartman
` (531 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tristan Elvers, Qu Wenruo,
Filipe Manana, David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit 398ee8a011d9187e83fc24738b3391e508da91da ]
When using the no-holes feature (enabled by default since btrfs-progs
v5.15) and doing an incremental send, we can miss issuing a hole punching
command when the following conditions happen:
1) A hole is punched in a tail section of a file extent item that happens
to be the last item in a leaf (for example the extent covers the file
range [1M, 3M) and a hole is punched in the range [2M, 3M)). Between
the end of this file extent item's range and the i_size, there are
other file extent items;
2) The next leaf was not modified in the send snapshot, remaining shared
with the parent snapshot.
In this scenario we are unable to detect a hole was punched and never
issue a hole punch command because with no-holes there we don't have an
explicit file extent item to mark a hole.
Fix this by teaching maybe_send_hole() to detect such case.
A test case for fstests will follow soon.
Reported-by: Tristan Elvers <tristanelvers@gmail.com>
Link: https://lore.kernel.org/linux-btrfs/CAFoLKK+aErV4p6ZJPnVeH5SHQ5++0f=8ZgxPWe-E-CkeKBs8PA@mail.gmail.com/
Fixes: 16e7549f045d ("Btrfs: incompatible format change to remove hole extents")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/send.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 65 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 5c59b9abedcd7..d4b498ebfa56a 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -6371,6 +6371,9 @@ static int range_is_hole_in_parent(struct send_ctx *sctx,
static int maybe_send_hole(struct send_ctx *sctx, struct btrfs_path *path,
struct btrfs_key *key)
{
+ BTRFS_PATH_AUTO_FREE(next_path);
+ const u64 cur_extent_end = btrfs_file_extent_end(path);
+ u64 next_offset;
int ret = 0;
if (sctx->cur_ino != key->objectid || !need_send_hole(sctx))
@@ -6397,14 +6400,72 @@ static int maybe_send_hole(struct send_ctx *sctx, struct btrfs_path *path,
ret = range_is_hole_in_parent(sctx,
sctx->cur_inode_last_extent,
key->offset);
+ if (ret == 0)
+ ret = send_hole(sctx, key->offset);
+ else if (ret == 1)
+ ret = 0;
+
if (ret < 0)
return ret;
- else if (ret == 0)
- ret = send_hole(sctx, key->offset);
+ }
+ sctx->cur_inode_last_extent = cur_extent_end;
+
+ /*
+ * If we are the last file extent item in a leaf, we may have had a tail
+ * section that got a hole punched or the extent replaced with a smaller
+ * one, and if there is no change in the next leaf, we must find out if
+ * we have such a hole and punch it.
+ */
+ if (!btrfs_fs_incompat(sctx->send_root->fs_info, NO_HOLES) ||
+ (sctx->cur_inode_size <= cur_extent_end) ||
+ (path->slots[0] != btrfs_header_nritems(path->nodes[0]) - 1))
+ return 0;
+
+ next_path = alloc_path_for_send();
+ if (!next_path)
+ return -ENOMEM;
+
+ ret = btrfs_search_slot(NULL, sctx->send_root, key, next_path, 0, 0);
+ if (ret < 0)
+ return ret;
+ if (WARN_ON(ret != 0))
+ return -EUCLEAN;
+
+ ret = btrfs_next_leaf(sctx->send_root, next_path);
+ if (ret < 0) {
+ return ret;
+ } else if (ret > 0) {
+ /*
+ * No next leaf, must punch hole to i_size and set the path back
+ * to where it was before.
+ */
+ next_offset = sctx->cur_inode_size;
+ } else {
+ struct btrfs_key next_key;
+
+ btrfs_item_key_to_cpu(next_path->nodes[0], &next_key,
+ next_path->slots[0]);
+ if (next_key.objectid != key->objectid ||
+ next_key.type != BTRFS_EXTENT_DATA_KEY)
+ next_offset = sctx->cur_inode_size;
else
- ret = 0;
+ next_offset = next_key.offset;
}
- sctx->cur_inode_last_extent = btrfs_file_extent_end(path);
+
+ if (next_offset == cur_extent_end)
+ return 0;
+
+ btrfs_free_path(next_path);
+ next_path = NULL;
+
+ ret = range_is_hole_in_parent(sctx, sctx->cur_inode_last_extent, next_offset);
+ if (ret == 0)
+ ret = send_hole(sctx, next_offset);
+ else if (ret == 1)
+ ret = 0;
+
+ sctx->cur_inode_last_extent = next_offset;
+
return ret;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 204/742] btrfs: send: fix invalid access to inline extents in clone_range()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (194 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 203/742] btrfs: send: fix missing hole punching during incremental send Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 205/742] btrfs: wait for a grace period before freeing a new device Greg Kroah-Hartman
` (530 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit beed53bd3cb5f0b0a0aad453aa6f0b49060ff2dc ]
We can't access the disk_bytenr and offset fields of a file extent item
that represents an inline extent, since the extent's data starts at the
offset of the disk_bytenr field and the offset field is after that, so
both fields point either to inline data or beyond the file extent item
in case the data is too small.
Fix this by not reading the disk_bytenr and offset fields if we are
dealing with an inline extent.
Link: https://sashiko.dev/#/bug/linux-b662b951-0491-465b-a262-f01a108d8146
Fixes: 040ee6120cb6 ("Btrfs: send, improve clone range")
Fixes: d906d49fc5f4 ("Btrfs: send, fix file corruption due to incorrect cloning operations")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/send.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index d4b498ebfa56a..b7e07e2625ed8 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -5842,7 +5842,7 @@ static int clone_range(struct send_ctx *sctx, struct btrfs_path *dst_path,
u8 type;
u64 ext_len;
u64 clone_len;
- u64 clone_data_offset;
+ u64 clone_data_offset = 0;
bool crossed_src_i_size = false;
if (slot >= btrfs_header_nritems(leaf)) {
@@ -5906,23 +5906,26 @@ static int clone_range(struct send_ctx *sctx, struct btrfs_path *dst_path,
crossed_src_i_size = true;
}
- clone_data_offset = btrfs_file_extent_offset(leaf, ei);
- if (btrfs_file_extent_disk_bytenr(leaf, ei) == disk_byte) {
- clone_root->offset = key.offset;
- if (clone_data_offset < data_offset &&
- clone_data_offset + ext_len > data_offset) {
- u64 extent_offset;
-
- extent_offset = data_offset - clone_data_offset;
- ext_len -= extent_offset;
- clone_data_offset += extent_offset;
- clone_root->offset += extent_offset;
+ if (type != BTRFS_FILE_EXTENT_INLINE) {
+ clone_data_offset = btrfs_file_extent_offset(leaf, ei);
+ if (btrfs_file_extent_disk_bytenr(leaf, ei) == disk_byte) {
+ clone_root->offset = key.offset;
+ if (clone_data_offset < data_offset &&
+ clone_data_offset + ext_len > data_offset) {
+ u64 extent_offset;
+
+ extent_offset = data_offset - clone_data_offset;
+ ext_len -= extent_offset;
+ clone_data_offset += extent_offset;
+ clone_root->offset += extent_offset;
+ }
}
}
clone_len = min_t(u64, ext_len, len);
- if (btrfs_file_extent_disk_bytenr(leaf, ei) == disk_byte &&
+ if (type != BTRFS_FILE_EXTENT_INLINE &&
+ btrfs_file_extent_disk_bytenr(leaf, ei) == disk_byte &&
clone_data_offset == data_offset) {
const u64 src_end = clone_root->offset + clone_len;
const u64 sectorsize = SZ_64K;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 205/742] btrfs: wait for a grace period before freeing a new device
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (195 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 204/742] btrfs: send: fix invalid access to inline extents in clone_range() Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 206/742] btrfs: fix a race between reflink and compressed writes Greg Kroah-Hartman
` (529 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Daniel Vacek, Binbin Deng,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Binbin Deng <18983559317@163.com>
[ Upstream commit 38c94b99f8743a5b9aab864a12ecf9a06d36aeb4 ]
KASAN reports a slab-use-after-free in btrfs_statfs() walking
fs_devices->devices. btrfs_init_new_device() publishes the new device
with list_add_rcu() and can fail afterwards, for example with -ENOSPC
in init_first_rw_device() when a user with CAP_SYS_ADMIN adds a device
that is too small to a seeding filesystem mounted read-only. The error
path removes the entry with list_del_rcu() and frees the object in
btrfs_free_device() without waiting for a grace period, while
btrfs_calc_avail_data_space() and btrfs_ioctl_fs_info() keep reading
the device list under rcu_read_lock().
BUG: KASAN: slab-use-after-free in btrfs_statfs+0x11af/0x14a0
Read of size 8 at addr ffff8880096be858 by task poc/252
Call Trace:
<TASK>
dump_stack_lvl+0x53/0x70
print_report+0xd0/0x630
? __pfx__raw_spin_lock_irqsave+0x10/0x10
? filename_lookup+0x1a9/0x540
? btrfs_statfs+0x11af/0x14a0
kasan_report+0xce/0x100
? btrfs_statfs+0x11af/0x14a0
btrfs_statfs+0x11af/0x14a0
statfs_by_dentry+0x117/0x1e0
user_statfs+0xac/0x130
? __pfx_user_statfs+0x10/0x10
__do_sys_statfs+0x80/0xe0
? __pfx___do_sys_statfs+0x10/0x10
do_syscall_64+0xf9/0x540
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Allocated by task 256:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0x8f/0xa0
__kmalloc_cache_noprof+0x158/0x370
btrfs_alloc_device+0xad/0x3e0
btrfs_init_new_device+0x3e8/0x36e0
btrfs_ioctl+0x150d/0x6c20
__x64_sys_ioctl+0x134/0x1c0
do_syscall_64+0xf9/0x540
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 256:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x43/0x70
kfree+0x121/0x380
btrfs_init_new_device+0x4a0/0x36e0
btrfs_ioctl+0x150d/0x6c20
__x64_sys_ioctl+0x134/0x1c0
do_syscall_64+0xf9/0x540
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Fix by waiting for an RCU grace period after the device is removed
from the list and before it is freed.Place the synchronize_rcu() after
dropping the mutexes and before the `error_trans` label.
Fixes: 1f78160ce1b1 ("Btrfs: using rcu lock in the reader side of devices list")
Reviewed-by: Daniel Vacek <neelx@suse.com>
Signed-off-by: Binbin Deng <18983559317@163.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/volumes.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8eaabca99b4e4..054f7161cb112 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3205,6 +3205,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
btrfs_update_per_profile_avail(fs_info);
mutex_unlock(&fs_info->chunk_mutex);
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
+ synchronize_rcu();
error_trans:
if (trans)
btrfs_end_transaction(trans);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 206/742] btrfs: fix a race between reflink and compressed writes
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (196 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 205/742] btrfs: wait for a grace period before freeing a new device Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 207/742] ASoC: fsl_asrc_m2m: fix out-of-bounds write when draining the output FIFO Greg Kroah-Hartman
` (528 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Breno Leitao, Filipe Manana,
Qu Wenruo, David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <wqu@suse.com>
[ Upstream commit 3b112e8542862db4a92978385e0b9d3fb8064e7a ]
[BUG]
There is a bug report with a reproducer that can lead to transaction
abort. The reproducer requires either large folios or page size larger
than block size and compression:
BTRFS info (device dm-2): use zstd compression, level 3
------------[ cut here ]------------
WARNING: fs/btrfs/extent_map.c:443 at btrfs_unpin_extent_cache+0x12a/0x1a0 [btrfs], CPU#0: kworker/u41:1/1073
CPU: 0 UID: 0 PID: 1073 Comm: kworker/u41:1 Tainted: G W E 7.3.0-rc7-custom+ #111 PREEMPT(full) 181cfbec4e757bdd6c595e90a917484279074a92
Workqueue: btrfs-endio-write btrfs_work_helper [btrfs]
RIP: 0010:btrfs_unpin_extent_cache+0x12a/0x1a0 [btrfs]
Call Trace:
<TASK>
btrfs_finish_one_ordered+0x8f9/0xce0 [btrfs 78b39de6ff5f8aabf4d2477512804f86456deeca]
btrfs_work_helper+0xc5/0x3a0 [btrfs 78b39de6ff5f8aabf4d2477512804f86456deeca]
process_scheduled_works+0x20b/0x480
worker_thread+0x1f7/0x2f0
kthread+0x101/0x130
ret_from_fork+0xd9/0x250
ret_from_fork_asm+0x11/0x20
</TASK>
---[ end trace 0000000000000000 ]---
BTRFS warning (device dm-2): found extent map for inode 257 (root 5) with unexpected start offset 8192 when unpinning extent range [4096, 12288), generation 12
------------[ cut here ]------------
WARNING: fs/btrfs/inode.c:3321 at btrfs_finish_one_ordered+0xc4b/0xce0 [btrfs], CPU#0: kworker/u41:1/1073
CPU: 0 UID: 0 PID: 1073 Comm: kworker/u41:1 Tainted: G W E 7.3.0-rc7-custom+ #111 PREEMPT(full) 181cfbec4e757bdd6c595e90a917484279074a92
Workqueue: btrfs-endio-write btrfs_work_helper [btrfs]
RIP: 0010:btrfs_finish_one_ordered+0xc4b/0xce0 [btrfs]
Call Trace:
<TASK>
btrfs_work_helper+0xc5/0x3a0 [btrfs 78b39de6ff5f8aabf4d2477512804f86456deeca]
process_scheduled_works+0x20b/0x480
worker_thread+0x1f7/0x2f0
kthread+0x101/0x130
ret_from_fork+0xd9/0x250
ret_from_fork_asm+0x11/0x20
</TASK>
---[ end trace 0000000000000000 ]---
BTRFS error (device dm-2 state A): Transaction 12 aborted (-EUCLEAN)
BTRFS: error (device dm-2 state A) in btrfs_finish_one_ordered:3321: errno=-117 Filesystem corrupted
[CAUSE]
There is a race between compressed write and regular write inside the
same folio, that can lead to incorrect PAGECACHE_TAG_DIRTY tag to be
cleared too early.
In this example, we have a large folio containing 8 pages (4K page size,
4K block size), with the following layout:
0 8K 16K 24K 32K
|//////////| |///|
Where [4K, 12K) is dirty, and [20K, 24K) is also dirty.
Writeback | Compression worker
----------------------------------+------------------------------------
writepage_delalloc() |
|- run_delalloc_compressed() |
| | Queueing [4K, 12K) for |
| | compression. |
| \- btrfs_queue_work() |
| | compress_file_range()
| | |- extent_range_clear_dirty_for_io()
| | \- btrfs_folio_clamp_clear_dirty()
| | Now range [4K, 12K) is no longer
| | dirty, but also without an OE.
\- run_delalloc_cow() |
| For the [20K, 24K) |
\- submit_one_sector() |
|- btrfs_folio_clear_dirty()|
| Since [20K, 24K) is the |
| last dirty block, the |
| folio is no longer dirty |
| |
|- btrfs_folio_set_writeback()
Since the folio is no |
longer dirty, the |
PAGECACHE_TAG_DIRTY tag |
is also cleared. |
The above race will lead to a 32K folio that contains [4K, 12K) range
that is still under compression (and should still be counted dirty), but
without an OE.
Then later in the reflink:
Reflink | Compression worker
----------------------------------+------------------------------------
btrfs_clone_files() |
| Which is to replace [4K, 8K) |
| |
|- btrfs_wait_ordered_range() |
| |- btrfs_fdatawrite_range() |
| | Nothing to do, since no |
| | DIRTY tag for the folio |
| | |
| |- filemap_fdatawait_range() |
| | The [20K, 24K) finished, |
| | So no WRITEBACK tag |
| | |
| \- lookup OE |
| No OE is created for range |
| [4K, 12K) |
| |
| | submit_compressed_extents
| | \- submit_one_async_extent
| | \- btrfs_alloc_ordered_extent()
| | OE for [4K, 12K) created, but
| | it's too late.
\- btrfs_clone() |
Replace file extents for range |
[4K, 8K), which will conflict |
with the new compressed range |
[4K, 12K) |
| end_bbio_data_write([4k, 12K))
| \- btrfs_finish_ordered()
|
|
| finish_ordered_fn()
| \- btrfs_finish_one_ordered()
| \- btrfs_unpin_extent_cache()
| em start 8K != 4K
return -EUCLEAN, transaction aborted
[FIX]
Do not clear the folio dirty early during compress_file_range().
The premature clearing is done through extent_range_clear_dirty_for_io(),
so remove the folio dirty clearing completely from it.
And since what's left is only checking the folio write protection,
rename the function to extent_range_check_write_protected() instead, and
slightly clean it up, so it doesn't need to return an int.
Finally since the range is still dirty now, all run_delalloc_cow()
callers pass @pages_dirty = true, we can remove that parameter along other
involved functions.
Fixes: 1d2fbb7f1f9e ("btrfs: allow compression even if the range is not page aligned")
Reported-by: Breno Leitao <leitao@debian.org>
Link: https://lore.kernel.org/linux-btrfs/ause7k_HjzUWT3D-@gmail.com/
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Tested-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/extent_io.c | 5 ++---
fs/btrfs/extent_io.h | 3 +--
fs/btrfs/inode.c | 44 ++++++++++++++------------------------------
3 files changed, 17 insertions(+), 35 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index fe4c87dc61ba8..3fa57c4165b95 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2888,8 +2888,7 @@ static int extent_write_cache_pages(struct address_space *mapping,
* locked.
*/
void extent_write_locked_range(struct inode *inode, const struct folio *locked_folio,
- u64 start, u64 end, struct writeback_control *wbc,
- bool pages_dirty)
+ u64 start, u64 end, struct writeback_control *wbc)
{
bool found_error = false;
int ret = 0;
@@ -2932,7 +2931,7 @@ void extent_write_locked_range(struct inode *inode, const struct folio *locked_f
cur_len = cur_end + 1 - cur;
ASSERT(folio_test_locked(folio));
- if (pages_dirty && folio != locked_folio)
+ if (folio != locked_folio)
ASSERT(folio_test_dirty(folio));
/*
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index d8dd2ae9ff9a8..c55b37cb24b70 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -280,8 +280,7 @@ void btrfs_check_folio_write_protected(struct folio *folio);
static inline void btrfs_check_folio_write_protected(struct folio *folio) { }
#endif
void extent_write_locked_range(struct inode *inode, const struct folio *locked_folio,
- u64 start, u64 end, struct writeback_control *wbc,
- bool pages_dirty);
+ u64 start, u64 end, struct writeback_control *wbc);
int btrfs_writepages(struct address_space *mapping, struct writeback_control *wbc);
int btree_writepages(struct address_space *mapping, struct writeback_control *wbc);
void btrfs_btree_wait_writeback_range(struct btrfs_fs_info *fs_info, u64 start, u64 end);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 019e25f34416a..e73f3197e426c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -120,8 +120,7 @@ static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback);
static noinline int run_delalloc_cow(struct btrfs_inode *inode,
struct folio *locked_folio, u64 start,
- u64 end, struct writeback_control *wbc,
- bool pages_dirty);
+ u64 end, struct writeback_control *wbc);
static int data_reloc_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
u64 root, void *warn_ctx)
@@ -773,33 +772,29 @@ static inline void inode_should_defrag(struct btrfs_inode *inode,
btrfs_add_inode_defrag(inode, small_write);
}
-static int extent_range_clear_dirty_for_io(struct btrfs_inode *inode, u64 start, u64 end)
+static void extent_range_check_write_protected(struct btrfs_inode *inode, u64 start, u64 end)
{
pgoff_t index = start >> PAGE_SHIFT;
const pgoff_t end_index = end >> PAGE_SHIFT;
struct folio *folio;
- int ret = 0;
+
+ if (!IS_ENABLED(CONFIG_BTRFS_DEBUG))
+ return;
while (index <= end_index) {
folio = filemap_get_folio(inode->vfs_inode.i_mapping, index);
+ /* Compression should have all involved folios still locked. */
if (IS_ERR(folio)) {
- if (!ret)
- ret = PTR_ERR(folio);
+ DEBUG_WARN(
+"missing a folio inside the compression range, index %lu start %llu end %llu",
+ index, start, end);
index++;
continue;
}
- /*
- * We are about to compress the folio, so it must not be mmap
- * writeable or we could corrupt the data as we attempt to
- * compress it.
- */
btrfs_check_folio_write_protected(folio);
- btrfs_folio_clamp_clear_dirty(inode->root->fs_info, folio, start,
- end + 1 - start);
index = folio_next_index(folio);
folio_put(folio);
}
- return ret;
}
static struct folio *compressed_bio_last_folio(struct compressed_bio *cb)
@@ -886,16 +881,7 @@ static void compress_file_range(struct btrfs_work *work)
inode_should_defrag(inode, start, end, end - start + 1, SZ_16K);
- ret = extent_range_clear_dirty_for_io(inode, start, end);
-
- /*
- * All the folios should have been locked thus no failure.
- *
- * And even if some folios are missing, btrfs_compress_bio()
- * would handle them correctly, so here just do an ASSERT() check for
- * early logic errors.
- */
- ASSERT(ret == 0);
+ extent_range_check_write_protected(inode, start, end);
/*
* We need to save i_size before now because it could change in between
@@ -1011,8 +997,7 @@ static void submit_uncompressed_range(struct btrfs_inode *inode,
};
wbc_attach_fdatawrite_inode(&wbc, &inode->vfs_inode);
- ret = run_delalloc_cow(inode, locked_folio, start, end,
- &wbc, false);
+ ret = run_delalloc_cow(inode, locked_folio, start, end, &wbc);
wbc_detach_inode(&wbc);
if (ret < 0) {
if (locked_folio)
@@ -1657,8 +1642,7 @@ static bool run_delalloc_compressed(struct btrfs_inode *inode,
*/
static noinline int run_delalloc_cow(struct btrfs_inode *inode,
struct folio *locked_folio, u64 start,
- u64 end, struct writeback_control *wbc,
- bool pages_dirty)
+ u64 end, struct writeback_control *wbc)
{
u64 done_offset = end;
int ret;
@@ -1669,7 +1653,7 @@ static noinline int run_delalloc_cow(struct btrfs_inode *inode,
if (ret)
return ret;
extent_write_locked_range(&inode->vfs_inode, locked_folio,
- start, done_offset, wbc, pages_dirty);
+ start, done_offset, wbc);
start = done_offset + 1;
}
@@ -2451,7 +2435,7 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct folio *locked_fol
return 1;
if (zoned)
- return run_delalloc_cow(inode, locked_folio, start, end, wbc, true);
+ return run_delalloc_cow(inode, locked_folio, start, end, wbc);
else
return cow_file_range(inode, locked_folio, start, end, NULL, 0);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 207/742] ASoC: fsl_asrc_m2m: fix out-of-bounds write when draining the output FIFO
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (197 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 206/742] btrfs: fix a race between reflink and compressed writes Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 208/742] ASoC: fsl_asrc: fix pair ownership on repeated or failed hw_params Greg Kroah-Hartman
` (527 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stefan Ghetu, Shengjiu Wang,
Mark Brown, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Ghetu <stefan.ghetu@nxp.com>
[ Upstream commit 6b3f779dcac4ea16e232019b68650395ad55f5a2 ]
asrc_read_last_fifo() checks the FIFO fill level, a number of frames,
against a length in bytes, and ignores the frames already drained by
previous iterations of its retry loop. With an output length close to
the 512 KiB buffer size, which userspace controls through the task input
size and formats, the drain writes past the end of the output buffer:
312 bytes for 10 channels of S24_LE with 8 frames left in the FIFO.
Check the space needed by all drained frames in bytes.
Fixes: 24a01710f627 ("ASoC: fsl_asrc_m2m: Add memory to memory function")
Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://patch.msgid.link/20261116093751.138455-2-stefan.ghetu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/fsl/fsl_asrc_m2m.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc_m2m.c b/sound/soc/fsl/fsl_asrc_m2m.c
index a90a1c8ed34d4..afb098f1ac33f 100644
--- a/sound/soc/fsl/fsl_asrc_m2m.c
+++ b/sound/soc/fsl/fsl_asrc_m2m.c
@@ -53,21 +53,27 @@ static void asrc_read_last_fifo(struct fsl_asrc_pair *pair, void *dma_vaddr, u32
{
struct fsl_asrc *asrc = pair->asrc;
enum asrc_pair_index index = pair->index;
- u32 i, reg, size, t_size = 0, width;
+ u32 i, reg, size, t_size = 0, width, sample_bytes, frame_bytes;
u32 *reg32 = NULL;
u16 *reg16 = NULL;
u8 *reg24 = NULL;
width = snd_pcm_format_physical_width(pair->sample_format[OUT]);
- if (width == 32)
+ if (width == 32) {
reg32 = dma_vaddr + *length;
- else if (width == 16)
+ sample_bytes = 4;
+ } else if (width == 16) {
reg16 = dma_vaddr + *length;
- else
+ sample_bytes = 2;
+ } else {
reg24 = dma_vaddr + *length;
+ sample_bytes = 3;
+ }
+
+ frame_bytes = pair->channels * sample_bytes;
retry:
size = asrc->get_output_fifo_size(pair);
- if (size + *length > ASRC_M2M_BUFFER_SIZE)
+ if (*length + (t_size + size) * frame_bytes > ASRC_M2M_BUFFER_SIZE)
goto end;
for (i = 0; i < size * pair->channels; i++) {
@@ -89,12 +95,7 @@ static void asrc_read_last_fifo(struct fsl_asrc_pair *pair, void *dma_vaddr, u32
goto retry;
end:
/* Update payload length */
- if (reg32)
- *length += t_size * pair->channels * 4;
- else if (reg16)
- *length += t_size * pair->channels * 2;
- else
- *length += t_size * pair->channels * 3;
+ *length += t_size * frame_bytes;
}
/* config dma channel */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 208/742] ASoC: fsl_asrc: fix pair ownership on repeated or failed hw_params
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (198 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 207/742] ASoC: fsl_asrc_m2m: fix out-of-bounds write when draining the output FIFO Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 209/742] ASoC: fsl_asrc: Replace dma_request_slave_channel() by dma_request_chan() Greg Kroah-Hartman
` (526 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stefan Ghetu, Shengjiu Wang,
Mark Brown, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Ghetu <stefan.ghetu@nxp.com>
[ Upstream commit fbeac9352de6584bd5eb7c23d2f224339772c992 ]
hw_params() can be called again without hw_free() in between, and
hw_free() is also called after a failed hw_params().
fsl_asrc_request_pair() always takes a new pair, so a second hw_params()
leaves the stream in two asrc->pair[] entries. Only one is released, and
after close the other points to freed memory, which is dereferenced by
fsl_asrc_isr() and fsl_asrc_m2m_suspend(). After a failed hw_params(),
fsl_asrc_release_pair() releases a stale index that may belong to
another running stream.
Keep the owned pair and only update its channels when it is requested
again, and ignore a pair the stream does not own on release.
Fixes: 3117bb3109dc ("ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers")
Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://patch.msgid.link/20261116093751.138455-3-stefan.ghetu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/fsl/fsl_asrc.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index d80afe1bf4be3..c40c26b5cedc3 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -216,6 +216,8 @@ static void fsl_asrc_sel_proc(int inrate, int outrate,
* It assigns pair by the order of A->C->B because allocation of pair B,
* within range [ANCA, ANCA+ANCB-1], depends on the channels of pair A
* while pair A and pair C are comparatively independent.
+ *
+ * If @pair already owns a pair, it is kept and only its channels are updated.
*/
static int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair)
{
@@ -226,6 +228,19 @@ static int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair)
guard(spinlock_irqsave)(&asrc->lock);
+ if (asrc->pair[pair->index] == pair) {
+ if (asrc->channel_avail + pair->channels < channels) {
+ dev_err(dev, "can't afford required channels: %d\n", channels);
+ return -EINVAL;
+ }
+
+ asrc->channel_avail += pair->channels;
+ asrc->channel_avail -= channels;
+ pair->channels = channels;
+
+ return 0;
+ }
+
for (i = ASRC_PAIR_A; i < ASRC_PAIR_MAX_NUM; i++) {
if (asrc->pair[i] != NULL)
continue;
@@ -257,12 +272,19 @@ static int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair)
* @pair: pair to release
*
* It clears the resource from asrc and releases the occupied channels.
+ * Nothing is done if @pair does not own a pair.
*/
static void fsl_asrc_release_pair(struct fsl_asrc_pair *pair)
{
struct fsl_asrc *asrc = pair->asrc;
enum asrc_pair_index index = pair->index;
+ /* Only the owner clears its entry, so it cannot change after this check */
+ scoped_guard(spinlock_irqsave, &asrc->lock) {
+ if (asrc->pair[index] != pair)
+ return;
+ }
+
/* Make sure the pair is disabled */
regmap_update_bits(asrc->regmap, REG_ASRCTR,
ASRCTR_ASRCEi_MASK(index), 0);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 209/742] ASoC: fsl_asrc: Replace dma_request_slave_channel() by dma_request_chan()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (199 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 208/742] ASoC: fsl_asrc: fix pair ownership on repeated or failed hw_params Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 210/742] ASoC: fsl_asrc_dma: release DMA channels on repeated hw_params Greg Kroah-Hartman
` (525 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Andy Shevchenko, Frank Li,
Mark Brown, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
[ Upstream commit b045248399d0cd8b6188ce1a5b9d722709ad3ddc ]
Replace dma_request_slave_channel() by dma_request_chan() as suggested
since the former is deprecated. With this, propagate all possible errors
to the caller.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20260918113727.1898998-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Stable-dep-of: 0d02516a94b4 ("ASoC: fsl_asrc_dma: release DMA channels on repeated hw_params")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/fsl/fsl_asrc.c | 2 +-
sound/soc/fsl/fsl_asrc_dma.c | 19 +++++++++++--------
sound/soc/fsl/fsl_asrc_m2m.c | 15 +++++++++------
sound/soc/fsl/fsl_easrc.c | 2 +-
4 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index c40c26b5cedc3..231e6a85ca910 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -660,7 +660,7 @@ static struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair,
sprintf(name, "%cx%c", dir == IN ? 'r' : 't', index + 'a');
- return dma_request_slave_channel(&asrc->pdev->dev, name);
+ return dma_request_chan(&asrc->pdev->dev, name);
}
static int fsl_asrc_dai_startup(struct snd_pcm_substream *substream,
diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
index 64f2b06122743..0aa5db8973d6f 100644
--- a/sound/soc/fsl/fsl_asrc_dma.c
+++ b/sound/soc/fsl/fsl_asrc_dma.c
@@ -136,8 +136,8 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
struct snd_dmaengine_dai_dma_data *dma_params_be = NULL;
struct snd_pcm_runtime *runtime = substream->runtime;
struct fsl_asrc_pair *pair = runtime->private_data;
- struct dma_chan *tmp_chan = NULL, *be_chan = NULL;
struct snd_soc_component *component_be = NULL;
+ struct dma_chan *tmp_chan, *be_chan = NULL;
struct fsl_asrc *asrc = pair->asrc;
struct dma_slave_config config_fe = {}, config_be = {};
struct sdma_peripheral_config audio_config;
@@ -190,11 +190,12 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
dma_params_fe->addr = asrc->paddr + asrc->get_fifo_addr(!dir, index);
dma_params_fe->maxburst = dma_params_be->maxburst;
- pair->dma_chan[!dir] = asrc->get_dma_channel(pair, !dir);
- if (!pair->dma_chan[!dir]) {
+ tmp_chan = asrc->get_dma_channel(pair, !dir);
+ if (IS_ERR(tmp_chan)) {
dev_err(dev, "failed to request DMA channel\n");
- return -EINVAL;
+ return PTR_ERR(tmp_chan);
}
+ pair->dma_chan[!dir] = tmp_chan;
ret = snd_dmaengine_pcm_prepare_slave_config(substream, params, &config_fe);
if (ret) {
@@ -223,6 +224,8 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
be_chan = pcm->chan[substream->stream];
tmp_chan = be_chan;
+ } else {
+ tmp_chan = NULL;
}
if (!tmp_chan) {
tmp_chan = dma_request_chan(dev_be, tx ? "tx" : "rx");
@@ -409,9 +412,9 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component,
/* Request a dummy dma channel, which will be released later. */
tmp_chan = asrc->get_dma_channel(pair, dir);
- if (!tmp_chan) {
+ ret = PTR_ERR_OR_ZERO(tmp_chan);
+ if (ret) {
dev_err(dev, "failed to get dma channel\n");
- ret = -EINVAL;
goto dma_chan_err;
}
@@ -502,9 +505,9 @@ static int fsl_asrc_dma_pcm_new(struct snd_soc_component *component,
/* Request a dma channel, which will be released later. */
chan = asrc->get_dma_channel(pair, IN);
- if (!chan) {
+ ret = PTR_ERR_OR_ZERO(chan);
+ if (ret) {
dev_err(dev, "failed to get dma channel\n");
- ret = -EINVAL;
goto dma_chan_err;
}
diff --git a/sound/soc/fsl/fsl_asrc_m2m.c b/sound/soc/fsl/fsl_asrc_m2m.c
index afb098f1ac33f..b3f0b8c520876 100644
--- a/sound/soc/fsl/fsl_asrc_m2m.c
+++ b/sound/soc/fsl/fsl_asrc_m2m.c
@@ -467,6 +467,7 @@ static int fsl_asrc_m2m_comp_task_create(struct snd_compr_stream *stream,
struct snd_compr_runtime *runtime = stream->runtime;
struct fsl_asrc_pair *pair = runtime->private_data;
struct device *dev = &asrc->pdev->dev;
+ struct dma_chan *tmp_chan;
int ret;
exp_info_in.ops = &fsl_asrc_m2m_dma_buf_ops;
@@ -505,19 +506,21 @@ static int fsl_asrc_m2m_comp_task_create(struct snd_compr_stream *stream,
}
/* Request dma channels */
- pair->dma_chan[IN] = asrc->get_dma_channel(pair, IN);
- if (!pair->dma_chan[IN]) {
+ tmp_chan = asrc->get_dma_channel(pair, IN);
+ ret = PTR_ERR_OR_ZERO(tmp_chan);
+ if (ret) {
dev_err(dev, "[ctx%d] failed to get input DMA channel\n", pair->index);
- ret = -EBUSY;
goto err_dma_channel_in;
}
+ pair->dma_chan[IN] = tmp_chan;
- pair->dma_chan[OUT] = asrc->get_dma_channel(pair, OUT);
- if (!pair->dma_chan[OUT]) {
+ tmp_chan = asrc->get_dma_channel(pair, OUT);
+ ret = PTR_ERR_OR_ZERO(tmp_chan);
+ if (ret) {
dev_err(dev, "[ctx%d] failed to get output DMA channel\n", pair->index);
- ret = -EBUSY;
goto err_dma_channel_out;
}
+ pair->dma_chan[OUT] = tmp_chan;
return 0;
diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c
index aced16d1228ac..d30cc3e902156 100644
--- a/sound/soc/fsl/fsl_easrc.c
+++ b/sound/soc/fsl/fsl_easrc.c
@@ -1433,7 +1433,7 @@ static struct dma_chan *fsl_easrc_get_dma_channel(struct fsl_asrc_pair *ctx,
/* Example of dma name: ctx0_rx */
sprintf(name, "ctx%c_%cx", index + '0', dir == IN ? 'r' : 't');
- return dma_request_slave_channel(&easrc->pdev->dev, name);
+ return dma_request_chan(&easrc->pdev->dev, name);
};
static const unsigned int easrc_rates[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 210/742] ASoC: fsl_asrc_dma: release DMA channels on repeated hw_params
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (200 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 209/742] ASoC: fsl_asrc: Replace dma_request_slave_channel() by dma_request_chan() Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 211/742] ASoC: fsl_easrc: fix context ownership " Greg Kroah-Hartman
` (524 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stefan Ghetu, Shengjiu Wang,
Mark Brown, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Ghetu <stefan.ghetu@nxp.com>
[ Upstream commit 0d02516a94b47637acaad8e7a83c3a810402e70a ]
fsl_asrc_dma_hw_params() requests new DMA channels on every call and
overwrites the previous ones, which are leaked when hw_params() is
called again without hw_free(). Its Back-End error path also releases a
channel without clearing the pointer, so the following hw_free()
releases it a second time.
Release the channels of a previous call first, and clear the pointer in
the error path.
Fixes: 3117bb3109dc ("ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and platform drivers")
Fixes: 36124fb19f1a ("ASoC: fsl_asrc_dma: Fix dma_chan leak when config DMA channel failed")
Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://patch.msgid.link/20261116093751.138455-4-stefan.ghetu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/fsl/fsl_asrc_dma.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
index 0aa5db8973d6f..7615bef3b9503 100644
--- a/sound/soc/fsl/fsl_asrc_dma.c
+++ b/sound/soc/fsl/fsl_asrc_dma.c
@@ -124,6 +124,19 @@ static int fsl_asrc_dma_trigger(struct snd_soc_component *component,
return 0;
}
+static void fsl_asrc_dma_release_chans(struct fsl_asrc_pair *pair, u8 dir)
+{
+ if (pair->dma_chan[!dir])
+ dma_release_channel(pair->dma_chan[!dir]);
+
+ /* release dev_to_dev chan if we aren't reusing the Back-End one */
+ if (pair->dma_chan[dir] && pair->req_dma_chan)
+ dma_release_channel(pair->dma_chan[dir]);
+
+ pair->dma_chan[!dir] = NULL;
+ pair->dma_chan[dir] = NULL;
+}
+
static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
@@ -190,6 +203,9 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
dma_params_fe->addr = asrc->paddr + asrc->get_fifo_addr(!dir, index);
dma_params_fe->maxburst = dma_params_be->maxburst;
+ /* hw_params() may be called again without hw_free() in between */
+ fsl_asrc_dma_release_chans(pair, dir);
+
tmp_chan = asrc->get_dma_channel(pair, !dir);
if (IS_ERR(tmp_chan)) {
dev_err(dev, "failed to request DMA channel\n");
@@ -342,6 +358,7 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component,
dev_err(dev, "failed to config DMA channel for Back-End\n");
if (pair->req_dma_chan)
dma_release_channel(pair->dma_chan[dir]);
+ pair->dma_chan[dir] = NULL;
return ret;
}
@@ -356,15 +373,7 @@ static int fsl_asrc_dma_hw_free(struct snd_soc_component *component,
struct fsl_asrc_pair *pair = runtime->private_data;
u8 dir = tx ? OUT : IN;
- if (pair->dma_chan[!dir])
- dma_release_channel(pair->dma_chan[!dir]);
-
- /* release dev_to_dev chan if we aren't reusing the Back-End one */
- if (pair->dma_chan[dir] && pair->req_dma_chan)
- dma_release_channel(pair->dma_chan[dir]);
-
- pair->dma_chan[!dir] = NULL;
- pair->dma_chan[dir] = NULL;
+ fsl_asrc_dma_release_chans(pair, dir);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 211/742] ASoC: fsl_easrc: fix context ownership on repeated hw_params
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (201 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 210/742] ASoC: fsl_asrc_dma: release DMA channels on repeated hw_params Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 212/742] ASoC: fsl_asrc_m2m: allow only one task at a time per stream Greg Kroah-Hartman
` (523 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stefan Ghetu, Shengjiu Wang,
Mark Brown, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Ghetu <stefan.ghetu@nxp.com>
[ Upstream commit f50dfefe6d4dd8cf5e826353de21228b9f073e68 ]
hw_params() can be called again without hw_free() in between.
fsl_easrc_hw_params() then requests a second context while the stream
still owns the first one, which is never released. After close, that
easrc->pair[] entry points to freed memory and is dereferenced by
fsl_easrc_runtime_resume() on the next open.
The EASRC slots depend on the number of channels, so release the owned
context before requesting a new one, and make
fsl_easrc_release_context() ignore a context it does not own.
Fixes: 955ac624058f ("ASoC: fsl_easrc: Add EASRC ASoC CPU DAI drivers")
Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://patch.msgid.link/20261116093751.138455-5-stefan.ghetu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/fsl/fsl_easrc.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c
index d30cc3e902156..40b3142ce93aa 100644
--- a/sound/soc/fsl/fsl_easrc.c
+++ b/sound/soc/fsl/fsl_easrc.c
@@ -1347,6 +1347,10 @@ static void fsl_easrc_release_context(struct fsl_asrc_pair *ctx)
guard(spinlock_irqsave)(&easrc->lock);
+ /* Nothing to release if the context is not owned by @ctx */
+ if (easrc->pair[ctx->index] != ctx)
+ return;
+
fsl_easrc_release_slot(easrc, ctx->index);
easrc->channel_avail += ctx->channels;
@@ -1500,6 +1504,12 @@ static int fsl_easrc_hw_params(struct snd_pcm_substream *substream,
snd_pcm_format_t format = params_format(params);
int ret;
+ /* hw_params() may be called again without hw_free() in between */
+ if (ctx_priv->ctx_streams & BIT(substream->stream)) {
+ ctx_priv->ctx_streams &= ~BIT(substream->stream);
+ fsl_easrc_release_context(ctx);
+ }
+
ret = fsl_easrc_request_context(channels, ctx);
if (ret) {
dev_err(dev, "failed to request context\n");
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 212/742] ASoC: fsl_asrc_m2m: allow only one task at a time per stream
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (202 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 211/742] ASoC: fsl_easrc: fix context ownership " Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 213/742] cpufreq: intel_pstate: Refresh cpuinfo.max_freq when a CPU goes online Greg Kroah-Hartman
` (522 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stefan Ghetu, Shengjiu Wang,
Mark Brown, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Ghetu <stefan.ghetu@nxp.com>
[ Upstream commit f0277994dbd09cc45d600c2f86cbfde9c17c6fcf ]
All tasks of a stream share one pair and one set of DMA channels, and
get_caps() advertises a single fragment, but the compress core allows
up to 64 tasks. A second task requests the pair again and overwrites the
DMA channels. Freeing both tasks then releases the same channels twice
and leaves a stale asrc->pair[] entry after close.
Return -EBUSY from task_create() while a task exists, and clear the DMA
channel pointers once they are released.
Fixes: 24a01710f627 ("ASoC: fsl_asrc_m2m: Add memory to memory function")
Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Link: https://patch.msgid.link/20261116093751.138455-6-stefan.ghetu@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/fsl/fsl_asrc_m2m.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sound/soc/fsl/fsl_asrc_m2m.c b/sound/soc/fsl/fsl_asrc_m2m.c
index b3f0b8c520876..9d124d2464027 100644
--- a/sound/soc/fsl/fsl_asrc_m2m.c
+++ b/sound/soc/fsl/fsl_asrc_m2m.c
@@ -470,6 +470,10 @@ static int fsl_asrc_m2m_comp_task_create(struct snd_compr_stream *stream,
struct dma_chan *tmp_chan;
int ret;
+ /* All tasks share the pair and DMA channels: one task at a time */
+ if (pair->dma_chan[IN])
+ return -EBUSY;
+
exp_info_in.ops = &fsl_asrc_m2m_dma_buf_ops;
exp_info_in.size = ASRC_M2M_BUFFER_SIZE;
exp_info_in.flags = O_RDWR;
@@ -526,6 +530,7 @@ static int fsl_asrc_m2m_comp_task_create(struct snd_compr_stream *stream,
err_dma_channel_out:
dma_release_channel(pair->dma_chan[IN]);
+ pair->dma_chan[IN] = NULL;
err_dma_channel_in:
if (asrc->m2m_unprepare)
asrc->m2m_unprepare(pair);
@@ -570,6 +575,8 @@ static int fsl_asrc_m2m_comp_task_free(struct snd_compr_stream *stream,
dma_release_channel(pair->dma_chan[IN]);
if (pair->dma_chan[OUT])
dma_release_channel(pair->dma_chan[OUT]);
+ pair->dma_chan[IN] = NULL;
+ pair->dma_chan[OUT] = NULL;
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 213/742] cpufreq: intel_pstate: Refresh cpuinfo.max_freq when a CPU goes online
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (203 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 212/742] ASoC: fsl_asrc_m2m: allow only one task at a time per stream Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 214/742] btrfs: remove devid kobject when deleting a missing device Greg Kroah-Hartman
` (521 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ximing Zhang, Hugo Sales,
Rafael J. Wysocki, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Sales <hugo@hsal.es>
[ Upstream commit a636989f93b4f70df0e44dd3025ba13c05266053 ]
A write to no_turbo or a change in the HWP capabilities updates
policy->cpuinfo.max_freq through intel_pstate_update_max_freq(), which
gets the policy with cpufreq_cpu_get(). That returns NULL for an offline
CPU, so its policy keeps the old value. When the CPU comes back, the
core reuses the policy and calls ->online(), and
intel_pstate_cpu_online() doesn't recompute cpuinfo.max_freq either.
Before commit 4adcf2e5829f ("cpufreq: intel_pstate: Add ->offline and
->online callbacks"), ->init() ran on every online and set it
Turning turbo on while a CPU is offline leaves that CPU at the non-turbo
maximum once it's back, while the other CPUs report the turbo frequency.
In the reverse order the CPU keeps the turbo maximum with turbo off
Set cpuinfo.max_freq at the end of intel_pstate_cpu_online(), after HWP
is enabled again, the same way __intel_pstate_update_max_freq() does.
cpufreq_online() applies the policy limits after that. Hold the CPU
hotplug lock in store_no_turbo(), so a CPU can't come online between
the no_turbo store and the update of the online CPUs
Fixes: 4adcf2e5829f ("cpufreq: intel_pstate: Add ->offline and ->online callbacks")
Reported-by: Ximing Zhang <xzhangjr@gmail.com>
Closes: https://lore.kernel.org/all/20261108071225.54656-1-xzhangjr@gmail.com/
Signed-off-by: Hugo Sales <hugo@hsal.es>
Tested-by: Ximing Zhang <xzhangjr@gmail.com>
[ rjw: Renamed the new function ]
Link: https://patch.msgid.link/20261114-intel-pstate-online-max-freq-v1-1-1bbdae2b4986@hsal.es
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/cpufreq/intel_pstate.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index c78dcd681511c..d3650a6e37b54 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1426,16 +1426,24 @@ static void intel_pstate_update_policies(void)
cpufreq_update_policy(cpu);
}
-static void __intel_pstate_update_max_freq(struct cpufreq_policy *policy,
- struct cpudata *cpudata)
+static void __intel_pstate_update_cpuinfo_max_freq(struct cpufreq_policy *policy,
+ struct cpudata *cpudata)
{
- guard(cpufreq_policy_write)(policy);
+ lockdep_assert_held_write(&policy->rwsem);
if (hwp_active)
intel_pstate_get_hwp_cap(cpudata);
policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
+}
+
+static void __intel_pstate_update_max_freq(struct cpufreq_policy *policy,
+ struct cpudata *cpudata)
+{
+ guard(cpufreq_policy_write)(policy);
+
+ __intel_pstate_update_cpuinfo_max_freq(policy, cpudata);
refresh_frequency_limits(policy);
}
@@ -1569,6 +1577,12 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
return -EINVAL;
guard(mutex)(&intel_pstate_driver_lock);
+ /*
+ * intel_pstate_update_max_freq() skips offline CPUs, and a CPU coming
+ * online reads global.no_turbo in intel_pstate_cpu_online(). Keep CPUs
+ * from coming online until every online CPU has the new limit
+ */
+ guard(cpus_read_lock)();
if (!intel_pstate_driver)
return -EAGAIN;
@@ -3019,6 +3033,14 @@ static int intel_pstate_cpu_online(struct cpufreq_policy *policy)
hybrid_update_capacity(cpu);
}
+ /*
+ * intel_pstate_update_max_freq() skips offline CPUs, so the turbo
+ * setting or the HWP capabilities may have changed since this CPU
+ * went offline. Read the HWP capabilities only once HWP is enabled
+ * again
+ */
+ __intel_pstate_update_cpuinfo_max_freq(policy, cpu);
+
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 214/742] btrfs: remove devid kobject when deleting a missing device
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (204 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 213/742] cpufreq: intel_pstate: Refresh cpuinfo.max_freq when a CPU goes online Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 215/742] btrfs: pre-flush reflink source before taking inode locks Greg Kroah-Hartman
` (520 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Cheng Yongkang,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cheng Yongkang <teel4res@gmail.com>
[ Upstream commit 9383a7fdcb27142d97e65fc76f28475018980b35 ]
btrfs_rm_device() removes the sysfs device entry only when
device->bdev_file is non-NULL. A missing device (created by
add_missing_dev() for an absent disk) has bdev_file == NULL, but
btrfs_sysfs_add_device() still registers its devid kobject under
/sys/fs/btrfs/<uuid>/devinfo/<devid>.
When such a device is deleted, btrfs_free_device() frees the
btrfs_device while the devid kobject remains registered. The kobject is
embedded in the freed btrfs_device and its show functions use
container_of() to reach it, so reading any devinfo attribute is a
use-after-free:
BUG: KASAN: slab-use-after-free in sysfs_kf_seq_show+0x157/0x490
Read of size 8 at addr ffff88801d8172a8 by task poc/9385
...
Freed by task 9385:
kfree
btrfs_rm_device+0x11ee/0x17b0
btrfs_ioctl_rm_dev+0x265/0x400
Allocated by task 9390:
btrfs_alloc_device+0x7e/0x400
device_list_add
btrfs_scan_one_device
btrfs_control_ioctl
The freed object is kmalloc-1k and the faulting access is 680 bytes
inside it (offsetof(struct btrfs_device, devid_kobj) = 640 plus
offsetof(struct kobject, ktype) = 40), confirming the embedded
devid_kobj.
btrfs_sysfs_remove_device() already skips the block-device link when
device->bdev is NULL and only touches the devid kobject when it is
initialized. Call it for missing devices too.
Fixes: 668e48af7a94 ("btrfs: sysfs, add devid/dev_state kobject and device attributes")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Assisted-by: LLM
Signed-off-by: Cheng Yongkang <teel4res@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/volumes.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 054f7161cb112..fa39d1b34f145 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2479,11 +2479,11 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info,
btrfs_assign_next_active_device(device, NULL);
- if (device->bdev_file) {
+ if (device->bdev_file)
cur_devices->open_devices--;
- /* remove sysfs entry */
- btrfs_sysfs_remove_device(device);
- }
+
+ /* Remove sysfs entry, including for a missing device. */
+ btrfs_sysfs_remove_device(device);
num_devices = btrfs_super_num_devices(fs_info->super_copy) - 1;
btrfs_set_super_num_devices(fs_info->super_copy, num_devices);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 215/742] btrfs: pre-flush reflink source before taking inode locks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (205 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 214/742] btrfs: remove devid kobject when deleting a missing device Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 216/742] btrfs: downgrade the reflink source inode lock for tree walking Greg Kroah-Hartman
` (519 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Filipe Manana, Boris Burkov,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <boris@bur.io>
[ Upstream commit 220c44b1b90fbff746472cbb3dde778b02afbef9 ]
Consider the following sketch of a shell script:
dd if=/dev/urandom of=/mnt/src bs=1M count=4096
cp --reflink=always /mnt/src /mnt/dst &
sleep 0.1 # let the clone reach its flush
time dd if=/mnt/src of=/dev/null bs=4K count=1 iflag=direct
The current logic in reflink ensures the existence and stability of both
the src and destination inode by locking them both and then flushing all
dirty pages / ordered_extents under the inode lock. This blocks
concurrent usage by even readers of the inode locks, like direct reads
or seeks for the duration of writeback on the entirety of the two files.
We observe this particular contention frequently in the Meta fleet.
It is also a relatively common pattern to write the src file, then reflink
it while it is still dirty, so that typical path naturally hits this
contention. This workload motivates a relatively simple optimization:
trigger the unavoidable src flushing outside the locked region.
Therefore, do an optimistic btrfs_wait_ordered_range() without the locks
while relying on the calls to btrfs_wait_ordered_range() under the
locks in btrfs_remap_file_range_prep() to ensure correctness. In the
worst case with concurrent writes while unlocked, we can end up doing
the writeback twice, which I think is a reasonable price to pay to avoid
victimizing innocent readers in a common case.
With and without this patch, the above reproducer runs the reflink in
the same ~0.5s on my system. Without the patch, the direct read blocks
for basically the full duration of the reflink while with the patch it
returns in a few milliseconds.
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: ad4bb983915d ("btrfs: fix race between concurrent sync direct IO writes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/reflink.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index d2a4101912bdb..24c0b226bc316 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -833,6 +833,17 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
return 0;
}
+static u64 calc_remap_wb_len(struct btrfs_inode *src_inode, loff_t off, loff_t len,
+ unsigned int remap_flags)
+{
+ const u32 bs = src_inode->root->fs_info->sectorsize;
+ const loff_t isize = i_size_read(&src_inode->vfs_inode);
+
+ if (len == 0 && !(remap_flags & REMAP_FILE_DEDUP))
+ return ALIGN(isize, bs) - ALIGN_DOWN(off, bs);
+ return ALIGN(len, bs);
+}
+
static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
struct file *file_out, loff_t pos_out,
loff_t *len, unsigned int remap_flags)
@@ -876,10 +887,7 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
* not for the ordered extents to complete. We need to wait for them
* to complete so that new file extent items are in the fs tree.
*/
- if (*len == 0 && !(remap_flags & REMAP_FILE_DEDUP))
- wb_len = ALIGN(inode_in->vfs_inode.i_size, bs) - ALIGN_DOWN(pos_in, bs);
- else
- wb_len = ALIGN(*len, bs);
+ wb_len = calc_remap_wb_len(inode_in, pos_in, *len, remap_flags);
/*
* Workaround to make sure NOCOW buffered write reach disk as NOCOW.
@@ -930,6 +938,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
struct btrfs_inode *src_inode = BTRFS_I(file_inode(src_file));
struct btrfs_inode *dst_inode = BTRFS_I(file_inode(dst_file));
bool same_inode = dst_inode == src_inode;
+ u64 wb_start, wb_len;
int ret;
if (btrfs_is_shutdown(src_inode->root->fs_info))
@@ -938,6 +947,17 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
return -EINVAL;
+ /*
+ * Optimistically write out the src inode before taking locks.
+ * Consistency is properly ensured by the btrfs_wait_ordered_range()
+ * inside btrfs_remap_file_range_prep().
+ */
+ wb_start = ALIGN_DOWN(off, src_inode->root->fs_info->sectorsize);
+ wb_len = calc_remap_wb_len(src_inode, off, len, remap_flags);
+ ret = btrfs_wait_ordered_range(src_inode, wb_start, wb_len);
+ if (ret < 0)
+ return ret;
+
if (same_inode) {
btrfs_inode_lock(src_inode, BTRFS_ILOCK_MMAP);
} else {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 216/742] btrfs: downgrade the reflink source inode lock for tree walking
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (206 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 215/742] btrfs: pre-flush reflink source before taking inode locks Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 217/742] btrfs: fix race between concurrent sync direct IO writes Greg Kroah-Hartman
` (518 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Filipe Manana, Boris Burkov,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <boris@bur.io>
[ Upstream commit cf02c310d018c7e5363b80dfd68ffdf159f3c914 ]
When doing a reflink, we are not writing to the src inode or modifying
it in any way, so it is counter-intuitive to have to lock it
exclusively. This has the cost of blocking other shared lock users of
the src file for the duration of any new writeback since the optimistic
pre-flush and all the actual reflinking. So we would like to downgrade
the lock to shared as much as possible.
There are two important gotchas to do with direct io that must be
addressed to make this idea work.
The first gotcha is that dio writes that come in under EOF try to take
inode->i_rwsem shared, which would result in messed up views of the
extents in the reflinked file. Therefore, add "being used as a reflink
src" as another inode flag exception for the dio write shared tests that
already exist to check for other dangerous conditions. In order to
ensure that this flag is visible to the dio writer, reflink must first
take i_rwsem exclusive, then set the flag, then downgrade to shared.
The second is that dio reads increment inode->i_dio_count which blocks
inode_dio_wait() in __generic_remap_file_range_prep(). Therefore, we
must remain exclusive to dio reads through finishing the prep or risk
starving the clone on a stream of dio readers. There is still O(extents)
work in btrfs_clone() which can be done without holding the lock
exclusive, so we should downgrade to shared and admit dio readers (and
other shared lock users like lseek) after we are finished with
inode_dio_wait().
By running concurrent clones and lseeks or dio reads on a src file with
32k extents on a vm, I can demonstrate 100ms+ stalls on the readers
without this patch and they go away entirely with the patch.
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: ad4bb983915d ("btrfs: fix race between concurrent sync direct IO writes")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/btrfs_inode.h | 6 ++++++
fs/btrfs/direct-io.c | 7 +++++++
fs/btrfs/reflink.c | 17 +++++++++++++++--
3 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 89e5e9c0c904f..a1bc1eb2ff31f 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -98,6 +98,12 @@ enum {
* range).
*/
BTRFS_INODE_COW_WRITE_ERROR,
+ /*
+ * Set by reflink while it holds the source's VFS inode lock shared.
+ * Direct IO writes also take that lock shared; one that finds this bit
+ * set after acquiring it must retry with the exclusive lock.
+ */
+ BTRFS_INODE_REFLINK_SRC,
/*
* Indicate this is a directory that points to a subvolume for which
* there is no root reference item. That's a case like the following:
diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c
index 3075d79927130..ed3914257d395 100644
--- a/fs/btrfs/direct-io.c
+++ b/fs/btrfs/direct-io.c
@@ -913,6 +913,13 @@ ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
goto relock;
}
+ if ((ilock_flags & BTRFS_ILOCK_SHARED) &&
+ test_bit(BTRFS_INODE_REFLINK_SRC, &BTRFS_I(inode)->runtime_flags)) {
+ btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
+ ilock_flags &= ~BTRFS_ILOCK_SHARED;
+ goto relock;
+ }
+
ret = generic_write_checks(iocb, from);
if (ret <= 0) {
btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 24c0b226bc316..ac8dfd6fa8140 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -939,6 +939,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
struct btrfs_inode *dst_inode = BTRFS_I(file_inode(dst_file));
bool same_inode = dst_inode == src_inode;
u64 wb_start, wb_len;
+ bool src_downgraded = false;
int ret;
if (btrfs_is_shutdown(src_inode->root->fs_info))
@@ -970,6 +971,12 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
if (ret < 0 || len == 0)
goto out_unlock;
+ if (!same_inode) {
+ set_bit(BTRFS_INODE_REFLINK_SRC, &src_inode->runtime_flags);
+ downgrade_write(&src_inode->vfs_inode.i_rwsem);
+ src_downgraded = true;
+ }
+
if (remap_flags & REMAP_FILE_DEDUP)
ret = btrfs_extent_same(src_inode, off, len, dst_inode, destoff);
else
@@ -980,8 +987,14 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
btrfs_inode_unlock(src_inode, BTRFS_ILOCK_MMAP);
} else {
btrfs_double_mmap_unlock(src_inode, dst_inode);
- unlock_two_nondirectories(&src_inode->vfs_inode,
- &dst_inode->vfs_inode);
+ if (src_downgraded) {
+ clear_bit(BTRFS_INODE_REFLINK_SRC, &src_inode->runtime_flags);
+ inode_unlock_shared(&src_inode->vfs_inode);
+ inode_unlock(&dst_inode->vfs_inode);
+ } else {
+ unlock_two_nondirectories(&src_inode->vfs_inode,
+ &dst_inode->vfs_inode);
+ }
}
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 217/742] btrfs: fix race between concurrent sync direct IO writes
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (207 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 216/742] btrfs: downgrade the reflink source inode lock for tree walking Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 218/742] btrfs: zstd: fix UAF due to race between putting workspace and reclaim Greg Kroah-Hartman
` (517 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit ad4bb983915d8588dc9dd3aeb60cf58aff574e3b ]
If we have a direct IO write within i_size, we lock the inode's VFS lock
in shared mode, which allows for concurrent direct IO writes within
different ranges of the file, which is an important optimization for many
applications such as databases.
However if we have a sync direct IO write within i_size, it locks the
inode in shared mode and then enters fsync through the call to the
iomap_dio_complete() function from iomap using the shared lock. This
means that if we have another concurrent direct IO write that locks the
inode in shared mode and the fsync is in fast mode (the inode flag
BTRFS_INODE_NEEDS_FULL_SYNC is not set), the fsync does not wait for
the ordered extent created by the concurrent direct IO write to complete
before logging its extent map. The fsync code relies on direct IO writes
to create ordered extents and wait for their IO to finish while holding
the inode's lock, while the fsync should hold the inode lock in exclusive
mode. This means that this race can end up persisting a log tree with
file extent items that point to extents that were not yet written when
the log is synced.
Fix this by always taking the inode lock in exclusive mode if we have a
sync write.
This issue was identified by Sashiko in the link below, which identifies
two different races between direct IO writes and fsync. The race fixed
here is the second case identified by Sashiko in the link below. The first
race is already being fixed in a separate patch from Josef.
Link: https://sashiko.dev/#/bug/linux-ee047626-2fa7-46d5-b543-861136993fc7
Fixes: 939b656bc8ab ("btrfs: fix corruption after buffer fault in during direct IO append write")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/direct-io.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c
index ed3914257d395..e7c3647c0f739 100644
--- a/fs/btrfs/direct-io.c
+++ b/fs/btrfs/direct-io.c
@@ -896,9 +896,13 @@ ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
* If the write DIO is within EOF, use a shared lock and also only if
* security bits will likely not be dropped by file_remove_privs() called
* from btrfs_write_check(). Either will need to be rechecked after the
- * lock was acquired.
+ * lock was acquired. Also if this is a sync write we will need to fsync
+ * and therefore we must lock in exclusive mode, otherwise we would race
+ * with other concurrent DIO writes and the fsync would not wait for
+ * their ordered extent to finish IO before logging the new extent maps.
*/
- if (iocb->ki_pos + iov_iter_count(from) <= i_size_read(inode) && IS_NOSEC(inode))
+ if (iocb->ki_pos + iov_iter_count(from) <= i_size_read(inode) &&
+ IS_NOSEC(inode) && !iocb_is_dsync(iocb))
ilock_flags |= BTRFS_ILOCK_SHARED;
relock:
@@ -920,6 +924,13 @@ ssize_t btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
goto relock;
}
+ /* Sync writes must use exclusive locking, see the comment above. */
+ if ((ilock_flags & BTRFS_ILOCK_SHARED) && iocb_is_dsync(iocb)) {
+ btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
+ ilock_flags &= ~BTRFS_ILOCK_SHARED;
+ goto relock;
+ }
+
ret = generic_write_checks(iocb, from);
if (ret <= 0) {
btrfs_inode_unlock(BTRFS_I(inode), ilock_flags);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 218/742] btrfs: zstd: fix UAF due to race between putting workspace and reclaim
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (208 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 217/742] btrfs: fix race between concurrent sync direct IO writes Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 219/742] ASoC: SOF: control: reject out-of-range enum values Greg Kroah-Hartman
` (516 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit 2d8b3d9b210a388129e41757372d70c66ae20a5b ]
When we put a workspace with a level matching the requested level, we add
it back to the lru list of the workspace manager and set the timer to
run the reclaim function (zstd_reclaim_timer_fn()). If that workspace than
gets used by some other task, obtained with zstd_find_workspace(), for
some compression level lower than the workspace's level, we set the
workspace's req_level field to the requested level (done in
zstd_find_workspace()) and leave it in the lru list without updating the
last_used field of the workspace. Once the last_used field ages past the
ZSTD_BTRFS_RECLAIM_JIFFIES value, when zstd_put_workspace() is called it
skips the lru update branch because the workspace's req_level does not
match its level, and then it sets its req_level to 0 before releasing
the workspace manager's lock - and after that and before
zstd_put_workspace() does:
if (workspace->level == clip_level(ZSTD_BTRFS_MAX_LEVEL))
cond_wake_up(&zwsm->wait);
the reclaim function, zstd_reclaim_timer_fn(), can run, see the workspace
in the lru list and see that it has a req_level of 0 and an expired
last_used time, and therefore call zstd_free_workspace() to free the
workspace, right before the task that is putting the workspace executes
the code above to read its level.
Fix this by reading the workspace's level before unlocking the workspace
manager in zstd_put_workspace().
Link: https://sashiko.dev/#/bug/linux-92b08485-a86c-4bb5-9138-fa80c84389f0
Fixes: 3f93aef535c8 ("btrfs: add zstd compression level support")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/zstd.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c
index 082f653464c8e..610f87da19faf 100644
--- a/fs/btrfs/zstd.c
+++ b/fs/btrfs/zstd.c
@@ -340,6 +340,7 @@ void zstd_put_workspace(struct btrfs_fs_info *fs_info, struct list_head *ws)
{
struct zstd_workspace_manager *zwsm = fs_info->compr_wsm[BTRFS_COMPRESS_ZSTD];
struct workspace *workspace = list_to_workspace(ws);
+ bool wakeup;
ASSERT(zwsm);
spin_lock_bh(&zwsm->lock);
@@ -363,9 +364,14 @@ void zstd_put_workspace(struct btrfs_fs_info *fs_info, struct list_head *ws)
list_add(&workspace->list, &zwsm->idle_ws[workspace->level]);
workspace->req_level = 0;
+ /*
+ * Check if we should wakeup before releasing the lock because after
+ * that the reclaim function can run and free the workspace.
+ */
+ wakeup = (workspace->level == clip_level(ZSTD_BTRFS_MAX_LEVEL));
spin_unlock_bh(&zwsm->lock);
- if (workspace->level == clip_level(ZSTD_BTRFS_MAX_LEVEL))
+ if (wakeup)
cond_wake_up(&zwsm->wait);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 219/742] ASoC: SOF: control: reject out-of-range enum values
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (209 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 218/742] btrfs: zstd: fix UAF due to race between putting workspace and reclaim Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 220/742] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset() Greg Kroah-Hartman
` (515 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Arnav Kapoor, Mark Brown,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnav Kapoor <kapoorarnav43@gmail.com>
[ Upstream commit 3092b9e481fedc413bf7acda9edc04b0bd8cb28a ]
snd_sof_enum_put() passes the item indexes from user space to the IPC
enum_put() op unchecked, and the IPC3 and IPC4 ops store them as they
are and send them to the DSP. With the IPC4 sof-hda-generic-2ch.tplg on
a Tiger Lake laptop, "Dmic0 Capture TDFB angle set enum" has 13 items
but accepts 13 and 0xffffffff, and reads them back. The ALSA mixer-test
selftest reports this as a write_invalid failure.
Reject indexes past the last item, as snd_soc_put_enum_double() does.
Fixes: c3078f539704 ("ASoC: SOF: Add Sound Open Firmware KControl support")
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
Link: https://patch.msgid.link/20261118103129.113970-1-kapoorarnav43@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/sof/control.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c
index 74d997a4f6203..625a17624f415 100644
--- a/sound/soc/sof/control.c
+++ b/sound/soc/sof/control.c
@@ -120,6 +120,11 @@ int snd_sof_enum_put(struct snd_kcontrol *kcontrol,
struct snd_soc_component *scomp = scontrol->scomp;
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
const struct sof_ipc_tplg_ops *tplg_ops = sof_ipc_get_ops(sdev, tplg);
+ unsigned int i;
+
+ for (i = 0; i < scontrol->num_channels; i++)
+ if (ucontrol->value.enumerated.item[i] >= se->items)
+ return -EINVAL;
if (tplg_ops && tplg_ops->control && tplg_ops->control->enum_put)
return tplg_ops->control->enum_put(scontrol, ucontrol);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 220/742] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (210 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 219/742] ASoC: SOF: control: reject out-of-range enum values Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 221/742] btrfs: fix double release of space when cloning compressed inline extent Greg Kroah-Hartman
` (514 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit fd573263740371f76cad610cbcc70629b27f6c0c ]
In the while loop that finds the first file extent item, counting from the
end of the file, that is not a hole, we are accessing the disk_bytenr
field of each file extent item, which is wrong in case we have an item
that represents an inline extent. In that case the inline data starts at
the disk_bytenr offset and therefore we are reading user data or in case
the inline data is less than 8 bytes, we are accessing another region of
the leaf or even beyond the leaf boundaries in case it's the last item.
This should be a very rare case, as it implies having an inline extent
followed by a hole file extent item (the no-holes feature is not used).
Fixes: ac3c0d36a2a2 ("btrfs: make fiemap more efficient and accurate reporting extent sharedness")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/fiemap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/btrfs/fiemap.c b/fs/btrfs/fiemap.c
index 817171028413c..285398eb36dc1 100644
--- a/fs/btrfs/fiemap.c
+++ b/fs/btrfs/fiemap.c
@@ -621,6 +621,8 @@ static int fiemap_find_last_extent_offset(struct btrfs_inode *inode,
leaf = path->nodes[0];
ei = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_file_extent_item);
+ if (btrfs_file_extent_type(leaf, ei) == BTRFS_FILE_EXTENT_INLINE)
+ break;
disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, ei);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 221/742] btrfs: fix double release of space when cloning compressed inline extent
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (211 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 220/742] btrfs: fiemap: deal with inline extent in fiemap_find_last_extent_offset() Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 222/742] btrfs: abort transaction on failure to update inode after hole punching Greg Kroah-Hartman
` (513 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit ee020b5f0eb81a86533a16dcaafcee2b97a0f74d ]
In copy_inline_to_page(), if we fail to decompress the inline extent, we
jump to the out_unlock label and release the reserved data and metadata
space with a call to btrfs_delalloc_release_space(). However we leave the
range in the inode's io_tree marked as delalloc, which was set by
btrfs_reset_extent_delalloc(), and that means when someone later clears
the delalloc range, using EXTENT_DO_ACCOUNTING (like
btrfs_reset_extent_delalloc() does), it will release again the space.
This does not happen for uncompressed inline extents, because after the
call to btrfs_reset_extent_delalloc() we can't get any other errors.
Link: https://sashiko.dev/#/bug/linux-52478dd4-bd10-48de-baba-a527b38b64aa
Fixes: 05a5a7621ce6 ("Btrfs: implement full reflink support for inline extents")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/reflink.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index ac8dfd6fa8140..d2567ee6e5fa3 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -120,8 +120,21 @@ static int copy_inline_to_page(struct btrfs_inode *inode,
ret = btrfs_decompress(comp_type, data_start, folio,
offset_in_folio(folio, file_offset),
inline_size, datal);
- if (ret)
+ if (ret) {
+ /*
+ * btrfs_reset_extent_delalloc() set the range as
+ * delalloc, so clear it, otherwise we will free the
+ * reserved data and metadata space twice, once below by
+ * btrfs_delalloc_release_space() and once again when
+ * someone else clears the delalloc range with
+ * EXTENT_DO_ACCOUNTING (like
+ * btrfs_reset_extent_delalloc() does).
+ */
+ btrfs_clear_extent_bit(&inode->io_tree, file_offset,
+ range_end, EXTENT_DELALLOC |
+ EXTENT_DELALLOC_NEW, NULL);
goto out_unlock;
+ }
flush_dcache_folio(folio);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 222/742] btrfs: abort transaction on failure to update inode after hole punching
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (212 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 221/742] btrfs: fix double release of space when cloning compressed inline extent Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 223/742] btrfs: fix blocking allocation for nowait encoded reads of inline extents Greg Kroah-Hartman
` (512 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit 6cd72166183bfc290fd853470232020c4b807aa2 ]
If we fail to update the inode we simply release the transaction and don't
abort the transaction. This means the transaction can get committed and we
will not persist important updates to the inode item such as nbytes (which
gets reduced after punching holes) and the timestamps. Fix this by adding
the missing abort.
Link: https://sashiko.dev/#/bug/linux-d8b4cb7a-8dfe-454f-9b19-a67af28b81bd
Fixes: 2aaa66558172 ("Btrfs: add hole punching")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/file.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index f978c6524aa03..731362056104d 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2747,7 +2747,10 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
inode_inc_iversion(inode);
inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
ret = btrfs_update_inode(trans, BTRFS_I(inode));
- updated_inode = true;
+ if (ret)
+ btrfs_abort_transaction(trans, ret);
+ else
+ updated_inode = true;
btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info);
out:
@@ -2773,6 +2776,8 @@ static int btrfs_punch_hole(struct file *file, loff_t offset, loff_t len)
int ret2;
ret = btrfs_update_inode(trans, BTRFS_I(inode));
+ if (ret)
+ btrfs_abort_transaction(trans, ret);
ret2 = btrfs_end_transaction(trans);
if (!ret)
ret = ret2;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 223/742] btrfs: fix blocking allocation for nowait encoded reads of inline extents
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (213 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 222/742] btrfs: abort transaction on failure to update inode after hole punching Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 224/742] btrfs: fix incorrect task accounting on error during io_uring read Greg Kroah-Hartman
` (511 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit 85c98fd512bb3e2f326f1a1cac30f2fb0af30c6a ]
If we are doing a nowait encoded read of an inline extent, we are doing
a GFP_NOFS allocation for the temporary buffer, which can block. We are
also returning -ENOMEM on failure, which is wrong for a nowait context.
Fix this by using GFP_NOWAIT when we are in a nowait context and by
returning -EAGAIN instead of -ENOMEM if the allocation fails.
Fixes: 973a432637ed ("btrfs: don't sleep in btrfs_encoded_read() if IOCB_NOWAIT is set")
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/inode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e73f3197e426c..9cc5464d05fe8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9508,9 +9508,9 @@ static ssize_t btrfs_encoded_read_inline(
ptr += iocb->ki_pos - extent_start;
}
- tmp = kmalloc(count, GFP_NOFS);
+ tmp = kmalloc(count, nowait ? GFP_NOWAIT : GFP_NOFS);
if (!tmp)
- return -ENOMEM;
+ return nowait ? -EAGAIN : -ENOMEM;
read_extent_buffer(leaf, tmp, ptr, count);
btrfs_release_path(path);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 224/742] btrfs: fix incorrect task accounting on error during io_uring read
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (214 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 223/742] btrfs: fix blocking allocation for nowait encoded reads of inline extents Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 225/742] btrfs: fix delayed inode count leak after failure to delete inode ref Greg Kroah-Hartman
` (510 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit 42de7db475fe895d97934b73a06527a2e4912d93 ]
We are passing 'ret' to add_rchar() under the 'out' label, which is meant
to take a byte count for accounting, however if we got an error we pass
it to add_rchar() too, which is just wrong. Fix thing by passing 'ret'
only when it's not an error.
Fixes: 34310c442e17 ("btrfs: add io_uring command for encoded reads (ENCODED_READ ioctl)")
Link: https://sashiko.dev/#/bug/linux-beb0369e-eb47-41d3-86c1-e79cdc2de157
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/ioctl.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 2ea0146730d88..5245ee0413791 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4661,7 +4661,8 @@ static void btrfs_uring_read_finished(struct io_tw_req tw_req, io_tw_token_t tw)
btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
io_uring_cmd_done(cmd, ret, IO_URING_CMD_TASK_WORK_ISSUE_FLAGS);
- add_rchar(current, ret);
+ if (ret > 0)
+ add_rchar(current, ret);
for (index = 0; index < priv->nr_pages; index++)
__free_page(priv->pages[index]);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 225/742] btrfs: fix delayed inode count leak after failure to delete inode ref
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (215 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 224/742] btrfs: fix incorrect task accounting on error during io_uring read Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 226/742] ext4: Fix sparse warning in extents kunit test when EXT4_KUNIT_TESTS=m Greg Kroah-Hartman
` (509 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qu Wenruo, Filipe Manana,
David Sterba, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <fdmanana@suse.com>
[ Upstream commit 3100f46985fd14148e79a0e79912180934ef7231 ]
When updating a delayed inode, if we have an inode ref to delete (the flag
BTRFS_DELAYED_NODE_DEL_IREF is set) and we fail the deletion of the inode
ref item (if it's in another leaf), we abort the transaction and then
never release the delayed count for the inode ref deletion (by calling
btrfs_release_delayed_iref()), resulting in a permanent leak of the
delayed inode.
Fix this by jumping to the 'out' label instead and removing the now no
longer necessary 'err_out' label.
Fixes: 67de11769bd5 ("Btrfs: introduce the delayed inode ref deletion for the single link inode")
Link: https://sashiko.dev/#/bug/linux-3520c6eb-7928-477d-b369-9caff2b98d10
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/delayed-inode.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index db2ffab0941a6..3b9de1a79e16f 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1053,7 +1053,7 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
if (unlikely(ret < 0)) {
btrfs_abort_transaction(trans, ret);
- goto err_out;
+ goto out;
}
ASSERT(ret > 0);
ASSERT(path->slots[0] > 0);
@@ -1081,7 +1081,6 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
out:
btrfs_release_delayed_iref(node);
btrfs_release_path(path);
-err_out:
btrfs_delayed_inode_release_metadata(fs_info, node, (ret < 0));
btrfs_release_delayed_inode(node);
return ret;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 226/742] ext4: Fix sparse warning in extents kunit test when EXT4_KUNIT_TESTS=m
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (216 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 225/742] btrfs: fix delayed inode count leak after failure to delete inode ref Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 227/742] jbd2: set JBD2_LOADED under j_state_lock Greg Kroah-Hartman
` (508 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, kernel test robot, Baokun Li,
Zhang Yi, Jan Kara, Ojaswin Mujoo, Theodore Tso, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ojaswin Mujoo <ojaswin@linux.ibm.com>
[ Upstream commit f0a38eb3ebf925386ded88e642bd2c5b3d06534b ]
When kunit tests are compiled as modules, the extents kunit test emits
a sparse warning:
>> fs/ext4/extents-test.c:59:3: sparse: sparse: symbol 'k_ctx' was not
declared. Should it be static?
Fix this by declaring it as static.
Fixes: cb1e0c1d1fad ("ext4: kunit tests for extent splitting and conversion")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202609221900.Pgwrcp41-lkp@intel.com/
Reviewed-by: Baokun Li <libaokun@linux.alibaba.com>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Link: https://patch.msgid.link/20260924073929.2594339-1-ojaswin@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/ext4/extents-test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ext4/extents-test.c b/fs/ext4/extents-test.c
index 2e997f228330f..0f897d9ff4fee 100644
--- a/fs/ext4/extents-test.c
+++ b/fs/ext4/extents-test.c
@@ -48,7 +48,7 @@
#define EXT_DATA_LBLK 10
#define EXT_DATA_LEN 3
-struct kunit_ctx {
+static struct kunit_ctx {
/*
* Ext4 inode which has only 1 unwrit extent
*/
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 227/742] jbd2: set JBD2_LOADED under j_state_lock
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (217 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 226/742] ext4: Fix sparse warning in extents kunit test when EXT4_KUNIT_TESTS=m Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 228/742] jbd2: document the h_invalid handle flag Greg Kroah-Hartman
` (507 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christian Göttsche, Jan Kara,
Theodore Tso, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Göttsche <cgzones@googlemail.com>
[ Upstream commit 40e53dad45a92e932156de23a69c991f3e2512c9 ]
j_flags is protected by j_state_lock, with only quick racy checks done
without it. jbd2_journal_load() however sets JBD2_LOADED with a plain
read-modify-write after journal_reset() has already started kjournald2,
which tests and may update j_flags under the lock. KCSAN reports this
while mounting the root file system:
BUG: KCSAN: data-race in jbd2_journal_load / kjournald2
write to 0xffff9c6b012c6000 of 8 bytes by task 1 on cpu 3:
jbd2_journal_load+0x279/0x3c0
ext4_fill_super+0x34dc/0x5740
get_tree_bdev_flags+0x21d/0x340
...
read to 0xffff9c6b012c6000 of 8 bytes by task 77 on cpu 0:
kjournald2+0xc8/0x3e0
kthread+0x1bd/0x200
...
value changed: 0x00000000000000a8 -> 0x00000000000000b8
A concurrent update of another flag, e.g. JBD2_ABORT, could be lost.
Take j_state_lock when setting JBD2_LOADED, like the other writers of
j_flags do.
Fixes: 470decc613ab ("[PATCH] jbd2: initial copy of files from jbd")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20260928202159.2463182-1-cgoettsche@seltendoof.de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/jbd2/journal.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 55b4ce0102289..a10623504234e 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2091,7 +2091,10 @@ int jbd2_journal_load(journal_t *journal)
return err;
}
+ /* kjournald2 is already running, see journal_reset(). */
+ write_lock(&journal->j_state_lock);
journal->j_flags |= JBD2_LOADED;
+ write_unlock(&journal->j_state_lock);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 228/742] jbd2: document the h_invalid handle flag
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (218 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 227/742] jbd2: set JBD2_LOADED under j_state_lock Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 229/742] bpf: Let the bpf_fastcall boundary cover the longest pattern Greg Kroah-Hartman
` (506 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Amit Patole, Jan Kara, Theodore Tso,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Patole <amit.patole@gmail.com>
[ Upstream commit 308c3c2ead9b32e959e8b08f6375b19aabad116f ]
Commit 61e2a90a910c ("ext4: enable scoped NOFS when starting a handle
in nojournal mode") added the h_invalid bit to struct
jbd2_journal_handle but did not add it to the kernel-doc comment above
the structure, so kernel-doc now warns:
include/linux/jbd2.h:523 struct member 'h_invalid' not described in
'jbd2_journal_handle'
Describe the new flag. It is set by ext4_get_nojournal() on a handle
that is not attached to any journal and is tested by
ext4_handle_valid().
The warning was found by running scripts/kernel-doc over the headers
pulled into the htmldocs build. An AI coding assistant (Claude Opus
5.5) was used to locate the warning and draft this change; it was
verified with scripts/kernel-doc (no warnings left) and checkpatch.
Fixes: 61e2a90a910c ("ext4: enable scoped NOFS when starting a handle in nojournal mode")
Signed-off-by: Amit Patole <amit.patole@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20261105-kdoc-jbd2-h_invalid-v1-1-4bc224f7d0a2@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/jbd2.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 1b42fe47c26b2..b344cb7336fe3 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -482,6 +482,7 @@ struct jbd2_revoke_table_s;
* @h_sync: Flag for sync-on-close.
* @h_reserved: Flag for handle for reserved credits.
* @h_aborted: Flag indicating fatal error on handle.
+ * @h_invalid: Flag for a handle not attached to a journal (ext4 nojournal mode).
* @h_type: For handle statistics.
* @h_line_no: For handle statistics.
* @h_start_jiffies: Handle Start time.
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 229/742] bpf: Let the bpf_fastcall boundary cover the longest pattern
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (219 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 228/742] jbd2: document the h_invalid handle flag Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 230/742] net: sock_reuseport: Check program type on the migration path Greg Kroah-Hartman
` (505 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov,
Kumar Kartikeya Dwivedi, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 95d366cb57752fb8821488676f607ebd0050fa9e ]
A subprog can have bpf_fastcall patterns of different length:
*(u64 *)(r10 - 8) = r2
*(u64 *)(r10 - 16) = r1
call bpf_get_smp_processor_id
r1 = *(u64 *)(r10 - 16)
r2 = *(u64 *)(r10 - 8)
*(u64 *)(r10 - 16) = r1
call bpf_get_smp_processor_id
r1 = *(u64 *)(r10 - 16)
r0 = *(u64 *)(r10 - 8)
For each pattern, take the offset just above its highest spill slot: 0 for
the first pattern here, -8 for the second. Currently
mark_fastcall_pattern_for_call() keeps the lowest of these offsets in
fastcall_stack_off, the bpf_fastcall boundary of the subprog, which is -8
here. check_fastcall_stack_contract() looks only at accesses below the
boundary, so the last load, at -8, does not switch the rewrite off.
bpf_remove_fastcall_spills_fills() then removes all three pairs of a spill
and a fill, and the load reads a slot that nothing wrote, while the
verifier took it for a slot with the type of R2.
Keep the highest of these offsets instead: every slot of every pattern is
below it. Start from S16_MIN, the value that says that nothing is
rewritten. Stop at 0, as min() did, because a pattern in code that never
runs may end above the frame pointer.
Fixes: 5b5f51bff1b6 ("bpf: no_caller_saved_registers attribute for helper calls")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://patch.msgid.link/adbe7671c30f744adf6682d6431b9d818039cefb.1795462417.git.memxor@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/verifier.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 4bb0f362f44a8..8b80c25cd3695 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -18176,7 +18176,11 @@ static void mark_fastcall_pattern_for_call(struct bpf_verifier_env *env,
env->insn_aux_data[insn_idx].fastcall_spills_num = i - 1;
else
subprog->keep_fastcall_stack = 1;
- subprog->fastcall_stack_off = min(subprog->fastcall_stack_off, off);
+ /*
+ * The upper end of the longest pattern: no slot of a pattern is above it. Code that never
+ * runs may have a pattern that ends above the frame pointer.
+ */
+ subprog->fastcall_stack_off = max(subprog->fastcall_stack_off, min_t(s16, off, 0));
}
static int mark_fastcall_patterns(struct bpf_verifier_env *env)
@@ -18187,6 +18191,7 @@ static int mark_fastcall_patterns(struct bpf_verifier_env *env)
int s, i;
for (s = 0; s < env->subprog_cnt; ++s, ++subprog) {
+ subprog->fastcall_stack_off = S16_MIN;
/* find lowest stack spill offset used in this subprog */
lowest_off = 0;
for (i = subprog->start; i < (subprog + 1)->start; ++i) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 230/742] net: sock_reuseport: Check program type on the migration path
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (220 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 229/742] bpf: Let the bpf_fastcall boundary cover the longest pattern Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 231/742] tick/sched: Make tick_nohz_full_mask and HK_TYPE_KERNEL_NOISE cpumask consistent Greg Kroah-Hartman
` (504 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Shihuang Liu, Alexei Starovoitov,
Kuniyuki Iwashima, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shihuang Liu <shlomojune6@gmail.com>
[ Upstream commit cbaaeff649b7aa09170cb31db001e5468c2726c0 ]
A BPF_PROG_TYPE_SOCKET_FILTER program can be loaded with
expected_attach_type set to BPF_SK_REUSEPORT_SELECT_OR_MIGRATE and
attached to a SO_REUSEPORT TCP group. Closing a listener that still
has queued children then runs it with a struct sk_reuseport_kern
context even though it was verified against struct sk_buff, which
KASAN reports as a stack-out-of-bounds in ___bpf_prog_run().
Reaching this without CAP_BPF requires
kernel.unprivileged_bpf_disabled=0; with
CONFIG_BPF_UNPRIV_DEFAULT_OFF=y, the Kconfig default, the sysctl
starts at 2.
reuseport_migrate_sock() decides from prog->expected_attach_type
alone, a field user space sets that does not identify the program
type. Require BPF_PROG_TYPE_SK_REUSEPORT there and in
reuseport_stop_listen_sock(); socket filters still work as
selectors, so the selection path is unchanged.
Fixes: d5e4ddaeb6ab ("bpf: Support socket migration by eBPF.")
Signed-off-by: Shihuang Liu <shlomojune6@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20261118153541.172499-1-shlomojune6@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/sock_reuseport.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
index b9e5648fa4c51..e039e35f39a90 100644
--- a/net/core/sock_reuseport.c
+++ b/net/core/sock_reuseport.c
@@ -461,6 +461,18 @@ void reuseport_detach_sock(struct sock *sk)
}
EXPORT_SYMBOL(reuseport_detach_sock);
+/*
+ * Only a BPF_PROG_TYPE_SK_REUSEPORT program is verified against
+ * struct sk_reuseport_kern, which is the context bpf_run_sk_reuseport()
+ * passes to it. expected_attach_type is set by user space and does not
+ * identify the program type.
+ */
+static bool reuseport_is_migration_prog(const struct bpf_prog *prog)
+{
+ return prog && prog->type == BPF_PROG_TYPE_SK_REUSEPORT &&
+ prog->expected_attach_type == BPF_SK_REUSEPORT_SELECT_OR_MIGRATE;
+}
+
void reuseport_stop_listen_sock(struct sock *sk)
{
if (sk->sk_protocol == IPPROTO_TCP) {
@@ -475,7 +487,7 @@ void reuseport_stop_listen_sock(struct sock *sk)
lockdep_is_held(&reuseport_lock));
if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req) ||
- (prog && prog->expected_attach_type == BPF_SK_REUSEPORT_SELECT_OR_MIGRATE)) {
+ reuseport_is_migration_prog(prog)) {
/* Migration capable, move sk from the listening section
* to the closed section.
*/
@@ -645,7 +657,7 @@ struct sock *reuseport_migrate_sock(struct sock *sk,
hash = migrating_sk->sk_hash;
prog = rcu_dereference(reuse->prog);
- if (!prog || prog->expected_attach_type != BPF_SK_REUSEPORT_SELECT_OR_MIGRATE) {
+ if (!reuseport_is_migration_prog(prog)) {
if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_migrate_req))
goto select_by_hash;
goto failure;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 231/742] tick/sched: Make tick_nohz_full_mask and HK_TYPE_KERNEL_NOISE cpumask consistent
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (221 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 230/742] net: sock_reuseport: Check program type on the migration path Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 232/742] cgroup/rstat: disable preemption in css_rstat_updated() Greg Kroah-Hartman
` (503 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Waiman Long, Frederic Weisbecker,
Ridong Chen, Guopeng Zhang, Tejun Heo, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <longman@redhat.com>
[ Upstream commit 884e88175b95a03ea9f4dc8c89acca5d5b33cbd2 ]
When the nohz_full boot parameter is first set, the cpu list parameter is
passed directly to tick_nohz_full_setup() to set up tick_nohz_full_mask
cpumask. Then the HK_TYPE_KERNEL_NOISE cpumask will be set up as the
inverse of given cpu list parameter. Some of the timer code and RCU
uses tick_nohz_full_mask directly while other timer code, scheduler
and other subsystems use the HK_TYPE_KERNEL_NOISE cpumask.
With CONFIG_PM_SLEEP_SMP && !CONFIG_PM_SLEEP_SMP_NONZERO_CPU config
options, the boot CPU will be cleared from tick_nohz_full_mask if set
while the corresponding HK_TYPE_KERNEL_NOISE cpumask isn't touched.
The nohz_full entry in kernel-parameters.txt does state that the boot
CPU will be forced outside the range to maintain the timekeeping. So it
makes sense that the HK_TYPE_KERNEL_NOISE should be modified accordingly.
Fix this inconsistency problem by adding a new cpumask_set_cpu() init
function to be called by tick_nohz_init() when the boot CPU is cleared
from tick_nohz_full_mask.
In the special case that "nohz_full=0" and CPU 0 is cleared in
tick_nohz_init(), tick_nohz_full_running will be set to false. However,
housekeeping_enabled(HK_TYPE_KERNEL_NOISE) will stil be true with
housekeeping_cpumask(HK_TYPE_KERNEL_NOISE) equal to cpu_possible_mask.
So some unneeded code paths will be activated, but no harm will be done
other than wasting some CPU cycles.
Another problem that needs further thought but is not handled in
this patch is when arch_irq_work_has_interrupt() turns out to be
false. When this happens, tick_nohz_full_mask will be cleared and
tick_nohz_full_running will be set back to false in tick_nohz_init().
PM_SLEEP_SMP_NONZERO_CPU depends on ARCH_SUSPEND_NONZERO_CPU which can
only be set for the PowerPC architecture. Moreover CONFIG_PM_SLEEP_SMP is
on by default, it means most kernels will not allow CPU 0 to be set in
the tick_nohz_full_mask and hence should be set in HK_TYPE_KERNEL_NOISE
cpumask.
Fixes: 6f1982fedd59 ("sched/isolation: Handle the nohz_full= parameter")
Signed-off-by: Waiman Long <longman@redhat.com>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: Ridong Chen <ridong.chen@linux.dev>
Acked-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
Tested-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/sched/isolation.h | 2 ++
kernel/sched/isolation.c | 11 +++++++++++
kernel/time/tick-sched.c | 6 ++++++
3 files changed, 19 insertions(+)
diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h
index cf0fd03dd7a24..ae5109450ac92 100644
--- a/include/linux/sched/isolation.h
+++ b/include/linux/sched/isolation.h
@@ -44,6 +44,7 @@ extern bool housekeeping_enabled(enum hk_type type);
extern void housekeeping_affine(struct task_struct *t, enum hk_type type);
extern bool housekeeping_test_cpu(int cpu, enum hk_type type);
extern int housekeeping_update(struct cpumask *isol_mask);
+extern void __init housekeeping_set_cpu(int cpu, enum hk_type type);
extern void __init housekeeping_init(void);
#else
@@ -72,6 +73,7 @@ static inline bool housekeeping_test_cpu(int cpu, enum hk_type type)
}
static inline int housekeeping_update(struct cpumask *isol_mask) { return 0; }
+static inline void housekeeping_set_cpu(int cpu, enum hk_type type) { }
static inline void housekeeping_init(void) { }
#endif /* CONFIG_CPU_ISOLATION */
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 156025ef81b75..c0c8b8862cbdc 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -120,6 +120,17 @@ bool housekeeping_test_cpu(int cpu, enum hk_type type)
}
EXPORT_SYMBOL_GPL(housekeeping_test_cpu);
+void __init housekeeping_set_cpu(int cpu, enum hk_type type)
+{
+ /* Only CPU setting of HK_TYPE_KERNEL_NOISE is currently supported */
+ if (type != HK_TYPE_KERNEL_NOISE)
+ return;
+
+ if (static_branch_unlikely(&housekeeping_overridden) &&
+ READ_ONCE(housekeeping.flags) & BIT(type))
+ cpumask_set_cpu(cpu, housekeeping_cpumask_dereference(type));
+}
+
int housekeeping_update(struct cpumask *isol_mask)
{
struct cpumask *trial, *old = NULL;
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 6546e196645f2..81180573a4c51 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -22,6 +22,7 @@
#include <linux/sched/stat.h>
#include <linux/sched/nohz.h>
#include <linux/sched/loadavg.h>
+#include <linux/sched/isolation.h>
#include <linux/module.h>
#include <linux/irq_work.h>
#include <linux/posix-timers.h>
@@ -683,6 +684,11 @@ void __init tick_nohz_init(void)
pr_warn("NO_HZ: Clearing %d from nohz_full range "
"for timekeeping\n", cpu);
cpumask_clear_cpu(cpu, tick_nohz_full_mask);
+ housekeeping_set_cpu(cpu, HK_TYPE_KERNEL_NOISE);
+ if (cpumask_empty(tick_nohz_full_mask)) {
+ tick_nohz_full_running = false;
+ return;
+ }
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 232/742] cgroup/rstat: disable preemption in css_rstat_updated()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (222 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 231/742] tick/sched: Make tick_nohz_full_mask and HK_TYPE_KERNEL_NOISE cpumask consistent Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 233/742] x86/efi: Disregard the INITRD and MEMATTR config tables after kexec Greg Kroah-Hartman
` (502 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jiayuan Chen, Karl Mehltretter,
Shakeel Butt, Tejun Heo, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <kmehltretter@gmail.com>
[ Upstream commit c99f50e4acf86bfbbe313d79f281d83be1763260 ]
BPF programs can call css_rstat_updated() with preemption enabled.
The kfunc calls __css_rstat_updated(), which requires preemption to
be disabled while it queues an rstat update. A cgroup iterator can
hit the lockdep assertion on both RT and non-RT kernels. The
cgroup_hierarchical_stats selftest can also hit it on PREEMPT_RT:
spin_lock_irqsave() on trace_cgroup_path_lock leaves preemption and
interrupts enabled there.
Disable preemption in the BPF wrapper after validating the CPU and
before calling __css_rstat_updated().
Fixes: 36df6e3dbd7e ("cgroup: make css_rstat_updated nmi safe")
Reported-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Closes: https://lore.kernel.org/r/20251119111402.153727-1-jiayuan.chen@linux.dev/
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/cgroup/rstat.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index de816a43db9f0..d72fe721cea05 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -131,6 +131,7 @@ __bpf_kfunc void css_rstat_updated(struct cgroup_subsys_state *css, int cpu)
if (unlikely(cpu < 0 || cpu >= nr_cpu_ids || !cpu_possible(cpu)))
return;
+ guard(preempt)();
__css_rstat_updated(css, cpu);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 233/742] x86/efi: Disregard the INITRD and MEMATTR config tables after kexec
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (223 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 232/742] cgroup/rstat: disable preemption in css_rstat_updated() Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 234/742] efi/tpm: Allocate the event log from EFI loader data again Greg Kroah-Hartman
` (501 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ilias Apalodimas,
Jasmeet (Jazz) Bhatia, Ard Biesheuvel, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <ardb@kernel.org>
[ Upstream commit 6863183e8b65e833f8140e20d526282a725e040e ]
When the EFI stub loads the initrd itself, it describes its location and
size to the core kernel via a LINUX_EFI_INITRD_MEDIA_GUID configuration
table, which is allocated from EFI loader data, just like the initrd.
On x86, the stub passes the same information via boot_params as well,
which takes precedence, but the core kernel will fall back to the INITRD
config table if boot_params does not describe an initrd.
The EFI configuration table array is passed on to kexec'd kernels as-is,
and so a kexec'd kernel that is booted without an initrd will pick up
the INITRD config table that was installed during the original boot, and
use the initrd it describes, which no longer exists at that point.
Commit 6e62d1c6f2c7 ("efi: Wipe INITRD config table from memory after
consumption") mitigated this by wiping the base and size fields of the
table once it has been consumed. However, the memory holding the table
is released to the page allocator as well, and so it may have been
reused by the time the kexec occurs, in which case the kexec'd kernel
will interpret whatever happens to be stored there as the base and size
of the initrd, e.g.,
[ 0.000000] efi: ... INITRD=0x7c41cc18 ...
[ 0.000000] RAMDISK: [mem 0x9090909090909090-0xd1e7d1e68aaeafff]
[ 0.000000] Kernel panic - not syncing: Cannot find place for new RAMDISK of size 4708303772963442675
Crash kernels will find the stale table as well, and wipe it again, i.e.,
write to the memory of the crashed kernel that they are supposed to
capture.
Both kexec_file_load() and kexec-tools pass a SETUP_EFI setup_data entry
to the next kernel when EFI is enabled, which the x86 EFI code already
relies on to detect that it was booted via kexec. Such kernels are
entered directly, bypassing the EFI stub, and so any INITRD config table
they encounter is necessarily stale. So wire up
efi_config_table_is_usable() for x86, and use it to disregard the INITRD
config table when a SETUP_EFI setup_data entry is present.
While at it, use the same mechanism to disregard the Memory Attributes
table after kexec, which is currently achieved by overwriting its address
in the firmware's config table array with EFI_INVALID_TABLE_ADDR in
efi_reuse_config(). This only happens on 64-bit firmware, and only if
the SETUP_EFI entry carries the address of an SMBIOS table, which
kexec-tools does not provide on systems that only expose an SMBIOS3
entry point. In that case, the kexec'd kernel will parse the table, which
may be stale as well, given that EDK2 based firmware allocates it from
EFI boot services data, which is released to the page allocator after
boot too, e.g.,
[ 0.000000] efi: memattr: Unexpected EFI Memory Attributes table version -1958647317
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Jasmeet (Jazz) Bhatia <jasmeet.bhatia.us@gmail.com>
Fixes: f4dc7fffa987 ("efi: libstub: unify initrd loading between architectures")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/platform/efi/efi.c | 26 ++++++++++++++++++++++++++
arch/x86/platform/efi/quirks.c | 4 ----
include/linux/efi.h | 3 +++
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 0c39adb96b912..d74d44bf2605b 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -432,6 +432,32 @@ static int __init efi_systab_init(unsigned long phys)
return 0;
}
+/*
+ * kexec passes the firmware's config table array on to the next kernel as-is,
+ * but some of the tables it describes must be disregarded when booting via
+ * kexec, which is indicated by the presence of a SETUP_EFI setup_data entry:
+ *
+ * - The INITRD table is installed by the EFI stub to describe the initrd that
+ * it loaded. Both the table and the initrd are allocated from EFI loader
+ * data, which is released to the page allocator once the kernel is up and
+ * running, and so the table is stale by the time kexec boots the next kernel.
+ *
+ * - The Memory Attributes table may reside in EFI boot services data, which is
+ * released to the page allocator as well. Even if it is still intact, the
+ * sanity check in efi_memattr_init() may fail spuriously, given that only
+ * the runtime regions of the EFI memory map are passed on via kexec. Applying
+ * the permissions it describes is not critical, so just ignore it.
+ */
+bool __init x86_efi_config_table_is_usable(const efi_guid_t *guid,
+ unsigned long table)
+{
+ if (!efi_setup)
+ return true;
+
+ return efi_guidcmp(*guid, LINUX_EFI_INITRD_MEDIA_GUID) &&
+ efi_guidcmp(*guid, EFI_MEMORY_ATTRIBUTES_TABLE_GUID);
+}
+
static int __init efi_config_init(const efi_config_table_type_t *arch_tables)
{
void *config_tables;
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index 02c56a02eb9bc..d6d34dfa19e60 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -611,10 +611,6 @@ int __init efi_reuse_config(u64 tables, int nr_tables)
if (!efi_guidcmp(guid, SMBIOS_TABLE_GUID))
((efi_config_table_64_t *)p)->table = data->smbios;
- /* Do not bother to play with mem attr table across kexec */
- if (!efi_guidcmp(guid, EFI_MEMORY_ATTRIBUTES_TABLE_GUID))
- ((efi_config_table_64_t *)p)->table = EFI_INVALID_TABLE_ADDR;
-
p += sz;
}
early_memunmap(tablep, nr_tables * sz);
diff --git a/include/linux/efi.h b/include/linux/efi.h
index aa15ff88539bd..7cfe85e6b0b41 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -1321,10 +1321,13 @@ struct linux_efi_initrd {
#define EFI_SECRET_TABLE_HEADER_GUID EFI_GUID(0x1e74f542, 0x71dd, 0x4d66, 0x96, 0x3e, 0xef, 0x42, 0x87, 0xff, 0x17, 0x3b)
bool xen_efi_config_table_is_usable(const efi_guid_t *guid, unsigned long table);
+bool x86_efi_config_table_is_usable(const efi_guid_t *guid, unsigned long table);
static __always_inline
bool efi_config_table_is_usable(const efi_guid_t *guid, unsigned long table)
{
+ if (IS_ENABLED(CONFIG_X86) && !x86_efi_config_table_is_usable(guid, table))
+ return false;
if (!IS_ENABLED(CONFIG_XEN_EFI))
return true;
return xen_efi_config_table_is_usable(guid, table);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 234/742] efi/tpm: Allocate the event log from EFI loader data again
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (224 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 233/742] x86/efi: Disregard the INITRD and MEMATTR config tables after kexec Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 235/742] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state() Greg Kroah-Hartman
` (500 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jasmeet (Jazz) Bhatia,
Ard Biesheuvel, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <ardb@kernel.org>
[ Upstream commit cc919b0db7d322c65067801869bc6354669726dc ]
The EFI stub currently allocates the TPM event log as
EFI_ACPI_RECLAIM_MEMORY. On x86, this becomes an ACPI data entry
in the E820 map.
On a Framework Laptop 16 (AMD Ryzen AI 300 Series), the EFI allocator
can place this allocation at different physical addresses across boots.
Since x86 hibernation validates architecture-specific data from
the firmware E820 map, this causes an otherwise valid hibernation image
to be rejected on resume with the following error:
Hibernate inconsistent memory map detected!
PM: hibernation: Image mismatch: architecture specific data
Allocating the event log as EFI_LOADER_DATA avoids changing the E820
map, but doing that alone would regress the kexec corruption issue fixed
by commit 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event
log to avoid corruption"): the E820 map that kexec passes on to the next
kernel describes EFI loader data as ordinary RAM, and so the event log
may get clobbered before the next kernel gets around to reserving it.
So use the x86 implementation of efi_config_table_is_usable() to
disregard the TPM event log table after kexec, just like the INITRD
table, and go back to allocating it as EFI_LOADER_DATA. This is simpler
than preserving the event log across kexec, e.g., by installing the
memreserve table on x86 and using efi_mem_reserve_persistent(), and the
utility of the event log after kexec is questionable to begin with.
This also protects kexec'd kernels from a clobbered event log if the
previous kernel predates the change above, and allocated the table from
EFI loader data as well. The kexec issue was specific to x86, so other
architectures can use EFI loader data as before.
Tested-by: Jasmeet (Jazz) Bhatia <jasmeet.bhatia.us@gmail.com>
Fixes: 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event log to avoid corruption")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/platform/efi/efi.c | 8 ++++++++
drivers/firmware/efi/libstub/tpm.c | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index d74d44bf2605b..a649f282aacd5 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -442,6 +442,13 @@ static int __init efi_systab_init(unsigned long phys)
* data, which is released to the page allocator once the kernel is up and
* running, and so the table is stale by the time kexec boots the next kernel.
*
+ * - The TPM event log table is installed by the EFI stub too. It is allocated
+ * from EFI loader data rather than ACPI reclaim memory, as the latter would
+ * create an E820 entry that may move around between boots, which breaks
+ * resume from hibernation. It is reserved by the kernel, but the E820 map
+ * that kexec passes on describes it as ordinary RAM, and so it may get
+ * clobbered before the next kernel gets around to reserving it.
+ *
* - The Memory Attributes table may reside in EFI boot services data, which is
* released to the page allocator as well. Even if it is still intact, the
* sanity check in efi_memattr_init() may fail spuriously, given that only
@@ -455,6 +462,7 @@ bool __init x86_efi_config_table_is_usable(const efi_guid_t *guid,
return true;
return efi_guidcmp(*guid, LINUX_EFI_INITRD_MEDIA_GUID) &&
+ efi_guidcmp(*guid, LINUX_EFI_TPM_EVENT_LOG_GUID) &&
efi_guidcmp(*guid, EFI_MEMORY_ATTRIBUTES_TABLE_GUID);
}
diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
index 73f0011147323..b8183bfdbaa3d 100644
--- a/drivers/firmware/efi/libstub/tpm.c
+++ b/drivers/firmware/efi/libstub/tpm.c
@@ -96,7 +96,7 @@ static void efi_retrieve_tcg2_eventlog(int version, efi_physical_addr_t log_loca
}
/* Allocate space for the logs and copy them. */
- status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY,
+ status = efi_bs_call(allocate_pool, EFI_LOADER_DATA,
sizeof(*log_tbl) + log_size, (void **)&log_tbl);
if (status != EFI_SUCCESS) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 235/742] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (225 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 234/742] efi/tpm: Allocate the event log from EFI loader data again Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 236/742] drm/xe/hwmon: Unregister hwmon before the device is unplugged Greg Kroah-Hartman
` (499 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Borah, Chaitanya Kumar,
Rafael J. Wysocki, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[ Upstream commit 569e1eb36b033f42a9c363ffe4bfbf50bdadae51 ]
Commit eee2a44e4e2b ("cpufreq: Improve suspend-resume synchronization")
caused lockdep to complain about a possible circular locking dependency
because intel_pstate_resume() is now called under cpus_read_lock, and it
calls set_power_ctl_ee_state() that acquires intel_pstate_driver_lock
which can be held around CPU hotplug locking.
Fortunately, this cannot lead to a real deadlock because
intel_pstate_resume() does not run in parallel with the other holders
of intel_pstate_driver_lock, but in fact set_power_ctl_ee_state() need
not use that particular lock either. Moreover, the original purpose of
that lock is different, so using it in set_power_ctl_ee_state() is
questionable.
Accordingly, introduce a dedicated mutex for protecting MSR_IA32_POWER_CTL
updates and power_ctl_ee_state accesses and make set_power_ctl_ee_state()
use it instead of intel_pstate_driver_lock. Also take it directly in
intel_pstate_resume() around the EE state restore.
Fixes: eee2a44e4e2b ("cpufreq: Improve suspend-resume synchronization")
Reported-by: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
Closes: https://lore.kernel.org/linux-pm/efcb1647-46fd-442a-bbda-283560d9df53@intel.com/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/2862244.mvXUDI8C0e@rafael.j.wysocki
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/cpufreq/intel_pstate.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index d3650a6e37b54..05c0ba06e1e31 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1351,13 +1351,14 @@ static void intel_pstate_hwp_offline(struct cpudata *cpu)
/* Enable bit for Dynamic Efficiency Control (DEC) */
#define POWER_CTL_DEC_ENABLE 27
+static DEFINE_MUTEX(power_ctl_update_lock);
static int power_ctl_ee_state;
-static void set_power_ctl_ee_state(bool input)
+static void __set_power_ctl_ee_state(bool input)
{
u64 power_ctl;
- guard(mutex)(&intel_pstate_driver_lock);
+ lockdep_assert_held(&power_ctl_update_lock);
rdmsrq(MSR_IA32_POWER_CTL, power_ctl);
if (input) {
@@ -1370,6 +1371,13 @@ static void set_power_ctl_ee_state(bool input)
wrmsrq(MSR_IA32_POWER_CTL, power_ctl);
}
+static void set_power_ctl_ee_state(bool input)
+{
+ guard(mutex)(&power_ctl_update_lock);
+
+ __set_power_ctl_ee_state(input);
+}
+
static void intel_pstate_hwp_enable(struct cpudata *cpudata);
static void intel_pstate_hwp_reenable(struct cpudata *cpu)
@@ -1398,11 +1406,13 @@ static int intel_pstate_resume(struct cpufreq_policy *policy)
pr_debug("CPU %d resuming\n", cpu->cpu);
- /* Only restore if the system default is changed */
- if (power_ctl_ee_state == POWER_CTL_EE_ENABLE)
- set_power_ctl_ee_state(true);
- else if (power_ctl_ee_state == POWER_CTL_EE_DISABLE)
- set_power_ctl_ee_state(false);
+ scoped_guard(mutex, &power_ctl_update_lock) {
+ /* Only restore if the system default has changed */
+ if (power_ctl_ee_state == POWER_CTL_EE_ENABLE)
+ __set_power_ctl_ee_state(true);
+ else if (power_ctl_ee_state == POWER_CTL_EE_DISABLE)
+ __set_power_ctl_ee_state(false);
+ }
if (cpu->suspended && hwp_active) {
mutex_lock(&intel_pstate_limits_lock);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 236/742] drm/xe/hwmon: Unregister hwmon before the device is unplugged
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (226 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 235/742] cpufreq: intel_pstate: Use dedicated lock in set_power_ctl_ee_state() Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 237/742] arm64: dts: st: add PSCI idle state to STM32MP25 CPU domains Greg Kroah-Hartman
` (498 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Karthik Poosa, Michael J. Ruhl,
Rodrigo Vivi, Matthew Brost, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
[ Upstream commit 72296e02b46a34e52c8b97c5ebf95c2a970373fd ]
hwmon was registered with devm, so its sysfs attributes stayed
reachable after drm_dev_unplug() until devres teardown. A reader in
that window accesses an unplugged device, e.g. the PMT energy read
on BMG.
Unregister it explicitly in xe_device_remove() and in the probe error
path, before the device is unplugged. Removing the attributes waits
for in-flight reads, so none can run afterwards.
Cc: Karthik Poosa <karthik.poosa@intel.com>
Cc: Michael J. Ruhl <michael.j.ruhl@intel.com>
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Fixes: fb1b70607f73 ("drm/xe/hwmon: Expose power attributes")
Link: https://patch.msgid.link/20261120152753.1346010-2-rodrigo.vivi@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
(cherry picked from commit 6bae3d8f569445db5e3385b61efa5f9ba9eed3d3)
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/xe/xe_device.c | 9 ++++++---
drivers/gpu/drm/xe/xe_hwmon.c | 22 +++++++++++++++++++---
drivers/gpu/drm/xe/xe_hwmon.h | 2 ++
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 7ec5d301f9995..4e661fbf54228 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -1141,7 +1141,7 @@ int xe_device_probe(struct xe_device *xe)
err = xe_i2c_probe(xe);
if (err)
- goto err_unregister_display;
+ goto err_unregister_hwmon;
for_each_gt(gt, xe, id)
xe_gt_sanitize_freq(gt);
@@ -1150,7 +1150,7 @@ int xe_device_probe(struct xe_device *xe)
err = xe_sriov_init_late(xe);
if (err)
- goto err_unregister_display;
+ goto err_unregister_hwmon;
detect_preproduction_hw(xe);
@@ -1163,10 +1163,12 @@ int xe_device_probe(struct xe_device *xe)
err = devm_add_action_or_reset(xe->drm.dev, xe_device_sanitize, xe);
if (err)
- goto err_unregister_display;
+ goto err_unregister_hwmon;
return 0;
+err_unregister_hwmon:
+ xe_hwmon_unregister(xe);
err_unregister_display:
xe_display_unregister(xe);
drm_dev_unregister(&xe->drm);
@@ -1176,6 +1178,7 @@ int xe_device_probe(struct xe_device *xe)
void xe_device_remove(struct xe_device *xe)
{
+ xe_hwmon_unregister(xe);
xe_display_unregister(xe);
drm_dev_unplug(&xe->drm);
diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
index b47c083e52b6c..1997fd6be1746 100644
--- a/drivers/gpu/drm/xe/xe_hwmon.c
+++ b/drivers/gpu/drm/xe/xe_hwmon.c
@@ -1652,9 +1652,9 @@ int xe_hwmon_register(struct xe_device *xe)
drm_dbg(&xe->drm, "Register xe hwmon interface\n");
/* hwmon_dev points to device hwmon<i> */
- hwmon->hwmon_dev = devm_hwmon_device_register_with_info(dev, "xe", hwmon,
- &hwmon_chip_info,
- hwmon_groups);
+ hwmon->hwmon_dev = hwmon_device_register_with_info(dev, "xe", hwmon,
+ &hwmon_chip_info,
+ hwmon_groups);
if (IS_ERR(hwmon->hwmon_dev)) {
drm_err(&xe->drm, "Failed to register xe hwmon (%pe)\n", hwmon->hwmon_dev);
xe->hwmon = NULL;
@@ -1663,4 +1663,20 @@ int xe_hwmon_register(struct xe_device *xe)
return 0;
}
+
+/**
+ * xe_hwmon_unregister - Remove the hwmon interface
+ * @xe: xe device
+ *
+ * Called before the device is unplugged, so that no hwmon attribute can
+ * be accessed afterwards.
+ */
+void xe_hwmon_unregister(struct xe_device *xe)
+{
+ if (!xe->hwmon)
+ return;
+
+ hwmon_device_unregister(xe->hwmon->hwmon_dev);
+ xe->hwmon = NULL;
+}
MODULE_IMPORT_NS("INTEL_PMT_TELEMETRY");
diff --git a/drivers/gpu/drm/xe/xe_hwmon.h b/drivers/gpu/drm/xe/xe_hwmon.h
index d02c1bfe8c0a0..e67e0134f02a5 100644
--- a/drivers/gpu/drm/xe/xe_hwmon.h
+++ b/drivers/gpu/drm/xe/xe_hwmon.h
@@ -12,8 +12,10 @@ struct xe_device;
#if IS_REACHABLE(CONFIG_HWMON)
int xe_hwmon_register(struct xe_device *xe);
+void xe_hwmon_unregister(struct xe_device *xe);
#else
static inline int xe_hwmon_register(struct xe_device *xe) { return 0; };
+static inline void xe_hwmon_unregister(struct xe_device *xe) { }
#endif
#endif /* _XE_HWMON_H_ */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 237/742] arm64: dts: st: add PSCI idle state to STM32MP25 CPU domains
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (227 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 236/742] drm/xe/hwmon: Unregister hwmon before the device is unplugged Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 238/742] arm64: dts: st: add PSCI idle state to STM32MP23 " Greg Kroah-Hartman
` (497 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Patrick Delaunay, Amelie Delaunay,
Alexandre Torgue, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Delaunay <patrick.delaunay@foss.st.com>
[ Upstream commit ab4ce1d0630f677032d7e20d27c80ecfbd9960cb ]
Define a PSCI CPU suspend state and reference it from both STM32MP25
CPU power domains.
In OSI mode, PSCI power domains are initialized as off. The idle-state
allows the CPU power-domain governor to manage them, avoiding probe
stalls for devices that depend on the cluster power domain, including
SDMMC1.
Fixes: 9c8d852dabbd ("arm64: dts: st: add power domain on stm32mp25")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Tested-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/20261119185544.v2.1.Ia5e0774883d237f5825b7090962b454294922558@changeid
Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm64/boot/dts/st/stm32mp251.dtsi | 14 ++++++++++++++
arch/arm64/boot/dts/st/stm32mp253.dtsi | 1 +
2 files changed, 15 insertions(+)
diff --git a/arch/arm64/boot/dts/st/stm32mp251.dtsi b/arch/arm64/boot/dts/st/stm32mp251.dtsi
index f81fd06f4be5e..539d190d4612f 100644
--- a/arch/arm64/boot/dts/st/stm32mp251.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp251.dtsi
@@ -25,6 +25,19 @@ cpu0: cpu@0 {
power-domains = <&CPU_PD0>;
power-domain-names = "psci";
};
+
+ idle-states {
+ entry-method = "psci";
+
+ cpu_sleep: cpu-sleep {
+ compatible = "arm,idle-state";
+ arm,psci-suspend-param = <0x00000002>;
+ local-timer-stop;
+ entry-latency-us = <150>;
+ exit-latency-us = <200>;
+ min-residency-us = <1000>;
+ };
+ };
};
arm-pmu {
@@ -145,6 +158,7 @@ psci {
CPU_PD0: power-domain-cpu0 {
#power-domain-cells = <0>;
+ domain-idle-states = <&cpu_sleep>;
power-domains = <&CLUSTER_PD>;
};
diff --git a/arch/arm64/boot/dts/st/stm32mp253.dtsi b/arch/arm64/boot/dts/st/stm32mp253.dtsi
index eeceb086252bf..96483733d7a86 100644
--- a/arch/arm64/boot/dts/st/stm32mp253.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp253.dtsi
@@ -26,6 +26,7 @@ arm-pmu {
psci {
CPU_PD1: power-domain-cpu1 {
#power-domain-cells = <0>;
+ domain-idle-states = <&cpu_sleep>;
power-domains = <&CLUSTER_PD>;
};
};
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 238/742] arm64: dts: st: add PSCI idle state to STM32MP23 CPU domains
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (228 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 237/742] arm64: dts: st: add PSCI idle state to STM32MP25 CPU domains Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 239/742] arm64: dts: st: mark STM32MP23 timer as stopping in suspend Greg Kroah-Hartman
` (496 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Patrick Delaunay, Amelie Delaunay,
Alexandre Torgue, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Delaunay <patrick.delaunay@foss.st.com>
[ Upstream commit 0818ec0de18627ff7d2306e5c2843a0358960874 ]
Define a PSCI CPU suspend state and reference it from both STM32MP23
CPU power domains.
In OSI mode, PSCI power domains are initialized as off. The idle-state
allows the CPU power-domain governor to manage them, avoiding probe
stalls for devices that depend on the cluster power domain, including
SDMMC1.
Fixes: e9b03ef21386 ("arm64: dts: st: introduce stm32mp23 SoCs family")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/all/20261030102907.1.I0ef2a7ac525ef18fa683368382d93e98cc36ee25@changeid/
Link: https://lore.kernel.org/r/20261119184209.v2.1.If2b6b99285c1e60ca11b6e7fccf7d9b130ca20dd@changeid
Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm64/boot/dts/st/stm32mp231.dtsi | 14 ++++++++++++++
arch/arm64/boot/dts/st/stm32mp233.dtsi | 1 +
2 files changed, 15 insertions(+)
diff --git a/arch/arm64/boot/dts/st/stm32mp231.dtsi b/arch/arm64/boot/dts/st/stm32mp231.dtsi
index 0eca3ca6a781a..ea4d230332d74 100644
--- a/arch/arm64/boot/dts/st/stm32mp231.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp231.dtsi
@@ -24,6 +24,19 @@ cpu0: cpu@0 {
power-domains = <&cpu0_pd>;
power-domain-names = "psci";
};
+
+ idle-states {
+ entry-method = "psci";
+
+ cpu_sleep: cpu-sleep {
+ compatible = "arm,idle-state";
+ arm,psci-suspend-param = <0x00000002>;
+ local-timer-stop;
+ entry-latency-us = <150>;
+ exit-latency-us = <200>;
+ min-residency-us = <1000>;
+ };
+ };
};
arm-pmu {
@@ -123,6 +136,7 @@ psci {
cpu0_pd: power-domain-cpu0 {
#power-domain-cells = <0>;
+ domain-idle-states = <&cpu_sleep>;
power-domains = <&cluster_pd>;
};
diff --git a/arch/arm64/boot/dts/st/stm32mp233.dtsi b/arch/arm64/boot/dts/st/stm32mp233.dtsi
index 78f4059fca5db..cebefd99906f6 100644
--- a/arch/arm64/boot/dts/st/stm32mp233.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp233.dtsi
@@ -26,6 +26,7 @@ arm-pmu {
psci {
cpu1_pd: power-domain-cpu1 {
#power-domain-cells = <0>;
+ domain-idle-states = <&cpu_sleep>;
power-domains = <&cluster_pd>;
};
};
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 239/742] arm64: dts: st: mark STM32MP23 timer as stopping in suspend
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (229 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 238/742] arm64: dts: st: add PSCI idle state to STM32MP23 " Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 240/742] ARM: dts: stm32: Fix STM32MP15xx DHCOM SoM PicoITX overlay application Greg Kroah-Hartman
` (495 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Patrick Delaunay, Amelie Delaunay,
Alexandre Torgue, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Delaunay <patrick.delaunay@foss.st.com>
[ Upstream commit 9eb9bea92c7ea2a8886eeab01cdfe4365bee0328 ]
The generic ARM timer, based on STGEN, stops ticking in low-power
states such as Stop1. Replace the always-on property with
arm,no-tick-in-suspend in the STM32MP23 timer node, matching the
STM32MP25 configuration.
Fixes: e9b03ef21386 ("arm64: dts: st: introduce stm32mp23 SoCs family")
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Link: https://lore.kernel.org/r/20261030102907.1.I0ef2a7ac525ef18fa683368382d93e98cc36ee25@changeid
Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm64/boot/dts/st/stm32mp231.dtsi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/boot/dts/st/stm32mp231.dtsi b/arch/arm64/boot/dts/st/stm32mp231.dtsi
index ea4d230332d74..457639fcc3e7e 100644
--- a/arch/arm64/boot/dts/st/stm32mp231.dtsi
+++ b/arch/arm64/boot/dts/st/stm32mp231.dtsi
@@ -157,7 +157,7 @@ timer {
<GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>,
<GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>,
<GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>;
- always-on;
+ arm,no-tick-in-suspend;
};
soc@0 {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 240/742] ARM: dts: stm32: Fix STM32MP15xx DHCOM SoM PicoITX overlay application
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (230 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 239/742] arm64: dts: st: mark STM32MP23 timer as stopping in suspend Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 241/742] drm/ttm/tests: do not count pages after pools teardown Greg Kroah-Hartman
` (494 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Marek Vasut, Alexandre Torgue,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <marex@nabladev.com>
[ Upstream commit add40017961d3f07b36bad48840aaecf57128150 ]
Generate the combined STM32MP15xx DHCOM SoM PicoITX and overlay from
PicoITX instead of PDK2. Fix the Makefile to use the correct base DT.
Fixes: 77a5fde00b9a ("ARM: dts: stm32: Add DT overlays for DH STM32MP13xx/STM32MP15xx DHSOM")
Signed-off-by: Marek Vasut <marex@nabladev.com>
Link: https://lore.kernel.org/r/20261102052306.868349-1-marex@nabladev.com
Signed-off-by: Alexandre Torgue <alexandre.torgue@foss.st.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm/boot/dts/st/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/st/Makefile b/arch/arm/boot/dts/st/Makefile
index 10c5d75f6169c..f699d37254e24 100644
--- a/arch/arm/boot/dts/st/Makefile
+++ b/arch/arm/boot/dts/st/Makefile
@@ -94,11 +94,11 @@ stm32mp15xx-dhcom-picoitx-overlay-548-200-x2-mi0700s4t-6-dtbs := \
stm32mp15xx-dhcom-picoitx-overlay-548-200-x2-mi0700s4t-6.dtbo \
stm32mp15xx-dhcom-picoitx-overlay-553-100-x2-tst043015cmhx-dtbs := \
- stm32mp157c-dhcom-pdk2.dtb \
+ stm32mp157c-dhcom-picoitx.dtb \
stm32mp15xx-dhcom-picoitx-overlay-553-100-x2-tst043015cmhx.dtbo \
stm32mp15xx-dhcom-picoitx-overlay-626-100-x2-ch101olhlwh-dtbs := \
- stm32mp157c-dhcom-pdk2.dtb \
+ stm32mp157c-dhcom-picoitx.dtb \
stm32mp15xx-dhcom-picoitx-overlay-626-100-x2-ch101olhlwh.dtbo \
dtb-$(CONFIG_ARCH_STM32) += \
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 241/742] drm/ttm/tests: do not count pages after pools teardown
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (231 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 240/742] ARM: dts: stm32: Fix STM32MP15xx DHCOM SoM PicoITX overlay application Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 242/742] ftrace: Fix lost recursion records in ftrace_record_recursion() Greg Kroah-Hartman
` (493 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ian Forbes, Christian König,
Michał Grzelak, Dave Airlie, Rodrigo Vivi, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michał Grzelak <michal.grzelak@linux.intel.com>
[ Upstream commit cb9809483c7f08c8333833ecac11188e41bcc3c9 ]
Currently ttm_pool_fini_basic() checks if page count of pool-type's lru
list is zero after tearing down its pre-populated pool.
After commit 5ffdc8f83613 ("ttm/pool: Don't leak LRU list on shutdown")
this check causes NULL dereference because page's lru list is destroyed
during pool's teardown which leads to KUnit's crash:
[20:08:24] ========== [PASSED] ttm_pool_alloc_basic_dma_addr ==========
[20:08:24] [PASSED] ttm_pool_alloc_order_caching_match
[20:08:24] [PASSED] ttm_pool_alloc_caching_mismatch
[20:08:24] [PASSED] ttm_pool_alloc_order_mismatch
[20:08:24] [PASSED] ttm_pool_free_dma_alloc
[20:08:24] [PASSED] ttm_pool_free_no_dma_alloc
[20:08:25] [ERROR] Test: ttm_pool: missing expected subtest!
[20:08:25]
[20:08:25] Pid: 80, comm: kunit_try_catch Tainted: G W N 7.4.0-rc4-g401a3e7b64d1
[20:08:25] RIP: 0033:list_lru_count_node+0xe/0x20
[20:08:25] RSP: 00000000a08dbef8 EFLAGS: 00010246
[20:08:25] RAX: 0000000000000001 RBX: 00000000a0803c70 RCX: 0000000000000020
[20:08:25] RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000000060853030
[20:08:25] RBP: 0000000060853000 R08: 00000000a08dbe98 R09: 00000000601246ac
[20:08:25] R10: 000000009f227d00 R11: 0000000000000000 R12: 0000000060124640
[20:08:25] R13: 0000000060853030 R14: 000000006047c950 R15: 00000000604c6488
[20:08:25] Kernel panic - not syncing: Segfault with no mm
[20:08:25] [CRASHED]
[20:08:25] [ERROR] Test: ttm_pool: missing subtest result line!
[20:08:25] # module: ttm_pool_test
[20:08:25] ==================== [CRASHED] ttm_pool ====================
[20:08:25] [ERROR] Test: main: missing expected subtest!
[20:08:25] [CRASHED]
[20:08:25] [ERROR] Test: main: missing expected subtest!
[20:08:25] [CRASHED]
[20:08:25] [ERROR] Test: main: missing expected subtest!
[20:08:25] [CRASHED]
[20:08:25] [ERROR] Test: main: missing expected subtest!
[20:08:25] [CRASHED]
[20:08:25] ============================================================
[20:08:25] Testing complete. Ran 28 tests: passed: 23, crashed: 5, errors: 6
The crash in turn prevents Xe CI from running IGT.
Drop the post-teardown assertion.
Fixes: 5ffdc8f83613 ("ttm/pool: Don't leak LRU list on shutdown")
Cc: Ian Forbes <ian.forbes@broadcom.com>
Cc: Christian König <christian.koenig@amd.com>
Signed-off-by: Michał Grzelak <michal.grzelak@linux.intel.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20261124004312.3880264-2-michal.grzelak@linux.intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/ttm/tests/ttm_pool_test.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/gpu/drm/ttm/tests/ttm_pool_test.c b/drivers/gpu/drm/ttm/tests/ttm_pool_test.c
index be75c8abf3883..dab03dd6c9dd7 100644
--- a/drivers/gpu/drm/ttm/tests/ttm_pool_test.c
+++ b/drivers/gpu/drm/ttm/tests/ttm_pool_test.c
@@ -401,8 +401,6 @@ static void ttm_pool_fini_basic(struct kunit *test)
KUNIT_ASSERT_FALSE(test, !list_lru_count(&pt->pages));
ttm_pool_fini(pool);
-
- KUNIT_ASSERT_TRUE(test, !list_lru_count(&pt->pages));
}
static struct kunit_case ttm_pool_test_cases[] = {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 242/742] ftrace: Fix lost recursion records in ftrace_record_recursion()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (232 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 241/742] drm/ttm/tests: do not count pages after pools teardown Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 243/742] ASoC: aw88166: fix backup restoring the RE value instead of saving it Greg Kroah-Hartman
` (492 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Andrea Parri, Steven Rostedt,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Parri <parri.andrea@gmail.com>
[ Upstream commit 7792e21d0a6e2fa819209949e8ba957504bedcd4 ]
cached_function is set to the current ip before the cmpxchg() that
claims a slot in recursed_functions[]. When that cmpxchg() loses a
race for the same slot, the code bumps index and retries via "goto
again", but the retry immediately matches its own cached_function
write and returns without ever reaching the bumped-index cmpxchg().
Concretely, for two writers racing on the same index:
CPU 0 (ip = A) CPU 1 (ip = B)
-------------- --------------
cmpxchg(&recursed_functions[index].ip,
0, B); // succeeds
cached_function = A;
cmpxchg(&recursed_functions[index].ip,
0, A);
// fails, old == B
index++;
goto again;
if (A == cached_function) // true: matches A's own store
return; // A is dropped, not retried
Once dropped this way, cached_function stays set to A, so every later
recursion of A also hits the fast path and returns before reaching the
retry, until some unrelated ip overwrites the cache.
Set cached_function only after the cmpxchg() has claimed the slot. The
retry path then leaves the cache untouched and no longer matches its
own store. When the cmpxchg() finds ip already present, the writer
that installed it sets the cache.
The bug was found with the help of an LLM.
Link: https://patch.msgid.link/20261026182553.221141-1-parri.andrea@gmail.com
Fixes: 773c16705058e ("ftrace: Add recording of functions that caused recursion")
Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/trace/trace_recursion_record.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/kernel/trace/trace_recursion_record.c b/kernel/trace/trace_recursion_record.c
index bac4bc844ccd8..4f63bec052fca 100644
--- a/kernel/trace/trace_recursion_record.c
+++ b/kernel/trace/trace_recursion_record.c
@@ -17,8 +17,8 @@ static struct recursed_functions recursed_functions[CONFIG_FTRACE_RECORD_RECURSI
static atomic_t nr_records;
/*
- * Cache the last found function. Yes, updates to this is racey, but
- * so is memory cache ;-)
+ * Cache the last function found in or added to recursed_functions[].
+ * Updates to this are racy, but this is only a best-effort cache.
*/
static unsigned long cached_function;
@@ -67,24 +67,25 @@ void ftrace_record_recursion(unsigned long ip, unsigned long parent_ip)
}
}
- cached_function = ip;
-
/*
* We only want to add a function if it hasn't been added before.
- * Add to the current location before incrementing the count.
- * If it fails to add, then increment the index (save in i)
- * and try again.
+ * Claim the current slot before incrementing the count. If the slot
+ * is occupied by another function, advance to the next slot and retry.
+ *
+ * Do not update cached_function until ip is known to be present;
+ * otherwise the retry would match its own cache update.
*/
old = cmpxchg(&recursed_functions[index].ip, 0, ip);
if (old != 0) {
/* Did something else already added this for us? */
if (old == ip)
return;
- /* Try the next location (use i for the next index) */
+ /* Try the next location */
index++;
goto again;
}
+ cached_function = ip;
recursed_functions[index].parent_ip = parent_ip;
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 243/742] ASoC: aw88166: fix backup restoring the RE value instead of saving it
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (233 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 242/742] ftrace: Fix lost recursion records in ftrace_record_recursion() Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 244/742] KEYS: trusted: caam: propagate protected key option parsing errors Greg Kroah-Hartman
` (491 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Marco Giunta, Mark Brown,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Giunta <marco_giunta@outlook.it>
[ Upstream commit b0d43948d45bef795e4769b88179ba598382bc4f ]
aw_dev_backup_sec_record() saves the VCALB and RE values so that
aw_dev_backup_sec_recovery() can restore them later. However, it passes
AW88166_RECOVERY_SEC_DATA for RE, so instead of reading ACR1/ACR2 it
writes the stored value back to them.
Pass AW88166_RECORD_SEC_DATA instead, as the vendor aw883xx driver does.
Fixes: 94e412c28e61 ("ASoC: codecs: Add aw88166 amplifier driver")
Signed-off-by: Marco Giunta <marco_giunta@outlook.it>
Link: https://patch.msgid.link/SN6PR19MB230389321D29F0C88582B4F6FC452@SN6PR19MB2303.namprd19.prod.outlook.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/codecs/aw88166.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/aw88166.c b/sound/soc/codecs/aw88166.c
index d2a138211c596..010a74ebc99a8 100644
--- a/sound/soc/codecs/aw88166.c
+++ b/sound/soc/codecs/aw88166.c
@@ -404,7 +404,7 @@ static int aw_dev_init_re_update(struct aw88166 *aw88166, int flag)
static void aw_dev_backup_sec_record(struct aw88166 *aw88166)
{
aw_dev_init_vcalb_update(aw88166, AW88166_RECORD_SEC_DATA);
- aw_dev_init_re_update(aw88166, AW88166_RECOVERY_SEC_DATA);
+ aw_dev_init_re_update(aw88166, AW88166_RECORD_SEC_DATA);
}
static void aw_dev_backup_sec_recovery(struct aw88166 *aw88166)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 244/742] KEYS: trusted: caam: propagate protected key option parsing errors
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (234 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 243/742] ASoC: aw88166: fix backup restoring the RE value instead of saving it Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 245/742] workqueue: Skip redundant unbound updates during CPU bringup Greg Kroah-Hartman
` (490 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Keisuke Tsukuda, Serge Hallyn,
Jarkko Sakkinen, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keisuke Tsukuda <tkdkei@outlook.jp>
[ Upstream commit 1bbbf65c75064aeaff793b7bc218f12c53cbe1a9 ]
get_pkey_options() returns -EINVAL for invalid protected key options,
such as "key_enc_algo=GG". trusted_caam_seal() and trusted_caam_unseal()
ignore this error and return 0. The trusted key core then instantiates
a key without a blob for "new", or with a zero-length key for "load".
On an i.MX6Q running a 7.4.0-rc2-based kernel, adding a key with
"new 32 pk key_enc_algo=GG" succeeds, but KEYCTL_READ returns zero
bytes because no blob was created. The key cannot be saved and
reloaded.
Return the parsing error from both paths. On the patched kernel,
"new" and "load" with "key_enc_algo=GG" both fail with -EINVAL, while
valid requests succeed.
Fixes: a703a4c2a328 ("KEYS: trusted: caam based protected key")
Signed-off-by: Keisuke Tsukuda <tkdkei@outlook.jp>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Link: https://lore.kernel.org/r/20261124155310.32044-1-tkdkei@outlook.jp
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
security/keys/trusted-keys/trusted_caam.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/keys/trusted-keys/trusted_caam.c b/security/keys/trusted-keys/trusted_caam.c
index 6a33dbf2a7f55..33000d7bb1cca 100644
--- a/security/keys/trusted-keys/trusted_caam.c
+++ b/security/keys/trusted-keys/trusted_caam.c
@@ -110,7 +110,7 @@ static int trusted_caam_seal(struct trusted_key_payload *p, char *datablob)
info.pkey_info.is_pkey = 1;
ret = get_pkey_options(datablob, &info.pkey_info);
if (ret < 0)
- return 0;
+ return ret;
dump_options(&info.pkey_info);
}
@@ -142,7 +142,7 @@ static int trusted_caam_unseal(struct trusted_key_payload *p, char *datablob)
info.pkey_info.is_pkey = 1;
ret = get_pkey_options(datablob, &info.pkey_info);
if (ret < 0)
- return 0;
+ return ret;
dump_options(&info.pkey_info);
p->key_len = p->blob_len + sizeof(struct caam_pkey_info);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 245/742] workqueue: Skip redundant unbound updates during CPU bringup
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (235 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 244/742] KEYS: trusted: caam: propagate protected key option parsing errors Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 246/742] eth: bnxt_en: restore Rx coalescing after re-allocating the completion ring Greg Kroah-Hartman
` (489 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Saurabh Sengar, Tejun Heo,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saurabh Sengar <ssengar@linux.microsoft.com>
[ Upstream commit edf1066ba69c89c42c3007e4230c7b9cb13405a8 ]
Before workqueue_init_topology(), all CPUs share the SYSTEM pod,
which contains every possible CPU. The effective cpumask and the
per-pod cpumask of an unbound workqueue are therefore identical,
regardless of which CPUs are online.
During this stage, workqueue_online_cpu() walks every possible CPU for
every unbound workqueue each time a secondary CPU comes online. The
pwq mappings cannot change yet, so this repeats redundant work that
scales quadratically with CPU count.
On a 640-vCPU Hyper-V VM, each of the 639 secondary CPU-online
callbacks walks all 640 possible CPUs for each of the 8 unbound
workqueues, giving 3,271,680 unbound_wq_update_pwq() calls that took
about 975 ms in total.
Skip these updates until workqueue_init_topology(). The pwq mappings
already match the effective cpumask, and wq_update_node_max_active()
does nothing before topology initialization. workqueue_init_topology()
will apply the topology-specific mappings and node limits once ready.
Keep worker rebinding and restoration of unbound worker affinity before
the guard. CPU hotplug after topology initialization is unchanged.
On the same VM running a v7.3 kernel, smp_init() took 1054 ms with this
change, compared to 2008 ms without it, a 47.5% reduction.
Before After Reduction
smp_init() 2008 ms 1054 ms 47.5%
Fixes: 84193c07105c ("workqueue: Generalize unbound CPU pods")
Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/workqueue.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index c1cb328bce3c7..e545a34857f45 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -6978,6 +6978,14 @@ int workqueue_online_cpu(unsigned int cpu)
mutex_unlock(&wq_pool_attach_mutex);
}
+ /*
+ * Before topology initialization, the SYSTEM pod covers all possible
+ * CPUs, so CPU onlining does not require updating pwq mappings.
+ * wq_update_node_max_active() also returns early at this stage.
+ */
+ if (!wq_topo_initialized)
+ goto out_unlock;
+
/* update pod affinity of unbound workqueues */
list_for_each_entry(wq, &workqueues, list) {
struct workqueue_attrs *attrs = wq->attrs;
@@ -6995,6 +7003,7 @@ int workqueue_online_cpu(unsigned int cpu)
}
}
+out_unlock:
mutex_unlock(&wq_pool_mutex);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 246/742] eth: bnxt_en: restore Rx coalescing after re-allocating the completion ring
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (236 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 245/742] workqueue: Skip redundant unbound updates during CPU bringup Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 247/742] eth: bnxt_en: restore Tx " Greg Kroah-Hartman
` (488 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jakub Kicinski, Pavan Chebbi,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <kuba@kernel.org>
[ Upstream commit a6ea69915a230d24e9d9cd8dc0ff0551dab36106 ]
With TPH enabled, queue restart frees and re-allocates the Rx
completion ring in the FW, to apply the new Steering Tag. The new
FW ring starts with default interrupt coalescing parameters. The
driver programs coalescing only at open, from ethtool and from DIM,
so after a restart the ring ignores the configured settings, while
ethtool keeps reporting them.
Re-program Rx coalescing of the ring after allocating it. Use DIM's
current profile if adaptive coalescing is enabled, the static
settings otherwise. The per-ring DIM values may be stale when DIM is
off, ethtool changes to static coalescing don't update them.
With rx-usecs 1000, re-allocating the ring on a BCM57508 lowers the
latency of a 1 byte ping-pong on that queue by ~250us. Latency goes
back up once ethtool re-programs coalescing.
Fixes: 6b6bf60fc95f ("bnxt_en: Reallocate RX completion ring for TPH support")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Link: https://patch.msgid.link/20261120034645.364630-1-kuba@kernel.org
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 24 +++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index ab932f7d0d76a..a2a8087bc4287 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -8619,6 +8619,25 @@ int bnxt_hwrm_set_coal(struct bnxt *bp)
return rc;
}
+/* Program Rx coalescing of a single ring, e.g. after its completion ring
+ * was re-allocated in the FW, which resets the coalescing parameters.
+ */
+static int bnxt_hwrm_set_rx_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi)
+{
+ struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req;
+ int rc;
+
+ if (bp->flags & BNXT_FLAG_DIM)
+ return bnxt_hwrm_set_ring_coal(bp, bnapi);
+
+ rc = hwrm_req_init(bp, req, HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS);
+ if (rc)
+ return rc;
+
+ bnxt_hwrm_set_coal_params(bp, &bp->rx_coal, req);
+ return bnxt_hwrm_set_rx_coal(bp, bnapi, req);
+}
+
static void bnxt_hwrm_stat_ctx_free(struct bnxt *bp)
{
struct hwrm_stat_ctx_clr_stats_input *req0 = NULL;
@@ -16632,6 +16651,11 @@ static int bnxt_queue_start(struct net_device *dev,
rc = bnxt_hwrm_cp_ring_alloc_p5(bp, rxr->rx_cpr);
if (rc)
goto err_reset;
+
+ rc = bnxt_hwrm_set_rx_ring_coal(bp, bnapi);
+ if (rc)
+ netdev_warn(bp->dev, "HWRM set coalescing failure rc: %d\n",
+ rc);
}
rc = bnxt_hwrm_rx_agg_ring_alloc(bp, rxr);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 247/742] eth: bnxt_en: restore Tx coalescing after re-allocating the completion ring
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (237 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 246/742] eth: bnxt_en: restore Rx coalescing after re-allocating the completion ring Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 248/742] net: dsa: b53: initialize the jumbo frame size register offset Greg Kroah-Hartman
` (487 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jakub Kicinski, Pavan Chebbi,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <kuba@kernel.org>
[ Upstream commit 32756b82fde8f6cc98b174fdcd02c2a61033e263 ]
With TPH enabled, queue restart also frees and re-allocates the Tx
completion rings which share the NAPI instance with the Rx queue.
Same as on the Rx side, the new FW rings start with default interrupt
coalescing parameters, and the configured settings are applied again
only at the next open or ethtool change.
On P5+ chips the Tx completion rings are separate from the Rx ones
even in combined channels, and the Tx settings do take effect. On a
BCM57508 the completion latency of sparse Tx traffic follows
tx-usecs, it's ~20us with tx-usecs 1 and ~220us with tx-usecs 200.
Re-program Tx coalescing of each completion ring after allocating it.
DIM only manages Rx, the static settings always apply to Tx.
Fixes: fe96d717d38e ("bnxt_en: Extend queue stop/start for TX rings")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Link: https://patch.msgid.link/20261120034645.364630-2-kuba@kernel.org
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index a2a8087bc4287..85563a90ecdfe 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -8638,6 +8638,24 @@ static int bnxt_hwrm_set_rx_ring_coal(struct bnxt *bp, struct bnxt_napi *bnapi)
return bnxt_hwrm_set_rx_coal(bp, bnapi, req);
}
+/* Program Tx coalescing of the completion ring of a single Tx ring, e.g.
+ * after it was re-allocated in the FW.
+ */
+static int bnxt_hwrm_set_tx_ring_coal(struct bnxt *bp,
+ struct bnxt_tx_ring_info *txr)
+{
+ struct hwrm_ring_cmpl_ring_cfg_aggint_params_input *req;
+ int rc;
+
+ rc = hwrm_req_init(bp, req, HWRM_RING_CMPL_RING_CFG_AGGINT_PARAMS);
+ if (rc)
+ return rc;
+
+ bnxt_hwrm_set_coal_params(bp, &bp->tx_coal, req);
+ req->ring_id = cpu_to_le16(bnxt_cp_ring_for_tx(bp, txr));
+ return hwrm_req_send(bp, req);
+}
+
static void bnxt_hwrm_stat_ctx_free(struct bnxt *bp)
{
struct hwrm_stat_ctx_clr_stats_input *req0 = NULL;
@@ -11858,6 +11876,11 @@ static int bnxt_tx_queue_start(struct bnxt *bp, int idx)
if (rc)
return rc;
+ rc = bnxt_hwrm_set_tx_ring_coal(bp, txr);
+ if (rc)
+ netdev_warn(bp->dev, "HWRM set coalescing failure rc: %d\n",
+ rc);
+
rc = bnxt_hwrm_tx_ring_alloc(bp, txr, false);
if (rc)
return rc;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 248/742] net: dsa: b53: initialize the jumbo frame size register offset
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (238 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 247/742] eth: bnxt_en: restore Tx " Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 249/742] net: dsa: b53: fix the SRAB grant timeout check Greg Kroah-Hartman
` (486 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jonas Gorski, Florian Fainelli,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <florian.fainelli@broadcom.com>
[ Upstream commit 5d30a02245c375a9c5e557b1b7476710c4a94a2d ]
The chip data specifies both the jumbo port mask and frame size register
offsets, but b53_switch_init() only copies the former into the device.
Since the device is zero-initialized, b53_set_jumbo() writes the frame
size to offset zero instead of the chip-specific size register at 0x05
or 0x08.
Copy jumbo_size_reg from the chip data along with jumbo_pm_reg so frame
size updates reach the intended register.
Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/dsa/b53/b53_common.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index a2a5754c413c6..ca2ba8c157b70 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -3172,6 +3172,7 @@ static int b53_switch_init(struct b53_device *dev)
dev->vta_regs[1] = chip->vta_regs[1];
dev->vta_regs[2] = chip->vta_regs[2];
dev->jumbo_pm_reg = chip->jumbo_pm_reg;
+ dev->jumbo_size_reg = chip->jumbo_size_reg;
dev->imp_port = chip->imp_port;
dev->num_vlans = chip->vlans;
dev->num_arl_bins = chip->arl_bins;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 249/742] net: dsa: b53: fix the SRAB grant timeout check
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (239 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 248/742] net: dsa: b53: initialize the jumbo frame size register offset Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 250/742] net: dsa: b53: clear stale state when creating an ARL entry Greg Kroah-Hartman
` (485 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jonas Gorski, Daniel Machon,
Florian Fainelli, Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <florian.fainelli@broadcom.com>
[ Upstream commit bd7fc60896b3de8ce677142142c96277377e5167 ]
b53_srab_request_grant() polls for a grant up to 20 times, but checks for
an iteration count of five to detect a timeout. This rejects a grant
received on the sixth poll and reports success when all 20 polls finish
without a grant. The latter allows a register access to proceed without
ownership of the switch resources.
Check for exhaustion of all 20 iterations instead.
Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")
Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/dsa/b53/b53_srab.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/b53/b53_srab.c b/drivers/net/dsa/b53/b53_srab.c
index b9939bbd2cd51..eafd1dfaaf9d1 100644
--- a/drivers/net/dsa/b53/b53_srab.c
+++ b/drivers/net/dsa/b53/b53_srab.c
@@ -105,7 +105,7 @@ static int b53_srab_request_grant(struct b53_device *dev)
break;
usleep_range(10, 100);
}
- if (WARN_ON(i == 5))
+ if (WARN_ON(i == 20))
return -EIO;
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 250/742] net: dsa: b53: clear stale state when creating an ARL entry
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (240 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 249/742] net: dsa: b53: fix the SRAB grant timeout check Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 251/742] net: dsa: b53: use the correct override register 2 Gbps bit Greg Kroah-Hartman
` (484 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Willem de Bruijn,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <florian.fainelli@broadcom.com>
[ Upstream commit c6f0992ff6c2c138ffb1b64f406a66d42615770b ]
When an ARL lookup does not find the requested MAC and VID, b53_arl_read()
returns the first free bin index but leaves the entry populated with the
last bin examined. The multicast add path then ORs the requested port into
that unrelated entry's forwarding bitmap, potentially forwarding packets
to ports which are not members of the multicast group.
Clear the entry before creating a new one. Also return without writing
anything when deleting an entry which is not present, instead of writing
back stale bin contents. The return value for that case is unchanged (0).
Fixes: 5d65b64a3d97 ("net: dsa: b53: Add support for MDB")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/dsa/b53/b53_common.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index ca2ba8c157b70..cc42b2a4870ae 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -2055,9 +2055,13 @@ static int b53_arl_op(struct b53_device *dev, int op, int port,
addr, vid);
return is_valid ? ret : 0;
case -ENOENT:
+ if (!is_valid)
+ return 0;
+
/* We could not find a matching MAC, so reset to a new entry */
dev_dbg(dev->dev, "{%pM,%.4d} not found, using idx: %d\n",
addr, vid, idx);
+ memset(&ent, 0, sizeof(ent));
break;
default:
dev_dbg(dev->dev, "{%pM,%.4d} found, using idx: %d\n",
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 251/742] net: dsa: b53: use the correct override register 2 Gbps bit
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (241 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 250/742] net: dsa: b53: clear stale state when creating an ARL entry Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 252/742] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365 Greg Kroah-Hartman
` (483 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jonas Gorski, Florian Fainelli,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <florian.fainelli@broadcom.com>
[ Upstream commit fd2752aac6c2193507af2e96cfc1406b28cade6f ]
The IMP and per-port GMII override registers swap the override-enable and 2
Gbps speed bits. Using the IMP speed bit on a GMII port clears its override
enable and leaves any previous 2 Gbps selection intact. Select the speed
bit alongside the register and enable bit so lower speeds clear the correct
bit and 2 Gbps sets it.
Fixes: b6a8a5477fe9 ("net: dsa: b53: fix resetting speed and pause on forced link")
Fixes: 41af38324341 ("net: dsa: b53: restore the NSP IMP port 2 Gbps mode")
Reviewed-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/dsa/b53/b53_common.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index cc42b2a4870ae..0cb1fa6378aff 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1427,17 +1427,19 @@ static void b53_force_port_config(struct b53_device *dev, int port,
int speed, int duplex,
bool tx_pause, bool rx_pause)
{
- u8 reg, val, off;
+ u8 reg, val, off, speed2000;
/* Override the port settings */
if (port == dev->imp_port) {
off = B53_PORT_OVERRIDE_CTRL;
val = PORT_OVERRIDE_EN;
+ speed2000 = PORT_OVERRIDE_SPEED_2000M;
} else if (is5325(dev)) {
return;
} else {
off = B53_GMII_PORT_OVERRIDE_CTRL(port);
val = GMII_PO_EN;
+ speed2000 = GMII_PO_SPEED_2000M;
}
b53_read8(dev, B53_CTRL_PAGE, off, ®);
@@ -1449,11 +1451,12 @@ static void b53_force_port_config(struct b53_device *dev, int port,
reg &= ~(0x3 << GMII_PO_SPEED_S);
if (is5301x(dev) || is58xx(dev))
- reg &= ~PORT_OVERRIDE_SPEED_2000M;
+ reg &= ~speed2000;
switch (speed) {
case 2000:
- reg |= PORT_OVERRIDE_SPEED_2000M;
+ if (is5301x(dev) || is58xx(dev))
+ reg |= speed2000;
fallthrough;
case SPEED_1000:
reg |= PORT_OVERRIDE_SPEED_1000M;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 252/742] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (242 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 251/742] net: dsa: b53: use the correct override register 2 Gbps bit Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 253/742] net: dsa: b53: fix mirror destination and source state tracking Greg Kroah-Hartman
` (482 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Willem de Bruijn,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <florian.fainelli@broadcom.com>
[ Upstream commit 000d468855945953c491810f97fb0bd4166b0b07 ]
BCM5325 and BCM5365 use an 11-bit bitmap for the mirror capture port,
whereas newer switches use a four-bit port ID. Programming the port
number directly can select no destination or the wrong destination, and
can select multiple destinations. For example, port 2 requires BIT(2),
but writing 2 selects port 1 instead.
Use the bitmap encoding on BCM5325 and BCM5365, including translating
logical CPU port 5 to hardware bit 8. Apply the corresponding field mask
when checking for a conflicting destination, replacing the destination,
and clearing it after the last mirror source is removed. Keep the port ID
encoding for newer switches.
The ingress and egress mirror source masks use the same layout on these
switches, with the CPU port at bit 8 and bits 5-7 reserved, so apply the
same translation when setting and clearing a source port bit.
Fixes: ed3af5fd08eb ("net: dsa: b53: Add support for port mirroring")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/dsa/b53/b53_common.c | 35 +++++++++++++++++++++++++++-----
drivers/net/dsa/b53/b53_regs.h | 1 +
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 0cb1fa6378aff..7638bf95b5ab2 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -2604,6 +2604,31 @@ enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds, int port,
}
EXPORT_SYMBOL(b53_get_tag_protocol);
+static u16 b53_mirror_capture_port_mask(struct b53_device *dev)
+{
+ if (is5325(dev) || is5365(dev))
+ return CAP_PORT_MASK_25;
+
+ return CAP_PORT_MASK;
+}
+
+static u16 b53_mirror_port_mask(struct b53_device *dev, int port)
+{
+ /* These switches use a bitmap with the CPU port at bit 8. */
+ if ((is5325(dev) || is5365(dev)) && port == B53_CPU_PORT_25)
+ port = B53_CPU_PORT;
+
+ return BIT(port);
+}
+
+static u16 b53_mirror_capture_port(struct b53_device *dev, int port)
+{
+ if (is5325(dev) || is5365(dev))
+ return b53_mirror_port_mask(dev, port);
+
+ return port;
+}
+
int b53_mirror_add(struct dsa_switch *ds, int port,
struct dsa_mall_mirror_tc_entry *mirror, bool ingress,
struct netlink_ext_ack *extack)
@@ -2617,12 +2642,12 @@ int b53_mirror_add(struct dsa_switch *ds, int port,
loc = B53_EG_MIR_CTL;
b53_read16(dev, B53_MGMT_PAGE, loc, ®);
- reg |= BIT(port);
+ reg |= b53_mirror_port_mask(dev, port);
b53_write16(dev, B53_MGMT_PAGE, loc, reg);
b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, ®);
- reg &= ~CAP_PORT_MASK;
- reg |= mirror->to_local_port;
+ reg &= ~b53_mirror_capture_port_mask(dev);
+ reg |= b53_mirror_capture_port(dev, mirror->to_local_port);
reg |= MIRROR_EN;
b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg);
@@ -2644,7 +2669,7 @@ void b53_mirror_del(struct dsa_switch *ds, int port,
/* Update the desired ingress/egress register */
b53_read16(dev, B53_MGMT_PAGE, loc, ®);
- reg &= ~BIT(port);
+ reg &= ~b53_mirror_port_mask(dev, port);
if (!(reg & MIRROR_MASK))
loc_disable = true;
b53_write16(dev, B53_MGMT_PAGE, loc, reg);
@@ -2663,7 +2688,7 @@ void b53_mirror_del(struct dsa_switch *ds, int port,
/* Both no longer have ports, let's disable mirroring */
if (loc_disable && other_loc_disable) {
reg &= ~MIRROR_EN;
- reg &= ~mirror->to_local_port;
+ reg &= ~b53_mirror_capture_port_mask(dev);
}
b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg);
}
diff --git a/drivers/net/dsa/b53/b53_regs.h b/drivers/net/dsa/b53/b53_regs.h
index cfdb5ed383260..ee049927a63ae 100644
--- a/drivers/net/dsa/b53/b53_regs.h
+++ b/drivers/net/dsa/b53/b53_regs.h
@@ -239,6 +239,7 @@
/* Mirror capture control register (16 bit) */
#define B53_MIR_CAP_CTL 0x10
#define CAP_PORT_MASK 0xf
+#define CAP_PORT_MASK_25 0x7ff
#define BLK_NOT_MIR BIT(14)
#define MIRROR_EN BIT(15)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 253/742] net: dsa: b53: fix mirror destination and source state tracking
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (243 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 252/742] net: dsa: b53: fix mirror port encoding on BCM5325 and BCM5365 Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 254/742] net: bcmasp: avoid refcount drain on probe Greg Kroah-Hartman
` (481 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Joseph Telaak,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <florian.fainelli@broadcom.com>
[ Upstream commit 320bc9b8e2bc8a5fc75537082529b534ace633e3 ]
The mirror capture control register selects one destination for all
ingress and egress sources. Adding a rule for another destination
currently redirects existing rules. Multiple matchall filters can also
share one source bit, but deleting any one of them clears that bit and
can disable mirroring while other filters still need it.
Reject a different destination while either source mask is occupied, and
reference count each port's ingress and egress source bit under RTNL.
Program a source on its first reference and clear it on its last one.
Check every mirror register access and record a first reference only
after programming succeeds. Select the destination before enabling the
source, and log deletion failures because the callback returns no error.
Use the source masks to retain the destination after a failed source
deletion and allow a new destination after a failed capture-control clear.
Not all supported switches receive a hardware reset during setup, so
clear stale capture and source registers before accepting mirror rules.
Introduce b53_mirror_init() together with its b53 and bcm_sf2 setup
callers. Rebuild active sources and their destination from the reference
counts when setup runs again, preserving rules across bcm_sf2 resume.
Propagate initialization failures instead of accepting stale state.
This depends on "net: dsa: b53: fix mirror port encoding on BCM5325 and
BCM5365" for the chip-specific source and capture-port helpers.
Fixes: ed3af5fd08eb ("net: dsa: b53: Add support for port mirroring")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Joseph Telaak <joseph@telaak.dev>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/dsa/b53/b53_common.c | 168 ++++++++++++++++++++++++-------
drivers/net/dsa/b53/b53_priv.h | 4 +
drivers/net/dsa/bcm_sf2.c | 4 +
3 files changed, 140 insertions(+), 36 deletions(-)
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 7638bf95b5ab2..5bdf9cf147b35 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1360,6 +1360,10 @@ static int b53_setup(struct dsa_switch *ds)
return ret;
}
+ ret = b53_mirror_init(ds);
+ if (ret)
+ return ret;
+
/* setup default vlan for filtering mode */
pvid = b53_default_pvid(dev);
vl = &dev->vlans[pvid];
@@ -2629,27 +2633,103 @@ static u16 b53_mirror_capture_port(struct b53_device *dev, int port)
return port;
}
+int b53_mirror_init(struct dsa_switch *ds)
+{
+ struct b53_device *dev = ds->priv;
+ u16 ingress = 0, egress = 0, cap_ctl = 0;
+ unsigned int port;
+ int ret;
+
+ /* A switch reset may leave the previous mirror configuration intact. */
+ ret = b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, 0);
+ if (ret)
+ return ret;
+
+ ret = b53_write16(dev, B53_MGMT_PAGE, B53_IG_MIR_CTL, 0);
+ if (ret)
+ return ret;
+
+ ret = b53_write16(dev, B53_MGMT_PAGE, B53_EG_MIR_CTL, 0);
+ if (ret)
+ return ret;
+
+ /* DSA retains matchall filters across suspend and resume. */
+ for (port = 0; port < dev->num_ports; port++) {
+ if (dev->ports[port].mirror_count[true])
+ ingress |= b53_mirror_port_mask(dev, port);
+ if (dev->ports[port].mirror_count[false])
+ egress |= b53_mirror_port_mask(dev, port);
+ }
+
+ if (!(ingress | egress))
+ return 0;
+
+ cap_ctl = MIRROR_EN | b53_mirror_capture_port(dev, dev->mirror_port);
+ ret = b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, cap_ctl);
+ if (ret)
+ return ret;
+
+ ret = b53_write16(dev, B53_MGMT_PAGE, B53_IG_MIR_CTL, ingress);
+ if (ret)
+ return ret;
+
+ return b53_write16(dev, B53_MGMT_PAGE, B53_EG_MIR_CTL, egress);
+}
+EXPORT_SYMBOL(b53_mirror_init);
+
int b53_mirror_add(struct dsa_switch *ds, int port,
struct dsa_mall_mirror_tc_entry *mirror, bool ingress,
struct netlink_ext_ack *extack)
{
struct b53_device *dev = ds->priv;
- u16 reg, loc;
+ unsigned int *mirror_count = &dev->ports[port].mirror_count[ingress];
+ u16 reg, other_reg, loc, other_loc, cap_ctl;
+ u16 cap_mask = b53_mirror_capture_port_mask(dev);
+ u16 cap_port = b53_mirror_capture_port(dev, mirror->to_local_port);
+ int ret;
- if (ingress)
- loc = B53_IG_MIR_CTL;
- else
- loc = B53_EG_MIR_CTL;
+ loc = ingress ? B53_IG_MIR_CTL : B53_EG_MIR_CTL;
+ other_loc = ingress ? B53_EG_MIR_CTL : B53_IG_MIR_CTL;
- b53_read16(dev, B53_MGMT_PAGE, loc, ®);
- reg |= b53_mirror_port_mask(dev, port);
- b53_write16(dev, B53_MGMT_PAGE, loc, reg);
+ ret = b53_read16(dev, B53_MGMT_PAGE, loc, ®);
+ if (ret)
+ return ret;
- b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, ®);
- reg &= ~b53_mirror_capture_port_mask(dev);
- reg |= b53_mirror_capture_port(dev, mirror->to_local_port);
- reg |= MIRROR_EN;
- b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg);
+ ret = b53_read16(dev, B53_MGMT_PAGE, other_loc, &other_reg);
+ if (ret)
+ return ret;
+
+ ret = b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, &cap_ctl);
+ if (ret)
+ return ret;
+
+ if (((reg | other_reg) & MIRROR_MASK) &&
+ (cap_ctl & cap_mask) != cap_port) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Only one mirroring destination is supported");
+ return -EOPNOTSUPP;
+ }
+
+ if (*mirror_count) {
+ (*mirror_count)++;
+ return 0;
+ }
+
+ /* Select the destination before enabling the new source. */
+ cap_ctl &= ~cap_mask;
+ cap_ctl |= cap_port;
+ cap_ctl |= MIRROR_EN;
+ ret = b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, cap_ctl);
+ if (ret)
+ return ret;
+
+ ret = b53_write16(dev, B53_MGMT_PAGE, loc,
+ reg | b53_mirror_port_mask(dev, port));
+ if (ret)
+ return ret;
+
+ (*mirror_count)++;
+ dev->mirror_port = mirror->to_local_port;
return 0;
}
@@ -2659,38 +2739,54 @@ void b53_mirror_del(struct dsa_switch *ds, int port,
struct dsa_mall_mirror_tc_entry *mirror)
{
struct b53_device *dev = ds->priv;
- bool loc_disable = false, other_loc_disable = false;
- u16 reg, loc;
+ unsigned int *mirror_count =
+ &dev->ports[port].mirror_count[mirror->ingress];
+ u16 reg, other_reg, loc, other_loc;
+ int ret;
- if (mirror->ingress)
- loc = B53_IG_MIR_CTL;
- else
- loc = B53_EG_MIR_CTL;
+ if (!*mirror_count)
+ return;
+
+ if (--(*mirror_count))
+ return;
+
+ loc = mirror->ingress ? B53_IG_MIR_CTL : B53_EG_MIR_CTL;
+ other_loc = mirror->ingress ? B53_EG_MIR_CTL : B53_IG_MIR_CTL;
/* Update the desired ingress/egress register */
- b53_read16(dev, B53_MGMT_PAGE, loc, ®);
+ ret = b53_read16(dev, B53_MGMT_PAGE, loc, ®);
+ if (ret)
+ goto err;
+
reg &= ~b53_mirror_port_mask(dev, port);
- if (!(reg & MIRROR_MASK))
- loc_disable = true;
- b53_write16(dev, B53_MGMT_PAGE, loc, reg);
+ ret = b53_write16(dev, B53_MGMT_PAGE, loc, reg);
+ if (ret)
+ goto err;
/* Now look at the other one to know if we can disable mirroring
* entirely
*/
- if (mirror->ingress)
- b53_read16(dev, B53_MGMT_PAGE, B53_EG_MIR_CTL, ®);
- else
- b53_read16(dev, B53_MGMT_PAGE, B53_IG_MIR_CTL, ®);
- if (!(reg & MIRROR_MASK))
- other_loc_disable = true;
+ ret = b53_read16(dev, B53_MGMT_PAGE, other_loc, &other_reg);
+ if (ret)
+ goto err;
- b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, ®);
- /* Both no longer have ports, let's disable mirroring */
- if (loc_disable && other_loc_disable) {
- reg &= ~MIRROR_EN;
- reg &= ~b53_mirror_capture_port_mask(dev);
- }
- b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg);
+ if ((reg | other_reg) & MIRROR_MASK)
+ return;
+
+ ret = b53_read16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, ®);
+ if (ret)
+ goto err;
+
+ reg &= ~(MIRROR_EN | b53_mirror_capture_port_mask(dev));
+ ret = b53_write16(dev, B53_MGMT_PAGE, B53_MIR_CAP_CTL, reg);
+ if (ret)
+ goto err;
+
+ return;
+
+err:
+ dev_err(dev->dev, "Failed to delete mirror rule for port %d: %d\n",
+ port, ret);
}
EXPORT_SYMBOL(b53_mirror_del);
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index c4d2a41c714f6..df00a5ae46c9d 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -119,6 +119,8 @@ struct b53_pcs {
#define B53_N_PCS 2
struct b53_port {
+ /* References to each egress/ingress mirror source mask bit. */
+ unsigned int mirror_count[2];
u16 vlan_ctl_mask;
u16 pvid;
struct ethtool_keee eee;
@@ -170,6 +172,7 @@ struct b53_device {
/* run time configuration */
bool enable_jumbo;
+ unsigned int mirror_port;
unsigned int num_vlans;
struct b53_vlan *vlans;
@@ -545,6 +548,7 @@ int b53_mdb_add(struct dsa_switch *ds, int port,
int b53_mdb_del(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_mdb *mdb,
struct dsa_db db);
+int b53_mirror_init(struct dsa_switch *ds);
int b53_mirror_add(struct dsa_switch *ds, int port,
struct dsa_mall_mirror_tc_entry *mirror, bool ingress,
struct netlink_ext_ack *extack);
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index f3b56ea87b07b..babf5b142ad85 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1061,6 +1061,10 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
unsigned int port;
int ret;
+ ret = b53_mirror_init(ds);
+ if (ret)
+ return ret;
+
/* Enable all valid ports and disable those unused */
for (port = 0; port < priv->hw_params.num_ports; port++) {
/* IMP port receives special treatment */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 254/742] net: bcmasp: avoid refcount drain on probe
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (244 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 253/742] net: dsa: b53: fix mirror destination and source state tracking Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:01 ` [PATCH 7.3 255/742] net: bcmgenet: keep DIM from getting stuck after close or suspend Greg Kroah-Hartman
` (480 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Wang Haoran, Willem de Bruijn,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Haoran <wanghr2026@mail.zgclab.edu.cn>
[ Upstream commit 846a6d0982be30aaba5268aac14a0c557d70cc23 ]
bcmasp_probe() calls of_find_node_by_name(dev->of_node, "ethernet-ports"),
which unconditionally drops the from-node reference the caller never held.
Every probe or bind cycle that reaches the port scan, including ones that
later fail with "No ports found", drains the asp node refcount by one. Once
it hits zero, of_node_release() deadlocks in its error printk (%pOF on the
parent while holding devtree_lock with IRQs off), so the machine freezes
silently with nothing on the console.
Use of_get_child_by_name() which leaves the parent reference alone.
Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
Signed-off-by: Wang Haoran <wanghr2026@mail.zgclab.edu.cn>
Link: https://patch.msgid.link/1795076102979-9-385853cc@mail.zgclab.edu.cn
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/asp2/bcmasp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
index f41a79529f100..eb3efbf8e35c5 100644
--- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c
+++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
@@ -1342,7 +1342,7 @@ static int bcmasp_probe(struct platform_device *pdev)
bcmasp_init_wol(priv);
- ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports");
+ ports_node = of_get_child_by_name(dev->of_node, "ethernet-ports");
if (!ports_node) {
dev_warn(dev, "No ports found\n");
ret = -EINVAL;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 255/742] net: bcmgenet: keep DIM from getting stuck after close or suspend
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (245 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 254/742] net: bcmasp: avoid refcount drain on probe Greg Kroah-Hartman
@ 2026-12-04 10:01 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 256/742] net: bcmgenet: accumulate the DIM packet and byte counters Greg Kroah-Hartman
` (479 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:01 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Nicolai Buchwitz, Florian Fainelli,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <nb@tipi-net.de>
[ Upstream commit aa5a537ec43c13e4d2850468b0d88f97cce45dd3 ]
A close or WoL suspend cancels the pending profile work and can leave
DIM in DIM_APPLY_NEW_PROFILE, where net_dim() does nothing. Adaptive
coalescing then stays stuck after the next open or resume, and the
profile index no longer matches the hardware. The poll also calls
net_dim() after napi_complete_done(), so it can queue new work after
napi_disable() has returned.
Run net_dim() before completing NAPI and flush the work instead of
cancelling it, so the pending profile gets applied. Also reset the DIM
state on ring init and start from the default profile, which is what
bcmgenet_init_rx_coalesce() programs.
Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index f258997f20a9f..2ca5c0be178d3 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2507,15 +2507,16 @@ static int bcmgenet_rx_poll(struct napi_struct *napi, int budget)
work_done = bcmgenet_desc_rx(ring, budget);
- if (work_done < budget && napi_complete_done(napi, work_done))
- bcmgenet_rx_ring_int_enable(ring);
-
+ /* net_dim() can queue work, so run it while NAPI is still owned */
if (ring->dim.use_dim) {
dim_update_sample(ring->dim.event_ctr, ring->dim.packets,
ring->dim.bytes, &dim_sample);
net_dim(&ring->dim.dim, &dim_sample);
}
+ if (work_done < budget && napi_complete_done(napi, work_done))
+ bcmgenet_rx_ring_int_enable(ring);
+
return work_done;
}
@@ -2707,8 +2708,11 @@ static void bcmgenet_init_dim(struct bcmgenet_rx_ring *ring,
{
struct bcmgenet_net_dim *dim = &ring->dim;
+ memset(&dim->dim, 0, sizeof(dim->dim));
INIT_WORK(&dim->dim.work, cb);
dim->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
+ /* Match the profile bcmgenet_init_rx_coalesce() programs */
+ dim->dim.profile_ix = NET_DIM_DEF_PROFILE_EQE;
dim->event_ctr = 0;
dim->packets = 0;
dim->bytes = 0;
@@ -3019,7 +3023,8 @@ static void bcmgenet_disable_rx_napi(struct bcmgenet_priv *priv)
for (i = 0; i <= priv->hw_params->rx_queues; ++i) {
ring = &priv->rx_rings[i];
napi_disable(&ring->napi);
- cancel_work_sync(&ring->dim.dim.work);
+ /* Cancelling would leave DIM stuck in DIM_APPLY_NEW_PROFILE */
+ flush_work(&ring->dim.dim.work);
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 256/742] net: bcmgenet: accumulate the DIM packet and byte counters
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (246 preceding siblings ...)
2026-12-04 10:01 ` [PATCH 7.3 255/742] net: bcmgenet: keep DIM from getting stuck after close or suspend Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 257/742] net: bcmgenet: reset the Rx discard count with the ring Greg Kroah-Hartman
` (478 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Nicolai Buchwitz,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <nb@tipi-net.de>
[ Upstream commit a15079369636f4324d2985cede7ce7fbefddf4b3 ]
net_dim() computes rates from the difference between two samples and
needs running totals, but bcmgenet_desc_rx() passes the counts of the
last poll. Adaptive coalescing then picks profiles from wrong rates.
On a CM4 at a steady 300 Mbit/s UDP, DIM changed profile about 1000
times in 20 s. With the fix it settles, and Rx interrupts drop from about
4500/s to 2240/s.
Accumulate the counters instead.
Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 2ca5c0be178d3..c43535af02051 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2491,8 +2491,8 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
bcmgenet_rdma_ring_writel(priv, ring->index, ring->c_index, RDMA_CONS_INDEX);
}
- ring->dim.bytes = bytes_processed;
- ring->dim.packets = rxpktprocessed;
+ ring->dim.bytes += bytes_processed;
+ ring->dim.packets += rxpktprocessed;
return rxpktprocessed;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 257/742] net: bcmgenet: reset the Rx discard count with the ring
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (247 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 256/742] net: bcmgenet: accumulate the DIM packet and byte counters Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 258/742] net: systemport: restart DIM from the default profile on start Greg Kroah-Hartman
` (477 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Nicolai Buchwitz,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <nb@tipi-net.de>
[ Upstream commit e99faa3a16209ea5d0b83cc58b64785efd2d9045 ]
Ring init clears the hardware discard counter but not
ring->old_discards. Discards after an ifdown and ifup or a resume are
then missing from rx_missed. On a CM4, after an ifdown and ifup, 3666
discards showed up as 0 in rx_missed.
Reset old_discards together with the ring.
Fixes: d26ea6cc48da ("net: bcmgenet: collect Rx discarded packet count")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index c43535af02051..dd461721c6085 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -2831,6 +2831,8 @@ static int bcmgenet_init_rx_ring(struct bcmgenet_priv *priv,
ring->read_ptr = start_ptr;
ring->cb_ptr = start_ptr;
ring->end_ptr = end_ptr - 1;
+ /* Zeroing RDMA_PROD_INDEX below also clears the discard counter */
+ ring->old_discards = 0;
ret = bcmgenet_rx_ring_create_pool(priv, ring);
if (ret)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 258/742] net: systemport: restart DIM from the default profile on start
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (248 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 257/742] net: bcmgenet: reset the Rx discard count with the ring Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 259/742] net: systemport: accumulate the DIM packet and byte counters Greg Kroah-Hartman
` (476 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Nicolai Buchwitz, Willem de Bruijn,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <nb@tipi-net.de>
[ Upstream commit 8e428e263fa4fd3a752db8d9e1e584307f446aae ]
A close or suspend can cancel the pending profile work and leave DIM in
DIM_APPLY_NEW_PROFILE, where net_dim() does nothing. Adaptive coalescing
then stays stuck after the next open or resume. The poll also calls
net_dim() after napi_complete_done(), so it can queue new work after
napi_disable() has returned.
Run net_dim() before completing NAPI. Reset the DIM state on start and
begin from the default profile, which is what
bcm_sysport_init_rx_coalesce() programs.
Fixes: b6e0e875421e ("net: systemport: Implement adaptive interrupt coalescing")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 78909f5168231..4593fb0058549 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1012,18 +1012,19 @@ static int bcm_sysport_poll(struct napi_struct *napi, int budget)
else
rdma_writel(priv, priv->rx_c_index << 16, RDMA_CONS_INDEX);
- if (work_done < budget) {
- napi_complete_done(napi, work_done);
- /* re-enable RX interrupts */
- intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE);
- }
-
+ /* net_dim() can queue work, so run it while NAPI is still owned */
if (priv->dim.use_dim) {
dim_update_sample(priv->dim.event_ctr, priv->dim.packets,
priv->dim.bytes, &dim_sample);
net_dim(&priv->dim.dim, &dim_sample);
}
+ if (work_done < budget) {
+ napi_complete_done(napi, work_done);
+ /* re-enable RX interrupts */
+ intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE);
+ }
+
return work_done;
}
@@ -1452,8 +1453,11 @@ static void bcm_sysport_init_dim(struct bcm_sysport_priv *priv,
{
struct bcm_sysport_net_dim *dim = &priv->dim;
+ memset(&dim->dim, 0, sizeof(dim->dim));
INIT_WORK(&dim->dim.work, cb);
dim->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE;
+ /* Match the profile bcm_sysport_init_rx_coalesce() programs */
+ dim->dim.profile_ix = NET_DIM_DEF_PROFILE_EQE;
dim->event_ctr = 0;
dim->packets = 0;
dim->bytes = 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 259/742] net: systemport: accumulate the DIM packet and byte counters
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (249 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 258/742] net: systemport: restart DIM from the default profile on start Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 260/742] ipv4: fix conntrack defrag forwarding after ip_frag_reinit() Greg Kroah-Hartman
` (475 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Nicolai Buchwitz,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolai Buchwitz <nb@tipi-net.de>
[ Upstream commit 3e7e20beef4ec04f7601e92e78608333f2ab3904 ]
net_dim() computes rates from the difference between two samples and
needs running totals, but bcm_sysport_desc_rx() passes the counts of the
last poll. Adaptive coalescing then picks profiles from wrong rates.
Accumulate the counters instead.
Fixes: b6e0e875421e ("net: systemport: Implement adaptive interrupt coalescing")
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/bcmsysport.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 4593fb0058549..38918aa735513 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -844,8 +844,8 @@ static unsigned int bcm_sysport_desc_rx(struct bcm_sysport_priv *priv,
priv->rx_read_ptr = 0;
}
- priv->dim.packets = processed;
- priv->dim.bytes = processed_bytes;
+ priv->dim.packets += processed;
+ priv->dim.bytes += processed_bytes;
return processed;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 260/742] ipv4: fix conntrack defrag forwarding after ip_frag_reinit()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (250 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 259/742] net: systemport: accumulate the DIM packet and byte counters Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 261/742] tun: bound the NAPI receive queue Greg Kroah-Hartman
` (474 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Jiayuan Chen,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <jiayuan.chen@linux.dev>
[ Upstream commit 3ab5aae0eb60079d17378af5aab0db84ba946e0e ]
q.max_size and max_df_size are used by ip_frag_reasm() to set
IPCB(skb)->frag_max_size and the DF bit of the reassembled packet.
ip_frag_reinit() reuses the queue for a new datagram but does not
reset them, so the new datagram inherits them from the old one.
On a router with conntrack defrag, if the largest fragment of the old
datagram had DF set and was larger than the egress MTU, a new datagram
without DF gets DF set after reassembly and is rejected with
ICMP_FRAG_NEEDED, even though all its fragments fit.
Reset both fields.
Fixes: 5f2d04f1f9b5 ("ipv4: fix path MTU discovery with connection tracking")
Fixes: d6b915e29f4a ("ip_fragment: don't forward defragmented DF packet")
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20261120094700.46500-1-jiayuan.chen@linux.dev
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ipv4/ip_fragment.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index ef7fd61284a3f..0688be8142c4b 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -250,6 +250,8 @@ static int ip_frag_reinit(struct ipq *qp)
qp->q.flags = 0;
qp->q.len = 0;
qp->q.meat = 0;
+ qp->q.max_size = 0;
+ qp->max_df_size = 0;
qp->iif = 0;
qp->ecn = 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 261/742] tun: bound the NAPI receive queue
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (251 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 260/742] ipv4: fix conntrack defrag forwarding after ip_frag_reinit() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 262/742] bpf: net_sched: Defer bpf_kfree_skb() to irq_work with irqs off Greg Kroah-Hartman
` (473 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Antonio Quartulli, Willem de Bruijn,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antonio Quartulli <antonio@mandelbit.com>
[ Upstream commit cc7fe6e741730fef549e484379281736d32746f0 ]
With IFF_NAPI, tun_get_user() queues every written packet for NAPI on
an unbounded list. When the poll runs asynchronously (threaded NAPI or
ksoftirqd) and is slower than the writer, the queue grows until the
system runs out of memory. An unprivileged user can do this from its own
user and network namespaces, and the queued skbs are not charged to its
memcg: in a test VM, a uid 1000 process limited to 128 MB caused a
global OOM in ~6 seconds. The socket send buffer does not help: tun sets
it to INT_MAX by default, the build_skb() path is only used while it is
INT_MAX, and the XDP batch path never checks it.
Drop packets once more than netdev_max_backlog of them are queued, like
enqueue_to_backlog() does, and count them as rx_dropped; the write still
reports success, as for a full backlog. The check sits where packets are
queued for NAPI, in tun_get_user() and in tun_xdp_one() for the batches
vhost-net passes, so packets consumed by XDP or delivered through
IFF_NAPI_FRAGS are not affected. A dropped zerocopy skb completes its
buffer when freed. The check is lockless, so concurrent writers can each
still add one packet.
The NAPI poll moved the whole queue out, processed up to its budget and
put the rest back: while it ran, the queue looked empty to writers, so
with the poll on another CPU the backlog could still grow without limit.
Take at most budget packets instead: the rest stays on the queue writers
check.
Dropping also schedules NAPI. vhost-net sends with MSG_MORE while it has
more packets, and tun_get_user() schedules NAPI only for a packet
without it or once more than NAPI_POLL_WEIGHT are queued. With a
netdev_max_backlog below that, the queue fills first and the packet
without MSG_MORE is dropped too: nothing would schedule NAPI, and the
queued packets, with zerocopy also their buffers, would wait forever.
Reproducer, as an unprivileged user in a new user and network
namespace, without kernel modifications or fault injection:
ip tuntap add t0 mode tun; ip addr add 10.11.0.1/24 dev t0
ip link add d0 type dummy; ip addr add 10.20.0.1/24 dev d0
ip link set t0 up; ip link set d0 up; sysctl net.ipv4.ip_forward=1
install ~500 iptables FORWARD rules, to slow down the poll, and a
MASQUERADE rule on d0
open t0 with IFF_TUN | IFF_NO_PI | IFF_NAPI
echo 1 > /sys/class/net/t0/threaded
write() 1400-byte IPv4 packets for 10.20.0.2 in a loop
Found by code inspection while analysing the performance of the tun
write path. Tested in an x86-64 VM on net, with 1 and 2 vCPUs: the
reproducer causes a global OOM without the patch, while with it memory
use stays flat and the forwarding rate is unchanged; the tun kselftest
passes; a local vhost-net test of the batch, copy and zerocopy paths
with netdev_max_backlog set to 8 passes, and fails without the patch;
an XDP program on the device sees every packet while the excess is
dropped.
Still open: neither the packet size nor the queued memory is bounded,
and the skbs are not charged to the writer's memcg. A single write can
create an skb of several hundred KB, so even one queue can hold a lot,
and IFF_MULTI_QUEUE (allowed in a user namespace) and more devices
multiply it. This bounds the queue as enqueue_to_backlog() bounds the
per-CPU backlog; charging the skbs to the writer is left to a follow-up.
Fixes: 943170998b20 ("tun: enable NAPI for TUN/TAP driver")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20261119153056.353156-1-antonio@mandelbit.com
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/tun.c | 52 +++++++++++++++++++++++++++++++++++++++--------
1 file changed, 44 insertions(+), 8 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 8fa495a2787ae..30d5dc4c15671 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -58,6 +58,7 @@
#include <linux/nsproxy.h>
#include <linux/virtio_net.h>
#include <linux/rcupdate.h>
+#include <net/hotdata.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>
#include <net/rtnetlink.h>
@@ -227,6 +228,16 @@ struct veth {
static void tun_flow_init(struct tun_struct *tun);
static void tun_flow_uninit(struct tun_struct *tun);
+/* In IFF_NAPI mode written packets wait in the tfile's sk_write_queue for the
+ * NAPI poll, which may run later in a kthread or ksoftirqd. Bound that queue
+ * like the per-CPU backlog.
+ */
+static bool tun_napi_queue_full(const struct sk_buff_head *queue)
+{
+ return skb_queue_len_lockless(queue) >
+ READ_ONCE(net_hotdata.max_backlog);
+}
+
static int tun_napi_receive(struct napi_struct *napi, int budget)
{
struct tun_file *tfile = container_of(napi, struct tun_file, napi);
@@ -237,21 +248,22 @@ static int tun_napi_receive(struct napi_struct *napi, int budget)
__skb_queue_head_init(&process_queue);
+ /* At most budget skbs: the rest stays on the queue writers check */
spin_lock(&queue->lock);
- skb_queue_splice_tail_init(queue, &process_queue);
+ if (skb_queue_len(queue) <= budget) {
+ skb_queue_splice_tail_init(queue, &process_queue);
+ } else {
+ while (skb_queue_len(&process_queue) < budget &&
+ (skb = __skb_dequeue(queue)))
+ __skb_queue_tail(&process_queue, skb);
+ }
spin_unlock(&queue->lock);
- while (received < budget && (skb = __skb_dequeue(&process_queue))) {
+ while ((skb = __skb_dequeue(&process_queue))) {
napi_gro_receive(napi, skb);
++received;
}
- if (!skb_queue_empty(&process_queue)) {
- spin_lock(&queue->lock);
- skb_queue_splice(&process_queue, queue);
- spin_unlock(&queue->lock);
- }
-
return received;
}
@@ -2049,6 +2061,19 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
struct sk_buff_head *queue = &tfile->sk.sk_write_queue;
int queue_len;
+ /* Queue full: drop, and schedule NAPI, which a MSG_MORE sender
+ * may not have done yet. Lockless: concurrent writers can each
+ * still add one.
+ */
+ if (unlikely(tun_napi_queue_full(queue))) {
+ local_bh_disable();
+ napi_schedule(&tfile->napi);
+ local_bh_enable();
+ rcu_read_unlock();
+ drop_reason = SKB_DROP_REASON_FULL_RING;
+ goto drop;
+ }
+
spin_lock_bh(&queue->lock);
if (unlikely(tfile->detached)) {
@@ -2663,6 +2688,17 @@ static int tun_xdp_one(struct tun_struct *tun,
if (tfile->napi_enabled) {
queue = &tfile->sk.sk_write_queue;
+
+ /* Queue full: drop, and schedule NAPI so that it drains even if
+ * nothing in this batch gets queued.
+ */
+ if (unlikely(tun_napi_queue_full(queue))) {
+ napi_schedule(&tfile->napi);
+ kfree_skb_reason(skb, SKB_DROP_REASON_FULL_RING);
+ dev_core_stats_rx_dropped_inc(tun->dev);
+ return 0;
+ }
+
spin_lock(&queue->lock);
if (unlikely(tfile->detached)) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 262/742] bpf: net_sched: Defer bpf_kfree_skb() to irq_work with irqs off
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (252 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 261/742] tun: bound the NAPI receive queue Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 263/742] bpf: Save irq flags on the stack when freeing a list head or rb root Greg Kroah-Hartman
` (472 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov,
Kumar Kartikeya Dwivedi, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 73f17a98ea707b505b75c45f1ad7535f8d060195 ]
bpf_kfree_skb() is also the destructor of an skb kptr. A destructor runs
wherever an object or a map value with such a field is freed. That can be
with irqs off, for example:
- bpf_list_add() drops the new node when @prev is not in the list, while
the program holds the bpf_spin_lock of the list, which keeps irqs off.
The drop frees a node that has no other reference, with its fields.
- bpf_local_storage_map_free() frees the fields of each value under the
lock of its bucket, which bpf_selem_unlink_nofail() takes with
raw_res_spin_lock_irqsave(). A qdisc program can keep an skb in task
storage.
The rq lock can be held as well. A program that shares a list with the
qdisc program gets there:
prog drops the node with
---------------------- ----------------------------------------
sched_ext ops.dispatch bpf_obj_drop()
tp_btf/sched_switch bpf_list_add(), @prev is not in the list
The check from commit 94c8d1c21be4 ("bpf: Reject bpf_obj_drop() from
tracing progs") catches neither.
Currently bpf_kfree_skb() calls kfree_skb(), which is not made for that.
The destructor of the skb may enable softirqs, take a lock that sleeps on
PREEMPT_RT, or wake a task. sock_wfree() wakes the task that waits for
the socket to become writable, and under the rq lock that deadlocks:
__schedule() holds rq lock, irqs are off
bpf_kfree_skb_dtor(skb)
kfree_skb(skb)
sock_wfree(skb) a task polls the socket for write
__wake_up_common_lock()
try_to_wake_up() the task belongs on this cpu
rq_lock(rq) <- same rq
dev_kfree_skb_any() does not solve it. With irqs off it leaves the skb to
NET_TX_SOFTIRQ, and raising a softirq outside of an interrupt wakes
ksoftirqd:
__schedule() holds rq lock, irqs are off
bpf_kfree_skb_dtor(skb)
dev_kfree_skb_irq_reason(skb)
raise_softirq_irqoff() in_interrupt() == 0
wake_up_process(ksoftirqd)
ttwu_queue() cpu == this_cpu
rq_lock(rq) <- same rq
With irqs on it is kfree_skb(), which on PREEMPT_RT must not run with
preemption off either, as after bpf_preempt_disable():
bpf_kfree_skb(skb) preempt_count() == 1
sock_wfree(skb) a writer sleeps in sk_wq
__wake_up_common_lock()
spin_lock_irqsave(&wq_head->lock)
Free the skb from an irq_work in these contexts, like
bpf_async_refcount_put() does: with irqs off, and on PREEMPT_RT whenever
the caller is not preemptible. The skb waits on a lock-less list, linked
through skb->ll_node. A shared skb only loses the reference of the caller:
as in dev_kfree_skb_irq_reason(), the last reference is the one that may
link the skb.
The irq_work frees the list with dev_kfree_skb_any(). Without PREEMPT_RT
it runs in hard irq context, where dev_kfree_skb_any() leaves the skb to
NET_TX_SOFTIRQ and wakes nobody. With PREEMPT_RT it runs in the irq_work
thread, where dev_kfree_skb_any() is kfree_skb() and may sleep.
Everywhere else bpf_kfree_skb() remains kfree_skb(). Qdisc_ops::enqueue
and Qdisc_ops::dequeue run with irqs on, so a qdisc pays for the test of
the irq flag and no more. NET_SCH_BPF cannot be a module, so no exit path
has to wait for the irq_work.
Fixes: 870c28588afa ("bpf: net_sched: Add basic bpf qdisc kfuncs")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://patch.msgid.link/7a28c63f6b3d61442dbee1950f9a76d278a0f5be.1795550039.git.memxor@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/sched/bpf_qdisc.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/net/sched/bpf_qdisc.c b/net/sched/bpf_qdisc.c
index 098ca02aed89c..9e249a87d6bee 100644
--- a/net/sched/bpf_qdisc.c
+++ b/net/sched/bpf_qdisc.c
@@ -5,6 +5,7 @@
#include <linux/bpf.h>
#include <linux/btf.h>
#include <linux/filter.h>
+#include <linux/irq_work.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>
@@ -184,6 +185,19 @@ static int bpf_qdisc_gen_epilogue(struct bpf_insn *insn_buf, const struct bpf_pr
return insn - insn_buf;
}
+static LLIST_HEAD(bpf_skb_free_list);
+
+static void bpf_skb_free_irq_work(struct irq_work *work)
+{
+ struct llist_node *list = llist_del_all(&bpf_skb_free_list);
+ struct sk_buff *skb, *next;
+
+ llist_for_each_entry_safe(skb, next, list, ll_node)
+ dev_kfree_skb_any(skb);
+}
+
+static DEFINE_IRQ_WORK(bpf_skb_free_work, bpf_skb_free_irq_work);
+
__bpf_kfunc_start_defs();
/* bpf_skb_get_hash - Get the flow hash of an skb.
@@ -196,9 +210,22 @@ __bpf_kfunc u32 bpf_skb_get_hash(struct sk_buff *skb)
/* bpf_kfree_skb - Release an skb's reference and drop it immediately.
* @skb: The skb whose reference to be released and dropped.
+ *
+ * Also the destructor of an skb kptr, which runs wherever an object or a map
+ * value with such a field is freed: under a bpf_spin_lock too, with irqs off.
+ * rq lock can be held as well, so don't wake up ksoftirqd from here.
*/
__bpf_kfunc void bpf_kfree_skb(struct sk_buff *skb)
{
+ if (irqs_disabled() ||
+ (IS_ENABLED(CONFIG_PREEMPT_RT) && !preemptible())) {
+ /* Only the last reference may link the skb. */
+ if (refcount_dec_not_one(&skb->users))
+ return;
+ llist_add(&skb->ll_node, &bpf_skb_free_list);
+ irq_work_queue(&bpf_skb_free_work);
+ return;
+ }
kfree_skb(skb);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 263/742] bpf: Save irq flags on the stack when freeing a list head or rb root
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (253 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 262/742] bpf: net_sched: Defer bpf_kfree_skb() to irq_work with irqs off Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 264/742] gpiolib: fix inverted trace values in gpiod_get_array_value() Greg Kroah-Hartman
` (471 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov,
Kumar Kartikeya Dwivedi, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 81c6c8c608b6075846d3bd5b6f57958300a56eda ]
bpf_spin_lock() saves the irq flags in the per-cpu variable irqsave_flags,
and bpf_spin_unlock() restores them from there. One word per cpu is enough
as long as a cpu takes no second bpf_spin_lock before it releases the
first.
bpf_list_head_free() and bpf_rb_root_free() take a second one. They lock
the list or the tree that they free with __bpf_spin_lock_irqsave(), and
they can run while a program holds a bpf_spin_lock of its own.
bpf_list_add(), bpf_list_push_front(), bpf_list_push_back() and
bpf_rbtree_add() drop the node when they fail. The drop frees a node that
has no other reference, with its fields, and the node can have a list or a
tree itself, like struct foo of the selftests' linked_list.h:
bpf_spin_lock(&glock) irqsave_flags = on
bpf_list_add(&ghead, foo, prev) prev is not in the list
bpf_list_head_free(&foo->head)
__bpf_spin_lock_irqsave() irqsave_flags = off
bpf_spin_unlock(&glock) restores off
The program returns with irqs off.
Keep the flags of the two functions in a local variable, and take the lock
with __bpf_spin_lock(). Both functions unlock before they drop the nodes,
so nothing else runs between the save and the restore.
A failed add drops the node since the commit below. Until bpf_list_add()
existed, an add failed only for a node that a list or a tree still owned,
with a reference of its own, so the drop freed the node only in a race
with the release of that reference. bpf_list_add() fails for any node when
@prev is not in the list.
Fixes: d2dcc67df910 ("bpf: Migrate bpf_rbtree_add and bpf_list_push_{front,back} to possibly fail")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://patch.msgid.link/178849392dfb8ddf82d7ba4259be6113349bdc2e.1795550092.git.memxor@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/helpers.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 9100283e2935e..13b0ee50254b3 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2254,6 +2254,7 @@ void bpf_list_head_free(const struct btf_field *field, void *list_head,
struct bpf_spin_lock *spin_lock)
{
struct list_head *head = list_head, drain, *pos, *n;
+ unsigned long flags;
BUILD_BUG_ON(sizeof(struct list_head) > sizeof(struct bpf_list_head));
BUILD_BUG_ON(__alignof__(struct list_head) > __alignof__(struct bpf_list_head));
@@ -2265,7 +2266,8 @@ void bpf_list_head_free(const struct btf_field *field, void *list_head,
* section, and end up doing map ops that call bpf_list_head_free for
* the same map value again.
*/
- __bpf_spin_lock_irqsave(spin_lock);
+ local_irq_save(flags);
+ __bpf_spin_lock(spin_lock);
if (!head->next || list_empty(head))
goto unlock;
list_for_each_safe(pos, n, head) {
@@ -2277,7 +2279,8 @@ void bpf_list_head_free(const struct btf_field *field, void *list_head,
}
unlock:
INIT_LIST_HEAD(head);
- __bpf_spin_unlock_irqrestore(spin_lock);
+ __bpf_spin_unlock(spin_lock);
+ local_irq_restore(flags);
while (!list_empty(&drain)) {
struct bpf_list_node_kern *node;
@@ -2314,19 +2317,22 @@ void bpf_rb_root_free(const struct btf_field *field, void *rb_root,
struct rb_root_cached orig_root, *root = rb_root;
struct bpf_rb_node_kern *node;
struct rb_node *pos, *n;
+ unsigned long flags;
void *obj;
BUILD_BUG_ON(sizeof(struct rb_root_cached) > sizeof(struct bpf_rb_root));
BUILD_BUG_ON(__alignof__(struct rb_root_cached) > __alignof__(struct bpf_rb_root));
- __bpf_spin_lock_irqsave(spin_lock);
+ local_irq_save(flags);
+ __bpf_spin_lock(spin_lock);
orig_root = *root;
bpf_rbtree_postorder_for_each_entry_safe(pos, n, &orig_root.rb_root) {
node = rb_entry(pos, struct bpf_rb_node_kern, rb_node);
WRITE_ONCE(node->owner, BPF_PTR_POISON);
}
*root = RB_ROOT_CACHED;
- __bpf_spin_unlock_irqrestore(spin_lock);
+ __bpf_spin_unlock(spin_lock);
+ local_irq_restore(flags);
bpf_rbtree_postorder_for_each_entry_safe(pos, n, &orig_root.rb_root) {
obj = pos;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 264/742] gpiolib: fix inverted trace values in gpiod_get_array_value()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (254 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 263/742] bpf: Save irq flags on the stack when freeing a list head or rb root Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 265/742] ipv6: Honor suppress_prefixlength in fib6_lookup() Greg Kroah-Hartman
` (470 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jan Schär, Bartosz Golaszewski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Schär <jan@jschaer.ch>
[ Upstream commit 601acadb79b62ee52edbd29ec69d8f677dc32dcd ]
Almost all trace_gpio_value() calls report the raw value.
gpiod_get_array_value_complex() is the only exception; it reports
the logical value in traces unless the caller requests raw values.
This inconsistency makes GPIO traces confusing.
Move the trace call earlier, where the value is still raw.
Now, all GPIO traces consistently report raw values.
Fixes: eec1d566cdf9 ("gpio: Introduce ->get_multiple callback")
Signed-off-by: Jan Schär <jan@jschaer.ch>
Link: https://patch.msgid.link/20261120130208.89621-1-jan@jschaer.ch
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpiolib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index a16a787c58cbd..53d123661ebeb 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3623,10 +3623,10 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep,
int hwgpio = gpiod_hwgpio(desc);
int value = test_bit(hwgpio, bits);
+ trace_gpio_value(desc_to_gpio(desc), 1, value);
if (!raw && test_bit(GPIOD_FLAG_ACTIVE_LOW, &desc->flags))
value = !value;
__assign_bit(j, value_bitmap, value);
- trace_gpio_value(desc_to_gpio(desc), 1, value);
j++;
if (array_info)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 265/742] ipv6: Honor suppress_prefixlength in fib6_lookup()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (255 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 264/742] gpiolib: fix inverted trace values in gpiod_get_array_value() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 266/742] net: dsa: felix: fix NULL pointer dereference in felix_port_enable() Greg Kroah-Hartman
` (469 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Leonard Lausen, Ido Schimmel,
Paolo Abeni, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leonard Lausen <leonard@lausen.nl>
[ Upstream commit 94df5595e31bf4502fe5195748ca55164ac763f0 ]
When custom FIB rules are configured, fib6_lookup() performs the lookup
via fib6_rule_action_alt() which calls fib6_table_lookup() and only
populates the f6i, nh, fib6_flags and fib6_type fields of the FIB
result. However, fib6_rule_suppress() only examines the rt6 field, which
is only populated when the lookup is performed via one of the callers of
fib6_rule_lookup() such as ip6_route_output(). As a result,
fib6_lookup() ignores suppress_prefixlength.
This was not a problem for nftables until commit 1c32b24c234b
("netfilter: nft_fib_ipv6: switch to fib6_lookup") switched the FIB
expression from ip6_route_lookup() / nf_ip6_route() to fib6_lookup().
Since then, with a rule that suppresses the default route in the main
table before looking up a VPN table (as commonly configured for
WireGuard), the FIB expression returns the suppressed default route
instead of the VPN route. Strict reverse path filtering then drops
replies received over the VPN.
Fix by evaluating suppress_prefixlength against the prefix length of
the FIB entry when the lookup is performed via fib6_lookup().
fib_rules_lookup() only invokes the suppress callback when the rule
action returns 0. Unlike __fib6_rule_action(), fib6_rule_action_alt()
returns 0 for reject routes and instead sets RTF_REJECT in the result.
Do not suppress such routes so that they continue to terminate the
lookup, as with ip6_route_output() and IPv4. Check the flags in the
result rather than in the FIB entry so that blackhole nexthop objects
are also covered.
suppress_ifgroup is not handled since fib6_table_lookup() does not
perform multipath selection and the nexthop it returns might not be the
one that is eventually used.
Observed during WireGuard use and reproduced on unmodified v7.4-rc2,
without instrumentation or error injection. Verified with namespace
probes and nft_fib.sh on the rebuilt v7.4-rc2-based kernel.
Fixes: 1c32b24c234b ("netfilter: nft_fib_ipv6: switch to fib6_lookup")
Link: https://github.com/firewalld/firewalld/issues/1600
Signed-off-by: Leonard Lausen <leonard@lausen.nl>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20261117110813.9894-3-leonard@lausen.nl
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ipv6/fib6_rules.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 0ffd7b47a0460..7efb0515b5c8b 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -286,6 +286,12 @@ INDIRECT_CALLABLE_SCOPE bool fib6_rule_suppress(struct fib_rule *rule,
struct rt6_info *rt = res->rt6;
struct net_device *dev = NULL;
+ if (arg->lookup_ptr == fib6_table_lookup) {
+ /* fib6_table_lookup() returns 0 for reject routes. */
+ return !(res->fib6_flags & RTF_REJECT) &&
+ res->f6i->fib6_dst.plen <= rule->suppress_prefixlen;
+ }
+
if (!rt)
return false;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 266/742] net: dsa: felix: fix NULL pointer dereference in felix_port_enable()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (256 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 265/742] ipv6: Honor suppress_prefixlength in fib6_lookup() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 267/742] ipv6: mcast: do not pass uninitialized bytes to dev_mc_add() Greg Kroah-Hartman
` (468 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Aristo Chen, Vladimir Oltean,
Paolo Abeni, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aristo Chen <aristo.chen@canonical.com>
[ Upstream commit 469b61e4be88bc671dabe802e11f706b1ea7aa15 ]
DSA registers the user ports in dsa_tree_setup_ports() before it sets
conduit->dsa_ptr in dsa_tree_setup_conduit(). On teardown, it clears
conduit->dsa_ptr in dsa_tree_teardown_conduit() before
dsa_tree_teardown_ports() removes the user ports. RTNL is not held
across either pair of steps, so user space can open a user port while
conduit->dsa_ptr is NULL.
In NPI mode, felix_port_enable() calls felix_cpu_port_for_conduit().
For a physical conduit, that function reads the CPU port index through
conduit->dsa_ptr without checking for NULL. This caused an oops on an
LS1028A RDB when systemd-networkd tried to open a user port while the
switch was being probed again at runtime:
[ 166.722423] Unable to handle kernel access to user memory outside uaccess routines at virtual address 0000000000000028
[ 166.816908] Internal error: Oops: 0000000096000004 [#1] SMP
[ 166.961766] pc : felix_cpu_port_for_conduit.isra.0+0x90/0xb8 [mscc_felix_dsa_lib]
[ 166.969289] lr : felix_port_enable+0x120/0x1a0 [mscc_felix_dsa_lib]
The oops left RTNL locked. Later operations that waited for RTNL hung,
and the board had to be power cycled.
NPI mode uses one CPU port for the whole switch. Changing the conduit
of a user port can move the NPI port to another CPU port, and the check
in felix_port_enable() keeps user ports that still use the old CPU port
down.
For a physical conduit, compare dp->cpu_dp->index with the NPI port
instead. DSA sets dp->cpu_dp before it registers the user port and
clears it only after it removes the user port, so the check keeps
working while conduit->dsa_ptr is NULL. As long as the physical
conduit is set up, conduit->dsa_ptr and dp->cpu_dp point to the same
CPU port, so the check gives the same result as before. LAG conduits
keep using felix_cpu_port_for_conduit(), which does not read dsa_ptr
for them.
Fixes: eca70102cfb1 ("net: dsa: felix: add support for changing DSA master")
Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20261119100710.129379-1-aristo.chen@canonical.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/dsa/ocelot/felix.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 84a95007825f7..dd471fff23bd0 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -1239,8 +1239,19 @@ static int felix_port_enable(struct dsa_switch *ds, int port,
if (ocelot->npi >= 0) {
struct net_device *conduit = dsa_port_to_conduit(dp);
+ int cpu;
- if (felix_cpu_port_for_conduit(ds, conduit) != ocelot->npi) {
+ /* Do not use conduit->dsa_ptr for a physical conduit. It is
+ * NULL before DSA sets up the conduit and after it tears it
+ * down, and opening a user port can reach this check in both
+ * cases.
+ */
+ if (netif_is_lag_master(conduit))
+ cpu = felix_cpu_port_for_conduit(ds, conduit);
+ else
+ cpu = dp->cpu_dp->index;
+
+ if (cpu != ocelot->npi) {
dev_err(ds->dev, "Multiple conduits are not allowed\n");
return -EINVAL;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 267/742] ipv6: mcast: do not pass uninitialized bytes to dev_mc_add()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (257 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 266/742] net: dsa: felix: fix NULL pointer dereference in felix_port_enable() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 268/742] tcp: Dont clear saddr before ->put_port() Greg Kroah-Hartman
` (467 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Eric Dumazet,
Hangbin Liu, Ido Schimmel, Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <edumazet@kernel.org>
[ Upstream commit 58f419bfa4c3a6797246a7c4e53a535ee34372ae ]
igmp6_group_added() and igmp6_group_dropped() build a link-layer
multicast address in an on-stack buffer with ndisc_mc_map(), which
fills a number of bytes depending on dev->type.
dev_mc_add() and dev_mc_del() then use dev->addr_len bytes of it.
Since IPv6 multicast joins and leaves no longer hold RTNL, dev->type
and dev->addr_len can change between the two steps, for instance with
TUNSETLINK, or when bonding or team change their type.
If addr_len grows (eg ARPHRD_ETHER -> ARPHRD_IP6GRE), dev_mc_add()
copies uninitialized stack bytes into a netdev_hw_addr, which can
later be dumped to user space by /proc/net/dev_mcast and
RTM_GETMULTICAST.
Zero the buffers.
Found by Sashiko AI review of a tun patch, by code inspection only.
Kernels built with CONFIG_INIT_STACK_ALL_ZERO=y are not affected.
Fixes: 1767bb2d47b7 ("ipv6: mcast: Don't hold RTNL for IPV6_ADD_MEMBERSHIP and MCAST_JOIN_GROUP.")
Link: https://lore.kernel.org/netdev/179512665919.3136.5931555157250030152@kernel.org/
Cc: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20261123124458.205233-1-edumazet@kernel.org
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ipv6/mcast.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index ecef55f261890..bce7287ae709f 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -684,7 +684,10 @@ bool inet6_mc_check(const struct sock *sk, const struct in6_addr *mc_addr,
static void igmp6_group_added(struct ifmcaddr6 *mc)
{
struct net_device *dev = mc->idev->dev;
- char buf[MAX_ADDR_LEN];
+ /* RTNL might not be held: dev->type and dev->addr_len can change.
+ * Make sure dev_mc_{add|del}() do not use uninitialized bytes.
+ */
+ char buf[MAX_ADDR_LEN] = {};
mc_assert_locked(mc->idev);
@@ -720,7 +723,10 @@ static void igmp6_group_added(struct ifmcaddr6 *mc)
static void igmp6_group_dropped(struct ifmcaddr6 *mc)
{
struct net_device *dev = mc->idev->dev;
- char buf[MAX_ADDR_LEN];
+ /* RTNL might not be held: dev->type and dev->addr_len can change.
+ * Make sure dev_mc_{add|del}() do not use uninitialized bytes.
+ */
+ char buf[MAX_ADDR_LEN] = {};
mc_assert_locked(mc->idev);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 268/742] tcp: Dont clear saddr before ->put_port().
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (258 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 267/742] ipv6: mcast: do not pass uninitialized bytes to dev_mc_add() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 269/742] bpf: Do not allow bpf_d_path() by an id of another BTF Greg Kroah-Hartman
` (466 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Eric Dumazet,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <kuniyu@google.com>
[ Upstream commit 1ab3fb564f20b78615a6d88b8c90da292f29e227 ]
When CGROUP_INET4_POST_BIND or CGROUP_INET6_POST_BIND prog fails,
__inet_bind() / __inet6_bind() calls sk->sk_prot->put_port().
For TCP, __inet_put_port() calls inet_bhashfn_portaddr() to get
the corresponding bhash2 bucket.
inet_bhashfn_portaddr() requires saddr, but it is cleared before
__inet_put_port(), leading to bhash2 lock mismatch.
This triggers list corruption or use-after-free by a conccurent
thread touching the same bhash2 bucket, e.g. tcp_diag_dump()
with TCPF_BOUND_INACTIVE. [0]
Let's clear saddr after calling sk->sk_prot->put_port().
[0]:
BUG: KASAN: slab-use-after-free in tcp_diag_dump (net/ipv4/tcp_diag.c:415)
Read of size 8 at addr ffff88810ae0e7a0 by task a/1007
CPU: 10 UID: 0 PID: 1007 Comm: a Not tainted 7.4.0-rc3-00456-gd5b89d55a322 #295 PREEMPT(lazy)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl (lib/dump_stack.c:120)
print_address_description (mm/kasan/report.c:378)
print_report (mm/kasan/report.c:482)
kasan_report (mm/kasan/report.c:595)
sock_recvmsg (net/socket.c:1154)
__sys_recvfrom (net/socket.c:2333)
__x64_sys_recvfrom (net/socket.c:2348 net/socket.c:2344 net/socket.c:2344)
do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
RIP: 0033:0x7f2f268f8e92
Code: 08 0f 85 91 41 ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa 55 bf 01 00
RSP: 002b:00007f2f26874d28 EFLAGS: 00000246 ORIG_RAX: 000000000000002d
RAX: ffffffffffffffda RBX: 00007f2f26879ce4 RCX: 00007f2f268f8e92
RDX: 0000000000004000 RSI: 00007f2f26874db0 RDI: 00000000000007d7
RBP: 00007f2f26874d50 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000021
R13: 00007ffcbb216e70 R14: 0000000000000000 R15: 00007ffcbb216f77
</TASK>
Allocated by task 1009:
kasan_save_track (mm/kasan/common.c:57 mm/kasan/common.c:79)
__kasan_slab_alloc (mm/kasan/common.c:354 mm/kasan/common.c:380)
kmem_cache_alloc_noprof (./include/linux/kasan.h:257 mm/slub.c:4720 mm/slub.c:5033 mm/slub.c:5047)
inet_bind2_bucket_create (net/ipv4/inet_hashtables.c:162)
inet_csk_get_port (net/ipv4/inet_connection_sock.c:573)
__inet_bind (net/ipv4/af_inet.c:544)
inet_bind_sk (net/ipv4/af_inet.c:470)
__sys_bind (net/socket.c:1947 net/socket.c:1978)
__x64_sys_bind (net/socket.c:1983 net/socket.c:1981 net/socket.c:1981)
do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
Freed by task 1009:
kasan_save_track (mm/kasan/common.c:57 mm/kasan/common.c:79)
kasan_save_free_info (mm/kasan/generic.c:599)
__kasan_slab_free (mm/kasan/common.c:267 mm/kasan/common.c:299)
kmem_cache_free (./include/linux/kasan.h:239 mm/slub.c:2780 mm/slub.c:6637 mm/slub.c:6764)
inet_put_port (net/ipv4/inet_hashtables.c:178)
__inet_bind (net/ipv4/af_inet.c:554)
inet_bind_sk (net/ipv4/af_inet.c:470)
__sys_bind (net/socket.c:1947 net/socket.c:1978)
__x64_sys_bind (net/socket.c:1983 net/socket.c:1981 net/socket.c:1981)
do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
The buggy address belongs to the object at ffff88810ae0e780
which belongs to the cache tcp_bind2_bucket of size 80
Fixes: 28044fc1d495 ("net: Add a bhash2 table hashed by port and address")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261121203537.341320-1-kuniyu@google.com
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ipv4/af_inet.c | 2 +-
net/ipv6/af_inet6.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 09bf6e8aa058c..74f6e6e477837 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -548,9 +548,9 @@ int __inet_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len,
if (!(flags & BIND_FROM_BPF)) {
err = BPF_CGROUP_RUN_PROG_INET4_POST_BIND(sk);
if (err) {
- inet->inet_saddr = inet->inet_rcv_saddr = 0;
if (sk->sk_prot->put_port)
sk->sk_prot->put_port(sk);
+ inet->inet_saddr = inet->inet_rcv_saddr = 0;
goto out_release_sock;
}
}
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index f0efdc13baf4e..99b2a182a42cd 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -398,10 +398,10 @@ int __inet6_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len,
if (!(flags & BIND_FROM_BPF)) {
err = BPF_CGROUP_RUN_PROG_INET6_POST_BIND(sk);
if (err) {
- sk->sk_ipv6only = saved_ipv6only;
- inet_reset_saddr(sk);
if (sk->sk_prot->put_port)
sk->sk_prot->put_port(sk);
+ sk->sk_ipv6only = saved_ipv6only;
+ inet_reset_saddr(sk);
goto out;
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 269/742] bpf: Do not allow bpf_d_path() by an id of another BTF
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (259 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 268/742] tcp: Dont clear saddr before ->put_port() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 270/742] bpf: Check that an extension fits the hook of its target Greg Kroah-Hartman
` (465 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 1139c7d8ffcd941d4860a75ef37eb1ffd15b4f87 ]
For a program that is attached to a program attach_btf_id is an id in
the BTF of the target. bpf_d_path_allowed() looks for it in a list of
kernel functions, it can match by chance. Do not look at the list when
there is a target program.
Fixes: 6e22ab9da793 ("bpf: Add d_path helper")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-5-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/trace/bpf_trace.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 08ddadd80056c..74ee56cb068f2 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -976,6 +976,10 @@ BTF_SET_END(btf_allowlist_d_path)
static bool bpf_d_path_allowed(const struct bpf_prog *prog)
{
+ /* attach_btf_id is a function of the target program */
+ if (prog->aux->dst_prog)
+ return false;
+
if (prog->type == BPF_PROG_TYPE_TRACING &&
prog->expected_attach_type == BPF_TRACE_ITER)
return true;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 270/742] bpf: Check that an extension fits the hook of its target
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (260 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 269/742] bpf: Do not allow bpf_d_path() by an id of another BTF Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 271/742] bpf: Take the attach type of the target for tail calls of an extension Greg Kroah-Hartman
` (464 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Anton Protopopov,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit f44d0e6a1d684167d4fc58d313077ba21ad6f301 ]
An extension runs in the hook of its target, and the checks for the hook
do not see it.
Tracing, LSM and struct_ops programs are checked against the BTF of
their hook. An extension takes the type of its target, but it has no
attach_btf and no st_ops, and attach_btf_id and the prototype are those
of the function that it replaces:
- tp_btf: it can read more arguments than the tracepoint has.
- LSM: the range of bpf_get_retval() and bpf_set_retval(), and the
helpers that only some hooks have, are looked up by a wrong id.
- tp_btf and struct_ops: the load can oops.
fentry, fexit, fsession and iterators cannot be extended already. Refuse
the rest. freplace of global functions of tp_btf, fmod_ret and LSM
programs goes away. Targets of other types load with any
expected_attach_type. Do not take their extension for tp_btf or for an
iterator.
Some properties of a program are looked at when it is attached or run.
Nobody looks at those of an extension:
- bpf_get_local_storage() returns the storage of the attached program,
the extension is verified against its own map.
- bpf_override_return() needs a function that allows error injection.
- skb->cb is saved, cleared and restored only for programs that access
it.
Ask for the storage map of the target, at load and at attach. Refuse the
attach when the target does not call bpf_override_return() itself, or
does not access skb->cb. A tail call counts as an access to skb->cb.
Fixes: be8704ff07d2 ("bpf: Introduce dynamic program extensions")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Anton Protopopov <a.s.protopopov@gmail.com>
Link: https://patch.msgid.link/20261125032938.670542-6-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/syscall.c | 18 ++++++++++++++++++
kernel/bpf/verifier.c | 38 +++++++++++++++++++++++++-------------
2 files changed, 43 insertions(+), 13 deletions(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 1836cf9403fe2..12f51650fe6b7 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3830,6 +3830,24 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog,
err = -EINVAL;
goto out_unlock;
}
+ /* Where the return can be overridden is checked for the target only */
+ if (prog->type == BPF_PROG_TYPE_EXT &&
+ prog->kprobe_override && !tgt_prog->kprobe_override) {
+ err = -EINVAL;
+ goto out_unlock;
+ }
+ /* bpf_prog_run_save_cb() and bpf_prog_run_clear_cb() look at the target only */
+ if (prog->type == BPF_PROG_TYPE_EXT &&
+ (tgt_prog->type == BPF_PROG_TYPE_SOCKET_FILTER ||
+ tgt_prog->type == BPF_PROG_TYPE_CGROUP_SKB ||
+ tgt_prog->type == BPF_PROG_TYPE_LWT_IN ||
+ tgt_prog->type == BPF_PROG_TYPE_LWT_OUT ||
+ tgt_prog->type == BPF_PROG_TYPE_LWT_XMIT ||
+ tgt_prog->type == BPF_PROG_TYPE_LWT_SEG6LOCAL) &&
+ prog->cb_access && !tgt_prog->cb_access) {
+ err = -EINVAL;
+ goto out_unlock;
+ }
/*
* The size of these contexts depends on what the program is attached
* to, or run with. That is compared with max_ctx_offset of the program,
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 8b80c25cd3695..74a5277c5b352 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -20380,6 +20380,7 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,
}
if (tgt_prog) {
struct bpf_prog_aux *aux = tgt_prog->aux;
+ enum bpf_cgroup_storage_type stype;
bool tgt_changes_pkt_data;
bool tgt_might_sleep;
@@ -20426,6 +20427,16 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,
"Extension programs should be JITed\n");
return -EINVAL;
}
+ /* bpf_get_local_storage() returns the storage of the target */
+ for_each_cgroup_storage_type(stype) {
+ struct bpf_map *storage = prog->aux->cgroup_storage[stype];
+
+ if (storage && storage != aux->cgroup_storage[stype]) {
+ bpf_log(log,
+ "Extension program has another cgroup storage than original\n");
+ return -EINVAL;
+ }
+ }
/*
* How much of the buffer of the tracepoint is used
* is checked for the program that is attached to it.
@@ -20476,16 +20487,14 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,
bpf_log(log, "Cannot recursively attach\n");
return -EINVAL;
}
- if (tgt_prog->type == BPF_PROG_TYPE_TRACING &&
- prog_extension &&
- (tgt_prog->expected_attach_type == BPF_TRACE_FENTRY ||
- tgt_prog->expected_attach_type == BPF_TRACE_FEXIT ||
- tgt_prog->expected_attach_type == BPF_TRACE_FENTRY_MULTI ||
- tgt_prog->expected_attach_type == BPF_TRACE_FEXIT_MULTI ||
- tgt_prog->expected_attach_type == BPF_TRACE_FSESSION ||
- tgt_prog->expected_attach_type == BPF_TRACE_FSESSION_MULTI)) {
- /* Program extensions can extend all program types
- * except fentry/fexit. The reason is the following.
+ if (prog_extension &&
+ (tgt_prog->type == BPF_PROG_TYPE_TRACING ||
+ tgt_prog->type == BPF_PROG_TYPE_LSM ||
+ tgt_prog->type == BPF_PROG_TYPE_STRUCT_OPS)) {
+ /*
+ * These types are checked against the BTF of their hook,
+ * and an extension has the BTF of its target instead.
+ * There is one more reason for fentry/fexit.
* The fentry/fexit programs are used for performance
* analysis, stats and can be attached to any program
* type. When extension program is replacing XDP function
@@ -20498,7 +20507,7 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,
* beyond reasonable stack size. Hence extending fentry
* is not allowed.
*/
- bpf_log(log, "Cannot extend fentry/fexit/fsession\n");
+ bpf_log(log, "Cannot extend tracing, LSM and struct_ops programs\n");
return -EINVAL;
}
} else {
@@ -20825,10 +20834,13 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
prog->aux->saved_dst_attach_type = tgt_prog->expected_attach_type;
}
- if (prog->expected_attach_type == BPF_TRACE_RAW_TP) {
+ /* An extension has expected_attach_type of its target, it can be any value */
+ if (prog->type != BPF_PROG_TYPE_EXT &&
+ prog->expected_attach_type == BPF_TRACE_RAW_TP) {
prog->aux->attach_btf_trace = true;
return 0;
- } else if (prog->expected_attach_type == BPF_TRACE_ITER) {
+ } else if (prog->type != BPF_PROG_TYPE_EXT &&
+ prog->expected_attach_type == BPF_TRACE_ITER) {
return bpf_iter_prog_supported(prog);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 271/742] bpf: Take the attach type of the target for tail calls of an extension
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (261 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 270/742] bpf: Check that an extension fits the hook of its target Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 272/742] bpf: Compare what a hook tells next to its prototype at tail calls Greg Kroah-Hartman
` (463 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 3d6d222bb9794a054188e9304b5c5f0c30a83063 ]
A prog array compares expected_attach_type. It is 0 for an extension at
the time of the check, so the extension can call programs that were
checked for another attach type, and cannot share an array with its
target. Take the attach type of the target.
Fixes: 4540aed51b12 ("bpf: Enforce expected_attach_type for tailcall compatibility")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-7-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 37f6cbfac5113..6e81e0d9f886f 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -2514,6 +2514,7 @@ static unsigned int __bpf_prog_ret0_warn(const void *ctx,
static bool __bpf_prog_map_compatible(struct bpf_map *map,
const struct bpf_prog *fp)
{
+ enum bpf_attach_type attach_type = fp->expected_attach_type;
enum bpf_prog_type prog_type = resolve_prog_type(fp);
struct bpf_prog_aux *aux = fp->aux;
enum bpf_cgroup_storage_type i;
@@ -2523,6 +2524,9 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map,
if (fp->kprobe_override)
return ret;
+ if (fp->type == BPF_PROG_TYPE_EXT)
+ attach_type = aux->saved_dst_attach_type;
+
spin_lock(&map->owner_lock);
/* There's no owner yet where we could check for compatibility. */
if (!map->owner) {
@@ -2533,7 +2537,7 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map,
map->owner->jited = fp->jited;
map->owner->xdp_has_frags = aux->xdp_has_frags;
map->owner->sleepable = fp->sleepable;
- map->owner->expected_attach_type = fp->expected_attach_type;
+ map->owner->expected_attach_type = attach_type;
map->owner->attach_func_proto = aux->attach_func_proto;
for_each_cgroup_storage_type(i) {
map->owner->storage_cookie[i] =
@@ -2548,7 +2552,7 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map,
map->owner->sleepable == fp->sleepable;
if (ret &&
map->map_type == BPF_MAP_TYPE_PROG_ARRAY &&
- map->owner->expected_attach_type != fp->expected_attach_type)
+ map->owner->expected_attach_type != attach_type)
ret = false;
for_each_cgroup_storage_type(i) {
if (!ret)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 272/742] bpf: Compare what a hook tells next to its prototype at tail calls
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (262 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 271/742] bpf: Take the attach type of the target for tail calls of an extension Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 273/742] bpf: Reserve cookie and ip in the trampoline for " Greg Kroah-Hartman
` (462 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 98ff9cff0b94050d0404e1c5bee717ab3423a2d4 ]
Hooks of one prototype differ in what the verifier assumes:
- struct_ops: two structs can have the same index and prototype of
a member. Nullable and referenced arguments, filters of kfuncs and
the prologue belong to the struct.
- tp_btf: which arguments can be NULL.
- LSM and iterators: what is trusted, helpers, kfuncs, return values.
- A tracer of a program: the context of the target.
Compare that. Tracepoints that agree, and tracers of kernel functions,
share a prog array as before. Two LSM hooks cannot.
Fixes: 28ead3eaabc1 ("bpf: Prevent tail call between progs attached to different hooks")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-8-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/bpf.h | 3 +++
include/linux/btf.h | 1 +
kernel/bpf/btf.c | 10 ++++++++++
kernel/bpf/core.c | 20 ++++++++++++++++++--
kernel/bpf/syscall.c | 1 +
5 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index c4d1053bfe2bf..01d046553ec90 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -295,7 +295,9 @@ struct bpf_map_owner {
bool sleepable;
u64 storage_cookie[MAX_BPF_CGROUP_STORAGE_TYPE];
const struct btf_type *attach_func_proto;
+ const struct bpf_struct_ops *st_ops;
enum bpf_attach_type expected_attach_type;
+ u64 hook_key;
};
struct bpf_map {
@@ -1808,6 +1810,7 @@ struct bpf_prog_aux {
struct mutex dst_mutex; /* protects dst_* pointers below, *after* prog becomes visible */
struct bpf_prog *dst_prog;
struct bpf_trampoline *dst_trampoline;
+ enum bpf_prog_type saved_dst_ctx_type;
enum bpf_prog_type saved_dst_prog_type;
enum bpf_attach_type saved_dst_attach_type;
bool verifier_zext; /* Zero extensions has been inserted by verifier. */
diff --git a/include/linux/btf.h b/include/linux/btf.h
index 19eff0c17b2af..818c8a8a10875 100644
--- a/include/linux/btf.h
+++ b/include/linux/btf.h
@@ -145,6 +145,7 @@ struct btf_struct_metas {
extern const struct file_operations btf_fops;
const char *btf_get_name(const struct btf *btf);
+u64 btf_raw_tp_null_mask(const struct bpf_prog *prog);
void btf_get(struct btf *btf);
void btf_put(struct btf *btf);
const struct btf_header *btf_header(const struct btf *btf);
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index b13302f33ff5c..e25e07825db8e 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -6916,6 +6916,16 @@ static const struct bpf_raw_tp_null_args raw_tp_null_args[] = {
{ "amdtp_packet", 0x100 },
};
+u64 btf_raw_tp_null_mask(const struct bpf_prog *prog)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(raw_tp_null_args); i++)
+ if (!strcmp(prog->aux->attach_func_name, raw_tp_null_args[i].func))
+ return raw_tp_null_args[i].mask;
+ return btf_is_module(prog->aux->attach_btf) ? U64_MAX : 0;
+}
+
bool btf_ctx_access(int off, int size, enum bpf_access_type type,
const struct bpf_prog *prog,
struct bpf_insn_access_aux *info)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 6e81e0d9f886f..6feb5d49e390c 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -2511,6 +2511,18 @@ static unsigned int __bpf_prog_ret0_warn(const void *ctx,
return 0;
}
+/* What the verifier took from the hook, next to its prototype */
+static u64 bpf_prog_hook_key(const struct bpf_prog *fp)
+{
+ if (IS_ENABLED(CONFIG_BPF_SYSCALL) && fp->aux->attach_btf_trace)
+ return btf_raw_tp_null_mask(fp);
+ if (fp->type == BPF_PROG_TYPE_TRACING && fp->expected_attach_type != BPF_TRACE_ITER)
+ return fp->aux->saved_dst_ctx_type;
+ if (fp->type == BPF_PROG_TYPE_TRACING || fp->type == BPF_PROG_TYPE_LSM)
+ return fp->aux->attach_btf_id;
+ return 0;
+}
+
static bool __bpf_prog_map_compatible(struct bpf_map *map,
const struct bpf_prog *fp)
{
@@ -2518,8 +2530,8 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map,
enum bpf_prog_type prog_type = resolve_prog_type(fp);
struct bpf_prog_aux *aux = fp->aux;
enum bpf_cgroup_storage_type i;
+ u64 cookie, hook_key = bpf_prog_hook_key(fp);
bool ret = false;
- u64 cookie;
if (fp->kprobe_override)
return ret;
@@ -2539,6 +2551,8 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map,
map->owner->sleepable = fp->sleepable;
map->owner->expected_attach_type = attach_type;
map->owner->attach_func_proto = aux->attach_func_proto;
+ map->owner->st_ops = aux->st_ops;
+ map->owner->hook_key = hook_key;
for_each_cgroup_storage_type(i) {
map->owner->storage_cookie[i] =
aux->cgroup_storage[i] ?
@@ -2549,7 +2563,9 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map,
ret = map->owner->type == prog_type &&
map->owner->jited == fp->jited &&
map->owner->xdp_has_frags == aux->xdp_has_frags &&
- map->owner->sleepable == fp->sleepable;
+ map->owner->sleepable == fp->sleepable &&
+ map->owner->st_ops == aux->st_ops &&
+ map->owner->hook_key == hook_key;
if (ret &&
map->map_type == BPF_MAP_TYPE_PROG_ARRAY &&
map->owner->expected_attach_type != attach_type)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 12f51650fe6b7..51b2fe61b1da9 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3078,6 +3078,7 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, struct bpf_log_at
prog->aux->attach_btf_id = multi_func ? bpf_multi_func_btf_id[0] : attr->attach_btf_id;
prog->aux->dst_prog = dst_prog;
if (dst_prog) {
+ prog->aux->saved_dst_ctx_type = resolve_prog_type(dst_prog);
prog->aux->saved_dst_prog_type = dst_prog->type;
prog->aux->saved_dst_attach_type = dst_prog->expected_attach_type;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 273/742] bpf: Reserve cookie and ip in the trampoline for tail calls
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (263 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 272/742] bpf: Compare what a hook tells next to its prototype at tail calls Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 274/742] bpf: Check that a program and a struct_ops map are for the same struct Greg Kroah-Hartman
` (461 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit bf675c92165500367509fc126338ef3dea4611ed ]
The trampoline has a session cookie and the address of the function
only when the program that is attached asks for them. After a tail call
bpf_get_func_ip() returns what is on the stack, and
bpf_session_cookie() points to the first argument, which the trampoline
passes to the function:
KASAN: maybe wild-memory-access in range [0x4141414141414148-0x414141414141414f]
RIP: 0010:vfs_truncate+0x32/0x450
Ask for both when the program has a tail call.
Fixes: 9b99edcae5c8 ("bpf: Add bpf_get_func_ip helper for tracing programs")
Fixes: eeee4239dbb1 ("bpf: support fsession for bpf_session_cookie")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-9-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/fixups.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/bpf/fixups.c b/kernel/bpf/fixups.c
index 524e6d3de0776..927078bda67be 100644
--- a/kernel/bpf/fixups.c
+++ b/kernel/bpf/fixups.c
@@ -2018,6 +2018,10 @@ int bpf_do_misc_fixups(struct bpf_verifier_env *env)
* the program array.
*/
prog->cb_access = 1;
+ prog->call_get_func_ip = 1;
+ if (prog_type == BPF_PROG_TYPE_TRACING &&
+ (eatype == BPF_TRACE_FSESSION || eatype == BPF_TRACE_FSESSION_MULTI))
+ prog->call_session_cookie = 1;
if (!bpf_allow_tail_call_in_subprogs(env))
prog->aux->stack_depth = MAX_BPF_STACK;
prog->aux->max_pkt_offset = MAX_PACKET_OFF;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 274/742] bpf: Check that a program and a struct_ops map are for the same struct
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (264 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 273/742] bpf: Reserve cookie and ip in the trampoline for " Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 275/742] bpf: Keep the names in front of a number in delegate options Greg Kroah-Hartman
` (460 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 80184a7381c11eae0103f0c432e2adf6a5fd476f ]
A map takes a program when the id of the struct and the index of the
member are the same. Ids of types are not unique among modules. Compare
BTF too.
BPF_PROG_ASSOC_STRUCT_OPS takes any struct_ops map, and the callers of
bpf_prog_get_assoc_struct_ops() take the result for their own struct.
Pass the struct_ops that the caller wants, return NULL for another one.
The callers are scx_prog_sched() of sched_ext and bpf_testmod, they
change with the prototype.
Fixes: f6be98d19985 ("bpf, net: switch to dynamic registration")
Fixes: b5709f6d26d6 ("bpf: Support associating BPF program with struct_ops")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-10-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/bpf.h | 6 ++++--
kernel/bpf/bpf_struct_ops.c | 8 ++++++--
kernel/sched/ext/internal.h | 5 ++++-
tools/testing/selftests/bpf/test_kmods/bpf_testmod.c | 6 ++++--
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 01d046553ec90..a5e49895d6901 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -2307,7 +2307,8 @@ static inline void bpf_module_put(const void *data, struct module *owner)
int bpf_struct_ops_link_create(union bpf_attr *attr);
int bpf_prog_assoc_struct_ops(struct bpf_prog *prog, struct bpf_map *map);
void bpf_prog_disassoc_struct_ops(struct bpf_prog *prog);
-void *bpf_prog_get_assoc_struct_ops(const struct bpf_prog_aux *aux);
+void *bpf_prog_get_assoc_struct_ops(const struct bpf_prog_aux *aux,
+ const struct bpf_struct_ops *st_ops);
u32 bpf_struct_ops_id(const void *kdata);
int bpf_struct_ops_for_each_prog(const void *kdata,
int (*cb)(struct bpf_prog *prog, void *data),
@@ -2365,7 +2366,8 @@ static inline int bpf_prog_assoc_struct_ops(struct bpf_prog *prog, struct bpf_ma
static inline void bpf_prog_disassoc_struct_ops(struct bpf_prog *prog)
{
}
-static inline void *bpf_prog_get_assoc_struct_ops(const struct bpf_prog_aux *aux)
+static inline void *bpf_prog_get_assoc_struct_ops(const struct bpf_prog_aux *aux,
+ const struct bpf_struct_ops *st_ops)
{
return NULL;
}
diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c
index d7c3030bc63b0..3b747eb52aa3a 100644
--- a/kernel/bpf/bpf_struct_ops.c
+++ b/kernel/bpf/bpf_struct_ops.c
@@ -844,6 +844,7 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
}
if (prog->type != BPF_PROG_TYPE_STRUCT_OPS ||
+ prog->aux->attach_btf != st_map->btf ||
prog->aux->attach_btf_id != st_ops_desc->type_id ||
prog->expected_attach_type != i) {
bpf_prog_put(prog);
@@ -1540,13 +1541,14 @@ void bpf_prog_disassoc_struct_ops(struct bpf_prog *prog)
* Get a reference to the struct_ops struct (i.e., kdata) associated with a
* program. Should only be called in BPF program context (e.g., in a kfunc).
*
- * If the returned pointer is not NULL, it must points to a valid struct_ops.
+ * If the returned pointer is not NULL, it must points to a valid @st_ops.
* The struct_ops map is not guaranteed to be initialized nor attached.
* Kernel struct_ops implementers are responsible for tracking and checking
* the state of the struct_ops if the use case requires an initialized or
* attached struct_ops.
*/
-void *bpf_prog_get_assoc_struct_ops(const struct bpf_prog_aux *aux)
+void *bpf_prog_get_assoc_struct_ops(const struct bpf_prog_aux *aux,
+ const struct bpf_struct_ops *st_ops)
{
struct bpf_struct_ops_map *st_map;
struct bpf_map *st_ops_assoc;
@@ -1556,6 +1558,8 @@ void *bpf_prog_get_assoc_struct_ops(const struct bpf_prog_aux *aux)
return NULL;
st_map = (struct bpf_struct_ops_map *)st_ops_assoc;
+ if (st_map->st_ops_desc->st_ops != st_ops)
+ return NULL;
return &st_map->kvalue.data;
}
diff --git a/kernel/sched/ext/internal.h b/kernel/sched/ext/internal.h
index 2f35b98adb72b..974b4da74ab88 100644
--- a/kernel/sched/ext/internal.h
+++ b/kernel/sched/ext/internal.h
@@ -2520,6 +2520,8 @@ static inline bool scx_task_on_sched(struct scx_sched *sch,
return rcu_access_pointer(p->scx.sched) == sch;
}
+static struct bpf_struct_ops bpf_sched_ext_ops, bpf_sched_ext_ops_cid;
+
/**
* scx_prog_sched - Find scx_sched associated with a BPF prog
* @aux: aux passed in from BPF to a kfunc
@@ -2533,7 +2535,8 @@ static inline struct scx_sched *scx_prog_sched(const struct bpf_prog_aux *aux)
struct sched_ext_ops *ops;
struct scx_sched *sch, *root;
- ops = bpf_prog_get_assoc_struct_ops(aux);
+ ops = bpf_prog_get_assoc_struct_ops(aux, &bpf_sched_ext_ops) ?:
+ bpf_prog_get_assoc_struct_ops(aux, &bpf_sched_ext_ops_cid);
if (likely(ops)) {
sch = rcu_dereference_all(ops->priv);
if (sch && unlikely(READ_ONCE(sch->dead)))
diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
index 9366a3c578f13..d507ba37731b8 100644
--- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
@@ -2020,13 +2020,15 @@ int bpf_kfunc_multi_st_ops_test_1(struct st_ops_args *args, u32 id)
return ret;
}
+static struct bpf_struct_ops testmod_multi_st_ops;
+
/* Call test_1() of the associated struct_ops map */
int bpf_kfunc_multi_st_ops_test_1_assoc(struct st_ops_args *args, struct bpf_prog_aux *aux)
{
struct bpf_testmod_multi_st_ops *st_ops;
int ret = -1;
- st_ops = (struct bpf_testmod_multi_st_ops *)bpf_prog_get_assoc_struct_ops(aux);
+ st_ops = bpf_prog_get_assoc_struct_ops(aux, &testmod_multi_st_ops);
if (st_ops)
ret = st_ops->test_1(args);
@@ -2104,7 +2106,7 @@ static struct bpf_testmod_multi_st_ops multi_st_ops_cfi_stubs = {
.test_1 = bpf_testmod_multi_st_ops__test_1,
};
-struct bpf_struct_ops testmod_multi_st_ops = {
+static struct bpf_struct_ops testmod_multi_st_ops = {
.verifier_ops = &bpf_testmod_verifier_ops,
.init = multi_st_ops_init,
.init_member = multi_st_ops_init_member,
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 275/742] bpf: Keep the names in front of a number in delegate options
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (265 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 274/742] bpf: Check that a program and a struct_ops map are for the same struct Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 276/742] bpf: Do not trust the neighbour of tp_btf/neigh_create Greg Kroah-Hartman
` (459 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 4151f3558d6e65d4ae6cf1a431537ed52ad48239 ]
The delegate_* mount options of bpffs take names and numbers. A number
overwrites the mask, the names in front of it are lost. That is the
order in which /proc/mounts shows them.
Fixes: 6c1752e0b6ca ("bpf: Support symbolic BPF FS delegation mount options")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-11-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/inode.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 7837968c0842c..f3b1e440d0cb1 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -1055,7 +1055,7 @@ static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
struct bpffs_btf_enums info;
const struct btf_type *enum_t;
const char *enum_pfx;
- u64 *delegate_msk, msk = 0;
+ u64 *delegate_msk, msk = 0, num;
char *p, *str;
int val;
@@ -1094,9 +1094,10 @@ static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
} else if (find_btf_enum_const(info.btf, enum_t, enum_pfx, p, &val)) {
msk |= 1ULL << val;
} else {
- err = kstrtou64(p, 0, &msk);
+ err = kstrtou64(p, 0, &num);
if (err)
return err;
+ msk |= num;
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 276/742] bpf: Do not trust the neighbour of tp_btf/neigh_create
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (266 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 275/742] bpf: Keep the names in front of a number in delegate options Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 277/742] bpf: Leave nothing behind in the frame of bpf_throw() Greg Kroah-Hartman
` (458 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 2c517088d2ef5f9b17fcb2e44a296e36c5a91843 ]
___neigh_create() calls the tracepoint before it tests the result of
neigh_alloc(). It is NULL when the table is full. The verifier takes it
for a trusted pointer, and a load through it oopses:
BUG: kernel NULL pointer dereference, address: 000000000000013c
RIP: 0010:bpf_prog_56e3384dcafb1b5b_on_create+0x61/0xc4
Mark it untrusted, loads through it are probed then. PTR_MAYBE_NULL
would refuse programs like bpftune, which pass &n->parms to
bpf_probe_read_kernel() without a check. The pointer cannot be passed
as memory or as a trusted argument any more.
Fixes: 838a10bd2ebf ("bpf: Augment raw_tp arguments with PTR_MAYBE_NULL")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-12-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/btf.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index e25e07825db8e..4830d9e4ebf5b 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -6911,6 +6911,7 @@ static const struct bpf_raw_tp_null_args raw_tp_null_args[] = {
/* iptfs */
{ "iptfs_ingress_postq_event", 0x1000 },
/* neigh */
+ { "neigh_create", 0x4000 },
{ "neigh_update", 0x10 },
/* snd_firewire_lib */
{ "amdtp_packet", 0x100 },
@@ -7119,6 +7120,9 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,
/* Is the current arg IS_ERR? */
if (raw_tp_null_args[i].mask & (0x2ULL << (arg * 4)))
ptr_err_raw_tp = true;
+ /* It can be NULL, and programs that do not check it have to load */
+ if (raw_tp_null_args[i].mask & (0x4ULL << (arg * 4)))
+ info->reg_type = PTR_TO_BTF_ID | PTR_UNTRUSTED;
break;
}
/* If we don't know NULL-ness specification and the tracepoint
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 277/742] bpf: Leave nothing behind in the frame of bpf_throw()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (267 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 276/742] bpf: Do not trust the neighbour of tp_btf/neigh_create Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 278/742] bpf: Add the symbol of a prog before its id Greg Kroah-Hartman
` (457 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 86cedb416c4651dde27cfb8142541de8dd2801d9 ]
bpf_throw() does not return. What is kept for the return stays behind.
With fexit on bpf_throw() the trampoline is never freed. With kretprobes
and function_graph the next traced function up the stack takes the
return address of bpf_throw() for its own. Mark it notrace and
NOKPROBE_SYMBOL.
kasan_unpoison_task_stack_below() takes the stack for aligned to
THREAD_SIZE. The stack for interrupts of x86-64 is aligned to a page.
A program that throws in softirq can leave the redzones of bpf_throw()
there:
BUG: KASAN: stack-out-of-bounds in stack_trace_consume_entry+0x14e/0x170
It is the only frame with redzones that is skipped. Do not instrument
it.
Fixes: f18b03fabaa9 ("bpf: Implement BPF exceptions")
Fixes: ec5290a178b7 ("bpf: Prevent KASAN false positive with bpf_throw")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-14-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/helpers.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 13b0ee50254b3..aaa646b5be736 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -22,7 +22,7 @@
#include <linux/security.h>
#include <linux/btf_ids.h>
#include <linux/bpf_mem_alloc.h>
-#include <linux/kasan.h>
+#include <linux/kprobes.h>
#include <linux/bpf_verifier.h>
#include <linux/uaccess.h>
#include <linux/verification.h>
@@ -3405,7 +3405,8 @@ static bool bpf_stack_walker(void *cookie, u64 ip, u64 sp, u64 bp)
return false;
}
-__bpf_kfunc void bpf_throw(u64 cookie)
+/* It does not return. What a tracer keeps for the return would stay behind, redzones too. */
+__bpf_kfunc notrace __no_sanitize_address void bpf_throw(u64 cookie)
{
struct bpf_throw_ctx ctx = {};
@@ -3415,16 +3416,10 @@ __bpf_kfunc void bpf_throw(u64 cookie)
WARN_ON_ONCE(!ctx.aux->exception_boundary);
WARN_ON_ONCE(!ctx.bp);
WARN_ON_ONCE(!ctx.cnt);
- /*
- * Prevent KASAN false positives for CONFIG_KASAN_STACK by unpoisoning
- * deeper stack depths than ctx.sp as we do not return from bpf_throw,
- * which skips compiler generated instrumentation to do the same. Some
- * architectures cannot recover sp while unwinding, so fall back to bp.
- */
- kasan_unpoison_task_stack_below((void *)(long)(ctx.sp ?: ctx.bp));
ctx.aux->bpf_exception_cb(cookie, ctx.sp + ctx.aux->stack_arg_sp_adjust, ctx.bp, 0, 0);
WARN(1, "A call to BPF exception callback should never return\n");
}
+NOKPROBE_SYMBOL(bpf_throw);
__bpf_kfunc int bpf_wq_init(struct bpf_wq *wq, void *p__const_map, unsigned int flags)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 278/742] bpf: Add the symbol of a prog before its id
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (268 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 277/742] bpf: Leave nothing behind in the frame of bpf_throw() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 279/742] bpf: Do not fill jited line info for a hidden subprog Greg Kroah-Hartman
` (456 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit f7a40c2de8d4abdea6d1e21122b447b593e28bd9 ]
A prog can be taken by its id and run before bpf_prog_kallsyms_add().
bpf_throw() does not find the main prog and oopses:
KASAN: null-ptr-deref in range [0x0000000000000568-0x000000000000056f]
RIP: 0010:bpf_throw+0x129/0x220
The exception table is found by the same symbol.
Add the symbol first. bpf_prog_free() removes it when there is no id.
Fixes: 3dec541b2e63 ("bpf: Add support for BTF pointers to x86 JIT")
Fixes: f18b03fabaa9 ("bpf: Implement BPF exceptions")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-15-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/syscall.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 51b2fe61b1da9..152191a6de5b2 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3162,6 +3162,9 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, struct bpf_log_at
if (err < 0)
goto free_used_maps;
+ /* bpf_throw() and faults look for the symbol. The prog can run once it has the id. */
+ bpf_prog_kallsyms_add(prog);
+
err = bpf_prog_alloc_id(prog);
if (err)
goto free_used_maps;
@@ -3180,7 +3183,6 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr, struct bpf_log_at
* Also, any failure handling from this point onwards must
* be using bpf_prog_put() given the program is exposed.
*/
- bpf_prog_kallsyms_add(prog);
perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_LOAD, 0);
bpf_audit_prog(prog, BPF_AUDIT_LOAD);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 279/742] bpf: Do not fill jited line info for a hidden subprog
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (269 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 278/742] bpf: Add the symbol of a prog before its id Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 280/742] bpf: Fix NULL dereference in XDP redirect from async callbacks Greg Kroah-Hartman
` (455 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 2f2b119ea30dfba27563c1c939eb42b5298a391a ]
func_idx of the default exception callback is func_cnt, and the test
for hidden subprogs is off by one. The address of the callback goes to
jited_linfo[0]. libbpf and bpftool refuse the jited line info of the
prog.
Fixes: 335d1c5b5452 ("bpf: Implement support for adding hidden subprogs")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-16-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 6feb5d49e390c..e5c1bc0100036 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -236,7 +236,8 @@ void bpf_prog_fill_jited_linfo(struct bpf_prog *prog,
const struct bpf_line_info *linfo;
void **jited_linfo;
- if (!prog->aux->jited_linfo || prog->aux->func_idx > prog->aux->func_cnt)
+ if (!prog->aux->jited_linfo ||
+ (prog->aux->func_idx && prog->aux->func_idx >= prog->aux->func_cnt))
/* Userspace did not provide linfo */
return;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 280/742] bpf: Fix NULL dereference in XDP redirect from async callbacks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (270 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 279/742] bpf: Do not fill jited line info for a hidden subprog Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 281/742] bpf: Check the attach type when a cgroup link gets another program Greg Kroah-Hartman
` (454 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit f28ed533106bc01aedba6ba47c0e1a1098c92092 ]
bpf_redirect() and bpf_redirect_map() do not take the context, so the
timer callback of an XDP program can call them. There is no
current->bpf_net_context then:
KASAN: null-ptr-deref in range [0x0000000000000038-0x000000000000003f]
RIP: 0010:bpf_xdp_redirect+0x5b/0x170
Return XDP_ABORTED, like the tc helpers return TC_ACT_SHOT. It is one
more test and branch on a value that is loaded anyway.
Fixes: 401cb7dae813 ("net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-17-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/filter.h | 5 +++--
net/core/filter.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 39decde7fc730..94bbdb948ab02 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1863,13 +1863,14 @@ static __always_inline long __bpf_xdp_redirect_map(struct bpf_map *map, u64 inde
u64 flags, const u64 flag_mask,
void *lookup_elem(struct bpf_map *map, u32 key))
{
- struct bpf_redirect_info *ri = bpf_net_ctx_get_ri();
const u64 action_mask = XDP_ABORTED | XDP_DROP | XDP_PASS | XDP_TX;
+ struct bpf_redirect_info *ri;
/* Lower bits of the flags are used as return code on lookup failure */
- if (unlikely(flags & ~(action_mask | flag_mask)))
+ if (unlikely(!bpf_net_ctx_get() || flags & ~(action_mask | flag_mask)))
return XDP_ABORTED;
+ ri = bpf_net_ctx_get_ri();
ri->tgt_value = lookup_elem(map, index);
if (unlikely(!ri->tgt_value) && !(flags & BPF_F_BROADCAST)) {
/* If the lookup fails we want to clear out the state in the
diff --git a/net/core/filter.c b/net/core/filter.c
index 30bbd0c20a044..53ca1457fd331 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4895,11 +4895,12 @@ int xdp_do_generic_redirect(struct net_device *dev, struct sk_buff *skb,
BPF_CALL_2(bpf_xdp_redirect, u32, ifindex, u64, flags)
{
- struct bpf_redirect_info *ri = bpf_net_ctx_get_ri();
+ struct bpf_redirect_info *ri;
- if (unlikely(flags))
+ if (unlikely(!bpf_net_ctx_get() || flags))
return XDP_ABORTED;
+ ri = bpf_net_ctx_get_ri();
/* NB! Map type UNSPEC and map_id == INT_MAX (never generated
* by map_idr) is used for ifindex based XDP redirect.
*/
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 281/742] bpf: Check the attach type when a cgroup link gets another program
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (271 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 280/742] bpf: Fix NULL dereference in XDP redirect from async callbacks Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 282/742] bpf: Refuse metadata maps of signed programs that can be mapped writable Greg Kroah-Hartman
` (453 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit a5e757f6cb34e1be0700359a02567722bcbbf6e3 ]
BPF_LINK_UPDATE compares only the type of the program. A program that is
verified for one hook runs in another one. In setsockopt the result of
bpf_get_retval() is an errno, in getsockopt it is any int.
Check expected_attach_type, as the attach does.
Fixes: 0c991ebc8c69 ("bpf: Implement bpf_prog replacement for an active bpf_cgroup_link")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-18-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/cgroup.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index 59326938a01ea..7455d0b7d559c 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -1040,6 +1040,24 @@ static bool cgroup_bpf_storages_compatible(struct bpf_prog *old_prog,
return true;
}
+/* See bpf_prog_attach_check_attach_type() */
+static bool prog_is_for_attach_type(const struct bpf_prog *prog, enum bpf_attach_type type)
+{
+ switch (prog->type) {
+ case BPF_PROG_TYPE_CGROUP_SKB:
+ if (!prog->enforce_expected_attach_type)
+ return true;
+ fallthrough;
+ case BPF_PROG_TYPE_CGROUP_SOCK:
+ case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
+ case BPF_PROG_TYPE_CGROUP_SOCKOPT:
+ case BPF_PROG_TYPE_LSM:
+ return prog->expected_attach_type == type;
+ default:
+ return true;
+ }
+}
+
/**
* __cgroup_bpf_replace() - Replace link's program and propagate the change
* to descendants
@@ -1066,7 +1084,8 @@ static int __cgroup_bpf_replace(struct cgroup *cgrp,
progs = &cgrp->bpf.progs[atype];
- if (link->link.prog->type != new_prog->type)
+ if (link->link.prog->type != new_prog->type ||
+ !prog_is_for_attach_type(new_prog, link->link.attach_type))
return -EINVAL;
hlist_for_each_entry(pl, progs, node) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 282/742] bpf: Refuse metadata maps of signed programs that can be mapped writable
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (272 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 281/742] bpf: Check the attach type when a cgroup link gets another program Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 283/742] bpf: Take bpf_lock with interrupts disabled Greg Kroah-Hartman
` (452 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit c66c8adf3226e02b74a33728d1fa1e911c3f0d21 ]
The signature of a program covers the value of its metadata maps. It
holds because they are frozen and exclusive. The freeze is not final for
an array that user space was allowed to map for writing, which is why
bpf_map_mmap() refuses that for read-only maps. A loader writes to its
map, so it's not one of those.
Refuse a map that has BPF_F_MMAPABLE without BPF_F_RDONLY_PROG. Light
skeletons do not set it.
Fixes: b707068e0ed9 ("bpf: Verify signed loader metadata at load time")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-19-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Documentation/bpf/signing.rst | 3 ++-
kernel/bpf/verifier.c | 7 +++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/Documentation/bpf/signing.rst b/Documentation/bpf/signing.rst
index e73eaaebd8b15..102d86f18a6e6 100644
--- a/Documentation/bpf/signing.rst
+++ b/Documentation/bpf/signing.rst
@@ -141,7 +141,8 @@ reuses the existing ``fd_array``:
``excl_prog_sha``) and a plain array map (``BPF_MAP_TYPE_ARRAY``); only an
array map exposes its value buffer through ``map_direct_value_addr()`` as a
kernel address spanning ``value_size`` bytes. A map that is not exclusive, not
- frozen, or not a plain array is rejected, with a verifier log message naming
+ frozen, not a plain array, or that user space could map for writing
+ (``BPF_F_MMAPABLE``) is rejected, with a verifier log message naming
the offending map. The kernel appends each map's frozen
contents to the instruction buffer and verifies the PKCS#7 signature over the
concatenation ``insns || metadata_0 || metadata_1 || ...`` in ``used_maps``
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 74a5277c5b352..7667982d4e38e 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -21405,6 +21405,13 @@ static int bpf_prog_verify_signature(struct bpf_verifier_env *env,
err = -EPERM;
goto out;
}
+ /* The freeze is not final for it, see bpf_map_mmap() */
+ if ((map->map_flags & BPF_F_MMAPABLE) && !(map->map_flags & BPF_F_RDONLY_PROG)) {
+ verbose(env, "signed program metadata map '%s' must not be mmapable\n",
+ map->name);
+ err = -EPERM;
+ goto out;
+ }
data_sz += map->value_size;
}
if (bpf_dynptr_check_size(data_sz)) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 283/742] bpf: Take bpf_lock with interrupts disabled
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (273 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 282/742] bpf: Refuse metadata maps of signed programs that can be mapped writable Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 284/742] bpf: Refuse mmap() of a part of an arena Greg Kroah-Hartman
` (451 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 2c00b6b35af0122f1b1fc0ea029bcb567fd4f1b8 ]
A program can disable interrupts with bpf_local_irq_save().
bpf_setsockopt(TCP_CONGESTION) can put the last reference of a
struct_ops map there, which removes the symbols of the trampolines with
spin_lock_bh(). Use the irqsave lock, as bpf_map_free_id() does.
PREEMPT_RT is as before, both locks sleep there.
Fixes: 5db69b0fbdc8 ("bpf: Make struct_ops tasks_rcu grace period optional")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-20-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index e5c1bc0100036..44eb17428fbc3 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -644,11 +644,10 @@ static struct latch_tree_root bpf_tree __cacheline_aligned;
void bpf_ksym_add(struct bpf_ksym *ksym)
{
- spin_lock_bh(&bpf_lock);
+ guard(spinlock_irqsave)(&bpf_lock);
WARN_ON_ONCE(!list_empty(&ksym->lnode));
list_add_tail_rcu(&ksym->lnode, &bpf_kallsyms);
latch_tree_insert(&ksym->tnode, &bpf_tree, &bpf_tree_ops);
- spin_unlock_bh(&bpf_lock);
}
static void __bpf_ksym_del(struct bpf_ksym *ksym)
@@ -662,9 +661,8 @@ static void __bpf_ksym_del(struct bpf_ksym *ksym)
void bpf_ksym_del(struct bpf_ksym *ksym)
{
- spin_lock_bh(&bpf_lock);
+ guard(spinlock_irqsave)(&bpf_lock);
__bpf_ksym_del(ksym);
- spin_unlock_bh(&bpf_lock);
}
static bool bpf_prog_kallsyms_candidate(const struct bpf_prog *fp)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 284/742] bpf: Refuse mmap() of a part of an arena
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (274 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 283/742] bpf: Take bpf_lock with interrupts disabled Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 285/742] bpf: Flush TLB when a page of arena replaces the scratch page Greg Kroah-Hartman
` (450 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 0cd1f2029b1b9fd7ceb52e3dfec181452cf20be0 ]
The first mmap() sets the addresses of an arena that has no map_extra.
It can be shorter than max_entries, but all pages stay in the range
tree. An allocation without an address gets pages behind the end of the
mapping. They can be mapped behind the vmalloc area of the arena.
Require the length of the whole arena, as for an arena with map_extra.
libbpf and cilium/ebpf map all pages.
Fixes: b795379757eb ("bpf: Introduce range_tree data structure and use it in bpf arena")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-22-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/arena.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
index 5b65ffefbebd6..10fa8e7f3fa6a 100644
--- a/kernel/bpf/arena.c
+++ b/kernel/bpf/arena.c
@@ -637,16 +637,13 @@ static unsigned long arena_get_unmapped_area(struct file *filp, unsigned long ad
return -EINVAL;
if (len > (u64)map->max_entries * PAGE_SIZE)
return -E2BIG;
+ /* each page in the range tree needs an address */
+ if (len < (u64)map->max_entries * PAGE_SIZE)
+ return -EINVAL;
/* if user_vm_start was specified at arena creation time */
- if (arena->user_vm_start) {
- if (len > arena->user_vm_end - arena->user_vm_start)
- return -E2BIG;
- if (len != arena->user_vm_end - arena->user_vm_start)
- return -EINVAL;
- if (addr != arena->user_vm_start)
- return -EINVAL;
- }
+ if (arena->user_vm_start && addr != arena->user_vm_start)
+ return -EINVAL;
/*
* Without MAP_FIXED the mm finds a free range. Ask for twice the
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 285/742] bpf: Flush TLB when a page of arena replaces the scratch page
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (275 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 284/742] bpf: Refuse mmap() of a part of an arena Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 286/742] bpf: Fix reads past an enum in prints of BTF data Greg Kroah-Hartman
` (449 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 16829046f0a0df75fe0a0b937771ffa301b650f7 ]
A fault of a kfunc maps the scratch page. An allocation at that address
puts a new page in its place. flush_tlb_before_set() is empty on x86,
so all cpus that have touched the address keep the scratch page in TLB.
The program reads junk from the page that it has got, and its writes
are lost.
The flush takes an IPI. Do it after the lock is dropped when the caller
can sleep. Otherwise fail and free the range: the work unmaps the
scratch page and flushes TLB. The range is taken until then. As with
any deferred free, it stays taken when kmalloc_nolock() of the span
fails.
Fixes: f64c723741c9 ("bpf: Replace scratch PTE atomically when allocating arena pages")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-23-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/arena.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/kernel/bpf/arena.c b/kernel/bpf/arena.c
index 10fa8e7f3fa6a..f1958196c7a8d 100644
--- a/kernel/bpf/arena.c
+++ b/kernel/bpf/arena.c
@@ -149,6 +149,8 @@ struct apply_range_data {
struct bpf_arena *arena;
struct llist_head *pages;
int i;
+ bool can_flush; /* the caller can flush TLB of all cpus after it drops the lock */
+ bool flush;
};
struct clear_range_data {
@@ -189,6 +191,12 @@ static int apply_range_set_cb(pte_t *pte, unsigned long addr, void *data)
continue;
if (WARN_ON_ONCE(pte_page(old) != d->arena->scratch_page))
return -EBUSY;
+#ifndef flush_tlb_before_set
+ /* The scratch page is in TLB, and it takes an IPI to flush it */
+ if (!d->can_flush)
+ return -EBUSY;
+ d->flush = true;
+#endif
ptep_get_and_clear(&init_mm, addr, pte);
flush_tlb_before_set(addr);
}
@@ -571,6 +579,7 @@ static vm_fault_t arena_vm_fault(struct vm_fault *vmf)
}
llist_add(&new_page->pcp_llist, &pages);
data.arena = arena;
+ data.can_flush = false;
data.pages = &pages;
data.i = 0;
@@ -802,6 +811,8 @@ static long arena_alloc_pages(struct bpf_arena *arena, long uaddr, long page_cnt
goto out_memcg;
data.arena = arena;
+ data.can_flush = sleepable;
+ data.flush = false;
data.pages = &pages;
data.i = 0;
@@ -832,17 +843,18 @@ static long arena_alloc_pages(struct bpf_arena *arena, long uaddr, long page_cnt
flush_vmap_cache(kern_vm_start + uaddr32, mapped << PAGE_SHIFT);
raw_res_spin_unlock_irqrestore(&arena->spinlock, flags);
+ if (data.flush)
+ flush_tlb_kernel_range(kern_vm_start + uaddr32,
+ kern_vm_start + uaddr32 + (mapped << PAGE_SHIFT));
addr = clear_lo32(arena->user_vm_start) + uaddr32;
goto out_memcg;
out_unmap:
- /* Error handling: Undo partial mappings. */
+ /* Error handling: Undo partial mappings, unmap the scratch page. */
flush_vmap_cache(kern_vm_start + uaddr32, mapped << PAGE_SHIFT);
- range_tree_set(&arena->rt, pgoff + mapped, page_cnt - mapped);
raw_res_spin_unlock_irqrestore(&arena->spinlock, flags);
- if (mapped)
- arena_free_pages(arena, uaddr32, mapped, sleepable);
+ arena_free_pages(arena, uaddr32, page_cnt, sleepable);
out_free_pages:
/* Error handling: Free back any unmapped pages. */
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 286/742] bpf: Fix reads past an enum in prints of BTF data
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (276 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 285/742] bpf: Flush TLB when a page of arena replaces the scratch page Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 287/742] bpf: Give syscall programs without CAP_PERFMON the base helpers only Greg Kroah-Hartman
` (448 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 6c8d5a113c2341a9fc12a6550c0645d5cda0d56d ]
An enum has 1, 2, 4 or 8 bytes. It's read as int, enum64 as u64,
whatever the size is. The file of a map in bpffs shows what is behind
a key or a value that ends with a short enum.
Read as many bytes as the type has. The check of a member of a struct
with bitfields takes any enum for 4 bytes, so an enum of 8 bytes can
stick out of it. Use the size there too.
Short enums are printed by their names. BTF with an enum that sticks
out of its struct is refused, compilers don't make it.
Fixes: 9eea98497951 ("bpf: fix BTF verification of enums")
Fixes: 6089fb325cf7 ("bpf: Add btf enum64 support")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-24-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/btf.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 4830d9e4ebf5b..bb91c39644320 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -4531,7 +4531,7 @@ static int btf_enum_check_kflag_member(struct btf_verifier_env *env,
return -EINVAL;
}
- nr_bits = int_bitsize;
+ nr_bits = member_type->size * BITS_PER_BYTE;
} else if (nr_bits > int_bitsize) {
btf_verifier_log_member(env, struct_type, member,
"Invalid member bitfield_size");
@@ -4614,12 +4614,30 @@ static void btf_enum_log(struct btf_verifier_env *env,
btf_verifier_log(env, "size=%u vlen=%u", t->size, btf_type_vlen(t));
}
+static s64 btf_enum_read(const struct btf_type *t, const void *data)
+{
+ bool sign = btf_type_kflag(t);
+
+ switch (t->size) {
+ case 1:
+ return sign ? *(s8 *)data : *(u8 *)data;
+ case 2:
+ return sign ? *(s16 *)data : *(u16 *)data;
+ case 4:
+ return sign ? (s64)*(s32 *)data : *(u32 *)data;
+ default:
+ return *(s64 *)data;
+ }
+}
+
static void btf_enum_show(const struct btf *btf, const struct btf_type *t,
u32 type_id, void *data, u8 bits_offset,
struct btf_show *show)
{
const struct btf_enum *enums = btf_type_enum(t);
u32 i, nr_enums = btf_type_vlen(t);
+ /* Old compilers don't set the flag for negative values */
+ u32 mask = t->size < 4 ? BIT(t->size * BITS_PER_BYTE) - 1 : U32_MAX;
void *safe_data;
int v;
@@ -4627,10 +4645,10 @@ static void btf_enum_show(const struct btf *btf, const struct btf_type *t,
if (!safe_data)
return;
- v = *(int *)safe_data;
+ v = btf_enum_read(t, safe_data);
for (i = 0; i < nr_enums; i++) {
- if (v != enums[i].val)
+ if ((v ^ enums[i].val) & mask)
continue;
btf_show_type_value(show, "%s",
@@ -4730,7 +4748,7 @@ static void btf_enum64_show(const struct btf *btf, const struct btf_type *t,
if (!safe_data)
return;
- v = *(u64 *)safe_data;
+ v = btf_enum_read(t, safe_data);
for (i = 0; i < nr_enums; i++) {
if (v != btf_enum64_value(enums + i))
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 287/742] bpf: Give syscall programs without CAP_PERFMON the base helpers only
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (277 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 286/742] bpf: Fix reads past an enum in prints of BTF data Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 288/742] bpf: Limit reads of variables of the kernel Greg Kroah-Hartman
` (447 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 2ff55b023f637d61a56a893b0a3eb534acfb2ffd ]
A syscall program needs CAP_BPF only, and it gets all helpers of tracing
programs. These don't ask for CAP_PERFMON, the load of a tracing program
does.
The helpers for loader programs take current for the loader. It's
another task in a callback. bpf_kallsyms_lookup_name() answers in a
callback of bpf_wq, as a kworker has all capabilities. bpf_sys_close()
in a task work closes a file of any process.
Give the program the base helpers. It loses bpf_perf_event_output() too.
Loader programs are not affected, bpf_sys_bpf() needs CAP_PERFMON
already.
Fixes: 79a7f8bdb159 ("bpf: Introduce bpf_sys_bpf() helper and program type.")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-26-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/syscall.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 152191a6de5b2..ecf4f30b0ad92 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -6698,10 +6698,12 @@ static const struct bpf_func_proto bpf_kallsyms_lookup_name_proto = {
static const struct bpf_func_proto *
syscall_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
{
+ if (!bpf_token_capable(prog->aux->token, CAP_PERFMON))
+ return bpf_base_func_proto(func_id, prog);
+
switch (func_id) {
case BPF_FUNC_sys_bpf:
- return !bpf_token_capable(prog->aux->token, CAP_PERFMON)
- ? NULL : &bpf_sys_bpf_proto;
+ return &bpf_sys_bpf_proto;
case BPF_FUNC_btf_find_by_name_kind:
return &bpf_btf_find_by_name_kind_proto;
case BPF_FUNC_sys_close:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 288/742] bpf: Limit reads of variables of the kernel
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (278 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 287/742] bpf: Give syscall programs without CAP_PERFMON the base helpers only Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 289/742] bpf: Require CAP_PERFMON for dumps of xlated insns Greg Kroah-Hartman
` (446 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 419c69483a62c9b91654e9fa32e3782efea5dc7c ]
ld_imm64 of a variable that is not a struct gives readable memory, so do
bpf_per_cpu_ptr() and bpf_this_cpu_ptr(). Many variables hold addresses,
and CAP_BPF is enough to read them. The size comes from BTF, and that
can be BTF of the program. Loads from such memory are not probed.
Ask for CAP_PERFMON, as for the access to a struct. Addresses of
functions and of per-cpu variables can be loaded as before. Take BTF of
the kernel and of modules only, libbpf passes no other.
Fixes: eaa6bcb71ef6 ("bpf: Introduce bpf_per_cpu_ptr()")
Fixes: 541c3bad8dc5 ("bpf: Support BPF ksym variables in kernel modules")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-29-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/helpers.c | 8 ++++----
kernel/bpf/verifier.c | 11 +++++++++++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index aaa646b5be736..daef14d343aad 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -2137,10 +2137,6 @@ bpf_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return &bpf_spin_unlock_proto;
case BPF_FUNC_jiffies64:
return &bpf_jiffies64_proto;
- case BPF_FUNC_per_cpu_ptr:
- return &bpf_per_cpu_ptr_proto;
- case BPF_FUNC_this_cpu_ptr:
- return &bpf_this_cpu_ptr_proto;
case BPF_FUNC_timer_init:
return &bpf_timer_init_proto;
case BPF_FUNC_timer_set_callback:
@@ -2244,6 +2240,10 @@ bpf_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return &bpf_get_branch_snapshot_proto;
case BPF_FUNC_find_vma:
return &bpf_find_vma_proto;
+ case BPF_FUNC_per_cpu_ptr:
+ return &bpf_per_cpu_ptr_proto;
+ case BPF_FUNC_this_cpu_ptr:
+ return &bpf_this_cpu_ptr_proto;
default:
return NULL;
}
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 7667982d4e38e..d7de38f8e9203 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -18992,6 +18992,12 @@ static int __check_pseudo_btf_id(struct bpf_verifier_env *env,
}
}
+ if (!percpu && !env->allow_ptr_leaks) {
+ verbose(env, "access to '%s' is allowed only to CAP_PERFMON and CAP_SYS_ADMIN\n",
+ sym_name);
+ return -EPERM;
+ }
+
type = t->type;
t = btf_type_skip_modifiers(btf, type, NULL);
if (percpu) {
@@ -19037,6 +19043,11 @@ static int check_pseudo_btf_id(struct bpf_verifier_env *env,
verbose(env, "invalid module BTF object FD specified.\n");
return -EINVAL;
}
+ if (!btf_is_kernel(btf)) {
+ verbose(env, "BTF fd for ksym is not a kernel BTF\n");
+ btf_put(btf);
+ return -EINVAL;
+ }
} else {
if (!btf_vmlinux) {
verbose(env, "kernel is missing BTF, make sure CONFIG_DEBUG_INFO_BTF=y is specified in Kconfig.\n");
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 289/742] bpf: Require CAP_PERFMON for dumps of xlated insns
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (279 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 288/742] bpf: Limit reads of variables of the kernel Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 290/742] bpf: Zero bpf_list_head in copies of map values Greg Kroah-Hartman
` (445 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit b8aa487429d46a72881933c026a6ca2a8e72d6d2 ]
The verifier puts addresses of the kernel to insns: for ksyms, inlined
helpers and hidden arguments. The dump of xlated insns hides the ones of
maps and calls only, the others look like constants by then. Give no
dump, as for a blinded program, to who has no CAP_PERFMON and can't read
kallsyms.
Fixes: 2c78ee898d8f ("bpf: Implement CAP_BPF")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-30-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/syscall.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index ecf4f30b0ad92..2ae40bfcf8a86 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -5237,7 +5237,8 @@ static int bpf_prog_get_info_by_fd(struct file *file,
struct bpf_insn *insns_sanitized;
bool fault;
- if (!prog->blinded || bpf_dump_raw_ok(file->f_cred)) {
+ /* The verifier puts addresses to ld_imm64 and mov insns */
+ if (bpf_dump_raw_ok(file->f_cred) || (!prog->blinded && perfmon_capable())) {
insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred);
if (!insns_sanitized)
return -ENOMEM;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 290/742] bpf: Zero bpf_list_head in copies of map values
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (280 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 289/742] bpf: Require CAP_PERFMON for dumps of xlated insns Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 291/742] bpf: Require CAP_PERFMON to read pinned maps with special fields Greg Kroah-Hartman
` (444 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 8252c3517f95f02a8569480563a773e0462dce52 ]
Lookups from user space copy the value to a buffer and init special
fields there. An empty list_head points to itself. The caller gets the
address of the buffer.
Fill the fields with zeros. It's what a new element of a map has.
bpf_refcount in a value reads as 0.
Fixes: 3e81740a9062 ("bpf: Centralize btf_field-specific initialization logic")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-31-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/bpf.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index a5e49895d6901..8a8c54cc3d862 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -544,7 +544,14 @@ static inline void bpf_obj_init(const struct btf_record *rec, void *obj)
*/
static inline void check_and_init_map_value(struct bpf_map *map, void *dst)
{
- bpf_obj_init(map->record, dst);
+ const struct btf_record *rec = map->record;
+ int i;
+
+ if (IS_ERR_OR_NULL(rec))
+ return;
+ /* Not bpf_obj_init(): an empty list_head has the address of 'dst' */
+ for (i = 0; i < rec->cnt; i++)
+ memset(dst + rec->fields[i].offset, 0, rec->fields[i].size);
}
/* memcpy that is used with 8-byte aligned pointers, power-of-8 size and
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 291/742] bpf: Require CAP_PERFMON to read pinned maps with special fields
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (281 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 290/742] bpf: Zero bpf_list_head in copies of map values Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 292/742] bpf: Require CAP_PERFMON to pass values of insn_array as memory Greg Kroah-Hartman
` (443 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 398557b30b9cd673a762d284c714b5c6b2769fbe ]
A read of a pinned map prints values as they are in memory. bpf_timer,
bpf_wq, bpf_list_head and bpf_rb_root are arrays of u64 for BTF and have
addresses. Refuse open() of the file. BPF_OBJ_GET works as before.
Fixes: b00628b1c7d5 ("bpf: Introduce bpf timers.")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-32-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/inode.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index f3b1e440d0cb1..eea2c41571e1c 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -310,6 +310,11 @@ static int bpffs_map_open(struct inode *inode, struct file *file)
struct seq_file *m;
int err;
+ /* Special fields are printed as they are. Most have addresses. */
+ if (btf_record_has_field(map->record, ~(BPF_SPIN_LOCK | BPF_RES_SPIN_LOCK)) &&
+ !perfmon_capable())
+ return -EPERM;
+
iter = map_iter_alloc(map);
if (!iter)
return -ENOMEM;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 292/742] bpf: Require CAP_PERFMON to pass values of insn_array as memory
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (282 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 291/742] bpf: Require CAP_PERFMON to read pinned maps with special fields Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 293/742] bpf: Require CAP_PERFMON for the dump of all storages of sockets Greg Kroah-Hartman
` (442 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 5fec973f49daeb6f21993d9ea94f1231c975191b ]
The value of an insn_array has addresses in the JIT image. Helpers take
it for plain memory. Refuse to pass it without CAP_PERFMON. gotox works
as before.
Fixes: 493d9e0d6083 ("bpf, x86: add support for indirect jumps")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-33-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/verifier.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index d7de38f8e9203..2b9ce78fc9e29 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7134,6 +7134,10 @@ static int check_helper_mem_access(struct bpf_verifier_env *env, struct bpf_reg_
return check_mem_region_access(env, reg, argno, 0, access_size,
reg->map_ptr->key_size, false);
case PTR_TO_MAP_VALUE:
+ if (reg->map_ptr->map_type == BPF_MAP_TYPE_INSN_ARRAY && !env->allow_ptr_leaks) {
+ verbose(env, "%s leaks addr from insn_array\n", reg_arg_name(env, argno));
+ return -EACCES;
+ }
if (check_map_access_type(env, reg, 0, access_size, access_type))
return -EACCES;
return check_map_access(env, reg, argno, 0, access_size,
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 293/742] bpf: Require CAP_PERFMON for the dump of all storages of sockets
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (283 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 292/742] bpf: Require CAP_PERFMON to pass values of insn_array as memory Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 294/742] bpf, x86: Fix the range of BPF code that has a frame pointer Greg Kroah-Hartman
` (441 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit f9e4fda5eb350f4a310eb266cad83d55c14b3e1c ]
inet_diag dumps values of all sk_storage maps when the request names no
map. It takes CAP_BPF and no fd. These are data of other programs, and
tracing programs keep addresses and memory of the kernel there.
Ask for CAP_PERFMON. "ss --bpf-maps" needs it then. A request with fds of
maps works as before.
Fixes: 2c78ee898d8f ("bpf: Implement CAP_BPF")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-34-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/bpf_sk_storage.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
index ea22ec5ef5b19..04eef37fb31d5 100644
--- a/net/core/bpf_sk_storage.c
+++ b/net/core/bpf_sk_storage.c
@@ -502,6 +502,10 @@ bpf_sk_storage_diag_alloc(const struct nlattr *nla_stgs)
nr_maps++;
}
+ /* It's a dump of all maps, see bpf_sk_storage_diag_put() */
+ if (!nr_maps && !perfmon_capable())
+ return ERR_PTR(-EPERM);
+
diag = kzalloc_flex(*diag, maps, nr_maps);
if (!diag)
return ERR_PTR(-ENOMEM);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 294/742] bpf, x86: Fix the range of BPF code that has a frame pointer
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (284 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 293/742] bpf: Require CAP_PERFMON for the dump of all storages of sockets Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 295/742] bpf, arm64: Restore the shadow call stack pointer after an exception Greg Kroah-Hartman
` (440 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 1c34522e8b78b3d91b75fd7bd2318c8e7e293a76 ]
The ORC unwinder trusts rbp between ksym.fp_start and ksym.fp_end. The
JIT sets fp_end to an offset in the code of the exit insn, and fp_start
counts the CFI preamble, which is in front of the symbol. The main
program of a program with subprogs and trampolines of struct_ops get
neither. The range ends at the epilogue, compilers put blocks behind it.
So stack traces with BPF code in them are not reliable, and livepatch
waits for tasks that sleep there.
Behind the prologue of a program only the return has no frame. Record
its offset in fp_ret and take all the rest. Count from the start of the
symbol, copy the offsets from func[0], and from a struct bpf_tramp_image
that struct_ops passes for the time of the call.
Fixes: ca45c84afb8c ("bpf: Add bpf_has_frame_pointer()")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-37-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/net/bpf_jit_comp.c | 11 +++++------
include/linux/bpf.h | 5 +++--
kernel/bpf/bpf_struct_ops.c | 12 +++++++++---
kernel/bpf/core.c | 2 +-
kernel/bpf/fixups.c | 3 +++
net/bpf/bpf_dummy_struct_ops.c | 2 +-
6 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 1b56cb973d79e..0b95d84259cc5 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -1787,7 +1787,8 @@ static int do_jit(struct bpf_verifier_env *env, struct bpf_prog *bpf_prog, int *
bpf_prog_was_classic(bpf_prog), tail_call_reachable,
bpf_is_subprog(bpf_prog), bpf_prog->aux->exception_cb);
- bpf_prog->aux->ksym.fp_start = prog - temp;
+ bpf_prog->aux->ksym.fp_start = prog - temp - cfi_get_offset();
+ bpf_prog->aux->ksym.fp_end = U32_MAX;
/* Exception callback will clobber callee regs for its own use, and
* restore the original callee regs from main prog's stack frame.
@@ -2970,7 +2971,7 @@ st: insn_off = insn->off;
pop_r12(&prog);
}
EMIT1(0xC9); /* leave */
- bpf_prog->aux->ksym.fp_end = prog - temp;
+ bpf_prog->aux->ksym.fp_ret = proglen + (prog - temp) - cfi_get_offset();
emit_return(&prog, image + addrs[i - 1] + (prog - temp));
break;
@@ -3628,8 +3629,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im
}
EMIT1(0x55); /* push rbp */
EMIT3(0x48, 0x89, 0xE5); /* mov rbp, rsp */
- if (im)
- im->ksym.fp_start = prog - (u8 *)rw_image;
+ im->ksym.fp_start = prog - (u8 *)rw_image;
if (!is_imm8(stack_size)) {
/* sub rsp, stack_size */
@@ -3775,8 +3775,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im
emit_ldx(&prog, BPF_DW, BPF_REG_6, BPF_REG_FP, -rbx_off);
EMIT1(0xC9); /* leave */
- if (im)
- im->ksym.fp_end = prog - (u8 *)rw_image;
+ im->ksym.fp_end = prog - (u8 *)rw_image;
if (flags & BPF_TRAMP_F_SKIP_FRAME) {
/* skip our return address and return to parent */
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 8a8c54cc3d862..4fcaf3d7f4720 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1367,6 +1367,7 @@ struct bpf_ksym {
bool prog;
u32 fp_start;
u32 fp_end;
+ u32 fp_ret; /* a return in between, it has no frame */
};
enum bpf_tramp_prog_type {
@@ -1411,7 +1412,7 @@ static inline void bpf_tramp_image_add_skip(struct bpf_tramp_image *im, struct b
{
struct bpf_tramp_skip *skip;
- /* struct_ops trampolines and arch_bpf_trampoline_size() have no image */
+ /* struct_ops trampolines and arch_bpf_trampoline_size() have none */
if (!im || !im->skips)
return;
skip = &im->skips[im->nr_skips++];
@@ -2295,7 +2296,7 @@ int bpf_struct_ops_prepare_trampoline(struct bpf_tramp_nodes *tnodes,
const struct btf_func_model *model,
void *stub_func,
void **image, u32 *image_off,
- bool allow_alloc);
+ bool allow_alloc, struct bpf_ksym *ksym);
void bpf_struct_ops_image_free(void *image);
static inline bool bpf_try_module_get(const void *data, struct module *owner)
{
diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c
index 3b747eb52aa3a..f374a5ccbfbd8 100644
--- a/kernel/bpf/bpf_struct_ops.c
+++ b/kernel/bpf/bpf_struct_ops.c
@@ -639,9 +639,10 @@ int bpf_struct_ops_prepare_trampoline(struct bpf_tramp_nodes *tnodes,
const struct btf_func_model *model,
void *stub_func,
void **_image, u32 *_image_off,
- bool allow_alloc)
+ bool allow_alloc, struct bpf_ksym *ksym)
{
u32 image_off = *_image_off, flags = BPF_TRAMP_F_INDIRECT;
+ struct bpf_tramp_image im = {};
void *image = *_image;
int size;
@@ -666,7 +667,7 @@ int bpf_struct_ops_prepare_trampoline(struct bpf_tramp_nodes *tnodes,
image_off = 0;
}
- size = arch_prepare_bpf_trampoline(NULL, image + image_off,
+ size = arch_prepare_bpf_trampoline(&im, image + image_off,
image + image_off + size,
model, flags, tnodes, stub_func);
if (size <= 0) {
@@ -675,6 +676,10 @@ int bpf_struct_ops_prepare_trampoline(struct bpf_tramp_nodes *tnodes,
return size ? : -EFAULT;
}
+ if (ksym) {
+ ksym->fp_start = im.ksym.fp_start;
+ ksym->fp_end = im.ksym.fp_end;
+ }
*_image = image;
*_image_off = image_off + size;
return 0;
@@ -878,7 +883,8 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key,
&st_ops->func_models[i],
*(void **)(st_ops->cfi_stubs + moff),
&image, &image_off,
- st_map->image_pages_cnt < MAX_TRAMP_IMAGE_PAGES);
+ st_map->image_pages_cnt < MAX_TRAMP_IMAGE_PAGES,
+ ksym);
if (err)
goto reset_unlock;
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 44eb17428fbc3..90eba581fcef4 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -781,7 +781,7 @@ bool bpf_has_frame_pointer(unsigned long ip)
offset = ip - ksym->start;
- return offset >= ksym->fp_start && offset < ksym->fp_end;
+ return offset >= ksym->fp_start && offset < ksym->fp_end && offset != ksym->fp_ret;
}
const struct exception_table_entry *search_bpf_extables(unsigned long addr)
diff --git a/kernel/bpf/fixups.c b/kernel/bpf/fixups.c
index 927078bda67be..2f53df08e7056 100644
--- a/kernel/bpf/fixups.c
+++ b/kernel/bpf/fixups.c
@@ -1373,6 +1373,9 @@ static int jit_subprogs(struct bpf_verifier_env *env)
prog->jited_len = func[0]->jited_len;
prog->aux->extable = func[0]->aux->extable;
prog->aux->num_exentries = func[0]->aux->num_exentries;
+ prog->aux->ksym.fp_start = func[0]->aux->ksym.fp_start;
+ prog->aux->ksym.fp_end = func[0]->aux->ksym.fp_end;
+ prog->aux->ksym.fp_ret = func[0]->aux->ksym.fp_ret;
prog->aux->func = func;
prog->aux->func_cnt = env->subprog_cnt - env->hidden_subprog_cnt;
prog->aux->real_func_cnt = env->subprog_cnt;
diff --git a/net/bpf/bpf_dummy_struct_ops.c b/net/bpf/bpf_dummy_struct_ops.c
index 191a6b3ee2541..c724a6bc7b807 100644
--- a/net/bpf/bpf_dummy_struct_ops.c
+++ b/net/bpf/bpf_dummy_struct_ops.c
@@ -179,7 +179,7 @@ int bpf_struct_ops_test_run(struct bpf_prog *prog, const union bpf_attr *kattr,
&st_ops->func_models[op_idx],
&dummy_ops_test_ret_function,
&image, &image_off,
- true);
+ true, NULL);
if (err < 0)
goto out;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 295/742] bpf, arm64: Restore the shadow call stack pointer after an exception
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (285 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 294/742] bpf, x86: Fix the range of BPF code that has a frame pointer Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 296/742] bpf: Clear the data that bpf_msg_push_data() adds Greg Kroah-Hartman
` (439 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 918bea2c6b682405b20cde0f44e76b0161dde912 ]
bpf_throw() does not return, its return address stays on the shadow
call stack. The caller of the program takes it for its own.
test_progs -t exceptions crashes the kernel with
CONFIG_SHADOW_CALL_STACK:
Internal error: Oops - FPAC: 0000000072000000 [#1] SMP
pc : bpf_test_run+0x410/0x968
JITed code puts nothing on the shadow call stack, and bpf_throw() skips
only frames of JITed code. So that address is the only entry that is
left behind. Pop it in the prologue of the exception callback.
Fixes: 22fc0e80aeb5 ("bpf, arm64: support exceptions")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-38-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/arm64/net/bpf_jit_comp.c | 7 +++++++
kernel/bpf/helpers.c | 1 +
2 files changed, 8 insertions(+)
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index d393fa6bfbf4d..b96bf0126b8f2 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -14,6 +14,7 @@
#include <linux/filter.h>
#include <linux/memory.h>
#include <linux/printk.h>
+#include <linux/scs.h>
#include <linux/slab.h>
#include <asm/asm-extable.h>
@@ -599,6 +600,12 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)
* 12 registers are on the stack
*/
emit(A64_SUB_I(1, A64_SP, A64_FP, 96), ctx);
+ /*
+ * Pop the return address of bpf_throw() from the shadow call
+ * stack. The frames of the JIT put nothing there.
+ */
+ if (scs_is_enabled())
+ emit(A64_SUB_I(1, A64_R(18), A64_R(18), 8), ctx);
/* The callback may use its own BPF stack, set up fp for it. */
ctx->fp_used = true;
}
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index daef14d343aad..42d6b22edfcdf 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -3416,6 +3416,7 @@ __bpf_kfunc notrace __no_sanitize_address void bpf_throw(u64 cookie)
WARN_ON_ONCE(!ctx.aux->exception_boundary);
WARN_ON_ONCE(!ctx.bp);
WARN_ON_ONCE(!ctx.cnt);
+ /* arm64 drops one entry of the shadow call stack, don't move the call to a callee */
ctx.aux->bpf_exception_cb(cookie, ctx.sp + ctx.aux->stack_arg_sp_adjust, ctx.bp, 0, 0);
WARN(1, "A call to BPF exception callback should never return\n");
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 296/742] bpf: Clear the data that bpf_msg_push_data() adds
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (286 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 295/742] bpf, arm64: Restore the shadow call stack pointer after an exception Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 297/742] bpf: Fail loads from a network header that was not set Greg Kroah-Hartman
` (438 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 401fce9f48b1d684b92dbc08389d7c20bd036280 ]
The helper puts a new page into the message as the allocator gave it.
Bytes that the program does not write can be read by it, and are sent
to the peer. Allocate zeroed memory.
Fixes: 6fff607e2f14 ("bpf: sk_msg program helper bpf_msg_push_data")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-39-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/filter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 53ca1457fd331..96a3a208b575b 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2912,7 +2912,7 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start,
if (unlikely(copy + len < copy))
return -EINVAL;
- page = alloc_pages(__GFP_NOWARN | GFP_ATOMIC | __GFP_COMP,
+ page = alloc_pages(__GFP_NOWARN | GFP_ATOMIC | __GFP_COMP | __GFP_ZERO,
get_order(copy + len));
if (unlikely(!page))
return -ENOMEM;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 297/742] bpf: Fail loads from a network header that was not set
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (287 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 296/742] bpf: Clear the data that bpf_msg_push_data() adds Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 298/742] bpf: Fix slices behind the end of an XDP packet Greg Kroah-Hartman
` (437 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 766907cdaeefb57faddc5d09a49bdd4ce20a6272 ]
skb->network_header is 0 until something sets it. Loads at SKF_NET_OFF
and bpf_skb_load_bytes_relative() start at skb->head then, and read
headroom that nobody has written. qrtr and AF_XDP in copy mode make such
skbs.
Fail the load, like for the MAC header. A network header at skb->head
counts as set when skb->data or the MAC header is there too. CAN and
6LoWPAN make such skbs.
Fixes: 2e07fa9cd3ba ("[SK_BUFF]: Use offsets for skb->{mac,network,transport}_header on 64bit architectures")
Fixes: 0f5d82f187e1 ("net/filter: Permit reading NET in load_bytes_relative when MAC not set")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-40-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/filter.h | 9 +++++++++
kernel/bpf/core.c | 2 ++
net/core/filter.c | 5 ++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 94bbdb948ab02..f05e12b38038d 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1021,6 +1021,15 @@ static inline void bpf_restore_data_end(
cb->data_end = saved_data_end;
}
+/*
+ * If nothing has set the header, it points to headroom that was not written.
+ * The packet starts at skb->head when skb->data or the MAC header is there.
+ */
+static inline bool bpf_skb_has_network_header(const struct sk_buff *skb)
+{
+ return skb->network_header || !skb->mac_header || !skb_headroom(skb);
+}
+
static inline u8 *bpf_skb_cb(const struct sk_buff *skb)
{
/* eBPF programs may read/write skb->cb[] area to transfer meta
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 90eba581fcef4..307c0a1d854e2 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -81,6 +81,8 @@ void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb, int k, uns
u8 *ptr = NULL;
if (k >= SKF_NET_OFF) {
+ if (unlikely(!bpf_skb_has_network_header(skb)))
+ return NULL;
ptr = skb_network_header(skb) + k - SKF_NET_OFF;
} else if (k >= SKF_LL_OFF) {
if (unlikely(!skb_mac_header_was_set(skb)))
diff --git a/net/core/filter.c b/net/core/filter.c
index 96a3a208b575b..9f0cfb0b52357 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -232,7 +232,8 @@ static int bpf_skb_load_helper_convert_offset(const struct sk_buff *skb, int off
return offset;
if (offset >= SKF_NET_OFF)
- return offset - SKF_NET_OFF + skb_network_offset(skb);
+ return bpf_skb_has_network_header(skb) ?
+ offset - SKF_NET_OFF + skb_network_offset(skb) : INT_MIN;
if (offset >= SKF_LL_OFF && skb_mac_header_was_set(skb))
return offset - SKF_LL_OFF + skb_mac_offset(skb);
@@ -1862,6 +1863,8 @@ BPF_CALL_5(bpf_skb_load_bytes_relative, const struct sk_buff *, skb,
start = skb_mac_header(skb);
break;
case BPF_HDR_START_NET:
+ if (unlikely(!bpf_skb_has_network_header(skb)))
+ goto err_clear;
start = skb_network_header(skb);
break;
default:
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 298/742] bpf: Fix slices behind the end of an XDP packet
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (288 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 297/742] bpf: Fail loads from a network header that was not set Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 299/742] bpf: Clear family and port of a short address for cgroup sockaddr hooks Greg Kroah-Hartman
` (436 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 2fc7a1733992e28d4c89f57e2c237b85b236d83c ]
A dynptr keeps the size that the packet had at bpf_dynptr_from_xdp().
When the packet has shrunk since, bpf_dynptr_slice() takes the error of
bpf_xdp_pointer() for "not linear" and copies from the frags. A linear
packet has none, its skb_shared_info is what the buffer held before.
Return NULL. Don't look at the frags of a linear packet for a length of
0 at its end either.
Fixes: 66e3a13e7c2c ("bpf: Add bpf_dynptr_slice and bpf_dynptr_slice_rdwr")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-41-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/helpers.c | 4 +++-
net/core/filter.c | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 42d6b22edfcdf..991d03fede8c2 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -13,6 +13,7 @@
#include <linux/sched.h>
#include <linux/uidgid.h>
#include <linux/filter.h>
+#include <net/xdp.h>
#include <linux/ctype.h>
#include <linux/jiffies.h>
#include <linux/pid_namespace.h>
@@ -3092,7 +3093,8 @@ __bpf_kfunc void *bpf_dynptr_slice(const struct bpf_dynptr *p, u64 offset,
if (!IS_ERR_OR_NULL(xdp_ptr))
return xdp_ptr;
- if (!buffer__nullable)
+ /* the packet may be shorter than it was for bpf_dynptr_from_xdp() */
+ if (!buffer__nullable || ptr->offset + offset + len > xdp_get_buff_len(ptr->data))
return NULL;
bpf_xdp_copy_buf(ptr->data, ptr->offset + offset, buffer__nullable, len, false);
return buffer__nullable;
diff --git a/net/core/filter.c b/net/core/filter.c
index 9f0cfb0b52357..22246ec8f0c68 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4332,7 +4332,7 @@ void *bpf_xdp_pointer(struct xdp_buff *xdp, u32 offset, u32 len)
if (unlikely(offset + len > xdp_get_buff_len(xdp)))
return ERR_PTR(-EINVAL);
- if (likely(offset < size)) /* linear area */
+ if (likely(offset < size || !xdp_buff_has_frags(xdp))) /* linear area */
goto out;
sinfo = xdp_get_shared_info_from_buff(xdp);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 299/742] bpf: Clear family and port of a short address for cgroup sockaddr hooks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (289 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 298/742] bpf: Fix slices behind the end of an XDP packet Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 300/742] bpf: Take a neighbour of the L3 master in bpf_redirect_neigh() Greg Kroah-Hartman
` (435 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 2abc088aae543fa97350df8b2dd5eedf622e380d ]
recvmsg() from a unix socket that has no name leaves the buffer of the
address as it is, and that is on the stack of the kernel. The program
reads user_family and user_port whatever the length is.
bpf_sock_addr_set_sun_path() sends the family to user space.
Clear the bytes from the length up to 4. Write AF_UNIX next to the path
in the kfunc.
Fixes: 859051dd165e ("bpf: Implement cgroup sockaddr hooks for unix sockets")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-42-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/cgroup.c | 4 ++++
net/core/filter.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index 7455d0b7d559c..c020cd11c279c 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -1787,6 +1787,10 @@ int __cgroup_bpf_run_filter_sock_addr(struct sock *sk,
ctx.uaddrlen = 0;
} else {
ctx.uaddrlen = *uaddrlen;
+ /* Programs read the family and the port also of a short address. */
+ if (ctx.uaddrlen < offsetofend(struct sockaddr_in, sin_port))
+ memset((void *)uaddr + ctx.uaddrlen, 0,
+ offsetofend(struct sockaddr_in, sin_port) - ctx.uaddrlen);
}
cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data);
diff --git a/net/core/filter.c b/net/core/filter.c
index 22246ec8f0c68..e5284b8345838 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -12617,6 +12617,7 @@ __bpf_kfunc int bpf_sock_addr_set_sun_path(struct bpf_sock_addr_kern *sa_kern,
return -EINVAL;
un = (struct sockaddr_un *)sa_kern->uaddr;
+ un->sun_family = AF_UNIX;
memcpy(un->sun_path, sun_path, sun_path__sz);
sa_kern->uaddrlen = offsetof(struct sockaddr_un, sun_path) + sun_path__sz;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 300/742] bpf: Take a neighbour of the L3 master in bpf_redirect_neigh()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (290 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 299/742] bpf: Clear family and port of a short address for cgroup sockaddr hooks Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 301/742] bpf: Keep the MAC header in bpf_skb_change_tail() Greg Kroah-Hartman
` (434 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit c1b5decc73149f69db0b8d28ebcea204249e3b0b ]
bpf_redirect_neigh() takes the neighbour from the route, the skb gets
the device that the program has named. They are not always the same for
IPv4, and the queue of a neighbour is purged with its own device only.
When a L3 master was named take a neighbour of that device, as IPv6
does. Its driver drops the header and routes the packet, one entry does
for all.
Fixes: ba452c9e996d ("bpf: Fix bpf_redirect_neigh helper api to support supplying nexthop")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-43-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/filter.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index e5284b8345838..735031c4f7d53 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2367,7 +2367,11 @@ static int bpf_out_neigh_v4(struct net *net, struct sk_buff *skb,
}
rcu_read_lock();
- if (!nh) {
+ if (!nh && netif_is_l3_master(dev)) {
+ /* The route leads to another device, this one looks it up again */
+ skb_dst_drop(skb);
+ neigh = ip_neigh_gw4(dev, htonl(INADDR_ANY));
+ } else if (!nh) {
struct rtable *rt = skb_rtable(skb);
neigh = ip_neigh_for_gw(rt, skb, &is_v6gw);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 301/742] bpf: Keep the MAC header in bpf_skb_change_tail()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (291 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 300/742] bpf: Take a neighbour of the L3 master in bpf_redirect_neigh() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 302/742] bpf, sockmap: Fix psock update-side data races on sk->sk_prot and progs Greg Kroah-Hartman
` (433 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 28ffeb9cb9722f39854f11e5f0511a4a8c12d9fb ]
The least length of the skb is the offset of the transport header when
it's set, also when that is below the offset of the network header.
Callers of tc programs count on a skb that is not shorter than mac_len.
Take the bigger one of the two offsets.
Fixes: 5293efe62df8 ("bpf: add bpf_skb_change_tail helper")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-44-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/filter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 735031c4f7d53..2b134830a6d29 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4055,7 +4055,7 @@ static u32 __bpf_skb_min_len(const struct sk_buff *skb)
if (skb_transport_header_was_set(skb)) {
offset = skb_transport_offset(skb);
if (offset > 0)
- min_len = offset;
+ min_len = max_t(u32, min_len, offset);
}
return min_len;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 302/742] bpf, sockmap: Fix psock update-side data races on sk->sk_prot and progs
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (292 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 301/742] bpf: Keep the MAC header in bpf_skb_change_tail() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 303/742] bpf, sockmap: Keep the parser and sk_data_ready in sync Greg Kroah-Hartman
` (432 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Jakub Sitnicki,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Sitnicki <jakub@cloudflare.com>
[ Upstream commit bcd07fd1673beb873e2bee2731e4ef4d716e70c7 ]
The update side of the sockmap psock lifecycle has several unsynchronized
accesses to sk->sk_prot and psock prog state that KCSAN flags when the
new update-vs-delete race selftest runs. The fix comes from Alexei [1]:
* sock_map_link() installed psock programs and called sock_map_init_proto()
before taking sk->sk_callback_lock, racing a concurrent teardown's
tcp_bpf_update_proto() write of sk->sk_prot. Take the write_lock early,
before psock_set_prog() and sock_map_init_proto(), and drop the
psock->saved_data_ready gating from prog detection (it is re-checked
under the lock before stopping progs).
* sock_map_del_link() read psock->saved_data_ready outside the lock. Move
the saved_data_ready check under write_lock_bh(&sk->sk_callback_lock)
so prog teardown is serialized against the proto restore.
* sock_map_psock_get_checked() and sock_map_sk_is_suitable() did plain
sk->sk_prot reads. Convert to READ_ONCE() to mark the intentional racy
read against the WRITE_ONCE() swap in sock_replace_proto().
With these changes the sock_map_link/psock_set_prog side of the reported
KCSAN splats is silenced; the remaining teardown-vs-core-TCP pairings
are the separate read-side annotation problem.
[1] https://lore.kernel.org/bpf/DMBHB0TQOV1L.38MECMYFGUS5B@gmail.com
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261030-bpf-next-v1-2-035eabf8eae7@cloudflare.com
Stable-dep-of: b3a433f20f0a ("bpf, sockmap: Keep the parser and sk_data_ready in sync")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/sock_map.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index 38df842843289..20fb605bc1adf 100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -152,11 +152,11 @@ static void sock_map_del_link(struct sock *sk,
struct bpf_map *map = link->map;
struct sk_psock_progs *progs = sock_map_progs(map);
- if (psock->saved_data_ready && progs->stream_parser)
+ if (progs->stream_parser)
strp_stop = true;
- if (psock->saved_data_ready && progs->stream_verdict)
+ if (progs->stream_verdict)
verdict_stop = true;
- if (psock->saved_data_ready && progs->skb_verdict)
+ if (progs->skb_verdict)
verdict_stop = true;
list_del(&link->list);
sk_psock_free_link(link);
@@ -164,8 +164,11 @@ static void sock_map_del_link(struct sock *sk,
}
}
spin_unlock_bh(&psock->link_lock);
- if (strp_stop || verdict_stop) {
- write_lock_bh(&sk->sk_callback_lock);
+ if (!strp_stop && !verdict_stop)
+ return;
+
+ write_lock_bh(&sk->sk_callback_lock);
+ if (psock->saved_data_ready) {
if (strp_stop)
sk_psock_stop_strp(sk, psock);
if (verdict_stop)
@@ -173,8 +176,8 @@ static void sock_map_del_link(struct sock *sk,
if (psock->psock_update_sk_prot)
psock->psock_update_sk_prot(sk, psock, false);
- write_unlock_bh(&sk->sk_callback_lock);
}
+ write_unlock_bh(&sk->sk_callback_lock);
}
static void sock_map_unref(struct sock *sk, void *link_raw)
@@ -202,7 +205,7 @@ static struct sk_psock *sock_map_psock_get_checked(struct sock *sk)
rcu_read_lock();
psock = sk_psock(sk);
if (psock) {
- if (sk->sk_prot->close != sock_map_close) {
+ if (READ_ONCE(sk->sk_prot)->close != sock_map_close) {
psock = ERR_PTR(-EBUSY);
goto out;
}
@@ -284,6 +287,7 @@ static int sock_map_link(struct bpf_map *map, struct sock *sk)
}
}
+ write_lock_bh(&sk->sk_callback_lock);
if (msg_parser)
psock_set_prog(&psock->progs.msg_parser, msg_parser);
if (stream_parser)
@@ -298,11 +302,11 @@ static int sock_map_link(struct bpf_map *map, struct sock *sk)
*/
ret = sock_map_init_proto(sk, psock);
if (ret < 0) {
+ write_unlock_bh(&sk->sk_callback_lock);
sk_psock_put(sk, psock);
goto out;
}
- write_lock_bh(&sk->sk_callback_lock);
if (stream_parser && stream_verdict && !psock->saved_data_ready) {
if (sk_is_tcp(sk))
ret = sk_psock_init_strp(sk, psock);
@@ -536,7 +540,7 @@ static bool sock_map_redirect_allowed(const struct sock *sk)
static bool sock_map_sk_is_suitable(const struct sock *sk)
{
- return !!sk->sk_prot->psock_update_sk_prot;
+ return !!READ_ONCE(sk->sk_prot)->psock_update_sk_prot;
}
static bool sock_map_sk_state_allowed(const struct sock *sk)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 303/742] bpf, sockmap: Keep the parser and sk_data_ready in sync
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (293 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 302/742] bpf, sockmap: Fix psock update-side data races on sk->sk_prot and progs Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 304/742] bpf, sockmap: Hold the psock of the work in sk_psock_backlog() Greg Kroah-Hartman
` (431 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit b3a433f20f0a247cb2c4664b6e1400253287da63 ]
sk_psock_strp_data_ready() takes the psock that the socket has at the
call. An update from a program does not wait for the owner of the
socket, so that is not always the psock that has set the callback, and
it may have no parser. strp_data_ready() dereferences a NULL strp->sk
then. Look at SK_PSOCK_RX_STRP_ENABLED, it is set under
sk_callback_lock. The event is dropped, as it is when the socket has no
psock.
A socket can be in a map with a verdict program and not have it, the
program was attached after the update. Another map can start the parser
then. The delete from the first map restores sk_data_ready and nobody
stops the parser:
WARNING: net/strparser/strparser.c:451 at strp_done+0xef/0x130
Stop the parser when its callback goes away. The psock can outlive the
stop, and a later update must not run strp_init() on works that are
still pending. Start the stopped parser again instead.
Fixes: 0126240f448d ("bpf: sockmap: Allow update from BPF")
Fixes: ef5659280eb1 ("bpf, sockmap: Allow skipping sk_skb parser program")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-45-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/skmsg.c | 12 +++++++++---
net/core/sock_map.c | 3 ++-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index df385a5a961e8..9d6cbde8ed1f1 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -1138,7 +1138,9 @@ static void sk_psock_strp_data_ready(struct sock *sk)
psock = sk_psock(sk);
if (likely(psock)) {
read_lock_bh(&sk->sk_callback_lock);
- strp_data_ready(&psock->strp);
+ /* This psock may be not the one that has set the callback */
+ if (likely(sk_psock_test_state(psock, SK_PSOCK_RX_STRP_ENABLED)))
+ strp_data_ready(&psock->strp);
read_unlock_bh(&sk->sk_callback_lock);
}
rcu_read_unlock();
@@ -1146,7 +1148,7 @@ static void sk_psock_strp_data_ready(struct sock *sk)
int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock)
{
- int ret;
+ int ret = 0;
static const struct strp_callbacks cb = {
.rcv_msg = sk_psock_strp_read,
@@ -1154,7 +1156,11 @@ int sk_psock_init_strp(struct sock *sk, struct sk_psock *psock)
.parse_msg = sk_psock_strp_parse,
};
- ret = strp_init(&psock->strp, sk, &cb);
+ /* A stopped parser keeps its works and its skb until strp_done() */
+ if (sk_psock_test_state(psock, SK_PSOCK_RX_STRP_ENABLED))
+ psock->strp.stopped = 0;
+ else
+ ret = strp_init(&psock->strp, sk, &cb);
if (!ret)
sk_psock_set_state(psock, SK_PSOCK_RX_STRP_ENABLED);
diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index 20fb605bc1adf..0f58a0786f246 100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -169,7 +169,8 @@ static void sock_map_del_link(struct sock *sk,
write_lock_bh(&sk->sk_callback_lock);
if (psock->saved_data_ready) {
- if (strp_stop)
+ /* The parser can be from another map, it loses sk_data_ready too */
+ if (strp_stop || psock->progs.stream_parser)
sk_psock_stop_strp(sk, psock);
if (verdict_stop)
sk_psock_stop_verdict(sk, psock);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 304/742] bpf, sockmap: Hold the psock of the work in sk_psock_backlog()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (294 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 303/742] bpf, sockmap: Keep the parser and sk_data_ready in sync Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 305/742] libbpf: Fix struct_ops members 59-61 and optional struct_ops maps Greg Kroah-Hartman
` (430 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 9abfa0ad4f7606619586187152a0479efd306b13 ]
The socket can leave its map and come back after the test of
SK_PSOCK_TX_ENABLED. sk_psock_get() takes a reference to the new psock
then, and the work puts the old one that has none left. The new one and
its socket are never freed.
Take the reference that is put.
Fixes: 8259eb0e06d8 ("bpf, sockmap: Avoid using sk_socket after free when sending")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-46-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/skmsg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index 9d6cbde8ed1f1..c4bc16115c9e1 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -690,7 +690,7 @@ static void sk_psock_backlog(struct work_struct *work)
* before sk_socket freed. If refcnt increment fails, it indicates
* sock_map_close() completed with sk_socket potentially already freed.
*/
- if (!sk_psock_get(psock->sk))
+ if (!refcount_inc_not_zero(&psock->refcnt))
return;
mutex_lock(&psock->work_mutex);
while ((skb = skb_peek(&psock->ingress_skb))) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 305/742] libbpf: Fix struct_ops members 59-61 and optional struct_ops maps
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (295 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 304/742] bpf, sockmap: Hold the psock of the work in sk_psock_backlog() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 306/742] bpf: Check the type of R0 at the exit of a struct_ops program Greg Kroah-Hartman
` (429 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 434ea9c5125a8c3ad16e241687e1983309f99d1c ]
expected_attach_type of a struct_ops program is the index of the member.
For members 59, 60 and 61 it is equal to an attach type of tracing
multi, and attach_btf_obj_fd is overwritten. The load fails when the
struct is in a module. Look at the type of the program too.
Only the first map of SEC("?.struct_ops") or SEC("?.struct_ops.link") is
not created by default. The '?' is skipped in the loop over the
variables, so the next ones do not see it. They are created, and their
programs are loaded. Look at it once.
Fixes: f2aa370dfe57 ("libbpf: Add support to create tracing multi link")
Fixes: 5ad0ecbe056a ("libbpf: Struct_ops in SEC("?.struct_ops") / SEC("?.struct_ops.link")")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-47-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/lib/bpf/libbpf.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 4c3b79239a270..81d4e0e4c265a 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1412,6 +1412,7 @@ static int init_struct_ops_maps(struct bpf_object *obj, const char *sec_name,
__s32 type_id, datasec_id;
const struct btf *btf;
struct bpf_map *map;
+ bool optional;
__u32 i;
if (shndx == -1)
@@ -1426,6 +1427,14 @@ static int init_struct_ops_maps(struct bpf_object *obj, const char *sec_name,
return -EINVAL;
}
+ /*
+ * Follow same convention as for programs autoload:
+ * SEC("?.struct_ops") means map is not created by default.
+ */
+ optional = sec_name[0] == '?';
+ /* from now on forget there was ? in section name */
+ sec_name += optional;
+
datasec = btf__type_by_id(btf, datasec_id);
vsi = btf_var_secinfos(datasec);
for (i = 0; i < btf_vlen(datasec); i++, vsi++) {
@@ -1461,14 +1470,8 @@ static int init_struct_ops_maps(struct bpf_object *obj, const char *sec_name,
return -ENOMEM;
map->btf_value_type_id = type_id;
- /* Follow same convention as for programs autoload:
- * SEC("?.struct_ops") means map is not created by default.
- */
- if (sec_name[0] == '?') {
+ if (optional)
map->autocreate = false;
- /* from now on forget there was ? in section name */
- sec_name++;
- }
map->def.type = BPF_MAP_TYPE_STRUCT_OPS;
map->def.key_size = sizeof(int);
@@ -7967,7 +7970,7 @@ static int libbpf_prepare_prog_load(struct bpf_program *prog,
opts->attach_btf_id = btf_type_id;
}
- if (is_tracing_multi(prog->expected_attach_type)) {
+ if (prog->type == BPF_PROG_TYPE_TRACING && is_tracing_multi(prog->expected_attach_type)) {
int err, btf_obj_fd = 0;
err = tracing_multi_mod_fd(prog, &btf_obj_fd);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 306/742] bpf: Check the type of R0 at the exit of a struct_ops program
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (296 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 305/742] libbpf: Fix struct_ops members 59-61 and optional struct_ops maps Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 307/742] tcp: fix negative sk_forward_alloc after MSG_ZEROCOPY append Greg Kroah-Hartman
` (428 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 65e362827a6edf078ef8f5d34fbaea2ccb6b7879 ]
check_return_code() takes reg->btf for valid when it is not NULL. The
field is in a union, so for other types of registers it holds something
else, and the verifier follows that as a struct btf.
Look at it only when the register is PTR_TO_BTF_ID.
Fixes: 8d9f547f74c7 ("bpf: Allow struct_ops prog to return referenced kptr")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261125032938.670542-48-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/verifier.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 2b9ce78fc9e29..073b7594d3980 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -17853,7 +17853,8 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const char
* matches the operator's return type and is in its unmodified
* form. A scalar zero (i.e., a null pointer) is also allowed.
*/
- reg_type = reg->btf ? btf_type_by_id(reg->btf, reg->btf_id) : NULL;
+ reg_type = base_type(reg->type) == PTR_TO_BTF_ID ?
+ btf_type_by_id(reg->btf, reg->btf_id) : NULL;
ret_type = btf_type_resolve_ptr(prog->aux->attach_btf,
prog->aux->attach_func_proto->type,
NULL);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 307/742] tcp: fix negative sk_forward_alloc after MSG_ZEROCOPY append
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (297 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 306/742] bpf: Check the type of R0 at the exit of a struct_ops program Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 308/742] net: dpaa2-eth: fix objtool warning and logic bug Greg Kroah-Hartman
` (427 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jiayuan Chen, Eric Dumazet,
Willem de Bruijn, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <jiayuan.chen@linux.dev>
[ Upstream commit e50436deae925d1b95b01936e2499428c4782a6a ]
Our local syzbot reported the following warning:
WARNING: ./include/linux/ucopysize.h:57 at tcp_sendmsg_locked+0x1e13/0x1f20
Modules linked in:
CPU: 3 UID: 0 PID: 377 Comm: syz.2.2248 Not tainted 7.4.0-rc2+ #398 PREEMPT
RIP: 0010:tcp_sendmsg_locked+0x1e13/0x1f20
Call Trace:
<TASK>
tcp_sendmsg+0x2c/0x50
inet_sendmsg+0x62/0xb0
__sys_sendto+0x2fe/0x350
__x64_sys_sendto+0x7f/0xb0
x64_sys_call+0x1375/0x27e0
do_syscall_64+0xe4/0x470
entry_SYSCALL_64_after_hwframe+0x76/0x7e
</TASK>
The problem is here:
if (!skb_zcopy_pure(skb)) {
copy = tcp_wmem_schedule(sk, copy);
if (!copy)
goto wait_for_space;
}
When MSG_ZEROCOPY data is appended to a skb that already holds copied
data, only the user length is scheduled, but the pinned pages are then
charged by their truesize:
skb_zerocopy_iter_stream
__zerocopy_sg_from_iter
zerocopy_fill_skb_from_iter //truesize += PAGE_ALIGN(copied + start)
sk_mem_charge(sk, truesize) //sk_forward_alloc goes negative
For example, sending 8 iovecs of 1 byte each schedules 8 bytes and
charges 32768 with 4K pages.
On a later sendmsg() without MSG_ZEROCOPY, if sk_wmem_schedule() fails
(e.g. tcp_mem hard limit is reached), tcp_wmem_schedule() returns
min(copy, sk->sk_forward_alloc), which is negative. The negative copy
is passed to skb_copy_to_page_nocache() and triggers the warning, and
sendmsg() fails with -EFAULT.
A few options were considered:
1) Schedule the truesize up front. It is not known before the pages
are pinned, it depends on the iovec layout.
2) Do not append zerocopy data to a non pure skb. This splits a small
header and its zerocopy payload into two skbs.
3) Schedule the missing part right after the pages are charged. They
are already in the skb at this point, so this can not fail.
Go with 3).
Fixes: 849b425cd091 ("tcp: fix possible freeze in tx path under memory pressure")
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261123122432.297135-1-jiayuan.chen@linux.dev
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ipv4/tcp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 338c30c65dad9..de95bc5e9c9b6 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1349,6 +1349,8 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
err = skb_zerocopy_iter_stream(sk, skb, msg, copy, uarg,
binding);
+ if (!skb_zcopy_pure(skb))
+ sk_forced_mem_schedule(sk, 0);
if (err == -EMSGSIZE || err == -EEXIST) {
tcp_mark_push(tp, skb);
goto new_segment;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 308/742] net: dpaa2-eth: fix objtool warning and logic bug
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (298 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 307/742] tcp: fix negative sk_forward_alloc after MSG_ZEROCOPY append Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 309/742] tls: dont hide a queued KeyUpdate from poll() Greg Kroah-Hartman
` (426 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Robert-Ionut Alexa, Ioana Ciornei,
David S. Miller, Andrew Lunn, Jakub Kicinski, Paolo Abeni,
Linus Torvalds, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <torvalds@linux-foundation.org>
[ Upstream commit 25faec9ce61c01fb45abf812a222c5b43c3cd5c5 ]
This commit came about because I locally had a build with COMPILE_TEST
and various runtime hardening features (that don't make sense for a pure
build test anyway) disabled - and objtool complained about some of the
code as a result:
drivers/net/ethernet/freescale/dpaa2/fsl-dpaa2-eth.o: warning: objtool: dpaa2_eth_add_bufs+0x3f8: stack state mismatch: reg1[15]=-1+0 reg2[15]=-2-208
The reason seems to be that without the hardening features, objtool
notices that gcc is doing really odd things with the 'page' variable,
which is uninitialized in the path where 'ch->xsk_zc' is true.
Now, this seems to be just objtool becoming confused about some ugly
code, but that code is _also_ actively buggy in a different way, so
let's just fix this all.
What confuses objtool seems to be the stack slot for the uninitialized
'page' variable - for the case where that variable isn't actually used.
There is some shared error handling code that frees the previously
allocated page or xsk buffers depending on previous state.
That code is ugly and worth fixing: just free the page or buffers in the
context where they are actually allocated, not at some common point
where you have to wonder "which one is it I'm supposed to free again?".
That gets rid of the objtool warning, because now gcc doesn't take messy
and incomprehensible source code and turn it into messy and even more
incomprehensible object code any more. No more questionable stack
frames with CFI information that blows objtool's little mind.
But fixing that then makes a real bug more obvious: the freeing of the
xsk buffers is buggy. It frees the buffers that never got mapped:
for (; i < batch; i++)
xsk_buff_free(xdp_buffs[i]);
and that looks sane enough: iterate over the unused part of the batch.
But it's horrendously wrong, because it updates 'i'.
And 'i' isn't some harmless little local loop counter. It's the
variable that is supposed to contain how many buffers have been
successfully mapped. So now that 'free the buffers we didn't map' loop
ends up updating that counter, and after the loop 'i' will be the whole
batch we allocated.
So that loop first freed the buffers that failed to map, and then as a
side effect said "all these buffers I just freed were successfully
mapped" and they would be released to hardware.
So objtool didn't actually find a real bug. It just found code that was
so ugly that it triggered a false positive. And as is often the case
with ugly code: people hadn't understood it either, and it was buggy.
It's worth noting that the code is still ugly. A variable name like 'i'
is perfectly fine for some random anonymous loop iterator that is just
that. But when it has serious meaning outside the loop, you should give
it a serious name that makes sense non-locally.
This does not fix that kind of ugliness. This is just the minimal fix
for the objtool warning and the entirely incidental bug it then
uncovered. They had nothing in common except for the obfuscated C code
contest entry.
Fixes: 48276c08cf5d ("net: dpaa2-eth: AF_XDP RX zero copy support")
Cc: Robert-Ionut Alexa <robert-ionut.alexa@nxp.com>
Cc: Ioana Ciornei <ioana.ciornei@nxp.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 28 ++++++++-----------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 6f1046c9cc515..d81b014163fa3 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -1681,11 +1681,9 @@ static int dpaa2_eth_add_bufs(struct dpaa2_eth_priv *priv,
struct device *dev = priv->net_dev->dev.parent;
u64 buf_array[DPAA2_ETH_BUFS_PER_CMD];
struct dpaa2_eth_swa *swa;
- struct page *page;
dma_addr_t addr;
int retries = 0;
int i = 0, err;
- u32 batch;
/* Allocate buffers visible to WRIOP */
if (!ch->xsk_zc) {
@@ -1695,14 +1693,16 @@ static int dpaa2_eth_add_bufs(struct dpaa2_eth_priv *priv,
* the entire page except for a tailroom reserved for
* skb shared info
*/
- page = dev_alloc_pages(0);
+ struct page *page = dev_alloc_pages(0);
if (!page)
goto err_alloc;
addr = dma_map_page(dev, page, 0, priv->rx_buf_size,
DMA_BIDIRECTIONAL);
- if (unlikely(dma_mapping_error(dev, addr)))
- goto err_map;
+ if (unlikely(dma_mapping_error(dev, addr))) {
+ __free_pages(page, 0);
+ goto err_alloc;
+ }
buf_array[i] = addr;
@@ -1718,8 +1718,8 @@ static int dpaa2_eth_add_bufs(struct dpaa2_eth_priv *priv,
* of DPAA2_ETH_BUFS_PER_CMD. Bail out if the UMEM cannot
* provide enough buffers at the moment
*/
- batch = xsk_buff_alloc_batch(ch->xsk_pool, xdp_buffs,
- DPAA2_ETH_BUFS_PER_CMD);
+ u32 batch = xsk_buff_alloc_batch(ch->xsk_pool, xdp_buffs,
+ DPAA2_ETH_BUFS_PER_CMD);
if (!batch)
goto err_alloc;
@@ -1729,8 +1729,11 @@ static int dpaa2_eth_add_bufs(struct dpaa2_eth_priv *priv,
swa->xsk.xdp_buff = xdp_buffs[i];
addr = xsk_buff_xdp_get_frame_dma(xdp_buffs[i]);
- if (unlikely(dma_mapping_error(dev, addr)))
- goto err_map;
+ if (unlikely(dma_mapping_error(dev, addr))) {
+ for (int j = i; j < batch; j++)
+ xsk_buff_free(xdp_buffs[j]);
+ goto err_alloc;
+ }
buf_array[i] = addr;
@@ -1761,13 +1764,6 @@ static int dpaa2_eth_add_bufs(struct dpaa2_eth_priv *priv,
return i;
-err_map:
- if (!ch->xsk_zc) {
- __free_pages(page, 0);
- } else {
- for (; i < batch; i++)
- xsk_buff_free(xdp_buffs[i]);
- }
err_alloc:
/* If we managed to allocate at least some buffers,
* release them to hardware
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 309/742] tls: dont hide a queued KeyUpdate from poll()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (299 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 308/742] net: dpaa2-eth: fix objtool warning and logic bug Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 310/742] tg3: Dont fail probe if 31-bit coherent DMA mask is unsupported Greg Kroah-Hartman
` (425 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Felipe Pereira Stival, Simon Horman,
Sabrina Dubroca, Paolo Abeni, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Pereira Stival <v0idpwn@gmail.com>
[ Upstream commit 285ca329ad4bfc32d0f383340c40a40c8157ac7c ]
When application data and a KeyUpdate are both queued, the recv() for
the data can also decrypt the KeyUpdate. That makes a rekey pending,
and the KeyUpdate is left on rx_list because its record type differs.
tls_sk_poll() reports no read events while a rekey is pending, so the
socket doesn't poll readable although a recvmsg() would return the
KeyUpdate. A reader that waits for a read event before each recv()
never reads it, never provides the new key and receives nothing more.
Report read events for records on rx_list while a rekey is pending,
since they are already decrypted. Keep ignoring the records still in
the strparser, so once the KeyUpdate has been read there are no read
events until the new key is provided, as before. Update the
documentation to say so.
Found with a level-triggered epoll reader that does one recv() per
read event. Without this patch it gets the data and then no read event
for the KeyUpdate; with it, the KeyUpdate is reported and the rekey
completes.
Fixes: 47069594e67e ("tls: implement rekey for TLS1.3")
Signed-off-by: Felipe Pereira Stival <v0idpwn@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://patch.msgid.link/20261118-v0idpwn-tls-poll-parked-keyupdate-v1-1-8e25101e7be6@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Documentation/networking/tls.rst | 7 ++++---
net/tls/tls_main.c | 6 +++---
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/Documentation/networking/tls.rst b/Documentation/networking/tls.rst
index 980c442d7161a..e07c1a001b217 100644
--- a/Documentation/networking/tls.rst
+++ b/Documentation/networking/tls.rst
@@ -215,9 +215,10 @@ To prevent attempting to decrypt incoming records using the wrong key,
decryption will be paused when a KeyUpdate message is received by the
kernel, until the new key has been provided using the TLS_RX socket
option. Any read occurring after the KeyUpdate has been read and
-before the new key is provided will fail with EKEYEXPIRED. poll() will
-not report any read events from the socket until the new key is
-provided. There is no pausing on the transmit side.
+before the new key is provided will fail with EKEYEXPIRED. Once the
+KeyUpdate has been read, poll() will not report any read events from
+the socket until the new key is provided. There is no pausing on the
+transmit side.
Userspace should make sure that the crypto_info provided has been set
properly. In particular, the kernel will not check for key/nonce
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index f13faafe58d20..270b3aa708eb0 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -416,9 +416,9 @@ static __poll_t tls_sk_poll(struct file *file, struct socket *sock,
tls_ctx = tls_get_ctx(sk);
ctx = tls_sw_ctx_rx(tls_ctx);
- if ((skb_queue_empty_lockless(&ctx->rx_list) &&
- !tls_strp_msg_ready(ctx)) ||
- READ_ONCE(ctx->key_update_pending))
+ if (skb_queue_empty_lockless(&ctx->rx_list) &&
+ (!tls_strp_msg_ready(ctx) ||
+ READ_ONCE(ctx->key_update_pending)))
mask &= ~(EPOLLIN | EPOLLRDNORM);
return mask;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 310/742] tg3: Dont fail probe if 31-bit coherent DMA mask is unsupported
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (300 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 309/742] tls: dont hide a queued KeyUpdate from poll() Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 311/742] tg3: Skip management FW version when APE firmware is not ready Greg Kroah-Hartman
` (424 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Rui Salvaterra, Pavan Chebbi,
Simon Horman, Paolo Abeni, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavan Chebbi <pavan.chebbi@broadcom.com>
[ Upstream commit 686b8dbcedf8773dc505f9f315a0551c0bca70a3 ]
Commit 614f4d166eee ("tg3: Set coherent DMA mask bits to 31 for
BCM57766 chipsets") lowered the coherent DMA mask to 31 bits as a
workaround for a spurious address overflow error in the hardware.
The result of dma_set_coherent_mask() is fatal to probe, so on
platforms that cannot satisfy such a mask the device fails to probe:
tg3 0000:01:00.0: Unable to obtain 64 bit DMA for consistent allocations
tg3 0000:01:00.0: probe with driver tg3 failed with error -5
This was reported on a Mac mini (Macmini6,2, BCM57766) running a
kernel built without CONFIG_ZONE_DMA and with IOMMU passthrough as
the default. Without CONFIG_ZONE_DMA, dma_direct_supported() only
accepts a mask narrower than 32 bits if it covers the highest
physical memory address, so with direct mapping a 31-bit coherent
mask is rejected whenever memory extends above 2GB.
Treat the 31-bit mask as best effort. If it is refused, warn and fall
back to the mask used before 614f4d166eee, so that the device still
probes. Platforms that accept the mask are unaffected. Where it is
refused, 614f4d166eee never protected the device, it only stopped it
from probing, so this restores the behaviour of kernels before that
commit. Warn when a status block lands at an address matching the
pattern described in 614f4d166eee, so that a resulting TX timeout can
be identified.
Fixes: 614f4d166eee ("tg3: Set coherent DMA mask bits to 31 for BCM57766 chipsets")
Reported-by: Rui Salvaterra <rsalvaterra@gmail.com>
Link: https://lore.kernel.org/netdev/CALjTZvYKHWrD5m+RXimjxODvpFPw7Cq_EOEuzRi1PZT9_JxF+g@mail.gmail.com/
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20261118105408.1076095-2-pavan.chebbi@broadcom.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/tg3.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index fd1c95f1111c5..25a74ac8b80f1 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -8867,6 +8867,13 @@ static int tg3_alloc_consistent(struct tg3 *tp)
if (!tnapi->hw_status)
goto err_out;
+ if (tg3_asic_rev(tp) == ASIC_REV_57766 &&
+ (lower_32_bits(tnapi->status_mapping) & 0xffff0000) ==
+ 0xffff0000)
+ dev_warn(&tp->pdev->dev,
+ "Status block at DMA address %pad may cause TX timeouts on this device\n",
+ &tnapi->status_mapping);
+
sblk = tnapi->hw_status;
if (tg3_flag(tp, ENABLE_RSS)) {
@@ -17688,6 +17695,7 @@ static int tg3_init_one(struct pci_dev *pdev,
u64 dma_mask, persist_dma_mask;
netdev_features_t features = 0;
u8 addr[ETH_ALEN] __aligned(2);
+ u64 test_dma_mask = 0;
err = pci_enable_device(pdev);
if (err) {
@@ -17827,15 +17835,22 @@ static int tg3_init_one(struct pci_dev *pdev,
persist_dma_mask = dma_mask = DMA_BIT_MASK(64);
if (tg3_asic_rev(tp) == ASIC_REV_57766)
- persist_dma_mask = DMA_BIT_MASK(31);
+ test_dma_mask = DMA_BIT_MASK(31);
/* Configure DMA attributes. */
if (dma_mask > DMA_BIT_MASK(32)) {
err = dma_set_mask(&pdev->dev, dma_mask);
if (!err) {
features |= NETIF_F_HIGHDMA;
- err = dma_set_coherent_mask(&pdev->dev,
- persist_dma_mask);
+ if (!test_dma_mask ||
+ dma_set_coherent_mask(&pdev->dev,
+ test_dma_mask)) {
+ if (test_dma_mask)
+ dev_warn(&pdev->dev,
+ "Unable to set 31 bit coherent DMA mask, workaround not applied\n");
+ err = dma_set_coherent_mask(&pdev->dev,
+ persist_dma_mask);
+ }
if (err < 0) {
dev_err(&pdev->dev, "Unable to obtain 64 bit "
"DMA for consistent allocations\n");
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 311/742] tg3: Skip management FW version when APE firmware is not ready
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (301 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 310/742] tg3: Dont fail probe if 31-bit coherent DMA mask is unsupported Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 312/742] tg3: Fix heap overflow in unbuffered NVRAM write path Greg Kroah-Hartman
` (423 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Pavan Chebbi, Simon Horman,
Paolo Abeni, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavan Chebbi <pavan.chebbi@broadcom.com>
[ Upstream commit 70e57e1255e06fd7a22d45dd2bf854200fcbd575 ]
When the APE firmware is not present or not ready, for example when
the NCSI component is missing in the NVRAM, tg3_read_fw_ver() still
calls tg3_read_dash_ver() after tg3_probe_ncsi(). The signature and
ready checks that tg3_read_dash_ver() used to make were moved into
tg3_probe_ncsi(), which only sets the NCSI flag and does not stop the
caller. The driver then reads the APE firmware version register, which
holds no valid data in this state, and ethtool -i shows an invalid
"DASH" string with a garbage version.
Make tg3_probe_ncsi() return whether valid, ready APE firmware was
found, and read the version only in that case. Otherwise just report
the bootcode version.
This was seen by a user on BCM5719/BCM5720 with no NCSI component in
the NVRAM. With this change, ethtool -i displays only the bootcode
version.
Fixes: 165f4d1cb3d7 ("tg3: Fix the setting of the APE_HAS_NCSI flag")
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20261118105408.1076095-3-pavan.chebbi@broadcom.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/tg3.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 25a74ac8b80f1..4bd64124bdd9f 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -15997,20 +15997,26 @@ static void tg3_read_mgmtfw_ver(struct tg3 *tp)
}
}
-static void tg3_probe_ncsi(struct tg3 *tp)
+/* Returns true if valid, ready APE firmware is present, regardless of
+ * whether it advertises NCSI (it may be DASH or SMASH). Sets APE_HAS_NCSI
+ * if the NCSI feature is advertised.
+ */
+static bool tg3_probe_ncsi(struct tg3 *tp)
{
u32 apedata;
apedata = tg3_ape_read32(tp, TG3_APE_SEG_SIG);
if (apedata != APE_SEG_SIG_MAGIC)
- return;
+ return false;
apedata = tg3_ape_read32(tp, TG3_APE_FW_STATUS);
if (!(apedata & APE_FW_STATUS_READY))
- return;
+ return false;
if (tg3_ape_read32(tp, TG3_APE_FW_FEATURES) & TG3_APE_FW_FEATURE_NCSI)
tg3_flag_set(tp, APE_HAS_NCSI);
+
+ return true;
}
static void tg3_read_dash_ver(struct tg3 *tp)
@@ -16089,8 +16095,7 @@ static void tg3_read_fw_ver(struct tg3 *tp)
if (tg3_flag(tp, ENABLE_ASF)) {
if (tg3_flag(tp, ENABLE_APE)) {
- tg3_probe_ncsi(tp);
- if (!vpd_vers)
+ if (tg3_probe_ncsi(tp) && !vpd_vers)
tg3_read_dash_ver(tp);
} else if (!vpd_vers) {
tg3_read_mgmtfw_ver(tp);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 312/742] tg3: Fix heap overflow in unbuffered NVRAM write path
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (302 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 311/742] tg3: Skip management FW version when APE firmware is not ready Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 313/742] net: dsa: tag_brcm: fix link-local detection with a prepended tag Greg Kroah-Hartman
` (422 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Shravya KN, Pavan Chebbi,
Simon Horman, Paolo Abeni, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shravya KN <shravya.k-n@broadcom.com>
[ Upstream commit 0323a427052447e2c41c650fc98a6c04bf417e5d ]
tg3_nvram_write_block_unbuffered() reads a whole NVRAM page into a
buffer of pagesize bytes, copies the caller's data into it at page_off,
and writes the page back. The copy size was clamped to pagesize rather
than to the room left in the page, pagesize - page_off, so a write at an
offset that is not page aligned, as ETHTOOL_SEEPROM allows, copies past
the end of the buffer and corrupts the kernel heap.
Clamp size to pagesize - page_off. Also advance buf by size on each
iteration. Without this, a write that spans more than one page
programmed every page after the first with the data of the first page,
and a write that did not start on a page boundary lost the tail of the
data without reporting an error.
Reject an nvram_pagesize that is smaller than 4 or not a power of two.
The page mask is pagesize - 1, which is only a valid mask for a power
of two. A page size of 0, which tg3_get_nvram_info() leaves unset for
an unhandled flash vendor, also made the loop issue erase commands at
address 0 forever with the rtnl and NVRAM locks held. ethtool -E now
fails with -EINVAL in these cases.
This was found by an AI code review scan. It has not been observed on
hardware, but it can be reached with ethtool -E on devices with
unbuffered flash.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Shravya KN <shravya.k-n@broadcom.com>
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20261118105408.1076095-4-pavan.chebbi@broadcom.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/ethernet/broadcom/tg3.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 4bd64124bdd9f..4154a765767c3 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -56,6 +56,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/crc32.h>
#include <linux/dmi.h>
+#include <linux/log2.h>
#include <net/checksum.h>
#include <net/gso.h>
@@ -3379,6 +3380,9 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
u32 nvram_cmd;
u8 *tmp;
+ if (pagesize < 4 || !is_power_of_2(pagesize))
+ return -EINVAL;
+
tmp = kmalloc(pagesize, GFP_KERNEL);
if (tmp == NULL)
return -ENOMEM;
@@ -3399,13 +3403,14 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
break;
page_off = offset & pagemask;
- size = pagesize;
+ size = pagesize - page_off;
if (len < size)
size = len;
len -= size;
memcpy(tmp + page_off, buf, size);
+ buf += size;
offset = offset + (pagesize - page_off);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 313/742] net: dsa: tag_brcm: fix link-local detection with a prepended tag
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (303 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 312/742] tg3: Fix heap overflow in unbuffered NVRAM write path Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 314/742] perf: Prevent duplicate sigtrap task work enqueue Greg Kroah-Hartman
` (421 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Florian Fainelli, Paolo Abeni,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fainelli <florian.fainelli@broadcom.com>
[ Upstream commit ae8e5ef9fa9eeaf4ee0a9a9bde0fc63023d9b154 ]
brcm_tag_rcv_ll() checks eth_hdr(skb)->h_dest to avoid marking link-local
frames as forwarded by the switch. With a prepended tag, eth_type_trans()
sets the MAC header at the start of the tag, so the address checked is the
tag plus the first two bytes of the real destination address. Link-local
frames such as BPDUs, LLDP or EAPOL are then not recognized and get
skb->offload_fwd_mark set, which keeps the bridge from forwarding them in
software to the other ports of the switch when it is configured to do so.
Read the destination address after the tag instead when the tag is
prepended. Tags embedded after the source address are not affected.
Fixes: 762e7e174da9 ("net: dsa: tag_brcm: do not mark link local traffic as offloaded")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20261118184004.1916105-1-florian.fainelli@broadcom.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/dsa/tag_brcm.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c
index b7c49822ca888..b58669c921474 100644
--- a/net/dsa/tag_brcm.c
+++ b/net/dsa/tag_brcm.c
@@ -149,6 +149,7 @@ static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
unsigned int offset)
{
int source_port;
+ const u8 *dest;
u8 *brcm_tag;
if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN))) {
@@ -184,7 +185,11 @@ static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
/* Remove Broadcom tag and update checksum */
skb_pull_rcsum(skb, BRCM_TAG_LEN);
- if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest)))
+ /* With a prepended tag, the MAC header set by eth_type_trans() starts
+ * at the tag, and the destination address follows it.
+ */
+ dest = offset == ETH_HLEN ? brcm_tag + BRCM_TAG_LEN : eth_hdr(skb)->h_dest;
+ if (likely(!is_link_local_ether_addr(dest)))
dsa_default_offload_fwd_mark(skb);
return skb;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 314/742] perf: Prevent duplicate sigtrap task work enqueue
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (304 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 313/742] net: dsa: tag_brcm: fix link-local detection with a prepended tag Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:02 ` [PATCH 7.3 315/742] perf: Fix sigtrap for software events Greg Kroah-Hartman
` (420 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tengda Wu, Peter Zijlstra (Intel),
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tengda Wu <wutengda@huaweicloud.com>
[ Upstream commit e4c5112f01816b0ac6d74724545eca1195788c38 ]
The sigtrap handling in __perf_event_overflow() checks
event->pending_work before calling task_work_add(), but only sets
pending_work after the task work has been queued.
This leaves a window where an NMI can interrupt task_work_add() and
re-enter __perf_event_overflow() for the same (software/tracepoint)
event. Since pending_work is still zero, the nested invocation can
enqueue the same pending_task again.
The re-entrant call path looks like this:
__perf_event_overflow()
task_work_add()
<NMI>
__perf_event_overflow()
task_work_add()
The nested invocation may enqueue pending_task before the outer
invocation does. When the outer invocation resumes, it inserts the
same task work entry again, potentially creating a cycle in the task
work list.
As a result, perf_pending_task() may be executed repeatedly, leading
to unbalanced event reference counting.
Fix this by atomically claiming pending_work with cmpxchg_local()
before calling task_work_add(). This ensures that only one invocation
can enqueue the task work, even when another overflow occurs
re-entrantly from an NMI.
Notably: sigtrap events must be per-task, meaning that the there is no
concurrency, only re-entrancy.
[peterz: clarify and rewrite]
Fixes: c5d93d23a260 ("perf: Enqueue SIGTRAP always via task_work.")
Signed-off-by: Tengda Wu <wutengda@huaweicloud.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/45bd71c976aea1a0e8bf5762dd6b6552e6009439.1795053619.git.wutengda@huaweicloud.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/events/core.c | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index a62a1273fc691..cd070695f184b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7767,9 +7767,15 @@ static void perf_pending_task(struct callback_head *head)
rctx = perf_swevent_get_recursion_context();
if (event->pending_work) {
- event->pending_work = 0;
perf_sigtrap(event);
local_dec(&event->ctx->nr_no_switch_fast);
+ /*
+ * event->pending_work also acts as a 'lock' for
+ * event->{pending_addr, orig_type, attr.sig_data}. As such we
+ * must clear after perf_sigtrap is complete.
+ */
+ barrier();
+ event->pending_work = 0;
}
put_event(event);
@@ -10940,16 +10946,22 @@ static int __perf_event_overflow(struct perf_event *event,
notify_mode = in_nmi() ? TWA_NMI_CURRENT : TWA_RESUME;
- if (!event->pending_work &&
- !task_work_add(current, &event->pending_task, notify_mode)) {
- event->pending_work = pending_id;
- local_inc(&event->ctx->nr_no_switch_fast);
- WARN_ON_ONCE(!atomic_long_inc_not_zero(&event->refcount));
-
- event->pending_addr = 0;
- if (valid_sample && (data->sample_flags & PERF_SAMPLE_ADDR))
- event->pending_addr = data->addr;
-
+ /*
+ * Software events can nest and attempt this recursively;
+ * claim the pending_work before task_work_add() recurses.
+ */
+ if (cmpxchg_local(&event->pending_work, 0, 1) == 0) {
+ if (!task_work_add(current, &event->pending_task, notify_mode)) {
+ event->pending_work = pending_id;
+ local_inc(&event->ctx->nr_no_switch_fast);
+ WARN_ON_ONCE(!atomic_long_inc_not_zero(&event->refcount));
+
+ event->pending_addr = 0;
+ if (valid_sample && (data->sample_flags & PERF_SAMPLE_ADDR))
+ event->pending_addr = data->addr;
+ } else {
+ event->pending_work = 0;
+ }
} else if (event->attr.exclude_kernel && valid_sample) {
/*
* Should not be able to return to user space without
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 315/742] perf: Fix sigtrap for software events
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (305 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 314/742] perf: Prevent duplicate sigtrap task work enqueue Greg Kroah-Hartman
@ 2026-12-04 10:02 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 316/742] perf: Fix sigtrap vs fast-switch Greg Kroah-Hartman
` (419 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:02 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tengda Wu, Peter Zijlstra (Intel),
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <peterz@infradead.org>
[ Upstream commit 38606d2911f7f2fe80388315da0c4a7fc98af0f8 ]
perf_sigtrap() contains:
WARN_ON_ONCE(event->ctx->task != current)
The warning assumes that an event's ctx->task always matches the task
that ends up running the pending task_work. That assumption can be
broken by the context fast-swap path.
The failure sequence is:
1. A -> B switch, perf_event_context_sched_out() takes the fast path
and does WRITE_ONCE(ctx->task, next) / WRITE_ONCE(next_ctx->task, task).
An NMI then hits while the context is swapped, and
__perf_event_overflow() queues pending task_work on the *current*
task (A), even though the event now belongs to B's swapped-in
context view.
2. B -> A switch. Because A now has pending task_work,
nr_no_switch_fast is non-zero, so the slow path is taken and
ctx->task is *not* swapped back.
3. A returns to user mode, task_work runs perf_pending_task() ->
perf_sigtrap(), and event->ctx->task no longer equals current,
tripping the WARN_ON_ONCE().
The nr_no_switch_fast bits hard rely on perf_pmu_disable() actually working. It
turns out the software events do not implement the pmu::pmu_{dis,en}able()
methods and generally ignore the state, making the above scenario worse in that
an overflow can happen in the middle of swapping task contexts, making it
impossible to reconstruct state.
Ensure software and tracepoint events respect the disable state.
Fixes: ca6c21327c6a ("perf: Fix missing SIGTRAPs")
Fixes: c5d93d23a260 ("perf: Enqueue SIGTRAP always via task_work.")
Reported-by: Tengda Wu <wutengda@huaweicloud.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Tengda Wu <wutengda@huaweicloud.com>
Link: https://patch.msgid.link/20261125161342.GP2669272%40noisy.programming.kicks-ass.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/perf_event.h | 1 +
kernel/events/core.c | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 8a985486ab122..07b9d5a319996 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1237,6 +1237,7 @@ extern const struct perf_event_attr *perf_event_attrs(struct perf_event *event);
extern void perf_event_print_debug(void);
extern void perf_pmu_disable(struct pmu *pmu);
extern void perf_pmu_enable(struct pmu *pmu);
+extern bool perf_pmu_enabled(struct pmu *pmu);
extern void perf_sched_cb_dec(struct pmu *pmu);
extern void perf_sched_cb_inc(struct pmu *pmu);
extern int perf_event_task_disable(void);
diff --git a/kernel/events/core.c b/kernel/events/core.c
index cd070695f184b..3b8aea12a2fc5 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -1366,6 +1366,12 @@ void perf_pmu_enable(struct pmu *pmu)
pmu->pmu_enable(pmu);
}
+bool perf_pmu_enabled(struct pmu *pmu)
+{
+ int *count = &this_cpc(pmu)->pmu_disable_count;
+ return *count == 0;
+}
+
static void perf_assert_pmu_disabled(struct pmu *pmu)
{
int *count = &this_cpc(pmu)->pmu_disable_count;
@@ -11147,6 +11153,9 @@ static int perf_swevent_match(struct perf_event *event,
struct perf_sample_data *data,
struct pt_regs *regs)
{
+ if (!perf_pmu_enabled(event->pmu))
+ return 0;
+
if (event->attr.type != type)
return 0;
@@ -11527,6 +11536,9 @@ static int perf_tp_event_match(struct perf_event *event,
struct perf_raw_record *raw,
struct pt_regs *regs)
{
+ if (!perf_pmu_enabled(event->pmu))
+ return 0;
+
if (event->hw.state & PERF_HES_STOPPED)
return 0;
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 316/742] perf: Fix sigtrap vs fast-switch
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (306 preceding siblings ...)
2026-12-04 10:02 ` [PATCH 7.3 315/742] perf: Fix sigtrap for software events Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 317/742] gpio: davinci: use controller-specific MMIO for BINTEN Greg Kroah-Hartman
` (418 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tengda Wu, Peter Zijlstra (Intel),
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <peterz@infradead.org>
[ Upstream commit 34dc983cc1628dea5054baa8687477cbb8683e28 ]
perf_sigtrap() contains:
WARN_ON_ONCE(event->ctx->task != current)
The warning assumes that an event's ctx->task always matches the task
that ends up running the pending task_work. That assumption can be
broken by the context fast-swap path.
The failure sequence is:
1. A -> B switch, perf_event_context_sched_out() takes the fast path
and does WRITE_ONCE(ctx->task, next) / WRITE_ONCE(next_ctx->task, task).
An NMI then hits while the context is swapped, and
__perf_event_overflow() queues pending task_work on the *current*
task (A), even though the event now belongs to B's swapped-in
context view.
2. B -> A switch. Because A now has pending task_work,
nr_no_switch_fast is non-zero, so the slow path is taken and
ctx->task is *not* swapped back.
3. A returns to user mode, task_work runs perf_pending_task() ->
perf_sigtrap(), and event->ctx->task no longer equals current,
tripping the WARN_ON_ONCE().
Therefore; the task_work_add() should in fact use event->ctx->task, rather than
current. They are always the same, except in this narrow window between
perf_event_task_sched_out() and switch_to().
Fixes: c5d93d23a260 ("perf: Enqueue SIGTRAP always via task_work.")
Reported-by: Tengda Wu <wutengda@huaweicloud.com>
Tested-by: Tengda Wu <wutengda@huaweicloud.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20261125161342.GP2669272%40noisy.programming.kicks-ass.net
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/events/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 3b8aea12a2fc5..48fee445fb414 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10957,7 +10957,7 @@ static int __perf_event_overflow(struct perf_event *event,
* claim the pending_work before task_work_add() recurses.
*/
if (cmpxchg_local(&event->pending_work, 0, 1) == 0) {
- if (!task_work_add(current, &event->pending_task, notify_mode)) {
+ if (!task_work_add(event->ctx->task, &event->pending_task, notify_mode)) {
event->pending_work = pending_id;
local_inc(&event->ctx->nr_no_switch_fast);
WARN_ON_ONCE(!atomic_long_inc_not_zero(&event->refcount));
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 317/742] gpio: davinci: use controller-specific MMIO for BINTEN
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (307 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 316/742] perf: Fix sigtrap vs fast-switch Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 318/742] gpio: mvebu: validate ngpios before use Greg Kroah-Hartman
` (417 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Linus Walleij, Sahaj Chaudhari,
Bartosz Golaszewski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sahaj Chaudhari <sahaj123.sc@gmail.com>
[ Upstream commit a142f1c5de4b9c03910cc304a26fbbdef69ca422 ]
The file-global gpio_base can be overwritten when probes for multiple
DaVinci GPIO controllers overlap. The later IRQ setup can then write the
BINTEN register of a different controller.
Derive the BINTEN address from the current controller's mapped bank
instead of shared global state.
Fixes: 118150f22d6b ("gpio: davinci: move to platform device")
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Sahaj Chaudhari <sahaj123.sc@gmail.com>
Link: https://patch.msgid.link/20261124121500.2cd5cbf30f89-2-sahaj123.sc@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpio-davinci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index fc2b9bef7efc8..b482af43e998a 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -43,7 +43,6 @@ typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq);
#define BINTEN 0x8 /* GPIO Interrupt Per-Bank Enable Register */
-static void __iomem *gpio_base;
static unsigned int offset_array[5] = {0x10, 0x38, 0x60, 0x88, 0xb0};
struct davinci_gpio_irq_data {
@@ -168,6 +167,7 @@ static int davinci_gpio_probe(struct platform_device *pdev)
unsigned int ngpio, nbank, nirq, gpio_unbanked;
struct davinci_gpio_controller *chips;
struct device *dev = &pdev->dev;
+ void __iomem *gpio_base;
/*
* The gpio banks conceptually expose a segmented bitmap,
@@ -588,7 +588,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
* BINTEN -- per-bank interrupt enable. genirq would also let these
* bits be set/cleared dynamically.
*/
- writel_relaxed(binten, gpio_base + BINTEN);
+ writel_relaxed(binten, chips->regs[0] - offset_array[0] + BINTEN);
return 0;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 318/742] gpio: mvebu: validate ngpios before use
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (308 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 317/742] gpio: davinci: use controller-specific MMIO for BINTEN Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 319/742] ASoC: aw88399: fix register used to disable I2S TX Greg Kroah-Hartman
` (416 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Rosen Penev, Bartosz Golaszewski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <rosenp@gmail.com>
[ Upstream commit 62a41997c1553b723a7a333c0246d0646ebd2c95 ]
If ngpios is read as 0 from device tree, it is passed via
irq_alloc_domain_generic_chips() as irqs_per_chip, which leads to a
division by zero in DIV_ROUND_UP(d->revmap_size, irqs_per_chip).
Reject ngpios == 0 early.
Also reject higher than 32, which is the limit.
Fixes: fefe7b0923459 ("gpio: introduce gpio-mvebu driver for Marvell SoCs")
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20261126002650.603321-1-rosenp@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpio-mvebu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 92ce02441cc99..e16ba0204bff8 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -1214,6 +1214,9 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
return -ENODEV;
}
+ if (ngpios == 0 || ngpios > MVEBU_MAX_GPIO_PER_BANK)
+ return dev_err_probe(&pdev->dev, -EINVAL, "ngpios must be between 1 and 32\n");
+
id = of_alias_get_id(pdev->dev.of_node, "gpio");
if (id < 0) {
dev_err(&pdev->dev, "Couldn't get OF id\n");
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 319/742] ASoC: aw88399: fix register used to disable I2S TX
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (309 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 318/742] gpio: mvebu: validate ngpios before use Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 320/742] sched/topology: Dont claim sched_domain_shared twice on the same domain Greg Kroah-Hartman
` (415 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Marco Giunta, Mark Brown,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Giunta <marco_giunta@outlook.it>
[ Upstream commit 1e5a677a5c53b96abf8004cc4d7ba0387f4e8505 ]
aw_dev_i2s_tx_enable() uses I2SCTRL3 when enabling the I2S transmitter
but I2SCFG1 when disabling it. Per the datasheet, the I2STXEN bit lives
in I2SCTRL3.
As a result, the I2S transmitter is never disabled when the device is
stopped.
Use I2SCTRL3 in both cases, as the vendor Android driver (aw883xx) and
aw88166 (which is also derived from aw883xx) do.
Fixes: 8ade6cc7e261 ("ASoC: codecs: Add aw88399 amplifier driver")
Signed-off-by: Marco Giunta <marco_giunta@outlook.it>
Link: https://patch.msgid.link/SN6PR19MB23038B66A212CA32A4B6B3CCFC472@SN6PR19MB2303.namprd19.prod.outlook.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/codecs/aw88399-lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/aw88399-lib.c b/sound/soc/codecs/aw88399-lib.c
index 1ba0147cf4dfd..9aa2e9cde727f 100644
--- a/sound/soc/codecs/aw88399-lib.c
+++ b/sound/soc/codecs/aw88399-lib.c
@@ -561,7 +561,7 @@ static void aw_dev_i2s_tx_enable(struct aw_device *aw_dev, bool flag)
ret = regmap_update_bits(aw_dev->regmap, AW88399_I2SCTRL3_REG,
~AW88399_I2STXEN_MASK, AW88399_I2STXEN_ENABLE_VALUE);
else
- ret = regmap_update_bits(aw_dev->regmap, AW88399_I2SCFG1_REG,
+ ret = regmap_update_bits(aw_dev->regmap, AW88399_I2SCTRL3_REG,
~AW88399_I2STXEN_MASK, AW88399_I2STXEN_DISABLE_VALUE);
if (ret)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 320/742] sched/topology: Dont claim sched_domain_shared twice on the same domain
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (310 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 319/742] ASoC: aw88399: fix register used to disable I2S TX Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 321/742] efi/libstub: loongarch: Provide 64-bit integer shift helpers for 32-bit Greg Kroah-Hartman
` (414 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Breno Leitao, Peter Zijlstra (Intel),
André Draszik, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <leitao@debian.org>
[ Upstream commit 40fddc398878c2cf661b7f16d783bfc5b0000642 ]
build_sched_domains() lets the asymmetric capacity path claim a
sched_domain_shared object on the lowest SD_ASYM_CPUCAPACITY_FULL
ancestor, and then unconditionally claims one for the topmost
SD_SHARE_LLC domain. When those are the same sched_domain - a system
whose single LLC spans CPUs of differing capacity, for example an arm64
machine with one MC domain covering every CPU - init_sched_domain_shared()
runs twice on that domain. The second call overwrites sd->shared without
dropping the reference the first call took, so the asym blob ends up with
a refcount equal to the CPU count and nothing pointing at it.
claim_allocations() sees the non-zero refcount and clears the per-CPU
slot, so __sds_free() does not reclaim it either, and the object leaks.
kmemleak reports one 32-byte object per build_sched_domains() call:
unreferenced object 0xffff0000c02432a0 (size 32):
comm "swapper/0", pid 1, jiffies 4294667436
hex dump (first 32 bytes):
08 00 00 00 08 00 00 00 00 00 00 00 20 00 00 00 ............ ...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc f4478cb7):
kmemleak_alloc+0x44/0xd8
__kmalloc_cache_node_noprof+0x344/0x5d0
build_sched_domains+0x2f8/0x2110
sched_init_domains+0xec/0x160
sched_init_smp+0x48/0x108
kernel_init_freeable+0x1cc/0x2b8
ref and nr_busy_cpus are both the online CPU count and alloc_flags is
0x20, SD_ASYM_CPUCAPACITY, identifying it as the blob the asym path
claimed.
Only claim a shared object for the LLC domain when the domain does not
already have one. sd_init() zero initialises sd->shared for every domain
it builds, so a non-NULL sd->shared here means the asym path already
claimed this very domain. Cache aware scheduling still finds a shared
object on sd_llc, the same one, covering the same span.
Reproduced under QEMU/virtme-ng on arm64 with two capacity tiers
(capacity-dmips-mhz 0x400 on cpu0-3 and 0x200 on cpu4-7), where the MC
domain spans all CPUs and carries both SD_SHARE_LLC and
SD_ASYM_CPUCAPACITY_FULL. Leaked sched_domain_shared objects reported by
kmemleak, with a kmemleak-test module loaded as a positive control:
before after
after boot 1 0
after 12 rebuilds via CPU hotplug 13 0
That is exactly one leak per build_sched_domains(), and none once the
domain is only claimed once.
Fixes: 9e005ed21152 ("sched/topology: Allow multiple domains to claim sched_domain_shared")
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: André Draszik <andre.draszik@linaro.org>
Link: https://patch.msgid.link/20260810-b4-sched_shared_leak-v1-1-3eacd249d0a3@debian.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/sched/topology.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 21e3ab1af4c85..4a776734d2eef 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -3169,7 +3169,13 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
sd = sd->parent;
if (sd->flags & SD_SHARE_LLC) {
- init_sched_domain_shared(&d, sd, SD_SHARE_LLC);
+ /*
+ * The asym path above may have claimed a shared object
+ * on this very domain; claiming it again overwrites
+ * sd->shared and leaks the first reference.
+ */
+ if (!sd->shared)
+ init_sched_domain_shared(&d, sd, SD_SHARE_LLC);
/*
* In presence of higher domains, adjust the
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 321/742] efi/libstub: loongarch: Provide 64-bit integer shift helpers for 32-bit
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (311 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 320/742] sched/topology: Dont claim sched_domain_shared twice on the same domain Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 322/742] bpf: Undo insn aux changes of a failed speculative path Greg Kroah-Hartman
` (413 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dmitry Antipov, kernel test robot,
Ard Biesheuvel, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <ardb@kernel.org>
[ Upstream commit fe57062e09bc162be9133695d5f1459c1c0e46c0 ]
The EFI stub's copy of lib/cmdline.c performs 64-bit shifts in
memparse() [which is never actually called from the stub], and so it
needs library routines when running on 32-bit CPUs that lack native
instructions for this.
The LoongArch 32-bit EFI stub build already pulls in the library helpers
that are needed for this, but only when CONFIG_EFI_ZBOOT=y, which is not
sufficient, given that the same helpers will be needed in the vmlinux
build for the builtin copy of the EFI stub.
On other architectures, the builtin copy will call vmlinux's versions of
those routines, which are exposed to the stub via aliases in the linker
script. However, on LoongArch, those are C implementations that may be
instrumented and therefore unsuitable for use in the EFI stub.
Reported-by: Dmitry Antipov <dmantipov@yandex.ru>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/20261122125352.gAcg5yLx-lkp@intel.com/
Fixes: 3d9aba6618d1 ("LoongArch: Adjust build infrastructure for 32BIT/64BIT")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/firmware/efi/libstub/Makefile | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 48982d05c441e..9d4c28857457a 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -86,7 +86,9 @@ lib-$(CONFIG_ARM64) += kaslr.o arm64.o arm64-stub.o smbios.o
lib-$(CONFIG_X86) += x86-stub.o smbios.o
lib-$(CONFIG_X86_64) += x86-5lvl.o
lib-$(CONFIG_RISCV) += kaslr.o riscv.o riscv-stub.o
-lib-$(CONFIG_LOONGARCH) += loongarch.o loongarch-stub.o
+lib-loongarch-$(CONFIG_32BIT) += lib-ashldi3.o lib-lshrdi3.o
+lib-$(CONFIG_LOONGARCH) += loongarch.o loongarch-stub.o \
+ $(lib-loongarch-y)
CFLAGS_arm32-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
@@ -97,8 +99,7 @@ CFLAGS_zboot-decompress-zstd.o += -I$(srctree)/lib/zstd
zboot-riscv-obj-$(CONFIG_32BIT) := lib-ashldi3.o lib-lshrdi3.o
zboot-obj-$(CONFIG_RISCV) += lib-clz_ctz.o $(zboot-riscv-obj-y)
-zboot-loongarch-obj-$(CONFIG_32BIT) := lib-ashldi3.o lib-lshrdi3.o
-zboot-obj-$(CONFIG_LOONGARCH) += lib-clz_ctz.o $(zboot-loongarch-obj-y)
+zboot-obj-$(CONFIG_LOONGARCH) += lib-clz_ctz.o
lib-$(CONFIG_EFI_ZBOOT) += zboot.o $(zboot-obj-y)
lib-$(CONFIG_UNACCEPTED_MEMORY) += unaccepted_memory.o bitmap.o find.o
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 322/742] bpf: Undo insn aux changes of a failed speculative path
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (312 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 321/742] efi/libstub: loongarch: Provide 64-bit integer shift helpers for 32-bit Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 323/742] bpf: Treat NOT_INIT as a pointer in __is_pointer_value() Greg Kroah-Hartman
` (412 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit fa84f87e42af9ffa3f777d4ea3b8c4f82a5a7436 ]
If a check fails on a speculative path, do_check() adds a nospec before
the insn and ends the path. The check can have written nospec_result
and ctx_field_size of the insn already. The other paths can use the
insn with another type of pointer, so these values do not apply to them.
Save both fields before the check and restore them.
Fixes: d6f1c85f2253 ("bpf: Fall back to nospec for Spectre v1")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261126033816.4124847-2-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/verifier.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 073b7594d3980..a65af36e2b1c9 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -18667,7 +18667,8 @@ static int do_check(struct bpf_verifier_env *env)
for (;;) {
struct bpf_insn *insn;
struct bpf_insn_aux_data *insn_aux;
- int err;
+ int err, ctx_field_size;
+ bool nospec_result;
/* reset current history entry on each new instruction */
env->cur_hist_ent = NULL;
@@ -18805,6 +18806,8 @@ static int do_check(struct bpf_verifier_env *env)
if (state->speculative && insn_aux->nospec)
goto process_bpf_exit;
+ nospec_result = insn_aux->nospec_result;
+ ctx_field_size = insn_aux->ctx_field_size;
err = do_check_insn(env, &do_print_state);
if (error_recoverable_with_nospec(err) && state->speculative) {
/* Prevent this speculative path from ever reaching the
@@ -18815,6 +18818,8 @@ static int do_check(struct bpf_verifier_env *env)
* markings for alu sanitization.
*/
insn_aux->alu_state = 0;
+ insn_aux->nospec_result = nospec_result;
+ insn_aux->ctx_field_size = ctx_field_size;
goto process_bpf_exit;
} else if (err < 0) {
return err;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 323/742] bpf: Treat NOT_INIT as a pointer in __is_pointer_value()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (313 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 322/742] bpf: Undo insn aux changes of a failed speculative path Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 324/742] bpf: Emit nospec after calls and atomics that write to the stack Greg Kroah-Hartman
` (411 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexei Starovoitov, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit bbe2012ece4a72d4917dcc9b3461f7573a66c418 ]
The blamed commit made __is_pointer_value() use is_pointer_regtype(),
which is false for NOT_INIT. mark_reg_invalid() can set a spilled
register to NOT_INIT, and check_stack_read_fixed_off() must not handle
such a spill like a spilled scalar.
Go back to the check for SCALAR_VALUE.
Fixes: 1f737e46ca6a ("bpf: Remove artificial limitations on pointer types eligible for spilling")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261126033816.4124847-3-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/verifier.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index a65af36e2b1c9..ec3e02ae6b98a 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -3463,7 +3463,7 @@ static bool __is_pointer_value(bool allow_ptr_leaks,
if (allow_ptr_leaks)
return false;
- return is_pointer_regtype(reg->type);
+ return reg->type != SCALAR_VALUE;
}
static void clear_scalar_id(struct bpf_reg_state *reg)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 324/742] bpf: Emit nospec after calls and atomics that write to the stack
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (314 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 323/742] bpf: Treat NOT_INIT as a pointer in __is_pointer_value() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 325/742] bpf: Reject kernel threads in bpf_task_work_schedule() Greg Kroah-Hartman
` (410 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Luis Gerhorst, Alexei Starovoitov,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Starovoitov <ast@kernel.org>
[ Upstream commit 1879b5e505de97e250bb2d7e6914fbdf4032e15b ]
check_stack_write_fixed_off() sets nospec_result for BPF_ATOMIC insns
and for calls of helpers and kfuncs too. do_check() ends a speculative
path there, but bpf_convert_ctx_accesses() emits the nospec only after
BPF_MEM stores.
Later passes rewrite a call and need its aux data. Put the nospec in
front of the next insn.
Fixes: d6f1c85f2253 ("bpf: Fall back to nospec for Spectre v1")
Fixes: 880442305a39 ("bpf: Introduce load-acquire and store-release instructions")
Suggested-by: Luis Gerhorst <luis.gerhorst@fau.de>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Luis Gerhorst <luis.gerhorst@fau.de>
Link: https://patch.msgid.link/20261126033816.4124847-5-alexei.starovoitov@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/fixups.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/fixups.c b/kernel/bpf/fixups.c
index 2f53df08e7056..b39e6acfd002f 100644
--- a/kernel/bpf/fixups.c
+++ b/kernel/bpf/fixups.c
@@ -815,6 +815,7 @@ int bpf_convert_ctx_accesses(struct bpf_verifier_env *env)
const int insn_cnt = env->prog->len;
struct bpf_insn *epilogue_buf = env->epilogue_buf;
struct bpf_insn *insn_buf = env->insn_buf;
+ bool nospec, nospec_next = false;
struct bpf_insn *insn;
u32 target_size, size_default, off;
struct bpf_prog *new_prog;
@@ -884,8 +885,13 @@ int bpf_convert_ctx_accesses(struct bpf_verifier_env *env)
enum bpf_reg_type ptr_type;
u8 mode;
- if (env->insn_aux_data[i + delta].nospec) {
- WARN_ON_ONCE(env->insn_aux_data[i + delta].alu_state);
+ /* A call or an atomic gets its nospec in front of the next insn */
+ nospec = env->insn_aux_data[i + delta].nospec;
+ WARN_ON_ONCE(nospec && env->insn_aux_data[i + delta].alu_state);
+ nospec |= nospec_next;
+ nospec_next = env->insn_aux_data[i + delta].nospec_result;
+
+ if (nospec) {
struct bpf_insn *patch = insn_buf;
*patch++ = BPF_ST_NOSPEC();
@@ -977,6 +983,7 @@ int bpf_convert_ctx_accesses(struct bpf_verifier_env *env)
delta += cnt - 1;
env->prog = new_prog;
insn = new_prog->insnsi + i + delta;
+ nospec_next = false;
continue;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 325/742] bpf: Reject kernel threads in bpf_task_work_schedule()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (315 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 324/742] bpf: Emit nospec after calls and atomics that write to the stack Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 326/742] bpf, sockmap: Clear the redirect target after the stream parser runs Greg Kroah-Hartman
` (409 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sechang Lim, Alexei Starovoitov,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sechang Lim <rhkrqnwk98@gmail.com>
[ Upstream commit 3c625090b46b0d683112465a07d95bf5ff71174f ]
bpf_task_work_schedule_signal() on a kernel thread sets
TIF_NOTIFY_SIGNAL, but the thread never returns to user space, so
nothing clears it and signal_pending() stays true. Interruptible sleeps
in the thread return immediately.
For kthreadd this means spinning at 100% CPU. io_ring_exit_work() waits
on ctx->ref_comp interruptibly, assuming a kworker gets no signals. If a
prog running in that kworker schedules task work on current, the wait
returns -ERESTARTSYS and the ctx is freed while ctx->refs is still
switching to atomic:
WARNING: lib/percpu-refcount.c:114 at __percpu_ref_exit+0x77/0x110
Workqueue: iou_exit io_ring_exit_work
...
BUG: KASAN: slab-use-after-free in rcu_cblist_dequeue+0xd3/0x120
The callback can't run before the thread exits anyway. Reject kernel
threads with -EPERM, as bpf_send_signal() does.
Fixes: 38aa7003e369 ("bpf: task work scheduling kfuncs")
Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261126053016.1145482-1-rhkrqnwk98@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/bpf/helpers.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 991d03fede8c2..ed2e8db32728b 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -4653,6 +4653,9 @@ static int bpf_task_work_schedule(struct task_struct *task, struct bpf_task_work
BTF_TYPE_EMIT(struct bpf_task_work);
+ if (task->flags & PF_KTHREAD)
+ return -EPERM;
+
prog = bpf_prog_inc_not_zero(aux->prog);
if (IS_ERR(prog))
return -EBADF;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 326/742] bpf, sockmap: Clear the redirect target after the stream parser runs
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (316 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 325/742] bpf: Reject kernel threads in bpf_task_work_schedule() Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 327/742] iommu/vsi: keep the runtime PM callbacks without PM_SLEEP Greg Kroah-Hartman
` (408 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sechang Lim, Alexei Starovoitov,
Jiayuan Chen, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sechang Lim <rhkrqnwk98@gmail.com>
[ Upstream commit 14f6b10422d640695803c621687f790f6f3d2401 ]
A stream parser can call bpf_sk_redirect_{map,hash}(), which store the
target socket in skb->_sk_redir. sk_psock_strp_parse() never clears it,
and it shares storage with skb->_skb_refdst, so skb_dst_drop() later
passes the socket to dst_release():
KASAN: null-ptr-deref in range [0x0000000000000128-0x000000000000012f]
RIP: 0010:percpu_counter_add_batch+0x24/0x220
Call Trace:
dst_release.part.0+0xc9/0x180
skb_release_head_state+0x1cc/0x2f0
sk_skb_reason_drop+0xbc/0x420
strp_done+0xcf/0x150
sk_psock_destroy+0x85e/0xb10
Drop the dst before the parser runs, as the verdict paths do, and clear
the redirect after it. The parser's redirect was never used.
Fixes: e3526bb92a20 ("skmsg: Move sk_redir from TCP_SKB_CB to skb")
Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Link: https://patch.msgid.link/20261126101950.1682160-1-rhkrqnwk98@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/core/skmsg.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/core/skmsg.c b/net/core/skmsg.c
index c4bc16115c9e1..e2009a6be5819 100644
--- a/net/core/skmsg.c
+++ b/net/core/skmsg.c
@@ -1120,7 +1120,9 @@ static int sk_psock_strp_parse(struct strparser *strp, struct sk_buff *skb)
prog = READ_ONCE(psock->progs.stream_parser);
if (likely(prog)) {
skb->sk = psock->sk;
+ skb_dst_drop(skb);
ret = bpf_prog_run_pin_on_cpu(prog, skb);
+ skb_bpf_redirect_clear(skb);
skb->sk = NULL;
}
rcu_read_unlock();
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 327/742] iommu/vsi: keep the runtime PM callbacks without PM_SLEEP
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (317 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 326/742] bpf, sockmap: Clear the redirect target after the stream parser runs Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 328/742] iommu/vsi: Dont leak a runtime PM reference in the TLB flush Greg Kroah-Hartman
` (407 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Daniel Golle, Benjamin Gaignard,
Joerg Roedel, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Golle <daniel@makrotopia.org>
[ Upstream commit 0008c5d5030c4bddad186be9c5c3959f21012a66 ]
The runtime PM operations are handed to the driver core through
pm_sleep_ptr(), which is NULL unless CONFIG_PM_SLEEP is set.
Without system sleep support the IOMMU has no runtime PM callbacks at
all: its clocks are never enabled by the driver, the page table is not
restored when the power domain comes back, and iommu->enable stays set
while genpd powers the domain off.
The TLB flush issued from vsi_iommu_map() then writes to the unpowered
IOMMU, and the first buffer allocation of the RK3588 AV1 decoder ends
in an asynchronous SError.
Use pm_ptr(), which keeps the operations whenever CONFIG_PM is set.
Fixes: 917ace84b770 ("iommu: Add verisilicon IOMMU driver")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iommu/vsi-iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 5dac20b143a55..1b447c0693936 100644
--- a/drivers/iommu/vsi-iommu.c
+++ b/drivers/iommu/vsi-iommu.c
@@ -780,7 +780,7 @@ static struct platform_driver rockchip_vsi_iommu_driver = {
.driver = {
.name = "vsi_iommu",
.of_match_table = vsi_iommu_dt_ids,
- .pm = pm_sleep_ptr(&vsi_iommu_pm_ops),
+ .pm = pm_ptr(&vsi_iommu_pm_ops),
.suppress_bind_attrs = true,
},
};
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 328/742] iommu/vsi: Dont leak a runtime PM reference in the TLB flush
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (318 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 327/742] iommu/vsi: keep the runtime PM callbacks without PM_SLEEP Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 329/742] iommu/vsi: Dont resume the IOMMU in its interrupt handler Greg Kroah-Hartman
` (406 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Arun Iyengar, Benjamin Gaignard,
Joerg Roedel, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arun Iyengar <aiyengar1990@gmail.com>
[ Upstream commit 4ec193a567bf7f09a7a4b3eae4087ab1571f304e ]
pm_runtime_get() takes a usage reference even when it fails, e.g. with
-EINPROGRESS while a resume runs, and vsi_iommu_flush_tlb() then skips
the put. The IOMMU then never suspends again.
Flush only an active IOMMU and flush the TLB when the IOMMU is enabled,
which covers resume.
Fixes: 917ace84b770 ("iommu: Add verisilicon IOMMU driver")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iommu/vsi-iommu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 1b447c0693936..866d5c27cb3c8 100644
--- a/drivers/iommu/vsi-iommu.c
+++ b/drivers/iommu/vsi-iommu.c
@@ -369,7 +369,8 @@ static void vsi_iommu_flush_tlb(struct iommu_domain *domain)
struct vsi_iommu *iommu;
list_for_each_entry(iommu, &vsi_domain->iommus, node) {
- if (pm_runtime_get(iommu->dev) < 0)
+ /* A suspended IOMMU is flushed when it resumes */
+ if (pm_runtime_get_if_active(iommu->dev) <= 0)
continue;
spin_lock(&iommu->lock);
@@ -545,6 +546,8 @@ static void vsi_iommu_enable(struct vsi_iommu *iommu, struct iommu_domain *domai
writel(VSI_MMU_OUT_OF_BOUND, iommu->regs + VSI_MMU_CONFIG1_BASE);
writel(VSI_MMU_BIT_ENABLE, iommu->regs + VSI_MMU_AHB_EXCEPTION_BASE);
writel(VSI_MMU_BIT_ENABLE, iommu->regs + VSI_MMU_AHB_CONTROL_BASE);
+ writel(VSI_MMU_BIT_FLUSH, iommu->regs + VSI_MMU_FLUSH_BASE);
+ writel(0, iommu->regs + VSI_MMU_FLUSH_BASE);
iommu->enable = true;
}
@@ -564,8 +567,6 @@ static int vsi_iommu_attach_device(struct iommu_domain *domain,
spin_lock(&iommu->lock);
vsi_iommu_enable(iommu, domain);
- writel(VSI_MMU_BIT_FLUSH, iommu->regs + VSI_MMU_FLUSH_BASE);
- writel(0, iommu->regs + VSI_MMU_FLUSH_BASE);
list_del_init(&iommu->node);
list_add_tail(&iommu->node, &vsi_domain->iommus);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 329/742] iommu/vsi: Dont resume the IOMMU in its interrupt handler
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (319 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 328/742] iommu/vsi: Dont leak a runtime PM reference in the TLB flush Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 330/742] iommu/vsi: Unprepare the clocks when getting the IRQ fails Greg Kroah-Hartman
` (405 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Arun Iyengar, Benjamin Gaignard,
Joerg Roedel, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arun Iyengar <aiyengar1990@gmail.com>
[ Upstream commit 923278dea97476c58ace9f5b7d8429a185ce439a ]
The interrupt handler calls pm_runtime_resume_and_get(), which can
sleep, in hard IRQ context. Handle the interrupt only if the IOMMU is
active.
Fixes: 917ace84b770 ("iommu: Add verisilicon IOMMU driver")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iommu/vsi-iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 866d5c27cb3c8..60b1450a5f587 100644
--- a/drivers/iommu/vsi-iommu.c
+++ b/drivers/iommu/vsi-iommu.c
@@ -196,7 +196,7 @@ static irqreturn_t vsi_iommu_irq(int irq, void *dev_id)
dma_addr_t iova;
u32 status;
- if (pm_runtime_resume_and_get(iommu->dev) < 0)
+ if (pm_runtime_get_if_active(iommu->dev) <= 0)
return IRQ_NONE;
spin_lock_irqsave(&iommu->lock, flags);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 330/742] iommu/vsi: Unprepare the clocks when getting the IRQ fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (320 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 329/742] iommu/vsi: Dont resume the IOMMU in its interrupt handler Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 331/742] selftests: ublk: move the control command helpers into ctrl.c Greg Kroah-Hartman
` (404 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Arun Iyengar, Benjamin Gaignard,
Joerg Roedel, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arun Iyengar <aiyengar1990@gmail.com>
[ Upstream commit 807bf13083be85673963f57cb9375626e0b06f13 ]
vsi_iommu_probe() returns without clk_bulk_unprepare() when
platform_get_irq() fails.
Fixes: 917ace84b770 ("iommu: Add verisilicon IOMMU driver")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/iommu/vsi-iommu.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/vsi-iommu.c b/drivers/iommu/vsi-iommu.c
index 60b1450a5f587..483a3ec7b5d33 100644
--- a/drivers/iommu/vsi-iommu.c
+++ b/drivers/iommu/vsi-iommu.c
@@ -694,8 +694,10 @@ static int vsi_iommu_probe(struct platform_device *pdev)
return err;
iommu->irq = platform_get_irq(pdev, 0);
- if (iommu->irq < 0)
- return iommu->irq;
+ if (iommu->irq < 0) {
+ err = iommu->irq;
+ goto err_unprepare_clocks;
+ }
err = devm_request_irq(iommu->dev, iommu->irq, vsi_iommu_irq,
IRQF_SHARED, dev_name(dev), iommu);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 331/742] selftests: ublk: move the control command helpers into ctrl.c
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (321 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 330/742] iommu/vsi: Unprepare the clocks when getting the IRQ fails Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 332/742] selftests: ublk: add test for going live over canceled io commands Greg Kroah-Hartman
` (403 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ming Lei, Josef Bacik, Jens Axboe,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <tom.leiming@gmail.com>
[ Upstream commit cdf6e5de86a91da6e4d621260bc70e99e2f3a25e ]
Move the ublk_ctrl_*() helpers and ublk_setup_ring() out of kublk.c,
so a small test program can send control commands without copying
them. kublk still links every *.c file, ctrl.c included.
ublk_ctrl_deinit() now also exits the control ring, and ublk_ctrl_init()
checks the allocation and closes /dev/ublk-control when the ring setup
fails. kublk calls them only around its own lifetime, but a test which
opens a control handle per thread must not leak.
No functional change for kublk.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Tested-by: Josef Bacik <josef@toxicpanda.com>
Link: https://patch.msgid.link/20261011063555.1142277-10-tom.leiming@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: d9667b1a6a33 ("selftests/ublk: use the configured kernel UAPI headers")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/testing/selftests/ublk/ctrl.c | 268 ++++++++++++++++++++++++++
tools/testing/selftests/ublk/kublk.c | 271 ---------------------------
tools/testing/selftests/ublk/kublk.h | 32 ++++
3 files changed, 300 insertions(+), 271 deletions(-)
create mode 100644 tools/testing/selftests/ublk/ctrl.c
diff --git a/tools/testing/selftests/ublk/ctrl.c b/tools/testing/selftests/ublk/ctrl.c
new file mode 100644
index 0000000000000..53d54799f9097
--- /dev/null
+++ b/tools/testing/selftests/ublk/ctrl.c
@@ -0,0 +1,268 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/* ublk control commands, shared by kublk and ublk_cancel_ready */
+
+#include "kublk.h"
+
+static void ublk_ctrl_init_cmd(struct ublk_dev *dev,
+ struct io_uring_sqe *sqe,
+ struct ublk_ctrl_cmd_data *data)
+{
+ struct ublksrv_ctrl_dev_info *info = &dev->dev_info;
+ struct ublksrv_ctrl_cmd *cmd = (struct ublksrv_ctrl_cmd *)ublk_get_sqe_cmd(sqe);
+
+ sqe->fd = dev->ctrl_fd;
+ sqe->opcode = IORING_OP_URING_CMD;
+ sqe->ioprio = 0;
+
+ if (data->flags & CTRL_CMD_HAS_BUF) {
+ cmd->addr = data->addr;
+ cmd->len = data->len;
+ }
+
+ if (data->flags & CTRL_CMD_HAS_DATA)
+ cmd->data[0] = data->data[0];
+
+ cmd->dev_id = info->dev_id;
+ cmd->queue_id = -1;
+
+ ublk_set_sqe_cmd_op(sqe, data->cmd_op);
+
+ io_uring_sqe_set_data(sqe, cmd);
+}
+
+int __ublk_ctrl_cmd(struct ublk_dev *dev,
+ struct ublk_ctrl_cmd_data *data)
+{
+ struct io_uring_sqe *sqe;
+ struct io_uring_cqe *cqe;
+ int ret = -EINVAL;
+
+ sqe = io_uring_get_sqe(&dev->ring);
+ if (!sqe) {
+ ublk_err("%s: can't get sqe ret %d\n", __func__, ret);
+ return ret;
+ }
+
+ ublk_ctrl_init_cmd(dev, sqe, data);
+
+ ret = io_uring_submit(&dev->ring);
+ if (ret < 0) {
+ ublk_err("uring submit ret %d\n", ret);
+ return ret;
+ }
+
+ ret = io_uring_wait_cqe(&dev->ring, &cqe);
+ if (ret < 0) {
+ ublk_err("wait cqe: %s\n", strerror(-ret));
+ return ret;
+ }
+ io_uring_cqe_seen(&dev->ring, cqe);
+
+ return cqe->res;
+}
+
+void ublk_ctrl_deinit(struct ublk_dev *dev)
+{
+ io_uring_queue_exit(&dev->ring);
+ close(dev->ctrl_fd);
+ free(dev);
+}
+
+struct ublk_dev *ublk_ctrl_init(void)
+{
+ struct ublk_dev *dev = (struct ublk_dev *)calloc(1, sizeof(*dev));
+ struct ublksrv_ctrl_dev_info *info;
+ int ret;
+
+ if (!dev)
+ return NULL;
+ info = &dev->dev_info;
+ dev->ctrl_fd = open(CTRL_DEV, O_RDWR);
+ if (dev->ctrl_fd < 0) {
+ free(dev);
+ return NULL;
+ }
+
+ info->max_io_buf_bytes = UBLK_IO_MAX_BYTES;
+
+ ret = ublk_setup_ring(&dev->ring, UBLK_CTRL_RING_DEPTH,
+ UBLK_CTRL_RING_DEPTH, IORING_SETUP_SQE128);
+ if (ret < 0) {
+ ublk_err("queue_init: %s\n", strerror(-ret));
+ close(dev->ctrl_fd);
+ free(dev);
+ return NULL;
+ }
+ dev->nr_fds = 1;
+
+ return dev;
+}
+
+int ublk_ctrl_stop_dev(struct ublk_dev *dev)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_STOP_DEV,
+ };
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_try_stop_dev(struct ublk_dev *dev)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_TRY_STOP_DEV,
+ };
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_start_dev(struct ublk_dev *dev,
+ int daemon_pid)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_START_DEV,
+ .flags = CTRL_CMD_HAS_DATA,
+ };
+
+ dev->dev_info.ublksrv_pid = data.data[0] = daemon_pid;
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_start_user_recovery(struct ublk_dev *dev)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_START_USER_RECOVERY,
+ };
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_end_user_recovery(struct ublk_dev *dev, int daemon_pid)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_END_USER_RECOVERY,
+ .flags = CTRL_CMD_HAS_DATA,
+ };
+
+ dev->dev_info.ublksrv_pid = data.data[0] = daemon_pid;
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_add_dev(struct ublk_dev *dev)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_ADD_DEV,
+ .flags = CTRL_CMD_HAS_BUF,
+ .addr = (__u64) (uintptr_t) &dev->dev_info,
+ .len = sizeof(struct ublksrv_ctrl_dev_info),
+ };
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_del_dev(struct ublk_dev *dev)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_DEL_DEV,
+ .flags = 0,
+ };
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_get_info(struct ublk_dev *dev)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_GET_DEV_INFO,
+ .flags = CTRL_CMD_HAS_BUF,
+ .addr = (__u64) (uintptr_t) &dev->dev_info,
+ .len = sizeof(struct ublksrv_ctrl_dev_info),
+ };
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_set_params(struct ublk_dev *dev,
+ struct ublk_params *params)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_SET_PARAMS,
+ .flags = CTRL_CMD_HAS_BUF,
+ .addr = (__u64) (uintptr_t) params,
+ .len = sizeof(*params),
+ };
+ params->len = sizeof(*params);
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_get_params(struct ublk_dev *dev,
+ struct ublk_params *params)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_GET_PARAMS,
+ .flags = CTRL_CMD_HAS_BUF,
+ .addr = (__u64)params,
+ .len = sizeof(*params),
+ };
+
+ params->len = sizeof(*params);
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_get_features(struct ublk_dev *dev,
+ __u64 *features)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_GET_FEATURES,
+ .flags = CTRL_CMD_HAS_BUF,
+ .addr = (__u64) (uintptr_t) features,
+ .len = sizeof(*features),
+ };
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_update_size(struct ublk_dev *dev,
+ __u64 nr_sects)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_UPDATE_SIZE,
+ .flags = CTRL_CMD_HAS_DATA,
+ };
+
+ data.data[0] = nr_sects;
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_quiesce_dev(struct ublk_dev *dev, unsigned int timeout_ms)
+{
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_QUIESCE_DEV,
+ .flags = CTRL_CMD_HAS_DATA,
+ };
+
+ data.data[0] = timeout_ms;
+ return __ublk_ctrl_cmd(dev, &data);
+}
+
+int ublk_ctrl_reg_buf(struct ublk_dev *dev, void *addr, size_t size,
+ __u32 flags)
+{
+ struct ublk_shmem_buf_reg buf_reg = {
+ .addr = (unsigned long)addr,
+ .len = size,
+ .flags = flags,
+ };
+ struct ublk_ctrl_cmd_data data = {
+ .cmd_op = UBLK_U_CMD_REG_BUF,
+ .flags = CTRL_CMD_HAS_BUF,
+ .addr = (unsigned long)&buf_reg,
+ .len = sizeof(buf_reg),
+ };
+
+ return __ublk_ctrl_cmd(dev, &data);
+}
diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c
index 5b19bfcfa8d74..5a4ff689c1f7a 100644
--- a/tools/testing/selftests/ublk/kublk.c
+++ b/tools/testing/selftests/ublk/kublk.c
@@ -37,203 +37,6 @@ static const struct ublk_tgt_ops *ublk_find_tgt(const char *name)
return NULL;
}
-static inline int ublk_setup_ring(struct io_uring *r, int depth,
- int cq_depth, unsigned flags)
-{
- struct io_uring_params p;
-
- memset(&p, 0, sizeof(p));
- p.flags = flags | IORING_SETUP_CQSIZE;
- p.cq_entries = cq_depth;
-
- return io_uring_queue_init_params(depth, r, &p);
-}
-
-static void ublk_ctrl_init_cmd(struct ublk_dev *dev,
- struct io_uring_sqe *sqe,
- struct ublk_ctrl_cmd_data *data)
-{
- struct ublksrv_ctrl_dev_info *info = &dev->dev_info;
- struct ublksrv_ctrl_cmd *cmd = (struct ublksrv_ctrl_cmd *)ublk_get_sqe_cmd(sqe);
-
- sqe->fd = dev->ctrl_fd;
- sqe->opcode = IORING_OP_URING_CMD;
- sqe->ioprio = 0;
-
- if (data->flags & CTRL_CMD_HAS_BUF) {
- cmd->addr = data->addr;
- cmd->len = data->len;
- }
-
- if (data->flags & CTRL_CMD_HAS_DATA)
- cmd->data[0] = data->data[0];
-
- cmd->dev_id = info->dev_id;
- cmd->queue_id = -1;
-
- ublk_set_sqe_cmd_op(sqe, data->cmd_op);
-
- io_uring_sqe_set_data(sqe, cmd);
-}
-
-static int __ublk_ctrl_cmd(struct ublk_dev *dev,
- struct ublk_ctrl_cmd_data *data)
-{
- struct io_uring_sqe *sqe;
- struct io_uring_cqe *cqe;
- int ret = -EINVAL;
-
- sqe = io_uring_get_sqe(&dev->ring);
- if (!sqe) {
- ublk_err("%s: can't get sqe ret %d\n", __func__, ret);
- return ret;
- }
-
- ublk_ctrl_init_cmd(dev, sqe, data);
-
- ret = io_uring_submit(&dev->ring);
- if (ret < 0) {
- ublk_err("uring submit ret %d\n", ret);
- return ret;
- }
-
- ret = io_uring_wait_cqe(&dev->ring, &cqe);
- if (ret < 0) {
- ublk_err("wait cqe: %s\n", strerror(-ret));
- return ret;
- }
- io_uring_cqe_seen(&dev->ring, cqe);
-
- return cqe->res;
-}
-
-static int ublk_ctrl_stop_dev(struct ublk_dev *dev)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_STOP_DEV,
- };
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_try_stop_dev(struct ublk_dev *dev)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_TRY_STOP_DEV,
- };
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_start_dev(struct ublk_dev *dev,
- int daemon_pid)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_START_DEV,
- .flags = CTRL_CMD_HAS_DATA,
- };
-
- dev->dev_info.ublksrv_pid = data.data[0] = daemon_pid;
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_start_user_recovery(struct ublk_dev *dev)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_START_USER_RECOVERY,
- };
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_end_user_recovery(struct ublk_dev *dev, int daemon_pid)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_END_USER_RECOVERY,
- .flags = CTRL_CMD_HAS_DATA,
- };
-
- dev->dev_info.ublksrv_pid = data.data[0] = daemon_pid;
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_add_dev(struct ublk_dev *dev)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_ADD_DEV,
- .flags = CTRL_CMD_HAS_BUF,
- .addr = (__u64) (uintptr_t) &dev->dev_info,
- .len = sizeof(struct ublksrv_ctrl_dev_info),
- };
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_del_dev(struct ublk_dev *dev)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_DEL_DEV,
- .flags = 0,
- };
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_get_info(struct ublk_dev *dev)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_GET_DEV_INFO,
- .flags = CTRL_CMD_HAS_BUF,
- .addr = (__u64) (uintptr_t) &dev->dev_info,
- .len = sizeof(struct ublksrv_ctrl_dev_info),
- };
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_set_params(struct ublk_dev *dev,
- struct ublk_params *params)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_SET_PARAMS,
- .flags = CTRL_CMD_HAS_BUF,
- .addr = (__u64) (uintptr_t) params,
- .len = sizeof(*params),
- };
- params->len = sizeof(*params);
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_get_params(struct ublk_dev *dev,
- struct ublk_params *params)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_GET_PARAMS,
- .flags = CTRL_CMD_HAS_BUF,
- .addr = (__u64)params,
- .len = sizeof(*params),
- };
-
- params->len = sizeof(*params);
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_get_features(struct ublk_dev *dev,
- __u64 *features)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_GET_FEATURES,
- .flags = CTRL_CMD_HAS_BUF,
- .addr = (__u64) (uintptr_t) features,
- .len = sizeof(*features),
- };
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
static int parse_param_types(const char *arg, __u32 *types)
{
char buf[128], *save = NULL, *tok;
@@ -283,30 +86,6 @@ static void ublk_init_params_from_ctx(const struct dev_ctx *ctx,
};
}
-static int ublk_ctrl_update_size(struct ublk_dev *dev,
- __u64 nr_sects)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_UPDATE_SIZE,
- .flags = CTRL_CMD_HAS_DATA,
- };
-
- data.data[0] = nr_sects;
- return __ublk_ctrl_cmd(dev, &data);
-}
-
-static int ublk_ctrl_quiesce_dev(struct ublk_dev *dev,
- unsigned int timeout_ms)
-{
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_QUIESCE_DEV,
- .flags = CTRL_CMD_HAS_DATA,
- };
-
- data.data[0] = timeout_ms;
- return __ublk_ctrl_cmd(dev, &data);
-}
-
static const char *ublk_dev_state_desc(struct ublk_dev *dev)
{
switch (dev->dev_info.state) {
@@ -426,38 +205,6 @@ static void ublk_ctrl_dump(struct ublk_dev *dev)
fflush(stdout);
}
-static void ublk_ctrl_deinit(struct ublk_dev *dev)
-{
- close(dev->ctrl_fd);
- free(dev);
-}
-
-static struct ublk_dev *ublk_ctrl_init(void)
-{
- struct ublk_dev *dev = (struct ublk_dev *)calloc(1, sizeof(*dev));
- struct ublksrv_ctrl_dev_info *info = &dev->dev_info;
- int ret;
-
- dev->ctrl_fd = open(CTRL_DEV, O_RDWR);
- if (dev->ctrl_fd < 0) {
- free(dev);
- return NULL;
- }
-
- info->max_io_buf_bytes = UBLK_IO_MAX_BYTES;
-
- ret = ublk_setup_ring(&dev->ring, UBLK_CTRL_RING_DEPTH,
- UBLK_CTRL_RING_DEPTH, IORING_SETUP_SQE128);
- if (ret < 0) {
- ublk_err("queue_init: %s\n", strerror(-ret));
- free(dev);
- return NULL;
- }
- dev->nr_fds = 1;
-
- return dev;
-}
-
static size_t __ublk_queue_cmd_buf_sz(const struct ublk_queue *q, __u16 depth)
{
size_t size = depth * (size_t)q->io_desc_size;
@@ -1283,24 +1030,6 @@ static void ublk_shmem_unregister_all(void)
shmem_count = 0;
}
-static int ublk_ctrl_reg_buf(struct ublk_dev *dev, void *addr, size_t size,
- __u32 flags)
-{
- struct ublk_shmem_buf_reg buf_reg = {
- .addr = (unsigned long)addr,
- .len = size,
- .flags = flags,
- };
- struct ublk_ctrl_cmd_data data = {
- .cmd_op = UBLK_U_CMD_REG_BUF,
- .flags = CTRL_CMD_HAS_BUF,
- .addr = (unsigned long)&buf_reg,
- .len = sizeof(buf_reg),
- };
-
- return __ublk_ctrl_cmd(dev, &data);
-}
-
/*
* Handle one client connection: receive memfd, mmap it, register
* the VA range with kernel, send back the assigned index.
diff --git a/tools/testing/selftests/ublk/kublk.h b/tools/testing/selftests/ublk/kublk.h
index d98f3d612d888..99b8ceff853cb 100644
--- a/tools/testing/selftests/ublk/kublk.h
+++ b/tools/testing/selftests/ublk/kublk.h
@@ -294,6 +294,38 @@ struct ublk_dev {
extern int ublk_queue_io_cmd(struct ublk_thread *t, struct ublk_io *io);
+static inline int ublk_setup_ring(struct io_uring *r, int depth,
+ int cq_depth, unsigned int flags)
+{
+ struct io_uring_params p;
+
+ memset(&p, 0, sizeof(p));
+ p.flags = flags | IORING_SETUP_CQSIZE;
+ p.cq_entries = cq_depth;
+
+ return io_uring_queue_init_params(depth, r, &p);
+}
+
+/* ctrl.c: control commands */
+struct ublk_dev *ublk_ctrl_init(void);
+void ublk_ctrl_deinit(struct ublk_dev *dev);
+int __ublk_ctrl_cmd(struct ublk_dev *dev, struct ublk_ctrl_cmd_data *data);
+int ublk_ctrl_add_dev(struct ublk_dev *dev);
+int ublk_ctrl_del_dev(struct ublk_dev *dev);
+int ublk_ctrl_get_info(struct ublk_dev *dev);
+int ublk_ctrl_set_params(struct ublk_dev *dev, struct ublk_params *params);
+int ublk_ctrl_get_params(struct ublk_dev *dev, struct ublk_params *params);
+int ublk_ctrl_get_features(struct ublk_dev *dev, __u64 *features);
+int ublk_ctrl_start_dev(struct ublk_dev *dev, int daemon_pid);
+int ublk_ctrl_stop_dev(struct ublk_dev *dev);
+int ublk_ctrl_try_stop_dev(struct ublk_dev *dev);
+int ublk_ctrl_start_user_recovery(struct ublk_dev *dev);
+int ublk_ctrl_end_user_recovery(struct ublk_dev *dev, int daemon_pid);
+int ublk_ctrl_update_size(struct ublk_dev *dev, __u64 nr_sects);
+int ublk_ctrl_quiesce_dev(struct ublk_dev *dev, unsigned int timeout_ms);
+int ublk_ctrl_reg_buf(struct ublk_dev *dev, void *addr, size_t size,
+ __u32 flags);
+
static inline int __ublk_use_batch_io(__u64 flags)
{
return flags & UBLK_F_BATCH_IO;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 332/742] selftests: ublk: add test for going live over canceled io commands
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (322 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 331/742] selftests: ublk: move the control command helpers into ctrl.c Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 333/742] selftests: ublk: fix the build and file offsets on 32-bit Greg Kroah-Hartman
` (402 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ming Lei, Jens Axboe, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <tom.leiming@gmail.com>
[ Upstream commit bcab0b98566b8f73f8e398d4f12a088b81885459 ]
Add ublk_cancel_ready, a small liburing program which sends control
commands with kublk's helpers from ctrl.c, and test_generic_18.sh,
which runs its modes:
mode what it does expected
stop_start STOP_DEV before START_DEV START_DEV -EBUSY
partial_fetch task A fetches tags 0-2 and START_DEV -EBUSY
dies, then task B fetches tag 3
recovery in user recovery, queue 0's END_USER_RECOVERY
task dies before queue 1 is -EBUSY
ready
stop_restart STOP_DEV on a new device, then START_DEV 0,
a server starts it reads succeed
stop_attached STOP_DEV after open, before FETCH ABORT and
FETCH, then a new server START_DEV -EBUSY,
then a new one works
stop_live_restart STOP_DEV on a live device, then FETCH and START_DEV
a new server starts it 0, reads succeed
race_start STOP_DEV and START_DEV at the START_DEV 0 and
same time, 50 times reads complete,
or -EBUSY
race_fetch STOP_DEV while a server opens START_DEV 0 and
and fetches, then START_DEV, reads succeed,
50 times or -EBUSY
race_async_fetch IOSQE_ASYNC FETCH while STOP_DEV no crash (KASAN
cancels, then close the ring finds the bug)
race_batch_stop STOP_DEV while kublk's batch kublk add returns,
server prepares and fetches, started or not
20 times
If the device goes live, the test reads it, so an unfixed kernel shows
the oops in ublk_queue_cmd(). In stop_live_restart, an unfixed kernel
doesn't reset the FETCH round in ublk_ch_release() once the disk is
gone, so the new server's FETCH gets -EBUSY.
A dying task is a child process which fetches and then calls exec().
exec() cancels the task's uring_cmds before it returns, so the cancel
is done once the child is reaped, with no sleep. kublk can't be used:
its failure injection kills the whole process, which closes
/dev/ublkcN and starts a new round.
Link: https://lore.kernel.org/linux-block/20260928-b4-ublk-cancel-stop-v1-0-4a4360232a46@toxicpanda.com/
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Assisted-by: LLM
Link: https://patch.msgid.link/20261011063555.1142277-12-tom.leiming@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: d9667b1a6a33 ("selftests/ublk: use the configured kernel UAPI headers")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/testing/selftests/ublk/.gitignore | 1 +
tools/testing/selftests/ublk/Makefile | 6 +-
.../testing/selftests/ublk/test_generic_18.sh | 69 ++
.../selftests/ublk/ublk_cancel_ready.c | 957 ++++++++++++++++++
4 files changed, 1031 insertions(+), 2 deletions(-)
create mode 100755 tools/testing/selftests/ublk/test_generic_18.sh
create mode 100644 tools/testing/selftests/ublk/ublk_cancel_ready.c
diff --git a/tools/testing/selftests/ublk/.gitignore b/tools/testing/selftests/ublk/.gitignore
index e17bd28f27e04..d8e93fef7fcd3 100644
--- a/tools/testing/selftests/ublk/.gitignore
+++ b/tools/testing/selftests/ublk/.gitignore
@@ -3,3 +3,4 @@
/tools
kublk
metadata_size
+ublk_cancel_ready
diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile
index 37883e9d50ec3..fc64b8f028332 100644
--- a/tools/testing/selftests/ublk/Makefile
+++ b/tools/testing/selftests/ublk/Makefile
@@ -19,6 +19,7 @@ TEST_PROGS += test_generic_12.sh
TEST_PROGS += test_generic_13.sh
TEST_PROGS += test_generic_16.sh
TEST_PROGS += test_generic_17.sh
+TEST_PROGS += test_generic_18.sh
TEST_PROGS += test_batch_01.sh
TEST_PROGS += test_batch_02.sh
@@ -76,13 +77,14 @@ TEST_FILES := settings
TEST_FILES += test_common.sh
TEST_FILES += trace
-TEST_GEN_PROGS_EXTENDED = kublk metadata_size
-STANDALONE_UTILS := metadata_size.c
+TEST_GEN_PROGS_EXTENDED = kublk metadata_size ublk_cancel_ready
+STANDALONE_UTILS := metadata_size.c ublk_cancel_ready.c
LOCAL_HDRS += $(wildcard *.h)
include ../lib.mk
$(OUTPUT)/kublk: $(filter-out $(STANDALONE_UTILS),$(wildcard *.c))
+$(OUTPUT)/ublk_cancel_ready: ublk_cancel_ready.c ctrl.c
check:
shellcheck -x -f gcc *.sh
diff --git a/tools/testing/selftests/ublk/test_generic_18.sh b/tools/testing/selftests/ublk/test_generic_18.sh
new file mode 100755
index 0000000000000..2dbb59e238a41
--- /dev/null
+++ b/tools/testing/selftests/ublk/test_generic_18.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
+
+ERR_CODE=0
+CANCEL_PROG="$(_ublk_test_top_dir)/ublk_cancel_ready"
+
+_prep_test "generic" "start device over canceled io commands"
+
+# STOP_DEV while kublk's UBLK_F_BATCH_IO server prepares and fetches: the
+# server has to fail cleanly when PREP or FETCH is aborted, so `kublk add`
+# must return either way.
+race_batch_stop()
+{
+ local id=9999 i res started=0
+
+ _have_feature "BATCH_IO" || return "$UBLK_SKIP_CODE"
+ for i in $(seq 1 20); do
+ timeout 20 "$UBLK_PROG" add -t null -q 2 -b -n "$id" > /dev/null 2>&1 &
+ local pid=$!
+ # vary where STOP_DEV lands relative to the batch PREP and FETCH
+ sleep "0.$((i % 10))"
+ "$UBLK_PROG" stop -n "$id" > /dev/null 2>&1
+ wait "$pid"
+ res=$?
+ "$UBLK_PROG" del -n "$id" > /dev/null 2>&1
+ if [ "$res" -eq 124 ]; then
+ echo "run $i: kublk add -b hung after STOP_DEV"
+ return 255
+ fi
+ [ "$res" -eq 0 ] && started=$((started + 1))
+ done
+ echo "20 runs: started $started, stopped before start $((20 - started))"
+}
+
+# race_batch_stop is above, the other modes are described in
+# ublk_cancel_ready.c
+for mode in stop_start partial_fetch recovery stop_restart stop_attached \
+ stop_live_restart race_start race_fetch race_async_fetch \
+ race_batch_stop; do
+ dmesg_before=$(dmesg | wc -l)
+ if [ "$mode" = race_batch_stop ]; then
+ race_batch_stop > "$UBLK_TMP" 2>&1
+ else
+ timeout 60 "$CANCEL_PROG" "$mode" > "$UBLK_TMP" 2>&1
+ fi
+ res=$?
+ msg=""
+
+ if dmesg | tail -n +"$((dmesg_before + 1))" | \
+ grep -q -e "BUG:" -e "Oops" -e "WARNING:"; then
+ msg="$mode: kernel oops/warning"
+ ERR_CODE=255
+ elif [ "$res" -eq "$UBLK_SKIP_CODE" ]; then
+ [ "$ERR_CODE" -eq 0 ] && ERR_CODE=$UBLK_SKIP_CODE
+ elif [ "$res" -ne 0 ]; then
+ msg="$mode: failed ($res)"
+ ERR_CODE=255
+ fi
+ # the output once: on failure, or always when not quiet
+ [ -n "$msg" ] && echo "$msg"
+ if [ -n "$msg" ] || [ "$UBLK_TEST_QUIET" -eq 0 ]; then
+ cat "$UBLK_TMP"
+ fi
+done
+
+_cleanup_test
+_show_result $TID $ERR_CODE
diff --git a/tools/testing/selftests/ublk/ublk_cancel_ready.c b/tools/testing/selftests/ublk/ublk_cancel_ready.c
new file mode 100644
index 0000000000000..23071babc0e4c
--- /dev/null
+++ b/tools/testing/selftests/ublk/ublk_cancel_ready.c
@@ -0,0 +1,957 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Bring a ublk device live while some of its fetched io commands are
+ * canceled.
+ *
+ * A cancel completes a fetched command and clears io->cmd, but the io
+ * still counts as ready. Only ubq->canceling keeps ublk_queue_rq() away
+ * from the NULL io->cmd. Each mode below loses ->canceling in another way:
+ *
+ * stop_start: fetch every tag, STOP_DEV before START_DEV, START_DEV.
+ * STOP_DEV cancels the commands of the attached server,
+ * so START_DEV must get -EBUSY until that server is gone.
+ * An unfixed kernel starts the device over them.
+ *
+ * partial_fetch: task A fetches tags 0..depth-2 and dies, so its
+ * commands are canceled. Task B fetches the last tag, and
+ * an unfixed kernel clears ->canceling when the queue gets
+ * ready. /dev/ublkcN stays open all the time, so
+ * ublk_ch_release() never resets the queue.
+ *
+ * recovery: a UBLK_F_USER_RECOVERY device with two queues loses its
+ * server. During recovery task Q0 fetches queue 0, which
+ * clears q0->canceling, then dies. An unfixed kernel still
+ * has ub->canceling set because queue 1 is not ready, so
+ * ublk_start_cancel() does not mark queue 0 again. Reads
+ * are issued on a CPU mapped to queue 0.
+ *
+ * In partial_fetch and recovery, START_DEV / END_USER_RECOVERY must refuse
+ * with -EBUSY. An unfixed kernel oopses in ublk_queue_cmd() on a NULL
+ * io->cmd.
+ *
+ * stop_restart: control mode. STOP_DEV on a new device, before any
+ * server opened it, takes no command. A server started
+ * afterwards has to start the device and serve I/O.
+ *
+ * stop_attached: STOP_DEV on a device whose server opened it but fetched
+ * nothing stops that server too: FETCH gets ABORT and
+ * START_DEV -EBUSY, until a new server opens the device.
+ *
+ * stop_live_restart: STOP_DEV on a live device; once its server is gone,
+ * a new server has to fetch and start it again. An unfixed
+ * ublk_ch_release() skips the reset once the disk is gone,
+ * so the new FETCH gets -EBUSY.
+ *
+ * race_start: STOP_DEV and START_DEV at the same time on a device whose
+ * server fetched every tag. START_DEV either wins, and
+ * reads complete (they fail once STOP_DEV removes the
+ * disk), or gets -EBUSY. An unfixed kernel cancels the
+ * commands of the live disk.
+ *
+ * race_fetch: STOP_DEV while a server opens the device and fetches,
+ * then START_DEV. If STOP_DEV came before the open, it must
+ * not take any command, so START_DEV works and every read
+ * succeeds; otherwise START_DEV gets -EBUSY. An unfixed
+ * kernel takes commands fetched after its unlock and goes
+ * live over them.
+ *
+ * race_async_fetch: FETCH with IOSQE_ASYNC while STOP_DEV cancels,
+ * then close the ring. An unfixed FETCH marks its command
+ * cancelable only after publishing it and dropping
+ * ub->mutex; a cancel in between completes a command which
+ * is then put on io_uring's cancelable list. Closing the
+ * ring walks that list: KASAN reports a use after free.
+ * Needs a KASAN kernel to see the bug; otherwise it must
+ * just not crash.
+ *
+ * A dying task is a child process which fetches and then calls exec().
+ * exec() cancels the task's uring_cmds before it returns, so the cancel
+ * is done once the child is reaped. A thread exit does not cancel them,
+ * and closing the ring cancels them later, from io_ring_exit_work().
+ */
+#include <sched.h>
+
+#include "kublk.h"
+#include "../kselftest.h"
+
+#define NR_QUEUES 2
+#define DEPTH 4
+#define BUF_SIZE (64 << 10)
+#define DEV_SECTORS (64 << 11) /* 64MB */
+#define NR_READS (DEPTH * 2)
+#define SERVE_DELAY_US 200000
+#define RACE_LOOPS 50
+#define ASYNC_LOOPS 300
+
+/* one control handle per thread, the race modes send commands from two */
+static __thread struct ublk_dev *ctrl_dev;
+static int cdev_fd = -1;
+static int dev_id = -1;
+static int nr_queues;
+static void *bufs[NR_QUEUES][DEPTH];
+static const struct ublksrv_io_desc *iods[NR_QUEUES];
+static size_t iods_len;
+
+static struct io_uring_sqe *get_sqe(struct io_uring *ring)
+{
+ struct io_uring_sqe *sqe = io_uring_get_sqe(ring);
+
+ if (!sqe) {
+ fprintf(stderr, "out of sqes\n");
+ exit(KSFT_FAIL);
+ }
+ return sqe;
+}
+
+static struct ublk_dev *ctrl(void)
+{
+ if (!ctrl_dev) {
+ ctrl_dev = ublk_ctrl_init();
+ if (!ctrl_dev) {
+ fprintf(stderr, "ublk_ctrl_init failed\n");
+ exit(KSFT_FAIL);
+ }
+ }
+ ctrl_dev->dev_info.dev_id = dev_id;
+ return ctrl_dev;
+}
+
+static void ctrl_put(void)
+{
+ if (ctrl_dev)
+ ublk_ctrl_deinit(ctrl_dev);
+ ctrl_dev = NULL;
+}
+
+static int dev_state(void)
+{
+ struct ublk_dev *dev = ctrl();
+ int ret = ublk_ctrl_get_info(dev);
+
+ return ret ? ret : dev->dev_info.state;
+}
+
+static int open_cdev(void)
+{
+ size_t max_len = UBLK_MAX_QUEUE_DEPTH * sizeof(struct ublksrv_io_desc);
+ int pg = getpagesize();
+ char path[64];
+
+ snprintf(path, sizeof(path), "/dev/ublkc%d", dev_id);
+ for (int i = 0; i < 100 && cdev_fd < 0; i++) {
+ cdev_fd = open(path, O_RDWR);
+ if (cdev_fd < 0)
+ usleep(50000);
+ }
+ if (cdev_fd < 0)
+ return -errno;
+
+ /* queue q's descriptors start at q * the size for the max depth */
+ max_len = (max_len + pg - 1) & ~(size_t)(pg - 1);
+ iods_len = (DEPTH * sizeof(struct ublksrv_io_desc) + pg - 1) &
+ ~(size_t)(pg - 1);
+ for (int q = 0; q < nr_queues; q++) {
+ void *p = mmap(NULL, iods_len, PROT_READ,
+ MAP_SHARED | MAP_POPULATE, cdev_fd,
+ UBLKSRV_CMD_BUF_OFFSET + q * max_len);
+
+ if (p == MAP_FAILED)
+ return -errno;
+ iods[q] = p;
+ }
+ return 0;
+}
+
+/* the last reference to /dev/ublkcN runs ublk_ch_release() */
+static void close_cdev(void)
+{
+ for (int q = 0; q < nr_queues; q++) {
+ if (iods[q])
+ munmap((void *)iods[q], iods_len);
+ iods[q] = NULL;
+ }
+ if (cdev_fd >= 0)
+ close(cdev_fd);
+ cdev_fd = -1;
+}
+
+/* ADD_DEV and SET_PARAMS, without opening /dev/ublkcN */
+static int add_dev_noopen(int queues, __u64 flags)
+{
+ struct ublk_dev *dev = ctrl();
+ struct ublksrv_ctrl_dev_info info = {
+ .nr_hw_queues = queues,
+ .queue_depth = DEPTH,
+ .max_io_buf_bytes = BUF_SIZE,
+ .dev_id = -1,
+ .flags = UBLK_F_NO_AUTO_PART_SCAN | flags,
+ };
+ struct ublk_params p = {
+ .types = UBLK_PARAM_TYPE_BASIC,
+ .basic = {
+ .logical_bs_shift = 9,
+ .physical_bs_shift = 12,
+ .io_opt_shift = 12,
+ .io_min_shift = 9,
+ .max_sectors = BUF_SIZE >> 9,
+ .dev_sectors = DEV_SECTORS,
+ },
+ };
+ int ret;
+
+ nr_queues = queues;
+ dev->dev_info = info;
+ ret = ublk_ctrl_add_dev(dev);
+ if (ret)
+ return ret;
+ dev_id = dev->dev_info.dev_id;
+
+ ret = ublk_ctrl_set_params(ctrl(), &p);
+ if (ret)
+ return ret;
+
+ for (int q = 0; q < queues; q++)
+ for (int i = 0; i < DEPTH; i++)
+ if (!bufs[q][i] &&
+ posix_memalign(&bufs[q][i], getpagesize(), BUF_SIZE))
+ return -ENOMEM;
+ return 0;
+}
+
+static int add_dev(int queues, __u64 flags)
+{
+ return add_dev_noopen(queues, flags) ?: open_cdev();
+}
+
+static void cleanup(void)
+{
+ if (dev_id < 0)
+ return;
+ ublk_ctrl_stop_dev(ctrl());
+ close_cdev();
+ ublk_ctrl_del_dev(ctrl());
+ dev_id = -1;
+}
+
+/* race_async_fetch sets IOSQE_ASYNC on the io commands */
+static int io_cmd_sqe_flags;
+
+static void queue_io_cmd(struct io_uring *ring, __u32 op, int q, int tag,
+ int res)
+{
+ struct io_uring_sqe *sqe = get_sqe(ring);
+ struct ublksrv_io_cmd *cmd = (struct ublksrv_io_cmd *)sqe->cmd;
+
+ memset(sqe, 0, sizeof(*sqe));
+ sqe->fd = cdev_fd;
+ sqe->opcode = IORING_OP_URING_CMD;
+ sqe->flags = io_cmd_sqe_flags;
+ ublk_set_sqe_cmd_op(sqe, op);
+ cmd->q_id = q;
+ cmd->tag = tag;
+ cmd->result = res;
+ cmd->addr = (__u64)(uintptr_t)bufs[q][tag];
+ io_uring_sqe_set_data64(sqe, (q << 16) | tag);
+}
+
+struct async_arg {
+ pthread_barrier_t go, stopped;
+};
+
+/*
+ * FETCH every tag with IOSQE_ASYNC, racing STOP_DEV, then close the ring once
+ * STOP_DEV returned: that walks io_uring's list of cancelable commands.
+ */
+static void *race_async_fn(void *data)
+{
+ struct async_arg *a = data;
+ struct io_uring ring;
+ int ok = !io_uring_queue_init(DEPTH, &ring, 0);
+
+ if (ok)
+ for (int tag = 0; tag < DEPTH; tag++)
+ queue_io_cmd(&ring, UBLK_U_IO_FETCH_REQ, 0, tag, 0);
+ pthread_barrier_wait(&a->go);
+ if (ok)
+ io_uring_submit(&ring);
+ pthread_barrier_wait(&a->stopped);
+ if (ok)
+ io_uring_queue_exit(&ring);
+ return NULL;
+}
+
+/* reap @nr completions of canceled fetch commands, return how many */
+static int reap_aborts(struct io_uring *ring, int nr)
+{
+ struct __kernel_timespec ts = { .tv_sec = 2 };
+ struct io_uring_cqe *cqe;
+ int aborted = 0;
+
+ while (nr--) {
+ if (io_uring_wait_cqe_timeout(ring, &cqe, &ts))
+ break;
+ if (cqe->res == UBLK_IO_RES_ABORT)
+ aborted++;
+ io_uring_cqe_seen(ring, cqe);
+ }
+ return aborted;
+}
+
+/*
+ * A server thread fetches @nr_tags tags of queue @q, then completes each
+ * request after @delay_us, until its commands are aborted.
+ */
+struct server {
+ int q, first_tag, nr_tags, delay_us;
+ int failed; /* result which ended the serve loop, 0 if none */
+ pthread_t thread;
+ pthread_barrier_t fetched;
+ /* race_fetch: wait for @go and @race_delay_us, open, fetch one by one */
+ pthread_barrier_t go;
+ int race, race_delay_us;
+};
+
+static void *server_fn(void *data)
+{
+ struct server *s = data;
+ struct io_uring ring;
+ struct io_uring_cqe *cqe;
+
+ if (io_uring_queue_init(DEPTH, &ring, 0)) {
+ pthread_barrier_wait(&s->fetched);
+ return NULL;
+ }
+ if (s->race) {
+ pthread_barrier_wait(&s->go);
+ usleep(s->race_delay_us);
+ if (open_cdev()) {
+ pthread_barrier_wait(&s->fetched);
+ io_uring_queue_exit(&ring);
+ return NULL;
+ }
+ }
+ for (int tag = s->first_tag; tag < s->first_tag + s->nr_tags; tag++) {
+ queue_io_cmd(&ring, UBLK_U_IO_FETCH_REQ, s->q, tag, 0);
+ if (s->race)
+ io_uring_submit(&ring);
+ }
+ io_uring_submit(&ring);
+ pthread_barrier_wait(&s->fetched);
+
+ while (!io_uring_wait_cqe(&ring, &cqe)) {
+ int tag = cqe->user_data & 0xffff;
+ const struct ublksrv_io_desc *iod = &iods[s->q][tag];
+ int res = cqe->res;
+
+ io_uring_cqe_seen(&ring, cqe);
+ if (res != UBLK_IO_RES_OK) {
+ __atomic_store_n(&s->failed, res, __ATOMIC_RELEASE);
+ break;
+ }
+ usleep(s->delay_us);
+ res = ublksrv_get_op(iod) <= UBLK_IO_OP_WRITE ?
+ iod->nr_sectors << 9 : 0;
+ queue_io_cmd(&ring, UBLK_U_IO_COMMIT_AND_FETCH_REQ, s->q, tag,
+ res);
+ io_uring_submit(&ring);
+ }
+ io_uring_queue_exit(&ring);
+ return NULL;
+}
+
+/* returns once the fetch commands are issued; with @race, call race_go() */
+static void server_start(struct server *s)
+{
+ pthread_barrier_init(&s->fetched, NULL, 2);
+ pthread_barrier_init(&s->go, NULL, 2);
+ pthread_create(&s->thread, NULL, server_fn, s);
+ if (!s->race)
+ pthread_barrier_wait(&s->fetched);
+}
+
+/* wait up to 5s for the serve loop of @s to end, return its result */
+static int server_wait_failed(struct server *s)
+{
+ int res = 0;
+
+ for (int i = 0; i < 500 && !res; i++) {
+ res = __atomic_load_n(&s->failed, __ATOMIC_ACQUIRE);
+ if (!res)
+ usleep(10000);
+ }
+ return res;
+}
+
+/*
+ * A task fetches @nr_tags tags of queue @q and dies. Returns once its
+ * commands are canceled, see the top of this file.
+ */
+static int fetch_and_die(int q, int first_tag, int nr_tags)
+{
+ int status;
+ pid_t pid = fork();
+
+ if (pid < 0)
+ return -1;
+ if (!pid) {
+ struct io_uring ring;
+
+ if (io_uring_queue_init(DEPTH, &ring, 0))
+ _exit(1);
+ for (int tag = first_tag; tag < first_tag + nr_tags; tag++)
+ queue_io_cmd(&ring, UBLK_U_IO_FETCH_REQ, q, tag, 0);
+ if (io_uring_submit(&ring) != nr_tags)
+ _exit(1);
+ execlp("true", "true", NULL);
+ _exit(1);
+ }
+ if (waitpid(pid, &status, 0) != pid || !WIFEXITED(status) ||
+ WEXITSTATUS(status))
+ return -1;
+ printf("q%d: task died with %d fetch cmds in flight\n", q, nr_tags);
+ return 0;
+}
+
+struct reads {
+ struct io_uring ring;
+ void *buf;
+ int fd, done, ok, eio, other;
+};
+
+/*
+ * Issue NR_READS reads at once, from @cpu if it is not negative: blk-mq
+ * maps the submitting CPU to the hw queue. A server holding its live
+ * tags for a while makes the other reads take the canceled tags.
+ */
+static int open_tries = 100; /* 50ms each */
+
+static int reads_submit(struct reads *r, int cpu)
+{
+ char path[64];
+ cpu_set_t set, old;
+
+ snprintf(path, sizeof(path), "/dev/ublkb%d", dev_id);
+ r->fd = -1;
+ for (int i = 0; i < open_tries && r->fd < 0; i++) {
+ r->fd = open(path, O_RDONLY | O_DIRECT);
+ if (r->fd < 0)
+ usleep(50000);
+ }
+ if (r->fd < 0) {
+ fprintf(stderr, "open %s: %s\n", path, strerror(errno));
+ return -1;
+ }
+ if (posix_memalign(&r->buf, 4096, NR_READS * 4096) ||
+ io_uring_queue_init(NR_READS, &r->ring, 0))
+ return -1;
+
+ for (int i = 0; i < NR_READS; i++)
+ io_uring_prep_read(get_sqe(&r->ring), r->fd,
+ r->buf + i * 4096, 4096, i * 4096);
+
+ if (cpu >= 0) {
+ sched_getaffinity(0, sizeof(old), &old);
+ CPU_ZERO(&set);
+ CPU_SET(cpu, &set);
+ sched_setaffinity(0, sizeof(set), &set);
+ }
+ io_uring_submit(&r->ring);
+ if (cpu >= 0)
+ sched_setaffinity(0, sizeof(old), &old);
+ return 0;
+}
+
+static void reads_reap(struct reads *r, int timeout_s)
+{
+ struct __kernel_timespec ts = { .tv_sec = timeout_s };
+ struct io_uring_cqe *cqe;
+
+ while (r->done < NR_READS &&
+ !io_uring_wait_cqe_timeout(&r->ring, &cqe, &ts)) {
+ if (cqe->res == 4096)
+ r->ok++;
+ else if (cqe->res == -EIO)
+ r->eio++;
+ else
+ r->other++;
+ r->done++;
+ io_uring_cqe_seen(&r->ring, cqe);
+ }
+}
+
+static void reads_put(struct reads *r)
+{
+ io_uring_queue_exit(&r->ring);
+ close(r->fd);
+ free(r->buf);
+}
+
+static int reads_result(struct reads *r)
+{
+ printf("reads: %d ok, %d -EIO, %d other, %d not completed\n",
+ r->ok, r->eio, r->other, NR_READS - r->done);
+ reads_put(r);
+ return r->other || r->done < NR_READS ? KSFT_FAIL : KSFT_PASS;
+}
+
+static int start_dev(void)
+{
+ int ret = ublk_ctrl_start_dev(ctrl(), getpid());
+
+ printf("START_DEV: %d\n", ret);
+ return ret;
+}
+
+static int expect_err(const char *what, int ret, int want)
+{
+ if (ret == want)
+ return KSFT_PASS;
+ fprintf(stderr, "%s: %d, expected %d\n", what, ret, want);
+ return KSFT_FAIL;
+}
+
+/* START_DEV must fail with @want; if it went live, show what a read does */
+static int start_dev_expect(int want)
+{
+ struct reads r = {};
+ int ret = start_dev();
+
+ if (!ret && !reads_submit(&r, -1)) {
+ reads_reap(&r, 10);
+ reads_result(&r);
+ }
+ return expect_err("START_DEV", ret, want);
+}
+
+static int test_stop_start(void)
+{
+ struct io_uring ring;
+ int ret;
+
+ if (add_dev(1, 0))
+ return KSFT_FAIL;
+ if (io_uring_queue_init(DEPTH, &ring, 0))
+ return KSFT_FAIL;
+ for (int tag = 0; tag < DEPTH; tag++)
+ queue_io_cmd(&ring, UBLK_U_IO_FETCH_REQ, 0, tag, 0);
+ io_uring_submit(&ring);
+
+ /* device is ready but not started: state is UBLK_S_DEV_DEAD */
+ ret = ublk_ctrl_stop_dev(ctrl());
+ printf("STOP_DEV: %d, canceled fetch cmds: %d/%d\n", ret,
+ reap_aborts(&ring, DEPTH), DEPTH);
+
+ /* STOP_DEV canceled the attached server: no start until it exits */
+ ret = start_dev_expect(-EBUSY);
+ io_uring_queue_exit(&ring);
+ return ret;
+}
+
+static int test_partial_fetch(void)
+{
+ struct server b = { .q = 0, .first_tag = DEPTH - 1, .nr_tags = 1,
+ .delay_us = SERVE_DELAY_US };
+ int ret;
+
+ if (add_dev(1, 0) || fetch_and_die(0, 0, DEPTH - 1))
+ return KSFT_FAIL;
+
+ /* the last FETCH makes the queue ready and clears ->canceling */
+ server_start(&b);
+
+ ret = start_dev_expect(-EBUSY);
+
+ cleanup();
+ pthread_join(b.thread, NULL);
+ return ret;
+}
+
+static int test_stop_restart(void)
+{
+ struct server s = { .q = 0, .nr_tags = DEPTH };
+ struct reads r = {};
+ int ret;
+
+ if (add_dev_noopen(1, 0))
+ return KSFT_FAIL;
+
+ /* no server is attached, so there is nothing to cancel */
+ ret = ublk_ctrl_stop_dev(ctrl());
+ printf("STOP_DEV: %d\n", ret);
+ if (open_cdev())
+ return KSFT_FAIL;
+
+ server_start(&s);
+ if (start_dev()) {
+ ret = KSFT_FAIL;
+ } else if (reads_submit(&r, -1)) {
+ ret = KSFT_FAIL;
+ } else {
+ reads_reap(&r, 10);
+ ret = reads_result(&r);
+ if (r.ok != NR_READS)
+ ret = KSFT_FAIL;
+ }
+
+ cleanup();
+ pthread_join(s.thread, NULL);
+ return ret;
+}
+
+struct start_arg {
+ pthread_barrier_t go;
+ int ret, reads_ok;
+};
+
+static void *race_start_fn(void *data)
+{
+ struct start_arg *a = data;
+ struct reads r = {};
+
+ pthread_barrier_wait(&a->go);
+ a->ret = ublk_ctrl_start_dev(ctrl(), getpid());
+ a->reads_ok = 1;
+ /*
+ * The disk may be gone already if STOP_DEV came right after, and
+ * reads may fail then: they only have to complete.
+ */
+ if (!a->ret && !reads_submit(&r, -1)) {
+ reads_reap(&r, 5);
+ a->reads_ok = r.done == NR_READS;
+ if (a->reads_ok)
+ reads_put(&r);
+ else
+ reads_result(&r);
+ }
+ ctrl_put();
+ return NULL;
+}
+
+static int test_race_start(void)
+{
+ int live = 0, ebusy = 0;
+
+ open_tries = 4;
+ for (int i = 0; i < RACE_LOOPS; i++) {
+ struct server s = { .q = 0, .nr_tags = DEPTH };
+ struct start_arg a = {};
+ pthread_t t;
+
+ if (add_dev(1, 0))
+ return KSFT_FAIL;
+ server_start(&s);
+ pthread_barrier_init(&a.go, NULL, 2);
+ pthread_create(&t, NULL, race_start_fn, &a);
+ pthread_barrier_wait(&a.go);
+ ublk_ctrl_stop_dev(ctrl());
+ pthread_join(t, NULL);
+ cleanup();
+ pthread_join(s.thread, NULL);
+
+ if (a.ret == 0)
+ live++;
+ else if (a.ret == -EBUSY)
+ ebusy++;
+ if ((a.ret && a.ret != -EBUSY) || !a.reads_ok) {
+ fprintf(stderr, "loop %d: START_DEV %d, reads %s\n",
+ i, a.ret, a.reads_ok ? "ok" : "failed");
+ return KSFT_FAIL;
+ }
+ }
+ printf("%d loops: START_DEV won %d, got -EBUSY %d\n", RACE_LOOPS,
+ live, ebusy);
+ return KSFT_PASS;
+}
+
+static int test_race_fetch(void)
+{
+ int live = 0, ebusy = 0;
+
+ for (int i = 0; i < RACE_LOOPS; i++) {
+ /* vary who goes first: STOP_DEV, or the server's open */
+ struct server s = { .q = 0, .nr_tags = DEPTH, .race = 1,
+ .race_delay_us = (i % 10) * 50 };
+ struct reads r = {};
+ int ret;
+
+ if (add_dev_noopen(1, 0))
+ return KSFT_FAIL;
+ server_start(&s);
+ pthread_barrier_wait(&s.go);
+ ublk_ctrl_stop_dev(ctrl());
+ pthread_barrier_wait(&s.fetched);
+
+ ret = ublk_ctrl_start_dev(ctrl(), getpid());
+ if (!ret) {
+ /* nothing was taken, so every read has to succeed */
+ live++;
+ if (reads_submit(&r, -1))
+ return KSFT_FAIL;
+ reads_reap(&r, 5);
+ if (r.ok != NR_READS) {
+ fprintf(stderr, "loop %d: live, but ", i);
+ reads_result(&r);
+ return KSFT_FAIL;
+ }
+ reads_put(&r);
+ } else if (ret == -EBUSY) {
+ ebusy++;
+ } else {
+ fprintf(stderr, "loop %d: START_DEV %d\n", i, ret);
+ return KSFT_FAIL;
+ }
+ cleanup();
+ pthread_join(s.thread, NULL);
+ }
+ printf("%d loops: START_DEV worked %d, got -EBUSY %d\n", RACE_LOOPS,
+ live, ebusy);
+ return KSFT_PASS;
+}
+
+static int test_race_async_fetch(void)
+{
+ io_cmd_sqe_flags = IOSQE_ASYNC;
+ for (int i = 0; i < ASYNC_LOOPS; i++) {
+ struct async_arg a;
+ pthread_t t;
+
+ if (add_dev(1, 0))
+ return KSFT_FAIL;
+ pthread_barrier_init(&a.go, NULL, 2);
+ pthread_barrier_init(&a.stopped, NULL, 2);
+ pthread_create(&t, NULL, race_async_fn, &a);
+ pthread_barrier_wait(&a.go);
+ /* vary where STOP_DEV lands relative to the FETCHes */
+ usleep((i % 5) * 1000);
+ ublk_ctrl_stop_dev(ctrl());
+ pthread_barrier_wait(&a.stopped);
+ pthread_join(t, NULL);
+ cleanup();
+ }
+ printf("%d loops done\n", ASYNC_LOOPS);
+ return KSFT_PASS;
+}
+
+/*
+ * The stopped server is gone: reopen /dev/ublkcN, start a new server and
+ * the device, and read from it.
+ */
+static int restart_server(void)
+{
+ struct server s = { .q = 0, .nr_tags = DEPTH };
+ struct reads r = {};
+ int ret;
+
+ close_cdev();
+ if (open_cdev())
+ return KSFT_FAIL;
+ server_start(&s);
+ usleep(200000);
+ if (s.failed) {
+ fprintf(stderr, "new server: FETCH failed %d\n", s.failed);
+ cleanup();
+ pthread_join(s.thread, NULL);
+ return KSFT_FAIL;
+ }
+ /* -EEXIST until the old disk is freed, e.g. after a udev probe */
+ for (int i = 0; i < 100; i++) {
+ ret = start_dev();
+ if (ret != -EEXIST)
+ break;
+ usleep(50000);
+ }
+ if (ret || reads_submit(&r, -1)) {
+ fprintf(stderr, "new server: START_DEV %d\n", ret);
+ ret = KSFT_FAIL;
+ } else {
+ reads_reap(&r, 10);
+ ret = reads_result(&r);
+ if (r.ok != NR_READS)
+ ret = KSFT_FAIL;
+ }
+ cleanup();
+ pthread_join(s.thread, NULL);
+ return ret;
+}
+
+/*
+ * stop_attached: STOP_DEV while a server has the device open but has
+ * fetched nothing stops that server too: its FETCH gets ABORT and
+ * START_DEV -EBUSY. Once it is gone, a new server can start the device.
+ */
+static int test_stop_attached(void)
+{
+ struct server s = { .q = 0, .nr_tags = DEPTH };
+ int ret;
+
+ if (add_dev(1, 0))
+ return KSFT_FAIL;
+ ret = ublk_ctrl_stop_dev(ctrl());
+ printf("STOP_DEV: %d\n", ret);
+
+ server_start(&s);
+ ret = server_wait_failed(&s);
+ printf("FETCH after STOP_DEV: %d\n", ret);
+ if (ret != UBLK_IO_RES_ABORT) {
+ cleanup();
+ pthread_join(s.thread, NULL);
+ return KSFT_FAIL;
+ }
+ pthread_join(s.thread, NULL);
+ if (expect_err("START_DEV", start_dev(), -EBUSY))
+ return KSFT_FAIL;
+ return restart_server();
+}
+
+/*
+ * stop_live_restart: STOP_DEV on a live device; once its server is gone,
+ * a new server has to fetch and start it again.
+ */
+static int test_stop_live_restart(void)
+{
+ struct server s = { .q = 0, .nr_tags = DEPTH };
+ int ret;
+
+ if (add_dev(1, 0))
+ return KSFT_FAIL;
+ server_start(&s);
+ if (expect_err("START_DEV", start_dev(), 0))
+ return KSFT_FAIL;
+ ret = ublk_ctrl_stop_dev(ctrl());
+ printf("STOP_DEV: %d\n", ret);
+ pthread_join(s.thread, NULL);
+ return restart_server();
+}
+
+/* first CPU which blk-mq maps to hw queue @q */
+static int queue_cpu(int q)
+{
+ char path[96];
+ FILE *f;
+ int cpu = -1;
+
+ snprintf(path, sizeof(path), "/sys/block/ublkb%d/mq/%d/cpu_list",
+ dev_id, q);
+ for (int i = 0; i < 100 && !(f = fopen(path, "r")); i++)
+ usleep(50000);
+ if (!f)
+ return -1;
+ if (fscanf(f, "%d", &cpu) != 1)
+ cpu = -1;
+ fclose(f);
+ return cpu;
+}
+
+static int test_recovery(void)
+{
+ struct server q1 = { .q = 1, .nr_tags = DEPTH };
+ struct io_uring ring;
+ struct reads r = {};
+ int ret, cpu;
+
+ if (add_dev(NR_QUEUES, UBLK_F_USER_RECOVERY))
+ return KSFT_FAIL;
+
+ /* the first server: fetch everything, start, then die */
+ if (io_uring_queue_init(NR_QUEUES * DEPTH, &ring, 0))
+ return KSFT_FAIL;
+ for (int q = 0; q < NR_QUEUES; q++)
+ for (int tag = 0; tag < DEPTH; tag++)
+ queue_io_cmd(&ring, UBLK_U_IO_FETCH_REQ, q, tag, 0);
+ io_uring_submit(&ring);
+ if (start_dev())
+ return KSFT_FAIL;
+ cpu = queue_cpu(0);
+ if (cpu < 0) {
+ printf("no CPU maps to queue 0, can't aim the reads\n");
+ return KSFT_SKIP;
+ }
+
+ io_uring_queue_exit(&ring);
+ close_cdev();
+ for (int i = 0; i < 100 && dev_state() != UBLK_S_DEV_QUIESCED; i++)
+ usleep(50000);
+ printf("server exited, state %d (QUIESCED is %d)\n", dev_state(),
+ UBLK_S_DEV_QUIESCED);
+
+ for (int i = 0; i < 100; i++) {
+ ret = ublk_ctrl_start_user_recovery(ctrl());
+ if (ret != -EBUSY)
+ break;
+ usleep(50000);
+ }
+ printf("START_USER_RECOVERY: %d\n", ret);
+ if (ret || open_cdev())
+ return KSFT_FAIL;
+
+ /* queue 0 gets ready, then its task dies before queue 1 is ready */
+ if (fetch_and_die(0, 0, DEPTH))
+ return KSFT_FAIL;
+
+ printf("reads on cpu %d, which maps to queue 0\n", cpu);
+ if (reads_submit(&r, cpu))
+ return KSFT_FAIL;
+
+ server_start(&q1);
+ ret = ublk_ctrl_end_user_recovery(ctrl(), getpid());
+ printf("END_USER_RECOVERY: %d\n", ret);
+ ret = expect_err("END_USER_RECOVERY", ret, -EBUSY);
+
+ /*
+ * Requests held back on queue 0 wait for STOP_DEV to fail them.
+ * Close the disk before DEL_DEV, which waits for its last reference.
+ */
+ reads_reap(&r, 1);
+ ublk_ctrl_stop_dev(ctrl());
+ reads_reap(&r, 5);
+ if (reads_result(&r))
+ ret = KSFT_FAIL;
+ cleanup();
+ pthread_join(q1.thread, NULL);
+ return ret;
+}
+
+static const struct {
+ const char *name;
+ int (*fn)(void);
+} modes[] = {
+ { "stop_start", test_stop_start },
+ { "partial_fetch", test_partial_fetch },
+ { "recovery", test_recovery },
+ { "stop_restart", test_stop_restart },
+ { "race_start", test_race_start },
+ { "race_fetch", test_race_fetch },
+ { "race_async_fetch", test_race_async_fetch },
+ { "stop_attached", test_stop_attached },
+ { "stop_live_restart", test_stop_live_restart },
+};
+
+int main(int argc, char **argv)
+{
+ int (*fn)(void) = NULL;
+ int ret;
+
+ for (int i = 0; argc == 2 && i < ARRAY_SIZE(modes); i++)
+ if (!strcmp(argv[1], modes[i].name))
+ fn = modes[i].fn;
+ if (!fn) {
+ fprintf(stderr, "usage: %s MODE, modes:", argv[0]);
+ for (int i = 0; i < ARRAY_SIZE(modes); i++)
+ fprintf(stderr, " %s", modes[i].name);
+ fprintf(stderr, "\n");
+ return KSFT_FAIL;
+ }
+
+ /* keep the output of a run that ends in an oops */
+ setvbuf(stdout, NULL, _IOLBF, 0);
+
+ if (access(CTRL_DEV, F_OK)) {
+ perror(CTRL_DEV);
+ return KSFT_SKIP;
+ }
+ printf("%s\n", argv[1]);
+ ret = fn();
+ cleanup();
+ ctrl_put();
+ return ret;
+}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 333/742] selftests: ublk: fix the build and file offsets on 32-bit
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (323 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 332/742] selftests: ublk: add test for going live over canceled io commands Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 334/742] selftests/ublk: use the configured kernel UAPI headers Greg Kroah-Hartman
` (401 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sasha Levin, Ming Lei, Jens Axboe
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sasha Levin <sashal@kernel.org>
[ Upstream commit 3197517875fdcfae1e9b5a4dcaf35cbbd66c413c ]
kublk puts pointers into 64-bit UAPI and SQE fields with a plain (__u64)
cast. ublk builds with -Werror, so it fails to build on 32-bit
architectures:
batch.c:379:42: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
Cast through uintptr_t. kublk also passes 64-bit user copy offsets,
which start at UBLKSRV_IO_BUF_OFFSET (2 GB), to pread() and pwrite(),
and with glibc those are truncated to a 32-bit off_t there. Build with
-D_FILE_OFFSET_BITS=64 as well.
Signed-off-by: Sasha Levin <sashal@kernel.org>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Link: https://patch.msgid.link/20261103163928.641519-1-sashal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: d9667b1a6a33 ("selftests/ublk: use the configured kernel UAPI headers")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/testing/selftests/ublk/Makefile | 1 +
tools/testing/selftests/ublk/batch.c | 6 +++---
tools/testing/selftests/ublk/ctrl.c | 2 +-
tools/testing/selftests/ublk/kublk.c | 2 +-
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile
index fc64b8f028332..1a50d4695c9fa 100644
--- a/tools/testing/selftests/ublk/Makefile
+++ b/tools/testing/selftests/ublk/Makefile
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)/usr/include
+CFLAGS += -D_FILE_OFFSET_BITS=64
ifneq ($(WERROR),0)
CFLAGS += -Werror
endif
diff --git a/tools/testing/selftests/ublk/batch.c b/tools/testing/selftests/ublk/batch.c
index d8d9ebed5979f..00957d55c4494 100644
--- a/tools/testing/selftests/ublk/batch.c
+++ b/tools/testing/selftests/ublk/batch.c
@@ -376,10 +376,10 @@ static int __ublk_batch_queue_prep_io_cmds(struct ublk_thread *t, struct ublk_qu
if (ublk_queue_use_auto_zc(q))
elem->buf_index = ublk_batch_io_buf_idx(t, q, i);
else if (!ublk_queue_no_buf(q))
- elem->buf_addr = (__u64)io->buf_addr;
+ elem->buf_addr = (__u64)(uintptr_t)io->buf_addr;
}
- sqe->addr = (__u64)buf;
+ sqe->addr = (__u64)(uintptr_t)buf;
sqe->len = t->commit_buf_elem_size * nr_elem;
ublk_init_batch_cmd(t, q->q_id, sqe, UBLK_U_IO_PREP_IO_CMDS,
@@ -466,7 +466,7 @@ static void __ublk_batch_commit_io_cmds(struct ublk_thread *t,
ublk_io_alloc_sqes(t, &sqe, 1);
buf_idx = cb->buf_idx;
- sqe->addr = (__u64)cb->elem;
+ sqe->addr = (__u64)(uintptr_t)cb->elem;
sqe->len = nr_elem * t->commit_buf_elem_size;
/* commit isn't per-queue command */
diff --git a/tools/testing/selftests/ublk/ctrl.c b/tools/testing/selftests/ublk/ctrl.c
index 53d54799f9097..5e0762cfc4eae 100644
--- a/tools/testing/selftests/ublk/ctrl.c
+++ b/tools/testing/selftests/ublk/ctrl.c
@@ -204,7 +204,7 @@ int ublk_ctrl_get_params(struct ublk_dev *dev,
struct ublk_ctrl_cmd_data data = {
.cmd_op = UBLK_U_CMD_GET_PARAMS,
.flags = CTRL_CMD_HAS_BUF,
- .addr = (__u64)params,
+ .addr = (__u64)(uintptr_t)params,
.len = sizeof(*params),
};
diff --git a/tools/testing/selftests/ublk/kublk.c b/tools/testing/selftests/ublk/kublk.c
index 5a4ff689c1f7a..115f25351d309 100644
--- a/tools/testing/selftests/ublk/kublk.c
+++ b/tools/testing/selftests/ublk/kublk.c
@@ -148,7 +148,7 @@ static int ublk_ctrl_get_affinity(struct ublk_dev *ctrl_dev, cpu_set_t **ptr_buf
for (i = 0; i < ctrl_dev->dev_info.nr_hw_queues; i++) {
data.data[0] = i;
data.len = sizeof(cpu_set_t);
- data.addr = (__u64)&buf[i];
+ data.addr = (__u64)(uintptr_t)&buf[i];
ret = __ublk_ctrl_cmd(ctrl_dev, &data);
if (ret < 0) {
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 334/742] selftests/ublk: use the configured kernel UAPI headers
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (324 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 333/742] selftests: ublk: fix the build and file offsets on 32-bit Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 335/742] block: fix BLKSECDISCARD zero-length range causing page cache invalidation Greg Kroah-Hartman
` (400 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sasha Levin, Ming Lei, Jens Axboe
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sasha Levin <sashal@kernel.org>
[ Upstream commit d9667b1a6a3387ef934667b9a2e6c099eee0e4f1 ]
With generated headers in an output directory, the hardcoded source-tree
include path falls through to distribution headers. New ublk flags and
structure members, including UBLK_F_IO_DESC_SIZE, are then missing.
Use KHDR_INCLUDES to consume the headers from the kernel under test, and
add the headers target as an order-only prerequisite of the ublk
programs, as nolibc-test does, so that a standalone build installs them
first. Baseline builds fail on the missing definitions; GCC 14 and Clang
21 builds succeed with the output-directory headers and target liburing
development files available.
Fixes: e371b9d3368c ("selftests: ublk: kublk: fix include path")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Link: https://patch.msgid.link/20261126231706.1303486-1-sashal@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/testing/selftests/ublk/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile
index 1a50d4695c9fa..8fc3291eaed94 100644
--- a/tools/testing/selftests/ublk/Makefile
+++ b/tools/testing/selftests/ublk/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
-CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)/usr/include
+CFLAGS += -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
CFLAGS += -D_FILE_OFFSET_BITS=64
ifneq ($(WERROR),0)
CFLAGS += -Werror
@@ -86,6 +86,7 @@ include ../lib.mk
$(OUTPUT)/kublk: $(filter-out $(STANDALONE_UTILS),$(wildcard *.c))
$(OUTPUT)/ublk_cancel_ready: ublk_cancel_ready.c ctrl.c
+$(TEST_GEN_PROGS_EXTENDED): | headers
check:
shellcheck -x -f gcc *.sh
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 335/742] block: fix BLKSECDISCARD zero-length range causing page cache invalidation
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (325 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 334/742] selftests/ublk: use the configured kernel UAPI headers Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 336/742] sched/core: Rank DL server picks as deadline in the core-wide pick Greg Kroah-Hartman
` (399 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zizhi Wo, Yu Kuai, Christoph Hellwig,
Bart Van Assche, Jens Axboe, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zizhi Wo <wozizhi@huawei.com>
[ Upstream commit aea1c2ec03b399434ff1bafbb2f0d5076f74ce03 ]
Commit 697ba0b6ec4a ("block: fix integer overflow in BLKSECDISCARD") fixed
the start+len overflow via check_add_overflow() but did not handle the
start=0, len=0 case. There, start + len = 0, so end = 0 passes all checks,
and truncate_bdev_range()->truncate_inode_pages_range() is then called with
lend=UINT64_MAX, whitch is the "truncate to the end of file" sentinel, so
the entire page cache is invalidated.
Fix this by replacing the validation with blk_validate_byte_range(), which
already rejects a zero-length range and is what BLKDISCARD uses. This also
switches the alignment check from a hardcoded 512 to
bdev_logical_block_size().
Fixes: 0bd1ed4860d0 ("block: pass inclusive 'lend' parameter to truncate_inode_pages_range")
Signed-off-by: Zizhi Wo <wozizhi@huawei.com>
Reviewed-by: Yu Kuai <yukuai@fygo.io>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20261102080420.3774409-1-wozizhi@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
block/ioctl.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/block/ioctl.c b/block/ioctl.c
index fb2f4b4d2505e..96da0c87802be 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -177,8 +177,7 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
static int blk_ioctl_secure_erase(struct block_device *bdev, blk_mode_t mode,
void __user *argp)
{
- uint64_t start, len, end;
- uint64_t range[2];
+ uint64_t range[2], start, len;
int err;
if (!(mode & BLK_OPEN_WRITE))
@@ -190,15 +189,13 @@ static int blk_ioctl_secure_erase(struct block_device *bdev, blk_mode_t mode,
start = range[0];
len = range[1];
- if ((start & 511) || (len & 511))
- return -EINVAL;
- if (check_add_overflow(start, len, &end) ||
- end > bdev_nr_bytes(bdev))
- return -EINVAL;
+ err = blk_validate_byte_range(bdev, start, len);
+ if (err)
+ return err;
inode_lock(bdev->bd_mapping->host);
filemap_invalidate_lock(bdev->bd_mapping);
- err = truncate_bdev_range(bdev, mode, start, end - 1);
+ err = truncate_bdev_range(bdev, mode, start, start + len - 1);
if (!err)
err = blkdev_issue_secure_erase(bdev, start >> 9, len >> 9,
GFP_KERNEL);
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 336/742] sched/core: Rank DL server picks as deadline in the core-wide pick
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (326 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 335/742] block: fix BLKSECDISCARD zero-length range causing page cache invalidation Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 337/742] drm/gud: avoid divide error in gud_stats_debugfs Greg Kroah-Hartman
` (398 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Fernand Sieber,
Peter Zijlstra (Intel), Ingo Molnar, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernand Sieber <sieberf@amazon.com>
[ Upstream commit edf8ee40167473828c1ae20ab9c6442f2e66dded ]
Commit 4b26cfdd3956 ("sched/core: Fix priority checking for DL server
picks") made the core-wide selection rank a task picked through a DL
server as deadline, so that a fair task competing with RT tasks under
core scheduling still gets its server's bandwidth. It keys on
p->dl_server, which pick_task() used to set.
Since commit bd9bbc96e835 ("sched: Rework dl_server"), pick_task()
records the server in rq->dl_server and p->dl_server is only set once
the task is switched in. The core-wide selection still ranks each
sibling's pick with prio_less(), so a task the sibling's server has
just picked ranks as a plain fair or ext task and loses to an RT task
on another sibling. The server's CPU then runs a task with the RT
task's cookie or is forced idle, and the fair task gets none of the
server's bandwidth for as long as the RT task runs.
Rank each sibling's pick by the server it came through, rq_i->dl_server.
prio_less() keeps using p->dl_server for the core tree, whose tasks are
not being picked.
Fixes: bd9bbc96e835 ("sched: Rework dl_server")
Signed-off-by: Fernand Sieber <sieberf@amazon.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://patch.msgid.link/20261112161548.78189-4-sieberf@amazon.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
kernel/sched/core.c | 51 +++++++++++++++++++++++++++++++--------------
1 file changed, 35 insertions(+), 16 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 645111c09d7ea..9c518ba210c14 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -196,12 +196,13 @@ __read_mostly int scheduler_running;
DEFINE_STATIC_KEY_FALSE(__sched_core_enabled);
/* kernel prio, less is more */
-static inline int __task_prio(const struct task_struct *p)
+static inline int __task_prio(const struct task_struct *p,
+ const struct sched_dl_entity *dl_server)
{
if (p->sched_class == &stop_sched_class) /* trumps deadline */
return -2;
- if (p->dl_server)
+ if (dl_server)
return -1; /* deadline */
if (rt_or_dl_prio(p->prio))
@@ -223,12 +224,19 @@ static inline int __task_prio(const struct task_struct *p)
* ge(a,b) := !l(a,b)
*/
-/* real prio, less is less */
-static inline bool prio_less(const struct task_struct *a,
- const struct task_struct *b, bool in_fi)
+/*
+ * real prio, less is less
+ *
+ * @a_dl_server and @b_dl_server are the DL servers @a and @b run on
+ * behalf of, if any.
+ */
+static inline bool __prio_less(const struct task_struct *a,
+ const struct sched_dl_entity *a_dl_server,
+ const struct task_struct *b,
+ const struct sched_dl_entity *b_dl_server,
+ bool in_fi)
{
-
- int pa = __task_prio(a), pb = __task_prio(b);
+ int pa = __task_prio(a, a_dl_server), pb = __task_prio(b, b_dl_server);
if (-pa < -pb)
return true;
@@ -239,18 +247,13 @@ static inline bool prio_less(const struct task_struct *a,
if (pa == -1) { /* dl_prio() doesn't work because of stop_class above */
const struct sched_dl_entity *a_dl, *b_dl;
- a_dl = &a->dl;
/*
- * Since,'a' and 'b' can be CFS tasks served by DL server,
+ * Since 'a' and 'b' can be tasks served by a DL server,
* __task_prio() can return -1 (for DL) even for those. In that
* case, get to the dl_server's DL entity.
*/
- if (a->dl_server)
- a_dl = a->dl_server;
-
- b_dl = &b->dl;
- if (b->dl_server)
- b_dl = b->dl_server;
+ a_dl = a_dl_server ?: &a->dl;
+ b_dl = b_dl_server ?: &b->dl;
return !dl_time_before(a_dl->deadline, b_dl->deadline);
}
@@ -266,6 +269,12 @@ static inline bool prio_less(const struct task_struct *a,
return false;
}
+static inline bool prio_less(const struct task_struct *a,
+ const struct task_struct *b, bool in_fi)
+{
+ return __prio_less(a, a->dl_server, b, b->dl_server, in_fi);
+}
+
static inline bool __sched_core_less(const struct task_struct *a,
const struct task_struct *b)
{
@@ -6251,6 +6260,7 @@ pick_next_task(struct rq *rq, struct rq_flags *rf)
__must_hold(__rq_lockp(rq))
{
struct task_struct *next, *p, *max;
+ struct sched_dl_entity *max_dl_server;
bool fi_before = false;
bool core_clock_updated = (rq == rq->core);
unsigned long cookie;
@@ -6365,6 +6375,7 @@ pick_next_task(struct rq *rq, struct rq_flags *rf)
* Tie-break prio towards the current CPU
*/
max = NULL;
+ max_dl_server = NULL;
for_each_core_cpu_wrap(i, rq) {
rq_i = cpu_rq(i);
@@ -6388,8 +6399,16 @@ pick_next_task(struct rq *rq, struct rq_flags *rf)
rq_i->core_pick = p;
rq_i->core_dl_server = rq_i->dl_server;
- if (!max || prio_less(max, p, fi_before))
+ /*
+ * p->dl_server is only set once @p runs; rank a pick that
+ * came through a DL server by that server.
+ */
+ if (!max || __prio_less(max, max_dl_server,
+ p, rq_i->dl_server,
+ fi_before)) {
max = p;
+ max_dl_server = rq_i->dl_server;
+ }
}
cookie = rq->core->core_cookie = max->core_cookie;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 337/742] drm/gud: avoid divide error in gud_stats_debugfs
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (327 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 336/742] sched/core: Rank DL server picks as deadline in the core-wide pick Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 338/742] drm/i915/cdclk: Ignore SWF18 in SKL CDCLK sanitization Greg Kroah-Hartman
` (397 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Bin Yu, Cheng Wen, YuanZhe Liu,
Ruben Wauters
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
commit 431c2dffd2b7c1240a6e579f0c74104cd2e17329 upstream.
gud_stats_debugfs() computes the compression ratio by dividing the
accumulated uncompressed length by stats_actual_length. That counter is
zero until the first framebuffer flush has completed, so reading the
stats debugfs file on a display which negotiates LZ4 compression raises
a divide error before any frame has been sent. The wrap-around reset in
gud_flush_rect() also clears the counter for a moment, which a
concurrent read can observe.
Copy the counter into a local variable and skip the ratio computation
when it is zero.
Fixes: 40e1a70b4aed ("drm: Add GUD USB Display driver")
Cc: stable@vger.kernel.org
Co-developed-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Acked-by: Ruben Wauters <rubenru09@aol.com>
Link: https://patch.msgid.link/20261029073311.14556-1-25031212351@stu.xidian.edu.cn
Signed-off-by: Ruben Wauters <rubenru09@aol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/gud/gud_drv.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
--- a/drivers/gpu/drm/gud/gud_drv.c
+++ b/drivers/gpu/drm/gud/gud_drv.c
@@ -329,10 +329,17 @@ static int gud_stats_debugfs(struct seq_
seq_puts(m, "\n");
if (gdrm->compression) {
+ u64 actual_length = gdrm->stats_actual_length;
u64 remainder;
- u64 ratio = div64_u64_rem(gdrm->stats_length, gdrm->stats_actual_length,
- &remainder);
- u64 ratio_frac = div64_u64(remainder * 10, gdrm->stats_actual_length);
+ u64 ratio, ratio_frac;
+
+ if (!actual_length) {
+ seq_puts(m, "Compression ratio: n/a\n");
+ return 0;
+ }
+
+ ratio = div64_u64_rem(gdrm->stats_length, actual_length, &remainder);
+ ratio_frac = div64_u64(remainder * 10, actual_length);
seq_printf(m, "Compression ratio: %llu.%llu\n", ratio, ratio_frac);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 338/742] drm/i915/cdclk: Ignore SWF18 in SKL CDCLK sanitization
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (328 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 337/742] drm/gud: avoid divide error in gud_stats_debugfs Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 339/742] drm/i915/display: Flush the fbdev frontbuffer Greg Kroah-Hartman
` (396 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ville Syrjälä, Mika Kahola,
Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
commit 9e7a9295c90e28e1bb6e88b76aaa91839266352b upstream.
Currently on SKL/derivatives we are checking whether
the VBIOS/GOP programmed the SWF18 scratch register
appropriately. SWF18 is where the VBIOS/GOP should
stuff some information about what outputs it enabled.
A related register SWF06 is where the VBIOS/GOP is
supposed to stuff the maximum CDCLK frequency.
I think only SWF06 is really used by the Windows
driver (and even that only up to and including ADL),
the other stuff it doesn't even look at.
Apparently at least some coreboot based systems
don't set these scratch registers up at all.
SWF18 not being populated leads us to reprogram the
CDCLK PLL during driver initialization, while the
display pipes are still potentially active. We also
set CDCLK to its minimum frequency, under the
assumption that nothing actually needs a higher
CDCLK frequency when it hasn't even been correctly
initialized.
Due to some other changes in the code we may no longer
force a full CDCLK recalculation and reprogramming upon
the first atomic commit, so CDCLK can remain at a
potentially too low a frequency indefinitely.
To fix this let's just stop looking at SWF18 completely.
We don't look at that register on any other platform either,
and neither does Windows from what I can see. We also do an
actual readout of the CDCLK state from the hardware
so we should be able to spot if anything is wrong
enough to need reprogramming.
v2: Rewrite the commit message to mix up SWF06 vs. SWF18
Cc: stable@vger.kernel.org
Fixes: ba91b9eecb47 ("drm/i915/cdclk: Decouple cdclk from state->modeset")
Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/work_items/16595
Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/work_items/17423
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/20261105124737.24456-1-ville.syrjala@linux.intel.com
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
(cherry picked from commit a6e9767ca2e353277aa06d4c796093ef71a191b6)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_cdclk.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
--- a/drivers/gpu/drm/i915/display/intel_cdclk.c
+++ b/drivers/gpu/drm/i915/display/intel_cdclk.c
@@ -1229,18 +1229,7 @@ static void skl_set_cdclk(struct intel_d
static void skl_sanitize_cdclk(struct intel_display *display)
{
- u32 cdctl, expected, swf18;
-
- /*
- * check if the pre-os initialized the display
- * There is SWF18 scratchpad register defined which is set by the
- * pre-os which can be used by the OS drivers to check the status
- */
- swf18 = intel_de_read(display, SWF_ILK(0x18));
- if ((swf18 & 0x00FFFFFF) == 0) {
- drm_dbg_kms(display->drm, "Sanitizing CDCLK due to SWF18 0x%x\n", swf18);
- goto sanitize;
- }
+ u32 cdctl, expected;
intel_update_cdclk(display);
intel_cdclk_dump_config(display, &display->cdclk.hw, "Current CDCLK");
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 339/742] drm/i915/display: Flush the fbdev frontbuffer
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (329 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 338/742] drm/i915/cdclk: Ignore SWF18 in SKL CDCLK sanitization Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 340/742] drm/i915/dp_aux: Take the TypeC port lock after the PPS lock Greg Kroah-Hartman
` (395 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Maarten Lankhorst,
Jouni Högander, Mika Kahola, Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jouni Högander <jouni.hogander@intel.com>
commit f1f5942c3fdac3bb553d0019f60d11ca35f9b836 upstream.
fbdev invalidates on set_par, blank, pan_display and restore, but never
flushes. On i915, unrelated rendering may clear the bits; Xe has no
ORIGIN_CS invalidation, so PSR and FBC can remain disabled indefinitely.
Flush after these operations; they are already complete.
Fixes: 44e694958b95 ("drm/xe/display: Implement display support")
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: <stable@vger.kernel.org> # v6.8+
Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Link: https://patch.msgid.link/20261102100051.272137-5-jouni.hogander@intel.com
(cherry picked from commit ab965cbc781e4f4f8f81e48d01e0a0d78c94d369)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_fbdev.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -75,9 +75,10 @@ static struct intel_frontbuffer *to_fron
return ifbdev->fb->frontbuffer;
}
-static void intel_fbdev_invalidate(struct intel_fbdev *ifbdev)
+/* The console operation has already completed, hence flush not invalidate. */
+static void intel_fbdev_flush(struct intel_fbdev *ifbdev)
{
- intel_frontbuffer_invalidate(to_frontbuffer(ifbdev), ORIGIN_CPU);
+ intel_frontbuffer_flush(to_frontbuffer(ifbdev), ORIGIN_CPU);
}
FB_GEN_DEFAULT_DEFERRED_IOMEM_OPS(intel_fbdev,
@@ -91,7 +92,7 @@ static int intel_fbdev_set_par(struct fb
ret = drm_fb_helper_set_par(info);
if (ret == 0)
- intel_fbdev_invalidate(ifbdev);
+ intel_fbdev_flush(ifbdev);
return ret;
}
@@ -103,7 +104,7 @@ static int intel_fbdev_blank(int blank,
ret = drm_fb_helper_blank(blank, info);
if (ret == 0)
- intel_fbdev_invalidate(ifbdev);
+ intel_fbdev_flush(ifbdev);
return ret;
}
@@ -116,7 +117,7 @@ static int intel_fbdev_pan_display(struc
ret = drm_fb_helper_pan_display(var, info);
if (ret == 0)
- intel_fbdev_invalidate(ifbdev);
+ intel_fbdev_flush(ifbdev);
return ret;
}
@@ -180,7 +181,7 @@ static void intelfb_restore(struct drm_f
{
struct intel_fbdev *ifbdev = to_intel_fbdev(fb_helper);
- intel_fbdev_invalidate(ifbdev);
+ intel_fbdev_flush(ifbdev);
}
static void intelfb_set_suspend(struct drm_fb_helper *fb_helper, bool suspend)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 340/742] drm/i915/dp_aux: Take the TypeC port lock after the PPS lock
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (330 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 339/742] drm/i915/display: Flush the fbdev frontbuffer Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 341/742] drm/i915/dsb: Realign GOSUB only for QW slots 6 and 7 Greg Kroah-Hartman
` (394 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Mika Kahola, Imre Deak,
Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <imre.deak@intel.com>
commit 5a3ffd06d47d3a7694288327855d6faff42ec3c0 upstream.
An upcoming change will need to acquire a TypeC port link reference
along with an AUX power domain reference when enabling PPS VDD for the
port during an AUX transfer. Acquiring the link reference requires
holding the TypeC port lock.
To allow the PPS VDD code to take this lock itself, acquire the TypeC
port lock in the AUX transfer function only after locking PPS and
enabling VDD.
CC: stable@vger.kernel.org # 6.14+
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patch.msgid.link/20261029113017.618286-2-imre.deak@intel.com
(cherry picked from commit 86fabed8d8cf7db734a9a3f63af5f500cf0ed139)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_dp_aux.c | 39 +++++++++++++---------------
1 file changed, 19 insertions(+), 20 deletions(-)
--- a/drivers/gpu/drm/i915/display/intel_dp_aux.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_aux.c
@@ -270,22 +270,6 @@ intel_dp_aux_xfer(struct intel_dp *intel
for (i = 0; i < ARRAY_SIZE(ch_data); i++)
ch_data[i] = intel_dp->aux_ch_data_reg(intel_dp, i);
- intel_digital_port_lock(encoder);
- /*
- * Abort transfers on a disconnected port as required by
- * DP 1.4a link CTS 4.2.1.5, also avoiding the long AUX
- * timeouts that would otherwise happen.
- */
- if (!intel_dp_is_edp(intel_dp) &&
- !intel_digital_port_connected_locked(&dig_port->base)) {
- ret = -ENXIO;
- goto out_unlock;
- }
-
- aux_domain = intel_aux_power_domain(dig_port);
-
- aux_wakeref = intel_display_power_get(display, aux_domain);
-
/*
* The PPS state needs to be locked for:
* - eDP on all platforms, since AUX transfers on eDP need VDD power
@@ -308,6 +292,21 @@ intel_dp_aux_xfer(struct intel_dp *intel
*/
vdd = intel_pps_vdd_on_unlocked(intel_dp);
+ intel_digital_port_lock(encoder);
+ /*
+ * Abort transfers on a disconnected port as required by
+ * DP 1.4a link CTS 4.2.1.5, also avoiding the long AUX
+ * timeouts that would otherwise happen.
+ */
+ if (!intel_dp_is_edp(intel_dp) &&
+ !intel_digital_port_connected_locked(&dig_port->base)) {
+ ret = -ENXIO;
+ goto out_unlock;
+ }
+
+ aux_domain = intel_aux_power_domain(dig_port);
+ aux_wakeref = intel_display_power_get(display, aux_domain);
+
/*
* dp aux is extremely sensitive to irq latency, hence request the
* lowest possible wakeup latency and so prevent the cpu from going into
@@ -453,16 +452,16 @@ done:
out:
cpu_latency_qos_update_request(&intel_dp->pm_qos, PM_QOS_DEFAULT_VALUE);
+ intel_display_power_put_async(display, aux_domain, aux_wakeref);
+out_unlock:
+ intel_digital_port_unlock(encoder);
+
if (vdd)
intel_pps_vdd_off_unlocked(intel_dp, false);
if (pps_wakeref)
intel_pps_unlock(intel_dp, pps_wakeref);
- intel_display_power_put_async(display, aux_domain, aux_wakeref);
-out_unlock:
- intel_digital_port_unlock(encoder);
-
return ret;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 341/742] drm/i915/dsb: Realign GOSUB only for QW slots 6 and 7
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (331 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 340/742] drm/i915/dp_aux: Take the TypeC port lock after the PPS lock Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 342/742] drm/i915/mtl+: Use PHY type to identify TypeC ports in PLL ID lookup Greg Kroah-Hartman
` (393 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Hanson Wang, Ville Syrjälä,
Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hanson Wang <hanson.wang@ugreen.com>
commit 715f145f6204363a50853eb15719dc860db0bc01 upstream.
intel_dsb_gosub_align() moves free_pos to the next cacheline
unconditionally, but only clears the skipped bytes when at most two
QW slots remain. Wa_16024917128 forbids GOSUB in slots 6 and 7 only.
A larger gap is still executed. A Panther Lake DSB dump showed
nonzero data in that gap, with the tail at 0x58 and GOSUB at 0x80.
Advance free_pos only when the instruction would land in slot 6 or 7,
and fill that gap with NOPs. Emit GOSUB in place for every other slot.
intel_dsb_align_tail() still clears the rest of the cacheline.
Update free_pos inside the existing gap check in intel_dsb_align_tail()
as well, so the two helpers keep the same shape.
Fixes: 2c41d62f6fb1 ("drm/i915/dsb: Implement intel_dsb_gosub()")
Cc: stable@vger.kernel.org # v6.17+
Signed-off-by: Hanson Wang <hanson.wang@ugreen.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/20261106102315.1361645-1-hanson.wang@ugreen.com
(cherry picked from commit a2f5df6c5468b4f65e58c4125bba3f0e3cdc6aa1)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_dsb.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
--- a/drivers/gpu/drm/i915/display/intel_dsb.c
+++ b/drivers/gpu/drm/i915/display/intel_dsb.c
@@ -589,10 +589,10 @@ static void intel_dsb_align_tail(struct
tail = dsb->free_pos * 4;
aligned_tail = ALIGN(tail, CACHELINE_BYTES);
- if (aligned_tail > tail)
+ if (aligned_tail > tail) {
dsb_buffer_fill(dsb, dsb->free_pos, 0, aligned_tail - tail);
-
- dsb->free_pos = aligned_tail / 4;
+ dsb->free_pos = aligned_tail / 4;
+ }
}
static void intel_dsb_gosub_align(struct intel_dsb *dsb)
@@ -607,11 +607,15 @@ static void intel_dsb_gosub_align(struct
/*
* Wa_16024917128
* "Ensure GOSUB is not placed in cacheline QW slot 6 or 7 (numbered 0-7)"
+ *
+ * Move to the next cacheline only for those two slots. The skipped
+ * bytes stay in the programmed range, so fill them with NOPs. Any
+ * other slot can take the GOSUB directly.
*/
- if (aligned_tail - tail <= 2 * 8)
+ if (aligned_tail - tail <= 2 * 8) {
dsb_buffer_fill(dsb, dsb->free_pos, 0, aligned_tail - tail);
-
- dsb->free_pos = aligned_tail / 4;
+ dsb->free_pos = aligned_tail / 4;
+ }
}
void intel_dsb_gosub(struct intel_dsb *dsb,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 342/742] drm/i915/mtl+: Use PHY type to identify TypeC ports in PLL ID lookup
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (332 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 341/742] drm/i915/dsb: Realign GOSUB only for QW slots 6 and 7 Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 343/742] drm/i915/pps: Hold a TypeC link reference for PPS VDD Greg Kroah-Hartman
` (392 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Mika Kahola, Imre Deak,
Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <imre.deak@intel.com>
commit 522b0bdda49901113293f8b7e1aeb1c96ec41d85 upstream.
Use the PHY type to identify TypeC ports in the PLL ID lookup function.
This ensures that port B takes the TypeC path when an upcoming change
sets its PHY type to TypeC on PTL+ platforms with an eDP panel connected
to a TypeC PHY.
Keep the existing port >= PORT_TC1 case for BMG, where PORT_TC1 has a
a TypeC DDI (and so uses the TypeC DDI register addresses, has a C20 PHY
and the corresponding TC port -> PLL ID mapping), but this C20 PHY is
not a TypeC PHY (i.e. it's not controlled by the TypeC Subsystem and so
the driver doesn't need to run the TypeC PHY connect/disconnect,
power-on/power-off sequences for the PHY).
v2: Keep handling the BMG TypeC DDI but non-TypeC PHY cases. (Sashiko)
CC: stable@vger.kernel.org # 6.14+
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patch.msgid.link/20261030114456.651066-1-imre.deak@intel.com
(cherry picked from commit 493091a94dca1d832dc0349d1d7e7b3ad369cee7)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
+++ b/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
@@ -206,7 +206,8 @@ enum intel_dpll_id icl_tc_port_to_pll_id
enum intel_dpll_id mtl_port_to_pll_id(struct intel_display *display, enum port port)
{
- if (port >= PORT_TC1)
+ if (port >= PORT_TC1 ||
+ intel_phy_is_tc(display, intel_port_to_phy(display, port)))
return icl_tc_port_to_pll_id(intel_port_to_tc(display, port));
switch (port) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 343/742] drm/i915/pps: Hold a TypeC link reference for PPS VDD
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (333 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 342/742] drm/i915/mtl+: Use PHY type to identify TypeC ports in PLL ID lookup Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 344/742] drm/i915/pps: Reset PPS state after TypeC port init on resume Greg Kroah-Hartman
` (391 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Mika Kahola, Imre Deak,
Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <imre.deak@intel.com>
commit 2e28d9e416d3e9cfd3cb90addc2b0107fa000c33 upstream.
On TypeC ports, the AUX power domain reference held for PPS VDD requires
the TypeC mode to remain unchanged. Hold a TypeC link reference for the
lifetime of the PPS VDD power reference.
This prepares for an upcoming change that will use the TypeC port type
for eDP on TypeC ports. Allow the additional PPS link reference when
sanitizing the TypeC mode.
CC: stable@vger.kernel.org # 6.14+
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patch.msgid.link/20261029113017.618286-3-imre.deak@intel.com
(cherry picked from commit 3e2444989824139e342aa9affd10cd920255aabc)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_pps.c | 14 ++++++++++++++
drivers/gpu/drm/i915/display/intel_tc.c | 9 +++++++--
2 files changed, 21 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/i915/display/intel_pps.c
+++ b/drivers/gpu/drm/i915/display/intel_pps.c
@@ -23,6 +23,7 @@
#include "intel_pps.h"
#include "intel_pps_regs.h"
#include "intel_quirks.h"
+#include "intel_tc.h"
static void vlv_steal_power_sequencer(struct intel_display *display,
enum pipe pipe);
@@ -758,6 +759,9 @@ bool intel_pps_vdd_on_unlocked(struct in
if (edp_have_panel_vdd(intel_dp))
return need_to_disable;
+ if (intel_encoder_is_tc(&dig_port->base))
+ intel_tc_port_get_link(dig_port, 1);
+
drm_WARN_ON(display->drm, intel_dp->pps.vdd_wakeref);
intel_dp->pps.vdd_wakeref = intel_display_power_get(display,
intel_aux_power_domain(dig_port));
@@ -864,6 +868,9 @@ static void intel_pps_vdd_off_sync_unloc
intel_display_power_put(display,
intel_aux_power_domain(dig_port),
fetch_and_zero(&intel_dp->pps.vdd_wakeref));
+
+ if (intel_encoder_is_tc(&dig_port->base))
+ intel_tc_port_put_link(dig_port);
}
void intel_pps_vdd_off_sync(struct intel_dp *intel_dp)
@@ -1066,6 +1073,9 @@ void intel_pps_off_unlocked(struct intel
intel_display_power_put(display,
intel_aux_power_domain(dig_port),
fetch_and_zero(&intel_dp->pps.vdd_wakeref));
+
+ if (intel_encoder_is_tc(&dig_port->base))
+ intel_tc_port_put_link(dig_port);
}
void intel_pps_off(struct intel_dp *intel_dp)
@@ -1334,6 +1344,10 @@ static void pps_vdd_init(struct intel_dp
"[ENCODER:%d:%s] %s VDD left on by BIOS, adjusting state tracking\n",
dig_port->base.base.base.id, dig_port->base.base.name,
pps_name(intel_dp));
+
+ if (intel_encoder_is_tc(&dig_port->base))
+ intel_tc_port_get_link(dig_port, 1);
+
drm_WARN_ON(display->drm, intel_dp->pps.vdd_wakeref);
intel_dp->pps.vdd_wakeref = intel_display_power_get(display,
intel_aux_power_domain(dig_port));
--- a/drivers/gpu/drm/i915/display/intel_tc.c
+++ b/drivers/gpu/drm/i915/display/intel_tc.c
@@ -1669,7 +1669,7 @@ void intel_tc_port_sanitize_mode(struct
mutex_lock(&tc->lock);
- drm_WARN_ON(display->drm, tc->link_refcount != 1);
+ drm_WARN_ON(display->drm, tc->link_refcount < 1);
if (!tc_port_has_active_streams(tc, crtc_state)) {
/*
* TBT-alt is the default mode in any case the PHY ownership is not
@@ -1683,7 +1683,12 @@ void intel_tc_port_sanitize_mode(struct
"Port %s: PHY left in %s mode on disabled port, disconnecting it\n",
tc->port_name,
tc_port_mode_name(tc->init_mode));
- tc_phy_disconnect(tc);
+ /*
+ * A link reference taken during a preceding (eDP) connector initialization will be
+ * dropped later, also disconnecting the PHY.
+ */
+ if (tc->link_refcount == 1)
+ tc_phy_disconnect(tc);
__intel_tc_port_put_link(tc);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 344/742] drm/i915/pps: Reset PPS state after TypeC port init on resume
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (334 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 343/742] drm/i915/pps: Hold a TypeC link reference for PPS VDD Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 345/742] drm/i915/psr: Re-arm PSR after flush Greg Kroah-Hartman
` (390 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Mika Kahola, Imre Deak,
Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <imre.deak@intel.com>
commit af8b4d4817678a255ee310dbca983193cc09a075 upstream.
Resetting the PPS state involves acquiring an AUX power domain
reference. On TypeC ports, the AUX power domain depends on the TypeC
mode of the port using the PPS.
An upcoming change will set the port/PHY type to TypeC for eDP ports on
PTL+ platforms with an eDP DDI mapped to a TypeC PHY. Prepare for this by
resetting the PPS state on resume only after initializing the port's
TypeC mode.
CC: stable@vger.kernel.org # 6.14+
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patch.msgid.link/20261029113017.618286-4-imre.deak@intel.com
(cherry picked from commit 43eb42b332fe48ab8649bd5e4e0ef351473d8a4a)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_ddi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -4688,10 +4688,10 @@ static void intel_ddi_encoder_reset(stru
intel_dp->reset_link_params = true;
intel_dp_invalidate_source_oui(intel_dp);
- intel_pps_encoder_reset(intel_dp);
-
if (intel_encoder_is_tc(&dig_port->base))
intel_tc_port_init_mode(dig_port);
+
+ intel_pps_encoder_reset(intel_dp);
}
static int intel_ddi_encoder_late_register(struct drm_encoder *_encoder)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 345/742] drm/i915/psr: Re-arm PSR after flush
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (335 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 344/742] drm/i915/pps: Reset PPS state after TypeC port init on resume Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 346/742] drm/i915/psr: Clear CFF state on flip flush Greg Kroah-Hartman
` (389 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ambica Pramod, Jouni Högander,
Mika Kahola, Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jouni Högander <jouni.hogander@intel.com>
commit 4247f4e2c10eac8c17fc23c2db0e14911b1ba5ff upstream.
An ORIGIN_FLIP flush can clear the last busy frontbuffer bits without
queuing the work that re-arms PSR.
Queue the re-arm work after each flush when PSR is inactive and no
frontbuffers are busy.
Move also pipe_frontbuffer_bits ==0 check to done right after pipe
frontbuffer bits are figured out. Anyways nothing is currently done after
in intel_psr_flush if the bits are 0.
v2: Do not re-activate PSR on other pipe frontbuffer bits.
Fixes: ef39826c12b4 ("drm/i915/display: Fix glitches when moving cursor with PSR2 selective fetch enabled")
Cc: <stable@vger.kernel.org> # v5.16+
Tested-by: Ambica Pramod <ambica.pramod@intel.com>
Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Link: https://patch.msgid.link/20261102100051.272137-3-jouni.hogander@intel.com
(cherry picked from commit 731ed8af13bdead02924b39a8c01d5f60d6a2e68)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_psr.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
--- a/drivers/gpu/drm/i915/display/intel_psr.c
+++ b/drivers/gpu/drm/i915/display/intel_psr.c
@@ -3672,9 +3672,6 @@ static void _psr_flush_handle(struct int
*/
intel_psr_force_update(intel_dp);
}
-
- if (!intel_dp->psr.active && !intel_dp->psr.busy_frontbuffer_bits)
- queue_work(display->wq.unordered, &intel_dp->psr.work);
}
/**
@@ -3707,6 +3704,10 @@ void intel_psr_flush(struct intel_displa
pipe_frontbuffer_bits &=
INTEL_FRONTBUFFER_ALL_MASK(intel_dp->psr.pipe);
+
+ if (pipe_frontbuffer_bits == 0)
+ goto unlock;
+
intel_dp->psr.busy_frontbuffer_bits &= ~pipe_frontbuffer_bits;
/*
@@ -3721,13 +3722,14 @@ void intel_psr_flush(struct intel_displa
psr2_dc3co_flush_locked(intel_dp, frontbuffer_bits);
if (origin == ORIGIN_FLIP)
- goto unlock;
-
- if (pipe_frontbuffer_bits == 0)
- goto unlock;
+ goto rearm;
/* By definition flush = invalidate + flush */
_psr_flush_handle(intel_dp);
+
+rearm:
+ if (!intel_dp->psr.active && !intel_dp->psr.busy_frontbuffer_bits)
+ queue_work(display->wq.unordered, &intel_dp->psr.work);
unlock:
mutex_unlock(&intel_dp->psr.lock);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 346/742] drm/i915/psr: Clear CFF state on flip flush
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (336 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 345/742] drm/i915/psr: Re-arm PSR after flush Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 347/742] drm/i915/ptl+: Add TypeC HPD pin selection for port B Greg Kroah-Hartman
` (388 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jouni Högander, Mika Kahola,
Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jouni Högander <jouni.hogander@intel.com>
commit 9bf9ced37e60a6c947a481385cd9ed919f14cf36 upstream.
An ORIGIN_FLIP flush can clear the last busy frontbuffer bits without
running _psr_flush_handle(), leaving the CFF state flag set.
Clear CFF state when no frontbuffer bits remain busy, and queue PSR
work only when inactive and not paused.
Fixes: 805f04d42a6b ("drm/i915/display/psr: Use continuos full frame to handle frontbuffer invalidations")
Cc: <stable@vger.kernel.org> # v5.19+
Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Link: https://patch.msgid.link/20261102100051.272137-4-jouni.hogander@intel.com
(cherry picked from commit 233e3453eb705c0434f6f8467f211f0250c5832b)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_psr.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
--- a/drivers/gpu/drm/i915/display/intel_psr.c
+++ b/drivers/gpu/drm/i915/display/intel_psr.c
@@ -3648,12 +3648,6 @@ static void _psr_flush_handle(struct int
intel_psr_exit(intel_dp);
} else if (intel_dp->psr.psr2_sel_fetch_enabled) {
/* Selective fetch prior LNL */
- if (intel_dp->psr.psr2_sel_fetch_cff_enabled) {
- /* can we turn CFF off? */
- if (intel_dp->psr.busy_frontbuffer_bits == 0)
- intel_dp->psr.psr2_sel_fetch_cff_enabled = false;
- }
-
/*
* Still keep cff bit enabled as we don't have proper SU
* configuration in case update is sent for any reason after
@@ -3710,13 +3704,8 @@ void intel_psr_flush(struct intel_displa
intel_dp->psr.busy_frontbuffer_bits &= ~pipe_frontbuffer_bits;
- /*
- * If the PSR is paused by an explicit intel_psr_paused() call,
- * we have to ensure that the PSR is not activated until
- * intel_psr_resume() is called.
- */
if (intel_dp->psr.pause_counter)
- goto unlock;
+ goto rearm;
if (origin == ORIGIN_FLIP || origin == ORIGIN_CURSOR_UPDATE)
psr2_dc3co_flush_locked(intel_dp, frontbuffer_bits);
@@ -3728,8 +3717,20 @@ void intel_psr_flush(struct intel_displa
_psr_flush_handle(intel_dp);
rearm:
- if (!intel_dp->psr.active && !intel_dp->psr.busy_frontbuffer_bits)
- queue_work(display->wq.unordered, &intel_dp->psr.work);
+ if (!intel_dp->psr.busy_frontbuffer_bits) {
+ if (intel_dp->psr.psr2_sel_fetch_cff_enabled)
+ intel_dp->psr.psr2_sel_fetch_cff_enabled = false;
+
+ /*
+ * If the PSR is paused by an explicit
+ * intel_psr_paused() call, we have to ensure that the
+ * PSR is not activated until intel_psr_resume() is
+ * called.
+ */
+ if (!intel_dp->psr.active && !intel_dp->psr.pause_counter)
+ queue_work(display->wq.unordered, &intel_dp->psr.work);
+ }
+
unlock:
mutex_unlock(&intel_dp->psr.lock);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 347/742] drm/i915/ptl+: Add TypeC HPD pin selection for port B
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (337 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 346/742] drm/i915/psr: Clear CFF state on flip flush Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 348/742] drm/i915/ptl+: Fix TypeC detection for eDP on " Greg Kroah-Hartman
` (387 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Mika Kahola, Imre Deak,
Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <imre.deak@intel.com>
commit 899f7dc007391b8e3fd514b30645cdb263970db3 upstream.
Handle the TypeC PHY on port B case while mapping the port to an HPD
pin. This prepares for an upcoming change that will set port B's PHY
type to TypeC on PTL+ platforms with an eDP panel connected to a TypeC
PHY.
Keep the existing port >= PORT_TC1 case and its HPD pin mapping for
DG2, where PORT_TC1 has a non-TypeC PHY.
CC: stable@vger.kernel.org # 6.14+
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patch.msgid.link/20261029113017.618286-5-imre.deak@intel.com
(cherry picked from commit 0f35ced2b44db21527cdb80065e80693fb0ab563)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_ddi.c | 2 ++
1 file changed, 2 insertions(+)
--- a/drivers/gpu/drm/i915/display/intel_ddi.c
+++ b/drivers/gpu/drm/i915/display/intel_ddi.c
@@ -5018,6 +5018,8 @@ static enum hpd_pin xelpd_hpd_pin(struct
return HPD_PORT_D + port - PORT_D_XELPD;
else if (port >= PORT_TC1)
return HPD_PORT_TC1 + port - PORT_TC1;
+ else if (intel_phy_is_tc(display, intel_port_to_phy(display, port)))
+ return HPD_PORT_TC1 + intel_port_to_tc(display, port) - TC_PORT_1;
else
return HPD_PORT_A + port - PORT_A;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 348/742] drm/i915/ptl+: Fix TypeC detection for eDP on port B
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (338 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 347/742] drm/i915/ptl+: Add TypeC HPD pin selection for port B Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 349/742] drm/meson: encoder_dsi: load ENCL gamma table while ENCL is disabled Greg Kroah-Hartman
` (386 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Mika Kahola, Imre Deak,
Joonas Lahtinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <imre.deak@intel.com>
commit b8c29d1e64a712decce01e3671bf7e6ec6bd70a0 upstream.
On PTL+ platforms with eDP on TypeC, port B's DDI is connected to a C20
TypeC PHY. Identify PHY B as TypeC and map port B to TC_PORT_1 when eDP
TypeC support is enabled.
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/9196
CC: stable@vger.kernel.org # 6.14+
Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patch.msgid.link/20261029113017.618286-7-imre.deak@intel.com
(cherry picked from commit 20e3d954f70486bf14000fc1a6dac7c34e6e4f07)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/display/intel_display.c | 11 +++++++++++
1 file changed, 11 insertions(+)
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -1843,6 +1843,11 @@ bool intel_phy_is_combo(struct intel_dis
return false;
}
+static bool intel_phy_is_edp_on_tc(struct intel_display *display, enum phy phy)
+{
+ return DISPLAY_RUNTIME_INFO(display)->edp_typec_support && phy == PHY_B;
+}
+
/*
* This function returns true if the DDI port respective to the PHY enumeration
* is a Type-C capable port.
@@ -1863,6 +1868,9 @@ bool intel_phy_is_tc(struct intel_displa
if (display->platform.dgfx)
return false;
+ if (intel_phy_is_edp_on_tc(display, phy))
+ return true;
+
if (DISPLAY_VER(display) >= 13)
return phy >= PHY_F && phy <= PHY_I;
else if (display->platform.tigerlake)
@@ -1909,6 +1917,9 @@ enum phy intel_port_to_phy(struct intel_
*/
enum tc_port intel_port_to_tc(struct intel_display *display, enum port port)
{
+ if (intel_phy_is_edp_on_tc(display, intel_port_to_phy(display, port)))
+ return TC_PORT_1;
+
if (DISPLAY_VER(display) >= 12)
return TC_PORT_1 + port - PORT_TC1;
else
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 349/742] drm/meson: encoder_dsi: load ENCL gamma table while ENCL is disabled
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (339 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 348/742] drm/i915/ptl+: Fix TypeC detection for eDP on " Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 350/742] drm/nouveau/bar: take the GSP-RM flush pointer from the BAR2 io_mapping Greg Kroah-Hartman
` (385 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, John Williams, Shigeaki Asai,
Neil Armstrong
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shigeaki Asai <y-asai.0816@docomonet.jp>
commit 0cb7f6d9e4b1d0a411b628ccf78695ad41c66570 upstream.
meson_encoder_dsi_atomic_enable() programmed the ENCL gamma LUT right
after meson_venc_mipi_dsi_mode_set(), i.e. while the ENCL timing
generator was already running (ENCL_VIDEO_EN=1). Writing the LUT
during active video stalls the hardware: L_GAMMA_CNTL_PORT
WR_RDY/ADR_RDY deassert and the ENCL line counter (ENCL_INFO_READ)
freezes, so every remaining write times out (~8s total at boot) and
the panel ends up with a corrupted gamma table (wrong colors).
Instrumented boots on the ODROID-GO Ultra (S922X) show:
failing: start: VIDEO_EN=1 INFO 0000001a->002d0000 GAMMA_CNTL=00000030
stall: INFO 002d0000->002d0000 GAMMA_CNTL=00000000
(VID_CLK_CNTL2 / VIID_CLK_CNTL / VIID_CLK_DIV unchanged,
i.e. the ENCL clock is still running)
fixed: start: VIDEO_EN=0 INFO 00000000->00000000 GAMMA_CNTL=00000030
no stall, no timeout
Whether it failed depended only on timing, which is why enabling
lock debugging (LOCKDEP etc.) appeared to "fix" it most of the time.
It happens regardless of the bootloader (mainline or Hardkernel vendor
U-Boot).
The function already writes ENCL_VIDEO_EN=0 right afterwards before
re-enabling the encoder, so simply move meson_encl_load_gamma() after
that write. This matches the order used by the vendor U-Boot's own LCD
driver, which never times out.
Tested on the ODROID-GO Ultra with mainline U-Boot: 5 cold boots +
3 warm reboots, no timeouts, correct colors, LOCKDEP disabled.
Fixes: 42dcf15f901c ("drm/meson: add DSI encoder")
Cc: stable@vger.kernel.org
Tested-by: John Williams <porschemad911@gmail.com>
Signed-off-by: Shigeaki Asai <y-asai.0816@docomonet.jp>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patch.msgid.link/20261004-meson-gamma-v1-1-6347558e2bb3@docomonet.jp
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/meson/meson_encoder_dsi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/gpu/drm/meson/meson_encoder_dsi.c
+++ b/drivers/gpu/drm/meson/meson_encoder_dsi.c
@@ -65,9 +65,9 @@ static void meson_encoder_dsi_atomic_ena
/* ENCL clock setup is handled by CCF */
meson_venc_mipi_dsi_mode_set(priv, &crtc_state->adjusted_mode);
- meson_encl_load_gamma(priv);
writel_relaxed(0, priv->io_base + _REG(ENCL_VIDEO_EN));
+ meson_encl_load_gamma(priv);
writel_bits_relaxed(ENCL_VIDEO_MODE_ADV_VFIFO_EN, ENCL_VIDEO_MODE_ADV_VFIFO_EN,
priv->io_base + _REG(ENCL_VIDEO_MODE_ADV));
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 350/742] drm/nouveau/bar: take the GSP-RM flush pointer from the BAR2 io_mapping
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (340 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 349/742] drm/meson: encoder_dsi: load ENCL gamma table while ENCL is disabled Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 351/742] drm/nouveau/disp: Set drm_mode_config_funcs.atomic_(check|commit) (attempt 2) Greg Kroah-Hartman
` (384 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Mohamed Ahmed, Thomas Andersen,
Dave Airlie
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
commit 4ffab70118f8691ee68c1a24091a36c16957b6dd upstream.
r535_bar_new_() maps the first page of BAR2 with ioremap(), to flush
BAR2 writes with a read while flushFBZero is not mapped. On x86 with
PAT, a mapping that overlaps an existing one gets its type. The instmem
io_mapping is created later, so with GSP-RM it is also mapped UC- and
its writes are not write-combined.
Take the flush pointer from the io_mapping. A new bar2.oneinit hook
sets it up once the BAR2 page tables are bootstrapped and the
io_mapping exists.
Fixes: 34e27b90552a ("nouveau/instmem: use iomapping interface for instmem handling")
Cc: stable@vger.kernel.org
Signed-off-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
Tested-by: Thomas Andersen <phomes@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20261117214352.337961-3-mohamedahmedegypt2001@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c | 6 +++
drivers/gpu/drm/nouveau/nvkm/subdev/bar/priv.h | 1
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/bar.c | 32 +++++++++++++-----
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c | 8 ++++
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h | 3 +
5 files changed, 42 insertions(+), 8 deletions(-)
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/gf100.c
@@ -133,6 +133,12 @@ gf100_bar_oneinit(struct nvkm_bar *base)
if (ret)
return ret;
+ if (bar->base.func->bar2.oneinit) {
+ ret = bar->base.func->bar2.oneinit(&bar->base);
+ if (ret)
+ return ret;
+ }
+
bar->base.subdev.oneinit = true;
nvkm_bar_bar2_init(bar->base.subdev.device);
}
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bar/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bar/priv.h
@@ -16,6 +16,7 @@ struct nvkm_bar_func {
void (*init)(struct nvkm_bar *);
struct {
+ int (*oneinit)(struct nvkm_bar *);
void (*init)(struct nvkm_bar *);
void (*fini)(struct nvkm_bar *);
void (*wait)(struct nvkm_bar *);
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/bar.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/bar.c
@@ -24,9 +24,11 @@
#include <core/mm.h>
#include <subdev/fb.h>
#include <subdev/gsp.h>
-#include <subdev/instmem.h>
+#include <subdev/instmem/priv.h>
#include <subdev/mmu/vmm.h>
+#include <linux/io-mapping.h>
+
#include "nvrm/bar.h"
#include "nvrm/rpcfn.h"
@@ -65,6 +67,25 @@ r535_bar_bar2_update_pde(struct nvkm_gsp
return nvkm_gsp_rpc_wr(gsp, rpc, NVKM_GSP_RPC_REPLY_RECV);
}
+static int
+r535_bar_bar2_oneinit(struct nvkm_bar *bar)
+{
+ struct io_mapping *iomap = nv50_instmem_bar2_iomap(bar->subdev.device->imem);
+
+ if (!iomap)
+ return -ENOMEM;
+
+ /* BAR2 writes are flushed by a read. While flushFBZero is not mapped,
+ * read the first page of the BAR2 io_mapping.
+ */
+ bar->flushBAR2PhysMode = io_mapping_map_wc(iomap, 0, PAGE_SIZE);
+ if (!bar->flushBAR2PhysMode)
+ return -ENOMEM;
+
+ bar->flushBAR2 = bar->flushBAR2PhysMode;
+ return 0;
+}
+
static void
r535_bar_bar2_fini(struct nvkm_bar *bar)
{
@@ -155,7 +176,7 @@ r535_bar_dtor(struct nvkm_bar *bar)
nvkm_memory_unref(&bar->flushFBZero);
if (bar->flushBAR2PhysMode)
- iounmap(bar->flushBAR2PhysMode);
+ io_mapping_unmap(bar->flushBAR2PhysMode);
kfree(bar->func);
return data;
@@ -178,6 +199,7 @@ r535_bar_new_(const struct nvkm_bar_func
rm->bar1.fini = r535_bar_bar1_fini;
rm->bar1.wait = r535_bar_bar1_wait;
rm->bar1.vmm = hw->bar1.vmm;
+ rm->bar2.oneinit = r535_bar_bar2_oneinit;
rm->bar2.init = r535_bar_bar2_init;
rm->bar2.fini = r535_bar_bar2_fini;
rm->bar2.wait = r535_bar_bar2_wait;
@@ -191,12 +213,6 @@ r535_bar_new_(const struct nvkm_bar_func
}
*pbar = bar;
- bar->flushBAR2PhysMode = ioremap(device->func->resource_addr(device, NVKM_BAR2_INST), PAGE_SIZE);
- if (!bar->flushBAR2PhysMode)
- return -ENOMEM;
-
- bar->flushBAR2 = bar->flushBAR2PhysMode;
-
gf100_bar(*pbar)->bar2_halve = true;
return 0;
}
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
@@ -436,6 +436,14 @@ nv50_instmem_dtor(struct nvkm_instmem *b
return imem;
}
+struct io_mapping *
+nv50_instmem_bar2_iomap(struct nvkm_instmem *base)
+{
+ struct nv50_instmem *imem = nv50_instmem(base);
+
+ return imem->iomap.size ? &imem->iomap : NULL;
+}
+
static const struct nvkm_instmem_func
nv50_instmem = {
.dtor = nv50_instmem_dtor,
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h
@@ -4,6 +4,8 @@
#define nvkm_instmem(p) container_of((p), struct nvkm_instmem, subdev)
#include <subdev/instmem.h>
+struct io_mapping;
+
struct nvkm_instmem_func {
void *(*dtor)(struct nvkm_instmem *);
int (*oneinit)(struct nvkm_instmem *);
@@ -27,6 +29,7 @@ int nv50_instobj_new(struct nvkm_instmem
int nv50_instobj_wrap(struct nvkm_instmem *, struct nvkm_memory *vram,
struct nvkm_memory **bar2);
void *nv50_instmem_dtor(struct nvkm_instmem *base);
+struct io_mapping *nv50_instmem_bar2_iomap(struct nvkm_instmem *base);
void nvkm_instmem_ctor(const struct nvkm_instmem_func *, struct nvkm_device *,
enum nvkm_subdev_type, int, struct nvkm_instmem *);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 351/742] drm/nouveau/disp: Set drm_mode_config_funcs.atomic_(check|commit) (attempt 2)
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (341 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 350/742] drm/nouveau/bar: take the GSP-RM flush pointer from the BAR2 io_mapping Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 352/742] drm/nouveau/gsp: only handle GSP interrupts routed to the host Greg Kroah-Hartman
` (383 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ruben Wauters, Lyude Paul,
Dave Airlie
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Airlie <airlied@redhat.com>
commit ed7fb901fce31588bd12ab95adc36ebcb51bc8ea upstream.
commit 604826acb3f5 attempted to add these flags but
commit 6c65db809796 reverted it due to it
failing on hw from pre-atomic times.
So use a second set of functions.
original commit msg from Lyude:
"Apparently we never actually filled these in, despite the fact that we do
in fact technically support atomic modesetting.
Since not having these filled in causes us to potentially forget to disable
fbdev and friends during suspend/resume, let's fix it."
Reported-by: Ruben Wauters <rubenru09@aol.com>
Closes: https://gitlab.freedesktop.org/drm/nouveau/-/work_items/517
Fixes: 6c65db809796 ("Revert "drm/nouveau/disp: Set drm_mode_config_funcs.atomic_(check|commit)"")
Cc: stable@vger.kernel.org
Reviewed-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20261111-nouveau-atomic-fix-v1-1-118e65d3a2f5@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/nouveau/nouveau_display.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -354,6 +354,11 @@ static const struct drm_mode_config_func
.fb_create = nouveau_user_framebuffer_create,
};
+static const struct drm_mode_config_funcs nouveau_mode_config_funcs_atomic = {
+ .fb_create = nouveau_user_framebuffer_create,
+ .atomic_commit = drm_atomic_helper_commit,
+ .atomic_check = drm_atomic_helper_check,
+};
struct nouveau_drm_prop_enum_list {
u8 gen_mask;
@@ -654,7 +659,11 @@ nouveau_display_create(struct drm_device
drm_mode_create_scaling_mode_property(dev);
drm_mode_create_dvi_i_properties(dev);
- dev->mode_config.funcs = &nouveau_mode_config_funcs;
+ /* this only gets set if the driver has the ATOMIC flag */
+ if (drm_drv_uses_atomic_modeset(dev))
+ dev->mode_config.funcs = &nouveau_mode_config_funcs_atomic;
+ else
+ dev->mode_config.funcs = &nouveau_mode_config_funcs;
dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 352/742] drm/nouveau/gsp: only handle GSP interrupts routed to the host
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (342 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 351/742] drm/nouveau/disp: Set drm_mode_config_funcs.atomic_(check|commit) (attempt 2) Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 353/742] drm/nouveau/instmem: map only the part of BAR2 that is used Greg Kroah-Hartman
` (382 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Joe Finzel, Dave Airlie
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Finzel <joe@sudmix.de>
commit 54d3ff1b5ac08d0e28029b93a1719ddd9ff670a4 upstream.
The GSP's interrupt handler takes every pending interrupt the RISC-V
IRQMASK enables as its own, without looking at IRQDEST, which says
whether an interrupt goes to the host or to the GSP itself. One that
belongs to GSP-RM, pending when the host's handler runs for the message
queue, is reported as unknown, cleared and masked off with IRQMCLR,
taking it away from the firmware:
nouveau 0000:01:00.0: gsp: intr 00040000
NVIDIA's driver reads the interrupts routed to the host as
IRQSTAT & IRQMASK & IRQDEST (kflcnRiscvReadIntrStatus_TU102() and
_GA102()). Do the same, with IRQDEST from NVIDIA's register headers
next to IRQMASK on each falcon.
Seen once in a few boots on an RTX 3070 Ti (GA104, GSP-RM 570.144),
before the login prompt. There IRQMASK reads 0x01049042 and IRQDEST
0x01000040: 0x00040000 is enabled but routed to the GSP.
Fixes: 830531e94712 ("drm/nouveau/gsp/r535: add interrupt handling")
Cc: stable@vger.kernel.org
Signed-off-by: Joe Finzel <joe@sudmix.de>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20261023-nouveau-gsp-irqdest-v1-1-5dd6131faa14@sudmix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/nouveau/include/nvkm/engine/falcon.h | 1 +
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga100.c | 1 +
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga102.c | 1 +
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c | 4 +++-
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c | 1 +
5 files changed, 7 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/nouveau/include/nvkm/engine/falcon.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/engine/falcon.h
@@ -63,6 +63,7 @@ struct nvkm_falcon_func {
int (*select)(struct nvkm_falcon *);
u32 addr2;
u32 riscv_irqmask;
+ u32 riscv_irqdest;
bool reset_pmc;
int (*reset_eng)(struct nvkm_falcon *);
int (*reset_prep)(struct nvkm_falcon *);
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga100.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga100.c
@@ -27,6 +27,7 @@ ga100_gsp_flcn = {
.enable = gm200_flcn_enable,
.addr2 = 0x1000,
.riscv_irqmask = 0x2b4,
+ .riscv_irqdest = 0x2b8,
.reset_eng = gp102_flcn_reset_eng,
.reset_wait_mem_scrubbing = gm200_flcn_reset_wait_mem_scrubbing,
.bind_inst = gm200_flcn_bind_inst,
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/ga102.c
@@ -140,6 +140,7 @@ ga102_gsp_flcn = {
.select = ga102_flcn_select,
.addr2 = 0x1000,
.riscv_irqmask = 0x528,
+ .riscv_irqdest = 0x52c,
.reset_eng = gp102_flcn_reset_eng,
.reset_prep = ga102_flcn_reset_prep,
.reset_wait_mem_scrubbing = ga102_flcn_reset_wait_mem_scrubbing,
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c
@@ -64,7 +64,9 @@ r535_gsp_intr(struct nvkm_inth *inth)
u32 intr = nvkm_falcon_rd32(&gsp->falcon, 0x0008);
u32 inte = nvkm_falcon_rd32(&gsp->falcon, gsp->falcon.func->addr2 +
gsp->falcon.func->riscv_irqmask);
- u32 stat = intr & inte;
+ u32 dest = nvkm_falcon_rd32(&gsp->falcon, gsp->falcon.func->addr2 +
+ gsp->falcon.func->riscv_irqdest);
+ u32 stat = intr & inte & dest;
if (!stat) {
nvkm_debug(subdev, "inte %08x %08x\n", intr, inte);
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c
@@ -420,6 +420,7 @@ tu102_gsp_flcn = {
.enable = gm200_flcn_enable,
.addr2 = 0x1000,
.riscv_irqmask = 0x2b4,
+ .riscv_irqdest = 0x2b8,
.reset_eng = gp102_flcn_reset_eng,
.reset_wait_mem_scrubbing = gm200_flcn_reset_wait_mem_scrubbing,
.bind_inst = gm200_flcn_bind_inst,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 353/742] drm/nouveau/instmem: map only the part of BAR2 that is used
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (343 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 352/742] drm/nouveau/gsp: only handle GSP interrupts routed to the host Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 354/742] drm/nouveau: do not return early from a synchronous VM_BIND Greg Kroah-Hartman
` (381 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Mohamed Ahmed, Thomas Andersen,
Dave Airlie
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
commit 7488ee210542b918b9c5749a29fd1502c49a0665 upstream.
The io_mapping covers the whole BAR2 resource. With GSP-RM and with
NvBar2Halve the BAR2 address space covers only its lower half. The
driver maps nothing in the upper half, and a mapping that already
exists there would give the io_mapping its type.
Size the io_mapping to the BAR2 address space. The range does not
change where BAR2 is not halved.
Fixes: 34e27b90552a ("nouveau/instmem: use iomapping interface for instmem handling")
Cc: stable@vger.kernel.org
Signed-off-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
Tested-by: Thomas Andersen <phomes@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20261117214352.337961-4-mohamedahmedegypt2001@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
@@ -191,16 +191,17 @@ nv50_instobj_map(struct nvkm_memory *mem
}
static bool
-check_io_mapping(struct nv50_instmem *imem)
+check_io_mapping(struct nv50_instmem *imem, struct nvkm_vmm *vmm)
{
struct nvkm_device *device = imem->base.subdev.device;
if (imem->iomap.size)
return true;
+ /* Map the part of BAR2 that its address space covers. */
return io_mapping_init_wc(&imem->iomap,
device->func->resource_addr(device, NVKM_BAR2_INST),
- device->func->resource_size(device, NVKM_BAR2_INST)) != NULL;
+ vmm->limit - vmm->start) != NULL;
}
static void
@@ -293,10 +294,10 @@ nv50_instobj_boot(struct nvkm_memory *me
}
/*
- * boot is only called on BAR2, if we can't remap the complete
- * BAR it's unlikely things are functioning well.
+ * boot is only called on BAR2. If we can't map it, it's unlikely
+ * things are functioning well.
*/
- if (check_io_mapping(iobj->imem))
+ if (check_io_mapping(iobj->imem, vmm))
nv50_instobj_kmap(iobj, vmm);
nvkm_instmem_boot(imem);
mutex_unlock(&imem->mutex);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 354/742] drm/nouveau: do not return early from a synchronous VM_BIND
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (344 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 353/742] drm/nouveau/instmem: map only the part of BAR2 that is used Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 355/742] drm/radeon: Bound GPIO I2C table entry count from VBIOS Greg Kroah-Hartman
` (380 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Mohamed Ahmed, Thomas Andersen,
Dave Airlie
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
commit b1939b201353d803f09a8eb07aa69e44f8441701 upstream.
A synchronous VM_BIND waits for its job with an interruptible wait and
ignores the result. On a signal the ioctl returns 0 while the job is
still queued. Userspace can then use the new mappings before the page
tables are written, and the channel can take an MMU fault.
Wait uninterruptibly. A synchronous job takes no syncobjs, so only the
jobs queued before it on the same scheduler can delay it.
Fixes: b88baab82871 ("drm/nouveau: implement new VM_BIND uAPI")
Cc: stable@vger.kernel.org
Signed-off-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
Tested-by: Thomas Andersen <phomes@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patch.msgid.link/20261117214352.337961-2-mohamedahmedegypt2001@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/nouveau/nouveau_sched.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/nouveau/nouveau_sched.c
+++ b/drivers/gpu/drm/nouveau/nouveau_sched.c
@@ -328,7 +328,11 @@ nouveau_job_submit(struct nouveau_job *j
mutex_unlock(&sched->mutex);
if (done_fence) {
- dma_fence_wait(done_fence, true);
+ /* The job is queued and its VA space changes are applied. It
+ * can neither be restarted nor reported as failed, so wait
+ * until it has run.
+ */
+ dma_fence_wait(done_fence, false);
dma_fence_put(done_fence);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 355/742] drm/radeon: Bound GPIO I2C table entry count from VBIOS
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (345 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 354/742] drm/nouveau: do not return early from a synchronous VM_BIND Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 356/742] drm/radeon: only unregister the ATPX handler if we registered it Greg Kroah-Hartman
` (379 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Andrey Misiurov
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Misiurov <amisiurov@cloudlinux.com>
commit 7345797c8652c976d18dc4be4bae632557c3bc38 upstream.
radeon_atombios_i2c_init() derives the number of GPIO I2C entries from
the size field of the VBIOS GPIO_I2C_Info table and stores a bus for
every valid entry in rdev->i2c_bus[i], which has RADEON_MAX_I2C_BUS
(16) slots. A table that claims more than 16 entries makes it write
past the end of the array into the rest of struct radeon_device. A
size smaller than the common header wraps the subtraction and the loop
walks far past the table. radeon_lookup_i2c_gpio() uses the same
calculation.
Reject undersized tables and cap the entry count at
RADEON_MAX_I2C_BUS.
Fixes: f376b94fbc0a ("drm/radeon/kms: unify i2c handling")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Andrey Misiurov <amisiurov@cloudlinux.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit ad5ddb2f77ff5e80b3c793f062dc1cad9907a2b9)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/radeon/radeon_atombios.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -125,6 +125,22 @@ static struct radeon_i2c_bus_rec radeon_
return i2c;
}
+/*
+ * The VBIOS table size is not checked against the image; cap the
+ * entry count to RADEON_MAX_I2C_BUS, the size of rdev->i2c_bus[].
+ */
+static int radeon_atombios_gpio_i2c_num_entries(uint16_t size)
+{
+ u32 bytes;
+
+ if (size < sizeof(ATOM_COMMON_TABLE_HEADER))
+ return 0;
+
+ bytes = size - sizeof(ATOM_COMMON_TABLE_HEADER);
+ return min_t(u32, bytes / sizeof(ATOM_GPIO_I2C_ASSIGMENT),
+ RADEON_MAX_I2C_BUS);
+}
+
static struct radeon_i2c_bus_rec radeon_lookup_i2c_gpio(struct radeon_device *rdev,
uint8_t id)
{
@@ -142,8 +158,7 @@ static struct radeon_i2c_bus_rec radeon_
if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) {
i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
- num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) /
- sizeof(ATOM_GPIO_I2C_ASSIGMENT);
+ num_indices = radeon_atombios_gpio_i2c_num_entries(size);
gpio = &i2c_info->asGPIO_Info[0];
for (i = 0; i < num_indices; i++) {
@@ -176,8 +191,7 @@ void radeon_atombios_i2c_init(struct rad
if (atom_parse_data_header(ctx, index, &size, NULL, NULL, &data_offset)) {
i2c_info = (struct _ATOM_GPIO_I2C_INFO *)(ctx->bios + data_offset);
- num_indices = (size - sizeof(ATOM_COMMON_TABLE_HEADER)) /
- sizeof(ATOM_GPIO_I2C_ASSIGMENT);
+ num_indices = radeon_atombios_gpio_i2c_num_entries(size);
gpio = &i2c_info->asGPIO_Info[0];
for (i = 0; i < num_indices; i++) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 356/742] drm/radeon: only unregister the ATPX handler if we registered it
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (346 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 355/742] drm/radeon: Bound GPIO I2C table entry count from VBIOS Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 357/742] drm/sched: Ensure stopped entity cannot be re-added to the run-queue Greg Kroah-Hartman
` (378 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Jiaming Fan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Fan <fan.jiaming@hotmail.com>
commit 83876755d089321e426a58f365a31b27b2c77f3b upstream.
radeon_register_atpx_handler() registers the ATPX handler with
vga_switcheroo only when ATPX is detected, and ignores the result:
vga_switcheroo has a single handler slot and refuses a second handler
with -EINVAL. radeon_unregister_atpx_handler() calls
vga_switcheroo_unregister_handler() in either case, and that clears the
slot no matter who set it.
So unloading radeon removes a handler registered by another driver, such
as apple-gmux. No Radeon GPU is needed for this; loading and unloading
radeon is enough. amdgpu is another such driver: when radeon and amdgpu
are both loaded and both detect ATPX, only the first one gets the slot,
and unloading the other one clears it. Afterwards vga_switcheroo can no
longer switch outputs, and a client that uses the vga_switcheroo runtime
PM domain, such as nouveau on a non-Optimus machine with a v1 DSM, can
dereference the now NULL handler during runtime suspend.
Record whether the registration succeeded and unregister only in that
case. amdgpu has the same problem and gets the same fix.
Fixes: 6a9ee8af344e ("vga_switcheroo: initial implementation (v15)")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jiaming Fan <fan.jiaming@hotmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit f90ef5de500fa47d8e2371d429700f0275e0b88d)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/radeon/radeon_atpx_handler.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -34,6 +34,7 @@ struct radeon_atpx {
static struct radeon_atpx_priv {
bool atpx_detected;
bool bridge_pm_usable;
+ bool handler_registered;
/* handle for device - and atpx */
acpi_handle dhandle;
struct radeon_atpx atpx;
@@ -605,7 +606,8 @@ void radeon_register_atpx_handler(void)
if (!r)
return;
- vga_switcheroo_register_handler(&radeon_atpx_handler, handler_flags);
+ if (!vga_switcheroo_register_handler(&radeon_atpx_handler, handler_flags))
+ radeon_atpx_priv.handler_registered = true;
}
/**
@@ -615,5 +617,14 @@ void radeon_register_atpx_handler(void)
*/
void radeon_unregister_atpx_handler(void)
{
+ /*
+ * vga_switcheroo has a single handler slot and unregistering clears it
+ * no matter who set it, so leave a handler registered by another
+ * driver, such as amdgpu or apple-gmux, in place.
+ */
+ if (!radeon_atpx_priv.handler_registered)
+ return;
+
vga_switcheroo_unregister_handler();
+ radeon_atpx_priv.handler_registered = false;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 357/742] drm/sched: Ensure stopped entity cannot be re-added to the run-queue
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (347 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 356/742] drm/radeon: only unregister the ATPX handler if we registered it Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 358/742] drm/syncobj: Limit the number of handles and use kvmalloc for user-sized arrays Greg Kroah-Hartman
` (377 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tvrtko Ursulin, Luben Tuikov,
Christian König, Andrey Grodzovsky, Matthew Brost,
Danilo Krummrich, Philipp Stanner, David Airlie, Simona Vetter
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
commit 7e2645d5c05ac03f240685fe76a2c04733d36a1a upstream.
When entities are torn down in drm_sched_entity_kill() a multi-step
process is undertaken to synchronize with a drm_sched_run_job_work()
consuming jobs from the same entity.
First the entity is marked as stopped and removed from the run-queue,
with both the entity and run-queue lock correctly taken. The process then
waits for the entity idle via the completion after which point it assumes
it is the only accessor to the entity in question.
What can happen however in drm_sched_run_job_work() if there are at least
two outstanding runnable jobs on an entity, is that
drm_sched_entity_pop_job() can re-add it to the run-queue due the
unconditial add to the rbtree via drm_sched_rq_update_fifo_locked().
What is required is that the teardown starts after the run job has
selected the entity and that it gets to it's completion waiting stage
before the run job goes to dequeue a job, and for the run job to be able
to de-queue a job before teardown has consumed too many.
Run job will then see there is another job pending (after the one about
to be de-queued) and it will re-add the entity to the run-queue. Run job
will then signal the completion and entity teardown will proceed
incorrectly thinking it's removal of the entity was final.
End result is a pointer to an entity about to be freed dangling forever in
the rbtree.
drm_sched_run_job_work() drm_sched_entity_kill()
drm_sched_select_entity
stops and removes entity
wait_for_completion
drm_sched_entity_pop_job
-> re-adds to run-queue due more jobs
complete_all
drm_sched_entity_queue_pop
... fini entity ...
drm_sched_run_job_queue
drm_sched_select_entity - UAF
This race existed ever since the FIFO policy was first added.
Lets mirror the guard from drm_sched_rq_add_entity() in
drm_sched_rq_pop_entity() and close this gap.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
References: https://sashiko.dev/#/patchset/20261020154123.33631-1-tvrtko.ursulin@igalia.com?part=7
Fixes: 08fb97de03aa ("drm/sched: Add FIFO sched policy to run queue")
Cc: Luben Tuikov <luben.tuikov@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: stable@vger.kernel.org # v6.2+
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patch.msgid.link/20261109160743.17020-1-tvrtko.ursulin@igalia.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/scheduler/sched_rq.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/drivers/gpu/drm/scheduler/sched_rq.c
+++ b/drivers/gpu/drm/scheduler/sched_rq.c
@@ -345,6 +345,13 @@ void drm_sched_rq_pop_entity(struct drm_
lockdep_assert_held(&entity->lock);
+ /*
+ * If entity is getting torn down via drm_sched_entity_kill() we need
+ * to ensure it does not get re-added to the tree behind it's back.
+ */
+ if (entity->stopped)
+ return;
+
spin_lock(&rq->lock);
/*
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 358/742] drm/syncobj: Limit the number of handles and use kvmalloc for user-sized arrays
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (348 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 357/742] drm/sched: Ensure stopped entity cannot be re-added to the run-queue Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 359/742] drm/tilcdc: Fix suspend/resume drvdata Greg Kroah-Hartman
` (376 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, syzbot+95416f957d84e858b377,
Christian König, Fei Yu
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fei Yu <fei.yu@intel.com>
commit 6ca87397aeebcfae3057653c3e7c008ccb0bb926 upstream.
The syncobj ioctls allocate several temporary arrays whose size is taken
directly from the u32 count_handles provided by userspace:
- handles and syncobjs in drm_syncobj_array_find()
- points and entries in drm_syncobj_array_wait_timeout()
- points and chains in drm_syncobj_timeline_signal_ioctl()
These are kmalloc() allocations, so a count above KMALLOC_MAX_SIZE /
element size trips the WARN_ON_ONCE_GFP() in ___kmalloc_large_node():
WARNING: mm/slub.c:5459 at ___kmalloc_large_node+0x10c/0x170 mm/slub.c:5459
Call Trace:
__kmalloc_large_node_noprof+0x18/0x90 mm/slub.c:5502
__do_kmalloc_node mm/slub.c:5519 [inline]
__kmalloc_noprof+0x3f6/0x710 mm/slub.c:5556
_kmalloc_noprof include/linux/slab.h:995 [inline]
_kmalloc_array_noprof include/linux/slab.h:1211 [inline]
drm_syncobj_array_find+0x3a/0x440 drivers/gpu/drm/drm_syncobj.c:1241
drm_syncobj_timeline_wait_ioctl+0x18a/0x640 drivers/gpu/drm/drm_syncobj.c:1356
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:817
drm_ioctl+0x70e/0xba0 drivers/gpu/drm/drm_ioctl.c:914
The wait entries are 64 bytes each on 64-bit, so with a 4 MiB
KMALLOC_MAX_SIZE a wait on more than about 64K handles already fails
today, with a warning.
Fix this in two parts:
- Reject more than DRM_SYNCOBJ_MAX_HANDLES (1M) handles with -EINVAL in
drm_syncobj_array_find(), which every ioctl taking a handle array goes
through. The limit is a fixed number, so it is the same on all
architectures. It is above what these ioctls can handle today: with a
4 MiB KMALLOC_MAX_SIZE the 8-byte arrays already fail above 512K
handles on 64-bit, so no request that succeeds now is rejected. A
static_assert() makes sure that the largest per-handle allocation, the
wait entries, stays below the INT_MAX size limit of kvmalloc().
- Switch the six allocations to kvmalloc(), so that handle counts up to
the limit (64 MiB of wait entries for 1M handles) no longer depend on
physically contiguous memory.
Using kvmalloc() alone is not enough: the reproducer asks for more than
INT_MAX bytes, which hits the WARN_ON_ONCE() in __kvmalloc_node_noprof()
instead.
Fixes: 3e6fb72d6cef ("drm/syncobj: Add a syncobj_array_find helper")
Reported-by: syzbot+95416f957d84e858b377@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=95416f957d84e858b377
Suggested-by: Christian König <christian.koenig@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Fei Yu <fei.yu@intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20261109014852.2127723-1-fei.yu@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/drm_syncobj.c | 44 +++++++++++++++++++++++++++---------------
1 file changed, 29 insertions(+), 15 deletions(-)
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -199,6 +199,7 @@
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/sched/signal.h>
+#include <linux/sizes.h>
#include <linux/sync_file.h>
#include <linux/uaccess.h>
@@ -220,6 +221,16 @@ struct syncobj_wait_entry {
u64 point;
};
+/*
+ * Upper limit for the number of handles passed to a single ioctl. This is a
+ * fixed number so that the limit is the same on all architectures. The
+ * largest per-handle allocation is the wait entry array, which must stay
+ * below the INT_MAX size limit of kvmalloc().
+ */
+#define DRM_SYNCOBJ_MAX_HANDLES SZ_1M
+static_assert(DRM_SYNCOBJ_MAX_HANDLES <=
+ INT_MAX / sizeof(struct syncobj_wait_entry));
+
static void syncobj_wait_syncobj_func(struct drm_syncobj *syncobj,
struct syncobj_wait_entry *wait);
@@ -1051,7 +1062,7 @@ static signed long drm_syncobj_array_wai
lockdep_assert_none_held_once();
}
- points = kmalloc_array(count, sizeof(*points), GFP_KERNEL);
+ points = kvmalloc_array(count, sizeof(*points), GFP_KERNEL);
if (points == NULL)
return -ENOMEM;
@@ -1064,7 +1075,7 @@ static signed long drm_syncobj_array_wai
goto err_free_points;
}
- entries = kzalloc_objs(*entries, count);
+ entries = kvzalloc_objs(*entries, count);
if (!entries) {
timeout = -ENOMEM;
goto err_free_points;
@@ -1185,10 +1196,10 @@ cleanup_entries:
&entries[i].fence_cb);
dma_fence_put(entries[i].fence);
}
- kfree(entries);
+ kvfree(entries);
err_free_points:
- kfree(points);
+ kvfree(points);
return timeout;
}
@@ -1238,7 +1249,10 @@ static int drm_syncobj_array_find(struct
struct drm_syncobj **syncobjs;
int ret;
- handles = kmalloc_array(count_handles, sizeof(*handles), GFP_KERNEL);
+ if (count_handles > DRM_SYNCOBJ_MAX_HANDLES)
+ return -EINVAL;
+
+ handles = kvmalloc_array(count_handles, sizeof(*handles), GFP_KERNEL);
if (handles == NULL)
return -ENOMEM;
@@ -1248,7 +1262,7 @@ static int drm_syncobj_array_find(struct
goto err_free_handles;
}
- syncobjs = kmalloc_objs(*syncobjs, count_handles);
+ syncobjs = kvmalloc_objs(*syncobjs, count_handles);
if (syncobjs == NULL) {
ret = -ENOMEM;
goto err_free_handles;
@@ -1262,16 +1276,16 @@ static int drm_syncobj_array_find(struct
}
}
- kfree(handles);
+ kvfree(handles);
*syncobjs_out = syncobjs;
return 0;
err_put_syncobjs:
while (i-- > 0)
drm_syncobj_put(syncobjs[i]);
- kfree(syncobjs);
+ kvfree(syncobjs);
err_free_handles:
- kfree(handles);
+ kvfree(handles);
return ret;
}
@@ -1283,7 +1297,7 @@ static void drm_syncobj_array_free(struc
for (i = 0; i < count; i++)
drm_syncobj_put(syncobjs[i]);
- kfree(syncobjs);
+ kvfree(syncobjs);
}
int
@@ -1572,8 +1586,8 @@ drm_syncobj_timeline_signal_ioctl(struct
if (ret < 0)
return ret;
- points = kmalloc_array(args->count_handles, sizeof(*points),
- GFP_KERNEL);
+ points = kvmalloc_array(args->count_handles, sizeof(*points),
+ GFP_KERNEL);
if (!points) {
ret = -ENOMEM;
goto out;
@@ -1586,7 +1600,7 @@ drm_syncobj_timeline_signal_ioctl(struct
goto err_points;
}
- chains = kmalloc_objs(*chains, args->count_handles);
+ chains = kvmalloc_objs(*chains, args->count_handles);
if (!chains) {
ret = -ENOMEM;
goto err_points;
@@ -1609,9 +1623,9 @@ drm_syncobj_timeline_signal_ioctl(struct
dma_fence_put(fence);
}
err_chains:
- kfree(chains);
+ kvfree(chains);
err_points:
- kfree(points);
+ kvfree(points);
out:
drm_syncobj_array_free(syncobjs, args->count_handles);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 359/742] drm/tilcdc: Fix suspend/resume drvdata
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (349 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 358/742] drm/syncobj: Limit the number of handles and use kvmalloc for user-sized arrays Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 360/742] drm/vblank: timer: Do not block within critical section Greg Kroah-Hartman
` (375 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Markus Schneider-Pargmann (TI),
Kory Maincent, Luca Ceresoli
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Markus Schneider-Pargmann (TI) <msp@baylibre.com>
commit b4d01c788bfa50dc65ffb5fbc9db4135004c0e01 upstream.
drvdata contains a pointer to a struct tilcdc_drm_private and not a
pointer to a struct drm_device anymore.
Note that this breaks suspend/resume at the moment, it hangs on
acquiring a mutex.
Interpret drvdata correctly as struct tilcdc_drm_private as is done in
the rest of the driver.
Fixes: 3301302060da ("drm/tilcdc: Modernize driver initialization and cleanup paths")
Cc: stable@vger.kernel.org
Signed-off-by: Markus Schneider-Pargmann (TI) <msp@baylibre.com>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Link: https://patch.msgid.link/20261103-v7-4-topic-am335lpm-tilcdc-v1-1-b7f91f9c9a05@baylibre.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/tilcdc/tilcdc_drv.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -235,7 +235,8 @@ static const struct drm_driver tilcdc_dr
static int tilcdc_pm_suspend(struct device *dev)
{
- struct drm_device *ddev = dev_get_drvdata(dev);
+ struct tilcdc_drm_private *priv = dev_get_drvdata(dev);
+ struct drm_device *ddev = &priv->ddev;
int ret = 0;
ret = drm_mode_config_helper_suspend(ddev);
@@ -248,7 +249,8 @@ static int tilcdc_pm_suspend(struct devi
static int tilcdc_pm_resume(struct device *dev)
{
- struct drm_device *ddev = dev_get_drvdata(dev);
+ struct tilcdc_drm_private *priv = dev_get_drvdata(dev);
+ struct drm_device *ddev = &priv->ddev;
/* Select default pin state */
pinctrl_pm_select_default_state(dev);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 360/742] drm/vblank: timer: Do not block within critical section
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (350 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 359/742] drm/tilcdc: Fix suspend/resume drvdata Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 361/742] drm/xe/dma-buf: Validate BOs on export to charge the exporter Greg Kroah-Hartman
` (374 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ville Syrjälä,
Thomas Zimmermann, Zack Rusin, Louis Chauvet,
Javier Martinez Canillas, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, dri-devel
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <tzimmermann@suse.de>
commit f02d1f70d361c42d09569e51612d6be5ffceb7d6 upstream.
Remove try-to-cancel loop from drm_crtc_vblank_start_timer() to avoid
a possible livelock while spinning within the loop. Hold interval_lock
when starting and forwarding the vblank timer's hrtimer to avoid
forwarding an already queued timer.
The vblank helper drm_vblank_disable_and_save() and the vblank IRQ
handler hold the spin lock vblank_time_lock at some point. This can
result in a deadlock if the vblank timer's disable code in
drm_crtc_vblank_cancel_timer() calls hrtimer_cancel() directly: the
helper waits for the timer function to complete and the timer function
waits for the helper to release vblank_time_lock.
drm_crtc_vblank_cancel_timer() works around this problem by calling
hrtimer_try_to_cancel() instead. For re-enabling the vblank timer,
drm_crtc_vblank_start_timer() currently waits for the vblank timer
to stop. It runs into the same locking problem while waiting for the
timer function to complete.
Resolve the locking problem by removing hrtimer_try_to_cancel() from
drm_crtc_vblank_start_timer(). Hold interval_lock while starting or
forwarding the hrtimer. Without holding interval_lock,
drm_crtc_vblank_start_timer() could set an interval and start the
hrtimer; while a concurrent timer function forwards the timer with the
old interval. This can corrupt the ordering of the hrtimer's internal
queue. Holding the lock prevents this from happening.
When starting the vblank timer, it is still possible that an already
running timer sends out a vblank event at the previous vblank interval.
This is merely an inconsistency and not critical.
Closes: https://lore.kernel.org/dri-devel/20260914111129.300691F00898@smtp.kernel.org/
Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
Fixes: 74afeb812850 ("drm/vblank: Add vblank timer")
Cc: Louis Chauvet <louis.chauvet@bootlin.com>
Cc: Javier Martinez Canillas <javierm@redhat.com>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.19+
Link: https://patch.msgid.link/20261110084710.503870-2-tzimmermann@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/drm_vblank.c | 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)
--- a/drivers/gpu/drm/drm_vblank.c
+++ b/drivers/gpu/drm/drm_vblank.c
@@ -2179,19 +2179,18 @@ static enum hrtimer_restart drm_vblank_t
struct drm_crtc *crtc = vtimer->crtc;
const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
struct drm_device *dev = crtc->dev;
- unsigned long flags;
- ktime_t interval;
- u64 ret_overrun;
+ u64 ret_overrun = 1;
bool succ;
- spin_lock_irqsave(&vtimer->interval_lock, flags);
- interval = vtimer->interval;
- spin_unlock_irqrestore(&vtimer->interval_lock, flags);
+ scoped_guard(spinlock_irqsave, &vtimer->interval_lock) {
+ ktime_t interval = vtimer->interval;
- if (!interval)
- return HRTIMER_NORESTART;
+ if (!interval || hrtimer_is_queued(timer))
+ return HRTIMER_NORESTART;
+
+ ret_overrun = hrtimer_forward_now(timer, interval);
+ }
- ret_overrun = hrtimer_forward_now(&vtimer->timer, interval);
if (ret_overrun != 1)
drm_dbg_vbl(dev, "vblank timer overrun\n");
@@ -2220,7 +2219,6 @@ int drm_crtc_vblank_start_timer(struct d
{
struct drm_vblank_crtc *vblank = drm_crtc_vblank_crtc(crtc);
struct drm_vblank_crtc_timer *vtimer = &vblank->vblank_timer;
- unsigned long flags;
if (!vtimer->crtc) {
/*
@@ -2230,22 +2228,14 @@ int drm_crtc_vblank_start_timer(struct d
spin_lock_init(&vtimer->interval_lock);
hrtimer_setup(&vtimer->timer, drm_vblank_timer_function,
CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- } else {
- /*
- * Timer should not be active. If it is, wait for the
- * previous cancel operations to finish.
- */
- while (hrtimer_active(&vtimer->timer))
- hrtimer_try_to_cancel(&vtimer->timer);
}
drm_calc_timestamping_constants(crtc, &crtc->mode);
- spin_lock_irqsave(&vtimer->interval_lock, flags);
- vtimer->interval = ns_to_ktime(vblank->framedur_ns);
- spin_unlock_irqrestore(&vtimer->interval_lock, flags);
-
- hrtimer_start(&vtimer->timer, vtimer->interval, HRTIMER_MODE_REL);
+ scoped_guard(spinlock_irqsave, &vtimer->interval_lock) {
+ vtimer->interval = ns_to_ktime(vblank->framedur_ns);
+ hrtimer_start(&vtimer->timer, vtimer->interval, HRTIMER_MODE_REL);
+ }
return 0;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 361/742] drm/xe/dma-buf: Validate BOs on export to charge the exporter
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (351 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 360/742] drm/vblank: timer: Do not block within critical section Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 362/742] drm/xe/guc: Treat CT-disabled TLB invalidation as cancelled Greg Kroah-Hartman
` (373 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Matthew Brost, Matthew Auld,
Dave Airlie, Rodrigo Vivi, intel-xe, Thomas Hellström
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellström <thomas.hellstrom@linux.intel.com>
commit 22e05ee854e1bdacebcfa36ecd3f33ec80cf897a upstream.
xe_gem_prime_export() calls ttm_bo_setup_export() to make sure the
exporter is charged for the memory backing an exported BO. However,
that only populates a TTM_PL_SYSTEM tt. A BO that has been evicted, or
that has deferred backing, will instead get its memory allocated when
the importer maps it. For p2p imports this happens through
xe_bo_validate() in xe_dma_buf_map(), so the importer, not the
exporter, is charged for the allocation.
Call xe_bo_validate() at export time instead, so that the BO is moved
into its preferred placement and the exporter is charged.
Do the purgeable checks and the validation in the same
xe_validation_guard() transaction, to avoid locking the BO twice.
The commit message and code was drafted using LLM.
Link: https://patchwork.freedesktop.org/patch/747480/?series=172524&rev=1
Fixes: 91494dee1091 ("xe: populate buffers before exporting them.")
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: intel-xe@lists.freedesktop.org
Cc: stable@vger.kernel.org # v6.18+
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patch.msgid.link/20261111100929.2228-1-thomas.hellstrom@linux.intel.com
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
(cherry picked from commit 451162b9f6570d19da1c5944aa0a0e3e8f17773d)
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/xe/xe_dma_buf.c | 80 ++++++++++++++++++++--------------------
1 file changed, 41 insertions(+), 39 deletions(-)
--- a/drivers/gpu/drm/xe/xe_dma_buf.c
+++ b/drivers/gpu/drm/xe/xe_dma_buf.c
@@ -222,60 +222,62 @@ static const struct dma_buf_ops xe_dmabu
struct dma_buf *xe_gem_prime_export(struct drm_gem_object *obj, int flags)
{
struct xe_bo *bo = gem_to_xe_bo(obj);
+ struct xe_validation_ctx ctx;
+ struct drm_exec exec;
struct dma_buf *buf;
- struct ttm_operation_ctx ctx = {
- .interruptible = true,
- .no_wait_gpu = true,
- /* We opt to avoid OOM on system pages allocations */
- .gfp_retry_mayfail = true,
- .allow_res_evict = false,
- };
- int ret;
+ int ret = 0;
if (bo->vm)
return ERR_PTR(-EPERM);
- /*
- * Reject exporting purgeable BOs. DONTNEED BOs can be purged
- * at any time, making the exported dma-buf unusable. Purged BOs
- * have no backing store and are permanently invalid.
- */
- ret = xe_bo_lock(bo, true);
- if (ret)
- return ERR_PTR(ret);
-
- if (xe_bo_madv_is_dontneed(bo)) {
- ret = -EBUSY;
- goto out_unlock;
- }
+ xe_validation_guard(&ctx, &xe_bo_device(bo)->val, &exec,
+ (struct xe_val_flags) {.interruptible = true}, ret) {
+ ret = drm_exec_lock_obj(&exec, &bo->ttm.base);
+ drm_exec_retry_on_contention(&exec);
+ if (ret)
+ break;
+
+ /*
+ * Reject exporting purgeable BOs. DONTNEED BOs can be purged
+ * at any time, making the exported dma-buf unusable. Purged BOs
+ * have no backing store and are permanently invalid.
+ */
+ if (xe_bo_madv_is_dontneed(bo)) {
+ ret = -EBUSY;
+ break;
+ }
+
+ if (xe_bo_is_purged(bo)) {
+ ret = -EINVAL;
+ break;
+ }
+
+ /*
+ * Make sure the BO is backed in its preferred placement so that
+ * the exporter, rather than the importer, is charged for the
+ * memory allocation.
+ */
+ ret = xe_bo_validate(bo, NULL, false, &exec);
+ drm_exec_retry_on_contention(&exec);
+ xe_validation_retry_on_oom(&ctx, &ret);
+ if (ret)
+ break;
- if (xe_bo_is_purged(bo)) {
- ret = -EINVAL;
- goto out_unlock;
+ xe_bo_willneed_get_locked(bo);
}
-
- xe_bo_willneed_get_locked(bo);
- xe_bo_unlock(bo);
-
- ret = ttm_bo_setup_export(&bo->ttm, &ctx);
if (ret)
- goto out_put;
+ return ERR_PTR(ret);
buf = drm_gem_prime_export(obj, flags);
if (IS_ERR(buf)) {
- ret = PTR_ERR(buf);
- goto out_put;
+ xe_bo_lock(bo, false);
+ xe_bo_willneed_put_locked(bo);
+ xe_bo_unlock(bo);
+ return buf;
}
buf->ops = &xe_dmabuf_ops;
return buf;
-
-out_put:
- xe_bo_lock(bo, false);
- xe_bo_willneed_put_locked(bo);
-out_unlock:
- xe_bo_unlock(bo);
- return ERR_PTR(ret);
}
static struct drm_gem_object *
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 362/742] drm/xe/guc: Treat CT-disabled TLB invalidation as cancelled
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (352 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 361/742] drm/xe/dma-buf: Validate BOs on export to charge the exporter Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 363/742] drm/xe/madvise: use already clamped pat_index Greg Kroah-Hartman
` (372 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Matthew Brost, Zongyao Bai,
Shuicheng Lin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zongyao Bai <zongyao.bai@intel.com>
commit b865310c41f5b68c7de3bec86f205ba8cd284fd1 upstream.
During a GT reset the GuC CT channel goes through two states before it
is enabled again:
gt_reset_worker()
xe_uc_stop() ENABLED -> STOPPED send: -ECANCELED
xe_tlb_inval_reset()
do_gt_reset()
do_gt_restart()
xe_uc_sanitize_reset() STOPPED -> DISABLED send: -ENODEV
GuC load, CT enable DISABLED -> ENABLED
xe_tlb_inval_issue() treats -ECANCELED as "undelivered, report done",
but -ENODEV is propagated to the caller. A userptr invalidation from an
MMU notifier (e.g. munmap() on a fault-mode VM) issued in the DISABLED
window thus trips the XE_WARN_ON() in xe_vma_userptr_do_inval() and
taints the kernel:
Tile0: GT1: GT: reset started
WARNING: drivers/gpu/drm/xe/xe_userptr.c:133 at xe_vma_userptr_do_inval+0x340/0x4a0 [xe]
RAX: 00000000ffffffed
xe_vma_userptr_invalidate_start+0x4b7/0x7c0 [xe]
__mmu_notifier_invalidate_range_start+0x247/0x370
unmap_vmas+0x1af/0x1c0
unmap_region+0x91/0xf0
...
The TLB invalidation ops contract is that the backend returns
-ECANCELED when it is mid-reset. The reset invalidates all TLBs, so
there is nothing left to do. Map -ENODEV to -ECANCELED in
send_tlb_inval() so that every GuC TLB invalidation type handles it the
same way, instead of only send_tlb_inval_ggtt_full() as done so far.
The CT is also DISABLED across system suspend and runtime suspend. On
resume from system suspend the GuC is reloaded with all TLBs invalid, so
nothing is lost there either; user space and the MM kernel threads are
frozen by then, so such a request is not expected anyway. A request
issued while runtime suspended violates the PM rules and is still
reported by the "Missing outer runtime PM protection" warning in
xe_tlb_inval_fence_init().
Fixes: db16f9d90c1d ("drm/xe: Split TLB invalidation code in frontend and backend")
Cc: stable@vger.kernel.org # v6.18+
Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Zongyao Bai <zongyao.bai@intel.com>
Reviewed-by: Shuicheng Lin <shuicheng.lin@intel.com>
Link: https://patch.msgid.link/20261116192220.3872267-2-zongyao.bai@intel.com
Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
(cherry picked from commit c17474e39028c7fb5cd6b2fb0f0413d07b1bf232)
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/xe/xe_guc_tlb_inval.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/xe/xe_guc_tlb_inval.c
+++ b/drivers/gpu/drm/xe/xe_guc_tlb_inval.c
@@ -31,12 +31,22 @@
static int send_tlb_inval(struct xe_guc *guc, const u32 *action, int len)
{
struct xe_gt *gt = guc_to_gt(guc);
+ int ret;
xe_gt_assert(gt, action[1]); /* Seqno */
xe_gt_stats_incr(gt, XE_GT_STATS_ID_TLB_INVAL, 1);
- return xe_guc_ct_send(&guc->ct, action, len,
- G2H_LEN_DW_TLB_INVALIDATE, 1);
+ ret = xe_guc_ct_send(&guc->ct, action, len, G2H_LEN_DW_TLB_INVALIDATE, 1);
+
+ /*
+ * A disabled CT can't deliver the request, and the GuC is reloaded
+ * with all TLBs invalid before the CT is enabled again, so there is
+ * nothing left to invalidate. Report it as cancelled, like a stopped CT.
+ */
+ if (ret == -ENODEV)
+ return -ECANCELED;
+
+ return ret;
}
#define MAKE_INVAL_OP_FLUSH(type, flush_cache) ((type << XE_GUC_TLB_INVAL_TYPE_SHIFT) | \
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 363/742] drm/xe/madvise: use already clamped pat_index
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (353 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 362/742] drm/xe/guc: Treat CT-disabled TLB invalidation as cancelled Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 364/742] drm/xe/query: Use ordered clock reads for engine cycles cpu_delta Greg Kroah-Hartman
` (371 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Matthew Auld, Alan Previn,
Tejas Upadhyay, Matthew Brost, Dave Airlie
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Auld <matthew.auld@intel.com>
commit eeae08f98bda4350baa5a76f37b23fab4fa426f7 upstream.
Pass the nospec-clamped pat_index to check_pat_args_are_sane() instead
of the raw args->pat_index.val, and fold into the preceding
DRM_XE_MEM_RANGE_ATTR_PAT block.
Assisted-by: LLM
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/message/sashiko-outbox-172627%40kernel.org
Fixes: 016ccdb674b8 ("drm/xe/uapi: Reject coh_none PAT index for CPU cached memory in madvise")
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Cc: <stable@vger.kernel.org> # v7.2+
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Link: https://patch.msgid.link/20261015103415.442931-2-matthew.auld@intel.com
(cherry picked from commit 3be1bd59ced603d2e6a6ba9a4fe274308cea9965)
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/xe/xe_vm_madvise.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
--- a/drivers/gpu/drm/xe/xe_vm_madvise.c
+++ b/drivers/gpu/drm/xe/xe_vm_madvise.c
@@ -659,11 +659,8 @@ int xe_vm_madvise_ioctl(struct drm_devic
err = -EINVAL;
goto free_vmas;
}
- }
- if (args->type == DRM_XE_MEM_RANGE_ATTR_PAT) {
- if (!check_pat_args_are_sane(xe, &madvise_range,
- args->pat_index.val)) {
+ if (!check_pat_args_are_sane(xe, &madvise_range, pat_index)) {
err = -EINVAL;
goto free_vmas;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 364/742] drm/xe/query: Use ordered clock reads for engine cycles cpu_delta
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (354 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 363/742] drm/xe/madvise: use already clamped pat_index Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 365/742] drm/xe: Dont abort the shrinker walk on -EBUSY Greg Kroah-Hartman
` (370 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Umesh Nerlige Ramappa, Matthew Brost,
Rodrigo Vivi, Aleksander Czerwionka, Sanjay Yadav
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanjay Yadav <sanjay.kumar.yadav@intel.com>
commit 65ef9dec511c018bcbe5993e9749c52c26e573e2 upstream.
cpu_delta is meant to bound the time taken to read the engine timestamp
register, but it is measured with local_clock(), which on x86 is a plain
RDTSC that is not ordered against loads. Either end of the window can
thus be sampled while an earlier MMIO read is still in flight.
A reproducer looping on DRM_XE_DEVICE_QUERY_ENGINE_CYCLES on BMG reports
cpu_delta as low as 18 ns, while the MMIO read alone takes > 1.5 us.
Use ktime_get_raw_ns() at both ends instead. Its clocksource read is
ordered (rdtsc_ordered() on x86).
With this, the reproducer reports min/median cpu_delta of 1567/1745 ns
and no short values.
Fixes: 7793d00d1bf5 ("drm/xe: Correlate engine and cpu timestamps with better accuracy")
Cc: <stable@vger.kernel.org> # v6.8+
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Suggested-by: Aleksander Czerwionka <aleksander.czerwionka@intel.com>
Signed-off-by: Sanjay Yadav <sanjay.kumar.yadav@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patch.msgid.link/20261111090401.975803-2-sanjay.kumar.yadav@intel.com
(cherry picked from commit 146dec4ce1f0794fefe5ad1d549655745358b515)
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/xe/xe_query.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/gpu/drm/xe/xe_query.c
+++ b/drivers/gpu/drm/xe/xe_query.c
@@ -6,7 +6,6 @@
#include "xe_query.h"
#include <linux/nospec.h>
-#include <linux/sched/clock.h>
#include <drm/ttm/ttm_placement.h>
#include <generated/xe_wa_oob.h>
@@ -97,13 +96,14 @@ hwe_read_timestamp(struct xe_hw_engine *
u32 upper, lower, old_upper, loop = 0;
struct xe_reg upper_reg = RING_TIMESTAMP_UDW(hwe->mmio_base),
lower_reg = RING_TIMESTAMP(hwe->mmio_base);
+ u64 delta_start;
upper = xe_mmio_read32(mmio, upper_reg);
do {
- *cpu_delta = local_clock();
+ delta_start = ktime_get_raw_ns();
*cpu_ts = cpu_clock();
lower = xe_mmio_read32(mmio, lower_reg);
- *cpu_delta = local_clock() - *cpu_delta;
+ *cpu_delta = ktime_get_raw_ns() - delta_start;
old_upper = upper;
upper = xe_mmio_read32(mmio, upper_reg);
} while (upper != old_upper && loop++ < 2);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 365/742] drm/xe: Dont abort the shrinker walk on -EBUSY
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (355 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 364/742] drm/xe/query: Use ordered clock reads for engine cycles cpu_delta Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 366/742] accel/rocket: number the cores by devicetree position, not bind order Greg Kroah-Hartman
` (369 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christian König, Matthew Brost,
Rodrigo Vivi, intel-xe, Thomas Hellström, Dave Airlie
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Hellström <thomas.hellstrom@linux.intel.com>
commit 9de430b6fbbdfeee1a5eec33edf53f52c13c869b upstream.
xe_bo_shrink() returns -EBUSY for bos that can't currently be shrunk,
for example imported dma-bufs, bos whose vm is currently validating,
bos that are still busy after the wait timeout, or bos whose backup
fails. The shrinker LRU walk treats any negative return value as
fatal and aborts, which also skips the remaining shrinker passes.
As a result, a single such bo, like an imported dma-buf on the
XE_PL_TT LRU, prevents reclaim of all bos behind it on the LRU.
Skip bos for which xe_bo_shrink() returns -EBUSY and continue the
walk, like the TTM LRU walk does.
v4:
- Patch introduced.
Fixes: 00c8efc3180f ("drm/xe: Add a shrinker for xe bos")
Cc: Christian König <christian.koenig@amd.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: intel-xe@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.15+
Assisted-by: LLM
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20261019095655.3501-2-thomas.hellstrom@linux.intel.com
(cherry picked from commit 846f333b3e0b48065f96bee74ffa0b9d390ed05f)
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/xe/xe_shrinker.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/gpu/drm/xe/xe_shrinker.c
+++ b/drivers/gpu/drm/xe/xe_shrinker.c
@@ -113,6 +113,9 @@ static int __xe_shrinker_walk(struct xe_
continue;
lret = xe_bo_shrink(ctx, ttm_bo, flags, scanned);
+ /* Like the TTM LRU walk, skip bos we can't shrink now. */
+ if (lret == -EBUSY)
+ continue;
if (lret < 0) {
ret = lret;
goto out;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 366/742] accel/rocket: number the cores by devicetree position, not bind order
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (356 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 365/742] drm/xe: Dont abort the shrinker walk on -EBUSY Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 367/742] drm/amd/pm: send smu8 sclk level indices, not the level mask Greg Kroah-Hartman
` (368 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Igor Paunovic, Heiko Stuebner,
Tomeu Vizoso
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Paunovic <royalnet026@gmail.com>
commit 97e48904cbdb32e4a66bd60d26ce45657f58bc46 upstream.
rocket_job_hw_submit() programs the S_POINTER registers of a core with an
extra bit derived from core->index, the way the vendor driver derives it
from the hardware number of the core. rocket_probe() sets core->index to
the slot the core takes in rdev->cores[], which is the order the cores
bind in.
The two agree only while the cores that bind are a prefix of the core
nodes in the devicetree, in devicetree order. Unbind them and bind them
back with a different core first, have one core's probe deferred behind a
sibling's, or disable a core other than the last one, and every task
submitted to a core whose slot is not its hardware number times out after
500 ms. The reset that follows does not help, and the inference finishes
with wrong output.
Observed on an Orange Pi 5 Plus with a KASAN build, over all six bind
orders of the three cores: only the devicetree order ran clean. The other
five produced 27 to 141 "NPU job timed out". In four of them no output
tensor changed with the input, and the harness gave up before its first
measured round; the fifth got through a six-second run with 27 timeouts
and a wrong top-1 class. All but one of the timeouts land on the cores
whose slot is not their hardware number, in proportion to the tasks the
scheduler hands them, and in both directions of the mismatch.
Number the cores by their position among the core nodes in the devicetree
instead, which is what the hardware number is.
The wrong value has been assigned since the driver was added, but it only
reached the hardware once the extra bit was introduced, hence the Fixes
tag below.
Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
Cc: stable@vger.kernel.org
Assisted-by: LLM sparse
Signed-off-by: Igor Paunovic <royalnet026@gmail.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
[tomeu: shortened the comments and dropped checkpatch from Assisted-by]
Reviewed-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Signed-off-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Link: https://patch.msgid.link/20260922080114.44662-3-royalnet026@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/accel/rocket/rocket_core.h | 4 ++++
drivers/accel/rocket/rocket_drv.c | 22 +++++++++++++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
--- a/drivers/accel/rocket/rocket_core.h
+++ b/drivers/accel/rocket/rocket_core.h
@@ -30,6 +30,10 @@
struct rocket_core {
struct device *dev;
struct rocket_device *rdev;
+ /*
+ * Hardware number of the core: its position among the core nodes in
+ * the devicetree.
+ */
unsigned int index;
int irq;
--- a/drivers/accel/rocket/rocket_drv.c
+++ b/drivers/accel/rocket/rocket_drv.c
@@ -157,10 +157,30 @@ static const struct drm_driver rocket_dr
.desc = "rocket DRM",
};
+static int rocket_core_hw_index(struct device *dev)
+{
+ struct device_node *np;
+ int index = 0;
+
+ for_each_matching_node(np, dev->driver->of_match_table) {
+ if (np == dev->of_node) {
+ of_node_put(np);
+ return index;
+ }
+ index++;
+ }
+
+ return -ENODEV;
+}
+
static int rocket_probe(struct platform_device *pdev)
{
+ int index = rocket_core_hw_index(&pdev->dev);
int ret;
+ if (index < 0)
+ return index;
+
if (rdev == NULL) {
/* First core probing, initialize DRM device. */
rdev = rocket_device_init(drm_dev, &rocket_drm_driver);
@@ -179,7 +199,7 @@ static int rocket_probe(struct platform_
rdev->cores[core].rdev = rdev;
rdev->cores[core].dev = &pdev->dev;
- rdev->cores[core].index = core;
+ rdev->cores[core].index = index;
rdev->num_cores++;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 367/742] drm/amd/pm: send smu8 sclk level indices, not the level mask
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (357 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 366/742] accel/rocket: number the cores by devicetree position, not bind order Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 368/742] drm/amdgpu/gfx_v9_0: Add gfxoff quirk for Lenovo Picasso 318F Greg Kroah-Hartman
` (367 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Joshua Horne
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Horne <hornejd@etsu.edu>
commit 535f6852652e3239c8688491ccd0ed4b6e09d14f upstream.
smu8_force_clock_level() passes the pp_dpm_sclk level mask straight to
PPSMC_MSG_SetSclkSoftMin and PPSMC_MSG_SetSclkSoftMax, which take a
level index, as the other smu8 callers do through smu8_get_sclk_level().
In manual mode, "echo 0 > pp_dpm_sclk" thus selects level 1, "echo 2"
selects level 4, and masks above the highest level index are out of
range for the SMU, so e.g. "echo 3", "echo 7" or "echo 0 1 2 3 4 5 6 7"
do not select the requested levels. The original single level version
sent 1 << level and had the same problem.
Send the lowest and highest level in the mask, as smu10 does, and reject
levels above those the SMU has enabled, as smu10 and vega20 do.
Fixes: d7341ef66870 ("drm/amd/powerplay: add some hwmgr functions for sysfs interface on Carrizo")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Joshua Horne <hornejd@etsu.edu>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 8ff6b368360adb24ccf145047b0261dfae77f28a)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c
@@ -1483,15 +1483,25 @@ static int smu8_store_cc6_data(struct pp
static int smu8_force_clock_level(struct pp_hwmgr *hwmgr,
enum pp_clock_type type, uint32_t mask)
{
+ struct phm_clock_voltage_dependency_table *table =
+ hwmgr->dyn_state.vddc_dependency_on_sclk;
+ uint32_t low, high;
+
switch (type) {
case PP_SCLK:
+ /* the SMU takes level indices, not a mask of levels */
+ low = mask ? (ffs(mask) - 1) : 0;
+ high = mask ? (fls(mask) - 1) : 0;
+ if (high >= min(table->count, smu8_get_max_sclk_level(hwmgr)))
+ return -EINVAL;
+
smum_send_msg_to_smc_with_parameter(hwmgr,
PPSMC_MSG_SetSclkSoftMin,
- mask,
+ low,
NULL);
smum_send_msg_to_smc_with_parameter(hwmgr,
PPSMC_MSG_SetSclkSoftMax,
- mask,
+ high,
NULL);
break;
default:
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 368/742] drm/amdgpu/gfx_v9_0: Add gfxoff quirk for Lenovo Picasso 318F
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (358 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 367/742] drm/amd/pm: send smu8 sclk level indices, not the level mask Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 369/742] drm/amdgpu/vce1: Fix checking whether VCE1 is idle Greg Kroah-Hartman
` (366 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Wang Jiang
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Jiang <jiangwang@kylinos.cn>
commit 24916f2c98f86c90db617d0e828d930d7a35577e upstream.
GFXOFF causes gfx ring timeout and desktop freeze on Lenovo 90NYA05DCD
(Ryzen 5 3400G, Picasso). Add a quirk entry with ANY_REV marker to
disable gfxoff for subsystem 17aa:318f regardless of chip revision.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Wang Jiang <jiangwang@kylinos.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 32a647c3218d8bb5bf03f68784fbc405c1e5fbd3)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
@@ -1365,6 +1365,9 @@ struct amdgpu_gfxoff_quirk {
u8 revision;
};
+/* Match any chip revision in amdgpu_gfxoff_quirk.revision */
+#define AMDGPU_GFXOFF_QUIRK_ANY_REV 0xff
+
static const struct amdgpu_gfxoff_quirk amdgpu_gfxoff_quirk_list[] = {
/* https://bugzilla.kernel.org/show_bug.cgi?id=204689 */
{ 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc8 },
@@ -1374,6 +1377,7 @@ static const struct amdgpu_gfxoff_quirk
{ 0x1002, 0x15dd, 0x1002, 0x15dd, 0xc6 },
/* Apple MacBook Pro (15-inch, 2019) Radeon Pro Vega 20 4 GB */
{ 0x1002, 0x69af, 0x106b, 0x019a, 0xc0 },
+ { 0x1002, 0x15d8, 0x17aa, 0x318f, AMDGPU_GFXOFF_QUIRK_ANY_REV },
/* https://bbs.openkylin.top/t/topic/171497 */
{ 0x1002, 0x15d8, 0x19e5, 0x3e14, 0xc2 },
/* HP 705G4 DM with R5 2400G */
@@ -1390,7 +1394,8 @@ static bool gfx_v9_0_should_disable_gfxo
pdev->device == p->chip_device &&
pdev->subsystem_vendor == p->subsys_vendor &&
pdev->subsystem_device == p->subsys_device &&
- pdev->revision == p->revision) {
+ (p->revision == AMDGPU_GFXOFF_QUIRK_ANY_REV ||
+ pdev->revision == p->revision)) {
return true;
}
++p;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 369/742] drm/amdgpu/vce1: Fix checking whether VCE1 is idle
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (359 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 368/742] drm/amdgpu/gfx_v9_0: Add gfxoff quirk for Lenovo Picasso 318F Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 370/742] drm/amd/display: Fix __udivdi3 link error in DCN6 DML2 Greg Kroah-Hartman
` (365 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, David Rosca, Timur Kristóf,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <timur.kristof@gmail.com>
commit 4807d0757c1e8ef8aff6d0e65d99f3820fea9833 upstream.
It turns out that the VCE_STATUS register bits that we
used to check whether VCE1 is idle are actually not useful:
VCE_STATUS.JOB_BUSY doesn't exist until VCE3
VCE_STATUS.UENC_BUSY seems to be stuck high on Cape Verde
Instead, do the following:
Check that the read and write pointer matches for each ring.
Check VCE_STATUS.VCPU_REPORT bits to check busy status.
Finally, also check SRBM_STATUS2.VCE_BUSY just in case,
although this one seems bogus on VCE1.
Fixes: d4a640d4b9f3 ("drm/amdgpu/vce1: Implement VCE1 IP block (v2)")
Acked-by: David Rosca <david.rosca@amd.com>
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Signed-off-by: David Rosca <david.rosca@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 0db6125a171f81422736850e3a7fefdf23380073)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/vce_v1_0.c | 25 +++++++++----
drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h | 2 -
2 files changed, 19 insertions(+), 8 deletions(-)
--- a/drivers/gpu/drm/amd/amdgpu/vce_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vce_v1_0.c
@@ -47,6 +47,9 @@
#define VCE_V1_0_STACK_SIZE (64 * 1024)
#define VCE_V1_0_DATA_SIZE (ALIGN(7808 * (AMDGPU_MAX_VCE_HANDLES + 1), VCE_V1_0_ALIGNMENT))
#define VCE_STATUS_VCPU_REPORT_FW_LOADED_MASK 0x02
+#define VCE_STATUS_VCPU_REPORT_AUTO_BUSY_MASK 0x08
+#define VCE_STATUS_VCPU_REPORT_RB0_BUSY_MASK 0x10
+#define VCE_STATUS_VCPU_REPORT_RB1_BUSY_MASK 0x20
static void vce_v1_0_set_ring_funcs(struct amdgpu_device *adev);
static void vce_v1_0_set_irq_funcs(struct amdgpu_device *adev);
@@ -349,19 +352,29 @@ static int vce_v1_0_mc_resume(struct amd
*
* @ip_block: amdgpu_ip_block pointer
*
- * Check whether VCE is busy according to VCE_STATUS.
+ * Check whether VCE is busy according to VCE_STATUS
+ * and whether the ring pointers match.
+ *
* Also check whether the SRBM thinks VCE is busy, although
- * SRBM_STATUS.VCE_BUSY seems to be bogus because it
+ * SRBM_STATUS2.VCE_BUSY seems to be bogus because it
* appears to mirror the VCE_STATUS.VCPU_REPORT_FW_LOADED bit.
*/
static bool vce_v1_0_is_idle(struct amdgpu_ip_block *ip_block)
{
struct amdgpu_device *adev = ip_block->adev;
- bool busy =
- (RREG32(mmVCE_STATUS) & (VCE_STATUS__JOB_BUSY_MASK | VCE_STATUS__UENC_BUSY_MASK)) ||
- (RREG32(mmSRBM_STATUS2) & SRBM_STATUS2__VCE_BUSY_MASK);
- return !busy;
+ /* Check whether the rings are busy. */
+ if (RREG32(mmVCE_RB_RPTR) != RREG32(mmVCE_RB_WPTR) ||
+ RREG32(mmVCE_RB_RPTR2) != RREG32(mmVCE_RB_WPTR2))
+ return false;
+
+ /* Check whether the VCPU is busy. */
+ if (RREG32(mmVCE_STATUS) & (VCE_STATUS_VCPU_REPORT_AUTO_BUSY_MASK |
+ VCE_STATUS_VCPU_REPORT_RB0_BUSY_MASK |
+ VCE_STATUS_VCPU_REPORT_RB1_BUSY_MASK))
+ return false;
+
+ return !(RREG32(mmSRBM_STATUS2) & SRBM_STATUS2__VCE_BUSY_MASK);
}
static int vce_v1_0_wait_for_idle(struct amdgpu_ip_block *ip_block)
--- a/drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h
+++ b/drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h
@@ -63,8 +63,6 @@
#define VCE_SOFT_RESET__ECPU_SOFT_RESET__SHIFT 0x00000000
#define VCE_SOFT_RESET__FME_SOFT_RESET_MASK 0x00000004L
#define VCE_SOFT_RESET__FME_SOFT_RESET__SHIFT 0x00000002
-#define VCE_STATUS__JOB_BUSY_MASK 0x00000001L
-#define VCE_STATUS__JOB_BUSY__SHIFT 0x00000000
#define VCE_STATUS__UENC_BUSY_MASK 0x00000100L
#define VCE_STATUS__UENC_BUSY__SHIFT 0x00000008
#define VCE_STATUS__VCPU_REPORT_MASK 0x000000feL
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 370/742] drm/amd/display: Fix __udivdi3 link error in DCN6 DML2
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (360 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 369/742] drm/amdgpu/vce1: Fix checking whether VCE1 is idle Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 371/742] drm/amd/display: Abort DPMS ON when enabling the link fails Greg Kroah-Hartman
` (364 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Linlin Yang, Mario Limonciello,
Alex Deucher, Dillon Varone, Ivan Lipski, Alex Hung
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Lipski <ivan.lipski@amd.com>
commit d489c42c9bd542b3fbbda97b97dc9a0b07010eb3 upstream.
[Why&How]
dchub_v2_get_sop_total_available_bandwidth_KBps() and
dchub_v2_is_qos_bandwidth_supported_by_sop() divide 64-bit integers
by 100. On 32-bit builds this emits a call to __udivdi3, which the
kernel does not link.
Use double-cast division instead.
Fixes: 7f7d7ea1fa51 ("drm/amd/display: Add new sources for DCN6")
Cc: Linlin Yang <yanglinlin@kylinos.cn>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Dillon Varone <dillon.varone@amd.com>
Signed-off-by: Ivan Lipski <ivan.lipski@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 83e7c8cb33363f2a2f893758c630f9a805ac4573)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/inc/bounding_boxes/utm_qos_model_dchub_v2.h | 32 +++++-----
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/inc/bounding_boxes/utm_qos_model_dchub_v3.h | 2
2 files changed, 17 insertions(+), 17 deletions(-)
--- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/inc/bounding_boxes/utm_qos_model_dchub_v2.h
+++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/inc/bounding_boxes/utm_qos_model_dchub_v2.h
@@ -58,27 +58,27 @@ static inline void dchub_v2_get_sop_tota
{
const struct utm_soc_operating_point *sop = &model->sops[sop_index];
const struct utm_qos_model_socbb *socbb = &model->socbb;
- uint64_t dram_available_bandwidth_KBps_nominal;
- uint64_t fabric_available_bandwidth_KBps_nominal;
- uint64_t dram_available_bandwidth_KBps_urgent;
- uint64_t fabric_available_bandwidth_KBps_urgent;
+ double dram_available_bandwidth_KBps_nominal;
+ double fabric_available_bandwidth_KBps_nominal;
+ double dram_available_bandwidth_KBps_urgent;
+ double fabric_available_bandwidth_KBps_urgent;
- dram_available_bandwidth_KBps_nominal = (uint64_t) sop->uclk_khz
+ dram_available_bandwidth_KBps_nominal = (double) sop->uclk_khz
* socbb->dram_channel_count
* socbb->dram_channel_width_bytes
* socbb->dram_transactions_per_clock
- * socbb->dram_derate_percent_nominal / 100;
- dram_available_bandwidth_KBps_urgent = (uint64_t) sop->uclk_khz
+ * socbb->dram_derate_percent_nominal / 100.0;
+ dram_available_bandwidth_KBps_urgent = (double) sop->uclk_khz
* socbb->dram_channel_count
* socbb->dram_channel_width_bytes
* socbb->dram_transactions_per_clock
- * socbb->dram_derate_percent_urgent / 100;
- fabric_available_bandwidth_KBps_nominal = (uint64_t) sop->fclk_khz
+ * socbb->dram_derate_percent_urgent / 100.0;
+ fabric_available_bandwidth_KBps_nominal = (double) sop->fclk_khz
* socbb->fabric_datapath_to_dcn_data_return_bytes
- * socbb->fabric_derate_percent_nominal / 100;
- fabric_available_bandwidth_KBps_urgent = (uint64_t) sop->fclk_khz
+ * socbb->fabric_derate_percent_nominal / 100.0;
+ fabric_available_bandwidth_KBps_urgent = (double) sop->fclk_khz
* socbb->fabric_datapath_to_dcn_data_return_bytes
- * socbb->fabric_derate_percent_urgent / 100;
+ * socbb->fabric_derate_percent_urgent / 100.0;
total_available_bandwidth->nominal_bandwidth_KBps =
dram_available_bandwidth_KBps_nominal < fabric_available_bandwidth_KBps_nominal ?
@@ -99,8 +99,8 @@ static inline bool dchub_v2_is_qos_bandw
{
struct utm_qos_model_dchub_memory_path_bandwidth_v2 available_bandwidth = {0};
const struct utm_qos_model_dchub_v2 *dchub = model->dchub_v2;
- uint64_t nominal_available_bandwidth_KBps;
- uint64_t urgent_available_bandwidth_KBps;
+ double nominal_available_bandwidth_KBps;
+ double urgent_available_bandwidth_KBps;
if (nominal_utm_budget_percent > dchub->max_nominal_utm_budget_percent ||
nominal_utm_budget_percent < dchub->min_nominal_utm_budget_percent ||
@@ -112,9 +112,9 @@ static inline bool dchub_v2_is_qos_bandw
nominal_available_bandwidth_KBps = available_bandwidth.nominal_bandwidth_KBps;
urgent_available_bandwidth_KBps = available_bandwidth.urgent_bandwidth_KBps;
- if ((nominal_available_bandwidth_KBps * nominal_utm_budget_percent / 100) < qos_bandwidth->nominal_bandwidth_KBps)
+ if ((nominal_available_bandwidth_KBps * nominal_utm_budget_percent / 100.0) < qos_bandwidth->nominal_bandwidth_KBps)
return false;
- else if ((urgent_available_bandwidth_KBps * urgent_utm_budget_percent / 100) < qos_bandwidth->urgent_bandwidth_KBps)
+ else if ((urgent_available_bandwidth_KBps * urgent_utm_budget_percent / 100.0) < qos_bandwidth->urgent_bandwidth_KBps)
return false;
else
return true;
--- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/inc/bounding_boxes/utm_qos_model_dchub_v3.h
+++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/inc/bounding_boxes/utm_qos_model_dchub_v3.h
@@ -50,4 +50,4 @@ struct utm_qos_model_dchub_v3 {
sops[UTM_QOS_MODEL_V3_MAX_LOAD_LEVEL_COUNT][UTM_QOS_MODEL_V3_MAX_SOP_COUNT];
};
-#endif /* #ifndef UTM_QOS_MODEL_DCHUB_V3_H */
\ No newline at end of file
+#endif /* #ifndef UTM_QOS_MODEL_DCHUB_V3_H */
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 371/742] drm/amd/display: Abort DPMS ON when enabling the link fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (361 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 370/742] drm/amd/display: Fix __udivdi3 link error in DCN6 DML2 Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 372/742] drm/amd/display: Add the AUX backlight minimum once on the custom curve Greg Kroah-Hartman
` (363 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Wayne Lin, Abdulla Bubshait,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdulla Bubshait <darkstego@gmail.com>
commit 4aa51b904cac06fe2c82623ce24d80853af730f6 upstream.
Since commit 843049bac7c0 ("drm/amd/display: Split DPMS ON into
parts"), link_set_dpms_on_enable_link() returns
DC_DPMS_FAILED_HANDSHAKE when enable_link() fails and the stream
enable has to be aborted: any failure other than link training, or a
link training failure on DP MST. The link has already been disabled at
that point. The step loop in link_set_dpms_on() treats
DC_DPMS_FAILED_HANDSHAKE like DC_DPMS_SUCCESS and goes on to
link_set_dpms_on_post_enable_link().
Before the split, this path returned right after disable_link(),
because MST displays can't proceed without link training. Now, for
failed MST handshakes MST slots are still allocated. When the link
trains again later, the new payload starts after the leaked slots so
ACT never completes, and the display stays black until
reboot. Replugging or power-cycling the monitor does not recover it.
Seen on Navi 33 (DCN 3.2.1) with a DP 2.1 MST monitor (Odyssey Neo G9)
at UHBR10 x4 with DSC. Link training sometimes fails on DPMS
wake. With this change, the failed attempt leaves no payload behind,
and the next modeset after the sink reconnects bring the monitor back
up.
Return early on DC_DPMS_FAILED_HANDSHAKE, as for
DC_DPMS_SKIPPED_HANDSHAKE. This restores the pre-split behaviour. Link
training failures on non-MST signals still return DC_DPMS_SUCCESS and
continue as before.
Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/6047
Fixes: 843049bac7c0 ("drm/amd/display: Split DPMS ON into parts")
Reviewed-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Abdulla Bubshait <darkstego@gmail.com>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit ece3dae13fb106684f8248f88387b1fbcfef8206)
Cc: stable@vger.kernel.org # 7.3
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/dc/link/link_dpms.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/gpu/drm/amd/display/dc/link/link_dpms.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_dpms.c
@@ -2802,11 +2802,11 @@ enum dc_status link_set_dpms_on(
switch (step_result) {
case DC_DPMS_SUCCESS:
- case DC_DPMS_FAILED_HANDSHAKE:
// Enum is ordered from "best" to "worst" results
result = max(result, step_result);
break;
+ case DC_DPMS_FAILED_HANDSHAKE:
case DC_DPMS_SKIPPED_HANDSHAKE:
return step_result;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 372/742] drm/amd/display: Add the AUX backlight minimum once on the custom curve
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (362 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 371/742] drm/amd/display: Abort DPMS ON when enabling the link fails Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 373/742] drm/amd/display: Apply the HDMI RGB range default only to HDMI signals Greg Kroah-Hartman
` (362 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ray Wu, Hugo Sales, Wayne Lin,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Sales <hugo@hsal.es>
commit 988ab04d773ac089588ce17742f491e9ee8b1793 upstream.
On an AUX backlight, convert_brightness_from_user() maps the user level
through the ATIF custom brightness curve with
convert_custom_brightness(), which rescales the result to
user_min..user_max. convert_brightness_from_user() then rescales it
again, from 0..user_max to user_min..user_max, so the minimum goes in
twice. On the 1..512 nits AUX fallback range, a request for 0 gives
1998 millinits instead of 1000
Rescale the curve's output to 0..user_max and leave the offset to the
caller
Fixes: 8dbd72cb7900 ("drm/amd/display: Export full brightness range to userspace")
Reviewed-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: Hugo Sales <hugo@hsal.es>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 5f95ef2cfd208ca7efe446abfc9e3144dc5ce4fa)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c | 9 ++----
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c | 14 +++++-----
2 files changed, 11 insertions(+), 12 deletions(-)
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
@@ -113,10 +113,10 @@ static inline u32 scale_input_to_fw(int
return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max);
}
-/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
-static inline u32 scale_fw_to_input(int min, int max, u64 input)
+/* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [0..max] */
+static inline u32 scale_fw_to_input(int max, u64 input)
{
- return min + DIV_ROUND_CLOSEST_ULL(input * (max - min), AMDGPU_MAX_BL_LEVEL);
+ return DIV_ROUND_CLOSEST_ULL(input * max, AMDGPU_MAX_BL_LEVEL);
}
static u32 backlight_signal_to_luminance(const struct amdgpu_dm_backlight_caps *caps,
@@ -242,8 +242,7 @@ void convert_custom_brightness(const str
(brightness - lower_signal),
upper_signal - lower_signal);
scale:
- *user_brightness = scale_fw_to_input(min, max,
- DIV_ROUND_CLOSEST(lum * brightness, 101));
+ *user_brightness = scale_fw_to_input(max, DIV_ROUND_CLOSEST(lum * brightness, 101));
}
EXPORT_IF_KUNIT(convert_custom_brightness);
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_backlight_test.c
@@ -1104,10 +1104,10 @@ static void dm_test_custom_brightness_ex
/*
* Exact match: lum=50, brightness_scaled=128
- * result = scale_fw_to_input(min, max, DIV_ROUND_CLOSEST(50*128, 101))
- * = scale_fw_to_input(0, 65535, DIV_ROUND_CLOSEST(6400, 101))
- * = scale_fw_to_input(0, 65535, 63)
- * = 0 + DIV_ROUND_CLOSEST(63 * 65535, 255) = 16191 (approx)
+ * result = scale_fw_to_input(max, DIV_ROUND_CLOSEST(50*128, 101))
+ * = scale_fw_to_input(65535, DIV_ROUND_CLOSEST(6400, 101))
+ * = scale_fw_to_input(65535, 63)
+ * = DIV_ROUND_CLOSEST(63 * 65535, 255) = 16191 (approx)
*/
KUNIT_EXPECT_TRUE(test, brightness != 32896);
KUNIT_EXPECT_TRUE(test, brightness < 32896);
@@ -1150,9 +1150,9 @@ static void dm_test_custom_brightness_be
/*
* Below first data point: lum = DIV_ROUND_CLOSEST(40 * 50, 100) = 20
- * Then: scale_fw_to_input(0, 65535, DIV_ROUND_CLOSEST(20 * 50, 101))
- * = scale_fw_to_input(0, 65535, DIV_ROUND_CLOSEST(1000, 101))
- * = scale_fw_to_input(0, 65535, 10)
+ * Then: scale_fw_to_input(65535, DIV_ROUND_CLOSEST(20 * 50, 101))
+ * = scale_fw_to_input(65535, DIV_ROUND_CLOSEST(1000, 101))
+ * = scale_fw_to_input(65535, 10)
* The output should be significantly less than input.
*/
KUNIT_EXPECT_TRUE(test, brightness < 12850);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 373/742] drm/amd/display: Apply the HDMI RGB range default only to HDMI signals
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (363 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 372/742] drm/amd/display: Add the AUX backlight minimum once on the custom curve Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 374/742] drm/amd/display: Dont warn about vendor infoframe for non-infoframe sinks Greg Kroah-Hartman
` (361 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Wayne Lin, Adrian Betschart,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Betschart <adrian.betschart@cinemaone.ch>
commit 6fd6e75162065c7ac9a4a7f3cf303574f0505d97 upstream.
Since d23f735d0eac, Broadcast RGB "Automatic" selects limited range on
CTA modes when display_info.is_hdmi is set. That flag comes from an HDMI
VSDB in the EDID and says nothing about the link, so a native
DisplayPort monitor whose EDID carries an HDMI VSDB now gets limited
range on CTA modes too. Monitors that ignore the DP range signal show
grey blacks, where 7.2 sent full range.
Require an HDMI signal as well, as the original commit intended. DP++
passive adapters drive an HDMI signal and keep the HDMI behaviour;
native DP, DP MST and active DP-to-HDMI converters get full range again.
Reported and analysed by Andrés Rodríguez in the issue below.
Fixes: d23f735d0eac ("drm/amd/display: Default HDMI RGB output to limited range on CTA modes")
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/6052
Reviewed-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Adrian Betschart <adrian.betschart@cinemaone.ch>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 39f37a2346410a33edf4af17a873ac96bb5244ce)
Cc: stable@vger.kernel.org # 7.3
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 +
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c | 16 +
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.h | 3
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c | 90 +++++++---
4 files changed, 89 insertions(+), 34 deletions(-)
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5088,9 +5088,11 @@ static void amdgpu_dm_atomic_commit_tail
scaling_changed = is_scaling_state_different(dm_new_con_state,
dm_old_con_state);
- if ((new_con_state->hdmi.broadcast_rgb != old_con_state->hdmi.broadcast_rgb) &&
- (dm_old_crtc_state->stream->output_color_space !=
- amdgpu_dm_get_output_color_space(&dm_new_crtc_state->stream->timing, new_con_state)))
+ if (new_con_state->hdmi.broadcast_rgb != old_con_state->hdmi.broadcast_rgb &&
+ dm_old_crtc_state->stream->output_color_space !=
+ amdgpu_dm_get_output_color_space(&dm_new_crtc_state->stream->timing,
+ new_con_state,
+ dm_new_crtc_state->stream->signal))
output_color_space_changed = true;
abm_changed = dm_new_crtc_state->abm_level !=
@@ -5112,8 +5114,10 @@ static void amdgpu_dm_atomic_commit_tail
}
if (output_color_space_changed) {
- dm_new_crtc_state->stream->output_color_space
- = amdgpu_dm_get_output_color_space(&dm_new_crtc_state->stream->timing, new_con_state);
+ dm_new_crtc_state->stream->output_color_space =
+ amdgpu_dm_get_output_color_space(&dm_new_crtc_state->stream->timing,
+ new_con_state,
+ dm_new_crtc_state->stream->signal);
stream_update.output_color_space = &dm_new_crtc_state->stream->output_color_space;
}
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
@@ -737,7 +737,8 @@ EXPORT_IF_KUNIT(get_aspect_ratio);
* With Broadcast RGB left at Automatic follow that default, as i915 does.
*/
static bool rgb_output_is_limited_range(const struct dc_crtc_timing *dc_crtc_timing,
- const struct drm_connector_state *connector_state)
+ const struct drm_connector_state *connector_state,
+ enum signal_type signal)
{
switch (connector_state->hdmi.broadcast_rgb) {
case DRM_HDMI_BROADCAST_RGB_FULL:
@@ -745,14 +746,16 @@ static bool rgb_output_is_limited_range(
case DRM_HDMI_BROADCAST_RGB_LIMITED:
return true;
default:
- return connector_state->connector->display_info.is_hdmi &&
+ return dc_is_hdmi_signal(signal) &&
+ connector_state->connector->display_info.is_hdmi &&
dc_crtc_timing->vic > 1;
}
}
enum dc_color_space
amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing,
- const struct drm_connector_state *connector_state)
+ const struct drm_connector_state *connector_state,
+ enum signal_type signal)
{
enum dc_color_space color_space = COLOR_SPACE_SRGB;
@@ -775,7 +778,7 @@ amdgpu_dm_get_output_color_space(const s
case DRM_MODE_COLORIMETRY_BT2020_RGB:
case DRM_MODE_COLORIMETRY_BT2020_YCC:
if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) {
- if (rgb_output_is_limited_range(dc_crtc_timing, connector_state))
+ if (rgb_output_is_limited_range(dc_crtc_timing, connector_state, signal))
color_space = COLOR_SPACE_2020_RGB_LIMITEDRANGE;
else
color_space = COLOR_SPACE_2020_RGB_FULLRANGE;
@@ -787,7 +790,7 @@ amdgpu_dm_get_output_color_space(const s
default:
if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) {
color_space = COLOR_SPACE_SRGB;
- if (rgb_output_is_limited_range(dc_crtc_timing, connector_state))
+ if (rgb_output_is_limited_range(dc_crtc_timing, connector_state, signal))
color_space = COLOR_SPACE_SRGB_LIMITED;
/*
* 27030khz is the separation point between HDTV and SDTV
@@ -981,7 +984,8 @@ STATIC_IFN_KUNIT void fill_stream_proper
if (is_hdmi_ep)
adjust_colour_depth_from_display_info(timing_out, info);
- stream->output_color_space = amdgpu_dm_get_output_color_space(timing_out, connector_state);
+ stream->output_color_space = amdgpu_dm_get_output_color_space(timing_out, connector_state,
+ stream->signal);
stream->content_type = get_output_content_type(connector_state);
}
EXPORT_IF_KUNIT(fill_stream_properties_from_drm_display_mode);
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.h
@@ -127,7 +127,8 @@ int amdgpu_dm_fill_hdr_info_packet(const
enum dc_color_space
amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing,
- const struct drm_connector_state *connector_state);
+ const struct drm_connector_state *connector_state,
+ enum signal_type signal);
struct drm_display_mode *
amdgpu_dm_get_highest_refresh_rate_mode(struct amdgpu_dm_connector *aconnector,
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
@@ -416,7 +416,8 @@ static void dm_test_output_color_space_d
state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_SRGB);
}
@@ -433,7 +434,8 @@ static void dm_test_output_color_space_d
state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_LIMITED;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_SRGB_LIMITED);
}
@@ -451,7 +453,8 @@ static void dm_test_output_color_space_d
timing.flags.Y_ONLY = 0;
state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_YCBCR709);
}
@@ -470,7 +473,8 @@ static void dm_test_output_color_space_d
timing.flags.Y_ONLY = 1;
state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_YCBCR601_LIMITED);
}
@@ -486,7 +490,8 @@ static void dm_test_output_color_space_b
timing.flags.Y_ONLY = 1;
state.colorspace = DRM_MODE_COLORIMETRY_BT601_YCC;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_YCBCR601_LIMITED);
}
@@ -502,7 +507,8 @@ static void dm_test_output_color_space_b
timing.flags.Y_ONLY = 0;
state.colorspace = DRM_MODE_COLORIMETRY_BT601_YCC;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_YCBCR601);
}
@@ -518,7 +524,8 @@ static void dm_test_output_color_space_b
timing.flags.Y_ONLY = 0;
state.colorspace = DRM_MODE_COLORIMETRY_BT709_YCC;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_YCBCR709);
}
@@ -534,7 +541,8 @@ static void dm_test_output_color_space_b
timing.flags.Y_ONLY = 1;
state.colorspace = DRM_MODE_COLORIMETRY_BT709_YCC;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_YCBCR709_LIMITED);
}
@@ -549,7 +557,8 @@ static void dm_test_output_color_space_o
state.colorspace = DRM_MODE_COLORIMETRY_OPRGB;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_ADOBERGB);
}
@@ -567,7 +576,8 @@ static void dm_test_output_color_space_b
timing.pixel_encoding = PIXEL_ENCODING_RGB;
state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_2020_RGB_FULLRANGE);
}
@@ -584,7 +594,8 @@ static void dm_test_output_color_space_b
state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB;
state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_LIMITED;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_2020_RGB_LIMITEDRANGE);
}
@@ -605,7 +616,8 @@ static void dm_test_output_color_space_d
state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_SRGB_LIMITED);
}
@@ -626,7 +638,8 @@ static void dm_test_output_color_space_d
state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_SRGB);
}
@@ -646,7 +659,31 @@ static void dm_test_output_color_space_d
state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_DISPLAY_PORT),
+ (int)COLOR_SPACE_SRGB);
+}
+
+/**
+ * dm_test_output_color_space_default_rgb_auto_dp_hdmi_vsdb - Automatic on DP stays full range
+ * even when the EDID has an HDMI VSDB
+ * @test: The KUnit test context
+ */
+static void dm_test_output_color_space_default_rgb_auto_dp_hdmi_vsdb(struct kunit *test)
+{
+ struct dc_crtc_timing timing = {};
+ struct drm_connector_state state = {};
+ struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL);
+
+ connector->display_info.is_hdmi = true;
+ timing.pixel_encoding = PIXEL_ENCODING_RGB;
+ timing.vic = 118;
+ state.connector = connector;
+ state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
+ state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO;
+
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_DISPLAY_PORT),
(int)COLOR_SPACE_SRGB);
}
@@ -667,7 +704,8 @@ static void dm_test_output_color_space_d
state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_FULL;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_SRGB);
}
@@ -688,7 +726,8 @@ static void dm_test_output_color_space_b
state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB;
state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_2020_RGB_LIMITEDRANGE);
}
@@ -704,7 +743,8 @@ static void dm_test_output_color_space_b
timing.pixel_encoding = PIXEL_ENCODING_YCBCR422;
state.colorspace = DRM_MODE_COLORIMETRY_BT2020_YCC;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_2020_YCBCR_LIMITED);
}
@@ -723,7 +763,8 @@ static void dm_test_output_color_space_d
timing.flags.Y_ONLY = 1;
state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_YCBCR709_LIMITED);
}
@@ -742,7 +783,8 @@ static void dm_test_output_color_space_d
timing.flags.Y_ONLY = 0;
state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_YCBCR601);
}
@@ -761,7 +803,8 @@ static void dm_test_output_color_space_b
timing.pixel_encoding = PIXEL_ENCODING_RGB;
state.colorspace = DRM_MODE_COLORIMETRY_BT2020_YCC;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_2020_RGB_FULLRANGE);
}
@@ -779,7 +822,8 @@ static void dm_test_output_color_space_b
state.colorspace = DRM_MODE_COLORIMETRY_BT2020_YCC;
state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_LIMITED;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_2020_RGB_LIMITEDRANGE);
}
@@ -796,7 +840,8 @@ static void dm_test_output_color_space_b
timing.pixel_encoding = PIXEL_ENCODING_YCBCR444;
state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB;
- KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
+ KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state,
+ SIGNAL_TYPE_HDMI_TYPE_A),
(int)COLOR_SPACE_2020_YCBCR_LIMITED);
}
@@ -5613,6 +5658,7 @@ static struct kunit_case amdgpu_dm_conne
KUNIT_CASE(dm_test_output_color_space_default_rgb_auto_hdmi_cta),
KUNIT_CASE(dm_test_output_color_space_default_rgb_auto_hdmi_vga),
KUNIT_CASE(dm_test_output_color_space_default_rgb_auto_dp_cta),
+ KUNIT_CASE(dm_test_output_color_space_default_rgb_auto_dp_hdmi_vsdb),
KUNIT_CASE(dm_test_output_color_space_default_rgb_full_hdmi_cta),
KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_auto_hdmi_cta),
KUNIT_CASE(dm_test_output_color_space_bt2020_ycc),
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 374/742] drm/amd/display: Dont warn about vendor infoframe for non-infoframe sinks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (364 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 373/742] drm/amd/display: Apply the HDMI RGB range default only to HDMI signals Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:03 ` [PATCH 7.3 375/742] drm/amd/display: Fix logger leak on perf trace allocation failure Greg Kroah-Hartman
` (360 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Wayne Lin, Paul Menzel, Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Menzel <pmenzel@molgen.mpg.de>
commit 2b784f5e78694d4d852053b3eef3de3f0ff1d02e upstream.
With an EIZO EV2781 connected over HDMI to an AMD Ryzen 3 2200G (Raven)
on an MSI B350M MORTAR (MS-7A37), Linux logs at every boot since v6.16:
amdgpu 0000:30:00.0: [drm] Failed to setup vendor infoframe on connector HDMI-A-1: -22
Commit 6027cbee1900 ("drm/amd/display: Add error check for avi and
vendor infoframe setup function") started to log the return value of
drm_hdmi_vendor_infoframe_from_display_mode(). With `frame` and `mode`
being non-NULL, the helper only fails with -EINVAL, if the sink does
not support HDMI infoframes, that means, if
`connector->display_info.has_hdmi_infoframe` is false, and its
kernel-doc says, that this error can be safely ignored.
drm_parse_hdmi_vsdb_video() only sets `has_hdmi_infoframe`, if the HDMI
VSDB has HDMI_Video_present set, and drm_parse_hdmi_forum_scds() sets
it for sinks with an HF-SCDB. So an HDMI sink, whose VSDB lacks
HDMI_Video_present, triggers the warning, although nothing failed.
The EIZO EV2781 is such a sink. Its HDMI VSDB has a payload of only
seven bytes (source physical address, Supports_AI, and a maximum TMDS
clock of 250 MHz), so the byte with HDMI_Video_present is absent, and
the EDID has no HF-SCDB:
67 03 0c 00 10 00 80 32
Only warn, if the sink supports HDMI infoframes. The infoframe setup
itself is unchanged.
Fixes: 6027cbee1900 ("drm/amd/display: Add error check for avi and vendor infoframe setup function")
Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/5025
Reviewed-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 2abfc667f622eb7132b139db2e175642713662f8)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
@@ -942,7 +942,8 @@ STATIC_IFN_KUNIT void fill_stream_proper
err = drm_hdmi_vendor_infoframe_from_display_mode(&hv_frame,
(struct drm_connector *)connector,
mode_in);
- if (err < 0)
+ /* Sinks without HDMI infoframe support make it fail with -EINVAL. */
+ if (err < 0 && info->has_hdmi_infoframe)
drm_warn_once(connector->dev, "Failed to setup vendor infoframe on connector %s: %zd\n",
connector->name, err);
timing_out->hdmi_vic = hv_frame.vic;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 375/742] drm/amd/display: Fix logger leak on perf trace allocation failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (365 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 374/742] drm/amd/display: Dont warn about vendor infoframe for non-infoframe sinks Greg Kroah-Hartman
@ 2026-12-04 10:03 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 376/742] drm/amd/display: Flip dml2_core_utils_get_segment_horizontal_contiguous() Inputs Greg Kroah-Hartman
` (359 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:03 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Wayne Lin, Jackie Liu, Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jackie Liu <liuyun01@kylinos.cn>
commit 5b148562d193fd63e5d1ae3c442d3d54403c7e51 upstream.
dc_construct_ctx() allocates a logger and stores an alias in dc->dml.logger
before allocating the performance trace object. If dc_perf_trace_create()
fails, the function frees dc_ctx without releasing the logger. Since
dc->ctx is assigned only after the trace allocation succeeds,
dc_destruct() cannot reclaim the logger on this error path.
Free the logger before discarding dc_ctx and clear dc->dml.logger to avoid
leaving a dangling alias after the failed construction.
Fixes: 5d72e247e58c ("drm/amd/display: switch DC over to the new DRM logging macros")
Reviewed-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit ac088505e74932f276ea6e3bbe19713e5770e7a1)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/dc/core/dc.c | 2 ++
1 file changed, 2 insertions(+)
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1020,6 +1020,8 @@ static bool dc_construct_ctx(struct dc *
dc_ctx->perf_trace = dc_perf_trace_create();
if (!dc_ctx->perf_trace) {
+ kfree(dc_ctx->logger);
+ dc->dml.logger = NULL;
kfree(dc_ctx);
ASSERT_CRITICAL(false);
return false;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 376/742] drm/amd/display: Flip dml2_core_utils_get_segment_horizontal_contiguous() Inputs
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (366 preceding siblings ...)
2026-12-04 10:03 ` [PATCH 7.3 375/742] drm/amd/display: Fix logger leak on perf trace allocation failure Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 377/742] drm/amd/display: Keep FreeSync flip timing across plane resets Greg Kroah-Hartman
` (358 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dillon Varone, Mario Limonciello,
Alex Deucher, ChiaHsuan Chung, Austin Zheng, Wayne Lin,
Dan Wheeler
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Austin Zheng <Austin.Zheng@amd.com>
commit 8bcb6863ac318dfadf622598171c79a020fdd7ff upstream.
[Why/How]
Parameters for dml2_core_utils_get_segment_horizontal_contiguous() should be flipped.
Should be swizzle mode then bytes per pixel.
Cc: Dillon Varone <dillon.varone@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: ChiaHsuan Chung <chiahsuan.chung@amd.com>
Signed-off-by: Austin Zheng <Austin.Zheng@amd.com>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 8e985b38672c3de9355dd8f166527f96e472706c)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn5_calcs_dchub.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn5_calcs_dchub.c
+++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn5_calcs_dchub.c
@@ -836,7 +836,7 @@ void dcn5_calculate_swath_and_det_config
p->SwathHeightC[k] = MaximumSwathHeightC[k];
RoundedUpSwathSizeBytesY[k] = p->full_swath_bytes_l[k] / 2;
RoundedUpSwathSizeBytesC[k] = p->full_swath_bytes_c[k];
- p->request_size_bytes_luma[k] = dml2_core_utils_get_segment_horizontal_contiguous(p->BytePerPixY[k], p->display_cfg->plane_descriptors[k].surface.tiling)
+ p->request_size_bytes_luma[k] = dml2_core_utils_get_segment_horizontal_contiguous(p->display_cfg->plane_descriptors[k].surface.tiling, p->BytePerPixY[k])
== dml2_core_utils_is_vertical_rotation(p->display_cfg->plane_descriptors[k].composition.rotation_angle) ? 64 : 128;
p->request_size_bytes_chroma[k] = 256;
@@ -846,7 +846,7 @@ void dcn5_calculate_swath_and_det_config
RoundedUpSwathSizeBytesY[k] = p->full_swath_bytes_l[k];
RoundedUpSwathSizeBytesC[k] = p->full_swath_bytes_c[k] / 2;
p->request_size_bytes_luma[k] = 256;
- p->request_size_bytes_chroma[k] = dml2_core_utils_get_segment_horizontal_contiguous(p->BytePerPixC[k], p->display_cfg->plane_descriptors[k].surface.tiling)
+ p->request_size_bytes_chroma[k] = dml2_core_utils_get_segment_horizontal_contiguous(p->display_cfg->plane_descriptors[k].surface.tiling, p->BytePerPixC[k])
== dml2_core_utils_is_vertical_rotation(p->display_cfg->plane_descriptors[k].composition.rotation_angle) ? 64 : 128;
} else {
@@ -854,9 +854,9 @@ void dcn5_calculate_swath_and_det_config
p->SwathHeightC[k] = MaximumSwathHeightC[k] / 2;
RoundedUpSwathSizeBytesY[k] = p->full_swath_bytes_l[k] / 2;
RoundedUpSwathSizeBytesC[k] = p->full_swath_bytes_c[k] / 2;
- p->request_size_bytes_luma[k] = dml2_core_utils_get_segment_horizontal_contiguous(p->BytePerPixY[k], p->display_cfg->plane_descriptors[k].surface.tiling)
+ p->request_size_bytes_luma[k] = dml2_core_utils_get_segment_horizontal_contiguous(p->display_cfg->plane_descriptors[k].surface.tiling, p->BytePerPixY[k])
== dml2_core_utils_is_vertical_rotation(p->display_cfg->plane_descriptors[k].composition.rotation_angle) ? 64 : 128;
- p->request_size_bytes_chroma[k] = dml2_core_utils_get_segment_horizontal_contiguous(p->BytePerPixC[k], p->display_cfg->plane_descriptors[k].surface.tiling)
+ p->request_size_bytes_chroma[k] = dml2_core_utils_get_segment_horizontal_contiguous(p->display_cfg->plane_descriptors[k].surface.tiling, p->BytePerPixC[k])
== dml2_core_utils_is_vertical_rotation(p->display_cfg->plane_descriptors[k].composition.rotation_angle) ? 64 : 128;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 377/742] drm/amd/display: Keep FreeSync flip timing across plane resets
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (367 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 376/742] drm/amd/display: Flip dml2_core_utils_get_segment_horizontal_contiguous() Inputs Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 378/742] drm/amd/display: Read DRAM channel width from SMU init table Greg Kroah-Hartman
` (357 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Harry Wentland, Davey Hughes,
Wayne Lin, Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davey Hughes <davidralphhughes@gmail.com>
commit fff46a322847a54cf11d5af3d7fc7fa07bc71b29 upstream.
dm_update_plane_state() replaces the DC plane with a newly allocated one
whenever the plane is reset. The new plane's flip timing is zero, and
mod_freesync_handle_preflip() runs before DC stores the new plane's
first flip timestamp, so FreeSync takes the 32-bit microsecond timestamp
itself as the last render time: the monotonic clock modulo about 71.6
minutes.
On a panel with below-the-range compensation (BTR), that engages BTR and
pins the frame time at the BTR mid-point (13.447 ms on a 48-165 Hz
panel). A panel without BTR (max refresh below twice the min) goes
through the fixed refresh path instead and locks to its max refresh
after six frames.
It takes a reset on every flip to keep the panel there, and color
management changes reset the plane. DRM sets color_mgmt_changed whenever
a color property is given a different blob, even one with the same
contents, and KWin 6.8.1 with HDR enabled and its color accuracy setting
at "Prefer efficiency" sets a new GAMMA_LUT blob on every commit
(current KWin master no longer does). Plane resets for CRTC color
changes, added by
commit 7316c4ad2996 ("drm/amd/display: Reset planes for color management
changes"), and later for plane color properties and colorops, made this
reachable on every flip.
Copy the flip timing from the old DC plane into the new one when the
plane stays on the same CRTC. Do it in amdgpu_dm_commit_planes() before
the preflip, after drm_atomic_helper_wait_for_dependencies() has waited
for the previous commit, so the copy holds that commit's flip and does
not race with DC writing it. This covers both the BTR and the fixed
refresh path. A plane that is newly enabled or moved to another CRTC
still starts without history.
Fixes: 180db303ff46 ("drm/amd/display: Add below the range support for FreeSync")
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Davey Hughes <davidralphhughes@gmail.com>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 4acf82d2a2dcca2d7df8649ecafb3da6c1245003)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3797,6 +3797,25 @@ static void dm_arm_vblank_event_pre_prog
drm_crtc_vblank_get(&acrtc->base);
}
+/*
+ * FreeSync times each frame from the plane's previous flip, and a plane
+ * reset gives the new DC plane zeroed flip timing, so copy it over. Do
+ * this at commit time, not in atomic check: by then the previous commit
+ * has finished writing it.
+ */
+static void
+dm_plane_inherit_flip_time(struct dc_plane_state *dc_plane_state,
+ struct drm_plane_state *old_plane_state,
+ struct drm_plane_state *new_plane_state)
+{
+ struct dc_plane_state *old_dc_plane_state =
+ to_dm_plane_state(old_plane_state)->dc_state;
+
+ if (old_dc_plane_state && old_dc_plane_state != dc_plane_state &&
+ old_plane_state->crtc == new_plane_state->crtc)
+ dc_plane_state->time = old_dc_plane_state->time;
+}
+
static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state,
struct drm_device *dev,
struct amdgpu_display_manager *dm,
@@ -3896,6 +3915,9 @@ static void amdgpu_dm_commit_planes(stru
if (!dc_plane)
continue;
+ dm_plane_inherit_flip_time(dc_plane, old_plane_state,
+ new_plane_state);
+
bundle->surface_updates[planes_count].surface = dc_plane;
if (new_pcrtc_state->color_mgmt_changed || new_plane_state->color_mgmt_changed) {
bundle->surface_updates[planes_count].gamma = &dc_plane->gamma_correction;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 378/742] drm/amd/display: Read DRAM channel width from SMU init table
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (368 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 377/742] drm/amd/display: Keep FreeSync flip timing across plane resets Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 379/742] drm/amd/display: Restore PSR-SU guard in power module Greg Kroah-Hartman
` (356 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dillon Varone, Mario Limonciello,
Alex Deucher, ChiaHsuan Chung, Wenjing Liu, Wayne Lin,
Dan Wheeler
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenjing Liu <wenjing.liu@amd.com>
commit 3846f4542b4ba5a95405527d1e68864a9e9f3fcf upstream.
[Why]
The channel count came from the SMU init table but the channel
width came from VBIOS vram info. Both values need to describe the
same memory type.
[How]
Add DramChannelWidthBytes to MemoryConfig_t, using a reserved slot
so the layout is unchanged. Populate the channel width in bw_params
from the init table instead of VBIOS vram info.
Cc: Dillon Varone <dillon.varone@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: ChiaHsuan Chung <chiahsuan.chung@amd.com>
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 37d64c58f610d771b7ab8cfbf7d9f5606939947b)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dalsmc.h | 3 ++-
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c | 3 +--
2 files changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dalsmc.h
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dalsmc.h
@@ -334,7 +334,8 @@ typedef struct {
typedef struct {
uint32_t NumUmcChannels;
- uint32_t Reserved[3];
+ uint32_t DramChannelWidthBytes;
+ uint32_t Reserved[2];
} MemoryConfig_t;
/**
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c
@@ -670,8 +670,7 @@ static bool dcn60_fetch_dal_init_table(s
dcn60_populate_dc_mode_limit(&bw_params->dc_mode_limit, init_table);
bw_params->num_channels = init_table->MemoryConfig.NumUmcChannels;
- bw_params->dram_channel_width_bytes =
- clk_mgr->base.ctx->dc_bios->vram_info.dram_channel_width_bytes;
+ bw_params->dram_channel_width_bytes = init_table->MemoryConfig.DramChannelWidthBytes;
dcn60_populate_utm_qos_model(clk_mgr, &bw_params->utm_qos_model, init_table);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 379/742] drm/amd/display: Restore PSR-SU guard in power module
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (369 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 378/742] drm/amd/display: Read DRAM channel width from SMU init table Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 380/742] drm/amd/display: Take every stream out of self-refresh before a modeset Greg Kroah-Hartman
` (355 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ray Wu, Egor Perevoshchikov,
Wayne Lin, Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Egor Perevoshchikov <rickbatra0z@gmail.com>
commit 57decaa0e378bf2481eae5f49293a5202976a19e upstream.
Commit a5ce8695d6d1 ("drm/amd/display: Avoid configuring PSR granularity
if PSR-SU not supported") restricted DSC slice-height configuration to
PSR-SU. The power-module integration removed that guarded caller. Its
replacement in mod_power_psr_notify_mode_change() calls
psr_su_set_dsc_slice_height() unconditionally and ignores its return value.
On PSR1 links with a DSC slice configuration, this applies a PSR-SU-only
alignment check even though selective update is not enabled. If the
calculated DSC slice height is not a multiple of the nonzero advertised
SU Y granularity, the helper triggers an assertion. It also sets
dsc_slice_height before failing the check, so the caller passes this
SU-specific value into PSR1 setup despite the failure.
Restore the PSR version guard and failure handling in the new caller.
PSR1 proceeds with the zero-initialized DSC slice height, while PSR-SU
retains its alignment validation and stops setup if that validation fails.
Fixes: 3c108046e1d6 ("drm/amd/display: Add power module on Linux")
Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/3027
Reviewed-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: Egor Perevoshchikov <rickbatra0z@gmail.com>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 83558fcf83cc911e09962ea17c883add596766c0)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/modules/power/power_psr.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/modules/power/power_psr.c b/drivers/gpu/drm/amd/display/modules/power/power_psr.c
index 96bb77fff05b..7139395b5c00 100644
--- a/drivers/gpu/drm/amd/display/modules/power/power_psr.c
+++ b/drivers/gpu/drm/amd/display/modules/power/power_psr.c
@@ -94,9 +94,12 @@ bool mod_power_psr_notify_mode_change(struct mod_power *mod_power,
* The value of DSC slice height is determined in DSC Driver but it does not
* propagated out here, so we need to calculate it as below 'slice_height'.
*/
- psr_su_set_dsc_slice_height(dc, link,
- (struct dc_stream_state *) stream,
- &psr_config);
+ if (link->psr_settings.psr_version == DC_PSR_VERSION_SU_1) {
+ if (!psr_su_set_dsc_slice_height(dc, link,
+ (struct dc_stream_state *)stream,
+ &psr_config))
+ return false;
+ }
dc_link_setup_psr(link, stream, &psr_config, &psr_context);
--
2.56.1
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 380/742] drm/amd/display: Take every stream out of self-refresh before a modeset
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (370 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 379/742] drm/amd/display: Restore PSR-SU guard in power module Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 381/742] drm/amd/display: Update DCN42B stutter latency to match DCN42 Greg Kroah-Hartman
` (354 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ray Wu, Hugo Sales, Wayne Lin,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Sales <hugo@hsal.es>
commit 09b6bf1a04cc6bbcbb8bb29fa1e38fa8a9f8d1dc upstream.
Commit 3c108046e1d6 ("drm/amd/display: Add power module on Linux")
dropped amdgpu_dm_psr_disable_all() and amdgpu_dm_replay_disable_all()
from amdgpu_dm_commit_streams(). Since then, a modeset only disables
self-refresh on the CRTCs in the commit, so an eDP on another CRTC stays
in PSR through dc_commit_streams()
Commit 6ee90e88b976 ("drm/amd/display: PSR eDP p-state warning occurs
intermittently after unplug DP") added that disable-all for this very
case. With it gone, turning off or unplugging an HDMI monitor while the
eDP is in PSR hangs DMUB on a Cezanne laptop (DCN 2.1), on the first
try:
dc_dmub_srv_log_diagnostic_data: DMCUB error
Error queueing DMUB command: status=2
The eDP then stays frozen until a GPU reset
Do the same through the power module's events. When a CRTC that is or
was active needs a modeset, raise the PSR and Replay pause events on
every stream mod_power tracks and wait for self-refresh to exit, before
amdgpu_dm_mod_power_update_streams() changes the stream set. Clear them
on the commit's streams after amdgpu_dm_mod_power_setup_streams(), since
enabling a stream clears psr_feature_enabled until then. Use
psr_event_pause and replay_event_pause rather than the hw_programming
events, which a fast update on the eDP can clear in
amdgpu_dm_enable_self_refresh() while the modeset is still running
Fixes: 3c108046e1d6 ("drm/amd/display: Add power module on Linux")
Reviewed-by: Ray Wu <ray.wu@amd.com>
Signed-off-by: Hugo Sales <hugo@hsal.es>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 5d90fdb959505b5f42f2dec699521ac56b4174be)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 101 ++++++++++++++++++++++
1 file changed, 101 insertions(+)
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4442,6 +4442,105 @@ static void amdgpu_dm_mod_power_update_s
}
}
+static bool amdgpu_dm_self_refresh_pause_needed(struct drm_atomic_commit *state)
+{
+ struct drm_crtc_state *old_crtc_state, *new_crtc_state;
+ struct drm_crtc *crtc;
+ int i;
+
+ for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i)
+ if (drm_atomic_crtc_needs_modeset(new_crtc_state) &&
+ (old_crtc_state->active || new_crtc_state->active))
+ return true;
+
+ return false;
+}
+
+static bool amdgpu_dm_is_new_modeset_stream(struct drm_atomic_commit *state,
+ const struct dc_stream_state *stream)
+{
+ struct drm_crtc_state *new_crtc_state;
+ struct drm_crtc *crtc;
+ int i;
+
+ for_each_new_crtc_in_state(state, crtc, new_crtc_state, i)
+ if (drm_atomic_crtc_needs_modeset(new_crtc_state) &&
+ to_dm_crtc_state(new_crtc_state)->stream == stream)
+ return true;
+
+ return false;
+}
+
+/*
+ * A modeset CRTC may have no PSR or Replay, such as an HDMI output being
+ * turned off, while an eDP on another CRTC is still in self-refresh. Pause
+ * self-refresh on every stream mod_power tracks before
+ * amdgpu_dm_mod_power_update_streams() changes the set: the old streams of
+ * the CRTCs in the commit and the unchanged streams of the new state.
+ * Unlike hw_programming, which a fast update on another CRTC clears, the
+ * pause holds until amdgpu_dm_resume_self_refresh()
+ */
+static void amdgpu_dm_pause_self_refresh(struct drm_atomic_commit *state,
+ struct amdgpu_display_manager *dm,
+ struct dc_state *dc_state)
+{
+ struct drm_crtc_state *old_crtc_state;
+ struct dc_stream_state *stream;
+ struct drm_crtc *crtc;
+ int i;
+
+ if (!amdgpu_dm_self_refresh_pause_needed(state))
+ return;
+
+ guard(mutex)(&dm->dc_lock);
+ dc_exit_ips_for_hw_access(dm->dc);
+
+ for_each_old_crtc_in_state(state, crtc, old_crtc_state, i) {
+ stream = to_dm_crtc_state(old_crtc_state)->stream;
+ if (!old_crtc_state->active || !stream)
+ continue;
+
+ amdgpu_dm_psr_set_event(dm, stream, true, psr_event_pause, true);
+ amdgpu_dm_replay_set_event(dm, stream, true, replay_event_pause, true);
+ }
+
+ for (i = 0; i < dc_state->stream_count; i++) {
+ stream = dc_state->streams[i];
+ if (amdgpu_dm_is_new_modeset_stream(state, stream))
+ continue;
+
+ amdgpu_dm_psr_set_event(dm, stream, true, psr_event_pause, true);
+ amdgpu_dm_replay_set_event(dm, stream, true, replay_event_pause, true);
+ }
+}
+
+/*
+ * Ends amdgpu_dm_pause_self_refresh() on the streams of the commit, which
+ * mod_power tracks from amdgpu_dm_mod_power_update_streams() on, even if
+ * dc_commit_streams() failed. mod_power keeps events across
+ * mod_power_replace_stream(), so the replaced streams carry the pause too.
+ * Runs after amdgpu_dm_mod_power_setup_streams(), since enabling a stream
+ * clears psr_feature_enabled and replay_feature_enabled on its link until
+ * then, and the set_event helpers skip a link without them
+ */
+static void amdgpu_dm_resume_self_refresh(struct drm_atomic_commit *state,
+ struct amdgpu_display_manager *dm,
+ struct dc_state *dc_state)
+{
+ int i;
+
+ if (!dc_state || !amdgpu_dm_self_refresh_pause_needed(state))
+ return;
+
+ guard(mutex)(&dm->dc_lock);
+ for (i = 0; i < dc_state->stream_count; i++) {
+ amdgpu_dm_psr_set_event(dm, dc_state->streams[i], false,
+ psr_event_pause, false);
+ amdgpu_dm_replay_set_event(dm, dc_state->streams[i], false,
+ replay_event_pause, false);
+ }
+}
+
/**
* amdgpu_dm_mod_power_setup_streams - setup mod_power stream state post modeset
* @state: the drm atomic state
@@ -4532,6 +4631,7 @@ static void amdgpu_dm_commit_streams(str
acrtc->wb_enabled = false;
}
+ amdgpu_dm_pause_self_refresh(state, dm, dc_state);
amdgpu_dm_mod_power_update_streams(state, dm);
for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state,
@@ -5270,6 +5370,7 @@ static void amdgpu_dm_atomic_commit_tail
}
amdgpu_dm_mod_power_setup_streams(state, dm);
+ amdgpu_dm_resume_self_refresh(state, dm, dc_state);
for_each_new_crtc_in_state(state, crtc, new_crtc_state, j)
if (new_crtc_state->async_flip)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 381/742] drm/amd/display: Update DCN42B stutter latency to match DCN42
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (371 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 380/742] drm/amd/display: Take every stream out of self-refresh before a modeset Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 382/742] drm/amdgpu: Allow cancelling a requested NPS mode Greg Kroah-Hartman
` (353 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dillon Varone, Charlene Liu,
Mario Limonciello, Alex Deucher, ChiaHsuan Chung, Allen Pan,
Wayne Lin, Dan Wheeler
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allen Pan <Allen.Pan@amd.com>
commit 007e7bf5692d93535adf943cd93c0e49b4e20e9d upstream.
[Why]
The DCN42B stutter latencies do not match DCN42, which can lead to
underflow and stutter issues.
[How]
Update the DCN42B LPDDR5/LPCAMM2 stutter latencies to the same
values DCN42 already uses.
Cc: Dillon Varone <dillon.varone@amd.com>
Cc: Charlene Liu <charlene.liu@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: ChiaHsuan Chung <chiahsuan.chung@amd.com>
Signed-off-by: Allen Pan <Allen.Pan@amd.com>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit c6b576ac64cedc990f3885efa85603fe5998da3f)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/inc/bounding_boxes/dcn42b_soc_bb.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/inc/bounding_boxes/dcn42b_soc_bb.h
+++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/inc/bounding_boxes/dcn42b_soc_bb.h
@@ -191,8 +191,8 @@ static const struct dml2_soc_bb dml2_soc
.dram_clk_change_blackout_us = 36,
.fclk_change_blackout_us = 0,
.g7_ppt_blackout_us = 0,
- .stutter_enter_plus_exit_latency_us = 14,
- .stutter_exit_latency_us = 12,
+ .stutter_enter_plus_exit_latency_us = 15.5,
+ .stutter_exit_latency_us = 13.5,
.z8_stutter_enter_plus_exit_latency_us = 300,
.z8_stutter_exit_latency_us = 200,
},
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 382/742] drm/amdgpu: Allow cancelling a requested NPS mode
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (372 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 381/742] drm/amd/display: Update DCN42B stutter latency to match DCN42 Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 383/742] drm/amdgpu: enable MGCG/FGCG/PERF_CLK for GC 11.0.2 Greg Kroah-Hartman
` (352 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Lijo Lazar, Asad Kamal, Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lijo Lazar <lijo.lazar@amd.com>
commit 9284db9e6ebf300b754b406525576d4848ea96f5 upstream.
NPS mode change request doesn't allow to request the current mode. This
causes an issue where a user stores a request and later wants to cancel
the request by writing the current mode back. The pending request stays
the same as before.
Allow user to change the mode by comparing against the cached request.
Writing the current mode back clears the pending request without asking
for a reload.
Fixes: 012be6f22c01 ("drm/amdgpu: Add sysfs interfaces for NPS mode")
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Asad Kamal <asad.kamal@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 595b5879f1bf776a8c2d085253d3bff2d19dfb57)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 52 ++++++++++++++++++++++++--------
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 4 ++
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 13 ++++++++
3 files changed, 56 insertions(+), 13 deletions(-)
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -1281,6 +1281,40 @@ static ssize_t available_memory_partitio
return size;
}
+void amdgpu_gmc_set_requested_nps_mode(struct amdgpu_device *adev,
+ enum amdgpu_memory_partition mode)
+{
+ struct amdgpu_hive_info *hive;
+
+ /* If device is part of hive, all devices in the hive should request the
+ * same mode. Hence store the requested mode in hive.
+ */
+ hive = amdgpu_get_xgmi_hive(adev);
+ if (hive) {
+ atomic_set(&hive->requested_nps_mode, mode);
+ amdgpu_put_xgmi_hive(hive);
+ } else {
+ adev->gmc.requested_nps_mode = mode;
+ }
+}
+
+enum amdgpu_memory_partition
+amdgpu_gmc_get_requested_nps_mode(struct amdgpu_device *adev)
+{
+ struct amdgpu_hive_info *hive;
+ enum amdgpu_memory_partition mode;
+
+ hive = amdgpu_get_xgmi_hive(adev);
+ if (hive) {
+ mode = atomic_read(&hive->requested_nps_mode);
+ amdgpu_put_xgmi_hive(hive);
+ } else {
+ mode = adev->gmc.requested_nps_mode;
+ }
+
+ return mode;
+}
+
static ssize_t current_memory_partition_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
@@ -1288,7 +1322,6 @@ static ssize_t current_memory_partition_
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_to_adev(ddev);
enum amdgpu_memory_partition mode;
- struct amdgpu_hive_info *hive;
int i;
mode = UNKNOWN_MEMORY_PARTITION_MODE;
@@ -1302,23 +1335,16 @@ static ssize_t current_memory_partition_
if (mode == UNKNOWN_MEMORY_PARTITION_MODE)
return -EINVAL;
- if (mode == adev->gmc.gmc_funcs->query_mem_partition_mode(adev)) {
+ if (mode == amdgpu_gmc_get_requested_nps_mode(adev)) {
dev_info(
adev->dev,
- "requested NPS mode is same as current NPS mode, skipping\n");
+ "requested NPS mode is same as current/already requested NPS mode, skipping\n");
return count;
}
- /* If device is part of hive, all devices in the hive should request the
- * same mode. Hence store the requested mode in hive.
- */
- hive = amdgpu_get_xgmi_hive(adev);
- if (hive) {
- atomic_set(&hive->requested_nps_mode, mode);
- amdgpu_put_xgmi_hive(hive);
- } else {
- adev->gmc.requested_nps_mode = mode;
- }
+ amdgpu_gmc_set_requested_nps_mode(adev, mode);
+ if (mode == amdgpu_gmc_query_memory_partition(adev))
+ return count;
dev_info(
adev->dev,
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -479,6 +479,10 @@ enum amdgpu_memory_partition
amdgpu_gmc_get_memory_partition(struct amdgpu_device *adev, u32 *supp_modes);
enum amdgpu_memory_partition
amdgpu_gmc_query_memory_partition(struct amdgpu_device *adev);
+void amdgpu_gmc_set_requested_nps_mode(struct amdgpu_device *adev,
+ enum amdgpu_memory_partition mode);
+enum amdgpu_memory_partition
+amdgpu_gmc_get_requested_nps_mode(struct amdgpu_device *adev);
int amdgpu_gmc_init_mem_ranges(struct amdgpu_device *adev);
void amdgpu_gmc_init_sw_mem_ranges(struct amdgpu_device *adev,
struct amdgpu_mem_partition_info *mem_ranges);
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -1616,6 +1616,7 @@ static int gmc_v9_0_early_init(struct am
static int gmc_v9_0_late_init(struct amdgpu_ip_block *ip_block)
{
struct amdgpu_device *adev = ip_block->adev;
+ bool nps_switch_support;
int r;
r = amdgpu_gmc_allocate_vm_inv_eng(adev);
@@ -1640,6 +1641,18 @@ static int gmc_v9_0_late_init(struct amd
amdgpu_ras_reset_error_count(adev, AMDGPU_RAS_BLOCK__HDP);
}
+ nps_switch_support = !adev->gmc.xgmi.connected_to_cpu &&
+ (hweight32(adev->gmc.supported_nps_modes &
+ AMDGPU_ALL_NPS_MASK) > 1);
+ /* Initialize requested NPS mode to be the same as current mode */
+ if (nps_switch_support) {
+ enum amdgpu_memory_partition mode =
+ amdgpu_gmc_get_requested_nps_mode(adev);
+ if (mode == UNKNOWN_MEMORY_PARTITION_MODE)
+ amdgpu_gmc_set_requested_nps_mode(
+ adev, amdgpu_gmc_query_memory_partition(adev));
+ }
+
return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 383/742] drm/amdgpu: enable MGCG/FGCG/PERF_CLK for GC 11.0.2
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (373 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 382/742] drm/amdgpu: Allow cancelling a requested NPS mode Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 384/742] drm/amdgpu: fix TLB invalidation fence handling v4 Greg Kroah-Hartman
` (351 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Andrei Krautsou, Kenneth Feng,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrei Krautsou <an9949an@gmail.com>
commit 491aa2b083e18ef11d34f776bcb0e396a84f47e4 upstream.
GC 11.0.2 (Navi33) never got the GFX MGCG, FGCG and PERF_CLK clock
gating flags. GC 11.0.0, 11.0.1 and 11.0.4 have all three, GC 11.0.3
has MGCG. The gfx_v11_0 code behind these flags is shared by all
GC 11 parts. Enable them for GC 11.0.2, same as for GC 11.0.0.
Without the flags the driver does not clear the override bits in
RLC_CGTT_MGCG_OVERRIDE (0x000605e7 under load), so this gating stays
off. On RX 7600S the GFX clock is limited by the GFX TDC limit
(68 A), in Linux and in Windows. With the gating off each MHz costs
more GFX current, so PMFW stops at a lower clock than in Windows.
vkpeak fp32-scalar for 300 s, median after the first 60 s, GFX
current is about 68 A (TDC limit) in all cases:
gfxclk VDDGFX GFLOPS
current flags 2030 MHz 800 mV 8915
+ MGCG 2261 MHz 873 mV 9921
+ MGCG, FGCG, PERF_CLK 2314 MHz 894 mV 10104
Windows 11, AMD driver 910 mV 10157-10186
GFLOPS per MHz is the same, only the current per clock goes down.
Windows shows other clock sensors, so there I compare GFLOPS only.
With all three flags vkpeak is within 1% of Windows. MGCG gives most
of the gain, FGCG and PERF_CLK add about 2% more.
Tested on one laptop, ASUS TUF A16 FA617NS (RX 7600S, PMFW 82.97.0),
Fedora kernel 7.2.11, Mesa 26.2.5, with the same flags set by a local
debug patch. One 300 s vkpeak run for each setting and some gaming,
no amdgpu errors in dmesg. Suspend/resume and long runs are not
tested yet.
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/6082
Signed-off-by: Andrei Krautsou <an9949an@gmail.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Signed-off-by: Andrei Krautsou <an9949an@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 85e5015b7879c04f7b9aabc865cdf7bcdf3d7470)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/soc21.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/gpu/drm/amd/amdgpu/soc21.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc21.c
@@ -599,7 +599,10 @@ static int soc21_common_early_init(struc
adev->cg_flags =
AMD_CG_SUPPORT_GFX_CGCG |
AMD_CG_SUPPORT_GFX_CGLS |
+ AMD_CG_SUPPORT_GFX_MGCG |
AMD_CG_SUPPORT_REPEATER_FGCG |
+ AMD_CG_SUPPORT_GFX_FGCG |
+ AMD_CG_SUPPORT_GFX_PERF_CLK |
AMD_CG_SUPPORT_VCN_MGCG |
AMD_CG_SUPPORT_JPEG_MGCG |
AMD_CG_SUPPORT_ATHUB_MGCG |
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 384/742] drm/amdgpu: fix TLB invalidation fence handling v4
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (374 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 383/742] drm/amdgpu: enable MGCG/FGCG/PERF_CLK for GC 11.0.2 Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 385/742] drm/amdgpu: Fix UserQ slot availability checks Greg Kroah-Hartman
` (350 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christian König, Felix Kuehling,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <christian.koenig@amd.com>
commit 566ed98e48be75a76eea34745815a51ba36687a8 upstream.
After each unmap it might be necessary to invalidate the TLB to flush out
VM changes to the HW and make it visible to executing work.
We tracked that as part of the vm->last_update fence, but as pointed out
by David it can be that this is overwritten by PDE updates when we have a
combined unmap/map operation.
In that case userspace doesn't correctly wait for the TLB invalidation to
finish leading to all kind of problems (sq_int, page faults etc...).
v2: fix ref leaking and error handling as pointed out by AI
v3: fix inverted ! pointed out by Benjamin
v4: fix || / && pointed out by Benjamin
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 892f46c7ae70969dbe0e0b88b5864df6f5582b98)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 32 ++++++++++--------
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 39 +++++++++++------------
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 13 ++++---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c | 22 ++++++++++--
4 files changed, 60 insertions(+), 46 deletions(-)
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -801,8 +801,10 @@ amdgpu_gem_va_update_vm(struct amdgpu_de
/* Always update PDEs after we touched the mappings. */
r = amdgpu_vm_update_pdes(adev, vm, false);
- if (r)
- goto error;
+
+error:
+ if (r && r != -ERESTARTSYS)
+ DRM_ERROR("Couldn't update BO_VA (%d)\n", r);
if ((operation == AMDGPU_VA_OP_MAP ||
operation == AMDGPU_VA_OP_REPLACE) &&
@@ -811,27 +813,27 @@ amdgpu_gem_va_update_vm(struct amdgpu_de
/*
* For MAP/REPLACE of non per-VM BOs we need to sync to both the
* bo_va->last_pt_update and vm->last_update or otherwise we
- * potentially miss the PDE updates.
+ * potentially miss the PDE updates or TLB invalidation.
*/
fence = dma_fence_unwrap_merge(vm->last_update,
+ vm->last_tlb_inv,
bo_va->last_pt_update);
- if (!fence) {
- /* As fallback in OOM situations */
- dma_fence_wait(vm->last_update, false);
+ if (!fence)
dma_fence_wait(bo_va->last_pt_update, false);
- fence = dma_fence_get_stub();
- }
+
} else {
- fence = dma_fence_get(vm->last_update);
+ fence = dma_fence_unwrap_merge(vm->last_update,
+ vm->last_tlb_inv);
}
- return fence;
-
-error:
- if (r && r != -ERESTARTSYS)
- DRM_ERROR("Couldn't update BO_VA (%d)\n", r);
+ if (!fence) {
+ /* As fallback in OOM situations */
+ dma_fence_wait(vm->last_update, false);
+ dma_fence_wait(vm->last_tlb_inv, false);
+ fence = dma_fence_get_stub();
+ }
- return dma_fence_get(vm->last_update);
+ return fence;
}
int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1083,21 +1083,16 @@ static void amdgpu_vm_tlb_seq_cb(struct
*/
static void
amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params,
- struct dma_fence **fence,
+ struct dma_fence *fence,
struct amdgpu_vm_tlb_seq_struct *tlb_cb)
{
struct amdgpu_vm *vm = params->vm;
tlb_cb->vm = vm;
- if (!fence || !*fence) {
- amdgpu_vm_tlb_seq_cb(NULL, &tlb_cb->cb);
- return;
- }
-
- if (!dma_fence_add_callback(*fence, &tlb_cb->cb,
- amdgpu_vm_tlb_seq_cb)) {
- dma_fence_put(vm->last_tlb_flush);
- vm->last_tlb_flush = dma_fence_get(*fence);
+ if (fence && !dma_fence_add_callback(fence, &tlb_cb->cb,
+ amdgpu_vm_tlb_seq_cb)) {
+ dma_fence_put(vm->last_seq_flush);
+ vm->last_seq_flush = dma_fence_get(fence);
} else {
amdgpu_vm_tlb_seq_cb(NULL, &tlb_cb->cb);
}
@@ -1107,11 +1102,12 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_upd
* sort out the issues with KIQ/MES TLB invalidation timeouts.
*/
if (!params->unlocked && vm->need_tlb_fence) {
- amdgpu_vm_tlb_fence_create(params->adev, vm, fence);
+ amdgpu_vm_tlb_fence_create(params->adev, vm, fence,
+ &vm->last_tlb_inv);
/* Makes sure no PD/PT is freed before the flush */
- dma_resv_add_fence(vm->root.bo->tbo.base.resv, *fence,
- DMA_RESV_USAGE_BOOKKEEP);
+ dma_resv_add_fence(vm->root.bo->tbo.base.resv,
+ vm->last_tlb_inv, DMA_RESV_USAGE_BOOKKEEP);
}
}
@@ -1260,7 +1256,7 @@ int amdgpu_vm_update_range(struct amdgpu
goto error_free;
if (params.needs_flush) {
- amdgpu_vm_tlb_flush(¶ms, fence, tlb_cb);
+ amdgpu_vm_tlb_flush(¶ms, *fence, tlb_cb);
tlb_cb = NULL;
}
@@ -2647,7 +2643,8 @@ int amdgpu_vm_init(struct amdgpu_device
vm->last_update = dma_fence_get_stub();
vm->last_unlocked = dma_fence_get_stub();
- vm->last_tlb_flush = dma_fence_get_stub();
+ vm->last_seq_flush = dma_fence_get_stub();
+ vm->last_tlb_inv = dma_fence_get_stub();
vm->generation = amdgpu_vm_generation(adev, NULL);
mutex_init(&vm->eviction_lock);
@@ -2691,7 +2688,8 @@ error_free_root:
error_free_delayed:
dma_fence_put(vm->last_update);
- dma_fence_put(vm->last_tlb_flush);
+ dma_fence_put(vm->last_seq_flush);
+ dma_fence_put(vm->last_tlb_inv);
dma_fence_put(vm->last_unlocked);
ttm_lru_bulk_move_fini(&adev->mman.bdev, &vm->lru_bulk_move);
amdgpu_vm_fini_entities(vm);
@@ -2791,11 +2789,12 @@ void amdgpu_vm_fini(struct amdgpu_device
amdgpu_bo_reserve(root, true);
dma_fence_wait(vm->last_unlocked, false);
dma_fence_put(vm->last_unlocked);
- dma_fence_wait(vm->last_tlb_flush, false);
+ dma_fence_wait(vm->last_seq_flush, false);
/* Make sure that all fence callbacks have completed */
- dma_fence_lock_irqsave(vm->last_tlb_flush, flags);
- dma_fence_unlock_irqrestore(vm->last_tlb_flush, flags);
- dma_fence_put(vm->last_tlb_flush);
+ dma_fence_lock_irqsave(vm->last_seq_flush, flags);
+ dma_fence_unlock_irqrestore(vm->last_seq_flush, flags);
+ dma_fence_put(vm->last_seq_flush);
+ dma_fence_put(vm->last_tlb_inv);
list_for_each_entry_safe(mapping, tmp, &vm->freed, list) {
if (mapping->flags & AMDGPU_VM_PAGE_PRT && prt_fini_needed) {
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -401,11 +401,12 @@ struct amdgpu_vm {
struct drm_sched_entity immediate;
struct drm_sched_entity delayed;
- /* Last finished delayed update */
+ /* Last TLB seq/fence */
atomic64_t tlb_seq;
- struct dma_fence *last_tlb_flush;
+ struct dma_fence *last_seq_flush;
atomic64_t kfd_last_flushed_seq;
uint64_t tlb_fence_context;
+ struct dma_fence *last_tlb_inv;
/* How many times we had to re-generate the page tables */
uint64_t generation;
@@ -642,7 +643,7 @@ static inline uint64_t amdgpu_vm_tlb_seq
* sure that the dma_fence structure isn't freed up.
*/
rcu_read_lock();
- lock = dma_fence_spinlock(vm->last_tlb_flush);
+ lock = dma_fence_spinlock(vm->last_seq_flush);
rcu_read_unlock();
spin_lock_irqsave(lock, flags);
@@ -683,9 +684,9 @@ void amdgpu_vm_update_fault_cache(struct
uint32_t status,
unsigned int vmhub);
void amdgpu_vm_tlb_fence_create(struct amdgpu_device *adev,
- struct amdgpu_vm *vm,
- struct dma_fence **fence);
-
+ struct amdgpu_vm *vm,
+ struct dma_fence *dep,
+ struct dma_fence **fence);
void amdgpu_vm_print_task_info(struct amdgpu_device *adev,
struct amdgpu_task_info *task_info);
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_tlb_fence.c
@@ -75,7 +75,19 @@ static const struct dma_fence_ops amdgpu
.get_timeline_name = amdgpu_tlb_fence_get_timeline_name
};
-void amdgpu_vm_tlb_fence_create(struct amdgpu_device *adev, struct amdgpu_vm *vm,
+/**
+ * amdgpu_vm_tlb_fence_create - create a TLB invalidation fence
+ * @adev: the amdgpu device
+ * @vm: the vm to use
+ * @dep: the dependency to wait for
+ * @fence: the resulting fence
+ *
+ * Creates a TLB invalidation fence which signals when all the VMIDs assigned to
+ * the PASID of the VM are invalidated.
+ */
+void amdgpu_vm_tlb_fence_create(struct amdgpu_device *adev,
+ struct amdgpu_vm *vm,
+ struct dma_fence *dep,
struct dma_fence **fence)
{
struct amdgpu_tlb_fence *f;
@@ -86,16 +98,15 @@ void amdgpu_vm_tlb_fence_create(struct a
* We can't fail since the PDEs and PTEs are already updated, so
* just block for the dependency and execute the TLB flush
*/
- if (*fence)
- dma_fence_wait(*fence, false);
+ if (dep)
+ dma_fence_wait(dep, false);
amdgpu_gmc_flush_gpu_tlb_pasid(adev, vm->pasid, 2, true, 0);
- *fence = dma_fence_get_stub();
return;
}
f->adev = adev;
- f->dependency = *fence;
+ f->dependency = dma_fence_get(dep);
f->pasid = vm->pasid;
INIT_WORK(&f->work, amdgpu_tlb_fence_work);
spin_lock_init(&f->lock);
@@ -107,5 +118,6 @@ void amdgpu_vm_tlb_fence_create(struct a
dma_fence_get(&f->base);
schedule_work(&f->work);
+ dma_fence_put(*fence);
*fence = &f->base;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 385/742] drm/amdgpu: Fix UserQ slot availability checks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (375 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 384/742] drm/amdgpu: fix TLB invalidation fence handling v4 Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 386/742] drm/amdgpu: Fix VCE buffer size check for DPB and input surface Greg Kroah-Hartman
` (349 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Erhan Bilgili
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Erhan Bilgili <erhan.bilgili@gmail.com>
commit cfb11282e0fbf5bd06e3f329f56dddc93e749679 upstream.
The compute and DMA queries check each other's disable_uq flags.
When the flags differ, this can hide available slots or report slots
for disabled UserQs.
Check gfx.disable_uq for compute and sdma.disable_uq for DMA.
Fixes: 78d0a27ae0e2 ("drm/amdgpu: Add user queue instance count in HW IP info")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Erhan Bilgili <erhan.bilgili@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit ed4f6b1f8848ad8890fd188da6b2ddfdd538a036)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -469,7 +469,7 @@ static int amdgpu_hw_ip_info(struct amdg
!adev->gfx.compute_ring[i].no_user_submission)
++num_rings;
- if (!adev->sdma.disable_uq) {
+ if (!adev->gfx.disable_uq) {
for (i = 0; i < AMDGPU_MES_MAX_COMPUTE_PIPES; i++)
num_slots += hweight32(adev->mes.compute_hqd_mask[i]);
}
@@ -484,7 +484,7 @@ static int amdgpu_hw_ip_info(struct amdg
!adev->sdma.instance[i].ring.no_user_submission)
++num_rings;
- if (!adev->gfx.disable_uq) {
+ if (!adev->sdma.disable_uq) {
for (i = 0; i < AMDGPU_MES_MAX_SDMA_PIPES; i++)
num_slots += hweight32(adev->mes.sdma_hqd_mask[i]);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 386/742] drm/amdgpu: Fix VCE buffer size check for DPB and input surface
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (376 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 385/742] drm/amdgpu: Fix UserQ slot availability checks Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 387/742] drm/amdgpu: only unregister the ATPX handler if we registered it Greg Kroah-Hartman
` (348 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Leo Liu, Ruijing Dong, David Rosca,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Rosca <david.rosca@amd.com>
commit 87a841d8c0b711519fb76e2412bb293743f602bd upstream.
In create command we get pitch and height for DPB, input surface
pitch and height is in encode command.
Fix the calculation to also consider different luma and chroma pitch.
Acked-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Signed-off-by: David Rosca <david.rosca@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 24c0be8ac3ef2eaa20f614b540e41382b5e97afc)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 35 +++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
@@ -775,6 +775,7 @@ int amdgpu_vce_ring_parse_cs(struct amdg
uint32_t allocated = 0;
uint32_t tmp, handle = 0;
uint32_t dummy = 0xffffffff;
+ uint32_t luma_pitch, chroma_pitch, height;
uint32_t *size = &dummy;
unsigned int idx;
int i, r = 0;
@@ -880,19 +881,19 @@ int amdgpu_vce_ring_parse_cs(struct amdg
goto out;
}
- uint32_t width, height;
- width = amdgpu_ib_get_value(ib, idx + 8);
- height = amdgpu_ib_get_value(ib, idx + 10);
-
- if (width == 0 || height == 0 ||
- width > 4096 || height > 2304) {
- DRM_ERROR("invalid VCE image size: %ux%u\n",
- width, height);
+ luma_pitch = amdgpu_ib_get_value(ib, idx + 8);
+ chroma_pitch = amdgpu_ib_get_value(ib, idx + 9);
+ height = amdgpu_ib_get_value(ib, idx + 10); /* encRefYHeightInQw */
+
+ if (luma_pitch == 0 || chroma_pitch == 0 || height == 0 ||
+ luma_pitch > 4096 || chroma_pitch > 4096 || height > 2304 / 8) {
+ DRM_ERROR("invalid VCE ref image size: (%u %u)x%u\n",
+ luma_pitch, chroma_pitch, height * 8);
r = -EINVAL;
goto out;
}
- *size = width * height * 8 * 3 / 2;
+ *size = luma_pitch * height * 8 + chroma_pitch * height * 8 / 2;
break;
@@ -921,13 +922,25 @@ int amdgpu_vce_ring_parse_cs(struct amdg
break;
case 0x03000001: /* encode */
+ height = amdgpu_ib_get_value(ib, idx + 13);
+ luma_pitch = amdgpu_ib_get_value(ib, idx + 14);
+ chroma_pitch = amdgpu_ib_get_value(ib, idx + 15);
+
+ if (luma_pitch == 0 || chroma_pitch == 0 || height == 0 ||
+ luma_pitch > 4096 || chroma_pitch > 4096 || height > 2304) {
+ DRM_ERROR("invalid VCE image size: (%u %u)x%u\n",
+ luma_pitch, chroma_pitch, height);
+ r = -EINVAL;
+ goto out;
+ }
+
r = amdgpu_vce_cs_reloc(p, ib, idx + 10, idx + 9,
- *size, 0);
+ luma_pitch * height, 0);
if (r)
goto out;
r = amdgpu_vce_cs_reloc(p, ib, idx + 12, idx + 11,
- *size / 3, 0);
+ chroma_pitch * height / 2, 0);
if (r)
goto out;
break;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 387/742] drm/amdgpu: only unregister the ATPX handler if we registered it
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (377 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 386/742] drm/amdgpu: Fix VCE buffer size check for DPB and input surface Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 388/742] drm/amdgpu: release the IMU firmware with the other GFX microcode Greg Kroah-Hartman
` (347 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Jiaming Fan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Fan <fan.jiaming@hotmail.com>
commit 53fc1be11892a8e695937fdbc24db2699d23dabf upstream.
amdgpu_register_atpx_handler() registers the ATPX handler with
vga_switcheroo only when ATPX is detected, and ignores the result:
vga_switcheroo has a single handler slot and refuses a second handler
with -EINVAL. amdgpu_unregister_atpx_handler() calls
vga_switcheroo_unregister_handler() in either case, and that clears the
slot no matter who set it.
So unloading amdgpu removes a handler registered by another driver, such
as apple-gmux. No AMD GPU is needed for this; loading and unloading
amdgpu is enough. Afterwards vga_switcheroo can no longer switch outputs,
and a client that uses the vga_switcheroo runtime PM domain, such as
nouveau on a non-Optimus machine with a v1 DSM, can dereference the now
NULL handler during runtime suspend.
Record whether the registration succeeded and unregister only in that
case.
Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jiaming Fan <fan.jiaming@hotmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit fbb6ebeff9d5327e8d06a83a3f7daa88422c9127)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
@@ -45,6 +45,7 @@ struct amdgpu_atpx {
static struct amdgpu_atpx_priv {
bool atpx_detected;
bool bridge_pm_usable;
+ bool handler_registered;
unsigned int quirks;
/* handle for device - and atpx */
acpi_handle dhandle;
@@ -663,7 +664,8 @@ void amdgpu_register_atpx_handler(void)
if (!r)
return;
- vga_switcheroo_register_handler(&amdgpu_atpx_handler, handler_flags);
+ if (!vga_switcheroo_register_handler(&amdgpu_atpx_handler, handler_flags))
+ amdgpu_atpx_priv.handler_registered = true;
}
/**
@@ -673,5 +675,14 @@ void amdgpu_register_atpx_handler(void)
*/
void amdgpu_unregister_atpx_handler(void)
{
+ /*
+ * vga_switcheroo has a single handler slot and unregistering clears it
+ * no matter who set it, so leave a handler registered by another
+ * driver, such as apple-gmux, in place.
+ */
+ if (!amdgpu_atpx_priv.handler_registered)
+ return;
+
vga_switcheroo_unregister_handler();
+ amdgpu_atpx_priv.handler_registered = false;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 388/742] drm/amdgpu: release the IMU firmware with the other GFX microcode
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (378 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 387/742] drm/amdgpu: only unregister the ATPX handler if we registered it Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 389/742] drm/amdgpu: unwind module init on failure Greg Kroah-Hartman
` (346 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Jesse Zhang
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jesse Zhang <Jesse.Zhang@amd.com>
commit 85bea8c788852be6fd262381006dabd90946bda4 upstream.
The IMU firmware of GFX11 and GFX12 is only released when loading the
microcode fails. Every unload or unbind of such a device leaks it. On
navi31, binding and unbinding the device leaves:
unreferenced object 0xffff88810dd6cd80 (size 32):
comm "modprobe", pid 2891, jiffies 4294943088
backtrace:
_request_firmware+0x207/0xad0
request_firmware+0x3b/0x60
amdgpu_ucode_request+0x150/0x330 [amdgpu]
amdgpu_device_init+0x2d70/0xa650 [amdgpu]
amdgpu_driver_load_kms+0x1e/0x140 [amdgpu]
a struct firmware of 132352 bytes, the size of gc_11_0_0_imu.bin.
Release it in the free_microcode() functions; with that it's gone.
Fixes: 289bcffb9d76 ("drm/amdgpu: support imu for gfx11")
Fixes: 32d163768989 ("drm/amd/amdgpu: imu fw loading support")
Fixes: a0f8297068cf ("drm/amdgpu: add imu support for gc 12_1")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit ae8aff53de906d98982e3dc3c691a72eb81c844b)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 1 +
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 1 +
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 1 +
3 files changed, 3 insertions(+)
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -687,6 +687,7 @@ static void gfx_v11_0_free_microcode(str
amdgpu_ucode_release(&adev->gfx.me_fw);
amdgpu_ucode_release(&adev->gfx.rlc_fw);
amdgpu_ucode_release(&adev->gfx.mec_fw);
+ amdgpu_ucode_release(&adev->gfx.imu_fw);
kfree(adev->gfx.rlc.register_list_format);
}
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
@@ -559,6 +559,7 @@ static void gfx_v12_0_free_microcode(str
amdgpu_ucode_release(&adev->gfx.me_fw);
amdgpu_ucode_release(&adev->gfx.rlc_fw);
amdgpu_ucode_release(&adev->gfx.mec_fw);
+ amdgpu_ucode_release(&adev->gfx.imu_fw);
kfree(adev->gfx.rlc.register_list_format);
}
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
@@ -494,6 +494,7 @@ static void gfx_v12_1_free_microcode(str
{
amdgpu_ucode_release(&adev->gfx.rlc_fw);
amdgpu_ucode_release(&adev->gfx.mec_fw);
+ amdgpu_ucode_release(&adev->gfx.imu_fw);
kfree(adev->gfx.rlc.register_list_format);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 389/742] drm/amdgpu: unwind module init on failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (379 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 388/742] drm/amdgpu: release the IMU firmware with the other GFX microcode Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 390/742] drm/amdgpu: use supported SMU clock messages on SMU 15.0.0 Greg Kroah-Hartman
` (345 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Deucher, Jiaming Fan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Fan <fan.jiaming@hotmail.com>
commit be94997dd5558a0e53bee97306d659e9327dcab9 upstream.
amdgpu_init() registers the ATPX handler with vga_switcheroo and
allocates the ACPI XCC/NUMA info before it initializes KFD, but its
error paths do not undo any of that:
- when amdgpu_amdkfd_init() fails, only amdgpu_sync_fini() is called;
- when pci_register_driver() fails, its result is returned as is, so
KFD, the ATPX handler, the ACPI info and the sync slab cache are all
left behind.
A failed module init frees the module, so vga_switcheroo keeps a
pointer to a handler in freed memory and /dev/kfd keeps file operations
that point into it. A later amdgpu load cannot register its own ATPX
handler, and vga_switcheroo_enable() calls into the stale one.
The KFD path is easy to reach since KFD init failures are no longer
ignored: kfd_init() returns -EINVAL for an out of range sched_policy or
max_num_of_queues_per_device module parameter.
Unwind in the reverse order of initialization, starting from the last
step that succeeded, with the same calls and in the same order as
amdgpu_exit().
amdgpu_amdkfd_fini() is a no-op when KFD was not initialized, which
covers the ignored -ENOENT case, and amdgpu_unregister_atpx_handler()
only removes a handler that amdgpu registered itself.
Fixes: 4259a25341ab ("amdkfd: Only ignore -ENOENT for KFD init failuires")
Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Jiaming Fan <fan.jiaming@hotmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit c2c34905fb40d3bddae0d2539830975781715e25)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -3194,7 +3194,7 @@ static int __init amdgpu_init(void)
/* Ignore KFD init failures when CONFIG_HSA_AMD is not set. */
r = amdgpu_amdkfd_init();
if (r && r != -ENOENT)
- goto error_fini_sync;
+ goto error_release_acpi;
if (amdgpu_pp_feature_mask & PP_OVERDRIVE_MASK) {
add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
@@ -3203,9 +3203,17 @@ static int __init amdgpu_init(void)
}
/* let modprobe override vga console setting */
- return pci_register_driver(&amdgpu_kms_pci_driver);
+ r = pci_register_driver(&amdgpu_kms_pci_driver);
+ if (r)
+ goto error_fini_kfd;
-error_fini_sync:
+ return 0;
+
+error_fini_kfd:
+ amdgpu_amdkfd_fini();
+error_release_acpi:
+ amdgpu_acpi_release();
+ amdgpu_unregister_atpx_handler();
amdgpu_sync_fini();
return r;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 390/742] drm/amdgpu: use supported SMU clock messages on SMU 15.0.0
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (380 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 389/742] drm/amdgpu: unwind module init on failure Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 391/742] drm/amdgpu: wait for tlb flush before freeing BO Greg Kroah-Hartman
` (344 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kanala Ramalingeswara Reddy,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kanala Ramalingeswara Reddy <Kanala.RamalingeswaraReddy@amd.com>
commit 6c9ad0fc63930830f12a4ccc9555121cc7db0aee upstream.
SMU 15.0.0 no longer implements SMU_MSG_SetHardMinGfxClk, or the
SMU_MSG_SetHardMin and SMU_MSG_SetHardMax messages. Sending them
makes the clock request fail.
Program the GFX hard-min clock with SMU_MSG_SetSoftMinGfxclk, which
this SMU firmware still supports.
Fixes: c7fc0f372374 ("drm/amd: Enable SMU 15_0_0 support")
Signed-off-by: Kanala Ramalingeswara Reddy <Kanala.RamalingeswaraReddy@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit a6ae245cea297fae613145d5e4c74145f81f2ee1)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c
@@ -1459,7 +1459,7 @@ int smu_v15_0_od_edit_dpm_table(struct s
return -EINVAL;
}
- ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinGfxClk,
+ ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMinGfxclk,
smu->gfx_actual_hard_min_freq,
NULL);
if (ret) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 391/742] drm/amdgpu: wait for tlb flush before freeing BO
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (381 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 390/742] drm/amdgpu: use supported SMU clock messages on SMU 15.0.0 Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 392/742] drm/amdkfd: Acquire buffers in CRIU queue restore (again) Greg Kroah-Hartman
` (343 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Benjamin Cheng, Christian König,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Cheng <benjamin.cheng@amd.com>
commit 11f1080ba1bd3df2b2539dab878b3e2a0a89681f upstream.
On gem object close, we previously only attached the fence of its own
clear_freed() call to the BO's resv. If an unmap of this BO happened
prior to the close call, clear_freed() would be invoked, leaving
vm->freed empty, and no meaningful fence to be attached to the resv.
Because of that the memory may be freed before the TLB flush is
complete, and give a running userq potential access to a stale
address translation.
Fix this by attaching the last_tlb_inv fence to the BO's resv.
Fixes: a1d201e16940 ("drm/amdgpu: enable GFX-V11 userqueue support")
Signed-off-by: Benjamin Cheng <benjamin.cheng@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit ab88e18030a1f2c340f64172287af19d1a48d3cc)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -326,7 +326,7 @@ static void amdgpu_gem_object_close(stru
drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 0);
drm_exec_until_all_locked(&exec) {
- r = drm_exec_prepare_obj(&exec, &bo->tbo.base, 1);
+ r = drm_exec_prepare_obj(&exec, &bo->tbo.base, 2); /* clear_freed + last_tlb_inv */
drm_exec_retry_on_contention(&exec);
if (unlikely(r))
goto out_unlock;
@@ -357,11 +357,14 @@ static void amdgpu_gem_object_close(stru
dev_err(adev->dev, "failed to clear page "
"tables on GEM object close (%ld)\n", r);
if (r || !fence)
- goto out_unlock;
+ goto out_tlb;
amdgpu_bo_fence(bo, fence, true);
dma_fence_put(fence);
+out_tlb:
+ amdgpu_bo_fence(bo, vm->last_tlb_inv, true);
+
out_unlock:
if (r && !drm_dev_is_unplugged(adev_to_drm(adev)))
dev_err(adev->dev, "leaking bo va (%ld)\n", r);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 392/742] drm/amdkfd: Acquire buffers in CRIU queue restore (again)
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (382 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 391/742] drm/amdgpu: wait for tlb flush before freeing BO Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 393/742] drm/amdkfd: Acquire cwsr buffer during CRIU resume Greg Kroah-Hartman
` (342 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, David Francis, Felix Kuehling,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Francis <David.Francis@amd.com>
commit 37820a7c716636b6ea499cc73875617886f4377f upstream.
CRIU queue restore doesn't acquire the bo buffers in the same way
normal queue creation does. In normal queue creation, the driver
gets an additional reference on the queue's underlying buffers
that lasts until the queue is destroyed; this prevents the
queue's buffers from being removed from underneath it.
Acquire them, but don't get the svm bo. SVM isn't yet fully
restored by this point in CRIU and so there's no svm range to get.
This will be addressed in the next patch.
v2: Don't use checkpoint ctl_stack_size
v5: Also avoid cwsr in criu failure path
Signed-off-by: David Francis <David.Francis@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 56ca6fb5b148eb045aef34c4e05f1f56864611d5)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 4 ++--
drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 4 ++--
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 12 ++++++++++--
drivers/gpu/drm/amd/amdkfd/kfd_queue.c | 13 ++++++++++---
4 files changed, 24 insertions(+), 9 deletions(-)
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -433,7 +433,7 @@ static int kfd_ioctl_create_queue(struct
goto err_bind_process;
}
- err = kfd_queue_acquire_buffers(pdd, &q_properties);
+ err = kfd_queue_acquire_buffers(pdd, &q_properties, false);
if (err) {
pr_debug("failed to acquire user queue buffers\n");
goto err_acquire_queue_buf;
@@ -478,7 +478,7 @@ static int kfd_ioctl_create_queue(struct
err_create_queue:
kfd_queue_unref_bo_vas(pdd, &q_properties);
- kfd_queue_release_buffers(pdd, &q_properties);
+ kfd_queue_release_buffers(pdd, &q_properties, false);
err_acquire_queue_buf:
err_sdma_engine_id:
err_bind_process:
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -1386,8 +1386,8 @@ void print_queue(struct queue *q);
int kfd_queue_buffer_get(struct amdgpu_vm *vm, void __user *addr, struct amdgpu_bo **pbo,
u64 expected_size);
void kfd_queue_buffer_put(struct amdgpu_bo **bo);
-int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_properties *properties);
-int kfd_queue_release_buffers(struct kfd_process_device *pdd, struct queue_properties *properties);
+int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_properties *properties, bool is_criu);
+int kfd_queue_release_buffers(struct kfd_process_device *pdd, struct queue_properties *properties, bool is_criu);
void kfd_queue_unref_bo_va(struct amdgpu_vm *vm, struct amdgpu_bo **bo);
int kfd_queue_unref_bo_vas(struct kfd_process_device *pdd,
struct queue_properties *properties);
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
@@ -227,7 +227,7 @@ void pqm_uninit(struct process_queue_man
pqm->process);
if (pdd) {
kfd_queue_unref_bo_vas(pdd, &pqn->q->properties);
- kfd_queue_release_buffers(pdd, &pqn->q->properties);
+ kfd_queue_release_buffers(pdd, &pqn->q->properties, false);
} else {
WARN_ON(!pdd);
}
@@ -571,7 +571,7 @@ int pqm_destroy_queue(struct process_que
goto err_destroy_queue;
}
kfd_procfs_del_queue(pqn->q);
- kfd_queue_release_buffers(pdd, &pqn->q->properties);
+ kfd_queue_release_buffers(pdd, &pqn->q->properties, false);
pqm_clean_queue_resource(pqm, pqn);
uninit_queue(pqn->q);
}
@@ -1093,9 +1093,17 @@ int kfd_criu_restore_queue(struct kfd_pr
print_queue_properties(&qp);
+ ret = kfd_queue_acquire_buffers(pdd, &qp, true);
+ if (ret) {
+ pr_err("Failed to acquire user queue buffers err:%d\n", ret);
+ goto exit;
+ }
+
ret = pqm_create_queue(&p->pqm, pdd->dev, &qp, &queue_id, q_data, mqd, ctl_stack, NULL);
if (ret) {
pr_err("Failed to create new queue err:%d\n", ret);
+ kfd_queue_unref_bo_vas(pdd, &qp);
+ kfd_queue_release_buffers(pdd, &qp, true);
goto exit;
}
--- a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
@@ -239,7 +239,7 @@ static void kfd_queue_put_bos(struct que
kfd_queue_buffer_put(&properties->cwsr_bo);
}
-int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_properties *properties)
+int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_properties *properties, bool is_criu)
{
struct kfd_topology_device *topo_dev;
u64 expected_queue_size;
@@ -334,6 +334,12 @@ int kfd_queue_acquire_buffers(struct kfd
amdgpu_bo_unreserve(vm->root.bo);
+ /* CRIU svm buffers are restored at a later stage than queues. They'll be in
+ * before the queue is actually used, so no risk here
+ */
+ if (is_criu)
+ return 0;
+
err = kfd_queue_buffer_svm_get(pdd, properties->ctx_save_restore_area_address,
total_cwsr_size);
if (err)
@@ -362,7 +368,7 @@ out_err_release:
return err;
}
-int kfd_queue_release_buffers(struct kfd_process_device *pdd, struct queue_properties *properties)
+int kfd_queue_release_buffers(struct kfd_process_device *pdd, struct queue_properties *properties, bool is_criu)
{
struct kfd_topology_device *topo_dev;
u64 total_cwsr_size;
@@ -380,7 +386,8 @@ int kfd_queue_release_buffers(struct kfd
return -EINVAL;
total_cwsr_size = ALIGN(total_cwsr_size, PAGE_SIZE);
- kfd_queue_buffer_svm_put(pdd, properties->ctx_save_restore_area_address, total_cwsr_size);
+ if (!is_criu)
+ kfd_queue_buffer_svm_put(pdd, properties->ctx_save_restore_area_address, total_cwsr_size);
return 0;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 393/742] drm/amdkfd: Acquire cwsr buffer during CRIU resume
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (383 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 392/742] drm/amdkfd: Acquire buffers in CRIU queue restore (again) Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 394/742] drm/amdkfd: check CRIU SVM priv data bounds before allocating Greg Kroah-Hartman
` (341 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, David Francis, Felix Kuehling,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Francis <David.Francis@amd.com>
commit 86aa8332ab2b2296cda98cde189e2ec539c4e1b3 upstream.
In normal kfd queue create, a reference to the cwsr svm range
is acquired so that this buffer is not freed from underneath the
queue. We weren't doing that.
After svm ranges are restored in RESUME phase of CRIU, go through
all the queues and acquire a reference to the cwsr.
Signed-off-by: David Francis <David.Francis@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 5a00bdd267a5d87307f9aaddabf550f2410c9d40)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 +
drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 3 +
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 32 +++++++++++++++++
drivers/gpu/drm/amd/amdkfd/kfd_queue.c | 4 +-
4 files changed, 39 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -2863,6 +2863,8 @@ static int criu_resume(struct file *file
goto exit;
}
+ kfd_criu_resume_queues(target);
+
ret = amdgpu_amdkfd_criu_resume(target->kgd_process_info);
if (ret)
pr_err("amdgpu_amdkfd_criu_resume failed for %i\n", args->pid);
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -1376,6 +1376,8 @@ int kfd_criu_restore_event(struct file *
uint8_t __user *user_priv_data,
uint64_t *priv_data_offset,
uint64_t max_priv_data_size);
+
+int kfd_criu_resume_queues(struct kfd_process *p);
/* CRIU - End */
/* Queue Context Management */
@@ -1392,6 +1394,7 @@ void kfd_queue_unref_bo_va(struct amdgpu
int kfd_queue_unref_bo_vas(struct kfd_process_device *pdd,
struct queue_properties *properties);
void kfd_queue_ctx_save_restore_size(struct kfd_topology_device *dev);
+int kfd_queue_buffer_svm_get(struct kfd_process_device *pdd, u64 addr, u64 size);
struct mqd_manager *mqd_manager_init_cik(enum KFD_MQD_TYPE type,
struct kfd_node *dev);
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
@@ -1122,6 +1122,38 @@ exit:
return ret;
}
+int kfd_criu_resume_queues(struct kfd_process *p)
+{
+ int ret, i;
+ u64 total_cwsr_size;
+
+ for (i = 0; i < p->n_pdds; i++) {
+ struct kfd_process_device *pdd = p->pdds[i];
+ struct kfd_topology_device *topo_dev;
+ struct queue *q;
+
+ topo_dev = kfd_topology_device_by_id(pdd->dev->id);
+
+ list_for_each_entry(q, &pdd->qpd.queues_list, list) {
+ total_cwsr_size = q->properties.ctx_save_restore_area_size +
+ topo_dev->node_props.debug_memory_size;
+ if (check_mul_overflow(total_cwsr_size,
+ NUM_XCC(pdd->dev->xcc_mask),
+ &total_cwsr_size))
+ return -EINVAL;
+ total_cwsr_size = ALIGN(total_cwsr_size, PAGE_SIZE);
+
+ ret = kfd_queue_buffer_svm_get(pdd, q->properties.ctx_save_restore_area_address,
+ total_cwsr_size);
+ if (ret)
+ return ret;
+ }
+
+ }
+
+ return 0;
+}
+
int pqm_get_queue_checkpoint_info(struct process_queue_manager *pqm,
unsigned int qid,
uint32_t *mqd_size,
--- a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
@@ -88,7 +88,7 @@ void uninit_queue(struct queue *q)
#if IS_ENABLED(CONFIG_HSA_AMD_SVM)
-static int kfd_queue_buffer_svm_get(struct kfd_process_device *pdd, u64 addr, u64 size)
+int kfd_queue_buffer_svm_get(struct kfd_process_device *pdd, u64 addr, u64 size)
{
struct kfd_process *p = pdd->process;
struct list_head update_list;
@@ -182,7 +182,7 @@ static void kfd_queue_buffer_svm_put(str
}
#else
-static int kfd_queue_buffer_svm_get(struct kfd_process_device *pdd, u64 addr, u64 size)
+int kfd_queue_buffer_svm_get(struct kfd_process_device *pdd, u64 addr, u64 size)
{
return -EINVAL;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 394/742] drm/amdkfd: check CRIU SVM priv data bounds before allocating
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (384 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 393/742] drm/amdkfd: Acquire cwsr buffer during CRIU resume Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 395/742] drm/amdkfd: dont check the HMM range when getting its pages failed Greg Kroah-Hartman
` (340 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Perry Yuan, Yifan Zhang,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Perry Yuan <perry.yuan@amd.com>
commit 732239b002678d8c534503f52a16afc310095523 upstream.
kfd_criu_restore_svm() allocated the per-range metadata before checking
that the range fits in the user supplied private data buffer, so an out
of range offset cost a pointless kzalloc()/kfree() round trip. Do the
bounds check first and return -EINVAL directly.
v2:
- split the original patch into two, one change per patch (Yifan)
Signed-off-by: Perry Yuan <perry.yuan@amd.com>
Reviewed-by: Yifan Zhang <yifan1.zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 0c3caec1161e458092364cb448e5bd165a26dcdb)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -4213,15 +4213,14 @@ int kfd_criu_restore_svm(struct kfd_proc
svm_priv_data_size = sizeof(struct kfd_criu_svm_range_priv_data) +
svm_attrs_size;
+ if (*priv_data_offset + svm_priv_data_size > max_priv_data_size)
+ return -EINVAL;
+
criu_svm_md = kzalloc(svm_object_md_size, GFP_KERNEL);
if (!criu_svm_md) {
pr_err("failed to allocate memory to store svm metadata\n");
return -ENOMEM;
}
- if (*priv_data_offset + svm_priv_data_size > max_priv_data_size) {
- ret = -EINVAL;
- goto exit;
- }
ret = copy_from_user(&criu_svm_md->data, user_priv_ptr + *priv_data_offset,
svm_priv_data_size);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 395/742] drm/amdkfd: dont check the HMM range when getting its pages failed
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (385 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 394/742] drm/amdkfd: check CRIU SVM priv data bounds before allocating Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 396/742] drm/amdkfd: Dont reuse a VRAM page that is still referenced Greg Kroah-Hartman
` (339 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Felix Kuehling, Jesse Zhang,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jesse Zhang <Jesse.Zhang@amd.com>
commit 264b67a79010cd3ffa85603d85e594867a45a01d upstream.
When allocating the PFN array fails, amdgpu_hmm_range_get_pages()
returns -ENOMEM before setting the notifier of the range, but
svm_range_validate_and_map() still checks the range, as it is not NULL,
before looking at the error. On navi48, setting SVM attributes with
failslab:
KASAN: null-ptr-deref in range [0x0000000000000050-0x0000000000000057]
RIP: 0010:amdgpu_hmm_range_valid+0x66/0xa0 [amdgpu]
svm_range_validate_and_map+0xaef/0x4e40 [amdgpu]
svm_range_set_attr+0x193e/0x4610 [amdgpu]
kfd_ioctl_svm+0x137/0x320 [amdgpu]
Check the error first; it is only 0 when the pages were taken.
Fixes: c0de552910bb ("drm/amdkfd: clean up the code to free hmm_range")
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit c7036242655cb2c6d14a0d04138536e1ddb5e42c)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1871,11 +1871,12 @@ static int svm_range_validate_and_map(st
svm_range_lock(prange);
- /* Free backing memory of hmm_range if it was initialized
- * Override return value to TRY AGAIN only if prior returns
- * were successful
+ /*
+ * Retry if the pages were invalidated after they were taken.
+ * Only check that when taking them succeeded: a range can exist
+ * without a notifier, e.g. when allocating its PFN array failed.
*/
- if (range && !amdgpu_hmm_range_valid(range) && !r) {
+ if (!r && !amdgpu_hmm_range_valid(range)) {
pr_debug("hmm update the range, need validate again\n");
r = -EAGAIN;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 396/742] drm/amdkfd: Dont reuse a VRAM page that is still referenced
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (386 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 395/742] drm/amdkfd: dont check the HMM range when getting its pages failed Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 397/742] drm/amdkfd: keep the DMA addresses of a range intact if splitting fails Greg Kroah-Hartman
` (338 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Apurv Mishra, Philip Yang,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Apurv Mishra <Apurv.Mishra@amd.com>
commit 8cd5429d429eced2441173b3306f7e137a4dc31f upstream.
In svm_migrate_copy_to_vram(), skip VRAM pages with a non-zero refcount
and leave those pages in system memory for this migration.
When an svm_bo is reused, a VRAM page can still be held by an in-flight
CPU fault (do_swap_page -> svm_migrate_to_ram). Migrating to VRAM then
re-initializes the page via zone_device_page_init(), resetting its
refcount. The fault's late put_page() frees the page mid-migration, so
migrate_vma_finalize() never restores that PTE. It is left pointing at a
freed system page and hmm_range_fault() hits BUG_ON in
pfn_swap_entry_to_page() (swapops.h).
Signed-off-by: Apurv Mishra <Apurv.Mishra@amd.com>
Reviewed-by: Philip Yang <Philip.Yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 1f19aa7acacbce35584dd8f75a30880096fda6a4)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
@@ -295,16 +295,26 @@ svm_migrate_copy_to_vram(struct kfd_node
amdgpu_res_first(prange->ttm_res, ttm_res_offset,
npages << PAGE_SHIFT, &cursor);
for (i = j = 0; (i < npages) && (mpages < migrate->cpages); i++) {
- struct page *spage;
+ struct page *spage = migrate_pfn_to_page(migrate->src[i]);
if (migrate->src[i] & MIGRATE_PFN_MIGRATE) {
dst[i] = cursor.start + (j << PAGE_SHIFT);
migrate->dst[i] = svm_migrate_addr_to_pfn(adev, dst[i]);
- svm_migrate_get_vram_page(prange, migrate->dst[i]);
- migrate->dst[i] = migrate_pfn(migrate->dst[i]);
- mpages++;
+ /*
+ * A reused svm_bo page may still be held by a CPU fault.
+ * Reinitializing it would free it under this migration,
+ * so leave this page in system memory.
+ */
+ if (page_ref_count(pfn_to_page(migrate->dst[i]))) {
+ dst[i] = 0;
+ migrate->dst[i] = 0;
+ spage = NULL;
+ } else {
+ svm_migrate_get_vram_page(prange, migrate->dst[i]);
+ migrate->dst[i] = migrate_pfn(migrate->dst[i]);
+ mpages++;
+ }
}
- spage = migrate_pfn_to_page(migrate->src[i]);
if (spage && !is_zone_device_page(spage)) {
src[i] = dma_map_page(dev, spage, 0, PAGE_SIZE,
DMA_BIDIRECTIONAL);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 397/742] drm/amdkfd: keep the DMA addresses of a range intact if splitting fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (387 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 396/742] drm/amdkfd: Dont reuse a VRAM page that is still referenced Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 398/742] drm/amdkfd: wait for the queue quiesce in concurrent SVM evictions Greg Kroah-Hartman
` (337 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Felix Kuehling, Jesse Zhang,
Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jesse Zhang <Jesse.Zhang@amd.com>
commit 63b42ad2fdd371ae4a86658295943d60a86a519b upstream.
svm_range_split_pages() splits the DMA address array of one GPU after
the other, and each split replaces the old range's array by a shorter
one. If a later GPU's array can't be allocated, the old range is left
with the arrays of the earlier GPUs already shortened, but with its old
size. Unmapping it then walks past their end.
On navi31 with its iGPU, an SVM range accessible by both GPUs, and
unmapping a page in its middle with allocations failing in turn through
failslab:
BUG: KASAN: slab-out-of-bounds in svm_range_dma_unmap_dev+0x13f/0x170 [amdgpu]
Read of size 8 at addr ffff88819ac32800 by task kworker/8:1/171
svm_range_dma_unmap_dev+0x13f/0x170 [amdgpu]
svm_range_dma_unmap+0x119/0x2c0 [amdgpu]
svm_range_free+0x312/0x520 [amdgpu]
svm_range_handle_list_op+0x326/0x500 [amdgpu]
svm_range_deferred_list_work+0x338/0x790 [amdgpu]
Allocated by task 2749:
svm_range_copy_array.constprop.0+0x55/0x190 [amdgpu]
svm_range_split+0x388/0x17b0 [amdgpu]
svm_range_unmap_split+0x254/0x370 [amdgpu]
svm_range_cpu_invalidate_pagetables+0xb29/0x11d0 [amdgpu]
The buggy address is located 0 bytes to the right of
allocated 2048-byte region [ffff88819ac32000, ffff88819ac32800)
Split the arrays of all GPUs first and only replace the old ones once
all succeeded. With that the 2759 unmaps of the same sweep give no
report.
Fixes: f80fe9d3c114 ("drm/amdkfd: map svm range to GPUs")
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 3cbd0b498ac18821ec01c08e39050a4d22ea9eeb)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1007,7 +1007,7 @@ svm_range_split_array(void *ppnew, void
kvfree(new);
return -ENOMEM;
}
- kvfree(pold);
+ /* The caller frees pold once all arrays of the range are split */
*(void **)ppold = old;
*(void **)ppnew = new;
@@ -1018,19 +1018,36 @@ static int
svm_range_split_pages(struct svm_range *new, struct svm_range *old,
uint64_t start, uint64_t last)
{
+ dma_addr_t *old_dma[MAX_GPU_INSTANCE];
uint64_t npages = last - start + 1;
bool has_dma_addr = false;
int i, r;
+ /*
+ * Split the arrays of all GPUs before replacing any of them, the old
+ * range must stay intact if one fails.
+ */
for (i = 0; i < MAX_GPU_INSTANCE; i++) {
+ old_dma[i] = old->dma_addr[i];
if (old->dma_addr[i])
has_dma_addr = true;
- r = svm_range_split_array(&new->dma_addr[i], &old->dma_addr[i],
+ r = svm_range_split_array(&new->dma_addr[i], &old_dma[i],
sizeof(*old->dma_addr[i]), old->start,
npages, new->start, new->npages,
old->actual_loc ? &new->vram_pages : NULL);
- if (r)
+ if (r) {
+ /* new->dma_addr[] goes with the new range */
+ while (i--)
+ if (old_dma[i] != old->dma_addr[i])
+ kvfree(old_dma[i]);
return r;
+ }
+ }
+ for (i = 0; i < MAX_GPU_INSTANCE; i++) {
+ if (old_dma[i] == old->dma_addr[i])
+ continue;
+ kvfree(old->dma_addr[i]);
+ old->dma_addr[i] = old_dma[i];
}
if (old->actual_loc) {
/*
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 398/742] drm/amdkfd: wait for the queue quiesce in concurrent SVM evictions
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (388 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 397/742] drm/amdkfd: keep the DMA addresses of a range intact if splitting fails Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 399/742] drm/vc4: Fix firmware reference leak in vc4_hvs_bind() Greg Kroah-Hartman
` (336 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Qiang Han, Philip Yang,
Felix Kuehling, Alex Deucher
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiang Han <qiangh@amd.com>
commit 8c417209754a9d2cd8dc1e78c0dfadefd0ad0e82 upstream.
With XNACK off, svm_range_evict() leaves the GPU page tables in place
and relies on the process's queues being stopped before the MMU
notifier returns.
Only the first eviction (evicted_ranges == 1) calls
kgd2kfd_quiesce_mm(). The quiesce preempts every GPU the process has
opened and takes milliseconds. Any other range invalidated in the
meantime sees evicted_ranges > 1 and returns at once. The core mm then
frees, migrates or reuses the page while the queues still run, and an
in-flight SDMA or blit copy accesses it through the old GPU PTE. The
result is silent corruption of the copy, or of whatever process now
owns the page.
Hold a new svms->evict_lock across the first evictor's quiesce, so that
concurrent evictions return only after the queues have stopped. This is
the scheme amdgpu_amdkfd_evict_userptr() uses with
process_info->notifier_lock. evict_lock nests inside prange->lock and
is taken nowhere else. Under it, the quiesce path takes the dqm lock,
which is already used in MMU notifiers (memalloc_noreclaim).
One way to reach this: a pageable hipMemcpy() larger than 1 MiB. ROCclr
pins the buffer with hsa_amd_memory_lock(), libhsakmt registers it as
a KFD SVM range, and host memory pressure (reclaim, compaction,
allocator purge) invalidates the range.
Fixes: 8a7c184a16d7 ("drm/amdkfd: svm range eviction and restore")
Signed-off-by: Qiang Han <qiangh@amd.com>
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit d443bd2512c04a5d34c4473ce9ce2f2a6f7bf8f5)
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +
drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 35 ++++++++++++++++++++++------------
2 files changed, 25 insertions(+), 12 deletions(-)
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -906,6 +906,8 @@ struct svm_range_list {
struct list_head deferred_range_list;
struct list_head criu_svm_metadata_list;
spinlock_t deferred_list_lock;
+ /* serializes XNACK-off evictions with the queue quiesce */
+ struct mutex evict_lock;
atomic_t evicted_ranges;
atomic_t drain_pagefaults;
struct delayed_work restore_work;
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -2113,21 +2113,30 @@ svm_range_evict(struct svm_range *prange
if (prange->start <= last && prange->last >= start)
atomic_inc(&prange->invalid);
+ /* The MMU notifier must not return before the GPU has stopped
+ * accessing the invalidated pages. Only the first eviction stops
+ * the queues, which takes milliseconds (HWS preemption on every
+ * GPU of the process). Serialize all evictions of this process so
+ * that a concurrent invalidation of another range waits until
+ * that quiesce has completed instead of returning while queues
+ * still run on stale PTEs.
+ */
+ mutex_lock(&svms->evict_lock);
evicted_ranges = atomic_inc_return(&svms->evicted_ranges);
- if (evicted_ranges != 1)
- return r;
+ if (evicted_ranges == 1) {
+ pr_debug("evicting svms 0x%p range [0x%lx 0x%lx]\n",
+ prange->svms, prange->start, prange->last);
- pr_debug("evicting svms 0x%p range [0x%lx 0x%lx]\n",
- prange->svms, prange->start, prange->last);
-
- /* First eviction, stop the queues */
- r = kgd2kfd_quiesce_mm(mm, KFD_QUEUE_EVICTION_TRIGGER_SVM);
- if (r)
- pr_debug("failed to quiesce KFD\n");
+ /* First eviction, stop the queues */
+ r = kgd2kfd_quiesce_mm(mm, KFD_QUEUE_EVICTION_TRIGGER_SVM);
+ if (r)
+ pr_debug("failed to quiesce KFD\n");
- pr_debug("schedule to restore svm %p ranges\n", svms);
- queue_delayed_work(system_freezable_wq, &svms->restore_work,
- msecs_to_jiffies(AMDGPU_SVM_RANGE_RESTORE_DELAY_MS));
+ pr_debug("schedule to restore svm %p ranges\n", svms);
+ queue_delayed_work(system_freezable_wq, &svms->restore_work,
+ msecs_to_jiffies(AMDGPU_SVM_RANGE_RESTORE_DELAY_MS));
+ }
+ mutex_unlock(&svms->evict_lock);
} else {
unsigned long s, l;
uint32_t trigger;
@@ -3398,6 +3407,7 @@ void svm_range_list_fini(struct kfd_proc
svm_range_free(prange, true);
}
+ mutex_destroy(&p->svms.evict_lock);
mutex_destroy(&p->svms.lock);
pr_debug("process pid %d svms 0x%p done\n",
@@ -3411,6 +3421,7 @@ int svm_range_list_init(struct kfd_proce
svms->objects = RB_ROOT_CACHED;
mutex_init(&svms->lock);
+ mutex_init(&svms->evict_lock);
INIT_LIST_HEAD(&svms->list);
atomic_set(&svms->evicted_ranges, 0);
atomic_set(&svms->drain_pagefaults, 0);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 399/742] drm/vc4: Fix firmware reference leak in vc4_hvs_bind()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (389 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 398/742] drm/amdkfd: wait for the queue quiesce in concurrent SVM evictions Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 400/742] drm/vc4: Hold a runtime PM reference while allocating the binner BO Greg Kroah-Hartman
` (335 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Maíra Canal, Wentao Liang
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <vulab@iscas.ac.cn>
commit af200e91c7b996177aa90981b2f0e794b085d43a upstream.
The firmware reference taken via rpi_firmware_get() is leaked when
either of the devm_clk_get() calls for the core or display clocks
fails, as both error paths return without releasing it.
Fix it by moving the firmware lookup below the clock lookups, so that
the reference is taken right before the firmware property is read and
released immediately afterwards. The rpi_firmware_find_node() call
moves with it: the device node reference it returns would otherwise be
leaked by those same error paths.
The candidate was found by our static analysis tooling, and this change
was prepared with assistance from DeepSeek-V4.1-Flash and GPT-6.1-Sol.
Fixes: 2a001ca00ad5 ("drm/vc4: hdmi: Rework hdmi_enable_4kp60 detection code")
Cc: stable@vger.kernel.org
Suggested-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/20261106092016.2282805-1-vulab@iscas.ac.cn
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vc4/vc4_hvs.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
@@ -1677,15 +1677,6 @@ static int vc4_hvs_bind(struct device *d
struct device_node *node;
unsigned int max_rate;
- node = rpi_firmware_find_node();
- if (!node)
- return -EINVAL;
-
- firmware = rpi_firmware_get(node);
- of_node_put(node);
- if (!firmware)
- return -EPROBE_DEFER;
-
hvs->core_clk = devm_clk_get(&pdev->dev,
(vc4->gen >= VC4_GEN_6_C) ? "core" : NULL);
if (IS_ERR(hvs->core_clk)) {
@@ -1700,6 +1691,15 @@ static int vc4_hvs_bind(struct device *d
return PTR_ERR(hvs->disp_clk);
}
+ node = rpi_firmware_find_node();
+ if (!node)
+ return -EINVAL;
+
+ firmware = rpi_firmware_get(node);
+ of_node_put(node);
+ if (!firmware)
+ return -EPROBE_DEFER;
+
max_rate = rpi_firmware_clk_get_max_rate(firmware,
RPI_FIRMWARE_CORE_CLK_ID);
rpi_firmware_put(firmware);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 400/742] drm/vc4: Hold a runtime PM reference while allocating the binner BO
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (390 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 399/742] drm/vc4: Fix firmware reference leak in vc4_hvs_bind() Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 401/742] drm/vc4: Check for a validated shader before reading its thread mode Greg Kroah-Hartman
` (334 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <mcanal@igalia.com>
commit a7d7a25b566635ac1ee6af1c3ef06484cf752c3f upstream.
bin_bo_alloc() arms the out-of-memory interrupt once it has allocated the
binner BO, and accessing a V3D register requires the block to be powered.
vc4_submit_cl_ioctl() already holds a runtime PM reference by the time it
reaches vc4_get_bcl(), but vc4_create_bo_ioctl() reaches vc4_grab_bin_bo()
without one, so the write can land on a suspended device.
Take the reference in vc4_v3d_bin_bo_get(), which covers both callers, and
take it before bin_bo_lock so that runtime PM is never waited for with the
mutex held.
Cc: stable@vger.kernel.org
Fixes: 35c8b4b2c0fe ("drm/vc4: Allocate binner bo when starting to use the V3D")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261111-vc4-irq-cleanup-v2-1-aa757bb742f2@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vc4/vc4_v3d.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/vc4/vc4_v3d.c
+++ b/drivers/gpu/drm/vc4/vc4_v3d.c
@@ -322,11 +322,15 @@ static int bin_bo_alloc(struct vc4_dev *
int vc4_v3d_bin_bo_get(struct vc4_dev *vc4, bool *used)
{
- int ret = 0;
+ int ret;
if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
return -ENODEV;
+ ret = vc4_v3d_pm_get(vc4);
+ if (ret)
+ return ret;
+
mutex_lock(&vc4->bin_bo_lock);
if (used && *used)
@@ -342,6 +346,7 @@ int vc4_v3d_bin_bo_get(struct vc4_dev *v
complete:
mutex_unlock(&vc4->bin_bo_lock);
+ vc4_v3d_pm_put(vc4);
return ret;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 401/742] drm/vc4: Check for a validated shader before reading its thread mode
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (391 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 400/742] drm/vc4: Hold a runtime PM reference while allocating the binner BO Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 402/742] drm/vc4: Clear the slice caches before resetting a stalled GPU Greg Kroah-Hartman
` (333 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <mcanal@igalia.com>
commit 15da41dff1f66a389d238db60a1c19fa83582d07 upstream.
validate_gl_shader_rec() reads the thread mode from the validated_shader
of the FS, VS and CS BOs before checking it for NULL. A shader record
pointing at a BO not created by DRM_IOCTL_VC4_CREATE_SHADER_BO has no
validated_shader, so userspace can trigger a NULL pointer dereference.
Check that every shader BO has a validated shader before using it.
Cc: stable@vger.kernel.org
Fixes: c778cc5df944 ("drm/vc4: Add fragment shader threading support")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-2-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vc4/vc4_validate.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
--- a/drivers/gpu/drm/vc4/vc4_validate.c
+++ b/drivers/gpu/drm/vc4/vc4_validate.c
@@ -823,6 +823,9 @@ validate_gl_shader_rec(struct drm_device
bo[i] = to_drm_gem_dma_obj(exec->bo[src_handles[i]]);
if (!bo[i])
return -EINVAL;
+
+ if (!to_vc4_bo(&bo[i]->base)->validated_shader)
+ return -EINVAL;
}
for (i = shader_reloc_count; i < nr_relocs; i++) {
bo[i] = vc4_use_bo(exec, src_handles[i]);
@@ -843,7 +846,8 @@ validate_gl_shader_rec(struct drm_device
}
for (i = 0; i < shader_reloc_count; i++) {
- struct vc4_validated_shader_info *validated_shader;
+ struct vc4_validated_shader_info *validated_shader =
+ to_vc4_bo(&bo[i]->base)->validated_shader;
uint32_t o = shader_reloc_offsets[i];
uint32_t src_offset = *(uint32_t *)(pkt_u + o);
uint32_t *texture_handles_u;
@@ -858,10 +862,6 @@ validate_gl_shader_rec(struct drm_device
return -EINVAL;
}
- validated_shader = to_vc4_bo(&bo[i]->base)->validated_shader;
- if (!validated_shader)
- return -EINVAL;
-
if (validated_shader->uniforms_src_size >
exec->uniforms_size) {
DRM_DEBUG("Uniforms src buffer overflow\n");
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 402/742] drm/vc4: Clear the slice caches before resetting a stalled GPU
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (392 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 401/742] drm/vc4: Check for a validated shader before reading its thread mode Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 403/742] drm/vc4: Drop BO usecnt before releasing the old FB Greg Kroah-Hartman
` (332 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <mcanal@igalia.com>
commit af1cf92e8617a7f7aa24b415596cbf64b76a12e7 upstream.
Starting shader code at varying offsets makes the GFXH-16 icache livelock
unlikely, but not impossible. When the livelock happens, the QPUs make no
progress and the hangcheck resets the GPU, losing the job.
When the hangcheck finds no progress, clear the slice instruction and
uniforms caches and check again before resetting. If the stall is a
livelock, clearing the caches can break it and let the job continue.
Drop round_jiffies_up() from the hangcheck timer, so checks run every
100 ms instead of at the next whole second. This shortens the screen
freeze before the caches are cleared. Long jobs are unaffected: while the
control lists advance, the hangcheck won't clear the caches or reset the
GPU.
Cc: stable@vger.kernel.org
Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/16652
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-4-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vc4/vc4_drv.h | 5 +++++
drivers/gpu/drm/vc4/vc4_gem.c | 20 ++++++++++++++++++--
2 files changed, 23 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -223,6 +223,11 @@ struct vc4_dev {
struct {
struct timer_list timer;
struct work_struct reset_work;
+
+ /* The instruction and uniforms caches were cleared at the
+ * last check that found no progress.
+ */
+ bool caches_cleared;
} hangcheck;
struct drm_modeset_lock ctm_state_lock;
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -43,8 +43,7 @@ vc4_queue_hangcheck(struct drm_device *d
{
struct vc4_dev *vc4 = to_vc4_dev(dev);
- mod_timer(&vc4->hangcheck.timer,
- round_jiffies_up(jiffies + msecs_to_jiffies(100)));
+ mod_timer(&vc4->hangcheck.timer, jiffies + msecs_to_jiffies(100));
}
struct vc4_hang_state {
@@ -343,6 +342,7 @@ vc4_hangcheck_elapsed(struct timer_list
/* If idle, we can stop watching for hangs. */
if (!bin_exec && !render_exec) {
+ vc4->hangcheck.caches_cleared = false;
spin_unlock_irqrestore(&vc4->job_lock, irqflags);
return;
}
@@ -359,11 +359,27 @@ vc4_hangcheck_elapsed(struct timer_list
bin_exec->last_ct0ca = ct0ca;
if (render_exec)
render_exec->last_ct1ca = ct1ca;
+
+ vc4->hangcheck.caches_cleared = false;
+
spin_unlock_irqrestore(&vc4->job_lock, irqflags);
vc4_queue_hangcheck(dev);
return;
}
+ /* Clear the slice caches to workaround GFXH-16 */
+ if (!vc4->hangcheck.caches_cleared) {
+ V3D_WRITE(V3D_SLCACTL, VC4_SET_FIELD(0xf, V3D_SLCACTL_ICC) |
+ VC4_SET_FIELD(0xf, V3D_SLCACTL_UCC));
+
+ vc4->hangcheck.caches_cleared = true;
+ spin_unlock_irqrestore(&vc4->job_lock, irqflags);
+ vc4_queue_hangcheck(dev);
+ return;
+ }
+
+ vc4->hangcheck.caches_cleared = false;
+
spin_unlock_irqrestore(&vc4->job_lock, irqflags);
/* We've gone too long with no progress, reset. This has to
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 403/742] drm/vc4: Drop BO usecnt before releasing the old FB
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (393 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 402/742] drm/vc4: Clear the slice caches before resetting a stalled GPU Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 404/742] drm/vc4: Fix off-by-one in the shader record BO handle check Greg Kroah-Hartman
` (331 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <mcanal@igalia.com>
commit 43b85636ea0d33152bf16816b7601e785723596d upstream.
The async page flip completion drops the old FB reference before
decrementing its BO usecnt. If that was the last reference, the BO is
already freed or recycled into the BO cache when vc4_bo_dec_usecnt()
runs, leading to a use-after-free or a refcount underflow. For example,
while running glmark2-es2-drm in the Raspberry Pi 3, the following
warning appears:
[ 459.078834] ------------[ cut here ]------------
[ 459.078855] refcount_t: underflow; use-after-free.
[ 459.078952] WARNING: lib/refcount.c:96 at refcount_dec_not_one+0xa0/0xa8, CPU#0: swapper/0/0
<snip>
[ 459.079316] Call trace:
[ 459.079323] refcount_dec_not_one+0xa0/0xa8 (P)
[ 459.079335] vc4_bo_dec_usecnt+0x30/0x118 [vc4]
[ 459.079371] vc4_async_page_flip_complete_with_cleanup+0xa0/0xc4 [vc4]
[ 459.079395] dma_fence_signal_timestamp_locked+0xb0/0x12c
[ 459.079408] dma_fence_signal+0x3c/0x6c
[ 459.079416] vc4_irq_render_job_done+0x24/0xbc [vc4]
[ 459.079440] vc4_irq+0x120/0x138 [vc4]
This could happen when userspace removes the old FB and closes its GEM
handle while the flip is still pending.
Decrement the BO usecnt before releasing the old FB reference. Do this
by unifying the two fence callbacks and only decrementing the BO usecnt
in VC4_GEN_4.
Cc: stable@vger.kernel.org
Fixes: 4d12c36fb73b ("drm/vc4: crtc: Move the BO handling out of common page-flip callback")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261114-vc4-async-flip-fixes-v2-1-d33cbe99ed5d@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vc4/vc4_crtc.c | 60 ++++++++++++++---------------------------
1 file changed, 21 insertions(+), 39 deletions(-)
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -895,6 +895,7 @@ vc4_async_page_flip_complete(struct vc4_
{
struct drm_crtc *crtc = flip_state->crtc;
struct drm_device *dev = crtc->dev;
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
struct drm_plane *plane = crtc->primary;
vc4_plane_async_set_fb(plane, flip_state->fb);
@@ -909,39 +910,27 @@ vc4_async_page_flip_complete(struct vc4_
drm_crtc_vblank_put(crtc);
drm_framebuffer_put(flip_state->fb);
- if (flip_state->old_fb)
- drm_framebuffer_put(flip_state->old_fb);
-
- kfree(flip_state);
-}
+ if (flip_state->old_fb) {
+ /*
+ * Decrement the BO usecnt in order to keep the inc/dec
+ * calls balanced when the planes are updated through
+ * the async update path.
+ *
+ * FIXME: we should move to generic async-page-flip when
+ * it's available, so that we can get rid of this
+ * hand-made cleanup_fb() logic.
+ */
+ if (vc4->gen == VC4_GEN_4) {
+ struct drm_gem_dma_object *dma_bo =
+ drm_fb_dma_get_gem_obj(flip_state->old_fb, 0);
-static void vc4_async_page_flip_complete_with_cleanup(struct dma_fence *fence,
- struct dma_fence_cb *cb)
-{
- struct vc4_async_flip_state *flip_state =
- container_of(cb, struct vc4_async_flip_state, cb);
- struct vc4_bo *bo = NULL;
+ vc4_bo_dec_usecnt(to_vc4_bo(&dma_bo->base));
+ }
- if (flip_state->old_fb) {
- struct drm_gem_dma_object *dma_bo =
- drm_fb_dma_get_gem_obj(flip_state->old_fb, 0);
- bo = to_vc4_bo(&dma_bo->base);
+ drm_framebuffer_put(flip_state->old_fb);
}
- vc4_async_page_flip_complete(flip_state);
- dma_fence_put(fence);
-
- /*
- * Decrement the BO usecnt in order to keep the inc/dec
- * calls balanced when the planes are updated through
- * the async update path.
- *
- * FIXME: we should move to generic async-page-flip when
- * it's available, so that we can get rid of this
- * hand-made cleanup_fb() logic.
- */
- if (bo)
- vc4_bo_dec_usecnt(bo);
+ kfree(flip_state);
}
static void vc4_async_page_flip_fence_complete(struct dma_fence *fence,
@@ -959,30 +948,23 @@ static int vc4_async_set_fence_cb(struct
{
struct drm_framebuffer *fb = flip_state->fb;
struct drm_gem_dma_object *dma_bo = drm_fb_dma_get_gem_obj(fb, 0);
- dma_fence_func_t async_page_flip_complete_function;
- struct vc4_dev *vc4 = to_vc4_dev(dev);
struct dma_fence *fence;
int ret;
- if (vc4->gen == VC4_GEN_4)
- async_page_flip_complete_function = vc4_async_page_flip_complete_with_cleanup;
- else
- async_page_flip_complete_function = vc4_async_page_flip_fence_complete;
-
ret = dma_resv_get_singleton(dma_bo->base.resv, DMA_RESV_USAGE_READ, &fence);
if (ret)
return ret;
/* If there's no fence, complete the page flip immediately */
if (!fence) {
- async_page_flip_complete_function(fence, &flip_state->cb);
+ vc4_async_page_flip_fence_complete(fence, &flip_state->cb);
return 0;
}
/* If the fence has already been completed, complete the page flip */
if (dma_fence_add_callback(fence, &flip_state->cb,
- async_page_flip_complete_function))
- async_page_flip_complete_function(fence, &flip_state->cb);
+ vc4_async_page_flip_fence_complete))
+ vc4_async_page_flip_fence_complete(fence, &flip_state->cb);
return 0;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 404/742] drm/vc4: Fix off-by-one in the shader record BO handle check
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (394 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 403/742] drm/vc4: Drop BO usecnt before releasing the old FB Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 405/742] drm/vc4: Start shader code at varying offsets in its BO Greg Kroah-Hartman
` (330 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <mcanal@igalia.com>
commit 1fbbd14add401c70c178f0fa13016a3a53ef0de5 upstream.
validate_gl_shader_rec() accepts a shader BO handle equal to
exec->bo_count, reading one entry past the end of exec->bo[] and
using it as a GEM object.
Reject handles that aren't below exec->bo_count.
Cc: stable@vger.kernel.org
Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-1-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vc4/vc4_validate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/gpu/drm/vc4/vc4_validate.c
+++ b/drivers/gpu/drm/vc4/vc4_validate.c
@@ -815,7 +815,7 @@ validate_gl_shader_rec(struct drm_device
exec->shader_rec_size -= packet_size;
for (i = 0; i < shader_reloc_count; i++) {
- if (src_handles[i] > exec->bo_count) {
+ if (src_handles[i] >= exec->bo_count) {
DRM_DEBUG("Shader handle %d too big\n", src_handles[i]);
return -EINVAL;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 405/742] drm/vc4: Start shader code at varying offsets in its BO
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (395 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 404/742] drm/vc4: Fix off-by-one in the shader record BO handle check Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 406/742] drm/vc4: Complete async page flips from an ordered workqueue Greg Kroah-Hartman
` (329 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <mcanal@igalia.com>
commit c0e1ed41ad86cf5230d64dc5f2c6d2e3aeb59937 upstream.
VC4 is affected by the HW erratum GFXH-16: the QPUs can get stuck in a
loop where instruction cache loads are evicted before they are used.
The QPUs of a slice share one instruction cache. Shader BOs are page
aligned and the code always starts at offset 0, so instructions at the
same position in different shaders end up mapping to the same cache sets.
When the four QPUs of a slice run four different shaders, their fills
evict each other, no instruction executes and the hangcheck resets the
GPU.
Place each shader's code at one of four offsets, 256 bytes apart, inside
its BO, and add the offset when relocating the shader record. Shader code
is position independent, as the validator only accepts relative branches.
The offsets are tracked per client, so shaders a given client creates in
sequence (which tend to run together) start in different sets.
Notice that this approach makes the livelock unlikely, but not impossible.
The next commit will address the remaining cases.
On a Raspberry Pi 3 running the issue's reproducer, GPU resets went from
dozens in an hour to none.
Cc: stable@vger.kernel.org
Fixes: 463873d57014 ("drm/vc4: Add an API for creating GPU shaders in GEM BOs.")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/16652
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261118-vc4-icache-workaround-v1-3-5b8adc2c84fe@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vc4/vc4_bo.c | 43 ++++++++++++++++++++++-------
drivers/gpu/drm/vc4/vc4_drv.h | 10 ++++++
drivers/gpu/drm/vc4/vc4_validate.c | 3 +-
drivers/gpu/drm/vc4/vc4_validate_shaders.c | 7 ++--
4 files changed, 48 insertions(+), 15 deletions(-)
--- a/drivers/gpu/drm/vc4/vc4_bo.c
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
@@ -17,6 +17,7 @@
*/
#include <linux/dma-buf.h>
+#include <linux/overflow.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_print.h>
@@ -836,6 +837,19 @@ int vc4_mmap_bo_ioctl(struct drm_device
return 0;
}
+/*
+ * QPUs sharing a slice's instruction cache can livelock evicting each
+ * other's fills. Considering that shader BOs are page aligned, any code
+ * at offset 0 maps every shader to the same cache sets. This makes a
+ * livelock more likely to happen due to GFXH-16.
+ *
+ * Start each shader at one of four offsets, cycled per client, to spread
+ * them across sets. The use of four different offsets is motivated by the
+ * number of QPUs per slice (4 QPUs).
+ */
+#define VC4_SHADER_OFFSET_STEP 256
+#define VC4_SHADER_OFFSET_NUM 4
+
int
vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
@@ -844,6 +858,7 @@ vc4_create_shader_bo_ioctl(struct drm_de
struct vc4_file *vc4file = file_priv->driver_priv;
struct vc4_dev *vc4 = to_vc4_dev(dev);
struct vc4_bo *bo = NULL;
+ u32 offset, size;
int ret;
if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
@@ -865,29 +880,37 @@ vc4_create_shader_bo_ioctl(struct drm_de
return -EINVAL;
}
+ offset = ((u32)atomic_inc_return(&vc4file->shader_offset_idx) %
+ VC4_SHADER_OFFSET_NUM) * VC4_SHADER_OFFSET_STEP;
+
+ if (check_add_overflow(offset, args->size, &size))
+ return -EINVAL;
+
ret = vc4_grab_bin_bo(vc4, vc4file);
if (ret)
return ret;
- bo = vc4_bo_create(dev, args->size, true, VC4_BO_TYPE_V3D_SHADER);
+ bo = vc4_bo_create(dev, size, true, VC4_BO_TYPE_V3D_SHADER);
if (IS_ERR(bo))
return PTR_ERR(bo);
bo->madv = VC4_MADV_WILLNEED;
+ bo->shader_offset = offset;
- if (copy_from_user(bo->base.vaddr,
- (void __user *)(uintptr_t)args->data,
- args->size)) {
+ /* Clear the memory around the code, which may come from the BO
+ * cache.
+ */
+ memset(bo->base.vaddr, 0, offset);
+ if (copy_from_user(bo->base.vaddr + offset,
+ (void __user *)(uintptr_t)args->data,
+ args->size)) {
ret = -EFAULT;
goto fail;
}
- /* Clear the rest of the memory from allocating from the BO
- * cache.
- */
- memset(bo->base.vaddr + args->size, 0,
- bo->base.base.size - args->size);
+ memset(bo->base.vaddr + offset + args->size, 0,
+ bo->base.base.size - offset - args->size);
- bo->validated_shader = vc4_validate_shader(&bo->base);
+ bo->validated_shader = vc4_validate_shader(&bo->base, offset);
if (!bo->validated_shader) {
ret = -EINVAL;
goto fail;
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -265,6 +265,9 @@ struct vc4_bo {
*/
struct vc4_validated_shader_info *validated_shader;
+ /* Byte offset of the shader code in the BO. */
+ u32 shader_offset;
+
/* One of enum vc4_kernel_bo_type, or VC4_BO_TYPE_COUNT + i
* for user-allocated labels.
*/
@@ -799,6 +802,11 @@ struct vc4_file {
struct xarray perfmons;
bool bin_bo_used;
+
+ /* Counter picking the start offset of the next shader BO's code,
+ * see vc4_create_shader_bo_ioctl().
+ */
+ atomic_t shader_offset_idx;
};
static inline struct vc4_exec_info *
@@ -1085,7 +1093,7 @@ bool vc4_check_tex_size(struct vc4_exec_
/* vc4_validate_shader.c */
struct vc4_validated_shader_info *
-vc4_validate_shader(struct drm_gem_dma_object *shader_obj);
+vc4_validate_shader(struct drm_gem_dma_object *shader_obj, u32 offset);
/* vc4_perfmon.c */
void vc4_perfmon_get(struct vc4_perfmon *perfmon);
--- a/drivers/gpu/drm/vc4/vc4_validate.c
+++ b/drivers/gpu/drm/vc4/vc4_validate.c
@@ -854,7 +854,8 @@ validate_gl_shader_rec(struct drm_device
void *uniform_data_u;
uint32_t tex, uni;
- *(uint32_t *)(pkt_v + o) = bo[i]->dma_addr + src_offset;
+ *(uint32_t *)(pkt_v + o) = bo[i]->dma_addr + src_offset +
+ to_vc4_bo(&bo[i]->base)->shader_offset;
if (src_offset != 0) {
DRM_DEBUG("Shaders must be at offset 0 of "
--- a/drivers/gpu/drm/vc4/vc4_validate_shaders.c
+++ b/drivers/gpu/drm/vc4/vc4_validate_shaders.c
@@ -779,7 +779,7 @@ vc4_handle_branch_target(struct vc4_shad
}
struct vc4_validated_shader_info *
-vc4_validate_shader(struct drm_gem_dma_object *shader_obj)
+vc4_validate_shader(struct drm_gem_dma_object *shader_obj, u32 offset)
{
struct vc4_dev *vc4 = to_vc4_dev(shader_obj->base.dev);
bool found_shader_end = false;
@@ -793,8 +793,9 @@ vc4_validate_shader(struct drm_gem_dma_o
return NULL;
memset(&validation_state, 0, sizeof(validation_state));
- validation_state.shader = shader_obj->vaddr;
- validation_state.max_ip = shader_obj->base.size / sizeof(uint64_t);
+ validation_state.shader = shader_obj->vaddr + offset;
+ validation_state.max_ip = (shader_obj->base.size - offset) /
+ sizeof(uint64_t);
reset_validation_state(&validation_state);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 406/742] drm/vc4: Complete async page flips from an ordered workqueue
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (396 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 405/742] drm/vc4: Start shader code at varying offsets in its BO Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 407/742] drm/vc4: Look up the async page flip fence before committing the flip Greg Kroah-Hartman
` (328 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <mcanal@igalia.com>
commit 12a321af56c436e299414d8c276457dcf387e0cf upstream.
Async page flips complete from a dma_fence callback, which runs in the
fence signaling context: the VC4 render job IRQ handler on RPi 0-3 since
commit e8941ac97f28 ("drm/vc4: Remove BOs seqnos"), and the V3D IRQ
handler on RPi 4-5 since commit d19e00ee06a9 ("drm/vc4: crtc: Fix out of
order frames during asynchronous page flips").
Completing the flip may sleep: on RPi 0-3, vc4_bo_dec_usecnt() takes
bo->madv_lock, and on all platforms, dropping the last framebuffer
reference takes fb_lock and can free the BO. When running the kernel
with CONFIG_DEBUG_ATOMIC_SLEEP=y on RPi 3, this triggers the following
warning:
[ 2511.636319] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:623
[ 2511.636667] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/0
[ 2511.636681] preempt_count: 1000002, expected: 0
[ 2511.636689] RCU nest depth: 0, expected: 0
[ 2511.636698] locks held by swapper/0/0: 1, on CPU#0:
[ 2511.636711] #0: ffff000037183198 (&fence->inline_lock){-...}-{3:3}, at: dma_fence_signal+0x88/0xec
<snip>
[ 2511.636892] Hardware name: Raspberry Pi 3 Model B Plus Rev 1.3 (DT)
[ 2511.636899] Call trace:
<snip>
[ 2511.636991] mutex_lock_nested+0x24/0x30
[ 2511.637002] vc4_bo_dec_usecnt+0x40/0x124 [vc4]
[ 2511.637070] vc4_async_page_flip_complete_with_cleanup+0xa0/0xc4 [vc4]
[ 2511.637102] dma_fence_signal_timestamp_locked+0x118/0x290
[ 2511.637116] dma_fence_signal+0x9c/0xec
[ 2511.637126] vc4_irq_render_job_done+0x24/0x114 [vc4]
[ 2511.637158] vc4_irq+0x16c/0x274 [vc4]
Make the fence callback only queue a work item on a per-CRTC ordered
workqueue and complete the flip from it. Flips with no fence or an already
signaled one still complete inline, but only after flushing that workqueue,
so they can't complete before earlier flips on the same CRTC whose fence
already signaled.
Cc: stable@vger.kernel.org
Fixes: d19e00ee06a9 ("drm/vc4: crtc: Fix out of order frames during asynchronous page flips")
Fixes: e8941ac97f28 ("drm/vc4: Remove BOs seqnos")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261114-vc4-async-flip-fixes-v2-2-d33cbe99ed5d@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vc4/vc4_crtc.c | 51 +++++++++++++++++++++++++----------------
drivers/gpu/drm/vc4/vc4_drv.h | 6 ++++
2 files changed, 38 insertions(+), 19 deletions(-)
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -884,15 +884,18 @@ struct vc4_async_flip_state {
struct drm_framebuffer *fb;
struct drm_framebuffer *old_fb;
struct drm_pending_vblank_event *event;
+ struct dma_fence *fence;
struct dma_fence_cb cb;
+ struct work_struct work;
};
-/* Called when the V3D execution for the BO being flipped to is done, so that
- * we can actually update the plane's address to point to it.
+/* Executed when the V3D execution for the BO being flipped to is done, so
+ * that we can actually update the plane's address to point to it.
*/
-static void
-vc4_async_page_flip_complete(struct vc4_async_flip_state *flip_state)
+static void vc4_async_page_flip_work(struct work_struct *work)
{
+ struct vc4_async_flip_state *flip_state =
+ container_of(work, struct vc4_async_flip_state, work);
struct drm_crtc *crtc = flip_state->crtc;
struct drm_device *dev = crtc->dev;
struct vc4_dev *vc4 = to_vc4_dev(dev);
@@ -930,17 +933,19 @@ vc4_async_page_flip_complete(struct vc4_
drm_framebuffer_put(flip_state->old_fb);
}
+ dma_fence_put(flip_state->fence);
kfree(flip_state);
}
-static void vc4_async_page_flip_fence_complete(struct dma_fence *fence,
- struct dma_fence_cb *cb)
+static void vc4_async_page_flip_fence_cb(struct dma_fence *fence,
+ struct dma_fence_cb *cb)
{
struct vc4_async_flip_state *flip_state =
container_of(cb, struct vc4_async_flip_state, cb);
+ struct vc4_crtc *vc4_crtc = to_vc4_crtc(flip_state->crtc);
- vc4_async_page_flip_complete(flip_state);
- dma_fence_put(fence);
+ /* Completing the flip may sleep, so defer it to a worker. */
+ queue_work(vc4_crtc->async_flip_wq, &flip_state->work);
}
static int vc4_async_set_fence_cb(struct drm_device *dev,
@@ -948,23 +953,26 @@ static int vc4_async_set_fence_cb(struct
{
struct drm_framebuffer *fb = flip_state->fb;
struct drm_gem_dma_object *dma_bo = drm_fb_dma_get_gem_obj(fb, 0);
- struct dma_fence *fence;
+ struct vc4_crtc *vc4_crtc = to_vc4_crtc(flip_state->crtc);
int ret;
- ret = dma_resv_get_singleton(dma_bo->base.resv, DMA_RESV_USAGE_READ, &fence);
+ INIT_WORK(&flip_state->work, vc4_async_page_flip_work);
+
+ ret = dma_resv_get_singleton(dma_bo->base.resv, DMA_RESV_USAGE_READ,
+ &flip_state->fence);
if (ret)
return ret;
- /* If there's no fence, complete the page flip immediately */
- if (!fence) {
- vc4_async_page_flip_fence_complete(fence, &flip_state->cb);
+ if (flip_state->fence &&
+ !dma_fence_add_callback(flip_state->fence, &flip_state->cb,
+ vc4_async_page_flip_fence_cb))
return 0;
- }
- /* If the fence has already been completed, complete the page flip */
- if (dma_fence_add_callback(fence, &flip_state->cb,
- vc4_async_page_flip_fence_complete))
- vc4_async_page_flip_fence_complete(fence, &flip_state->cb);
+ /* No fence or the fence has already signaled. Complete the flip
+ * immediately, after earlier queued flips.
+ */
+ flush_workqueue(vc4_crtc->async_flip_wq);
+ vc4_async_page_flip_work(&flip_state->work);
return 0;
}
@@ -990,7 +998,7 @@ vc4_async_page_flip_common(struct drm_cr
/* Save the current FB before it's replaced by the new one in
* drm_atomic_set_fb_for_plane(). We'll need the old FB in
- * vc4_async_page_flip_complete() to decrement the BO usecnt and keep
+ * vc4_async_page_flip_work() to decrement the BO usecnt and keep
* it consistent.
* FIXME: we should move to generic async-page-flip when it's
* available, so that we can get rid of this hand-made cleanup_fb()
@@ -1397,6 +1405,11 @@ int __vc4_crtc_init(struct drm_device *d
drm_crtc_helper_add(crtc, crtc_helper_funcs);
+ vc4_crtc->async_flip_wq = drmm_alloc_ordered_workqueue(drm, "%s-async-flip",
+ 0, crtc->name);
+ if (IS_ERR(vc4_crtc->async_flip_wq))
+ return PTR_ERR(vc4_crtc->async_flip_wq);
+
if (vc4->gen == VC4_GEN_4) {
drm_mode_crtc_set_gamma_size(crtc, ARRAY_SIZE(vc4_crtc->lut_r));
drm_crtc_enable_color_mgmt(crtc, 0, false, crtc->gamma_size);
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -602,6 +602,12 @@ struct vc4_crtc {
* access to that value.
*/
unsigned int current_hvs_channel;
+
+ /**
+ * @async_flip_wq: Ordered workqueue completing the CRTC's async
+ * page flips.
+ */
+ struct workqueue_struct *async_flip_wq;
};
#define to_vc4_crtc(_crtc) \
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 407/742] drm/vc4: Look up the async page flip fence before committing the flip
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (397 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 406/742] drm/vc4: Complete async page flips from an ordered workqueue Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 408/742] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies Greg Kroah-Hartman
` (327 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <mcanal@igalia.com>
commit f9fc6da01a290609428d308033143f1d96ab658f upstream.
vc4_async_page_flip_common() ignores dma_resv_get_singleton() failures.
By then the plane state already points at the new framebuffer, so the
flip is never completed. So, its state leaks, the vblank reference is
never dropped and the event is never sent.
Look up the fence before changing any state, so the error can be properly
returned to userspace.
Cc: stable@vger.kernel.org
Fixes: d19e00ee06a9 ("drm/vc4: crtc: Fix out of order frames during asynchronous page flips")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261114-vc4-async-flip-fixes-v2-3-d33cbe99ed5d@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vc4/vc4_crtc.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -948,33 +948,22 @@ static void vc4_async_page_flip_fence_cb
queue_work(vc4_crtc->async_flip_wq, &flip_state->work);
}
-static int vc4_async_set_fence_cb(struct drm_device *dev,
- struct vc4_async_flip_state *flip_state)
+static void vc4_async_set_fence_cb(struct vc4_async_flip_state *flip_state)
{
- struct drm_framebuffer *fb = flip_state->fb;
- struct drm_gem_dma_object *dma_bo = drm_fb_dma_get_gem_obj(fb, 0);
struct vc4_crtc *vc4_crtc = to_vc4_crtc(flip_state->crtc);
- int ret;
INIT_WORK(&flip_state->work, vc4_async_page_flip_work);
- ret = dma_resv_get_singleton(dma_bo->base.resv, DMA_RESV_USAGE_READ,
- &flip_state->fence);
- if (ret)
- return ret;
-
if (flip_state->fence &&
!dma_fence_add_callback(flip_state->fence, &flip_state->cb,
vc4_async_page_flip_fence_cb))
- return 0;
+ return;
/* No fence or the fence has already signaled. Complete the flip
* immediately, after earlier queued flips.
*/
flush_workqueue(vc4_crtc->async_flip_wq);
vc4_async_page_flip_work(&flip_state->work);
-
- return 0;
}
static int
@@ -983,14 +972,22 @@ vc4_async_page_flip_common(struct drm_cr
struct drm_pending_vblank_event *event,
uint32_t flags)
{
- struct drm_device *dev = crtc->dev;
+ struct drm_gem_dma_object *dma_bo = drm_fb_dma_get_gem_obj(fb, 0);
struct drm_plane *plane = crtc->primary;
struct vc4_async_flip_state *flip_state;
+ int ret;
flip_state = kzalloc_obj(*flip_state);
if (!flip_state)
return -ENOMEM;
+ ret = dma_resv_get_singleton(dma_bo->base.resv, DMA_RESV_USAGE_READ,
+ &flip_state->fence);
+ if (ret) {
+ kfree(flip_state);
+ return ret;
+ }
+
drm_framebuffer_get(fb);
flip_state->fb = fb;
flip_state->crtc = crtc;
@@ -1016,7 +1013,7 @@ vc4_async_page_flip_common(struct drm_cr
*/
drm_atomic_set_fb_for_plane(plane->state, fb);
- vc4_async_set_fence_cb(dev, flip_state);
+ vc4_async_set_fence_cb(flip_state);
/* Driver takes ownership of state on successful async commit. */
return 0;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 408/742] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (398 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 407/742] drm/vc4: Look up the async page flip fence before committing the flip Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 409/742] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages Greg Kroah-Hartman
` (326 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit 05ee42f3dd5484415fac587d0efb8fe846b74c2c upstream.
vmw_host_get_guestinfo subtracts the two-byte reply prefix using
max(reply_len - 2, (size_t)0). Since reply_len is unsigned, a one-byte
reply wraps to SIZE_MAX instead of being clamped to zero. The subsequent
copy can read past the host reply allocation.
Theoretically malformed host reply can reach this path when the driver
queries the GuestInfo parameter used to enable VKMS.
Check the reply length before subtracting the prefix so short replies
produce an empty payload and cannot cause an out-of-bounds read.
Sashiko reported this while reviewing the i386 hypercall changes.
Fixes: 89da76fde68d ("drm/vmwgfx: Add VMWare host messaging capability")
Cc: stable@vger.kernel.org
Closes: https://sashiko.dev/#/patchset/4ab10678a8f50053934b62b56af81f881c1d3798.1788414669.git.zack.rusin%40broadcom.com
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261029215738.3010276-1-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -431,7 +431,7 @@ int vmw_host_get_guestinfo(const char *g
/* Remove reply code, which are the first 2 characters of
* the reply
*/
- reply_len = max(reply_len - 2, (size_t) 0);
+ reply_len = reply_len > 2 ? reply_len - 2 : 0;
reply_len = min(reply_len, *length);
if (reply_len > 0)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 409/742] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (399 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 408/742] drm/vmwgfx: avoid underflow when stripping short GuestInfo replies Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 410/742] drm/vmwgfx: do not hand the embedded sg_table to the PRIME core Greg Kroah-Hartman
` (325 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit 9725b0454e65f15ae76788f2004a7ba8b493362a upstream.
vmw_mksstat_add_ioctl rounds the user-supplied 64bit lengths to page
counts before comparing them with the descriptors page arrays. PFN_UP
can wrap for lengths near U64_MAX. On 32bit kernels, storing a large page
count in size_t can also truncate it to a value that passes the checks.
A render-node client can therefore register a descriptor with lengths
that exceed its pinned page arrays, including nonzero lengths with no
backing pages.
Compare each byte length with its page array's capacity before rounding
or narrowing it. Compute those capacities in 64 bits and calculate the
page counts only after all three lengths have passed validation.
Sashiko reported this while reviewing the i386 hypercall changes.
Fixes: 7a7a933edd6c ("drm/vmwgfx: Introduce VMware mks-guest-stats")
Cc: stable@vger.kernel.org
Closes: https://sashiko.dev/#/patchset/4ab10678a8f50053934b62b56af81f881c1d3798.1788414669.git.zack.rusin%40broadcom.com
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261029215738.3010276-2-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -939,9 +939,12 @@ int vmw_mksstat_add_ioctl(struct drm_dev
struct vmw_private *const dev_priv = vmw_priv(dev);
- const size_t num_pages_stat = PFN_UP(arg->stat_len);
- const size_t num_pages_info = PFN_UP(arg->info_len);
- const size_t num_pages_strs = PFN_UP(arg->strs_len);
+ const u64 max_stat_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_STAT_PPNS * PAGE_SIZE;
+ const u64 max_info_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_INFO_PPNS * PAGE_SIZE;
+ const u64 max_strs_len = (u64)MKS_GUEST_STAT_INSTANCE_MAX_STRS_PPNS * PAGE_SIZE;
+ size_t num_pages_stat;
+ size_t num_pages_info;
+ size_t num_pages_strs;
long desc_len;
long nr_pinned_stat;
long nr_pinned_info;
@@ -965,11 +968,15 @@ int vmw_mksstat_add_ioctl(struct drm_dev
if (!arg->description)
return -EINVAL;
- if (num_pages_stat > ARRAY_SIZE(pdesc->statPPNs) ||
- num_pages_info > ARRAY_SIZE(pdesc->infoPPNs) ||
- num_pages_strs > ARRAY_SIZE(pdesc->strsPPNs))
+ if (arg->stat_len > max_stat_len ||
+ arg->info_len > max_info_len ||
+ arg->strs_len > max_strs_len)
return -EINVAL;
+ num_pages_stat = PFN_UP(arg->stat_len);
+ num_pages_info = PFN_UP(arg->info_len);
+ num_pages_strs = PFN_UP(arg->strs_len);
+
/* Find an available slot in the mksGuestStats user array and reserve it */
for (slot = 0; slot < ARRAY_SIZE(dev_priv->mksstat_user_pids); ++slot)
if (!atomic_cmpxchg(&dev_priv->mksstat_user_pids[slot], 0, MKSSTAT_PID_RESERVED))
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 410/742] drm/vmwgfx: do not hand the embedded sg_table to the PRIME core
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (400 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 409/742] drm/vmwgfx: bound MKSSTAT lengths before rounding to pages Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 411/742] drm/vmwgfx: Erase the detached resource entry on resource release Greg Kroah-Hartman
` (324 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Aldo Ariel Panzardo, Zack Rusin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
commit 030e6d11d3e5eb7328f7a3e8177737a4b1c30654 upstream.
vmw_gem_object_get_sg_table() returns vmw_tt->vsgt.sgt when the buffer
object has already been DMA mapped. vmw_ttm_map_dma() sets that field
to &vmw_tt->sgt, which is a member embedded inside the struct
vmw_ttm_tt allocation and not a table of its own.
The core owns whatever .get_sg_table returns. drm_gem_map_dma_buf()
takes the table and drm_gem_unmap_dma_buf() destroys it in full:
dma_unmap_sgtable(attach->dev, sgt, dir, DMA_ATTR_SKIP_CPU_SYNC);
sg_free_table(sgt);
kfree(sgt);
Both are ops of drm_gem_prime_dmabuf_ops, so the core ends up calling
kfree() on &vmw_tt->sgt, which is not the start of an allocation. The
preceding sg_free_table() also destroys a scatterlist that vmwgfx still
considers its own and frees again from vmw_ttm_unmap_dma().
drm_gem_unmap_dma_buf() runs from dma_buf_detach(), including the
importer's error path, so a failed import is enough to reach it:
exporting a bound buffer with DRM_IOCTL_PRIME_HANDLE_TO_FD and
importing it on a second DRM device with DRM_IOCTL_PRIME_FD_TO_HANDLE
is sufficient. Both ioctls are DRM_RENDER_ALLOW.
Observed on 6.12.101 with KASAN, as uid 65534:
BUG: KASAN: invalid-free in drm_gem_unmap_dma_buf+0xb3/0xf0
Free of addr ffff888008290450 by task poc_mm04_sgtabl/321
CPU: 1 UID: 65534 PID: 321 Comm: poc_mm04_sgtabl Not tainted 6.12.101 #4
kasan_report_invalid_free+0x94/0xc0
check_slab_allocation+0x116/0x120
kfree+0x103/0x360
drm_gem_unmap_dma_buf+0xb3/0xf0
dma_buf_detach+0x165/0x510
drm_gem_prime_import_dev+0x33e/0x430
which belongs to the cache kmalloc-192 of size 192
The buggy address is located 80 bytes inside of
144-byte region [ffff888008290400, ffff888008290490)
80 is offsetof(struct vmw_ttm_tt, sgt) and 144 is sizeof(struct
vmw_ttm_tt), which identifies the freed pointer as the embedded member.
Always return a table the core can own, as the other drivers do.
Reusing the cached representation would require copying it into a
freshly allocated sg_table, never returning the alias.
Fixes: 8afa13a0583f ("drm/vmwgfx: Implement DRIVER_GEM")
Cc: stable@vger.kernel.org
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20260923122601.438892-1-qwe.aldo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gem.c
@@ -73,10 +73,13 @@ static struct sg_table *vmw_gem_object_g
struct vmw_ttm_tt *vmw_tt =
container_of(bo->ttm, struct vmw_ttm_tt, dma_ttm);
- if (vmw_tt->vsgt.sgt)
- return vmw_tt->vsgt.sgt;
-
- return drm_prime_pages_to_sg(obj->dev, vmw_tt->dma_ttm.pages, vmw_tt->dma_ttm.num_pages);
+ /*
+ * Do not return &vmw_tt->sgt: the core owns what this returns and
+ * drm_gem_unmap_dma_buf() sg_free_table()s and kfree()s it, but that
+ * sg_table is embedded in the vmw_ttm_tt allocation.
+ */
+ return drm_prime_pages_to_sg(obj->dev, vmw_tt->dma_ttm.pages,
+ vmw_tt->dma_ttm.num_pages);
}
static int vmw_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 411/742] drm/vmwgfx: Erase the detached resource entry on resource release
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (401 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 410/742] drm/vmwgfx: do not hand the embedded sg_table to the PRIME core Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 412/742] drm/vmwgfx: fix NULL pointer dereference in vmw_validation_bo_fence() Greg Kroah-Hartman
` (323 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Jaeyeong Lee, Zack Rusin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaeyeong Lee <finpiler@protonmail.com>
commit c4b134969ce350cdd4e726b5102b85b8a2d6fad5 upstream.
vmw_bo_add_detached_resource() stores a raw struct vmw_resource pointer in
bo->detached_resources without taking a reference on the resource, and the
only place that erases the entry again is vmw_resource_mob_attach(). A
resource that is never validated, and therefore never attached to its
backing mob, keeps its entry until the buffer object itself is destroyed.
vmw_resource_release() detaches the resource from the mob RB tree and drops
its reference on the backing buffer object, but leaves the
detached_resources entry in place. Userspace can hold an independent GEM
handle on that buffer object, either because DRM_VMW_GB_SURFACE_CREATE
returned one in rep.buffer_handle, or because DRM_VMW_GB_SURFACE_REF minted
one with drm_gem_handle_create(). The buffer object then outlives the
surface while still holding a pointer to freed memory.
Any later surface lookup for that buffer object dereferences it:
vmw_prime_handle_to_fd()
vmw_lookup_surface_handle_for_buffer()
vmw_lookup_user_surface_for_buffer()
vmw_bo_surface()
res->func->res_type <-- use-after-free read
vmw_bo_surface() walks detached_resources before the mob RB tree, so the
stale entry is matched first. The kref_get_unless_zero() in
vmw_lookup_user_surface_for_buffer() does not help here: it runs after
the dereference, and struct vmw_user_surface is freed with kfree_rcu()
on a slab that is not SLAB_TYPESAFE_BY_RCU, so the memory is handed out
to unrelated allocations once the grace period elapses.
A sequence that reaches this from userspace is to create a guest-backed
surface with drm_vmw_surface_flag_create_buffer, never validate it,
release it with DRM_VMW_UNREF_SURFACE, and then call
DRM_IOCTL_PRIME_HANDLE_TO_FD on the buffer handle returned by the create
ioctl. All of the ioctls involved are DRM_RENDER_ALLOW.
Erase the entry next to the existing vmw_resource_mob_detach() call, so
that a released resource is removed from both containers, mirroring what
vmw_resource_mob_attach() does. The dumb buffer teardown path in
vmw_bo_free() clears res->guest_memory_bo before dropping its surface
reference, so it does not reach this code and is unaffected.
Fixes: d6667f0ddf46 ("drm/vmwgfx: Fix handling of dumb buffers")
Cc: stable@vger.kernel.org
Signed-off-by: Jaeyeong Lee <finpiler@protonmail.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
[zack: rebased; dropped the v7.2-rc4 analysis note from the commit message]
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20260725143859.797134-1-finpiler@protonmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -138,6 +138,7 @@ static void vmw_resource_release(struct
}
res->guest_memory_dirty = false;
vmw_resource_mob_detach(res);
+ vmw_bo_del_detached_resource(res->guest_memory_bo, res);
if (res->dirty)
res->func->dirty_free(res);
if (res->coherent)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 412/742] drm/vmwgfx: fix NULL pointer dereference in vmw_validation_bo_fence()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (402 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 411/742] drm/vmwgfx: Erase the detached resource entry on resource release Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 413/742] drm/vmwgfx: include legacy hotspots in GB-only cursor images Greg Kroah-Hartman
` (322 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Vladimir Popov, Zack Rusin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Popov <popov.nkv@gmail.com>
commit 06f8a6708a98dff199ef7ea553b092efc38b4eab upstream.
If vmw_execbuf_fence_commands() call fails in
vmw_kms_helper_validation_finish(), it sets *p_fence = NULL. If
ctx->bo_list is not empty, the caller, vmw_kms_helper_validation_finish(),
passes the fence through a chain of functions to dma_fence_is_array(),
which causes a NULL pointer dereference in dma_fence_is_array():
vmw_kms_helper_validation_finish() // pass NULL fence
vmw_validation_done()
vmw_validation_bo_fence()
ttm_eu_fence_buffer_objects() // pass NULL fence
dma_resv_add_fence()
dma_fence_is_container()
dma_fence_is_array() // NULL deref
Fix this by adding a NULL check in vmw_validation_bo_fence(): if the fence
is NULL, fall back to ttm_eu_backoff_reservation()to safely release
the buffer object reservations without attempting to add a NULL fence to
dma_resv. This is safe because when fence is NULL, vmw_fallback_wait()
has already been called inside vmw_execbuf_fence_commands() to synchronize
the GPU.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 038ecc503236 ("drm/vmwgfx: Add a validation module v2")
Cc: stable@vger.kernel.org
Signed-off-by: Vladimir Popov <popov.nkv@gmail.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20260414105529.9883-1-popov.nkv@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_validation.h | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_validation.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_validation.h
@@ -127,16 +127,23 @@ vmw_validation_bo_reserve(struct vmw_val
* vmw_validation_bo_fence - Unreserve and fence buffer objects registered
* with a validation context
* @ctx: The validation context
+ * @fence: Fence with which to fence all buffer objects taking part in the
+ * command submission.
*
* This function unreserves the buffer objects previously reserved using
- * vmw_validation_bo_reserve, and fences them with a fence object.
+ * vmw_validation_bo_reserve, and fences them with a fence object if the
+ * given fence object is not NULL.
*/
static inline void
vmw_validation_bo_fence(struct vmw_validation_context *ctx,
struct vmw_fence_obj *fence)
{
- ttm_eu_fence_buffer_objects(&ctx->ticket, &ctx->bo_list,
- (void *) fence);
+ /* fence is able to be NULL if vmw_execbuf_fence_commands() fails */
+ if (fence)
+ ttm_eu_fence_buffer_objects(&ctx->ticket, &ctx->bo_list,
+ (void *)fence);
+ else
+ ttm_eu_backoff_reservation(&ctx->ticket, &ctx->bo_list);
}
/**
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 413/742] drm/vmwgfx: include legacy hotspots in GB-only cursor images
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (403 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 412/742] drm/vmwgfx: fix NULL pointer dereference in vmw_validation_bo_fence() Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 414/742] drm/vmwgfx: keep cursor mappings and pins with each plane state Greg Kroah-Hartman
` (321 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tomas M, Maaz Mombasawala, fausten,
Zack Rusin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomas M <tomas@slax.org>
commit c116d38c3ad3ccdc1153ee7713c0eafd62b1c235 upstream.
The guest-backed cursor path without cursor MOB support defines the image
using only the hotspot from the plane state. Its position calculation
also includes the legacy hotspot supplied through DRM_VMW_CURSOR_BYPASS.
Xorg's xf86-video-vmware driver supplies its hotspot through that ioctl
and loads the image with drmModeSetCursor(), which does not set a plane
hotspot. The mismatched image and position hotspots displace the visible
cursor by the legacy offset.
Use the combined hotspot for both the GB-only image command and cursor
position, matching the legacy and MOB image paths.
Fixes: eef295a85082 ("drm/vmwgfx: Restore Guest-Backed only cursor plane support")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Tomas M <tomas@slax.org>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Tested-by: fausten <yunfeng.li.nb@gmail.com>
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20261027211729.646988-4-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
@@ -815,6 +815,10 @@ vmw_cursor_plane_atomic_update(struct dr
return;
}
+ /* Include legacy Xorg cursor-bypass offsets in the image and position. */
+ hotspot_x = vps->cursor.legacy.hotspot_x + new_state->hotspot_x;
+ hotspot_y = vps->cursor.legacy.hotspot_y + new_state->hotspot_y;
+
switch (vps->cursor.update_type) {
case VMW_CURSOR_UPDATE_LEGACY:
vmw_cursor_plane_update_legacy(dev_priv, vps);
@@ -828,8 +832,7 @@ vmw_cursor_plane_atomic_update(struct dr
vmw_send_define_cursor_cmd(dev_priv, bo->map.virtual,
vps->base.crtc_w,
vps->base.crtc_h,
- vps->base.hotspot_x,
- vps->base.hotspot_y);
+ hotspot_x, hotspot_y);
break;
case VMW_CURSOR_UPDATE_NONE:
/* do nothing */
@@ -842,9 +845,6 @@ vmw_cursor_plane_atomic_update(struct dr
cursor_x = new_state->crtc_x + du->set_gui_x;
cursor_y = new_state->crtc_y + du->set_gui_y;
- hotspot_x = vps->cursor.legacy.hotspot_x + new_state->hotspot_x;
- hotspot_y = vps->cursor.legacy.hotspot_y + new_state->hotspot_y;
-
vmw_cursor_update_position(dev_priv, true, cursor_x + hotspot_x,
cursor_y + hotspot_y);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 414/742] drm/vmwgfx: keep cursor mappings and pins with each plane state
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (404 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 413/742] drm/vmwgfx: include legacy hotspots in GB-only cursor images Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 415/742] drm/vmwgfx: log missing primary planes only once Greg Kroah-Hartman
` (320 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala,
fausten
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit 556271f0ade9d3f1ed0a386f29d3363be294c1fc upstream.
Cursor plane states duplicate the user object reference without acquiring
its mapping or pin. Preparing the duplicated state nevertheless unmaps
that object, and only pins the new buffer if it is not already pinned.
Cleanup of an older state can therefore remove a mapping or pin still
needed by another cursor commit. Repeated cursor updates from KMS clients
can then access an unmapped or movable buffer.
Give each prepared state its own mapping, buffer reference and pin, and
reset the mapping when duplicating a state. Release only the resources
owned by that state in cleanup_fb(). Map the required image extent for
every state so resizing a cursor on the same buffer cannot reuse a
smaller cached mapping. Unwind the pin and reservation if preparation
fails.
Fixes: 965544150d1c ("drm/vmwgfx: Refactor cursor handling")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Tested-by: fausten <yunfeng.li.nb@gmail.com>
Link: https://patch.msgid.link/20261027211729.646988-2-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c | 69 ++++++++++++++++-----------
drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.h | 4 +
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 1
3 files changed, 48 insertions(+), 26 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
@@ -112,8 +112,7 @@ static void vmw_cursor_update_mob(struct
{
SVGAGBCursorHeader *header;
SVGAGBAlphaCursorHeader *alpha_header;
- struct vmw_bo *bo = vmw_user_object_buffer(&vps->uo);
- u32 *image = vmw_bo_map_and_cache(bo);
+ u32 *image = vps->cursor.map.virtual;
const u32 image_size = vps->base.crtc_w * vps->base.crtc_h * sizeof(*image);
header = vmw_bo_map_and_cache(vps->cursor.mob);
@@ -132,7 +131,6 @@ static void vmw_cursor_update_mob(struct
memcpy(header + 1, image, image_size);
vmw_write(vmw, SVGA_REG_CURSOR_MOBID, vmw_bo_mobid(vps->cursor.mob));
- vmw_bo_unmap(bo);
vmw_bo_unmap(vps->cursor.mob);
}
@@ -490,9 +488,21 @@ vmw_cursor_plane_cleanup_fb(struct drm_p
{
struct vmw_cursor_plane *vcp = vmw_plane_to_vcp(plane);
struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state);
+ struct vmw_bo *bo;
+ int ret;
- if (!vmw_user_object_is_null(&vps->uo))
- vmw_user_object_unmap(&vps->uo);
+ if (vps->cursor.map.bo) {
+ bo = to_vmw_bo(&vps->cursor.map.bo->base);
+ ret = ttm_bo_reserve(&bo->tbo, false, false, NULL);
+ if (WARN_ON_ONCE(ret))
+ return;
+
+ ttm_bo_kunmap(&vps->cursor.map);
+ vps->cursor.map.bo = NULL;
+ ttm_bo_unpin(&bo->tbo);
+ ttm_bo_unreserve(&bo->tbo);
+ vmw_bo_unreference(&bo);
+ }
vmw_cursor_mob_unmap(vps);
vmw_cursor_mob_put(vcp, vps);
@@ -625,10 +635,12 @@ int vmw_cursor_plane_prepare_fb(struct d
struct vmw_surface *surface;
int ret = 0;
- if (!vmw_user_object_is_null(&vps->uo)) {
- vmw_user_object_unmap(&vps->uo);
+ /*
+ * A duplicated state only owns the user object reference. Its mappings
+ * and pins belong to the old state until cleanup_fb().
+ */
+ if (!vmw_user_object_is_null(&vps->uo))
vmw_user_object_unref(&vps->uo);
- }
if (fb) {
if (vmw_framebuffer_to_vfb(fb)->bo) {
@@ -652,31 +664,34 @@ int vmw_cursor_plane_prepare_fb(struct d
bo = vmw_user_object_buffer(&vps->uo);
if (bo) {
struct ttm_operation_ctx ctx = { false, false };
+ size_t size = (size_t)new_state->crtc_w *
+ new_state->crtc_h * sizeof(u32);
ret = ttm_bo_reserve(&bo->tbo, true, false, NULL);
if (ret != 0)
- return -ENOMEM;
+ return ret;
ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
if (ret != 0)
- return -ENOMEM;
+ goto out_unreserve;
/*
- * vmw_bo_pin_reserved also validates, so to skip
- * the extra validation use ttm_bo_pin directly
+ * vmw_bo_pin_reserved() also validates, so to skip
+ * the extra validation use ttm_bo_pin directly.
+ * Every state takes its own pin, the buffer can
+ * still be in use by an older state whose commit
+ * hasn't been cleaned up yet.
*/
- if (!bo->tbo.pin_count)
- ttm_bo_pin(&bo->tbo);
+ ttm_bo_pin(&bo->tbo);
- if (vmw_framebuffer_to_vfb(fb)->bo) {
- const u32 size = new_state->crtc_w *
- new_state->crtc_h *
- sizeof(u32);
-
- (void)vmw_bo_map_and_cache_size(bo, size);
- } else {
- vmw_bo_map_and_cache(bo);
+ ret = ttm_bo_kmap(&bo->tbo, 0, PFN_UP(size),
+ &vps->cursor.map);
+ if (ret) {
+ vps->cursor.map.bo = NULL;
+ ttm_bo_unpin(&bo->tbo);
+ goto out_unreserve;
}
+ vmw_bo_reference(bo);
ttm_bo_unreserve(&bo->tbo);
}
if (!vmw_user_object_is_null(&vps->uo)) {
@@ -703,6 +718,10 @@ int vmw_cursor_plane_prepare_fb(struct d
}
return 0;
+
+out_unreserve:
+ ttm_bo_unreserve(&bo->tbo);
+ return ret;
}
/**
@@ -796,7 +815,6 @@ void
vmw_cursor_plane_atomic_update(struct drm_plane *plane,
struct drm_atomic_commit *state)
{
- struct vmw_bo *bo;
struct drm_plane_state *new_state =
drm_atomic_get_new_plane_state(state, plane);
struct drm_plane_state *old_state =
@@ -827,9 +845,8 @@ vmw_cursor_plane_atomic_update(struct dr
vmw_cursor_update_mob(dev_priv, vps);
break;
case VMW_CURSOR_UPDATE_GB_ONLY:
- bo = vmw_user_object_buffer(&vps->uo);
- if (bo)
- vmw_send_define_cursor_cmd(dev_priv, bo->map.virtual,
+ if (vps->cursor.map.virtual)
+ vmw_send_define_cursor_cmd(dev_priv, vps->cursor.map.virtual,
vps->base.crtc_w,
vps->base.crtc_h,
hotspot_x, hotspot_y);
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.h
@@ -14,6 +14,8 @@
#include "drm/drm_fourcc.h"
#include "drm/drm_plane.h"
+#include <drm/ttm/ttm_bo.h>
+
#include <linux/types.h>
struct SVGA3dCmdHeader;
@@ -41,6 +43,8 @@ struct vmw_cursor_plane_state {
enum vmw_cursor_update_type update_type;
bool changed;
bool surface_changed;
+ /* The mapped buffer is referenced and pinned by this state. */
+ struct ttm_bo_kmap_obj map;
struct vmw_bo *mob;
struct {
s32 hotspot_x;
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -283,6 +283,7 @@ vmw_du_plane_duplicate_state(struct drm_
vps->cpp = 0;
vps->cursor.mob = NULL;
+ memset(&vps->cursor.map, 0, sizeof(vps->cursor.map));
/* Each ref counted resource needs to be acquired again */
vmw_user_object_ref(&vps->uo);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 415/742] drm/vmwgfx: log missing primary planes only once
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (405 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 414/742] drm/vmwgfx: keep cursor mappings and pins with each plane state Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 416/742] drm/vmwgfx: log MOB limits outside the manager spinlock Greg Kroah-Hartman
` (319 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit f01848d84577e5860a187eea64f5321acaf1f893 upstream.
Stop filling kernel logs due to something that's not even a bug. Some
igt tests, e.g. kms_flip trigger this message ~17000 times which makes
all the other diagnostics almost impossible to find.
Just inform the user about this condition once and let it through
afterward.
Fixes: a60ccade88f9 ("drm/vmwgfx: Fix crtc's atomic check conditional")
Cc: stable@vger.kernel.org
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261029215540.3008997-1-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -155,9 +155,8 @@ int vmw_du_crtc_atomic_check(struct drm_
* some actual rendering so give a clue as why it's blank.
*/
if (new_state->enable && !has_primary)
- drm_dbg_driver(&vmw->drm,
- "CRTC without a primary plane will be blank.\n");
-
+ drm_info_once(&vmw->drm,
+ "CRTC without a primary plane will be blank.\n");
if (new_state->connector_mask != connector_mask &&
new_state->connector_mask != 0) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 416/742] drm/vmwgfx: log MOB limits outside the manager spinlock
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (406 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 415/742] drm/vmwgfx: log missing primary planes only once Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 417/742] drm/vmwgfx: reserve cursor MOBs before unpinning them Greg Kroah-Hartman
` (318 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit eee4285a8c3c918bbd21791e17f2bb261a709792 upstream.
vmw_gmrid_man_get_node reports MOB limit expansion and allocation
failures through vmw_host_printf while holding gman->lock. The helper
formats its messages with GFP_KERNEL allocations, which may sleep.
KDE startup and desktop mode changes can reach this path, producing
"BUG: sleeping function called from invalid context" from kvasprintf()
while the manager spinlock is held. That's likely a separate bug
because KDE shouldn't be using that much memory but to debug
that properly stop filling kernel logs with warnings.
Defer both host messages until after dropping the spinlock. Capture the
failed allocation's page limit and roll back its accounting while locked,
then report the error and free the resource after unlocking. Use
drm_warn for the guest messages so they identify the device.
Fixes: cfdc3458db8a ("drm/vmwgfx: Be a lot more flexible with MOB limits")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261029215700.3009996-1-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 55 ++++++++++++++++----------
1 file changed, 34 insertions(+), 21 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -54,8 +54,11 @@ static int vmw_gmrid_man_get_node(struct
const struct ttm_place *place,
struct ttm_resource **res)
{
+ struct vmw_private *vmw = vmw_priv_from_ttm(bo->bdev);
struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man);
- int id;
+ u32 max_gmr_pages = 0;
+ bool mob_overflow = false;
+ int id, ret = 0;
*res = kmalloc_obj(**res);
if (!*res)
@@ -85,43 +88,53 @@ static int vmw_gmrid_man_get_node(struct
const unsigned long max_graphics_pages = totalram_pages() / 2;
uint32_t new_max_pages = 0;
- DRM_WARN("vmwgfx: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n");
- vmw_host_printf("vmwgfx, warning: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n");
+ mob_overflow = true;
+ drm_warn(&vmw->drm,
+ "vmwgfx: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n");
if (gman->max_gmr_pages > (max_graphics_pages / 2)) {
- DRM_WARN("vmwgfx: guest requires more than half of RAM for graphics.\n");
+ drm_warn(&vmw->drm,
+ "vmwgfx: guest requires more than half of RAM for graphics.\n");
new_max_pages = max_graphics_pages;
} else
new_max_pages = gman->max_gmr_pages * 2;
if (new_max_pages > gman->max_gmr_pages && new_max_pages >= gman->used_gmr_pages) {
- DRM_WARN("vmwgfx: increasing guest mob limits to %u KiB.\n",
- ((new_max_pages) << (PAGE_SHIFT - 10)));
+ drm_warn(&vmw->drm,
+ "vmwgfx: increasing guest mob limits to %u KiB.\n",
+ new_max_pages << (PAGE_SHIFT - 10));
gman->max_gmr_pages = new_max_pages;
} else {
- char buf[256];
- snprintf(buf, sizeof(buf),
- "vmwgfx, error: guest graphics is out of memory (mob limit at: %u KiB).\n",
- ((gman->max_gmr_pages) << (PAGE_SHIFT - 10)));
- vmw_host_printf(buf);
- DRM_WARN("%s", buf);
- goto nospace;
+ max_gmr_pages = gman->max_gmr_pages;
+ gman->used_gmr_pages -= PFN_UP((*res)->size);
+ ret = -ENOSPC;
+ goto out_unlock;
}
}
}
(*res)->start = id;
+out_unlock:
spin_unlock(&gman->lock);
- return 0;
-nospace:
- gman->used_gmr_pages -= PFN_UP((*res)->size);
- spin_unlock(&gman->lock);
- ida_free(&gman->gmr_ida, id);
- ttm_resource_fini(man, *res);
- kfree(*res);
- return -ENOSPC;
+ /* Host logging allocates with GFP_KERNEL and must run unlocked. */
+ if (mob_overflow)
+ vmw_host_printf("%s",
+ "vmwgfx, warning: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n");
+ if (ret) {
+ char buf[256];
+
+ snprintf(buf, sizeof(buf),
+ "vmwgfx, error: guest graphics is out of memory (mob limit at: %u KiB).\n",
+ max_gmr_pages << (PAGE_SHIFT - 10));
+ vmw_host_printf("%s", buf);
+ drm_warn(&vmw->drm, "%s", buf);
+ ida_free(&gman->gmr_ida, id);
+ ttm_resource_fini(man, *res);
+ kfree(*res);
+ }
+ return ret;
}
static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 417/742] drm/vmwgfx: reserve cursor MOBs before unpinning them
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (407 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 416/742] drm/vmwgfx: log MOB limits outside the manager spinlock Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 418/742] drm/vmwgfx: reserve dumb buffers while detaching their surfaces Greg Kroah-Hartman
` (317 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala,
fausten
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit 8a9b3b4c3a6cc95ea959183e20871d2421a6b986 upstream.
vmw_cursor_mob_destroy() unpins cursor MOBs when discarding an image from
the plane's cache or destroying the cursor plane. It calls ttm_bo_unpin()
without reserving the BO, although TTM requires its reservation to be held
when changing pin counts and LRU membership.
KMS clients issuing repeated nonblocking cursor updates can exhaust the
cache and reach this path. On a lockdep-enabled kernel this triggers
reservation assertions in ttm_bo_unpin() and ttm_resource_unevictable().
Reserve the MOB around ttm_bo_unpin(), then release the reservation before
dropping the BO reference.
Fixes: 485d98d472d5 ("drm/vmwgfx: Add support for CursorMob and CursorBypass 4")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Tested-by: fausten <yunfeng.li.nb@gmail.com>
Link: https://patch.msgid.link/20261027211729.646988-7-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
@@ -150,10 +150,17 @@ static u32 vmw_cursor_mob_size(enum vmw_
static void vmw_cursor_mob_destroy(struct vmw_bo **vbo)
{
+ int ret;
+
if (!(*vbo))
return;
+ ret = ttm_bo_reserve(&(*vbo)->tbo, false, false, NULL);
+ if (WARN_ON_ONCE(ret))
+ return;
+
ttm_bo_unpin(&(*vbo)->tbo);
+ ttm_bo_unreserve(&(*vbo)->tbo);
vmw_bo_unreference(vbo);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 418/742] drm/vmwgfx: reserve dumb buffers while detaching their surfaces
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (408 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 417/742] drm/vmwgfx: reserve cursor MOBs before unpinning them Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 419/742] drm/vmwgfx: return an error when a shared GB surface has no backup buffer Greg Kroah-Hartman
` (316 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala,
fausten
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit 13e766130673ec3b9df8b72ff1dbe6826cac1dfe upstream.
vmw_bo_free() detaches the surface associated with a dumb buffer and
clears its guest memory binding. It reserves the resource, but does not
hold the buffer reservation required by vmw_resource_mob_detach(). TTM
releases that reservation before invoking the buffer destructor.
KMS clients destroying dumb buffers can therefore trigger the reservation
assertion from vmw_resource_mob_detach(). GNOME reaches this path through
DRM_IOCTL_MODE_DESTROY_DUMB during cursor and display updates.
Reacquire the buffer reservation while detaching the surface and clearing
its dirty tracking and guest memory binding. Acquire it after
cmdbuf_mutex, following the command validation lock order, and release it
before releasing the resource and GEM object.
Fixes: d6667f0ddf46 ("drm/vmwgfx: Fix handling of dumb buffers")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Tested-by: fausten <yunfeng.li.nb@gmail.com>
Link: https://patch.msgid.link/20261027211729.646988-5-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
@@ -55,6 +55,8 @@ static void vmw_bo_free(struct ttm_buffe
/* Reserve and switch the backing mob. */
mutex_lock(&res->dev_priv->cmdbuf_mutex);
(void)vmw_resource_reserve(res, false, true);
+ /* TTM drops the reservation before calling the destructor. */
+ dma_resv_lock(bo->base.resv, NULL);
vmw_resource_mob_detach(res);
if (res->dirty)
res->func->dirty_free(res);
@@ -62,6 +64,7 @@ static void vmw_bo_free(struct ttm_buffe
vmw_bo_dirty_release(res->guest_memory_bo);
res->guest_memory_bo = NULL;
res->guest_memory_offset = 0;
+ dma_resv_unlock(bo->base.resv);
vmw_resource_unreserve(res, true, false, false, NULL,
0);
mutex_unlock(&res->dev_priv->cmdbuf_mutex);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 419/742] drm/vmwgfx: return an error when a shared GB surface has no backup buffer
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (409 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 418/742] drm/vmwgfx: reserve dumb buffers while detaching their surfaces Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 420/742] drm/vmwgfx: validate backup buffer size in command buffer processing Greg Kroah-Hartman
` (315 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Aldo Ariel Panzardo
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
commit 3a2f97af36754b64083d463a4cee0af26826bec8 upstream.
vmw_gb_surface_reference_internal() rejects a surface that has no backup
buffer by logging an error and jumping to out_bad_resource, but it never
sets ret on that path. ret is still 0 from the earlier successful
vmw_surface_handle_reference(), so the ioctl returns success while
leaving the reply structure unfilled — user space is handed a
"successful" reply that was never produced. DRM_VMW_GB_SURFACE_REF is
DRM_RENDER_ALLOW, so an unprivileged local user can reach it.
Set ret to -EINVAL and, on the error paths, drop the reference that
vmw_surface_handle_reference() took; once the ioctl fails user space no
longer releases it via DRM_VMW_UNREF_SURFACE. The unref is guarded by
ret so the shared success fall-through keeps the reference the caller
still owns, and it also plugs the same leak on the drm_gem_handle_create()
failure path.
Fixes: 14b1c33e8429 ("drm/vmwgfx: Add new ioctl for GB surface create and reference")
Cc: stable@vger.kernel.org
Suggested-by: Zack Rusin <zack.rusin@broadcom.com>
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
[zack: aligned a continuation line with the open parenthesis]
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20261007212051.2574235-2-qwe.aldo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -1720,6 +1720,7 @@ vmw_gb_surface_reference_internal(struct
srf = &user_srf->srf;
if (!srf->res.guest_memory_bo) {
DRM_ERROR("Shared GB surface is missing a backup buffer.\n");
+ ret = -EINVAL;
goto out_bad_resource;
}
metadata = &srf->metadata;
@@ -1758,6 +1759,9 @@ vmw_gb_surface_reference_internal(struct
rep->creq.must_be_zero = 0;
out_bad_resource:
+ if (ret)
+ ttm_ref_object_base_unref(vmw_fpriv(file_priv)->tfile,
+ base->handle);
ttm_base_object_unref(&base);
return ret;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 420/742] drm/vmwgfx: validate backup buffer size in command buffer processing
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (410 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 419/742] drm/vmwgfx: return an error when a shared GB surface has no backup buffer Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 421/742] drm/vmwgfx: validate command body sizes before parsing Greg Kroah-Hartman
` (314 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zack Rusin, Ian Forbes,
Zero Day Initiative
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit c1e6267b9dd3e04f9dc29e500414cc4fc237dec1 upstream.
vmw_cmd_res_switch_backup lets userspace bind an arbitrary MOB to a
resource without checking that the MOB is large enough for the resource's
guest_memory_size. The dirty-tracking bitmap is allocated based on the
MOB size, but later accessed using the (larger) surface size, causing an
out-of-bounds write in the bitmap that corrupts adjacent slab memory.
Add a check that backup_offset + res->guest_memory_size does not exceed
the buffer size before allowing the backup switch.
DX shaders and stream outputs never set guest_memory_size, and both were
allocated with kmalloc(), so the check would read uninitialized memory for
SVGA_3D_CMD_DX_BIND_SHADER and SVGA_3D_CMD_DX_BIND_STREAMOUTPUT and could
reject valid binds. Allocate both with kzalloc() so their
guest_memory_size is 0 and the check only bounds the offset.
Fixes: a97e21923b42 ("drm/vmwgfx: Hook up guest-backed surfaces")
Cc: stable@vger.kernel.org
Reported-by: Zero Day Initiative <zdi-disclosures@trendmicro.com> # ZDI-CAN-34068
Closes: https://lore.kernel.org/all/BYAPR01MB38301CFC012E873340F77E3D80662@BYAPR01MB3830.prod.exchangelabs.com/
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Ian Forbes <ian.forbes@broadcom.com>
Link: https://patch.msgid.link/20261027031533.2241918-1-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 8 ++++++++
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 2 +-
drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c | 2 +-
3 files changed, 10 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -1718,6 +1718,7 @@ static int vmw_cmd_res_switch_backup(str
{
struct vmw_bo *vbo;
void *info;
+ u64 end;
int ret;
info = vmw_execbuf_info_from_res(sw_context, res);
@@ -1728,6 +1729,13 @@ static int vmw_cmd_res_switch_backup(str
if (ret)
return ret;
+ if (check_add_overflow((u64)backup_offset,
+ (u64)res->guest_memory_size, &end) ||
+ end > vbo->tbo.base.size) {
+ VMW_DEBUG_USER("Backup buffer too small for resource.\n");
+ return -EINVAL;
+ }
+
vmw_validation_res_switch_backup(sw_context->ctx, info, vbo,
backup_offset);
return 0;
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
@@ -597,7 +597,7 @@ int vmw_dx_shader_add(struct vmw_cmdbuf_
if (!vmw_shader_id_ok(user_key, shader_type))
return -EINVAL;
- shader = kmalloc_obj(*shader);
+ shader = kzalloc_obj(*shader);
if (!shader) {
return -ENOMEM;
}
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c
@@ -284,7 +284,7 @@ int vmw_dx_streamoutput_add(struct vmw_c
struct vmw_private *dev_priv = ctx->dev_priv;
int ret;
- so = kmalloc_obj(*so);
+ so = kzalloc_obj(*so);
if (!so) {
return -ENOMEM;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 421/742] drm/vmwgfx: validate command body sizes before parsing
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (411 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 420/742] drm/vmwgfx: validate backup buffer size in command buffer processing Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 422/742] drm/vmwgfx: validate GB-only cursor command limits Greg Kroah-Hartman
` (313 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit 06069d6d650dbef746eb933e2f4fbfc686b6d330 upstream.
vmw_cmd_check verifies that a command's declared size fits in the
submitted buffer, but handlers can access fields beyond the declared
body. A truncated body can therefore cause relocations to target the
next command. Applying those relocations after validation can change
an already validated command ID and bypass command restrictions.
Legacy query conversion can also overwrite the next command, while
texture-state parsing can access fields beyond a truncated final record.
Check each handler's minimum body size before accessing command fields.
Use the common prefix for shared handlers to preserve shorter command
variants, and reject texture-state arrays containing incomplete records.
Fixes: fb1d9738ca05 ("drm/vmwgfx: Add DRM driver for VMware Virtual GPU")
Cc: stable@vger.kernel.org
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261111193836.3161904-1-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 200 ++++++++++++++++++++++++++++++++
1 file changed, 200 insertions(+)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -565,6 +565,29 @@ static int vmw_cmd_ok(struct vmw_private
}
/**
+ * vmw_cmd_body_fits - Check that a command body covers what a handler reads
+ *
+ * @header: Pointer to the command header in the command stream.
+ * @size: Number of body bytes that the command handler interprets.
+ *
+ * vmw_cmd_check() only verifies that @header->size fits into the submitted
+ * command buffer. A handler that reads past the declared body reads the next
+ * command, which is verified separately. A relocation recorded there would
+ * rewrite the already verified command after verification has finished.
+ *
+ * Return: true if the body is at least @size bytes, false otherwise.
+ */
+static bool vmw_cmd_body_fits(const SVGA3dCmdHeader *header, size_t size)
+{
+ if (likely(header->size >= size))
+ return true;
+
+ VMW_DEBUG_USER("SVGA3D command %u: body size %u is smaller than %zu.\n",
+ header->id, header->size, size);
+ return false;
+}
+
+/**
* vmw_resources_reserve - Reserve all resources on the sw_context's resource
* list.
*
@@ -810,6 +833,9 @@ static int vmw_cmd_cid_check(struct vmw_
VMW_DECLARE_CMD_VAR(*cmd, uint32_t) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
VMW_RES_DIRTY_SET, user_context_converter,
&cmd->body, NULL);
@@ -853,6 +879,8 @@ static int vmw_cmd_set_render_target_che
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
if (cmd->body.type >= SVGA3D_RT_MAX) {
VMW_DEBUG_USER("Illegal render target type %u.\n",
@@ -898,6 +926,8 @@ static int vmw_cmd_surface_copy_check(st
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
@@ -918,6 +948,9 @@ static int vmw_cmd_buffer_copy_check(str
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.src, NULL);
@@ -937,6 +970,9 @@ static int vmw_cmd_pred_copy_check(struc
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.srcSid, NULL);
@@ -956,6 +992,9 @@ static int vmw_cmd_stretch_blt_check(str
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.src.sid, NULL);
@@ -974,6 +1013,9 @@ static int vmw_cmd_blt_surf_screen_check
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBlitSurfaceToScreen) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.srcImage.sid, NULL);
@@ -986,6 +1028,9 @@ static int vmw_cmd_present_check(struct
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdPresent) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.sid, NULL);
@@ -1243,6 +1288,8 @@ static int vmw_cmd_dx_define_query(struc
return -EINVAL;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
if (cmd->body.type < SVGA3D_QUERYTYPE_MIN ||
cmd->body.type >= SVGA3D_QUERYTYPE_MAX)
@@ -1280,6 +1327,8 @@ static int vmw_cmd_dx_bind_query(struct
return -EINVAL;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
/*
* Look up the buffer pointed to by q.mobid, put it on the relocation
@@ -1310,6 +1359,9 @@ static int vmw_cmd_begin_gb_query(struct
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBeginGBQuery) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
VMW_RES_DIRTY_SET, user_context_converter,
&cmd->body.cid, NULL);
@@ -1329,6 +1381,9 @@ static int vmw_cmd_begin_query(struct vm
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBeginQuery) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (unlikely(dev_priv->has_mob)) {
VMW_DECLARE_CMD_VAR(gb_cmd, SVGA3dCmdBeginGBQuery);
@@ -1364,6 +1419,9 @@ static int vmw_cmd_end_gb_query(struct v
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
ret = vmw_cmd_cid_check(dev_priv, sw_context, header);
if (unlikely(ret != 0))
return ret;
@@ -1394,6 +1452,9 @@ static int vmw_cmd_end_query(struct vmw_
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (dev_priv->has_mob) {
VMW_DECLARE_CMD_VAR(gb_cmd, SVGA3dCmdEndGBQuery);
@@ -1440,6 +1501,9 @@ static int vmw_cmd_wait_gb_query(struct
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
ret = vmw_cmd_cid_check(dev_priv, sw_context, header);
if (unlikely(ret != 0))
return ret;
@@ -1468,6 +1532,9 @@ static int vmw_cmd_wait_query(struct vmw
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (dev_priv->has_mob) {
VMW_DECLARE_CMD_VAR(gb_cmd, SVGA3dCmdWaitForGBQuery);
@@ -1637,6 +1704,15 @@ static int vmw_cmd_tex_state(struct vmw_
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
+ /* The loop below must not read a truncated trailing state. */
+ if ((header->size - sizeof(cmd->body)) % sizeof(*cur_state)) {
+ VMW_DEBUG_USER("Invalid texture state size %u.\n",
+ header->size);
+ return -EINVAL;
+ }
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
VMW_RES_DIRTY_SET, user_context_converter,
@@ -1790,6 +1866,9 @@ static int vmw_cmd_bind_gb_surface(struc
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBindGBSurface) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_switch_backup(dev_priv, sw_context, vmw_res_surface,
user_surface_converter, &cmd->body.sid,
&cmd->body.mobid, 0);
@@ -1809,6 +1888,9 @@ static int vmw_cmd_update_gb_image(struc
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdUpdateGBImage) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.image.sid, NULL);
@@ -1828,6 +1910,9 @@ static int vmw_cmd_update_gb_surface(str
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdUpdateGBSurface) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_CLEAR, user_surface_converter,
&cmd->body.sid, NULL);
@@ -1847,6 +1932,9 @@ static int vmw_cmd_readback_gb_image(str
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdReadbackGBImage) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.image.sid, NULL);
@@ -1867,6 +1955,9 @@ static int vmw_cmd_readback_gb_surface(s
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdReadbackGBSurface) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_CLEAR, user_surface_converter,
&cmd->body.sid, NULL);
@@ -1887,6 +1978,9 @@ static int vmw_cmd_invalidate_gb_image(s
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdInvalidateGBImage) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.image.sid, NULL);
@@ -1907,6 +2001,9 @@ static int vmw_cmd_invalidate_gb_surface
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdInvalidateGBSurface) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_CLEAR, user_surface_converter,
&cmd->body.sid, NULL);
@@ -1929,6 +2026,8 @@ static int vmw_cmd_shader_define(struct
struct vmw_resource *ctx;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
VMW_RES_DIRTY_SET, user_context_converter,
@@ -1968,6 +2067,8 @@ static int vmw_cmd_shader_destroy(struct
struct vmw_resource *ctx;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
VMW_RES_DIRTY_SET, user_context_converter,
@@ -2007,6 +2108,8 @@ static int vmw_cmd_set_shader(struct vmw
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
if (!vmw_shadertype_is_valid(VMW_SM_LEGACY, cmd->body.type)) {
VMW_DEBUG_USER("Illegal shader type %u.\n",
@@ -2085,6 +2188,8 @@ static int vmw_cmd_set_shader_const(stru
int ret;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
VMW_RES_DIRTY_SET, user_context_converter,
@@ -2112,6 +2217,9 @@ static int vmw_cmd_bind_gb_shader(struct
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdBindGBShader) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
return vmw_cmd_switch_backup(dev_priv, sw_context, vmw_res_shader,
user_shader_converter, &cmd->body.shid,
&cmd->body.mobid, cmd->body.offsetInBytes);
@@ -2141,6 +2249,9 @@ vmw_cmd_dx_set_single_constant_buffer(st
return -EINVAL;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.sid, &res);
@@ -2194,6 +2305,9 @@ vmw_cmd_dx_set_constant_buffer_offset(st
return -EINVAL;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (cmd->body.slot >= SVGA3D_DX_MAX_CONSTBUFFERS) {
VMW_DEBUG_USER("Illegal const buffer slot %u.\n",
(unsigned int) cmd->body.slot);
@@ -2225,6 +2339,9 @@ static int vmw_cmd_dx_set_shader_res(str
u32 num_sr_view = (cmd->header.size - sizeof(cmd->body)) /
sizeof(SVGA3dShaderResourceViewId);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if ((u64) cmd->body.startView + (u64) num_sr_view >
(u64) SVGA3D_DX_MAX_SRVIEWS ||
!vmw_shadertype_is_valid(dev_priv->sm_type, cmd->body.type)) {
@@ -2260,6 +2377,8 @@ static int vmw_cmd_dx_set_shader(struct
return -EINVAL;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
if (!vmw_shadertype_is_valid(dev_priv->sm_type, cmd->body.type)) {
VMW_DEBUG_USER("Illegal shader type %u.\n",
@@ -2317,6 +2436,9 @@ static int vmw_cmd_dx_set_vertex_buffers
return -EINVAL;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
num = (cmd->header.size - sizeof(cmd->body)) /
sizeof(SVGA3dVertexBuffer);
if ((u64)num + (u64)cmd->body.startBuffer >
@@ -2368,6 +2490,9 @@ static int vmw_cmd_dx_set_index_buffer(s
return -EINVAL;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.sid, &res);
@@ -2403,6 +2528,9 @@ static int vmw_cmd_dx_set_rendertargets(
sizeof(SVGA3dRenderTargetViewId);
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (num_rt_view > SVGA3D_DX_MAX_RENDER_TARGETS) {
VMW_DEBUG_USER("Invalid DX Rendertarget binding.\n");
return -EINVAL;
@@ -2434,6 +2562,9 @@ static int vmw_cmd_dx_clear_rendertarget
container_of(header, typeof(*cmd), header);
struct vmw_resource *ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
ret = vmw_view_id_val_add(sw_context, vmw_view_rt,
cmd->body.renderTargetViewId);
@@ -2456,6 +2587,9 @@ static int vmw_cmd_dx_clear_depthstencil
container_of(header, typeof(*cmd), header);
struct vmw_resource *ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
ret = vmw_view_id_val_add(sw_context, vmw_view_ds,
cmd->body.depthStencilViewId);
@@ -2489,6 +2623,9 @@ static int vmw_cmd_dx_view_define(struct
return -EINVAL;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(*cmd) - sizeof(*header)))
+ return -EINVAL;
+
if (unlikely(cmd->sid == SVGA3D_INVALID_ID)) {
VMW_DEBUG_USER("Invalid surface id.\n");
return -EINVAL;
@@ -2537,6 +2674,9 @@ static int vmw_cmd_dx_set_so_targets(str
return -EINVAL;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
num = (cmd->header.size - sizeof(cmd->body)) / sizeof(SVGA3dSoTarget);
if (num > SVGA3D_DX_MAX_SOTARGETS) {
@@ -2590,6 +2730,9 @@ static int vmw_cmd_dx_so_define(struct v
if (IS_ERR_OR_NULL(res))
return res ? PTR_ERR(res) : -EINVAL;
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(*cmd) - sizeof(*header)))
+ return -EINVAL;
+
ret = vmw_cotable_notify(res, cmd->defined_id);
return ret;
@@ -2625,6 +2768,9 @@ static int vmw_cmd_dx_check_subresource(
offsetof(typeof(*cmd), sid));
cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->sid)))
+ return -EINVAL;
+
return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->sid, NULL);
@@ -2666,6 +2812,9 @@ static int vmw_cmd_dx_view_remove(struct
struct vmw_resource *view;
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!ctx_node)
return -EINVAL;
@@ -2703,6 +2852,9 @@ static int vmw_cmd_dx_define_shader(stru
container_of(header, typeof(*cmd), header);
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!ctx_node)
return -EINVAL;
@@ -2734,6 +2886,9 @@ static int vmw_cmd_dx_destroy_shader(str
container_of(header, typeof(*cmd), header);
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!ctx_node)
return -EINVAL;
@@ -2760,6 +2915,9 @@ static int vmw_cmd_dx_bind_shader(struct
container_of(header, typeof(*cmd), header);
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (cmd->body.cid != SVGA3D_INVALID_ID) {
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context,
VMW_RES_DIRTY_SET,
@@ -2811,6 +2969,9 @@ static int vmw_cmd_dx_genmips(struct vmw
struct vmw_resource *view;
struct vmw_res_cache_entry *rcache;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
view = vmw_view_id_val_add(sw_context, vmw_view_sr,
cmd->body.shaderResourceViewId);
if (IS_ERR(view))
@@ -2844,6 +3005,9 @@ static int vmw_cmd_dx_transfer_from_buff
container_of(header, typeof(*cmd), header);
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
VMW_RES_DIRTY_NONE, user_surface_converter,
&cmd->body.srcSid, NULL);
@@ -2869,6 +3033,9 @@ static int vmw_cmd_intra_surface_copy(st
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdIntraSurfaceCopy) =
container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!(dev_priv->capabilities2 & SVGA_CAP2_INTRA_SURFACE_COPY))
return -EINVAL;
@@ -2917,6 +3084,9 @@ static int vmw_cmd_clear_uav_uint(struct
} *cmd = container_of(header, typeof(*cmd), header);
struct vmw_resource *ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!has_sm5_context(dev_priv))
return -EINVAL;
@@ -2936,6 +3106,9 @@ static int vmw_cmd_clear_uav_float(struc
} *cmd = container_of(header, typeof(*cmd), header);
struct vmw_resource *ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!has_sm5_context(dev_priv))
return -EINVAL;
@@ -2957,6 +3130,9 @@ static int vmw_cmd_set_uav(struct vmw_pr
sizeof(SVGA3dUAViewId);
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!has_sm5_context(dev_priv))
return -EINVAL;
@@ -2989,6 +3165,9 @@ static int vmw_cmd_set_cs_uav(struct vmw
sizeof(SVGA3dUAViewId);
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!has_sm5_context(dev_priv))
return -EINVAL;
@@ -3021,6 +3200,9 @@ static int vmw_cmd_dx_define_streamoutpu
} *cmd = container_of(header, typeof(*cmd), header);
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!has_sm5_context(dev_priv))
return -EINVAL;
@@ -3052,6 +3234,9 @@ static int vmw_cmd_dx_destroy_streamoutp
SVGA3dCmdDXDestroyStreamOutput body;
} *cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!ctx_node) {
DRM_ERROR("DX Context not set.\n");
return -EINVAL;
@@ -3089,6 +3274,9 @@ static int vmw_cmd_dx_bind_streamoutput(
} *cmd = container_of(header, typeof(*cmd), header);
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!has_sm5_context(dev_priv))
return -EINVAL;
@@ -3131,6 +3319,9 @@ static int vmw_cmd_dx_set_streamoutput(s
} *cmd = container_of(header, typeof(*cmd), header);
int ret;
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!ctx_node) {
DRM_ERROR("DX Context not set.\n");
return -EINVAL;
@@ -3183,6 +3374,9 @@ static int vmw_cmd_indexed_instanced_ind
SVGA3dCmdDXDrawIndexedInstancedIndirect body;
} *cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!has_sm5_context(dev_priv))
return -EINVAL;
@@ -3200,6 +3394,9 @@ static int vmw_cmd_instanced_indirect(st
SVGA3dCmdDXDrawInstancedIndirect body;
} *cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!has_sm5_context(dev_priv))
return -EINVAL;
@@ -3217,6 +3414,9 @@ static int vmw_cmd_dispatch_indirect(str
SVGA3dCmdDXDispatchIndirect body;
} *cmd = container_of(header, typeof(*cmd), header);
+ if (!vmw_cmd_body_fits(header, sizeof(cmd->body)))
+ return -EINVAL;
+
if (!has_sm5_context(dev_priv))
return -EINVAL;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 422/742] drm/vmwgfx: validate GB-only cursor command limits
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (412 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 421/742] drm/vmwgfx: validate command body sizes before parsing Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 423/742] drm/vmwgfx: validate the framebuffer selected for cursor updates Greg Kroah-Hartman
` (312 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Yunfeng Li, Zack Rusin,
Maaz Mombasawala
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit 6baeb251d709d5f31f2a0ae89ca5ca054d0e04e7 upstream.
Guest-backed devices without cursor MOB support define cursor images with
SVGA_CMD_DEFINE_ALPHA_CURSOR. SVGA_REG_CURSOR_MAX_DIMENSION belongs to the
cursor MOB register class and reads as zero on devices that do not expose
that class. Applying this register to GB-only cursors rejects every
nonempty image submitted by KMS clients, leaving Xorg without a hardware
cursor.
The submission transport also limits the command size. A 96x96 image fits
the 40 KiB FIFO image limit, but exceeds the 32 KiB command-buffer limit
and causes a device command error when submitted through that transport.
Validate GB-only images against SVGA_MAX_CURSOR_CMD_DIMENSION and
SVGA_MAX_CURSOR_CMD_BYTES. For command-buffer submission, also bound the
whole command by SVGA_CB_MAX_COMMAND_SIZE, including its header. Calculate
the image byte count in 64 bits and keep the register-based dimension and
MOB size checks for MOB cursors.
Fixes: d5ed8749168a ("drm/vmwgfx: enforce cursor size limits for MOB cursors")
Cc: stable@vger.kernel.org
Reported-by: Yunfeng Li <yunfeng.li.nb@gmail.com>
Closes: https://patch.msgid.link/20260830151619.2452307-1-yunfeng.li.nb@gmail.com
Assisted-by: LLM
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Tested-by: fausten <yunfeng.li.nb@gmail.com>
Link: https://patch.msgid.link/20261027211729.646988-3-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
@@ -785,8 +785,27 @@ int vmw_cursor_plane_atomic_check(struct
"surface not suitable for cursor\n");
return -EINVAL;
}
- } else if (update_type == VMW_CURSOR_UPDATE_GB_ONLY ||
- update_type == VMW_CURSOR_UPDATE_MOB) {
+ } else if (update_type == VMW_CURSOR_UPDATE_GB_ONLY) {
+ u64 image_size = (u64)new_state->crtc_w *
+ new_state->crtc_h * sizeof(u32);
+ u32 max_size = SVGA_MAX_CURSOR_CMD_BYTES;
+
+ /* The command-buffer limit includes the define-cursor header. */
+ if (vmw->cman)
+ max_size = min_t(u32, max_size,
+ SVGA_CB_MAX_COMMAND_SIZE -
+ sizeof(struct vmw_svga_fifo_cmd_define_cursor));
+
+ if (!new_state->crtc_w || !new_state->crtc_h ||
+ new_state->crtc_w > SVGA_MAX_CURSOR_CMD_DIMENSION ||
+ new_state->crtc_h > SVGA_MAX_CURSOR_CMD_DIMENSION ||
+ image_size > max_size) {
+ drm_dbg_kms(&vmw->drm,
+ "Cursor dimensions (%u, %u) violate command limits\n",
+ new_state->crtc_w, new_state->crtc_h);
+ return -EINVAL;
+ }
+ } else if (update_type == VMW_CURSOR_UPDATE_MOB) {
u32 cursor_max_dim =
vmw_read(vmw, SVGA_REG_CURSOR_MAX_DIMENSION);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 423/742] drm/vmwgfx: validate the framebuffer selected for cursor updates
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (413 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 422/742] drm/vmwgfx: validate GB-only cursor command limits Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 424/742] drm/vmwgfx: close TOCTOU on guest_memory_bo in surface reference ioctl Greg Kroah-Hartman
` (311 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zack Rusin, Maaz Mombasawala,
fausten
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <zack.rusin@broadcom.com>
commit d6263d9bfa931dfc7e0dd922a6ee52b5535caa74 upstream.
Cursor atomic checks select an update path and look up surfaces through
vps->uo. That object is copied from the previous plane state and is only
replaced with the new framebuffer's object in prepare_fb(). Switching
between snooped surfaces and buffer objects therefore applies the old
framebuffer's cursor limits to the new image.
KMS clients can also submit a guest-backed surface without a backing BO.
The check accepts it, but the MOB update later copies from a NULL source.
Zero-sized MOB images pass the check as well, then fail preparation when
mapping zero pages, so TEST_ONLY accepts a commit that cannot succeed.
Resolve the user object directly from the selected framebuffer in both
validation and preparation. Apply the matching cursor limits, reject
zero dimensions and require a backing BO for GB-only and MOB images.
Recheck the backing BO in preparation before mapping it, while keeping
snooped surfaces independent of a BO mapping.
Fixes: 965544150d1c ("drm/vmwgfx: Refactor cursor handling")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Tested-by: fausten <yunfeng.li.nb@gmail.com>
Link: https://patch.msgid.link/20261027211729.646988-6-zack.rusin@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c | 59 +++++++++++++++++++--------
1 file changed, 42 insertions(+), 17 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
@@ -89,10 +89,26 @@ vmw_cursor_plane_update_legacy(struct vm
}
}
+static struct vmw_user_object
+vmw_cursor_plane_user_object(struct drm_framebuffer *fb)
+{
+ struct vmw_user_object uo = { 0 };
+
+ if (!fb)
+ return uo;
+
+ if (vmw_framebuffer_to_vfb(fb)->bo)
+ uo.buffer = vmw_framebuffer_to_vfbd(fb)->buffer;
+ else
+ uo = vmw_framebuffer_to_vfbs(fb)->uo;
+
+ return uo;
+}
+
static enum vmw_cursor_update_type
-vmw_cursor_update_type(struct vmw_private *vmw, struct vmw_plane_state *vps)
+vmw_cursor_update_type(struct vmw_private *vmw, struct vmw_user_object *uo)
{
- struct vmw_surface *surface = vmw_user_object_surface(&vps->uo);
+ struct vmw_surface *surface = vmw_user_object_surface(uo);
if (surface && surface->snooper.image)
return VMW_CURSOR_UPDATE_LEGACY;
@@ -649,17 +665,10 @@ int vmw_cursor_plane_prepare_fb(struct d
if (!vmw_user_object_is_null(&vps->uo))
vmw_user_object_unref(&vps->uo);
- if (fb) {
- if (vmw_framebuffer_to_vfb(fb)->bo) {
- vps->uo.buffer = vmw_framebuffer_to_vfbd(fb)->buffer;
- vps->uo.surface = NULL;
- } else {
- memcpy(&vps->uo, &vmw_framebuffer_to_vfbs(fb)->uo, sizeof(vps->uo));
- }
- vmw_user_object_ref(&vps->uo);
- }
+ vps->uo = vmw_cursor_plane_user_object(fb);
+ vmw_user_object_ref(&vps->uo);
- vps->cursor.update_type = vmw_cursor_update_type(vmw, vps);
+ vps->cursor.update_type = vmw_cursor_update_type(vmw, &vps->uo);
switch (vps->cursor.update_type) {
case VMW_CURSOR_UPDATE_LEGACY:
surface = vmw_user_object_surface(&vps->uo);
@@ -669,6 +678,9 @@ int vmw_cursor_plane_prepare_fb(struct d
case VMW_CURSOR_UPDATE_GB_ONLY:
case VMW_CURSOR_UPDATE_MOB: {
bo = vmw_user_object_buffer(&vps->uo);
+ if (fb && !bo)
+ return -EINVAL;
+
if (bo) {
struct ttm_operation_ctx ctx = { false, false };
size_t size = (size_t)new_state->crtc_w *
@@ -751,7 +763,7 @@ int vmw_cursor_plane_atomic_check(struct
int ret = 0;
struct drm_crtc_state *crtc_state = NULL;
struct vmw_surface *surface = NULL;
- struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state);
+ struct vmw_user_object uo;
enum vmw_cursor_update_type update_type;
struct drm_framebuffer *fb = new_state->fb;
@@ -770,7 +782,21 @@ int vmw_cursor_plane_atomic_check(struct
if (!fb)
return 0;
- update_type = vmw_cursor_update_type(vmw, vps);
+ if (!new_state->crtc_w || !new_state->crtc_h) {
+ drm_dbg_kms(&vmw->drm,
+ "Cursor dimensions (%u, %u) must be nonzero\n",
+ new_state->crtc_w, new_state->crtc_h);
+ return -EINVAL;
+ }
+
+ /* The duplicated plane state's user object still belongs to the old FB. */
+ uo = vmw_cursor_plane_user_object(fb);
+ update_type = vmw_cursor_update_type(vmw, &uo);
+ if ((update_type == VMW_CURSOR_UPDATE_GB_ONLY ||
+ update_type == VMW_CURSOR_UPDATE_MOB) &&
+ !vmw_user_object_buffer(&uo))
+ return -EINVAL;
+
if (update_type == VMW_CURSOR_UPDATE_LEGACY) {
if (new_state->crtc_w != VMW_CURSOR_SNOOP_WIDTH ||
new_state->crtc_h != VMW_CURSOR_SNOOP_HEIGHT) {
@@ -779,7 +805,7 @@ int vmw_cursor_plane_atomic_check(struct
new_state->crtc_w, new_state->crtc_h);
return -EINVAL;
}
- surface = vmw_user_object_surface(&vps->uo);
+ surface = vmw_user_object_surface(&uo);
if (!surface || !surface->snooper.image) {
drm_warn(&vmw->drm,
"surface not suitable for cursor\n");
@@ -796,8 +822,7 @@ int vmw_cursor_plane_atomic_check(struct
SVGA_CB_MAX_COMMAND_SIZE -
sizeof(struct vmw_svga_fifo_cmd_define_cursor));
- if (!new_state->crtc_w || !new_state->crtc_h ||
- new_state->crtc_w > SVGA_MAX_CURSOR_CMD_DIMENSION ||
+ if (new_state->crtc_w > SVGA_MAX_CURSOR_CMD_DIMENSION ||
new_state->crtc_h > SVGA_MAX_CURSOR_CMD_DIMENSION ||
image_size > max_size) {
drm_dbg_kms(&vmw->drm,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 424/742] drm/vmwgfx: close TOCTOU on guest_memory_bo in surface reference ioctl
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (414 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 423/742] drm/vmwgfx: validate the framebuffer selected for cursor updates Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 425/742] ALSA: hda/realtek: Fix regression on Lenovo Legion 16IRX9H Greg Kroah-Hartman
` (310 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Aldo Ariel Panzardo,
Zack Rusin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
commit 30131b82b062180183a09a97183a944fadab72ee upstream.
vmw_gb_surface_reference_internal() checks srf->res.guest_memory_bo
for NULL and reads its vma_node offset and base.size outside the
cmdbuf_mutex scope that protects the backup pointer.
A concurrent backup switch, e.g. from SVGA_3D_CMD_BIND_GB_SURFACE
via vmw_resource_unreserve(), drops its reference to the old buffer
and installs a new one under cmdbuf_mutex. The unlocked check in
the surface reference ioctl can see a transient NULL. The reads
after the unlock can return another buffer's offset and size; a
further switch can drop that buffer's last reference and free it
while the ioctl reads from it.
Move the NULL check inside the mutex, and read buffer_map_handle
and buffer_size while still holding it.
Fixes: a97e21923b42 ("drm/vmwgfx: Hook up guest-backed surfaces")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/r/20260808233347.209DD1F000E9@smtp.kernel.org
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Link: https://patch.msgid.link/20261007212051.2574235-3-qwe.aldo@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -1718,23 +1718,32 @@ vmw_gb_surface_reference_internal(struct
user_srf = container_of(base, struct vmw_user_surface, prime.base);
srf = &user_srf->srf;
+ metadata = &srf->metadata;
+
+ mutex_lock(&dev_priv->cmdbuf_mutex);
+
if (!srf->res.guest_memory_bo) {
+ mutex_unlock(&dev_priv->cmdbuf_mutex);
DRM_ERROR("Shared GB surface is missing a backup buffer.\n");
ret = -EINVAL;
goto out_bad_resource;
}
- metadata = &srf->metadata;
- mutex_lock(&dev_priv->cmdbuf_mutex); /* Protect res->backup */
ret = drm_gem_handle_create(file_priv, &srf->res.guest_memory_bo->tbo.base,
&backup_handle);
- mutex_unlock(&dev_priv->cmdbuf_mutex);
if (ret != 0) {
+ mutex_unlock(&dev_priv->cmdbuf_mutex);
drm_err(dev, "Wasn't able to create a backing handle for surface sid = %u.\n",
req->sid);
goto out_bad_resource;
}
+ rep->crep.buffer_map_handle =
+ drm_vma_node_offset_addr(&srf->res.guest_memory_bo->tbo.base.vma_node);
+ rep->crep.buffer_size = srf->res.guest_memory_bo->tbo.base.size;
+
+ mutex_unlock(&dev_priv->cmdbuf_mutex);
+
rep->creq.base.svga3d_flags = SVGA3D_FLAGS_LOWER_32(metadata->flags);
rep->creq.base.format = metadata->format;
rep->creq.base.mip_levels = metadata->mip_levels[0];
@@ -1747,9 +1756,6 @@ vmw_gb_surface_reference_internal(struct
rep->crep.handle = user_srf->prime.base.handle;
rep->crep.backup_size = srf->res.guest_memory_size;
rep->crep.buffer_handle = backup_handle;
- rep->crep.buffer_map_handle =
- drm_vma_node_offset_addr(&srf->res.guest_memory_bo->tbo.base.vma_node);
- rep->crep.buffer_size = srf->res.guest_memory_bo->tbo.base.size;
rep->creq.version = drm_vmw_gb_surface_v1;
rep->creq.svga3d_flags_upper_32_bits =
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 425/742] ALSA: hda/realtek: Fix regression on Lenovo Legion 16IRX9H
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (415 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 424/742] drm/vmwgfx: close TOCTOU on guest_memory_bo in surface reference ioctl Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 426/742] ALSA: pcm: oss: Restore params flag after failed reconfiguration Greg Kroah-Hartman
` (309 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <tiwai@suse.de>
commit 0b4d69e8d2b53907ea8640bf7aa8543ae9e7a0c0 upstream.
Lenovo Legion 16IRX9H has the very same PCI SSID (17aa:3842) as the
recently added quirk for Lenovo Thinkpad X G2 IAH, but it needs a
different qurik. Although the quirk for Legion 16IRX9H is present,
it's not applied because the PCI SSID 17aa:3842 matches at first and
the new quirk for Thinkpad X G2 is taken instead.
As a workaround, put the codec SSID matching (17aa:38cd) for Legion
before the conflicting PCI SSID quirk entry.
Fixes: f2293e7b2ddd ("ALSA: hda/realtek: Enable all four speaker amps on Lenovo ThinkBook X G2 IAH")
Cc: <stable@vger.kernel.org>
Closes: https://lore.kernel.org/CAFjFWEjt+DPJ_gM1uTBZ_NoV6-3mi57ArjZ_Qdah2DqY-GCD1w@mail.gmail.com
Link: https://patch.msgid.link/20261118125024.1900126-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/hda/codecs/realtek/alc269.c | 2 ++
1 file changed, 2 insertions(+)
--- a/sound/hda/codecs/realtek/alc269.c
+++ b/sound/hda/codecs/realtek/alc269.c
@@ -8344,6 +8344,8 @@ static const struct hda_quirk alc269_fix
SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF),
SND_PCI_QUIRK(0x17aa, 0x3834, "Lenovo IdeaPad Slim 9i 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
SND_PCI_QUIRK(0x17aa, 0x383d, "Legion Y9000X 2019", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),
+ /* Legion 16IRX9H shares PCI SSID 17aa:3842 with Thinkpad X G2 below */
+ HDA_CODEC_QUIRK(0x17aa, 0x38cd, "Lenovo Legion 16IRX9H", ALC287_FIXUP_TAS2781_I2C),
SND_PCI_QUIRK(0x17aa, 0x3842, "ThinkBook X G2 IAH", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_4_THINKPAD),
SND_PCI_QUIRK(0x17aa, 0x3843, "Lenovo Yoga 9i / Yoga Book 9i", ALC287_FIXUP_LENOVO_YOGA_BOOK_9I),
/* Yoga Pro 7 14IMH9 shares PCI SSID 17aa:3847 with Legion 7 16ACHG6;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 426/742] ALSA: pcm: oss: Restore params flag after failed reconfiguration
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (416 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 425/742] ALSA: hda/realtek: Fix regression on Lenovo Legion 16IRX9H Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 427/742] ALSA: usb-audio: Add always_set_rate quirk for Yamaha MODX M Greg Kroah-Hartman
` (308 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ye Weihua, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Weihua <yeweihua4@huawei.com>
commit bc3d6817c5325e76578cdd75e9c08bdadc5f73c4 upstream.
snd_pcm_runtime_buffer_set_silence() may fail with -EBUSY when a
concurrent PCM transfer is accessing the buffer. The error path
releases runtime->oss.buffer and clears the plugins, but leaves
runtime->oss.params cleared as well. A subsequent small read/write
then skips the reconfiguration and dereferences the released buffer:
Unable to handle kernel NULL pointer dereference at virtual address
0000000000000000
pc : __arch_copy_from_user+0x78/0x23c
lr : snd_pcm_oss_write+0x10c/0x340 [snd_pcm_oss]
Restore runtime->oss.params on the error path so that the next OSS
operation reconfigures and reallocates the buffer.
Fixes: 47c27c9c9c72 ("ALSA: pcm: Improve the fix for race of buffer access at PCM OSS layer")
Cc: stable@vger.kernel.org
Signed-off-by: Ye Weihua <yeweihua4@huawei.com>
Link: https://patch.msgid.link/20261116064850.3540576-1-yeweihua4@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/core/oss/pcm_oss.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -1084,8 +1084,10 @@ static int snd_pcm_oss_change_params_loc
err = 0;
failure:
- if (err)
+ if (err) {
+ runtime->oss.params = 1;
snd_pcm_oss_release_buffers(substream);
+ }
kfree(sw_params);
kfree(params);
kfree(sparams);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 427/742] ALSA: usb-audio: Add always_set_rate quirk for Yamaha MODX M
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (417 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 426/742] ALSA: pcm: oss: Restore params flag after failed reconfiguration Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 428/742] ACPI: CPPC: Reject EPP registers narrower than 8 bits Greg Kroah-Hartman
` (307 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Frank Slotta, Geoffrey D. Bennett,
Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geoffrey D. Bennett <g@b4.vu>
commit dd763c9a7d8ccd6b281e565187017fe619491d49 upstream.
The Yamaha MODX M uses a different USB ID for each combination of its
audio mode and MIDI version settings:
0499:1772 2 stereo, 44.1-96 kHz, MIDI 1.0
0499:1763 2 stereo, 44.1-96 kHz, MIDI 2.0
0499:1773 5 stereo, 44.1 kHz, MIDI 1.0
0499:1764 5 stereo, 44.1 kHz, MIDI 2.0
With 0499:1773 and 0499:1764 playback is silent. With the
always_set_rate quirk flag set for them it plays. 0499:1772 and
0499:1763 play without it.
Tested on a MODX M6 with the quirk_flags module parameter set to
0499:1773:always_set_rate and to 0499:1764:always_set_rate.
Reported-by: Frank Slotta <frank.slotta@posteo.de>
Closes: https://linuxmusicians.com/viewtopic.php?p=186121
Cc: <stable@vger.kernel.org> # 7.3.x
Tested-by: Frank Slotta <frank.slotta@posteo.de>
Signed-off-by: Geoffrey D. Bennett <g@b4.vu>
Link: https://patch.msgid.link/avnJGI3L/sf7KQCi@m.b4.vu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/usb/quirks.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -2297,6 +2297,10 @@ static const struct usb_audio_quirk_flag
QUIRK_FLAG_GENERIC_IMPLICIT_FB),
DEVICE_FLG(0x0499, 0x1509, /* Steinberg UR22 */
QUIRK_FLAG_GENERIC_IMPLICIT_FB),
+ DEVICE_FLG(0x0499, 0x1764, /* Yamaha MODX M, 5 stereo, MIDI 2.0 */
+ QUIRK_FLAG_ALWAYS_SET_RATE),
+ DEVICE_FLG(0x0499, 0x1773, /* Yamaha MODX M, 5 stereo, MIDI 1.0 */
+ QUIRK_FLAG_ALWAYS_SET_RATE),
DEVICE_FLG(0x0499, 0x3108, /* Yamaha YIT-W12TX */
QUIRK_FLAG_GET_SAMPLE_RATE),
DEVICE_FLG(0x04d8, 0xfeea, /* Benchmark DAC1 Pre */
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 428/742] ACPI: CPPC: Reject EPP registers narrower than 8 bits
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (418 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 427/742] ALSA: usb-audio: Add always_set_rate quirk for Yamaha MODX M Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 429/742] ARC: io: work around GCC PR127718 in __raw_write{w,l}() Greg Kroah-Hartman
` (306 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christian Loehle,
Mario Limonciello (AMD), Rafael J. Wysocki
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Loehle <christian.loehle@arm.com>
commit 7aca8e31a8fbf2ceffb487cec67ae300b95fa8b1 upstream.
The EPP interfaces use an 8-bit preference, but ACPI permits narrower
fields. With a 4- or 6-bit SystemMemory field, writing 128 succeeds but
stores zero, requesting maximum performance instead.
Reject a present EPP register narrower than eight bits during _CPC probe.
Use the existing error path to release previously acquired resources and
leave the CPU's CPPC descriptor unpublished. Keep absent EPP entries and
registers at least eight bits wide on their existing paths.
Fail the whole probe instead of disabling only EPP. This also makes
amd-pstate's acpi_cpc_valid() check reject the platform before registering
its MSR or shared-memory driver. No affected hardware is known or
expected and the specification is expected to no longer permit these
in the future [1].
Fixes: 922607a2b462 ("cpufreq: CPPC: Add support for autonomous selection")
Link: https://github.com/tianocore/edk2/issues/10838 [1]
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Cc: All applicable <stable@vger.kernel.org>
[ rjw: Changelog tweak ]
Link: https://patch.msgid.link/20261113130411.1433174-1-christian.loehle@arm.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/acpi/cppc_acpi.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -888,6 +888,15 @@ int acpi_cppc_processor_probe(struct acp
gas_t = (struct cpc_reg *)
cpc_obj->buffer.pointer;
+ /* EPP interfaces require the full 0-255 preference range. */
+ if (i - 2 == ENERGY_PERF && gas_t->bit_width < 8 &&
+ !IS_NULL_REG(gas_t)) {
+ pr_debug("CPU%d: EPP register width %u is not supported\n",
+ pr->id, gas_t->bit_width);
+ ret = -EOPNOTSUPP;
+ goto out_free;
+ }
+
/*
* The PCC Subspace index is encoded inside
* the CPC table entries. The same PCC index
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 429/742] ARC: io: work around GCC PR127718 in __raw_write{w,l}()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (419 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 428/742] ACPI: CPPC: Reject EPP registers narrower than 8 bits Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 430/742] arm64/mm: fix destructor for unconstructed hotplug page tables Greg Kroah-Hartman
` (305 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Vineet Gupta
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <vgupta@kernel.org>
commit 603b4fd69b4e77770761ea03451e2164186f8590 upstream.
The __raw_write{w,l}() accessors use inline asm with an "m" operand for
the store destination. GCC's ARC backend lets "m" match any legitimate
address, including the register-indexed [b,c] forms that only loads
support: stores only have [reg], [reg,s9] and [limm] addressing. With
newer GCC (late-combine in GCC 15, combine in GCC 16), a writew() with a
scaled, non-constant offset gets
stw.as r2,[r0,r1]
which the assembler rejects:
Error: inappropriate arguments for opcode 'stw'
With GCC 16 this breaks even hsdk_defconfig (drivers/net/pcs/
pcs-xpcs-plat.c) and axs101_defconfig. allyesconfig additionally trips
in drivers/pinctrl/renesas/pinctrl-rza2.c and drivers/video/fbdev/
s3c-fb.c.
Work around it by passing the address in a register and using a fixed
[%1] address in the asm template, so the compiler can't pick an
addressing mode that stores don't support. This is the minimal fix.
The next patch drops the inline asm altogether.
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127718
Cc: stable@vger.kernel.org
Signed-off-by: Vineet Gupta <vgupta@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arc/include/asm/io.h | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
--- a/arch/arc/include/asm/io.h
+++ b/arch/arc/include/asm/io.h
@@ -133,10 +133,14 @@ static inline void __raw_writeb(u8 b, vo
#define __raw_writew __raw_writew
static inline void __raw_writew(u16 s, volatile void __iomem *addr)
{
+ /*
+ * Not an "m" operand: GCC can pick a register-indexed address for it,
+ * which ST doesn't support (GCC PR target/127718).
+ */
__asm__ __volatile__(
- " stw%U1 %0, %1 \n"
+ " stw %0, [%1] \n"
:
- : "r" (s), "m" (*(volatile u16 __force *)addr)
+ : "r" (s), "r" (addr)
: "memory");
}
@@ -144,10 +148,11 @@ static inline void __raw_writew(u16 s, v
#define __raw_writel __raw_writel
static inline void __raw_writel(u32 w, volatile void __iomem *addr)
{
+ /* See __raw_writew() above for why this doesn't use an "m" operand. */
__asm__ __volatile__(
- " st%U1 %0, %1 \n"
+ " st %0, [%1] \n"
:
- : "r" (w), "m" (*(volatile u32 __force *)addr)
+ : "r" (w), "r" (addr)
: "memory");
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 430/742] arm64/mm: fix destructor for unconstructed hotplug page tables
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (420 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 429/742] ARC: io: work around GCC PR127718 in __raw_write{w,l}() Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 431/742] arm64: cpufeature: Remove Neoverse-V3/AE from the BBML3 allow list Greg Kroah-Hartman
` (304 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Muchun Song, Andrew Morton,
Kevin Brodsky, David Hildenbrand (Arm), Anshuman Khandual,
Catalin Marinas, Oscar Salvador, Dave Hansen, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Björn Töpel,
Will Deacon, Mark Rutland, Alexander Gordeev, Alistair Popple
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muchun Song <muchun.song@linux.dev>
commit 26601a6c80c52c5336cd02b3379710077aeafc4a upstream.
Commit c594b83457cc ("arm64: mm: call pagetable dtor when freeing
hot-removed page tables") made free_hotplug_pgtable_page()
unconditionally run the page-table destructor. This matches page tables
allocated by the arm64 mapping code, which runs the corresponding
constructors.
However, arm64 also uses the generic sparse-vmemmap population code.
Runtime intermediate page tables allocated by that code do not run a
page-table constructor. Freeing one during memory hot-remove therefore
runs a destructor without a matching constructor and corrupts
NR_PAGETABLE accounting.
Free intermediate page-table pages through pagetable_free(). It runs the
destructor only for constructor-backed pages and then releases the page
through the page-table freeing path.
Link: https://lore.kernel.org/20261023063428.3658761-5-songmuchun@bytedance.com
Fixes: c594b83457cc ("arm64: mm: call pagetable dtor when freeing hot-removed page tables")
Signed-off-by: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Björn Töpel <bjorn@rivosinc.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm64/mm/mmu.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -1495,8 +1495,7 @@ static void free_hotplug_page_range(stru
static void free_hotplug_pgtable_page(struct page *page)
{
- pagetable_dtor(page_ptdesc(page));
- free_hotplug_page_range(page, PAGE_SIZE, NULL);
+ pagetable_free(page_ptdesc(page));
}
static bool pgtable_range_aligned(unsigned long start, unsigned long end,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 431/742] arm64: cpufeature: Remove Neoverse-V3/AE from the BBML3 allow list
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (421 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 430/742] arm64/mm: fix destructor for unconstructed hotplug page tables Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 432/742] arm64: cpufeature: Remove Cortex-X4 " Greg Kroah-Hartman
` (303 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ryan Roberts, Catalin Marinas
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan Roberts <ryan.roberts@arm.com>
commit 4f9280c8db69bc807c6c6c616f1b9853ca9144c7 upstream.
Neoverse-V3 and Neoverse-V3AE erratum 3053180 can cause a load or store
to livelock when mapping size changes without break-before-make or when
contiguous hints are programmed inconsistently.
The erratum was previously reported as fixed in r0p2. On that basis,
commit 5aa4b625762e ("arm64: Add BBM Level 2 cpu feature") allowed
Neoverse-V3 from r0p2, and commit 8fca3852e33d ("arm64: cpufeature: add
Neoverse-V3AE to BBML2 allow list") did the same for Neoverse-V3AE.
The updated SDENs, MP168 v11 for Neoverse-V3 and MP172 v12 for
Neoverse-V3AE, dated 9 June 2026, list r0p0, r0p1 and r0p2 as affected
and the erratum as open. There is no fixed revision on which to base
either allow-list entry.
Remove both entries so these CPUs observe break-before-make, and record
the workaround in the silicon errata registry.
Fixes: 5aa4b625762e ("arm64: Add BBM Level 2 cpu feature")
Fixes: 8fca3852e33d ("arm64: cpufeature: add Neoverse-V3AE to BBML2 allow list")
Cc: stable@vger.kernel.org
Link: https://support.arm.com/documentation/109231/11-0/?lang=en
Link: https://support.arm.com/documentation/109704/12-0/?lang=en
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Documentation/arch/arm64/silicon-errata.rst | 4 ++++
arch/arm64/kernel/cpufeature.c | 2 --
2 files changed, 4 insertions(+), 2 deletions(-)
--- a/Documentation/arch/arm64/silicon-errata.rst
+++ b/Documentation/arch/arm64/silicon-errata.rst
@@ -250,10 +250,14 @@ stable kernels.
+----------------+-----------------+-----------------+-----------------------------+
| ARM | Neoverse-V2 | #4193787 | ARM64_ERRATUM_4118414 |
+----------------+-----------------+-----------------+-----------------------------+
+| ARM | Neoverse-V3 | #3053180 | N/A |
++----------------+-----------------+-----------------+-----------------------------+
| ARM | Neoverse-V3 | #3312417 | ARM64_ERRATUM_3194386 |
+----------------+-----------------+-----------------+-----------------------------+
| ARM | Neoverse-V3 | #4193784 | ARM64_ERRATUM_4118414 |
+----------------+-----------------+-----------------+-----------------------------+
+| ARM | Neoverse-V3AE | #3053180 | N/A |
++----------------+-----------------+-----------------+-----------------------------+
| ARM | Neoverse-V3AE | #3312417 | ARM64_ERRATUM_3194386 |
+----------------+-----------------+-----------------+-----------------------------+
| ARM | Neoverse-V3AE | #4193784 | ARM64_ERRATUM_4118414 |
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -2164,8 +2164,6 @@ bool cpu_supports_bbml3(void)
/* CPUs that support BBML3 but dont advertise through ID_AA64MMFR2_EL1 */
static const struct midr_range supports_bbml3_list[] = {
MIDR_REV_RANGE(MIDR_CORTEX_X4, 0, 3, 0xf),
- MIDR_REV_RANGE(MIDR_NEOVERSE_V3, 0, 2, 0xf),
- MIDR_REV_RANGE(MIDR_NEOVERSE_V3AE, 0, 2, 0xf),
MIDR_ALL_VERSIONS(MIDR_NVIDIA_OLYMPUS),
MIDR_ALL_VERSIONS(MIDR_AMPERE1),
MIDR_ALL_VERSIONS(MIDR_AMPERE1A),
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 432/742] arm64: cpufeature: Remove Cortex-X4 from the BBML3 allow list
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (422 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 431/742] arm64: cpufeature: Remove Neoverse-V3/AE from the BBML3 allow list Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 433/742] arm64: Drop stdint.h type overrides from asm/neon-intrinsics.h Greg Kroah-Hartman
` (302 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ryan Roberts, Catalin Marinas
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan Roberts <ryan.roberts@arm.com>
commit c6ba16d8157b05e0a05b773422f5d3c5941e22de upstream.
Cortex-X4 erratum 3043263 can cause a load or store to livelock when
mapping size changes without break-before-make or when contiguous hints
are programmed inconsistently.
The erratum was previously reported as fixed in r0p3. On that basis,
commit 5aa4b625762e ("arm64: Add BBM Level 2 cpu feature") added
Cortex-X4 from r0p3.
The updated Cortex-X4 SDEN v13, dated 18 June 2026, lists r0p0, r0p1,
r0p2 and r0p3 as affected and the erratum as open.
Remove the entry so Cortex-X4 observes break-before-make, and record the
workaround in the silicon errata registry.
Fixes: 5aa4b625762e ("arm64: Add BBM Level 2 cpu feature")
Cc: stable@vger.kernel.org
Link: https://support.arm.com/documentation/109148/13-0/?lang=en
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Documentation/arch/arm64/silicon-errata.rst | 2 ++
arch/arm64/kernel/cpufeature.c | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)
--- a/Documentation/arch/arm64/silicon-errata.rst
+++ b/Documentation/arch/arm64/silicon-errata.rst
@@ -206,6 +206,8 @@ stable kernels.
+----------------+-----------------+-----------------+-----------------------------+
| ARM | Cortex-X3 | #4193786 | ARM64_ERRATUM_4118414 |
+----------------+-----------------+-----------------+-----------------------------+
+| ARM | Cortex-X4 | #3043263 | N/A |
++----------------+-----------------+-----------------+-----------------------------+
| ARM | Cortex-X4 | #3194386 | ARM64_ERRATUM_3194386 |
+----------------+-----------------+-----------------+-----------------------------+
| ARM | Cortex-X4 | #4118414 | ARM64_ERRATUM_4118414 |
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -2163,7 +2163,6 @@ bool cpu_supports_bbml3(void)
{
/* CPUs that support BBML3 but dont advertise through ID_AA64MMFR2_EL1 */
static const struct midr_range supports_bbml3_list[] = {
- MIDR_REV_RANGE(MIDR_CORTEX_X4, 0, 3, 0xf),
MIDR_ALL_VERSIONS(MIDR_NVIDIA_OLYMPUS),
MIDR_ALL_VERSIONS(MIDR_AMPERE1),
MIDR_ALL_VERSIONS(MIDR_AMPERE1A),
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 433/742] arm64: Drop stdint.h type overrides from asm/neon-intrinsics.h
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (423 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 432/742] arm64: cpufeature: Remove Cortex-X4 " Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 434/742] arm64: kexec: use a typed entry to fix kCFI oops Greg Kroah-Hartman
` (301 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ard Biesheuvel, Nathan Chancellor,
Eric Biggers, Catalin Marinas
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <ardb@kernel.org>
commit a041bdbe1f3a8efa8a527a89c84d3771232b4942 upstream.
None of the users of NEON intrinsics include <linux/types.h> anymore,
and so there is no longer a need to override __INT64_TYPE__ and
__UINT64_TYPE__ in order to make the definitions of int64_t and uint64_t
provided by the compiler's freestanding <stdint.h> compatible with the
kernel's. So drop the overrides.
This also means that uint64_t now matches the type that Clang uses for
64-bit quantities in the prototypes of its NEON builtins, and so the
-Wincompatible-pointer-types warnings that are currently being disabled
for all NEON intrinsics code will no longer occur. So drop the pragma
that disables them as well.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm64/include/asm/neon-intrinsics.h | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
--- a/arch/arm64/include/asm/neon-intrinsics.h
+++ b/arch/arm64/include/asm/neon-intrinsics.h
@@ -6,23 +6,13 @@
#ifndef __ASM_NEON_INTRINSICS_H
#define __ASM_NEON_INTRINSICS_H
-#include <asm-generic/int-ll64.h>
-
/*
- * In the kernel, u64/s64 are [un]signed long long, not [un]signed long.
- * So by redefining these macros to the former, we can force gcc-stdint.h
- * to define uint64_t / in64_t in a compatible manner.
+ * <arm_neon.h> includes <stdint.h>, which defines some C99 types differently
+ * from <linux/types.h>, so the latter must not be included into code that uses
+ * NEON intrinsics. The kernel's u8/u16/u32/u64 types can be used alongside the
+ * C99 ones, so provide those instead.
*/
-
-#ifdef __INT64_TYPE__
-#undef __INT64_TYPE__
-#define __INT64_TYPE__ long long
-#endif
-
-#ifdef __UINT64_TYPE__
-#undef __UINT64_TYPE__
-#define __UINT64_TYPE__ unsigned long long
-#endif
+#include <asm-generic/int-ll64.h>
/*
* genksyms chokes on the ARM NEON instrinsics system header, but we
@@ -33,8 +23,4 @@
#include <arm_neon.h>
#endif
-#ifdef CONFIG_CC_IS_CLANG
-#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
-#endif
-
#endif /* __ASM_NEON_INTRINSICS_H */
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 434/742] arm64: kexec: use a typed entry to fix kCFI oops
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (424 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 433/742] arm64: Drop stdint.h type overrides from asm/neon-intrinsics.h Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:04 ` [PATCH 7.3 435/742] ASoC: amd: acp: fix PDM ring buffer address on ACP7.x resume Greg Kroah-Hartman
` (300 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Kees Cook, Ben Cressey,
Catalin Marinas
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Cressey <ben@cressey.dev>
commit b059e957d07b3cab92eef4656988244043f5769a upstream.
An arm64 Linux kernel built with CONFIG_CFI=y oopses after "Bye!" on
every kexec that relocates the image. Crash images load in place and are
not affected. The oops reproduces under QEMU:
Unable to handle kernel paging request at virtual address 00000000544bfffc
pc : machine_kexec+0x104/0x274
Code: d5182008 d5033fdf aa1303e0 f9418a68 (b85fc110)
b85fc110 is "ldur w16, [x8, #-4]", the kCFI check's load of the type
hash in front of the callee. Commit efc2d0f20a9d ("arm64: kexec: keep
MMU enabled during kexec relocation") made machine_kexec() call the
control page's copy of arm64_relocate_new_kernel() indirectly, while
TTBR0 maps only that page. The copy starts at the page's first byte, so
the load faults. SYM_CODE_START() also gives the routine no hash.
SYM_TYPED_FUNC_START() emits the hash inside .kexec_relocate.text, and
machine_kexec_post_load() already copies that whole section, at most
4 KiB, to the page's start, so the mapped page holds both hash and
entry.
The ASSERT from commit dc4824faa265 ("arm64: avoid executing padding
bytes during kexec / hibernation") kept the entry first, since C
branched to the page's start. Relax it, so the entry need only be in the
section.
Fix by typing the routine with SYM_TYPED_FUNC_START() and a C prototype,
and entering the copy at the symbol's offset in the section.
The code is Kees Cook's, as posted in review, with two comments and the
ASSERT message reworded.
An LLM diagnosed the oops.
Fixes: efc2d0f20a9d ("arm64: kexec: keep MMU enabled during kexec relocation")
Cc: stable@vger.kernel.org
Suggested-by: Kees Cook <kees@kernel.org>
Link: https://lore.kernel.org/linux-arm-kernel/202609241804.BB23BF10@keescook/
Signed-off-by: Ben Cressey <ben@cressey.dev>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm64/include/asm/kexec.h | 2 ++
arch/arm64/kernel/machine_kexec.c | 7 +++++--
arch/arm64/kernel/relocate_kernel.S | 11 +++++++----
arch/arm64/kernel/vmlinux.lds.S | 5 +++--
4 files changed, 17 insertions(+), 8 deletions(-)
--- a/arch/arm64/include/asm/kexec.h
+++ b/arch/arm64/include/asm/kexec.h
@@ -100,6 +100,8 @@ void cpu_soft_restart(unsigned long el2_
unsigned long arg0, unsigned long arg1,
unsigned long arg2);
+void arm64_relocate_new_kernel(struct kimage *kimage);
+
int machine_kexec_post_load(struct kimage *image);
#define machine_kexec_post_load machine_kexec_post_load
#endif
--- a/arch/arm64/kernel/machine_kexec.c
+++ b/arch/arm64/kernel/machine_kexec.c
@@ -136,9 +136,12 @@ int machine_kexec_post_load(struct kimag
kimage->arch.ttbr1 = __pa(trans_pgd);
kimage->arch.zero_page = __pa_symbol(empty_zero_page);
+ /* Copy the whole section: a kCFI hash may precede the entry point */
reloc_size = __relocate_new_kernel_end - __relocate_new_kernel_start;
memcpy(reloc_code, __relocate_new_kernel_start, reloc_size);
- kimage->arch.kern_reloc = __pa(reloc_code);
+ kimage->arch.kern_reloc = __pa(reloc_code) +
+ ((unsigned long)arm64_relocate_new_kernel -
+ (unsigned long)__relocate_new_kernel_start);
rc = trans_pgd_idmap_page(&info, &kimage->arch.ttbr0,
&kimage->arch.t0sz, reloc_code);
if (rc)
@@ -193,7 +196,7 @@ void machine_kexec(struct kimage *kimage
restart(is_hyp_nvhe(), kimage->start, kimage->arch.dtb_mem,
0, 0);
} else {
- void (*kernel_reloc)(struct kimage *kimage);
+ typeof(arm64_relocate_new_kernel) *kernel_reloc;
if (is_hyp_nvhe())
__hyp_set_vectors(kimage->arch.el2_vectors);
--- a/arch/arm64/kernel/relocate_kernel.S
+++ b/arch/arm64/kernel/relocate_kernel.S
@@ -8,6 +8,7 @@
* Pasha Tatashin <pasha.tatashin@soleen.com>
*/
+#include <linux/cfi_types.h>
#include <linux/kexec.h>
#include <linux/linkage.h>
@@ -32,11 +33,13 @@
* new image to its final location. To assure that the
* arm64_relocate_new_kernel routine which does that copy is not overwritten,
* all code and data needed by arm64_relocate_new_kernel must be between the
- * symbols arm64_relocate_new_kernel and arm64_relocate_new_kernel_end. The
- * machine_kexec() routine will copy arm64_relocate_new_kernel to the kexec
+ * symbols __relocate_new_kernel_start and __relocate_new_kernel_end. The
+ * machine_kexec_post_load() routine will copy that whole region to the kexec
* safe memory that has been set up to be preserved during the copy operation.
+ *
+ * Called indirectly by machine_kexec(), this routine needs a kCFI type hash.
*/
-SYM_CODE_START(arm64_relocate_new_kernel)
+SYM_TYPED_FUNC_START(arm64_relocate_new_kernel)
/*
* The kimage structure isn't allocated specially and may be clobbered
* during relocation. We must load any values we need from it prior to
@@ -98,4 +101,4 @@ SYM_CODE_START(arm64_relocate_new_kernel
mov x2, xzr
mov x3, xzr
br x28 /* Jumps from el1 */
-SYM_CODE_END(arm64_relocate_new_kernel)
+SYM_FUNC_END(arm64_relocate_new_kernel)
--- a/arch/arm64/kernel/vmlinux.lds.S
+++ b/arch/arm64/kernel/vmlinux.lds.S
@@ -432,6 +432,7 @@ ASSERT(swapper_pg_dir - tramp_pg_dir ==
ASSERT(__relocate_new_kernel_end - __relocate_new_kernel_start <= SZ_4K,
"kexec relocation code is bigger than 4 KiB")
ASSERT(KEXEC_CONTROL_PAGE_SIZE >= SZ_4K, "KEXEC_CONTROL_PAGE_SIZE is broken")
-ASSERT(__relocate_new_kernel_start == arm64_relocate_new_kernel,
- "kexec control page does not start with arm64_relocate_new_kernel")
+ASSERT(arm64_relocate_new_kernel >= __relocate_new_kernel_start &&
+ arm64_relocate_new_kernel < __relocate_new_kernel_end,
+ "kexec relocation code does not contain arm64_relocate_new_kernel")
#endif
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 435/742] ASoC: amd: acp: fix PDM ring buffer address on ACP7.x resume
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (425 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 434/742] arm64: kexec: use a typed entry to fix kCFI oops Greg Kroah-Hartman
@ 2026-12-04 10:04 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 436/742] ASoC: qcom: audioreach: only disconnect the route a mixer control owns Greg Kroah-Hartman
` (299 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:04 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Nicholas E. Andrade, Mark Brown
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas E. Andrade <sdnick484@gmail.com>
commit a3d8527ed469a31aeeb02c5e52ed89de410e46e6 upstream.
On ACP7.x the DMIC ring buffer lives at ACP7x_DMIC_MEM_WINDOW_START,
and acp_dmic_prepare() programs ACP_WOV_RX_RINGBUFADDR accordingly.
The system resume path (acp70_pcm_resume() -> restore_acp_pdm_params()
-> set_acp_pdm_ring_buffer()) however still uses the pre-ACP7.x
calculation, stream->reg_offset + MEM_WINDOW_START (0x6080000).
That window is not backed by the PTEs config_acp_dma() writes for the
DMIC stream (scratch offset 0x6000, i.e. window 0x4C00000), so after
resume the ATU translates DMIC DMA through uninitialised SRAM and the
ACP writes to random IOVAs. With the IOMMU enabled, a capture stream
held open across s2idle produces a continuous stream of faults until
it is closed, and captures nothing useful:
snd_acp_pci 0000:c4:00.5: AMD-Vi: Event logged [IO_PAGE_FAULT
domain=0x0018 address=0x1ddeee9942398e20 flags=0x0030]
Commit 3ee257aba1d5 ("ASoC: amd: acp: Audio is not resuming after
s0ix") fixed the same problem for the I2S restore path in
set_acp_i2s_dma_fifo() but left the PDM path unchanged. Select the
ACP7.x window there too, matching acp_dmic_prepare().
Tested on a Lenovo ThinkPad P14s Gen 6 AMD (ACP rev 0x71, kernel
7.3.1) by holding
arecord -D hw:CARD=acppdmmach,DEV=0 -f S32_LE -r 48000 -c 2
open across s2idle: before the fix, IO_PAGE_FAULTs after every resume
and no audio; after, no faults and audio captured correctly after
resume.
The bug was diagnosed and the fix drafted with the help of an AI
coding assistant (Claude); the analysis, change and testing were
reviewed and verified by the submitter on the hardware above.
Fixes: f6f7d25b1103 ("ASoC: amd: acp: Add pte configuration for ACP7.0 platform")
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas E. Andrade <sdnick484@gmail.com>
Link: https://patch.msgid.link/20261109-for-next-v1-1-54a06f391bda@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/soc/amd/acp/acp-legacy-common.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/sound/soc/amd/acp/acp-legacy-common.c
+++ b/sound/soc/amd/acp/acp-legacy-common.c
@@ -154,7 +154,10 @@ static void set_acp_pdm_ring_buffer(stru
period_bytes = frames_to_bytes(runtime, runtime->period_size);
pdm_size = frames_to_bytes(runtime, runtime->buffer_size);
- physical_addr = stream->reg_offset + MEM_WINDOW_START;
+ if (chip->acp_rev >= ACP70_PCI_ID)
+ physical_addr = ACP7x_DMIC_MEM_WINDOW_START;
+ else
+ physical_addr = stream->reg_offset + MEM_WINDOW_START;
/* Init ACP PDM Ring buffer */
writel(physical_addr, chip->base + ACP_WOV_RX_RINGBUFADDR);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 436/742] ASoC: qcom: audioreach: only disconnect the route a mixer control owns
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (426 preceding siblings ...)
2026-12-04 10:04 ` [PATCH 7.3 435/742] ASoC: amd: acp: fix PDM ring buffer address on ACP7.x resume Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 437/742] ASoC: qcom: audioreach: use a 32-bit container for S24_LE PCM Greg Kroah-Hartman
` (298 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Marc Herrero, Srinivas Kandagatla,
Mark Brown
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Herrero <marcht@proton.me>
commit 562b2cc2aa88e039790248b5f1014c4850a7e528 upstream.
Each AudioReach virtual mixer route control ("<BE> Audio Mixer <FE>")
connects a front-end stream graph to a back-end device graph by storing
the source module in the device graph's audioreach_graph_info. Writing 0
to any of these controls clears that link unconditionally, even when the
device graph is connected to a different front end.
When two front ends can feed the same back end the result therefore
depends on write order. On QCS6490 (Radxa Dragon Q6A):
- alsactl restore writes 'DISPLAY_PORT_RX_0 Audio Mixer MultiMedia2' = 1
and then 'DISPLAY_PORT_RX_0 Audio Mixer MultiMedia1' = 0, which leaves
DisplayPort disconnected although the saved state has it connected;
- the UCM HDMI enable sequence writes
'RX_CODEC_DMA_RX_0 Audio Mixer MultiMedia2' = 0, which disconnects
MultiMedia1 from the headphones. A PCM started on MultiMedia1 after
that never advances (hw_ptr stays at 0).
Make audioreach_connect_sub_graphs() only clear the link when it belongs
to the control being cleared, using the same test as
audioreach_is_vmixer_connected() does for get(). The DAPM mixer state is
still updated for every write, so DAPM keeps tracking each route control
as before.
Fixes: e4977b91cff8 ("ASoC: qdsp6: audioreach: Simplify handing FE and BE graph connections")
Cc: stable@vger.kernel.org
Signed-off-by: Marc Herrero <marcht@proton.me>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/20261116-q6apm-fixes-v2-2-ea89fb43316a@proton.me
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/soc/qcom/qdsp6/topology.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/sound/soc/qcom/qdsp6/topology.c
+++ b/sound/soc/qcom/qdsp6/topology.c
@@ -1240,7 +1240,9 @@ static void audioreach_connect_sub_graph
info->dst_mod_inst_id = m2->module_instance_id;
info->dst_mod_ip_port_id = 2;
- } else {
+ } else if (info->src_mod_inst_id == m1->module_instance_id &&
+ info->dst_mod_inst_id == m2->module_instance_id) {
+ /* only drop the link this control made, not another FE's */
info->src_mod_inst_id = 0;
info->src_mod_op_port_id = 0;
info->dst_mod_inst_id = 0;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 437/742] ASoC: qcom: audioreach: use a 32-bit container for S24_LE PCM
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (427 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 436/742] ASoC: qcom: audioreach: only disconnect the route a mixer control owns Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 438/742] ASoC: qcom: q6apm-dai: reject compress rings larger than the DMA buffer Greg Kroah-Hartman
` (297 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Srinivas Kandagatla, Marc Herrero,
Mark Brown
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Herrero <marcht@proton.me>
commit feb416ba626e95b12fc238587f8fee93cae66c9c upstream.
SNDRV_PCM_FORMAT_S24_LE carries 24 valid bits in a 32-bit container, but
audioreach_shmem_set_media_format() and audioreach_pcm_set_media_format()
set bits_per_sample = bit_width = 24 in PARAM_ID_MEDIA_FORMAT and
PARAM_ID_PCM_OUTPUT_FORMAT_CFG, which tells the DSP that the samples are
packed 3-byte words.
q6apm-dai advertises S24_LE, so with a topology that allows it on a
playback front end the DSP walks the buffer with the wrong stride. On
QCS6490 (Radxa Dragon Q6A) this crashes the ADSP audio_process:
PDM: service 'audio_process' crash: 'EX:audio_process:0x2:...'
q6apm-lpass-dais ...: Failed to start APM port 113
remoteproc remoteproc0: crash detected in adsp: type fatal error
Use the container size (32) for 24-bit data and keep bit_width = 24,
alignment = PCM_LSB_ALIGNED and q_factor = 23. With this change S24_LE
playback works on the headphone path (codec DMA RX -> LPASS RX macro ->
WCD9385), tested with the back end at S16_LE, S24_LE and S32_LE and at
48, 96 and 192 kHz.
The DSP then reads each 32-bit word as Q23, so S24_LE samples must be
sign-extended into the top byte, as alsa-lib's conversions do.
Fixes: 25ab80db6b13 ("ASoC: qdsp6: audioreach: add module configuration command helpers")
Cc: stable@vger.kernel.org
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Signed-off-by: Marc Herrero <marcht@proton.me>
Link: https://patch.msgid.link/20261116-q6apm-fixes-v2-1-ea89fb43316a@proton.me
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/soc/qcom/qdsp6/audioreach.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
--- a/sound/soc/qcom/qdsp6/audioreach.c
+++ b/sound/soc/qcom/qdsp6/audioreach.c
@@ -1212,7 +1212,12 @@ static int audioreach_pcm_set_media_form
media_cfg->interleaved = module->interleave_type;
media_cfg->num_channels = mcfg->num_channels;
media_cfg->q_factor = mcfg->bit_width - 1;
- media_cfg->bits_per_sample = mcfg->bit_width;
+ /*
+ * bit_width is the number of valid bits in a sample, bits_per_sample
+ * the size of the container it is stored in. S24_LE keeps 24 valid
+ * bits in a 32-bit container, so it is 24/32, not packed 24/24.
+ */
+ media_cfg->bits_per_sample = mcfg->bit_width == 24 ? 32 : mcfg->bit_width;
/* Convert the physical mapping to a logical mapping of the channels */
for (i = 0, j = 0; i < AR_PCM_MAX_NUM_CHANNEL && j < mcfg->num_channels; i++) {
if (!mcfg->channel_map[i])
@@ -1304,7 +1309,8 @@ static int audioreach_shmem_set_media_fo
cfg->sample_rate = mcfg->sample_rate;
cfg->bit_width = mcfg->bit_width;
cfg->alignment = PCM_LSB_ALIGNED;
- cfg->bits_per_sample = mcfg->bit_width;
+ /* S24_LE: 24 valid bits in a 32-bit container, see above */
+ cfg->bits_per_sample = mcfg->bit_width == 24 ? 32 : mcfg->bit_width;
cfg->q_factor = mcfg->bit_width - 1;
cfg->endianness = PCM_LITTLE_ENDIAN;
cfg->num_channels = mcfg->num_channels;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 438/742] ASoC: qcom: q6apm-dai: reject compress rings larger than the DMA buffer
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (428 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 437/742] ASoC: qcom: audioreach: use a 32-bit container for S24_LE PCM Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 439/742] ASoC: qcom: q6asm-dai: " Greg Kroah-Hartman
` (296 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Julius Bairaktaris,
Srinivas Kandagatla, Mark Brown
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julius Bairaktaris <julius@bairaktaris.de>
commit 3857bc06e5a40c5ebb62917147375a811f010aa0 upstream.
q6apm_dai_compr_open() allocates a fixed 8 MiB DMA buffer, but
q6apm_dai_compr_set_params() takes the ring size from the fragment size
and count that userspace passes to SNDRV_COMPRESS_SET_PARAMS without
checking it against that buffer. The compress core checks the geometry
against the runtime buffer only for drivers without a copy callback.
q6apm_compr_copy() places each write() at the stream position modulo the
ring size, so a ring larger than the DMA buffer lets write() copy user
data past its end, and after SNDRV_COMPRESS_NEXT_TRACK the copy starts at
the next multiple of the fragment size.
Reject a ring larger than the DMA buffer.
Fixes: c317d148a2b0 ("ASoC: q6dsp: q6apm-dai: Add mmap and copy compress DAI callbacks")
Cc: stable@vger.kernel.org
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/20261111080624.244291-2-julius@bairaktaris.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/soc/qcom/qdsp6/q6apm-dai.c | 3 +++
1 file changed, 3 insertions(+)
--- a/sound/soc/qcom/qdsp6/q6apm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6apm-dai.c
@@ -827,6 +827,9 @@ static int q6apm_dai_compr_set_params(st
if (!pdata)
return -EINVAL;
+ if (runtime->buffer_size > prtd->dma_buffer.bytes)
+ return -EINVAL;
+
prtd->periods = runtime->fragments;
prtd->pcm_count = runtime->fragment_size;
prtd->pcm_size = runtime->fragments * runtime->fragment_size;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 439/742] ASoC: qcom: q6asm-dai: reject compress rings larger than the DMA buffer
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (429 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 438/742] ASoC: qcom: q6apm-dai: reject compress rings larger than the DMA buffer Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 440/742] ASoC: qcom: q6dsp-lpass-clocks: Set driver data before registering clocks Greg Kroah-Hartman
` (295 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Julius Bairaktaris, Mark Brown
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julius Bairaktaris <julius@bairaktaris.de>
commit 4c15e549b7ad03183d10826da91e9ddc207a02cd upstream.
q6asm_dai_compr_open() allocates a fixed 8 MiB DMA buffer, but
q6asm_dai_compr_set_params() takes the ring size from the fragment size
and count that userspace passes to SNDRV_COMPRESS_SET_PARAMS without
checking it against that buffer. The compress core checks the geometry
against the runtime buffer only for drivers without a copy callback.
q6asm_compr_copy() places each write() at the stream position modulo the
ring size, so a ring larger than the DMA buffer lets write() copy user
data past its end, and after SNDRV_COMPRESS_NEXT_TRACK the copy starts at
the next multiple of the fragment size.
Reject a ring larger than the DMA buffer.
Fixes: a08cd56a4524 ("ASoC: q6asm-dai: add support to copy callback")
Cc: stable@vger.kernel.org
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
Link: https://patch.msgid.link/20261111080624.244291-3-julius@bairaktaris.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/soc/qcom/qdsp6/q6asm-dai.c | 3 +++
1 file changed, 3 insertions(+)
--- a/sound/soc/qcom/qdsp6/q6asm-dai.c
+++ b/sound/soc/qcom/qdsp6/q6asm-dai.c
@@ -900,6 +900,9 @@ static int q6asm_dai_compr_set_params(st
return -EINVAL;
}
+ if (runtime->buffer_size > prtd->dma_buffer.bytes)
+ return -EINVAL;
+
prtd->periods = runtime->fragments;
prtd->pcm_count = runtime->fragment_size;
prtd->pcm_size = runtime->fragments * runtime->fragment_size;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 440/742] ASoC: qcom: q6dsp-lpass-clocks: Set driver data before registering clocks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (430 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 439/742] ASoC: qcom: q6asm-dai: " Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 441/742] ASoC: wm8962: Fix broken headset button caused by wrong guard constant Greg Kroah-Hartman
` (294 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, yzddMr6, Srinivas Kandagatla,
Mark Brown
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: yzddMr6 <yzddmr6@gmail.com>
commit bd6e011c8121c909daf51c78b56bb3bf7f467889 upstream.
The clk ops of the q6dsp clock controller look up struct q6dsp_cc with
dev_get_drvdata(), but q6dsp_clock_dev_probe() sets the driver data only
after it has registered the clocks and added the OF clock provider. A
consumer that gets and prepares one of the clocks in between
dereferences a NULL pointer.
fw_devlink does not keep consumers out of that window. The q6prm and
q6afe clock controllers are described below the ADSP remoteproc node,
and their devices are only created once the ADSP has booted and its
GPR/APR services have come up, long after the remoteproc device has
bound. fw_devlink therefore makes the remoteproc device the supplier of
their consumers. A consumer such as the LPASS LPI pinctrl then just
defers until of_clk_get() succeeds, and its retry from the deferred
probe worker can run while the clock controller is still in its probe.
That happened once on a Xiaomi Pad 8 Pro (SM8750). While the LPI pinctrl
probe registered its GPIO chip, gpiolib read a GPIO direction, which
runtime resumed the device and prepared its q6prm vote clocks through
pm_clk. The prepare op then faulted with a NULL pointer dereference at
virtual address 0x350 (trimmed):
pc : clk_vote_q6dsp_block+0x24/0x58 [snd_q6dsp_common]
lr : clk_core_prepare+0x7c/0x298
Call trace:
clk_vote_q6dsp_block+0x24/0x58 [snd_q6dsp_common] (P)
clk_core_prepare+0x7c/0x298
clk_prepare+0x28/0x44
pm_clk_resume+0x10c/0x188
pm_generic_runtime_resume+0x2c/0x44
...
__pm_runtime_resume+0x50/0x94
...
lpi_gpio_get_direction+0x4c/0x8c [pinctrl_lpass_lpi]
gpiochip_add_data_with_key+0x7b0/0x10dc
devm_gpiochip_add_data_with_key+0x38/0x8c
lpi_pinctrl_probe+0x2b8/0x320 [pinctrl_lpass_lpi]
...
deferred_probe_work_func+0x88/0xc0
0x350 is the offset of desc in struct q6dsp_cc; the driver data pointer
it was loaded from was NULL. The oops left the clk prepare_lock held,
which blocks every later clk_prepare(), and the system did not finish
booting.
On mainline the window is short, but it includes a wait for prepare_lock
in clk_core_reparent_orphans(), which of_clk_add_hw_provider() calls
right after listing the provider. The kernel that hit this had
out-of-tree changes to drivers/clk/clk.c that do more work at that
point, which makes the window wider.
Both q6afe-clocks and q6prm-clocks use q6dsp_clock_dev_probe(). Set the
driver data before the first clock is registered.
The oops was analysed and the fix written with the help of an AI coding
assistant.
Fixes: 9ab71ac37240 ("ASoC: qdsp6: q6afe-clocks: move audio-clocks to common file")
Cc: stable@vger.kernel.org
Signed-off-by: yzddMr6 <yzddmr6@gmail.com>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Link: https://patch.msgid.link/20261115-upstream-q6dsp-clk-drvdata-v1-1-4d7dbea52e52@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
--- a/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c
+++ b/sound/soc/qcom/qdsp6/q6dsp-lpass-clocks.c
@@ -146,6 +146,12 @@ int q6dsp_clock_dev_probe(struct platfor
cc->dev = dev;
q6dsp_clks = desc->clks;
+ /*
+ * The clk ops look up cc through the driver data, so set it before
+ * any of the clocks can be prepared.
+ */
+ dev_set_drvdata(dev, cc);
+
for (i = 0; i < desc->num_clks; i++) {
unsigned int id = q6dsp_clks[i].clk_id;
struct clk_init_data init = {
@@ -174,12 +180,6 @@ int q6dsp_clock_dev_probe(struct platfor
return ret;
}
- ret = devm_of_clk_add_hw_provider(dev, q6dsp_of_clk_hw_get, cc);
- if (ret)
- return ret;
-
- dev_set_drvdata(dev, cc);
-
- return 0;
+ return devm_of_clk_add_hw_provider(dev, q6dsp_of_clk_hw_get, cc);
}
EXPORT_SYMBOL_GPL(q6dsp_clock_dev_probe);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 441/742] ASoC: wm8962: Fix broken headset button caused by wrong guard constant
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (431 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 440/742] ASoC: qcom: q6dsp-lpass-clocks: Set driver data before registering clocks Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 442/742] ata: libata-core: Add max sector quirk to INTEL SSDSCKKB240G8 Greg Kroah-Hartman
` (293 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Chen Yuxi, Charles Keepax,
Sebastian Krzyszkowiak, Mark Brown
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Yuxi <chenyuxi19@huawei.com>
commit fd3b0fc97ea72d027359e7603a1224703cec1864 upstream.
Commit e59075211902 ("ASoC: wm8962: Don't report a microphone if
it's shorted to ground on plug") guards the mic short report by
testing wm8962->mic_status against WM8962_MICDET_STS. But mic_status
stores the reported jack status, composed of SND_JACK_MICROPHONE and
SND_JACK_BTN_0, which never has WM8962_MICDET_STS set. The guard is
therefore always true, so every mic short event reports nothing.
Pressing the button on a TRRS headset shorts the mic pin to ground,
which used to be reported as SND_JACK_BTN_0. After that commit the
button press is silently dropped, breaking the headset button on all
wm8962 boards using the mic detect path.
Test mic_status against SND_JACK_MICROPHONE instead, restoring the
intended behaviour: suppress the report only when no microphone was
previously detected, i.e. a TRS plug in a TRRS socket.
Fixes: e59075211902 ("ASoC: wm8962: Don't report a microphone if it's shorted to ground on plug")
Cc: stable@vger.kernel.org
Signed-off-by: Chen Yuxi <chenyuxi19@huawei.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
Link: https://patch.msgid.link/20261117070516.3861828-1-chenyuxi19@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/soc/codecs/wm8962.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3109,7 +3109,7 @@ static void wm8962_mic_work(struct work_
/* Don't report a microphone if it's shorted right after
* plugging in, as this may be a TRS plug in a TRRS socket.
*/
- if (!(wm8962->mic_status & WM8962_MICDET_STS))
+ if (!(wm8962->mic_status & SND_JACK_MICROPHONE))
status = 0;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 442/742] ata: libata-core: Add max sector quirk to INTEL SSDSCKKB240G8
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (432 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 441/742] ASoC: wm8962: Fix broken headset button caused by wrong guard constant Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 443/742] ata: libata-scsi: fix the INC_512 bit test for SECURITY PROTOCOL IN/OUT Greg Kroah-Hartman
` (292 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Justinien Bouron, Gunnar Kudrjavets,
Damien Le Moal, Niklas Cassel
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justinien Bouron <jbouron@amazon.com>
commit a12cc63129380a5364e787d92b30a3257f66c250 upstream.
INTEL SSDSCKKB240G8 with firmware version XC311102 runs into FPDMA
timeout errors when queue/max_sectors_kb is set to
BLK_DEF_MAX_SECTORS_CAP = 4096KiB / 8192 sectors. Similar to model
SSDSC2KG480G8, the issue disappears when setting this max size to 8191
sectors, thus apply the same quirk.
Firmware version X5A1ME59 for SSDSCKKB240G8 is un-affected by this bug
thus keep the quirk specific to firmware XC311102.
Fixes: 9b8b84879d4a ("block: Increase BLK_DEF_MAX_SECTORS_CAP")
Signed-off-by: Justinien Bouron <jbouron@amazon.com>
Reviewed-by: Gunnar Kudrjavets <gunnarku@amazon.com>
Cc: stable@vger.kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20261116205430.44305-1-jbouron@amazon.com
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/ata/libata-core.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4204,6 +4204,7 @@ static const struct ata_dev_quirk_value
{ "LITEON EP1-*", NULL, 1024 },
{ "DELLBOSS VD", "MV.R00-0", 8191 },
{ "INTEL SSDSC2KG480G8", "XCV10120", 8191 },
+ { "INTEL SSDSCKKB240G8", "XC311102", 8191 },
{ },
};
@@ -4474,6 +4475,8 @@ static const struct ata_dev_quirks_entry
ATA_QUIRK_MAX_SEC },
{ "INTEL*SSDSC2CT*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM |
ATA_QUIRK_NO_FUA },
+ { "INTEL SSDSCKKB240G8", "XC311102", ATA_QUIRK_ZERO_AFTER_TRIM |
+ ATA_QUIRK_MAX_SEC },
{ "INTEL*SSD*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM },
{ "SSD*INTEL*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM },
{ "Samsung*SSD*", NULL, ATA_QUIRK_ZERO_AFTER_TRIM },
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 443/742] ata: libata-scsi: fix the INC_512 bit test for SECURITY PROTOCOL IN/OUT
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (433 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 442/742] ata: libata-core: Add max sector quirk to INTEL SSDSCKKB240G8 Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 444/742] blk-iocost: Fix overflow in donation weight calculation Greg Kroah-Hartman
` (291 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Damien Le Moal, Niklas Cassel
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <cassel@kernel.org>
commit e2954988bb987c1432806379f602573d2388df93 upstream.
ata_scsi_security_inout_xlat() tests the INC_512 bit with cdb[4] & 7.
INC_512 is bit 7 of byte 4 of the SECURITY PROTOCOL IN and SECURITY
PROTOCOL OUT CDBs (SPC-6, tables 280 and 282), and bits 6:0 of that
byte are reserved.
Test bit 7 instead.
Fixes: 818831c8b22f ("libata: implement SECURITY PROTOCOL IN/OUT")
Cc: stable@vger.kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20261116191008.2954277-2-cassel@kernel.org
Signed-off-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/ata/libata-scsi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -4743,7 +4743,7 @@ static unsigned int ata_scsi_security_in
return 1;
}
- if (cdb[4] & 7) { /* INC_512 */
+ if (cdb[4] & 0x80) { /* INC_512 */
if (len > 0xffff) {
ata_scsi_set_invalid_field(qc->dev, scmd, 6, 0);
return 1;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 444/742] blk-iocost: Fix overflow in donation weight calculation
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (434 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 443/742] ata: libata-scsi: fix the INC_512 bit test for SECURITY PROTOCOL IN/OUT Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 445/742] block: Keep RPM_ACTIVE in blk_pre_runtime_resume() when already active Greg Kroah-Hartman
` (290 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alex Kazinsky, Tejun Heo, Jens Axboe
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Kazinsky <a.kazinsky@ideco.ru>
commit a56d5a485be4a9d52f0d7b3ed0dc3521367cb986 upstream.
hweight_after_donation() receives usage as u32, clamped to the range
[1, WEIGHT_ONE]. Since WEIGHT_ONE is 1 << 16, multiplying it by usage
equal to WEIGHT_ONE wraps the 32-bit unsigned result to zero before
it is passed to div64_s64().
This makes new_hwi zero, which is then clamped to 1, incorrectly
reducing the cgroup's in-use weight to the minimum.
Cast WEIGHT_ONE to s64 before multiplication to preserve the full
product.
Found by Linux Verification Center (linuxtesting.org) with SVACE static
analysis tool.
Fixes: f1de2439ec43 ("blk-iocost: revamp donation amount determination")
Cc: stable@vger.kernel.org
Signed-off-by: Alex Kazinsky <a.kazinsky@ideco.ru>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://patch.msgid.link/20261113110842.4189035-1-a.kazinsky@ideco.ru
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
block/blk-iocost.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -1848,7 +1848,8 @@ static u32 hweight_after_donation(struct
delta = div64_s64(WEIGHT_ONE * (now->vnow - vtime),
now->vnow - ioc->period_at_vtime);
target = WEIGHT_ONE * MARGIN_TARGET_PCT / 100;
- new_hwi = div64_s64(WEIGHT_ONE * usage, WEIGHT_ONE - target + delta);
+ new_hwi = div64_s64((s64)WEIGHT_ONE * usage,
+ WEIGHT_ONE - target + delta);
return clamp_t(s64, new_hwi, 1, hwm);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 445/742] block: Keep RPM_ACTIVE in blk_pre_runtime_resume() when already active
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (435 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 444/742] blk-iocost: Fix overflow in donation weight calculation Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 446/742] Bluetooth: hci_qca: clear qca_memdump when discarding dump packets Greg Kroah-Hartman
` (289 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Bart Van Assche, Stanley Jhu,
Rafael J. Wysocki (Intel), Jens Axboe
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <stanleyjhu@google.com>
commit 657d7c48b84f2ef0bf885b47cf2318823bc72970 upstream.
Since commit eef1d74bf88f ("PM: runtime: Only set runtime_error on
suspend callback failures"), a failed runtime resume leaves
dev->power.runtime_error at 0 with runtime_status set to RPM_SUSPENDED,
so later runtime resume requests run sdev_runtime_resume() again:
1. A runtime suspend increments q->pm_only from 0 to 1 and sets
q->rpm_status to RPM_SUSPENDED.
2. The first runtime resume fails in the driver callback, and
blk_post_runtime_resume() sets q->rpm_status to RPM_ACTIVE and calls
blk_clear_pm_only(), decrementing q->pm_only from 1 to 0 so recovery
commands can enter the queue (intended since
commit 6e1fcab00a23 ("scsi: block: pm: Always set request queue
runtime active in blk_post_runtime_resume()")).
3. A retried runtime resume calls blk_pre_runtime_resume(), which
overwrites q->rpm_status from RPM_ACTIVE to RPM_RESUMING, so
blk_post_runtime_resume() sees old_status != RPM_ACTIVE and calls
blk_clear_pm_only() a second time without a matching
blk_set_pm_only().
4. q->pm_only underflows from 0 to -1 (triggering WARN_ON_ONCE in
blk_clear_pm_only()), blocking non-PM requests in blk_queue_enter()
and __bio_queue_enter() while the device is RPM_ACTIVE, and the next
runtime suspend increments q->pm_only from -1 to 0, letting non-PM
requests dispatch while RPM_SUSPENDED. This hits the UFS device
well-known LUN by default and SCSI disks with
manage_runtime_start_stop enabled (ATA and FireWire sbp2 defaults).
Transition q->rpm_status to RPM_RESUMING in blk_pre_runtime_resume()
only when it is RPM_SUSPENDED, and call blk_clear_pm_only() in
blk_post_runtime_resume() only when old_status is RPM_RESUMING, pairing
each clear with a completed runtime suspend.
Tested on QEMU ARM64 UFS in SDB and MCQ modes by injecting
runtime-resume START STOP UNIT failures on the UFS device well-known
LUN, confirming zero pm_only underflows and balanced runtime PM cycles.
Fixes: eef1d74bf88f ("PM: runtime: Only set runtime_error on suspend callback failures")
Cc: stable@vger.kernel.org # v7.3+
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Link: https://patch.msgid.link/20261104112744.1630864-1-stanleyjhu@google.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
block/blk-pm.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
--- a/block/blk-pm.c
+++ b/block/blk-pm.c
@@ -142,7 +142,8 @@ EXPORT_SYMBOL(blk_post_runtime_suspend);
*
* Description:
* Update the queue's runtime status to RESUMING in preparation for the
- * runtime resume of the device.
+ * runtime resume of the device if the queue is runtime suspended, or keep
+ * RPM_ACTIVE if a previous failed runtime resume already reactivated it.
*
* This function should be called near the start of the device's
* runtime_resume callback.
@@ -153,7 +154,9 @@ void blk_pre_runtime_resume(struct reque
return;
spin_lock_irq(&q->queue_lock);
- q->rpm_status = RPM_RESUMING;
+ /* Keep RPM_ACTIVE if a prior failed resume reactivated the queue. */
+ if (q->rpm_status == RPM_SUSPENDED)
+ q->rpm_status = RPM_RESUMING;
spin_unlock_irq(&q->queue_lock);
}
EXPORT_SYMBOL(blk_pre_runtime_resume);
@@ -168,8 +171,8 @@ EXPORT_SYMBOL(blk_pre_runtime_resume);
* driver or error handler will need to communicate with the device.
*
* This function should be called near the end of the device's
- * runtime_resume callback to correct queue runtime PM status and re-enable
- * peeking requests from the queue.
+ * runtime_resume callback to mark the queue runtime active and clear
+ * pm_only if the queue was resuming.
*/
void blk_post_runtime_resume(struct request_queue *q)
{
@@ -185,7 +188,7 @@ void blk_post_runtime_resume(struct requ
pm_request_autosuspend(q->dev);
spin_unlock_irq(&q->queue_lock);
- if (old_status != RPM_ACTIVE)
+ if (old_status == RPM_RESUMING)
blk_clear_pm_only(q);
}
EXPORT_SYMBOL(blk_post_runtime_resume);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 446/742] Bluetooth: hci_qca: clear qca_memdump when discarding dump packets
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (436 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 445/742] block: Keep RPM_ACTIVE in blk_pre_runtime_resume() when already active Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 447/742] Bluetooth: MGMT: Fix runtime config status opcode Greg Kroah-Hartman
` (288 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Joas Antonio dos Santos,
Luiz Augusto von Dentz
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <joasantonio108@gmail.com>
commit 45a25a1bfd267d9e420119a48e5291d7882395df upstream.
qca_controller_memdump() frees qca_memdump when a memdump packet with a
non-zero sequence number arrives while QCA_MEMDUMP_COLLECTION is not
set, but leaves qca->qca_memdump pointing at the freed object.
The next run of the work reads the stale pointer into its local
variable, skips the allocation and uses the freed memory. Another
packet with a non-zero sequence number frees it a second time, and a
packet with sequence number 0 writes ram_dump_size, current_seq_no and
received_dump into it.
The original code cleared the pointer here; the assignment was dropped
when the condition was changed to test QCA_MEMDUMP_COLLECTION. All
other places that free the structure clear the pointer.
A controller that sends two memdump events without a leading sequence
number 0 can trigger a use-after-free or double free of a kmalloc
object.
Found by LLM-assisted source review.
Fixes: 06d3fdfcdf5c ("Bluetooth: hci_qca: Add qcom devcoredump support")
Cc: stable@vger.kernel.org
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/bluetooth/hci_qca.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1132,6 +1132,7 @@ static void qca_controller_memdump(struc
if (!test_bit(QCA_MEMDUMP_COLLECTION, &qca->flags)) {
bt_dev_err(hu->hdev, "QCA: Discarding other packets");
kfree(qca_memdump);
+ qca->qca_memdump = NULL;
kfree_skb(skb);
mutex_unlock(&qca->hci_memdump_lock);
return;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 447/742] Bluetooth: MGMT: Fix runtime config status opcode
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (437 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 446/742] Bluetooth: hci_qca: clear qca_memdump when discarding dump packets Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 448/742] bpf: Restrict uprobe ctx writes to the registers ptrace can set Greg Kroah-Hartman
` (287 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Xu Rao, Luiz Augusto von Dentz
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Rao <raoxu@uniontech.com>
commit 4728474344793dd67956e03a2cb244b71383ef7c upstream.
The Set Default Runtime Configuration command uses opcode 0x004e,
but set_def_runtime_config() reports its invalid-parameter status with
the Set Default System Configuration opcode, 0x004c.
A management client that matches Command Status events to its pending
request by opcode therefore cannot associate the response with the
request it sent. Runtime configuration parameters are not implemented,
so the command still returns MGMT_STATUS_INVALID_PARAMS.
Use MGMT_OP_SET_DEF_RUNTIME_CONFIG for the status event so the response
identifies the command that was actually handled.
Fixes: aececa645dc7 ("Bluetooth: mgmt: Add commands for runtime configuration")
Signed-off-by: Xu Rao <raoxu@uniontech.com>
Cc: stable@vger.kernel.org
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/bluetooth/mgmt_config.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/net/bluetooth/mgmt_config.c
+++ b/net/bluetooth/mgmt_config.c
@@ -370,6 +370,6 @@ int set_def_runtime_config(struct sock *
{
bt_dev_dbg(hdev, "sock %p", sk);
- return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEF_SYSTEM_CONFIG,
+ return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_DEF_RUNTIME_CONFIG,
MGMT_STATUS_INVALID_PARAMS);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 448/742] bpf: Restrict uprobe ctx writes to the registers ptrace can set
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (438 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 447/742] Bluetooth: MGMT: Fix runtime config status opcode Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 449/742] capabilities: Check PR_SET_SECUREBITS with ns_capable() Greg Kroah-Hartman
` (286 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, rtm, Alexei Starovoitov, Jiri Olsa
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <jolsa@kernel.org>
commit ca44731a7009da1dbcdf1979438d1985d93331d1 upstream.
Since commit 7384893d970e ("bpf: Allow uprobe program to change context
registers") a uprobe program can write any field of struct pt_regs.
Some of those fields are not plain user registers. The exit to user
space loads them into the CPU:
arch field exit path ptrace
------ ------ ------------------------------- ------------------
riscv status csrw CSR_STATUS, a0 not in the regset
arm64 pstate msr spsr_el1, x22 valid_user_regs()
x86-64 cs, ss (cs & 3) == 0: iretq to ring 0 set_segment_reg()
x86-64 flags iretq loads IF and IOPL set_flags()
On riscv a program that sets sstatus.SPP in pt_regs.status makes
ret_from_exception return to user code in supervisor mode. On x86-64 a
program that writes a kernel selector to cs makes iretq return to
ring 0.
ptrace guards these fields, but the bpf verifier does not.
Add arch_uprobe_regs_writable(). Each arch lists the registers that
ptrace can set to any value, and kprobe_prog_is_valid_access() rejects
writes to any other offset when the program is loaded:
arm64: x0 to x30, sp, pc
riscv: epc, ra to t6
x86-64: r15 to di, ip, sp
The default is no writes, so arches without a list (and 32-bit x86)
lose ctx writes for uprobe programs. Reads are not affected.
flags on x86-64 and pstate on arm64 become read-only, including the
condition bits that ptrace would let a debugger change. orig_ax is
read-only too.
Kprobe programs that write ctx were already rejected when they were
attached. Those that write one of these fields now fail to load.
Fixes: 7384893d970e ("bpf: Allow uprobe program to change context registers")
Reported-by: rtm@csail.mit.edu
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261118084451.12590-2-jolsa@kernel.org
Closes: https://lore.kernel.org/bpf/30318.1794850523@30-11-166.wireless.csail.mit.edu/
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm64/kernel/probes/uprobes.c | 6 ++++++
arch/riscv/kernel/probes/uprobes.c | 6 ++++++
arch/x86/kernel/uprobes.c | 15 +++++++++++++++
include/linux/uprobes.h | 5 +++++
kernel/events/uprobes.c | 9 +++++++++
kernel/trace/bpf_trace.c | 10 +++++++++-
6 files changed, 50 insertions(+), 1 deletion(-)
--- a/arch/arm64/kernel/probes/uprobes.c
+++ b/arch/arm64/kernel/probes/uprobes.c
@@ -152,6 +152,12 @@ bool arch_uretprobe_is_alive(struct retu
return regs->sp < ret->stack;
}
+bool arch_uprobe_regs_writable(int off, int size)
+{
+ /* From x0 to x30, sp, pc. */
+ return off + size <= offsetof(struct pt_regs, pstate);
+}
+
unsigned long
arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr,
struct pt_regs *regs)
--- a/arch/riscv/kernel/probes/uprobes.c
+++ b/arch/riscv/kernel/probes/uprobes.c
@@ -126,6 +126,12 @@ bool arch_uretprobe_is_alive(struct retu
return regs->sp < ret->stack;
}
+bool arch_uprobe_regs_writable(int off, int size)
+{
+ /* epc, from ra to t6. */
+ return off + size <= offsetof(struct pt_regs, status);
+}
+
unsigned long
arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr,
struct pt_regs *regs)
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -1888,6 +1888,21 @@ bool arch_uretprobe_is_alive(struct retu
return regs->sp <= ret->stack;
}
+bool arch_uprobe_regs_writable(int off, int size)
+{
+ int end = off + size;
+
+ /* The 32-bit pt_regs has segments in front of orig_ax. */
+ if (!IS_ENABLED(CONFIG_X86_64))
+ return false;
+ /* From r15 to di. Not orig_ax, cs, flags, ss. */
+ if (end <= offsetof(struct pt_regs, orig_ax))
+ return true;
+ if (off >= offsetof(struct pt_regs, ip) && end <= offsetofend(struct pt_regs, ip))
+ return true;
+ return off >= offsetof(struct pt_regs, sp) && end <= offsetofend(struct pt_regs, sp);
+}
+
/*
* Heuristic-based check if uprobe is installed at the function entry.
*
--- a/include/linux/uprobes.h
+++ b/include/linux/uprobes.h
@@ -239,6 +239,7 @@ extern void uprobe_copy_from_page(struct
extern void handle_syscall_uprobe(struct pt_regs *regs, unsigned long bp_vaddr);
extern void arch_uprobe_optimize(struct arch_uprobe *auprobe, unsigned long vaddr);
extern unsigned long arch_uprobe_get_xol_area(void);
+extern bool arch_uprobe_regs_writable(int off, int size);
#else /* !CONFIG_UPROBES */
struct uprobes_state {
};
@@ -300,5 +301,9 @@ static inline void uprobe_copy_process(s
static inline void uprobe_clear_state(struct mm_struct *mm)
{
}
+static inline bool arch_uprobe_regs_writable(int off, int size)
+{
+ return false;
+}
#endif /* !CONFIG_UPROBES */
#endif /* _LINUX_UPROBES_H */
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -2704,6 +2704,15 @@ void __weak arch_uprobe_optimize(struct
}
/*
+ * Can a bpf prog write these bytes of pt_regs? An arch opts in and lists the
+ * registers that ptrace can set to any value.
+ */
+bool __weak arch_uprobe_regs_writable(int off, int size)
+{
+ return false;
+}
+
+/*
* Run handler and ask thread to singlestep.
* Ensure all non-fatal signals cannot interrupt thread while it singlesteps.
*/
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1390,8 +1390,16 @@ static bool kprobe_prog_is_valid_access(
if (off + size > sizeof(struct pt_regs))
return false;
- if (type == BPF_WRITE)
+ if (type == BPF_WRITE) {
+ /*
+ * pt_regs also holds what the kernel restores on the way to
+ * user space: cs and flags on x86, pstate on arm64, status on
+ * riscv. A prog can write the registers of the task only.
+ */
+ if (!arch_uprobe_regs_writable(off, size))
+ return false;
prog->aux->kprobe_write_ctx = true;
+ }
return true;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 449/742] capabilities: Check PR_SET_SECUREBITS with ns_capable()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (439 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 448/742] bpf: Restrict uprobe ctx writes to the registers ptrace can set Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 450/742] clang-format: Fix formatting of guard() Greg Kroah-Hartman
` (285 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christian Brauner,
Günther Noack, James Morris, John Johansen, KP Singh,
Matt Bobrowski, Paul Moore, Serge Hallyn, Stephen Smalley,
Serge Hallyn (AMD), Mickaël Salaün
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <mic@digikod.net>
commit 2ff5a29db0f542226d5bd029459de9703fc2a2ae upstream.
PR_SET_SECUREBITS checks CAP_SETPCAP with cap_capable(), which skips the
LSM capable hooks, so a task can change privileged securebits despite an
LSM denial.
Use ns_capable() instead, as PR_CAPBSET_DROP already does. Move the
check to a helper that only requires CAP_SETPCAP when needed, so that
changes limited to the unprivileged securebits still do not reach the
LSMs or set PF_SUPERPRIV.
Cc: Christian Brauner <brauner@kernel.org>
Cc: Günther Noack <gnoack@google.com>
Cc: James Morris <jmorris@namei.org>
Cc: John Johansen <john.johansen@canonical.com>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Matt Bobrowski <matt@bobrowski.net>
Cc: Paul Moore <paul@paul-moore.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Stephen Smalley <stephen.smalley.work@gmail.com>
Cc: stable@vger.kernel.org
Reviewed-by: Serge Hallyn (AMD) <sergeh@kernel.org>
Fixes: 3898b1b4ebff ("capabilities: implement per-process securebits")
Link: https://patch.msgid.link/20261118145431.2551578-2-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/commoncap.c | 45 +++++++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 22 deletions(-)
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -1283,6 +1283,26 @@ static int cap_prctl_drop(unsigned long
return commit_creds(new);
}
+/*
+ * Doing anything with securebits requires privilege (go read about the
+ * "sendmail capabilities bug"), except for unprivileged bits. Indeed, the
+ * SECURE_ALL_UNPRIVILEGED bits are not restrictions enforced by the kernel but
+ * by user space on itself. Only checking CAP_SETPCAP when it is needed keeps
+ * LSMs from seeing (and logging) a capability check for unprivileged changes.
+ */
+static bool securebits_need_setpcap(unsigned long old, unsigned long new)
+{
+ const unsigned long unpriv_and_locks = SECURE_ALL_UNPRIVILEGED |
+ SECURE_ALL_UNPRIVILEGED << 1;
+ const unsigned long changed = old ^ new;
+
+ /* For legacy reasons, a non-change requires privilege. */
+ if (!changed)
+ return true;
+
+ return changed & ~unpriv_and_locks;
+}
+
/**
* cap_task_prctl - Implement process control functions for this security module
* @option: The process control function requested
@@ -1346,28 +1366,9 @@ int cap_task_prctl(int option, unsigned
/* cannot change a locked bit */
return -EPERM;
- /*
- * Doing anything requires privilege (go read about the
- * "sendmail capabilities bug"), except for unprivileged bits.
- * Indeed, the SECURE_ALL_UNPRIVILEGED bits are not
- * restrictions enforced by the kernel but by user space on
- * itself.
- */
- if (cap_capable(current_cred(), current_cred()->user_ns,
- CAP_SETPCAP, CAP_OPT_NONE) != 0) {
- const unsigned long unpriv_and_locks =
- SECURE_ALL_UNPRIVILEGED |
- SECURE_ALL_UNPRIVILEGED << 1;
- const unsigned long changed = old->securebits ^ arg2;
-
- /* For legacy reason, denies non-change. */
- if (!changed)
- return -EPERM;
-
- /* Denies privileged changes. */
- if (changed & ~unpriv_and_locks)
- return -EPERM;
- }
+ if (securebits_need_setpcap(old->securebits, arg2) &&
+ !ns_capable(current_user_ns(), CAP_SETPCAP))
+ return -EPERM;
new = prepare_creds();
if (!new)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 450/742] clang-format: Fix formatting of guard()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (440 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 449/742] capabilities: Check PR_SET_SECUREBITS with ns_capable() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 451/742] cpufreq: CPPC: Set CPPC Enable register in cpu_init() Greg Kroah-Hartman
` (284 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Andrew Morton, Günther Noack,
Ingo Molnar, Miguel Ojeda, Peter Zijlstra, Bart Van Assche,
Mickaël Salaün
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <mic@digikod.net>
commit b2a9f2d43bbdf6dcf178e300c815816a4fe4447d upstream.
The previous fix was overzealous and included guard() along with
scoped_guard(), but only the later takes curly braces.
The original fix introduced this issue:
- guard(rcu)();
+ guard(rcu)
+ ();
This is especially visible with security/landlock/*.[ch] which is fully
formatted with clang-format.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Günther Noack <gnoack@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
Fixes: 99df2a8eba34 ("clang-format: fix formatting of guard() and scoped_guard() statements")
Closes: https://lore.kernel.org/r/20260702.Eibibi4the9j@digikod.net
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20260708105713.2073335-1-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
.clang-format | 1 -
1 file changed, 1 deletion(-)
diff --git a/.clang-format b/.clang-format
index 395292ab2ac6..ce170c0af717 100644
--- a/.clang-format
+++ b/.clang-format
@@ -481,7 +481,6 @@ ForEachMacros:
- 'genradix_for_each'
- 'genradix_for_each_from'
- 'genradix_for_each_reverse'
- - 'guard'
- 'hash_for_each'
- 'hash_for_each_possible'
- 'hash_for_each_possible_rcu'
--
2.56.1
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 451/742] cpufreq: CPPC: Set CPPC Enable register in cpu_init()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (441 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 450/742] clang-format: Fix formatting of guard() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 452/742] cpufreq: Skip inactive policies in cpufreq_driver_target() Greg Kroah-Hartman
` (283 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sumit Gupta, Christian Loehle,
Rafael J. Wysocki
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sumit Gupta <sumitg@nvidia.com>
commit 7cca01c39cc89f6ef39079484d26b6d99287a610 upstream.
As per ACPI 6.x s8.4.6.1.4 (CPPC Enable Register):
"If supported by the platform, OSPM writes a one to this register
to enable CPPC on this processor. If not implemented, OSPM assumes
the platform always has CPPC enabled."
The driver never writes this register. CPPC therefore stays disabled
on platforms such as NVIDIA GB10 that wait for OSPM to enable it.
Call cppc_set_enable() in cppc_cpufreq_cpu_init(). Fail init if
enabling CPPC fails. If init fails after CPPC is enabled, disable it
again. The register is optional, so -EOPNOTSUPP is not an error.
Fixes: 5477fb3bd1e8 ("ACPI / CPPC: Add a CPUFreq driver for use with CPPC")
Cc: All applicable <stable@vger.kernel.org> # ab482f1bac6b "ACPI: CPPC: Refactor register value get and set ABIs"
Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
[ rjw: Subject tweak ]
Link: https://patch.msgid.link/20261110101246.3665797-1-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/cpufreq/cppc_cpufreq.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -719,7 +719,17 @@ static int cppc_cpufreq_cpu_init(struct
pr_debug("Unsupported CPU co-ord type: %d\n",
policy->shared_type);
ret = -EFAULT;
- goto out;
+ goto out_put;
+ }
+
+ /*
+ * Enable CPPC. The Enable register is optional - some platforms
+ * may not support it.
+ */
+ ret = cppc_set_enable(cpu, true);
+ if (ret && ret != -EOPNOTSUPP) {
+ pr_err("Failed to enable CPPC for CPU%u (%d)\n", cpu, ret);
+ goto out_put;
}
policy->fast_switch_possible = cppc_allow_fast_switch(policy->cpus);
@@ -747,6 +757,8 @@ static int cppc_cpufreq_cpu_init(struct
return 0;
out:
+ cppc_set_enable(cpu, false);
+out_put:
cppc_cpufreq_put_cpu_data(policy);
return ret;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 452/742] cpufreq: Skip inactive policies in cpufreq_driver_target()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (442 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 451/742] cpufreq: CPPC: Set CPPC Enable register in cpu_init() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 453/742] dma-coherent: serialize reserved memory pool initialization Greg Kroah-Hartman
` (282 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Zhongqiu Han,
Rafael J. Wysocki
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
commit c5bdb87573726d3a10c58bb3ae09daf017be2297 upstream.
A policy obtained with cpufreq_cpu_get() may become inactive before
cpufreq_driver_target() acquires its rwsem, which may lead to a NULL
pointer dereference:
CPU X CPU Y (last CPU in policy)
cpufreq_cpu_get()
cpufreq_offline()
__cpufreq_offline()
->exit() /* frees freq_table */
policy->freq_table = NULL
cpufreq_driver_target()
__cpufreq_driver_target()
__target_index()
policy->freq_table[index] /* NULL dereference */
Before commit 2372784542cb ("cpufreq: Drop 'freq_table' argument of
__target_index()"), __cpufreq_driver_target() returned an error if
policy->freq_table was NULL. Since the offline path clears it under the
policy rwsem, which cpufreq_driver_target() also holds, that check was
sufficient to prevent the crash.
The race has been reachable in-tree since commit c210063b40ac
("cpufreq: mediatek: Add opp notification support"), which added the
first caller of cpufreq_driver_target() that can run concurrently with
CPU offline.
Address this by making cpufreq_driver_target() return -EBUSY if the
policy is inactive after acquiring its rwsem, in analogy with the checks
in cpufreq_get(), refresh_frequency_limits() and the sysfs show() and
store() callbacks.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20261104153042.3987338-1-zhongqiu.han%40oss.qualcomm.com
Fixes: 2372784542cb ("cpufreq: Drop 'freq_table' argument of __target_index()")
Fixes: c210063b40ac ("cpufreq: mediatek: Add opp notification support")
Cc: 5.19+ <stable@vger.kernel.org> # v5.19+
Signed-off-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
Link: https://patch.msgid.link/20261110135814.621355-1-zhongqiu.han@oss.qualcomm.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/cpufreq/cpufreq.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2452,6 +2452,14 @@ int cpufreq_driver_target(struct cpufreq
{
guard(cpufreq_policy_write)(policy);
+ /*
+ * The last CPU in the policy may have gone offline after the caller
+ * obtained it, in which case the policy is inactive and must not be
+ * used for changing the frequency.
+ */
+ if (unlikely(policy_is_inactive(policy)))
+ return -EBUSY;
+
return __cpufreq_driver_target(policy, target_freq, relation);
}
EXPORT_SYMBOL_GPL(cpufreq_driver_target);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 453/742] dma-coherent: serialize reserved memory pool initialization
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (443 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 452/742] cpufreq: Skip inactive policies in cpufreq_driver_target() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 454/742] dma-pool: release CMA pages on atomic_pool_expand() error path Greg Kroah-Hartman
` (281 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Marek Szyprowski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <m.szyprowski@samsung.com>
commit 494f40ffabcdc8d9fa4012b2c972690f25a0a40f upstream.
Multiple devices can share the same "shared-dma-pool" reserved memory
region, in which case the dma_coherent_mem structure is created by the
first device attached to it and stored in rmem->priv. To avoid the
potential race, serialize the check and initialization of rmem->priv
with a mutex.
Fixes: 7bfa5ab6fa1b ("drivers: dma-coherent: add initialization from device tree")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20261026095423.966856-2-m.szyprowski@samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/dma/coherent.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--- a/kernel/dma/coherent.c
+++ b/kernel/dma/coherent.c
@@ -7,6 +7,7 @@
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/dma-direct.h>
#include <linux/dma-map-ops.h>
@@ -335,10 +336,18 @@ static phys_addr_t dma_reserved_default_
static phys_addr_t dma_reserved_default_memory_size __initdata;
#endif
+static DEFINE_MUTEX(rmem_dma_mutex);
+
static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
{
- struct dma_coherent_mem *mem = rmem->priv;
+ struct dma_coherent_mem *mem;
+ /*
+ * Multiple devices can share the same pool and may be probed
+ * concurrently, so serialize the initialization of rmem->priv.
+ */
+ guard(mutex)(&rmem_dma_mutex);
+ mem = rmem->priv;
if (!mem) {
mem = dma_init_coherent_memory(rmem->base, rmem->base,
rmem->size, true);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 454/742] dma-pool: release CMA pages on atomic_pool_expand() error path
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (444 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 453/742] dma-coherent: serialize reserved memory pool initialization Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 455/742] dma: swiotlb: Properly tear down the default pool on exit Greg Kroah-Hartman
` (280 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Marek Szyprowski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <m.szyprowski@samsung.com>
commit ca010d38da7bf05a4572a54c2c16d6d64a758c3a upstream.
atomic_pool_expand() may allocate the pool backing pages from CMA via
dma_alloc_from_contiguous(), but the error path unconditionally frees
them with __free_pages(). This hands CMA pages to the buddy allocator
while leaving them marked as allocated in the CMA bitmap, permanently
leaking CMA capacity on every failed expansion.
Try dma_release_from_contiguous() first and fall back to __free_pages()
only for pages that did not come from CMA, as the code did before CMA
allocation was temporarily removed from the pool.
Fixes: d7e673ec2c8e ("dma-pool: Only allocate from CMA when in same memory zone")
Closes: https://sashiko.dev/#/bug/linux-fdfc6e83-15e4-4980-9818-691b034397e7
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20261026095423.966856-5-m.szyprowski@samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/dma/pool.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/kernel/dma/pool.c
+++ b/kernel/dma/pool.c
@@ -152,7 +152,8 @@ remove_mapping:
dma_common_free_remap(addr, pool_size);
free_page:
#endif
- if (!leak_pages)
+ if (!leak_pages &&
+ !dma_release_from_contiguous(NULL, page, 1 << order))
__free_pages(page, order);
out:
return ret;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 455/742] dma: swiotlb: Properly tear down the default pool on exit
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (445 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 454/742] dma-pool: release CMA pages on atomic_pool_expand() error path Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 456/742] dma: swiotlb: Round restricted DMA pool size down to IO_TLB_SEGSIZE Greg Kroah-Hartman
` (279 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Marek Szyprowski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <m.szyprowski@samsung.com>
commit 7d4a177d0d9bc0ca04caec9293ccb902a853cc47 upstream.
With CONFIG_SWIOTLB_DYNAMIC enabled, the default memory pool is added to
the io_tlb_default_mem.pools RCU list during initialization. When an IOMMU
takes over DMA translation, swiotlb_exit() tears the default pool down and
clears it with memset(), but leaves its node on the pools list. The list
then contains a zeroed entry with a NULL next pointer, and any later walk
of the list, for example mem_used() when reading the io_tlb_used debugfs
file, dereferences an invalid pointer and crashes.
swiotlb_exit() also leaves the io_tlb_default_mem fields that describe
the pool. io_tlb_default_mem.nslabs and can_grow stay set, so
is_swiotlb_allocated() and is_swiotlb_active() keep returning true, and
swiotlb_find_slots() can schedule dynamic pool allocation after teardown.
Without CONFIG_SWIOTLB_DYNAMIC, a later mapping can reach the zeroed
defpool and hit BUG_ON(area_index >= pool->nareas). Before the pool data
was split out of struct io_tlb_mem, swiotlb_exit() cleared the whole
structure, including nslabs.
Clear can_grow and cancel any pending dyn_alloc work, then remove the
default pool from the list and subtract its slots from nslabs, and wait
for an RCU grace period before clearing it, so that no reader can still
see it. Without CONFIG_SWIOTLB_DYNAMIC, reset nslabs directly.
As a result, with CONFIG_SWIOTLB_DYNAMIC swiotlb no longer silently keeps
working through dynamic or transient pools after an IOMMU has turned it
off, so for example dma-iommu bouncing for untrusted devices reports that
bounce buffers are inactive, as it did before the dynamic pools support.
Fixes: 158dbe9c9a3d ("swiotlb: separate memory pool data from other allocator data")
Fixes: 62708b2ba405 ("swiotlb: add a flag whether SWIOTLB is allowed to grow")
Fixes: 1aaa736815eb ("swiotlb: allocate a new memory pool when existing pools are full")
Closes: https://sashiko.dev/#/bug/linux-f75998aa-65ea-4596-9bb4-fa83773012a3
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20261109170603.385791-1-m.szyprowski@samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/dma/swiotlb.c | 11 +++++++++++
1 file changed, 11 insertions(+)
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -666,6 +666,17 @@ void __init swiotlb_exit(void)
return;
pr_info("tearing down default memory pool\n");
+#ifdef CONFIG_SWIOTLB_DYNAMIC
+ io_tlb_default_mem.can_grow = false;
+ cancel_work_sync(&io_tlb_default_mem.dyn_alloc);
+ spin_lock(&io_tlb_default_mem.lock);
+ list_del_rcu(&mem->node);
+ io_tlb_default_mem.nslabs -= mem->nslabs;
+ spin_unlock(&io_tlb_default_mem.lock);
+ synchronize_rcu();
+#else
+ io_tlb_default_mem.nslabs = 0;
+#endif
tbl_vaddr = (unsigned long)phys_to_virt(mem->start);
tbl_size = PAGE_ALIGN(mem->end - mem->start);
slots_size = PAGE_ALIGN(array_size(sizeof(*mem->slots), mem->nslabs));
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 456/742] dma: swiotlb: Round restricted DMA pool size down to IO_TLB_SEGSIZE
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (446 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 455/742] dma: swiotlb: Properly tear down the default pool on exit Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 457/742] dma: swiotlb: Serialize restricted DMA pool initialization Greg Kroah-Hartman
` (278 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Giorgi Kobakhia, Michael Kelley,
Marek Szyprowski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <m.szyprowski@samsung.com>
commit 5b4b87935bf9c6c81b603558c2e167fc27c22a1b upstream.
All other paths creating a swiotlb pool ensure that nslabs is a multiple
of IO_TLB_SEGSIZE, and the swiotlb code relies on that. Since commit
0b84e4f8b793 ("swiotlb: Add restricted DMA pool initialization") a
restricted pool can have an arbitrary size taken from the device tree.
If the pool size is not a multiple of IO_TLB_SEGSIZE, the last segment is
partial and swiotlb_release_slots() reads mem->slots[index + nslabs],
which is one past the end of the slots array when the freed buffer ends
at the end of the pool:
BUG: KASAN: slab-out-of-bounds in swiotlb_release_slots
Read of size 2
Round the pool size down to a multiple of IO_TLB_SEGSIZE, wasting a bit
of memory, and warn about it.
Reported-by: Giorgi Kobakhia <gkobakhi@asu.edu>
Closes: https://lore.kernel.org/all/20261026032007.1957949-1-gkobakhi@asu.edu/
Fixes: 0b84e4f8b793 ("swiotlb: Add restricted DMA pool initialization")
CC: stable@vger.kernel.org
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Link: https://lore.kernel.org/r/20261103155016.1107958-1-m.szyprowski@samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/dma/swiotlb.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -2020,6 +2020,19 @@ static int rmem_swiotlb_device_init(stru
*/
if (!mem) {
struct io_tlb_pool *pool;
+ unsigned long aligned_nslabs = ALIGN_DOWN(nslabs, IO_TLB_SEGSIZE);
+
+ if (aligned_nslabs != nslabs) {
+ dev_warn(dev, "Restricted DMA pool size %zu is not a multiple of %lu, rounding down to %lu bytes\n",
+ (size_t)rmem->size,
+ (unsigned long)IO_TLB_SEGSIZE << IO_TLB_SHIFT,
+ aligned_nslabs << IO_TLB_SHIFT);
+ nslabs = aligned_nslabs;
+ }
+ if (!nslabs) {
+ dev_err(dev, "Restricted DMA pool is too small\n");
+ return -EINVAL;
+ }
mem = kzalloc_obj(*mem);
if (!mem)
@@ -2047,7 +2060,7 @@ static int rmem_swiotlb_device_init(stru
mem->cc_shared = true;
ret = set_memory_decrypted((unsigned long)phys_to_virt(rmem->base),
- rmem->size >> PAGE_SHIFT);
+ (nslabs << IO_TLB_SHIFT) >> PAGE_SHIFT);
if (ret) {
dev_err(dev, "Failed to decrypt restricted DMA pool\n");
kfree(pool->areas);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 457/742] dma: swiotlb: Serialize restricted DMA pool initialization
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (447 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 456/742] dma: swiotlb: Round restricted DMA pool size down to IO_TLB_SEGSIZE Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 458/742] EDAC/i5000: Fix slot number passed to determine_mtr() Greg Kroah-Hartman
` (277 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Marek Szyprowski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <m.szyprowski@samsung.com>
commit 7ad92b81b415de806957b19828fc4777a9cf2216 upstream.
Multiple devices can share the same restricted DMA pool, in which case
the io_tlb_mem structure is allocated and initialized by the first
device attached to it and stored in rmem->priv. To avoid the potential
race, serialize the check and initialization of rmem->priv with a mutex.
Fixes: 0b84e4f8b793 ("swiotlb: Add restricted DMA pool initialization")
Closes: https://sashiko.dev/#/bug/linux-6fda7589-591d-4a68-b6e1-b1561f867319
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20261026095423.966856-3-m.szyprowski@samsung.com
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/dma/swiotlb.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -35,6 +35,7 @@
#include <linux/init.h>
#include <linux/memblock.h>
#include <linux/mm.h>
+#include <linux/mutex.h>
#include <linux/pfn.h>
#include <linux/rculist.h>
#include <linux/scatterlist.h>
@@ -1999,10 +2000,12 @@ void swiotlb_free_from_pool(struct devic
swiotlb_release_slots(dev, tlb_addr, pool);
}
+static DEFINE_MUTEX(rmem_swiotlb_mutex);
+
static int rmem_swiotlb_device_init(struct reserved_mem *rmem,
struct device *dev)
{
- struct io_tlb_mem *mem = rmem->priv;
+ struct io_tlb_mem *mem;
unsigned long nslabs = rmem->size >> IO_TLB_SHIFT;
/* Set Per-device io tlb area to one */
@@ -2016,8 +2019,10 @@ static int rmem_swiotlb_device_init(stru
/*
* Since multiple devices can share the same pool, the private data,
* io_tlb_mem struct, will be initialized by the first device attached
- * to it.
+ * to it. Serialize this, as devices may be probed concurrently.
*/
+ guard(mutex)(&rmem_swiotlb_mutex);
+ mem = rmem->priv;
if (!mem) {
struct io_tlb_pool *pool;
unsigned long aligned_nslabs = ALIGN_DOWN(nslabs, IO_TLB_SEGSIZE);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 458/742] EDAC/i5000: Fix slot number passed to determine_mtr()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (448 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 457/742] dma: swiotlb: Serialize restricted DMA pool initialization Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 459/742] fault-inject: fix boot failure with fault injection boot parameters Greg Kroah-Hartman
` (276 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Aristeu Rozanski, Andrew Luebke,
Borislav Petkov (AMD)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aristeu Rozanski <aris@redhat.com>
commit a088b092a8962db62327690ae2d0d68827e81229 upstream.
When the logic mapping branch/slot/channel was reworked back in
64e1fdaf55d6 ("i5000_edac: Fix the logic that retrieves memory information")
i5000_init_csrows() was not updated and kept passing twice the number
of slots to determine_mtr(), which leads to accessing past the end of
i5000_pvt.b1_mtr[]. This was found by KASAN.
Fixes: 64e1fdaf55d6 ("i5000_edac: Fix the logic that retrieves memory information")
Signed-off-by: Aristeu Rozanski <aris@redhat.com>
Signed-off-by: Andrew Luebke <andrew.luebke@gmail.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Andrew Luebke <andrew.luebke@gmail.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20220921181009.oxytvicy6sry6it7@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/edac/i5000_edac.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
--- a/drivers/edac/i5000_edac.c
+++ b/drivers/edac/i5000_edac.c
@@ -1253,14 +1253,12 @@ static int i5000_init_csrows(struct mem_
struct i5000_pvt *pvt;
struct dimm_info *dimm;
int empty;
- int max_csrows;
int mtr;
int csrow_megs;
int channel;
int slot;
pvt = mci->pvt_info;
- max_csrows = pvt->maxdimmperch * 2;
empty = 1; /* Assume NO memory */
@@ -1271,7 +1269,7 @@ static int i5000_init_csrows(struct mem_
* to map the dimms. A good cleanup would be to remove this array,
* and do a loop here with branch, channel, slot
*/
- for (slot = 0; slot < max_csrows; slot++) {
+ for (slot = 0; slot < pvt->maxdimmperch; slot++) {
for (channel = 0; channel < pvt->maxch; channel++) {
mtr = determine_mtr(pvt, slot, channel);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 459/742] fault-inject: fix boot failure with fault injection boot parameters
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (449 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 458/742] EDAC/i5000: Fix slot number passed to determine_mtr() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 460/742] fbcon: Avoid cancel_delayed_work_sync() in atomic context Greg Kroah-Hartman
` (275 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sang-Heon Jeon, Andrew Morton,
Akinobu Mita
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Heon Jeon <ekffu200098@gmail.com>
commit 27538caf7f72ce93be9c352148dba4f2274cf300 upstream.
Since commit e9bc360b105c ("fault-inject: use prandom where
cryptographically secure randomness is not needed"), setup_fault_attr()
calls prandom_init_once(), which calls kmalloc() and schedule_work().
But setup_fault_attr() can be called from __setup handlers before slab and
workqueues are initialized, so any fault injection boot parameter leads to
boot failure.
So use DO_ONCE_LITE() instead.
Link: https://lore.kernel.org/20261105160209.1504867-1-ekffu200098@gmail.com
Fixes: e9bc360b105c ("fault-inject: use prandom where cryptographically secure randomness is not needed")
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/fault-inject.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
lib/fault-inject.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/kernel.h>
#include <linux/init.h>
+#include <linux/once_lite.h>
#include <linux/prandom.h>
#include <linux/debugfs.h>
#include <linux/sched.h>
@@ -50,7 +51,12 @@ int setup_fault_attr(struct fault_attr *
return 0;
}
- prandom_init_once(&fault_rnd_state);
+ /*
+ * __setup handlers run before slab and workqueues are initialized,
+ * but prandom_init_once() calls kmalloc() and schedule_work(). So use
+ * DO_ONCE_LITE() instead.
+ */
+ DO_ONCE_LITE(prandom_seed_full_state, &fault_rnd_state);
attr->probability = probability;
attr->interval = interval;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 460/742] fbcon: Avoid cancel_delayed_work_sync() in atomic context
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (450 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 459/742] fault-inject: fix boot failure with fault injection boot parameters Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 461/742] fgraph: Allocate shadow stacks inline with GFP_NOWAIT Greg Kroah-Hartman
` (274 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Yao Yiqi, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yao Yiqi <yaoyiqi3@huawei.com>
commit b3a3f241dace3d4a775e1401b53a3f6d304534f0 upstream.
fbcon_cursor() can be reached from the console printing path, which runs
in atomic context. When the VT software cursor is enabled
(vc_cursor_type & CUR_SW), it calls fbcon_del_cursor_work(), which uses
cancel_delayed_work_sync() and therefore may sleep.
With CONFIG_DEBUG_ATOMIC_SLEEP enabled, the following is reported:
BUG: sleeping function called from invalid context at kernel/workqueue.c:4722
in_atomic(): 1, irqs_disabled(): 1, non_block: 0
...
__cancel_work_sync
fbcon_del_cursor_work
fbcon_cursor
hide_cursor
vt_console_print
console_unlock
...
Make the default helper safe: fbcon_del_cursor_work() only stops
blinking, using cancel_delayed_work(), which is allowed in any context.
Every "stop blinking" call site keeps using it, including fbcon_cursor().
Only fbcon_release(), which is about to free @par and must ensure that no
callback is still using it, calls the separate
fbcon_del_cursor_work_sync(). New call sites therefore get the safe
variant by default.
cancel_delayed_work() does not wait for a callback that is already
running. Since fb_flashcursor() re-arms itself, a callback that has
already been dequeued by process_one_work() can queue the work again
after fbcon_del_cursor_work() returns. Add a cursor_blink_on flag to
struct fbcon_par: fbcon_add_cursor_work() sets it, fbcon_del_cursor_work()
clears it, and fb_flashcursor() checks it after taking console_lock and
returns without drawing or re-arming once blinking has been stopped.
Keep the requeue inside the console_lock section so that the flag check
and the requeue are not split by a concurrent stop.
Fixes: 3b0fb6ab25dd ("fbcon: Use delayed work for cursor")
Cc: stable@vger.kernel.org
Assisted-by: Opencode:deepseek-v4.1-flash
Signed-off-by: Yao Yiqi <yaoyiqi3@huawei.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/core/fbcon.c | 41 +++++++++++++++++++++++++++++++++------
drivers/video/fbdev/core/fbcon.h | 1
2 files changed, 36 insertions(+), 6 deletions(-)
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -411,7 +411,8 @@ static void fb_flashcursor(struct work_s
if (par->currcon != -1)
vc = vc_cons[par->currcon].d;
- if (!vc || !con_is_visible(vc) ||
+ if (!par->cursor_blink_on ||
+ !vc || !con_is_visible(vc) ||
fbcon_info_from_console(vc->vc_num) != info ||
vc->vc_deccm != 1) {
console_unlock();
@@ -423,25 +424,53 @@ static void fb_flashcursor(struct work_s
par->bitops->cursor(vc, info, enable,
get_fg_color(vc, info, c),
get_bg_color(vc, info, c));
- console_unlock();
+ /*
+ * Re-arm under console_lock so that a concurrent
+ * fbcon_del_cursor_work() cannot race with this requeue.
+ */
queue_delayed_work(system_power_efficient_wq, &par->cursor_work,
par->cur_blink_jiffies);
+ console_unlock();
}
static void fbcon_add_cursor_work(struct fb_info *info)
{
struct fbcon_par *par = info->fbcon_par;
- if (fbcon_cursor_blink)
- queue_delayed_work(system_power_efficient_wq, &par->cursor_work,
- par->cur_blink_jiffies);
+ if (!fbcon_cursor_blink)
+ return;
+
+ par->cursor_blink_on = true;
+ queue_delayed_work(system_power_efficient_wq, &par->cursor_work,
+ par->cur_blink_jiffies);
}
+/*
+ * Stop the cursor blink.
+ *
+ * Does not wait for a callback that is already running, so it is safe to
+ * call from any context.
+ *
+ * console_lock serializes this with the requeue in fb_flashcursor();
+ * otherwise a running callback could re-arm the work.
+ */
static void fbcon_del_cursor_work(struct fb_info *info)
{
struct fbcon_par *par = info->fbcon_par;
+ par->cursor_blink_on = false;
+ cancel_delayed_work(&par->cursor_work);
+}
+
+/*
+ * Stop the cursor blink and wait for a running callback to finish before
+ * @par is freed. May sleep, only for teardown paths.
+ */
+static void fbcon_del_cursor_work_sync(struct fb_info *info)
+{
+ struct fbcon_par *par = info->fbcon_par;
+
cancel_delayed_work_sync(&par->cursor_work);
}
@@ -789,7 +818,7 @@ static void fbcon_release(struct fb_info
if (info->fbcon_par) {
struct fbcon_par *par = info->fbcon_par;
- fbcon_del_cursor_work(info);
+ fbcon_del_cursor_work_sync(info);
kfree(par->cursor_state.mask);
kfree(par->cursor_data);
kfree(par->cursor_src);
--- a/drivers/video/fbdev/core/fbcon.h
+++ b/drivers/video/fbdev/core/fbcon.h
@@ -97,6 +97,7 @@ struct fbcon_par {
int blank_state;
int graphics;
bool initialized;
+ bool cursor_blink_on;
int rotate;
char *cursor_data;
#ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 461/742] fgraph: Allocate shadow stacks inline with GFP_NOWAIT
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (451 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 460/742] fbcon: Avoid cancel_delayed_work_sync() in atomic context Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 462/742] fgraph: Do not mark index 0 in every shadow stack frame Greg Kroah-Hartman
` (273 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Peter Zijlstra, Vineet Gupta,
Andrii Nakryiko, Masami Hiramatsu (Google), Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vineet Gupta <vineet.gupta@linux.dev>
commit 700e5c063fd765fd09c1007ec8a927bddd82798b upstream.
When ftrace graphing is turned on, all tasks in the system missing
return stack page are assigned one. This is done in a simplistic
multi-sweep loop of FTRACE_RETSTACK_ALLOC_SIZE (currently 32) tasks
at a time as follows:
start_graph_tracing()
do {
alloc_retstack_tasklist
} while (-EAGAIN);
alloc_retstack_tasklist()
alloc x32 # GFP_KERNEL, may sleep
rcu_read_lock() # preempt off
for_each_process_thread walk N_total, no cond_resched
t->ret_stack = new_page
rcu_read_unlock() # preempt enable but no explicit yield
Each successive iteration of loop invokes for_each_process_thread()
which doesn't support cursor based resume and always restarts from the
init_task. Thus each successive loop needs to skip the tasks assigned
ret_stack in prior sweeps and thus take longer and longer to find the
candidate 32 tasks. And while the loop end calls rcu unlock,
and re-enables preemption briefly, there is no explicit yield.
The total number of iterations turn out to be
N_total * N_null / (2 * FTRACE_RETSTACK_ALLOC_SIZE)
where N_total is the number of threads on the system and N_null the number
of those whose ret_stack is still NULL. After boot with no fgraph user that
is every thread.
This is not a tracing-only path. Since commit 4346ba160409 ("fprobe:
Rewrite fprobe on function-graph tracer") fprobe is built on fgraph,
so an ordinary kprobe_multi BPF attach that flips ftrace_graph_active
from 0 to 1 pays the whole cost inside one bpf() syscall. Commit
2c67dc457bc6 ("tracing: fprobe: optimization for entry only case")
narrows that to return and session probes but does not remove it.
A host running hundreds of thousands of threads, with the current batch
size of 32, turns the ftrace_graph_active 0 -> 1 transition into a
multi-second, and eventually multi-minute, operation which showed up as
RCU stall and softlockup_panic on heavily loaded Meta Fleet machines
with preemption disabled.
rcu: INFO: rcu_sched self-detected stall on CPU
rcu: 0-....: (20718 ticks this GP) (t=21000 jiffies g=913 q=8 ncpus=8)
CPU: 0 UID: 0 PID: 160141 Comm: bpftrace
___slab_alloc+0x549/0xa20
kmem_cache_alloc_noprof+0x16c/0x340
register_ftrace_graph+0x3d7/0x6c0
register_fprobe_ips+0x2d5/0x310
bpf_kprobe_multi_link_attach+0x218/0x7e0
__sys_bpf+0x267a/0x27a0
Fix this by allocating inline with GFP_NOWAIT instead of pre-allocating
a fixed batch. GFP_NOWAIT does not sleep, so it is legal inside the RCU
read-side critical section.
A single sweep now serves every task, so the walk becomes O(N) rather
than O(N_total * N_null), and the retry loop is no longer the normal
path.
The pre-allocated array remains as the fallback when GFP_NOWAIT fails.
The runs below never needed it, so it was exercised with failslab
injection: at a 100% failure rate every task falls back and -EAGAIN
retries ~1560 times for 50000 threads, with no stall or splat.
smp_store_release() is a drop-in replacement for the smp_wmb() and
plain store it replaces.
Measured on a 60-core Sapphire Rapids machine running a PREEMPT_LAZY
kernel (CONFIG_PREEMPT_DYNAMIC=y, mode lazy), timing the write that
drives the ftrace_graph_active 0 -> 1 transition. Threads are spawned
while fgraph is inactive so every one of them has ret_stack == NULL,
and the loop was instrumented to count sweeps:
threads before after
sweeps time sweeps time
100000 3126 15.3 s 1 0.019 s
200000 6253 59.1 s 1 0.047 s
400000 12503 227.8 s 1 0.092 s
The sweep count is 1 throughout. Time now scales linearly with the
thread count at roughly 230 ns per task, which is the allocation and
initialisation of one shadow stack.
Fixes: f201ae2356c7 ("tracing/function-return-tracer: store return stack into task_struct and allocate it dynamically")
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>
Tested-by: Vineet Gupta <vineet.gupta@linux.dev>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261021174406.2891598-2-vineet.gupta@linux.dev
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/fgraph.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -1033,13 +1033,16 @@ void ftrace_stub_graph(struct ftrace_gra
trace_func_graph_ret_t ftrace_graph_return = ftrace_stub_graph;
trace_func_graph_ent_t ftrace_graph_entry = ftrace_graph_entry_stub;
-/* Try to assign a return stack array on FTRACE_RETSTACK_ALLOC_SIZE tasks. */
+/*
+ * Loop thru all the tasks in the system and assign ret_stack.
+ * The @ret_stack_list is a small pre-allocated fallback, in case
+ * the GFP_NOWAIT allocations here fail.
+ */
static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
{
- int i;
- int ret = 0;
int start = 0, end = FTRACE_RETSTACK_ALLOC_SIZE;
struct task_struct *g, *t;
+ int i, ret = 0;
if (WARN_ON_ONCE(!fgraph_stack_cachep))
return -ENOMEM;
@@ -1056,20 +1059,26 @@ static int alloc_retstack_tasklist(unsig
rcu_read_lock();
for_each_process_thread(g, t) {
- if (start == end) {
- ret = -EAGAIN;
- goto unlock;
- }
+ unsigned long *rs;
+
+ if (t->ret_stack)
+ continue;
- if (t->ret_stack == NULL) {
- atomic_set(&t->trace_overrun, 0);
- ret_stack_init_task_vars(ret_stack_list[start]);
- t->curr_ret_stack = 0;
- t->curr_ret_depth = -1;
- /* Make sure the tasks see the 0 first: */
- smp_wmb();
- t->ret_stack = ret_stack_list[start++];
+ rs = kmem_cache_alloc(fgraph_stack_cachep, GFP_NOWAIT);
+ if (!rs) {
+ if (start == end) {
+ ret = -EAGAIN;
+ goto unlock;
+ }
+ rs = ret_stack_list[start++];
}
+
+ atomic_set(&t->trace_overrun, 0);
+ ret_stack_init_task_vars(rs);
+ t->curr_ret_stack = 0;
+ t->curr_ret_depth = -1;
+ /* Make sure the tasks see the 0 first: */
+ smp_store_release(&t->ret_stack, rs);
}
unlock:
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 462/742] fgraph: Do not mark index 0 in every shadow stack frame
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (452 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 461/742] fgraph: Allocate shadow stacks inline with GFP_NOWAIT Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 463/742] fscrypt: Initialize ->ci_master_key before publication Greg Kroah-Hartman
` (272 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Breno Leitao, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <leitao@debian.org>
commit 65f42f1fa03829e0ab1473369461a7aabf525cb2 upstream.
We are seeing this warning on an arm64 host:
WARNING: kernel/trace/fprobe.c:676 at fprobe_return+0x260/0x2c8, CPU#16: FuncSched/3281330
Call trace:
fprobe_return+0x260/0x2c8 (P)
ftrace_return_to_handler+0x2bc/0x5a8
return_to_handler+0x20/0x48
futex_wait+0xa4/0x218
do_futex+0xb4/0x1d0
__arm64_sys_futex+0x15c/0x278
The theory is that function_graph_enter_regs() sets BIT(0) in the bitmap
of every frame, a leftover of an old tail-call check, while the return
path calls the retfunc of every set bit.
A reproducer on linux-next supports the theory. On a fresh boot, with no
other fgraph user yet:
cd /sys/kernel/tracing
echo 'f:fpexit vfs_read%return' >> dynamic_events
echo 1 > events/fprobes/fpexit/enable # fprobe_graph_ops: index 0
echo vfs_write > set_ftrace_filter
echo function_graph > current_tracer # function_graph: index 1
echo x > /dev/null # WARN on vfs_write return
Removing the bit was agreed in the review of the series that added it
[0], but the line stayed. Drop it now.
[0] https://lore.kernel.org/all/20240527093436.7060d358a64cc2ea3213b07b@kernel.org/
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261112-fgraph-bit0-v1-1-695ad14f4b1e@debian.org
Fixes: 7aa1eaef9f42 ("function_graph: Allow multiple users to attach to function graph")
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/fgraph.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -700,11 +700,7 @@ int function_graph_enter_regs(unsigned l
if (!bitmap)
goto out_ret;
- /*
- * Since this function uses fgraph_idx = 0 as a tail-call checking
- * flag, set that bit always.
- */
- set_bitmap(current, offset, bitmap | BIT(0));
+ set_bitmap(current, offset, bitmap);
ftrace_test_recursion_unlock(bit);
return 0;
out_ret:
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 463/742] fscrypt: Initialize ->ci_master_key before publication
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (453 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 462/742] fgraph: Do not mark index 0 in every shadow stack frame Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 464/742] fbdev: atafb: Restrict SuperVidel handling to the Falcon Greg Kroah-Hartman
` (271 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ada Smith, Eric Biggers
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <ebiggers@kernel.org>
commit 2de253924266eeedb798fb662173726c90b0cf04 upstream.
fscrypt_prepare_setflags() assumes that if the key for an inode with a
v2 encryption policy has been set up, then ->ci_master_key is non-NULL.
This is a reasonable assumption, but it does not take into account the
very short gap in fscrypt_setup_encryption_info() between the inode's
fscrypt_inode_info being set and ->ci_master_key being initialized.
Thus, a NULL pointer dereference was possible.
Fix this by closing the gap: make fscrypt_setup_encryption_info()
initialize ->ci_master_key before publication. If it loses the cmpxchg
race afterwards, set it back to NULL so that put_crypt_info() continues
to have the same behavior.
Fixes: b1c0ec3599f4 ("fscrypt: add FS_IOC_REMOVE_ENCRYPTION_KEY ioctl")
Cc: stable@vger.kernel.org
Reported-by: Ada Smith <adasmithgt@gmail.com>
Link: https://patch.msgid.link/20261110212011.35487-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/crypto/keysetup.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
--- a/fs/crypto/keysetup.c
+++ b/fs/crypto/keysetup.c
@@ -622,6 +622,13 @@ fscrypt_setup_encryption_info(struct ino
goto out;
/*
+ * Preemptively initialize ->ci_master_key, even though we don't know
+ * whether we'll win the race below yet, because if we do win the race
+ * then other tasks can see it right away and need ->ci_master_key.
+ */
+ crypt_info->ci_master_key = mk;
+
+ /*
* For existing inodes, multiple tasks may race to set the inode's
* fscrypt info pointer. So use cmpxchg_release(). This pairs with the
* smp_load_acquire() in fscrypt_get_inode_info(). I.e., publish the
@@ -634,7 +641,6 @@ fscrypt_setup_encryption_info(struct ino
* crypt_info. Now link it into the master key's inode list.
*/
if (mk) {
- crypt_info->ci_master_key = mk;
refcount_inc(&mk->mk_active_refs);
spin_lock(&mk->mk_decrypted_inodes_lock);
list_add(&crypt_info->ci_master_key_link,
@@ -642,6 +648,12 @@ fscrypt_setup_encryption_info(struct ino
spin_unlock(&mk->mk_decrypted_inodes_lock);
}
crypt_info = NULL;
+ } else {
+ /*
+ * Lost the race, so we won't be taking an active reference to
+ * the master key. Clear ->ci_master_key accordingly.
+ */
+ crypt_info->ci_master_key = NULL;
}
res = 0;
out:
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 464/742] fbdev: atafb: Restrict SuperVidel handling to the Falcon
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (454 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 463/742] fscrypt: Initialize ->ci_master_key before publication Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 465/742] fbdev: cobalt_lcdfb: Dont read info after framebuffer_release() Greg Kroah-Hartman
` (270 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christian Zietz, Miro Kropacek,
Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miro Kropacek <miro.kropacek@gmail.com>
commit f0486dd91e27d2eaf62abbd0c2af73a9c04eac48 upstream.
A framebuffer at 0xa0000000 or above is taken as being in SuperVidel
RAM. A TT with a VME graphics card such as the Nova has its framebuffer
there too, so in 8bpp it gets the Falcon palette registers instead of
the card's VGA DAC, and in 8, 16 and 32bpp the SuperBlitter, which it
does not have.
The SuperVidel exists only for the Falcon, so check for the Falcon video
hardware as well.
Fixes: 51df976c3268 ("fbdev: atafb: Add support for further video bit depths on atafb:external")
Fixes: d463633d63e6 ("fbdev: atafb: Add support for SuperVidel's SuperBlitter")
Cc: stable@vger.kernel.org # v7.3+
Reported-by: Christian Zietz <czietz@gmx.net>
Signed-off-by: Miro Kropacek <miro.kropacek@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/atafb.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
--- a/drivers/video/fbdev/atafb.c
+++ b/drivers/video/fbdev/atafb.c
@@ -2065,6 +2065,15 @@ static void st_ovsc_switch(void)
#ifdef ATAFB_EXT
+/*
+ * Only a Falcon can have a SuperVidel; a TT with a VME graphics card can
+ * have its framebuffer in the same address range.
+ */
+static bool ext_is_supervidel(void)
+{
+ return ATARIHW_PRESENT(VIDEL_SHIFTER) && external_addr >= 0xa0000000;
+}
+
static int ext_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
{
strcpy(fix->id, "Unknown Extern");
@@ -2083,8 +2092,7 @@ static int ext_encode_fix(struct fb_fix_
* SuperVidel 8bpp chunky (fb in SV RAM) uses the Falcon palette
*/
int visual = (external_vgaiobase ||
- (external_depth == 8 &&
- external_addr >= 0xa0000000)) ?
+ (external_depth == 8 && ext_is_supervidel())) ?
FB_VISUAL_PSEUDOCOLOR :
FB_VISUAL_STATIC_PSEUDOCOLOR;
switch (external_pmode) {
@@ -2181,7 +2189,7 @@ static int ext_encode_var(struct fb_var_
var->transp.offset = 24;
var->transp.length = 8;
} else if (external_pmode == FB_TYPE_PACKED_PIXELS &&
- external_depth == 8 && external_addr >= 0xa0000000) {
+ external_depth == 8 && ext_is_supervidel()) {
/* SuperVidel 8bpp chunky: palette has 8 bits per channel.
* Without this, fb_get_color_depth() sees length 0 and
* fbcon falls back to its 2-color palette — the console
@@ -2245,7 +2253,7 @@ static int ext_setcolreg(unsigned int re
return 0;
}
if (external_pmode == FB_TYPE_PACKED_PIXELS && external_depth == 8 &&
- external_addr >= 0xa0000000) {
+ ext_is_supervidel()) {
/* SuperVidel native 8bpp chunky scans out via the Falcon
* palette registers, honoring all 8 bits per channel
*/
@@ -3336,7 +3344,7 @@ static int __init atafb_probe(struct pla
memset (screen_base, 0, external_len);
/* framebuffer in SV RAM: enable the SuperBlitter */
- if (external_addr >= 0xa0000000 &&
+ if (ext_is_supervidel() &&
((external_pmode == FB_TYPE_PACKED_PIXELS &&
external_depth == 8) ||
(external_pmode == -1 &&
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 465/742] fbdev: cobalt_lcdfb: Dont read info after framebuffer_release()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (455 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 464/742] fbdev: atafb: Restrict SuperVidel handling to the Falcon Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 466/742] fbdev: fm2fb: Fix iomem access Greg Kroah-Hartman
` (269 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Kaixuan Li, Suyuan Wang,
Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suyuan Wang <stevewong@hust.edu.cn>
commit 2c8b0da3209955b42280ef60d8e0470dc788c0d8 upstream.
When devm_platform_get_and_ioremap_resource() fails, cobalt_lcdfb_probe()
releases the framebuffer and then dereferences it for the return value:
framebuffer_release(info);
return PTR_ERR(info->screen_base);
framebuffer_release() frees info, so info->screen_base is read from freed
memory. Save the error code before releasing info.
Found with a static analysis tool and checked by hand.
Fixes: d2386d9e3eb4 ("fbdev: cobalt_lcdfb: Request memory region")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/cobalt_lcdfb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
index f7faa95fefd3..e90f45c91725 100644
--- a/drivers/video/fbdev/cobalt_lcdfb.c
+++ b/drivers/video/fbdev/cobalt_lcdfb.c
@@ -297,8 +297,9 @@ static int cobalt_lcdfb_probe(struct platform_device *dev)
info->screen_base = devm_platform_get_and_ioremap_resource(dev, 0, &res);
if (IS_ERR(info->screen_base)) {
+ retval = PTR_ERR(info->screen_base);
framebuffer_release(info);
- return PTR_ERR(info->screen_base);
+ return retval;
}
info->screen_size = resource_size(res);
--
2.56.1
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 466/742] fbdev: fm2fb: Fix iomem access
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (456 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 465/742] fbdev: cobalt_lcdfb: Dont read info after framebuffer_release() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 467/742] fbdev: macmodes: compare the pixel clock of each candidate mode Greg Kroah-Hartman
` (268 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Steffen A. Mork, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steffen A. Mork <linux-dev@morknet.de>
commit 7d4a8a804cd1a3bcaa1a9a38e87517ead3130ca1 upstream.
This driver has not been tested for at least twenty years. In the meantime,
the frame buffer API has been updated. This patch addresses this issue and
makes the driver functional again.
Signed-off-by: Steffen A. Mork <linux-dev@morknet.de>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/fm2fb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/video/fbdev/fm2fb.c
+++ b/drivers/video/fbdev/fm2fb.c
@@ -257,7 +257,7 @@ static int fm2fb_probe(struct zorro_dev
strcpy(fb_fix.id, is_fm ? "FrameMaster II" : "Rainbow II");
/* make EBU color bars on display */
- ptr = (unsigned long *)fb_fix.smem_start;
+ ptr = (unsigned long *)info->screen_base;
for (y = 0; y < 576; y++) {
for (x = 0; x < 96; x++) *ptr++ = 0xffffff;/* white */
for (x = 0; x < 96; x++) *ptr++ = 0xffff00;/* yellow */
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 467/742] fbdev: macmodes: compare the pixel clock of each candidate mode
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (457 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 466/742] fbdev: fm2fb: Fix iomem access Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 468/742] fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var() Greg Kroah-Hartman
` (267 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Tim Douglas, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tim Douglas <me@timdoug.com>
commit 3e973ab62c86d620b2db9e90eb8fc3b065929e6e upstream.
In the second pass through the mode table in mac_var_to_vmode(),
the requested pixel clock period was compared with the first mode's
period at every step. The last mode at that resolution was therefore
returned even when its period was too short. Compare against the
current candidate's period.
Tested on a Performa 6200CD using a kernel with local platform
support. With video=valkyriefb:vmode:10 (800x600 at 60 Hz), the
measured refresh rate was about 72 Hz before the fix and 60 Hz
afterward. At 640x480, 67 Hz was also selected for a 60 Hz request
before the fix.
AI assistance was used to investigate the mode-table walk and draft
the fix.
Signed-off-by: Tim Douglas <me@timdoug.com>
Fixes: d876c11a0fd4 ("fbdev: mac_var_to_mode() fix")
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/macmodes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/video/fbdev/macmodes.c
+++ b/drivers/video/fbdev/macmodes.c
@@ -342,7 +342,7 @@ int mac_var_to_vmode(const struct fb_var
if (mode->xres != clk_mode->xres || mode->yres != clk_mode->yres)
break;
- if (var->pixclock > mode->pixclock)
+ if (var->pixclock > clk_mode->pixclock)
break;
if (mode->vmode != clk_mode->vmode)
continue;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 468/742] fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (458 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 467/742] fbdev: macmodes: compare the pixel clock of each candidate mode Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 469/742] fbdev: smscufx: allocate the size advertised in smem_len Greg Kroah-Hartman
` (266 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Jianqiang Zou, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianqiang Zou <jq.zou@outlook.com>
commit b3f1631d362539cfe14571ccfd7db919ffbc08c7 upstream.
radeonfb_set_par() derives the dot clock from the user supplied
struct fb_var_screeninfo:
dotClock = 1000000000 / pixClock;
where pixClock is copied from mode->pixclock. A zero pixclock
bypasses the existing validation and makes the kernel divide by zero
in radeonfb_set_par().
The driver does have a check for this: fb_validate_mode() returns
-EINVAL when pixclock is 0, but radeon_match_mode() only calls it when
the output has no scaler and an EDID-derived mode database is
available:
if (has_rmx == 0 && rinfo->mon1_modedb)
if (fb_validate_mode(...))
return -EINVAL;
mon1_modedb is only filled in when an EDID is read, so when no
EDID-derived mode database is available the validation is skipped and
the invalid mode reaches radeonfb_set_par().
Reject a zero pixclock in radeonfb_check_var() before matching the
mode. fb_set_var() calls it on the FBIOPUT_VSCREENINFO path before
->fb_set_par(), so the invalid value is rejected before the mode is
applied. This is the same check other fbdev drivers use (i740fb,
arkfb, s3fb).
Reproduced on Linux 7.3.0 using a custom QEMU PCI stub device with
vendor/device ID 1002:5955; no physical Radeon hardware was used. A
single FBIOPUT_VSCREENINFO with pixclock = 0 is enough to trigger the
divide error.
Signed-off-by: Jianqiang Zou <jq.zou@outlook.com>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/aty/radeon_base.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/video/fbdev/aty/radeon_base.c
+++ b/drivers/video/fbdev/aty/radeon_base.c
@@ -836,6 +836,9 @@ static int radeonfb_check_var (struct fb
int nom, den;
unsigned int pitch;
+ if (!var->pixclock)
+ return -EINVAL;
+
if (radeon_match_mode(rinfo, &v, var))
return -EINVAL;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 469/742] fbdev: smscufx: allocate the size advertised in smem_len
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (459 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 468/742] fbdev: radeonfb: reject a zero pixclock in radeonfb_check_var() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 470/742] fbdev: smscufx: dont free registered framebuffer on probe error Greg Kroah-Hartman
` (265 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, YuanZhe Liu, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
commit ae14fe6f367a9779e108449b4af41791bd6aaa47 upstream.
ufx_realloc_framebuffer() allocates line_length * yres bytes but records
PAGE_ALIGN(line_length * yres) in info->fix.smem_len. ufx_ops_set_par()
clears the framebuffer by writing smem_len bytes, so the write runs past
the end of the vmalloc() allocation whenever the mode size is not page
aligned:
BUG: KASAN: vmalloc-out-of-bounds in ufx_ops_set_par
Write of size 2 at addr ffffc90005518600
Call Trace:
ufx_ops_set_par
ufx_usb_probe
usb_probe_interface
This runs from the probe path, before any client can open the device: with
the fallback mode of 800x600 at 16 bpp the framebuffer is 960000 bytes and
PAGE_ALIGN() adds 2560 bytes that were never allocated.
Allocate the page aligned size that is published in smem_len instead, so
the buffer covers every byte the driver and the framebuffer core can reach
through smem_start and smem_len.
Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters")
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/smscufx.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1280,9 +1280,10 @@ static int ufx_realloc_framebuffer(struc
if (PAGE_ALIGN(new_len) > old_len) {
/*
- * Alloc system memory for virtual framebuffer
+ * Alloc system memory for virtual framebuffer. smem_len is
+ * rounded up to a page, so allocate that much as well.
*/
- new_fb = vmalloc(new_len);
+ new_fb = vmalloc(PAGE_ALIGN(new_len));
if (!new_fb)
return -ENOMEM;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 470/742] fbdev: smscufx: dont free registered framebuffer on probe error
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (460 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 469/742] fbdev: smscufx: allocate the size advertised in smem_len Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 471/742] fbdev: smscufx: keep the usb_device alive while ufx_data is in use Greg Kroah-Hartman
` (264 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, YuanZhe Liu, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
commit ed52e47133f72195f246a9f70c98e47431bb566d upstream.
register_framebuffer() can return an error after the framebuffer has
already been installed: do_register_framebuffer() bumps info->count,
creates /dev/fbN and stores the fb_info in registered_fb[] before it
returns the result of the console takeover, and that takeover may fail.
ufx_usb_probe() treats any error as "nothing was registered" and unwinds
through reset_active, which releases the fb_info and drops both
references to struct ufx_data, freeing @dev.
The framebuffer stays registered and can still be opened, so the next
open() of /dev/fbN reaches ufx_ops_open() with info->par pointing at
freed memory:
refcount_t: addition on 0; use-after-free.
WARNING: lib/refcount.c:25 at refcount_warn_saturate
Call Trace:
kref_get
ufx_ops_open drivers/video/fbdev/smscufx.c:1033
fb_open drivers/video/fbdev/core/fb_chrdev.c:351
chrdev_open
...
refcount_t: underflow; use-after-free.
WARNING: lib/refcount.c:28 at refcount_warn_saturate
Call Trace:
ufx_ops_release drivers/video/fbdev/smscufx.c:1135
fb_release drivers/video/fbdev/core/fb_chrdev.c:378
__fput
Reuse the "has this fb_info been registered" test that ufx_setup_modes()
already uses: take the error path only when refcount_read(&info->count)
says the core did not register the framebuffer. A failed console
takeover is not fatal for the driver, so report it and keep the
framebuffer registered; the disconnect callback will unregister it
normally.
Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters")
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/smscufx.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1701,8 +1701,16 @@ static int ufx_usb_probe(struct usb_inte
dev_dbg(dev->gdev, "registering framebuffer");
retval = register_framebuffer(info);
if (retval < 0) {
- dev_err(dev->gdev, "error %d register_framebuffer", retval);
- goto reset_active;
+ /*
+ * info is installed before the takeover can fail; freeing @dev
+ * here would leave registered_fb[] and /dev/fbN pointing at
+ * freed memory.
+ */
+ if (!refcount_read(&info->count)) { /* not registered */
+ dev_err(dev->gdev, "error %d register_framebuffer", retval);
+ goto reset_active;
+ }
+ dev_warn(dev->gdev, "console takeover failed: %d\n", retval);
}
dev_info(dev->gdev, "SMSC UDX USB device /dev/fb%d attached. %dx%d resolution."
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 471/742] fbdev: smscufx: keep the usb_device alive while ufx_data is in use
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (461 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 470/742] fbdev: smscufx: dont free registered framebuffer on probe error Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 472/742] fbdev: sstfb: Error out if pixclock equals zero Greg Kroah-Hartman
` (263 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, YuanZhe Liu, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
commit e8645fe7419828fd95a90171149c565c1bb72911 upstream.
ufx_usb_probe() stores the usb_device pointer in dev->udev without
taking a reference, and ufx_usb_disconnect() does not wait for in-flight
control transfers. A mode set or blank request that runs while the
device is being unplugged - through ufx_ops_set_par() or ufx_ops_blank()
on an open /dev/fbN file - keeps issuing synchronous control messages for
the whole ufx_set_vid_mode() sequence, including two msleep(1) delays in
ufx_config_pix_clk(). Once the disconnect callback returns, the USB core
may release the usb_device, and the next ufx_reg_write()/ufx_reg_read()
dereferences dev->udev through __create_pipe():
general protection fault, probably for non-canonical address
0xdffffc0000000006: 0000 [#1] SMP
KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037]
RIP: __create_pipe include/linux/usb.h:2031
Call Trace:
ufx_set_vid_mode
ufx_ops_set_par
fb_set_var
fb_set_var_from_user
store_rotate
Take a reference to the usb_device in ufx_usb_probe() and drop it in
ufx_free(), so dev->udev and dev->gdev stay valid until the last
ufx_data user is gone. The control transfers then fail with -ENODEV
instead of dereferencing freed memory.
Also return early from ufx_set_vid_mode() while the device is inactive,
matching the other transmit paths. That check alone is not enough,
because it is not serialized against ufx_usb_disconnect() and the
transfer sequence continues after it; it only avoids a long series of
failing transfers.
Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters")
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/smscufx.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -661,8 +661,12 @@ static int ufx_set_vid_mode(struct ufx_d
u32 temp;
u16 h_total, h_active, h_blank_start, h_blank_end, h_sync_start, h_sync_end;
u16 v_total, v_active, v_blank_start, v_blank_end, v_sync_start, v_sync_end;
+ int status;
- int status = ufx_reg_write(dev, 0x8028, 0);
+ if (!atomic_read(&dev->usb_active))
+ return -ENODEV;
+
+ status = ufx_reg_write(dev, 0x8028, 0);
check_warn_return(status, "ufx_set_vid_mode error disabling RGB pad");
status = ufx_reg_write(dev, 0x8024, 0);
@@ -1067,6 +1071,7 @@ static void ufx_free(struct kref *kref)
{
struct ufx_data *dev = container_of(kref, struct ufx_data, kref);
+ usb_put_dev(dev->udev);
kfree(dev);
}
@@ -1610,6 +1615,8 @@ static int ufx_usb_probe(struct usb_inte
dev->udev = usbdev;
dev->gdev = &usbdev->dev; /* our generic struct device * */
+ /* keep the device alive until the last ufx_data user is gone */
+ usb_get_dev(usbdev);
usb_set_intfdata(interface, dev);
dev_dbg(dev->gdev, "%s %s - serial #%s\n",
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 472/742] fbdev: sstfb: Error out if pixclock equals zero
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (462 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 471/742] fbdev: smscufx: keep the usb_device alive while ufx_data is in use Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 473/742] fbdev: valkyriefb: keep the framebuffer mapping size fixed Greg Kroah-Hartman
` (262 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Xue Haolin, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xue Haolin <xuehaolin@uniontech.com>
commit f37d206e145d25607c6a8e920d7bb643d203a1f7 upstream.
The userspace program could pass any values to the driver through
ioctl() interface. If the driver doesn't check the value of pixclock,
it may cause divide-by-zero error.
sstfb_check_var() calls PICOS2KHZ(var->pixclock) which expands to
1000000000UL / var->pixclock. If var->pixclock is zero, this causes
a divide-by-zero exception.
Fix this by checking whether pixclock is zero at the beginning of
sstfb_check_var(), before it is used as a divisor.
This is similar to CVE-2022-3061 in i740fb which was fixed by
commit 15cf0b82271b ("video: fbdev: i740fb: Error out if
'pixclock' equals zero"), and the fix in savagefb by
commit 04e5eac8f3ab ("fbdev: savage: Error out if pixclock equals zero").
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Xue Haolin <xuehaolin@uniontech.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/sstfb.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/video/fbdev/sstfb.c
+++ b/drivers/video/fbdev/sstfb.c
@@ -359,6 +359,9 @@ static int sstfb_check_var(struct fb_var
int tiles_in_X, real_length;
unsigned int freq;
+ if (!var->pixclock)
+ return -EINVAL;
+
if (sst_calc_pll(PICOS2KHZ(var->pixclock), &freq, &par->pll)) {
printk(KERN_ERR "sstfb: Pixclock at %ld KHZ out of range\n",
PICOS2KHZ(var->pixclock));
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 473/742] fbdev: valkyriefb: keep the framebuffer mapping size fixed
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (463 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 472/742] fbdev: sstfb: Error out if pixclock equals zero Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 474/742] fbdev: vfb: Validate framebuffer geometry and memory size Greg Kroah-Hartman
` (261 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Tim Douglas, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tim Douglas <me@timdoug.com>
commit fa9bebccf45571bd710b0591359b28d5354e7e7a upstream.
When /dev/fb0 is mapped before a depth change, as with Xorg's fbdev
driver, the mapping may be too short for the new mode. At 640x480,
a full frame at 16 bpp is 600 KiB, so drawing it through the
original 300 KiB mapping from 8 bpp can fault.
Set smem_len to the usable video RAM by subtracting the 4 KiB offset
already applied to smem_start, then keep that size across mode
changes.
On a Performa 6200CD using a kernel with local platform support,
a write past the mapping caused a fault during an Xorg test at
16 bpp. With the corrected mapping size in the test kernel, twm
and xterm were displayed successfully in Xorg at 640x480 and 16 bpp.
In a test on a Quadra 630 in MAME with Linux v7.4-rc3, /dev/fb0 was
mapped at 8 bpp and the depth was changed to 16 bpp with the original
mapping still in place. A SIGSEGV was reported during the 16 bpp draw
before the fix, and all 480 lines were drawn afterward.
AI assistance was used to investigate the mapping size and draft
the fix.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Tim Douglas <me@timdoug.com>
Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/valkyriefb.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/drivers/video/fbdev/valkyriefb.c
+++ b/drivers/video/fbdev/valkyriefb.c
@@ -510,7 +510,7 @@ static void valkyrie_init_fix(struct fb_
fix->mmio_len = sizeof(struct valkyrie_regs);
fix->type = FB_TYPE_PACKED_PIXELS;
fix->smem_start = p->frame_buffer_phys + 0x1000;
- fix->smem_len = p->total_vram;
+ fix->smem_len = p->total_vram - 0x1000;
fix->type_aux = 0;
fix->ywrapstep = 0;
@@ -523,7 +523,6 @@ static void valkyrie_init_fix(struct fb_
static void valkyrie_par_to_fix(struct fb_par_valkyrie *par,
struct fb_fix_screeninfo *fix)
{
- fix->smem_len = valkyrie_vram_reqd(par->vmode, par->cmode);
fix->visual = (par->cmode == CMODE_8) ?
FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR;
fix->line_length = par->vxres << par->cmode;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 474/742] fbdev: vfb: Validate framebuffer geometry and memory size
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (464 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 473/742] fbdev: valkyriefb: keep the framebuffer mapping size fixed Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 475/742] fuse: clear the old EOF tail before writeback-cache writes Greg Kroah-Hartman
` (260 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, co+b0df61d49532b2ee, Helge Deller,
Weiming Shi
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <bestswngs@gmail.com>
commit b438bb88f65a8b464ad08057873db9605cdae945 upstream.
FBIOPUT_VSCREENINFO can supply a virtual width large enough to
overflow get_line_length()'s int multiplication and bypass the
video-memory limit, allowing fbcon to write past the framebuffer. The
offset additions can also wrap, while an excessive videomemorysize
module parameter can be truncated when PAGE_ALIGN() is assigned to
unsigned int.
Limit virtual geometry and offsets to 8192 x 8192 and cap video
memory at 512 MiB, keeping the stride, framebuffer-size, and generic
fbdev drawing calculations within their destination types.
KASAN reports:
BUG: KASAN: vmalloc-out-of-bounds in sys_fillrect
drivers/video/fbdev/core/sysfillrect.c:24
Write of size 8 at addr ffa0000001671000 by task poc/198
sys_fillrect
drivers/video/fbdev/core/sysfillrect.c:24
bit_clear_margins
drivers/video/fbdev/core/bitblit.c:247
fbcon_clear_margins.constprop.0
drivers/video/fbdev/core/fbcon.c:1410
fbcon_switch
drivers/video/fbdev/core/fbcon.c:2261
redraw_screen
drivers/tty/vt/vt.c:994
fbcon_modechanged
drivers/video/fbdev/core/fbcon.c:2693
fbcon_update_vcs
drivers/video/fbdev/core/fbcon.c:2732
Cc: stable@vger.kernel.org
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: co+b0df61d49532b2ee@bugs.sh
Suggested-by: Helge Deller <deller@gmx.de>
Assisted-by: LLM
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/fbdev/vfb.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
--- a/drivers/video/fbdev/vfb.c
+++ b/drivers/video/fbdev/vfb.c
@@ -30,7 +30,10 @@
* The default can be overridden if the driver is compiled as a module
*/
-#define VIDEOMEMSIZE (1*1024*1024) /* 1 MB */
+#define MAX_XRES 8192
+#define MAX_YRES 8192
+#define VIDEOMEMSIZE (1 * 1024 * 1024) /* 1 MB */
+#define MAX_VIDEOMEMSIZE (8192 * 8192 * sizeof(u32))
static void *videomemory;
static u_long videomemorysize = VIDEOMEMSIZE;
@@ -159,6 +162,14 @@ static int vfb_check_var(struct fb_var_s
else
return -EINVAL;
+ if (var->xres_virtual > MAX_XRES ||
+ var->yres_virtual > MAX_YRES)
+ return -EINVAL;
+
+ if (var->xoffset > MAX_XRES - var->xres ||
+ var->yoffset > MAX_YRES - var->yres)
+ return -EINVAL;
+
if (var->xres_virtual < var->xoffset + var->xres)
var->xres_virtual = var->xoffset + var->xres;
if (var->yres_virtual < var->yoffset + var->yres)
@@ -434,9 +445,12 @@ static int __init vfb_setup(char *option
static int vfb_probe(struct platform_device *dev)
{
struct fb_info *info;
- unsigned int size = PAGE_ALIGN(videomemorysize);
+ unsigned int size;
int retval = -ENOMEM;
+ videomemorysize = min(videomemorysize, MAX_VIDEOMEMSIZE);
+ size = PAGE_ALIGN(videomemorysize);
+
/*
* For real video cards we use ioremap.
*/
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 475/742] fuse: clear the old EOF tail before writeback-cache writes
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (465 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 474/742] fbdev: vfb: Validate framebuffer geometry and memory size Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 476/742] fuse: fix possible UAF in fuse_direntplus_link() Greg Kroah-Hartman
` (259 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Hungyu Lin, Miklos Szeredi
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <dennylin0707@gmail.com>
commit d9013d15b9379b323f1bcdfff7e7d96df537268a upstream.
Buffered writeback-cache writes go through iomap_file_buffered_write(),
but do not clear cached data between the old EOF and the write position.
If a shared mapping dirtied the tail of the old EOF page, an extending
write can expose those bytes as file contents instead of zeros. A later
writeback can also send them to the server.
Clear the gap under the existing inode lock before the buffered write.
Use the same page-cache cleanup as fuse_perform_write() does for
write-through writes, leaving the write range itself untouched.
Fixes: 4d99ff8f12eb ("fuse: Turn writeback cache on")
Cc: stable@vger.kernel.org
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/fuse/file.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1546,6 +1546,11 @@ static ssize_t fuse_cache_write_iter(str
written = direct_write_fallback(iocb, from, written,
fuse_perform_write(iocb, from));
} else if (writeback) {
+ loff_t old_size = i_size_read(inode);
+
+ if (iocb->ki_pos > old_size)
+ truncate_pagecache_range(inode, old_size, iocb->ki_pos - 1);
+
/*
* Use iomap so that we can do granular uptodate reads
* and granular dirty tracking for large folios.
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 476/742] fuse: fix possible UAF in fuse_direntplus_link()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (466 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 475/742] fuse: clear the old EOF tail before writeback-cache writes Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 477/742] fuse: limit name size in listxattr Greg Kroah-Hartman
` (258 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Miklos Szeredi
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <mszeredi@redhat.com>
commit 9191c2c1a76a759ac97be72481fdd4f9e920c902 upstream.
In fuse_direntplus_link() a use-after-free occurs on struct fuse_inode when
linking a newly allocated in-lookup dentry during FUSE_READDIRPLUS
processing fails inside d_splice_alias().
When d_in_lookup(dentry) is true, fuse_iget() returns an inode with an
incremented reference count and fi->nlookup, which is then passed to
d_splice_alias(). Inside d_splice_alias_ops(), if the directory inode has
an existing alias and splicing fails with -ELOOP in d_ancestor() or -ESTALE
in __d_unalias(), the function drops the alias reference via dput(new) and
unconditionally consumes the caller's inode reference via iput(inode)
before returning the error pointer.
If the existing alias is concurrently unhashed and dropped, iput(inode)
drops the final inode reference and evicts the inode immediately via
fuse_evict_inode(), sending a FUSE_FORGET request for fi->nlookup and
freeing struct fuse_inode via RCU. Because fuse_direntplus_link()
subsequently checks !IS_ERR(inode) outside an RCU read-side critical
section, it dereferences the freed inode to acquire fi->lock and decrement
fi->nlookup, and its caller parse_dirplusfile() then invokes
fuse_force_forget() on the error return, issuing a duplicate FUSE_FORGET
request to the server.
Fixes: b8bd342d50cb ("fuse: nlookup missing decrement in fuse_direntplus_link")
Cc: stable@vger.kernel.org #v6.6+
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-0a00a32c-3732-46fe-9cdb-3c67a11903cc
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/fuse/readdir.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -238,9 +238,13 @@ retry:
inode = fuse_iget(dir->i_sb, o->nodeid, o->generation,
&o->attr, ATTR_TIMEOUT(o),
attr_version, evict_ctr);
- if (!inode)
- inode = ERR_PTR(-ENOMEM);
+ if (!inode) {
+ d_lookup_done(dentry);
+ dput(dentry);
+ return -ENOMEM;
+ }
+ ihold(inode); /* d_splice_alias() eats a reference */
alias = d_splice_alias(inode, dentry);
d_lookup_done(dentry);
if (alias) {
@@ -248,15 +252,15 @@ retry:
dentry = alias;
}
if (IS_ERR(dentry)) {
- if (!IS_ERR(inode)) {
- struct fuse_inode *fi = get_fuse_inode(inode);
+ struct fuse_inode *fi = get_fuse_inode(inode);
- spin_lock(&fi->lock);
- fi->nlookup--;
- spin_unlock(&fi->lock);
- }
+ spin_lock(&fi->lock);
+ fi->nlookup--;
+ spin_unlock(&fi->lock);
+ iput(inode);
return PTR_ERR(dentry);
}
+ iput(inode);
}
if (fc->readdirplus_auto)
set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 477/742] fuse: limit name size in listxattr
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (467 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 476/742] fuse: fix possible UAF in fuse_direntplus_link() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 478/742] fuse: set dentry epoch before making the dentry visible Greg Kroah-Hartman
` (257 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Miklos Szeredi
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <mszeredi@redhat.com>
commit 7f7b822d09c5590defcc61a37ffbd5a3533ed518 upstream.
Limit the size of names to XATTR_NAME_MAX. Return -EIO to the listxattr()
caller if the server exceeds this limit.
Fixes: 92a8780e1136 ("[PATCH] FUSE - extended attribute operations")
Cc: stable@vger.kernel.org
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/fuse/xattr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/fs/fuse/xattr.c
+++ b/fs/fuse/xattr.c
@@ -94,7 +94,7 @@ static int fuse_verify_xattr_list(char *
while (size) {
size_t thislen = strnlen(list, size);
- if (!thislen || thislen == size)
+ if (!thislen || thislen == size || thislen > XATTR_NAME_MAX)
return -EIO;
size -= thislen + 1;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 478/742] fuse: set dentry epoch before making the dentry visible
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (468 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 477/742] fuse: limit name size in listxattr Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 479/742] fuse: skip dcache instantiation for readdirplus names with embedded NUL Greg Kroah-Hartman
` (256 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Leon Ming, Miklos Szeredi
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Ming <leonming@meta.com>
commit fea42fae07822cd717ba4b3082834bb5908bf911 upstream.
fuse_lookup(), create_new_entry(), fuse_create_open() and
fuse_direntplus_link() set the dentry epoch only after d_splice_alias()
or d_instantiate() has made the dentry visible. A new dentry starts at
epoch 0 and the connection at epoch 1, so in that window a concurrent
lookup can find the dentry, fail fuse_dentry_revalidate() and
d_invalidate() it. The original lookup then returns an unhashed dentry,
and readlink() of /proc/self/fd/N on an O_PATH fd for it says
"<path> (deleted)" for a file that exists.
Anything that resolves real paths with open(O_PATH) + readlink() can
pick up the bogus path; TypeScript's native compiler (tsgo)
intermittently fails to find installed packages this way. It got much
more common after commit 5a6baf204610 ("fuse: fix uninit-value in
fuse_dentry_revalidate()") zeroed the initial epoch; before that, slab
garbage usually passed the check.
Set the epoch before the dentry is published, and keep setting it on
any alias that d_splice_alias() returns; the dentry that loses to an
alias is dropped without ever being visible, so setting it too is
harmless.
With 32 processes making concurrent first lookups of 6000 files on a
fresh squashfuse_ll mount (UML, 16 CPUs), 1652 of 10.75M lookups came
back "(deleted)" before this patch and none after.
Fixes: 2396356a945b ("fuse: add more control over cache invalidation behaviour")
Cc: stable@vger.kernel.org
Signed-off-by: Leon Ming <leonming@meta.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/fuse/dir.c | 12 ++++++++----
fs/fuse/readdir.c | 5 ++++-
2 files changed, 12 insertions(+), 5 deletions(-)
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -644,13 +644,17 @@ static struct dentry *fuse_lookup(struct
if (inode && get_node_id(inode) == FUSE_ROOT_ID)
goto out_iput;
+ /* Set before the dentry is visible, or a racing lookup invalidates it */
+ fuse_dentry_set_epoch(entry, epoch);
newent = d_splice_alias(inode, entry);
err = PTR_ERR(newent);
if (IS_ERR(newent))
goto out_err;
- entry = newent ? newent : entry;
- fuse_dentry_set_epoch(entry, epoch);
+ if (newent) {
+ entry = newent;
+ fuse_dentry_set_epoch(entry, epoch);
+ }
if (outarg_valid)
fuse_change_entry_timeout(entry, &outarg);
else
@@ -906,8 +910,8 @@ static int fuse_create_open(struct mnt_i
goto out_err;
}
kfree(forget);
- d_instantiate(entry, inode);
fuse_dentry_set_epoch(entry, epoch);
+ d_instantiate(entry, inode);
fuse_change_entry_timeout(entry, &outentry);
fuse_dir_changed(dir);
err = generic_file_open(inode, file);
@@ -1029,6 +1033,7 @@ static struct dentry *create_new_entry(s
fuse_chan_queue_forget(fm->fc->chan, forget, outarg.nodeid, 1);
return ERR_PTR(-ENOMEM);
}
+ fuse_dentry_set_epoch(entry, epoch);
kfree(forget);
d_drop(entry);
@@ -1040,7 +1045,6 @@ static struct dentry *create_new_entry(s
fuse_dentry_set_epoch(d, epoch);
fuse_change_entry_timeout(d, &outarg);
} else {
- fuse_dentry_set_epoch(entry, epoch);
fuse_change_entry_timeout(entry, &outarg);
}
fuse_dir_changed(dir);
--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -230,6 +230,7 @@ retry:
fuse_change_attributes(inode, &o->attr, NULL,
ATTR_TIMEOUT(o),
attr_version);
+ fuse_dentry_set_epoch(dentry, epoch);
/*
* The other branch comes via fuse_iget()
* which bumps nlookup inside
@@ -244,6 +245,7 @@ retry:
return -ENOMEM;
}
+ fuse_dentry_set_epoch(dentry, epoch);
ihold(inode); /* d_splice_alias() eats a reference */
alias = d_splice_alias(inode, dentry);
d_lookup_done(dentry);
@@ -260,11 +262,12 @@ retry:
iput(inode);
return PTR_ERR(dentry);
}
+ if (alias)
+ fuse_dentry_set_epoch(dentry, epoch);
iput(inode);
}
if (fc->readdirplus_auto)
set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state);
- fuse_dentry_set_epoch(dentry, epoch);
fuse_change_entry_timeout(dentry, o);
dput(dentry);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 479/742] fuse: skip dcache instantiation for readdirplus names with embedded NUL
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (469 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 478/742] fuse: set dentry epoch before making the dentry visible Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 480/742] gpio: cdev: dont overwrite the whole flags field when configuring lines Greg Kroah-Hartman
` (255 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Gwanhyun Lee, Junyoung Jang,
Amir Goldstein, Miklos Szeredi
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junyoung Jang <graypanda.inzag@gmail.com>
commit ae932b1f5727004f585d603e0cbab7e0725c04cf upstream.
FUSE READDIRPLUS can pass a length-bearing qstr with an embedded NUL to
d_splice_alias(). Unlike verify_dirent_name() in fs/readdir.c, this
path can create a dentry whose d_name.len extends past the NUL.
For such a name, strscpy() in inotify_handle_inode_event() and the
fanotify name-copy helpers stop early. The kmalloc() and kvmalloc()
event-name buffers retain uninitialized bytes within the recorded name
length, which copy_event_to_user() and copy_fid_info_to_user() can expose.
Some FUSE servers include a terminating NUL in namelen. Follow
nfs_prime_dcache() in commit 78d04af4995a1 ("NFS: nfs_prime_dcache must
validate the filename") by skipping dcache instantiation without
failing getdents(). Return -EIO from fuse_direntplus_link() so
parse_dirplusfile() sends FUSE_FORGET for the unused lookup reference
and continues readdir.
Fixes: 0b05b18381ee ("fuse: implement NFS-like readdirplus support")
Cc: stable@vger.kernel.org
Co-developed-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
Signed-off-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
Signed-off-by: Junyoung Jang <graypanda.inzag@gmail.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/fuse/readdir.c | 2 ++
1 file changed, 2 insertions(+)
--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -191,6 +191,8 @@ static int fuse_direntplus_link(struct f
return -EIO;
if (fuse_invalid_attr(&o->attr))
return -EIO;
+ if (memchr(name.name, '\0', name.len))
+ return -EIO;
fc = get_fuse_conn(dir);
epoch = atomic_read(&fc->epoch);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 480/742] gpio: cdev: dont overwrite the whole flags field when configuring lines
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (470 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 479/742] fuse: skip dcache instantiation for readdirplus names with embedded NUL Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 481/742] gpio: ljca: Validate the pin index of interrupt events Greg Kroah-Hartman
` (254 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Kent Gibson, Bartosz Golaszewski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
commit fa8bc4aa06674e78a4ee702966419aa4fdd8dc94 upstream.
linehandle_flags_to_desc_flags() and
gpio_v2_line_config_flags_to_desc_flags() read the flags word with
READ_ONCE(), modify the local copy and write it back with WRITE_ONCE().
The per-request config_mutex does not exclude sysfs, the irq core or
drivers touching the same descriptor, so bits they set or clear
concurrently can be lost.
Build the mask of bits owned by the line configuration and their new
values locally and apply them with gpiod_update_flags(). The whole
group changes in a single atomic step.
While at it: rename the functions whose semantics changed from
"conversion" to "flags update" accordingly.
Cc: stable@vger.kernel.org
Fixes: b7adfb6076ff ("gpio: cdev: update flags at once when reconfiguring from user-space")
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-5-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpio/gpiolib-cdev.c | 95 +++++++++++++++++++++-----------------------
1 file changed, 47 insertions(+), 48 deletions(-)
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -140,24 +140,25 @@ static int linehandle_validate_flags(u32
return 0;
}
-static void linehandle_flags_to_desc_flags(u32 lflags, unsigned long *flagsp)
+static void linehandle_update_desc_flags(u32 lflags, struct gpio_desc *desc)
{
- unsigned long flags = READ_ONCE(*flagsp);
+ unsigned long flags = 0, mask;
- assign_bit(GPIOD_FLAG_ACTIVE_LOW, &flags,
- lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW);
- assign_bit(GPIOD_FLAG_OPEN_DRAIN, &flags,
- lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN);
- assign_bit(GPIOD_FLAG_OPEN_SOURCE, &flags,
- lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE);
- assign_bit(GPIOD_FLAG_PULL_UP, &flags,
- lflags & GPIOHANDLE_REQUEST_BIAS_PULL_UP);
- assign_bit(GPIOD_FLAG_PULL_DOWN, &flags,
- lflags & GPIOHANDLE_REQUEST_BIAS_PULL_DOWN);
- assign_bit(GPIOD_FLAG_BIAS_DISABLE, &flags,
- lflags & GPIOHANDLE_REQUEST_BIAS_DISABLE);
+ mask = BIT(GPIOD_FLAG_ACTIVE_LOW) |
+ BIT(GPIOD_FLAG_OPEN_DRAIN) |
+ BIT(GPIOD_FLAG_OPEN_SOURCE) |
+ BIT(GPIOD_FLAG_PULL_UP) |
+ BIT(GPIOD_FLAG_PULL_DOWN) |
+ BIT(GPIOD_FLAG_BIAS_DISABLE);
+
+ __assign_bit(GPIOD_FLAG_ACTIVE_LOW, &flags, lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW);
+ __assign_bit(GPIOD_FLAG_OPEN_DRAIN, &flags, lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN);
+ __assign_bit(GPIOD_FLAG_OPEN_SOURCE, &flags, lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE);
+ __assign_bit(GPIOD_FLAG_PULL_UP, &flags, lflags & GPIOHANDLE_REQUEST_BIAS_PULL_UP);
+ __assign_bit(GPIOD_FLAG_PULL_DOWN, &flags, lflags & GPIOHANDLE_REQUEST_BIAS_PULL_DOWN);
+ __assign_bit(GPIOD_FLAG_BIAS_DISABLE, &flags, lflags & GPIOHANDLE_REQUEST_BIAS_DISABLE);
- WRITE_ONCE(*flagsp, flags);
+ set_mask_bits(&desc->flags, mask, flags);
}
static long linehandle_set_config(struct linehandle_state *lh,
@@ -182,7 +183,7 @@ static long linehandle_set_config(struct
for (i = 0; i < lh->num_descs; i++) {
desc = lh->descs[i];
- linehandle_flags_to_desc_flags(lflags, &desc->flags);
+ linehandle_update_desc_flags(lflags, desc);
if (lflags & GPIOHANDLE_REQUEST_OUTPUT) {
int val = !!gcnf.default_values[i];
@@ -346,7 +347,7 @@ static int linehandle_create(struct gpio
if (ret)
return ret;
lh->descs[i] = desc;
- linehandle_flags_to_desc_flags(handlereq.flags, &desc->flags);
+ linehandle_update_desc_flags(handlereq.flags, desc);
ret = gpiod_set_transitory(desc, false);
if (ret < 0)
@@ -1221,37 +1222,35 @@ static int gpio_v2_line_config_validate(
return 0;
}
-static void gpio_v2_line_config_flags_to_desc_flags(u64 lflags,
- unsigned long *flagsp)
+static void linereq_update_desc_flags(u64 lflags, struct gpio_desc *desc)
{
- unsigned long flags = READ_ONCE(*flagsp);
+ unsigned long flags = 0, mask;
- assign_bit(GPIOD_FLAG_ACTIVE_LOW, &flags,
- lflags & GPIO_V2_LINE_FLAG_ACTIVE_LOW);
+ mask = BIT(GPIOD_FLAG_ACTIVE_LOW) |
+ BIT(GPIOD_FLAG_EDGE_RISING) |
+ BIT(GPIOD_FLAG_EDGE_FALLING) |
+ BIT(GPIOD_FLAG_OPEN_DRAIN) |
+ BIT(GPIOD_FLAG_OPEN_SOURCE) |
+ BIT(GPIOD_FLAG_PULL_UP) |
+ BIT(GPIOD_FLAG_PULL_DOWN) |
+ BIT(GPIOD_FLAG_BIAS_DISABLE) |
+ BIT(GPIOD_FLAG_EVENT_CLOCK_REALTIME) |
+ BIT(GPIOD_FLAG_EVENT_CLOCK_HTE);
+
+ __assign_bit(GPIOD_FLAG_ACTIVE_LOW, &flags, lflags & GPIO_V2_LINE_FLAG_ACTIVE_LOW);
+ __assign_bit(GPIOD_FLAG_EDGE_RISING, &flags, lflags & GPIO_V2_LINE_FLAG_EDGE_RISING);
+ __assign_bit(GPIOD_FLAG_EDGE_FALLING, &flags, lflags & GPIO_V2_LINE_FLAG_EDGE_FALLING);
+ __assign_bit(GPIOD_FLAG_OPEN_DRAIN, &flags, lflags & GPIO_V2_LINE_FLAG_OPEN_DRAIN);
+ __assign_bit(GPIOD_FLAG_OPEN_SOURCE, &flags, lflags & GPIO_V2_LINE_FLAG_OPEN_SOURCE);
+ __assign_bit(GPIOD_FLAG_PULL_UP, &flags, lflags & GPIO_V2_LINE_FLAG_BIAS_PULL_UP);
+ __assign_bit(GPIOD_FLAG_PULL_DOWN, &flags, lflags & GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN);
+ __assign_bit(GPIOD_FLAG_BIAS_DISABLE, &flags, lflags & GPIO_V2_LINE_FLAG_BIAS_DISABLED);
+ __assign_bit(GPIOD_FLAG_EVENT_CLOCK_REALTIME, &flags,
+ lflags & GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME);
+ __assign_bit(GPIOD_FLAG_EVENT_CLOCK_HTE, &flags,
+ lflags & GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE);
- assign_bit(GPIOD_FLAG_EDGE_RISING, &flags,
- lflags & GPIO_V2_LINE_FLAG_EDGE_RISING);
- assign_bit(GPIOD_FLAG_EDGE_FALLING, &flags,
- lflags & GPIO_V2_LINE_FLAG_EDGE_FALLING);
-
- assign_bit(GPIOD_FLAG_OPEN_DRAIN, &flags,
- lflags & GPIO_V2_LINE_FLAG_OPEN_DRAIN);
- assign_bit(GPIOD_FLAG_OPEN_SOURCE, &flags,
- lflags & GPIO_V2_LINE_FLAG_OPEN_SOURCE);
-
- assign_bit(GPIOD_FLAG_PULL_UP, &flags,
- lflags & GPIO_V2_LINE_FLAG_BIAS_PULL_UP);
- assign_bit(GPIOD_FLAG_PULL_DOWN, &flags,
- lflags & GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN);
- assign_bit(GPIOD_FLAG_BIAS_DISABLE, &flags,
- lflags & GPIO_V2_LINE_FLAG_BIAS_DISABLED);
-
- assign_bit(GPIOD_FLAG_EVENT_CLOCK_REALTIME, &flags,
- lflags & GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME);
- assign_bit(GPIOD_FLAG_EVENT_CLOCK_HTE, &flags,
- lflags & GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE);
-
- WRITE_ONCE(*flagsp, flags);
+ set_mask_bits(&desc->flags, mask, flags);
}
static long linereq_get_values(struct linereq *lr, void __user *ip)
@@ -1409,7 +1408,7 @@ static long linereq_set_config(struct li
*/
if (!(flags & GPIO_V2_LINE_DIRECTION_FLAGS))
continue;
- gpio_v2_line_config_flags_to_desc_flags(flags, &desc->flags);
+ linereq_update_desc_flags(flags, desc);
edflags = flags & GPIO_V2_LINE_EDGE_DETECTOR_FLAGS;
if (flags & GPIO_V2_LINE_FLAG_OUTPUT) {
int val = gpio_v2_line_config_output_value(&lc, i);
@@ -1665,7 +1664,7 @@ static int linereq_create(struct gpio_de
lr->lines[i].desc = desc;
flags = gpio_v2_line_config_flags(lc, i);
- gpio_v2_line_config_flags_to_desc_flags(flags, &desc->flags);
+ linereq_update_desc_flags(flags, desc);
ret = gpiod_set_transitory(desc, false);
if (ret < 0)
@@ -2060,7 +2059,7 @@ static int lineevent_create(struct gpio_
le->desc = desc;
le->eflags = eflags;
- linehandle_flags_to_desc_flags(lflags, &desc->flags);
+ linehandle_update_desc_flags(lflags, desc);
ret = gpiod_direction_input(desc);
if (ret)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 481/742] gpio: ljca: Validate the pin index of interrupt events
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (471 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 480/742] gpio: cdev: dont overwrite the whole flags field when configuring lines Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 482/742] gpio: mlxbf2: Disable interrupts around the chip lock in direction ops Greg Kroah-Hartman
` (253 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Alexandre Becholey,
Bartosz Golaszewski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Becholey <alex@becholey.ch>
commit e6e2181c6920ff59ded349a100f80cf85d074601 upstream.
ljca_gpio_event_cb() takes the pin index of every item in a GPIO
interrupt event from the device and passes it to set_bit() on the
reenable_irqs bitmap, which is only LJCA_MAX_GPIO_NUM (64) bits long.
The index is a u8, so a malfunctioning or malicious device can set
bits past the end of the bitmap, in the members that follow it in
struct ljca_gpio_dev: the output_enabled bitmap, the connect_mode
pointer and the irq_lock mutex. connect_mode is later dereferenced and
written to by ljca_gpio_set_config() and ljca_irq_set_type(), so the
device can flip bits of a kernel pointer that is then used for a write.
Until commit 4c4e6ea4a120 ("gpio: ljca: Fix duplicated IRQ mapping")
an index without an IRQ mapping made irq_find_mapping() fail and the
handler returned before set_bit(). Since that change nothing checks
the index.
A device bound to usb-ljca can trigger this by sending one GPIO
interrupt event, once the gpiochip is registered, with an index that
sets a bit of connect_mode which is still clear in a kernel pointer:
175 (bit 47) on arm64, 174 (bit 46) on x86_64. The next GPIO line
request then faults in ljca_gpio_set_config(). With dummy_hcd and
KASAN, on arm64 (torvalds/master 067c5c24cef2):
Unable to handle kernel paging request at virtual address ffff7000023dfd30
pc : ljca_gpio_set_config (drivers/gpio/gpio-ljca.c:212)
and on x86_64 (torvalds/master 7e1392a42ea2, nokaslr):
BUG: unable to handle page fault for address: ffffc8800f5452b8
RIP: 0010:ljca_gpio_set_config (drivers/gpio/gpio-ljca.c:212)
Ignore event items whose pin index is not below the number of GPIOs of
the chip. That number never exceeds LJCA_MAX_GPIO_NUM, because
usb-ljca rejects larger values at enumeration, so set_bit() stays
inside the bitmap. Valid items in the same event are still handled.
The bug was found by AI agents (Claude Mythos and Claude Opus models). The
analysis and the patch were reviewed by a human, who also reproduced the
bug on x86_64 and aarch64 with current master.
Fixes: 4c4e6ea4a120 ("gpio: ljca: Fix duplicated IRQ mapping")
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Becholey <alex@becholey.ch>
Link: https://patch.msgid.link/20261113144432.1354180-1-alex@becholey.ch
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpio/gpio-ljca.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
--- a/drivers/gpio/gpio-ljca.c
+++ b/drivers/gpio/gpio-ljca.c
@@ -292,9 +292,14 @@ static void ljca_gpio_event_cb(void *con
return;
for (i = 0; i < packet->num; i++) {
- generic_handle_domain_irq(ljca_gpio->gc.irq.domain,
- packet->item[i].index);
- set_bit(packet->item[i].index, ljca_gpio->reenable_irqs);
+ u8 index = packet->item[i].index;
+
+ /* The pin index comes from the device, do not trust it */
+ if (index >= ljca_gpio->gc.ngpio)
+ continue;
+
+ generic_handle_domain_irq(ljca_gpio->gc.irq.domain, index);
+ set_bit(index, ljca_gpio->reenable_irqs);
}
schedule_work(&ljca_gpio->work);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 482/742] gpio: mlxbf2: Disable interrupts around the chip lock in direction ops
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (472 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 481/742] gpio: ljca: Validate the pin index of interrupt events Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 483/742] gpio: shared: use atomic set_bit() for descriptor flags Greg Kroah-Hartman
` (252 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, David Thompson, Bartosz Golaszewski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Thompson <davthompson@nvidia.com>
commit f95bdff1d53471159e3c7112c5de4f6240772521 upstream.
mlxbf2_gpio_lock_acquire() takes the generic GPIO chip lock with
gpio_generic_chip_lock(), a plain raw_spin_lock() that leaves
interrupts enabled. The same lock is also taken with the irqsave
variant by the IRQ callbacks (irq_set_type, irq_enable, irq_disable),
which run with the IRQ descriptor lock held.
This creates a possible deadlock that lockdep reports as an IRQ lock
inversion:
CPU0 CPU1
---- ----
lock(&chip->lock) lock(irq_desc->lock)
<GPIO interrupt> lock(&chip->lock)
lock(irq_desc->lock)
If a GPIO interrupt arrives on CPU0 while it holds the chip lock during
a direction change, the interrupt handler spins on the descriptor lock
that CPU1 holds, while CPU1 spins on the chip lock held by CPU0.
This was seen during probe of pwr-mlxbf. acpi_dev_gpio_irq_get() sets
the pin to input through mlxbf2_gpio_direction_input(), and then
irq_set_irq_type() runs with the descriptor lock held.
Use the irqsave variant for the chip lock in mlxbf2_gpio_lock_acquire()
and its release counterpart, and pass the saved flags from
mlxbf2_gpio_direction_input() and mlxbf2_gpio_direction_output(). This
matches the IRQ callbacks, so interrupts stay disabled for the whole
ModeX update.
Fixes: 2b725265cb08 ("gpio: mlxbf2: Introduce IRQ support")
Cc: stable@vger.kernel.org
Signed-off-by: David Thompson <davthompson@nvidia.com>
Link: https://patch.msgid.link/20261113184444.3431-1-davthompson@nvidia.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpio/gpio-mlxbf2.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
--- a/drivers/gpio/gpio-mlxbf2.c
+++ b/drivers/gpio/gpio-mlxbf2.c
@@ -128,12 +128,20 @@ exit:
* Acquire the YU arm_gpio_lock to be able to change the direction
* mode. If the lock_active bit is already set, return an error.
*/
-static int mlxbf2_gpio_lock_acquire(struct mlxbf2_gpio_context *gs)
+static int mlxbf2_gpio_lock_acquire(struct mlxbf2_gpio_context *gs,
+ unsigned long *flags)
{
u32 arm_gpio_lock_val;
mutex_lock(yu_arm_gpio_lock_param.lock);
- gpio_generic_chip_lock(&gs->chip);
+ /*
+ * Disable interrupts before taking the chip lock. The GPIO irq
+ * callbacks take this lock while holding the irq descriptor lock,
+ * and the irq handler takes the descriptor lock in hardirq context.
+ * A plain spin_lock() here lets lockdep report an inversion, and
+ * can deadlock if a GPIO interrupt arrives on this CPU.
+ */
+ gpio_generic_chip_lock_irqsave(&gs->chip, *flags);
arm_gpio_lock_val = readl(yu_arm_gpio_lock_param.io);
@@ -141,7 +149,7 @@ static int mlxbf2_gpio_lock_acquire(stru
* When lock active bit[31] is set, ModeX is write enabled
*/
if (YU_LOCK_ACTIVE_BIT(arm_gpio_lock_val)) {
- gpio_generic_chip_unlock(&gs->chip);
+ gpio_generic_chip_unlock_irqrestore(&gs->chip, *flags);
mutex_unlock(yu_arm_gpio_lock_param.lock);
return -EINVAL;
}
@@ -154,12 +162,13 @@ static int mlxbf2_gpio_lock_acquire(stru
/*
* Release the YU arm_gpio_lock after changing the direction mode.
*/
-static void mlxbf2_gpio_lock_release(struct mlxbf2_gpio_context *gs)
+static void mlxbf2_gpio_lock_release(struct mlxbf2_gpio_context *gs,
+ unsigned long flags)
__releases(&gs->chip.lock)
__releases(yu_arm_gpio_lock_param.lock)
{
writel(YU_ARM_GPIO_LOCK_RELEASE, yu_arm_gpio_lock_param.io);
- gpio_generic_chip_unlock(&gs->chip);
+ gpio_generic_chip_unlock_irqrestore(&gs->chip, flags);
mutex_unlock(yu_arm_gpio_lock_param.lock);
}
@@ -185,20 +194,21 @@ static int mlxbf2_gpio_direction_input(s
unsigned int offset)
{
struct mlxbf2_gpio_context *gs = gpiochip_get_data(chip);
+ unsigned long flags;
int ret;
/*
* Although the arm_gpio_lock was set in the probe function, check again
* if it is still enabled to be able to write to the ModeX registers.
*/
- ret = mlxbf2_gpio_lock_acquire(gs);
+ ret = mlxbf2_gpio_lock_acquire(gs, &flags);
if (ret < 0)
return ret;
writel(BIT(offset), gs->gpio_io + YU_GPIO_MODE0_CLEAR);
writel(BIT(offset), gs->gpio_io + YU_GPIO_MODE1_CLEAR);
- mlxbf2_gpio_lock_release(gs);
+ mlxbf2_gpio_lock_release(gs, flags);
return ret;
}
@@ -212,6 +222,7 @@ static int mlxbf2_gpio_direction_output(
int value)
{
struct mlxbf2_gpio_context *gs = gpiochip_get_data(chip);
+ unsigned long flags;
int ret = 0;
/*
@@ -219,14 +230,14 @@ static int mlxbf2_gpio_direction_output(
* check again it is still enabled to be able to write to the
* ModeX registers.
*/
- ret = mlxbf2_gpio_lock_acquire(gs);
+ ret = mlxbf2_gpio_lock_acquire(gs, &flags);
if (ret < 0)
return ret;
writel(BIT(offset), gs->gpio_io + YU_GPIO_MODE1_CLEAR);
writel(BIT(offset), gs->gpio_io + YU_GPIO_MODE0_SET);
- mlxbf2_gpio_lock_release(gs);
+ mlxbf2_gpio_lock_release(gs, flags);
return ret;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 483/742] gpio: shared: use atomic set_bit() for descriptor flags
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (473 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 482/742] gpio: mlxbf2: Disable interrupts around the chip lock in direction ops Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 484/742] gpio: virtio: bound the line names block by its configured size Greg Kroah-Hartman
` (251 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Kent Gibson, Bartosz Golaszewski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
commit 7d1d799d6251bc8cd1d5cfc881b0c09060b6b90d upstream.
Use the atomic set_bit() instead of __set_bit() on desc->flags so that
every modification of the field uses atomic bitops. No functional change
as these run before any line of the chip can be requested.
Cc: stable@vger.kernel.org
Fixes: eb374f764a70 ("gpio: provide gpiod_is_shared()")
Fixes: a060b8c511ab ("gpiolib: implement low-level, shared GPIO support")
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-2-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpio/gpiolib-shared.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -532,8 +532,7 @@ int gpiochip_setup_shared(struct gpio_ch
* This is a shared GPIO proxy. Mark its
* descriptor as such and return here.
*/
- __set_bit(GPIOD_FLAG_SHARED_PROXY,
- &gdev->descs[0].flags);
+ set_bit(GPIOD_FLAG_SHARED_PROXY, &gdev->descs[0].flags);
return 0;
}
}
@@ -573,7 +572,7 @@ int gpiochip_setup_shared(struct gpio_ch
desc = &gdev->descs[entry->offset];
- __set_bit(GPIOD_FLAG_SHARED, &desc->flags);
+ set_bit(GPIOD_FLAG_SHARED, &desc->flags);
/*
* Shared GPIOs are not requested via the normal path. Make
* them inaccessible to anyone even before we register the
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 484/742] gpio: virtio: bound the line names block by its configured size
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (474 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 483/742] gpio: shared: use atomic set_bit() for descriptor flags Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 485/742] gpio: virtio: compute the line names size in a size_t Greg Kroah-Hartman
` (250 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Lianjie Wang, Viresh Kumar,
Bartosz Golaszewski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>
commit 74aee8e06277df39ec10ed043bae0ed5b7a83864 upstream.
virtio_gpio_get_names() walks the line names that the device returns in
a block of gpio_names_size bytes, which the driver ends with a NUL, and
checks each name only after stepping past it. If the block holds fewer
than ngpio names, the walk reaches the end of the block after the last
name, and the next iteration starts strlen() at the byte after the
allocation. With a block that holds one name for four lines, KASAN
reports:
BUG: KASAN: slab-out-of-bounds in strlen+0x57/0x70
Read of size 1 at addr ffff8880026687c0 by task swapper/0/1
Call Trace:
strlen+0x57/0x70
virtio_gpio_probe+0xcb4/0xfc0
virtio_dev_probe+0xa7a/0xc50
Allocated by task 1:
devm_kmalloc+0x6e/0x280
virtio_gpio_probe+0xc06/0xfc0
The buggy address is located 0 bytes to the right of
allocated 64-byte region [ffff888002668780, ffff8880026687c0)
Check that a name starts inside the block before reading it.
Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://patch.msgid.link/20261104195632.1702765-1-lian@is.s.u-tokyo.ac.jp
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpio/gpio-virtio.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -520,13 +520,13 @@ static const char **virtio_gpio_get_name
gpio_names[gpio_names_size - 1] = '\0';
for (i = 0, str = gpio_names; i < ngpio; i++) {
- names[i] = str;
- str += strlen(str) + 1; /* zero-length strings are allowed */
-
- if (str > gpio_names + gpio_names_size) {
+ if (str >= gpio_names + gpio_names_size) {
dev_err(dev, "gpio_names block is too short (%d)\n", i);
return NULL;
}
+
+ names[i] = str;
+ str += strlen(str) + 1; /* zero-length strings are allowed */
}
return names;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 485/742] gpio: virtio: compute the line names size in a size_t
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (475 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 484/742] gpio: virtio: bound the line names block by its configured size Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 486/742] gpiolib: keep the line state workqueue alive until device release Greg Kroah-Hartman
` (249 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Lianjie Wang, Viresh Kumar,
Bartosz Golaszewski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>
commit 9e3032dc4d92e6214ae687b4c474de9270ce74a2 upstream.
virtio_gpio_get_names() computes the size of the GET_LINE_NAMES response
as sizeof(*res) + gpio_names_size in an int, where gpio_names_size is a
u32 from the config space. A gpio_names_size of 0xffffffff makes the
size 0, devm_kzalloc() returns ZERO_SIZE_PTR, and reading the status
byte of the response through it oopses:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
RIP: 0010:_virtio_gpio_req+0x2b8/0x550
Call Trace:
virtio_gpio_probe+0xc2a/0xfc0
virtio_dev_probe+0xa7a/0xc50
Compute the size with struct_size() into a size_t.
Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lianjie Wang <lian@is.s.u-tokyo.ac.jp>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://patch.msgid.link/20261104195632.1702765-2-lian@is.s.u-tokyo.ac.jp
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpio/gpio-virtio.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -494,12 +494,13 @@ static const char **virtio_gpio_get_name
struct device *dev = &vgpio->vdev->dev;
u8 *gpio_names, *str;
const char **names;
- int i, ret, len;
+ size_t len;
+ int i, ret;
if (!gpio_names_size)
return NULL;
- len = sizeof(*res) + gpio_names_size;
+ len = struct_size(res, value, gpio_names_size);
res = devm_kzalloc(dev, len, GFP_KERNEL);
if (!res)
return NULL;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 486/742] gpiolib: keep the line state workqueue alive until device release
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (476 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 485/742] gpio: virtio: compute the line names size in a size_t Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 487/742] gpiolib: dont overwrite the entire flags field in gpiod_get_direction() Greg Kroah-Hartman
` (248 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Bartosz Golaszewski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
commit 2e002a1d05b1979006f3c46eb6cb5cc36e5630ac upstream.
gpiod_line_state_notify() races with a concurrent gpiochip_remove() which
unconditionally destroys the line state workqueue causing
a use-after-free situation where queue_work() can schedule a work on a
freed workqueue.
Keep the line state workqueue alive until GPIO device release.
Cc: stable@vger.kernel.org
Fixes: 07c61d4da43f ("gpiolib: notify user-space about in-kernel line state changes")
Closes: https://sashiko.dev/#/bug/linux-d0e9e518-2348-4fe3-857d-f3d61a42f159
Link: https://patch.msgid.link/20261110-gpio-line-state-wq-uaf-v2-1-ce6d8266656e@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpio/gpiolib-cdev.c | 2 +-
drivers/gpio/gpiolib.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -2762,6 +2762,7 @@ int gpiolib_cdev_register(struct gpio_ch
ret = cdev_device_add(&gdev->chrdev, &gdev->dev);
if (ret) {
destroy_workqueue(gdev->line_state_wq);
+ gdev->line_state_wq = NULL;
return ret;
}
@@ -2772,7 +2773,6 @@ int gpiolib_cdev_register(struct gpio_ch
void gpiolib_cdev_unregister(struct gpio_device *gdev)
{
- destroy_workqueue(gdev->line_state_wq);
cdev_device_del(&gdev->chrdev, &gdev->dev);
blocking_notifier_call_chain(&gdev->device_notifier, 0, NULL);
}
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -28,6 +28,7 @@
#include <linux/srcu.h>
#include <linux/string.h>
#include <linux/string_choices.h>
+#include <linux/workqueue.h>
#include <linux/gpio.h>
#include <linux/gpio/driver.h>
@@ -901,6 +902,9 @@ static void gpiodev_release(struct devic
synchronize_srcu(&gdev->desc_srcu);
cleanup_srcu_struct(&gdev->desc_srcu);
+ if (gdev->line_state_wq)
+ destroy_workqueue(gdev->line_state_wq);
+
ida_free(&gpio_ida, gdev->id);
kfree_const(gdev->label);
kfree(gdev->descs);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 487/742] gpiolib: dont overwrite the entire flags field in gpiod_get_direction()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (477 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 486/742] gpiolib: keep the line state workqueue alive until device release Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 488/742] gve: fix RX page refcount overflow from INT_MAX pagecnt_bias Greg Kroah-Hartman
` (247 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Kent Gibson, Bartosz Golaszewski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
commit 8ed87a9adf48703b5729f9d020eb15fa79ffb099 upstream.
gpiod_get_direction() snapshots desc->flags with READ_ONCE(), updates
FLAG_IS_OUT in the local copy and writes the whole word back with
WRITE_ONCE(). Any bit that a concurrent user sets or clears atomically in
between - for instance: FLAG_USED_AS_IRQ from gpiochip_lock_as_irq() - is
silently lost.
Update FLAG_IS_OUT with a single atomic assign_bit() directly on
desc->flags. The earlier READ_ONCE() snapshot is only used for the
open-drain check and stays.
Cc: stable@vger.kernel.org
Fixes: 2559f2e09211 ("gpio: reinforce desc->flags handling")
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-1-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpio/gpiolib.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -490,8 +490,7 @@ int gpiod_get_direction(struct gpio_desc
if (ret > 0)
ret = 1;
- assign_bit(GPIOD_FLAG_IS_OUT, &flags, !ret);
- WRITE_ONCE(desc->flags, flags);
+ assign_bit(GPIOD_FLAG_IS_OUT, &desc->flags, !ret);
return ret;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 488/742] gve: fix RX page refcount overflow from INT_MAX pagecnt_bias
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (478 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 487/742] gpiolib: dont overwrite the entire flags field in gpiod_get_direction() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 489/742] gve: refuse XDP on queue formats without XDP support Greg Kroah-Hartman
` (246 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Harshitha Ramamurthy,
Maciej Fijalkowski, Amaan Cheval, Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amaan Cheval <amaan.cheval@gmail.com>
commit 3946899dbeac2397fdd1727d74a3547d2b13caf3 upstream.
gve's GQI and DQO-QPL RX paths set every RX page's refcount to INT_MAX and
hand references to the stack by decrementing page_info->pagecnt_bias, to
avoid an atomic op per packet. This leaves no room for anyone else: while
a fresh page's buffer sits in an skb its refcount is already INT_MAX, so a
single get_page() from the stack overflows it to negative.
splice() of received TCP data into a pipe takes such a reference, and the
onward splice into a socket then fails: skb_splice_from_iter() sees
page_count() < 1, sendpage_ok() fails and the send returns -EIO (since
commit 2e910b95329c ("net: Add a function to splice pages into an
skbuff for MSG_SPLICE_PAGES")). tee() of the pipe fails with -EFAULT via
try_get_page(). On GQI the reuse check gve_rx_can_recycle_buffer() also
sees page_count() < pagecnt_bias, WARNs and calls gve_schedule_reset(),
so a task that merely pins a fresh RX page (e.g. holds spliced data in
an undrained tee() pipe) can reset the NIC.
Use USHRT_MAX in a u16, as igb, igc, ixgbe, i40e and hns3 do: the bias
only has to make the per-packet atomic rare, so a small value keeps
page_count() far below INT_MAX however many references the stack takes.
Refill by adding a fixed batch and setting the bias to it, which keeps
the rule `references = page_count() - bias` intact.
Refilling at 0 hands the driver's last reference to the consumer once
every USHRT_MAX handoffs rather than once every INT_MAX, which is only
safe because every consumer on these paths holds its reference until
the driver has recycled the buffer. The previous patch keeps it that
way by blocking XDP on DQO-QPL, so this one depends on it. Trees before
6.17, without commit d8a8ca14c937 ("gve: add XDP_TX and XDP_REDIRECT
support for DQ RDA"), still refuse XDP on every format but GQI-QPL in
verify_xdp_configuration(), so there this patch stands alone.
Reproduced on gVNIC in GQI-QPL mode (GCE n2-standard-8, 6.12) and in
DQO-RDA mode (GCE c3-standard-8, 6.12, where DQO-RDA still uses the
bias) with the help of relay.py -- a small splice(2) TCP proxy --
relaying a download while the RX ring is refilled with fresh pages:
ethtool -G eth0 rx 512 && ethtool -G eth0 rx 1024 # fresh RX pages
./relay.py $HOST 8080 & # splice()s both ways
for i in $(seq 200); do curl -so /dev/null \
--connect-to $HOST:80:127.0.0.1:8080 http://$HOST/file; done
Most downloads failed with EIO before the fix (tee() with EFAULT) and
all completed after it. relay.py is at the Link below.
This bug was found and fixed with the help of an AI coding assistant
(Claude Code) over an interactive session; it read the driver and
splice/pipe code and ran the tests above.
Link: https://github.com/amaanc/kernel-bias
Fixes: 9b8dd5e5ea48 ("gve: DQO: Add RX path")
Fixes: 58401b2a46e7 ("gve: Add rx buffer pagecnt bias")
Fixes: 82fd151d38d9 ("gve: Reduce alloc and copy costs in the GQ rx path")
Cc: stable@vger.kernel.org
Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com>
Tested-by: Harshitha Ramamurthy <hramamurthy@google.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Amaan Cheval <amaan.cheval@gmail.com>
Tested-by on v2:
Link: https://patch.msgid.link/20261112091451.22969-3-amaan.cheval@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/google/gve/gve.h | 2 +-
drivers/net/ethernet/google/gve/gve_buffer_mgmt_dqo.c | 4 ++--
drivers/net/ethernet/google/gve/gve_rx.c | 8 ++++----
drivers/net/ethernet/google/gve/gve_utils.c | 12 ++++--------
drivers/net/ethernet/google/gve/gve_utils.h | 2 +-
5 files changed, 12 insertions(+), 16 deletions(-)
--- a/drivers/net/ethernet/google/gve/gve.h
+++ b/drivers/net/ethernet/google/gve/gve.h
@@ -119,7 +119,7 @@ struct gve_rx_slot_page_info {
void *page_address;
u32 page_offset; /* offset to write to in page */
unsigned int buf_size;
- int pagecnt_bias; /* expected pagecnt if only the driver has a ref */
+ u16 pagecnt_bias; /* expected pagecnt if only the driver has a ref */
u16 pad; /* adjustment for rx padding */
u8 can_flip; /* tracks if the networking stack is using the page */
};
--- a/drivers/net/ethernet/google/gve/gve_buffer_mgmt_dqo.c
+++ b/drivers/net/ethernet/google/gve/gve_buffer_mgmt_dqo.c
@@ -149,8 +149,8 @@ int gve_alloc_qpl_page_dqo(struct gve_rx
buf_state->last_single_ref_offset = 0;
/* The page already has 1 ref. */
- page_ref_add(buf_state->page_info.page, INT_MAX - 1);
- buf_state->page_info.pagecnt_bias = INT_MAX;
+ page_ref_add(buf_state->page_info.page, USHRT_MAX - 1);
+ buf_state->page_info.pagecnt_bias = USHRT_MAX;
return 0;
}
--- a/drivers/net/ethernet/google/gve/gve_rx.c
+++ b/drivers/net/ethernet/google/gve/gve_rx.c
@@ -152,8 +152,8 @@ static void gve_setup_rx_buffer(struct g
page_info->buf_size = rx->packet_buffer_size;
*slot_addr = cpu_to_be64(addr);
/* The page already has 1 ref */
- page_ref_add(page, INT_MAX - 1);
- page_info->pagecnt_bias = INT_MAX;
+ page_ref_add(page, USHRT_MAX - 1);
+ page_info->pagecnt_bias = USHRT_MAX;
}
static int gve_rx_alloc_buffer(struct gve_priv *priv, struct device *dev,
@@ -230,8 +230,8 @@ static int gve_rx_prefill_pages(struct g
rx->qpl_copy_pool[j].buf_size = rx->packet_buffer_size;
/* The page already has 1 ref. */
- page_ref_add(page, INT_MAX - 1);
- rx->qpl_copy_pool[j].pagecnt_bias = INT_MAX;
+ page_ref_add(page, USHRT_MAX - 1);
+ rx->qpl_copy_pool[j].pagecnt_bias = USHRT_MAX;
}
}
--- a/drivers/net/ethernet/google/gve/gve_utils.c
+++ b/drivers/net/ethernet/google/gve/gve_utils.c
@@ -93,15 +93,11 @@ void gve_dec_pagecnt_bias(struct gve_rx_
{
page_info->pagecnt_bias--;
if (page_info->pagecnt_bias == 0) {
- int pagecount = page_count(page_info->page);
-
- /* If we have run out of bias - set it back up to INT_MAX
- * minus the existing refs.
+ /* Out of bias: take another batch. USHRT_MAX keeps this rare
+ * while leaving page_count() far below INT_MAX.
*/
- page_info->pagecnt_bias = INT_MAX - pagecount;
-
- /* Set pagecount back up to max. */
- page_ref_add(page_info->page, INT_MAX - pagecount);
+ page_info->pagecnt_bias = USHRT_MAX;
+ page_ref_add(page_info->page, USHRT_MAX);
}
}
--- a/drivers/net/ethernet/google/gve/gve_utils.h
+++ b/drivers/net/ethernet/google/gve/gve_utils.h
@@ -25,7 +25,7 @@ struct sk_buff *gve_rx_copy_data(struct
struct sk_buff *gve_rx_copy(struct net_device *dev, struct napi_struct *napi,
struct gve_rx_slot_page_info *page_info, u16 len);
-/* Decrement pagecnt_bias. Set it back to INT_MAX if it reached zero. */
+/* Decrement pagecnt_bias. Top it up by USHRT_MAX if it reached zero. */
void gve_dec_pagecnt_bias(struct gve_rx_slot_page_info *page_info);
void gve_add_napi(struct gve_priv *priv, int ntfy_idx,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 489/742] gve: refuse XDP on queue formats without XDP support
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (479 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 488/742] gve: fix RX page refcount overflow from INT_MAX pagecnt_bias Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 490/742] hugetlbfs: move hugetlbfs_free_inode tracepoint to ->destroy_inode() Greg Kroah-Hartman
` (245 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Joshua Washington, Amaan Cheval,
Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amaan Cheval <amaan.cheval@gmail.com>
commit 92c569c28b63067da0276f67f711a3ac20a62aca upstream.
Commit d8a8ca14c937 ("gve: add XDP_TX and XDP_REDIRECT support for DQ
RDA") enabled XDP on DQO-RDA by dropping the queue_format check from
verify_xdp_configuration(), which until then refused every format but
GQI-QPL. Nothing replaced it: gve_set_netdev_xdp_features() advertises
no XDP features for DQO-QPL and GQI-RDA and gve_xdp_xmit() rejects
both, but the core only checks that ndo_bpf exists, so a native XDP
program, and an AF_XDP socket on top of it, can still be attached on a
queue format the driver does not support.
The DQO-QPL RX path was never written for that. Its page accounting
assumes the driver keeps a reference of its own across every handoff:
gve_xdp_done_dqo() passes the buffer to xdp_do_redirect() and then
recycles it with gve_reuse_buffer(), so a redirect target that releases
the buffer synchronously, such as an AF_XDP socket in copy mode, can
drop the page's last reference when pagecnt_bias runs out. The page is
then freed while it is still DMA-mapped and registered in the QPL, and
the driver posts it back to the device.
GQI-RDA is no better off: an XDP_TX there goes through
gve_tx_fill_xdp(), which copies the frame into tx->tx_fifo, but a
raw-addressing TX ring never allocates that FIFO, so the first XDP_TX
writes through a NULL tx_fifo.base.
Refuse XDP setup in gve_verify_xdp_configuration() whenever the driver
advertises no XDP features for the current queue format, which today
means DQO-QPL and GQI-RDA. A zero-copy XSK pool bind is already refused
by the core for the same reason, and a copy-mode bind never reaches the
driver and is harmless without a program.
Fixes: d8a8ca14c937 ("gve: add XDP_TX and XDP_REDIRECT support for DQ RDA")
Cc: stable@vger.kernel.org
Reviewed-by: Joshua Washington <joshwash@google.com>
Signed-off-by: Amaan Cheval <amaan.cheval@gmail.com>
Tested-by on v2:
Link: https://patch.msgid.link/20261112091451.22969-2-amaan.cheval@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/google/gve/gve_main.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/drivers/net/ethernet/google/gve/gve_main.c
+++ b/drivers/net/ethernet/google/gve/gve_main.c
@@ -1819,6 +1819,12 @@ static int gve_verify_xdp_configuration(
struct gve_priv *priv = netdev_priv(dev);
u16 max_xdp_mtu;
+ if (!(dev->xdp_features & NETDEV_XDP_ACT_BASIC)) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "XDP is not supported on this queue format.");
+ return -EOPNOTSUPP;
+ }
+
if (dev->features & NETIF_F_GRO_HW) {
NL_SET_ERR_MSG_MOD(extack,
"XDP is not supported when HW-GRO is on.");
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 490/742] hugetlbfs: move hugetlbfs_free_inode tracepoint to ->destroy_inode()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (480 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 489/742] gve: refuse XDP on queue formats without XDP support Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 491/742] ieee802154: require CAP_NET_ADMIN for SIOCSIFADDR Greg Kroah-Hartman
` (244 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Joas Antonio dos Santos,
Andrew Morton, syzbot+91e1fc35f51774c479b2, David Hildenbrand,
Muchun Song, Oscar Salvador, Hongbo Li
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <joasantonio108@gmail.com>
commit ccf8bda05b19dc144bc7051936b08573476499ee upstream.
hugetlbfs_free_inode() calls trace_hugetlbfs_free_inode(), and the
hugetlbfs__inode event class records inode->i_sb->s_dev. ->free_inode()
runs from an RCU callback (destroy_inode() queues i_callback() with
call_rcu()), and Documentation/filesystems/porting.rst says that this
callback "is *NOT* ordered wrt superblock destruction; as the matter of
fact, the superblock and all associated structures might be already gone".
put_super() frees the superblock with call_rcu() followed by a workqueue
item (destroy_super_rcu() -> destroy_super_work()). syzbot hit this with
the event enabled:
BUG: KASAN: slab-use-after-free in trace_event_raw_event_hugetlbfs__inode+0x45b/0x4c0 include/trace/events/hugetlbfs.h:36
Read of size 4 at addr ffff888038850010 by task syz-executor952/6134
hugetlbfs_free_inode+0x15e/0x1f0 fs/hugetlbfs/inode.c:1182
i_callback+0x46/0x80 fs/inode.c:317
rcu_do_batch kernel/rcu/tree.c:2650 [inline]
rcu_core+0x5f0/0x1220 kernel/rcu/tree.c:2919
Allocated by task 6134:
alloc_super fs/super.c:326 [inline]
sget_fc+0x1ba/0x1f60 fs/super.c:874
hugetlbfs_get_tree+0x1e7/0x2b0 fs/hugetlbfs/inode.c:1431
Freed by task 855:
kfree+0x22b/0x6d0 mm/slub.c:6923
process_one_work+0xac7/0x1b10 kernel/workqueue.c:3495
Emit the event from hugetlbfs_destroy_inode() instead. destroy_inode()
calls ->destroy_inode() synchronously, before it queues the RCU callback,
while the superblock is still alive; hugetlbfs_destroy_inode() already
dereferences inode->i_sb there. ->free_inode() is left with only the
kmem_cache_free().
Since the event no longer fires from ->free_inode(), rename it to
hugetlbfs_destroy_inode so that its name matches where it is emitted, as
suggested by David and Muchun.
Found by syzbot; analysed and tested with the syzbot C reproducer on an
arm64 KASAN kernel.
Link: https://lore.kernel.org/20261102-b4-hugetlbfs-trace-v4-1-72371825bb5e@gmail.com
Fixes: 014ad7c42a69 ("hugetlbfs: use tracepoints in hugetlbfs functions.")
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: <syzbot+91e1fc35f51774c479b2@syzkaller.appspotmail.com>
Closes: https://lore.kernel.org/all/6ae27525.5451848c.f7707.0001.GAE@google.com/
Suggested-by: David Hildenbrand <david@kernel.org>
Suggested-by: Muchun Song <muchun.song@linux.dev>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Hongbo Li <lihongbo22@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/hugetlbfs/inode.c | 2 +-
include/trace/events/hugetlbfs.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1184,12 +1184,12 @@ static struct inode *hugetlbfs_alloc_ino
static void hugetlbfs_free_inode(struct inode *inode)
{
- trace_hugetlbfs_free_inode(inode);
kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode));
}
static void hugetlbfs_destroy_inode(struct inode *inode)
{
+ trace_hugetlbfs_destroy_inode(inode);
hugetlbfs_inc_free_inodes(HUGETLBFS_SB(inode->i_sb));
}
--- a/include/trace/events/hugetlbfs.h
+++ b/include/trace/events/hugetlbfs.h
@@ -72,7 +72,7 @@ DEFINE_EVENT(hugetlbfs__inode, hugetlbfs
TP_ARGS(inode)
);
-DEFINE_EVENT(hugetlbfs__inode, hugetlbfs_free_inode,
+DEFINE_EVENT(hugetlbfs__inode, hugetlbfs_destroy_inode,
TP_PROTO(struct inode *inode),
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 491/742] ieee802154: require CAP_NET_ADMIN for SIOCSIFADDR
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (481 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 490/742] hugetlbfs: move hugetlbfs_free_inode tracepoint to ->destroy_inode() Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 492/742] iavf: add missing PTP adjustment callbacks Greg Kroah-Hartman
` (243 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sung Byeongchan, Miquel Raynal,
Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <tjdqudcks0424@naver.com>
commit a0abc1e4c9d5b8b846abe4293b7bca578736da8a upstream.
PF_IEEE802154 DGRAM sockets are available to ordinary init-net processes.
Their family-specific SIOCSIFADDR path calls the netdev ioctl directly and
does not pass through the generic network-device setter capability check.
An unprivileged process can therefore change the PAN ID and short address
of a separately administrator-owned down WPAN interface.
In a local fakelb fixture, uid 1000 changed both identifiers and the values
remained active through a later administrator interface open in three of
three fresh KASAN boots.
Require CAP_NET_ADMIN in the socket network namespace before processing
SIOCSIFADDR. Keep SIOCGIFADDR and all existing state and value checks
unchanged.
The fixed kernel rejected the same unprivileged request with -EPERM and
preserved the administrator identity in three of three matched boots.
Administrator SET, running-device, invalid-value, wrong-device, cleanup,
later-open and recovery controls passed in all baseline and fixed runs.
The demonstrated impact is local cross-principal WPAN identity and policy
modification after privileged device setup. Memory corruption, disclosure,
RCE and LPE were not demonstrated.
Fixes: 9ec767160357 ("net: add IEEE 802.15.4 socket family implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Sung Byeongchan <tjdqudcks0424@naver.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://patch.msgid.link/20261107093601.619363-1-tjdqudcks0424@naver.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/ieee802154/socket.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/net/ieee802154/socket.c
+++ b/net/ieee802154/socket.c
@@ -128,6 +128,10 @@ static int ieee802154_dev_ioctl(struct s
int ret = -ENOIOCTLCMD;
struct net_device *dev;
+ if (cmd == SIOCSIFADDR &&
+ !ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN))
+ return -EPERM;
+
if (get_user_ifreq(&ifr, NULL, arg))
return -EFAULT;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 492/742] iavf: add missing PTP adjustment callbacks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (482 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 491/742] ieee802154: require CAP_NET_ADMIN for SIOCSIFADDR Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 493/742] iavf: fix ASQ command buffer leak on init failure Greg Kroah-Hartman
` (242 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Xuanqiang Luo, Vadim Fedorenko,
Jacob Keller, Rafal Romanowski, Tony Nguyen, Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
commit adbc4d0fff640541d7071421ac59dbd70da33b18 upstream.
The PTP hardware clock documentation requires drivers to implement all
callbacks and return -EOPNOTSUPP for unsupported features.
The iavf driver registers a PHC without adjtime or adjfine callbacks.
A userspace clock_adjtime(2) request reaches ptp_clock_adjtime(), where
ADJ_SETOFFSET calls adjtime and ADJ_FREQUENCY calls adjfine. The missing
callbacks can therefore cause a NULL dereference.
Provide both callbacks and return -EOPNOTSUPP for the unsupported
operations.
Fixes: d734223b2f0d ("iavf: add initial framework for registering PTP clock")
Link: https://docs.kernel.org/driver-api/ptp.html#writing-clock-drivers
Link: https://lore.kernel.org/all/20260826101004.100979-1-xuanqiang.luo@linux.dev/
Cc: stable@vger.kernel.org
Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Acked-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20261113004602.129864-7-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/intel/iavf/iavf_ptp.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
--- a/drivers/net/ethernet/intel/iavf/iavf_ptp.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_ptp.c
@@ -252,6 +252,16 @@ static int iavf_ptp_gettimex64(struct pt
return iavf_read_phc_indirect(adapter, ts, sts);
}
+static int iavf_ptp_adjfine(struct ptp_clock_info *info, long scaled_ppm)
+{
+ return -EOPNOTSUPP;
+}
+
+static int iavf_ptp_adjtime(struct ptp_clock_info *info, s64 delta)
+{
+ return -EOPNOTSUPP;
+}
+
static int iavf_ptp_settime64(struct ptp_clock_info *info,
const struct timespec64 *ts)
{
@@ -326,6 +336,8 @@ static int iavf_ptp_register_clock(struc
KBUILD_MODNAME, dev_name(dev));
ptp_info->owner = THIS_MODULE;
ptp_info->gettimex64 = iavf_ptp_gettimex64;
+ ptp_info->adjfine = iavf_ptp_adjfine;
+ ptp_info->adjtime = iavf_ptp_adjtime;
ptp_info->settime64 = iavf_ptp_settime64;
ptp_info->do_aux_work = iavf_ptp_do_aux_work;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 493/742] iavf: fix ASQ command buffer leak on init failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (483 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 492/742] iavf: add missing PTP adjustment callbacks Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 494/742] iavf: fix QoS capabilities memory leak Greg Kroah-Hartman
` (241 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Xuanqiang Luo, Jedrzej Jagielski,
Aleksandr Loktionov, Tony Nguyen, Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
commit 2a1f106379a90ce7ac63f96a57c241a4cf20a983 upstream.
iavf_alloc_adminq_asq_ring() allocates cmd_buf before the remaining ASQ
resources. If iavf_alloc_asq_bufs() or iavf_config_asq_regs() fails, the
unwind path elides cmd_buf while freeing the other allocations.
The ASQ count is not set until initialization succeeds, so the shutdown
path cannot reclaim the buffer. Free cmd_buf in the common unwind path.
Fixes: d358aa9a7a2d ("i40evf: init code and hardware support")
Cc: stable@vger.kernel.org
Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Reviewed-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20261113004602.129864-6-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/intel/iavf/iavf_adminq.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/net/ethernet/intel/iavf/iavf_adminq.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_adminq.c
@@ -60,6 +60,7 @@ static enum iavf_status iavf_alloc_admin
**/
static void iavf_free_adminq_asq(struct iavf_hw *hw)
{
+ iavf_free_virt_mem(hw, &hw->aq.asq.cmd_buf);
iavf_free_dma_mem(hw, &hw->aq.asq.desc_buf);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 494/742] iavf: fix QoS capabilities memory leak
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (484 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 493/742] iavf: fix ASQ command buffer leak on init failure Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:05 ` [PATCH 7.3 495/742] hwmon: Use per-device lockdep keys Greg Kroah-Hartman
` (240 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jedrzej Jagielski, Xuanqiang Luo,
Aleksandr Loktionov, Tony Nguyen, Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
commit 65f6ffb9001bf539aebd478798460477980b60c4 upstream.
Commit 4c1a457cb8b0 ("iavf: add support to exchange qos capabilities")
allocates adapter->qos_caps during probe, but iavf_remove() does not
free it. This leaks the allocation whenever an iavf device is removed.
Free adapter->qos_caps in iavf_remove().
Fixes: 4c1a457cb8b0 ("iavf: add support to exchange qos capabilities")
Cc: stable@vger.kernel.org
Reviewed-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20261113004602.129864-5-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/intel/iavf/iavf_main.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -5638,6 +5638,7 @@ static void iavf_remove(struct pci_dev *
iounmap(hw->hw_addr);
pci_release_regions(pdev);
kfree(adapter->vf_res);
+ kfree(adapter->qos_caps);
spin_lock_bh(&adapter->mac_vlan_list_lock);
/* If we got removed before an up/down sequence, we've got a filter
* hanging out there that we need to get rid of.
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 495/742] hwmon: Use per-device lockdep keys
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (485 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 494/742] iavf: fix QoS capabilities memory leak Greg Kroah-Hartman
@ 2026-12-04 10:05 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 496/742] hwmon: (ads7871) Add error handle from spi_setup() Greg Kroah-Hartman
` (239 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:05 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Davíð Steinn Geirsson,
Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <linux@roeck-us.net>
commit f17d77541c909b7c03fa29095d45f23a79699879 upstream.
Currently, mutex_init(&hwdev->lock) in __hwmon_device_register() assigns
a single static lockdep key to all hardware monitoring device locks. If
one hardware monitoring device accesses another hardware monitoring
device (for example, pwm-fan controlling a PWM output provided by
adt7470), lockdep sees two instances of the same lock class acquired in
sequence and reports a false-positive recursive locking warning.
Give each struct hwmon_device its own dynamic struct lock_class_key,
registered via lockdep_register_key() and initialized with
mutex_init_with_key() before any error path that calls
hwmon_dev_release(), and cleaned up with mutex_destroy() and
lockdep_unregister_key() in hwmon_dev_release(). This allows nested
locking across distinct hwmon devices while preserving full lockdep
deadlock and self-recursion detection.
Fixes: 3ad2a7b9b15d ("hwmon: Serialize accesses in hwmon core")
Cc: stable@vger.kernel.org
Cc: Davíð Steinn Geirsson <david@dsg.is>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/hwmon.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -18,6 +18,7 @@
#include <linux/idr.h>
#include <linux/kstrtox.h>
#include <linux/list.h>
+#include <linux/lockdep.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pci.h>
@@ -37,6 +38,7 @@ struct hwmon_device {
const char *label;
struct device dev;
const struct hwmon_chip_info *chip;
+ struct lock_class_key lock_key;
struct mutex lock;
struct list_head tzdata;
struct attribute_group group;
@@ -136,6 +138,8 @@ static void hwmon_dev_release(struct dev
hwmon_free_attrs(hwdev->group.attrs_const);
kfree(hwdev->groups);
kfree(hwdev->label);
+ mutex_destroy(&hwdev->lock);
+ lockdep_unregister_key(&hwdev->lock_key);
kfree(hwdev);
}
@@ -933,6 +937,8 @@ __hwmon_device_register(struct device *d
}
hdev = &hwdev->dev;
+ lockdep_register_key(&hwdev->lock_key);
+ mutex_init_with_key(&hwdev->lock, &hwdev->lock_key);
if (chip) {
const struct attribute **attrs;
@@ -987,7 +993,6 @@ __hwmon_device_register(struct device *d
tdev = tdev->parent;
hdev->of_node = tdev ? tdev->of_node : NULL;
hwdev->chip = chip;
- mutex_init(&hwdev->lock);
dev_set_drvdata(hdev, drvdata);
dev_set_name(hdev, HWMON_ID_FORMAT, id);
err = device_register(hdev);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 496/742] hwmon: (ads7871) Add error handle from spi_setup()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (486 preceding siblings ...)
2026-12-04 10:05 ` [PATCH 7.3 495/742] hwmon: Use per-device lockdep keys Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 497/742] hwmon: (dell-smm) Reject a fan_max that the BIOS cannot take Greg Kroah-Hartman
` (238 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Vítor Hugo Silva, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vítor Hugo Silva <vitorhg20080@gmail.com>
commit 449cdc5e29c63aa66b41ce8c2783f6b0d84c62b0 upstream.
The ads7871 probe() ignores the spi_setup() error return value
and it attempts to write to registers even if spi_setup() fails.
Return the setup error before accessing any registers.
AI was used for peer-review the patch.
Fixes: e0c70b8078629 ("hwmon: add TI ads7871 a/d converter driver")
Cc: stable@vger.kernel.org
Signed-off-by: Vítor Hugo Silva <vitorhg20080@gmail.com>
Link: https://patch.msgid.link/20261118092928.163553-1-vitorhg20080@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/ads7871.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/drivers/hwmon/ads7871.c
+++ b/drivers/hwmon/ads7871.c
@@ -187,7 +187,9 @@ static int ads7871_probe(struct spi_devi
/* Configure the SPI bus */
spi->mode = (SPI_MODE_0);
spi->bits_per_word = 8;
- spi_setup(spi);
+ ret = spi_setup(spi);
+ if (ret)
+ return ret;
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 497/742] hwmon: (dell-smm) Reject a fan_max that the BIOS cannot take
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (487 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 496/742] hwmon: (ads7871) Add error handle from spi_setup() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 498/742] hwmon: (dell-smm) Reject out-of-range pwm values Greg Kroah-Hartman
` (237 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Rosen Penev, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <rosenp@gmail.com>
commit 69624d7d821ec7d3f9801e86acf555a8edc82f99 upstream.
The fan_max module parameter is used without any range check, unlike
fan_mult. dell_smm_init_hwmon() allocates the nominal speed table with
devm_kmalloc_array(dev, data->i8k_fan_max + 1, ...)
and fan_max=4294967295 wraps the count to 0. devm_kmalloc() then
returns ZERO_SIZE_PTR, which the first successful nominal speed call
writes through.
Values above 255 are also meaningless: the fan state is passed to the
BIOS as fan | (speed << 8), so the higher bits end up in other parts of
the request. Large values that do not wrap still cost one SMM call per
state and fan while probing.
Fail probing if the maximum fan state does not fit in a byte, like the
existing check for fan_mult.
Fixes: 81474fc2fae9 ("i8k: Add support for configurable maximum fan speed value")
cc: stable@vger.kernel.org
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/6d3b86acf6713e9286e60ecf788582e840946238.1794633179.git.rosenp@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/dell-smm-hwmon.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -1248,6 +1248,12 @@ static int dell_smm_init_data(struct dev
return -EINVAL;
}
data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH;
+ /* The BIOS takes the fan state in a single byte */
+ if (data->i8k_fan_max > U8_MAX) {
+ dev_err(dev, "maximum fan state %u is too large (max %u)\n",
+ data->i8k_fan_max, U8_MAX);
+ return -EINVAL;
+ }
data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max);
return 0;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 498/742] hwmon: (dell-smm) Reject out-of-range pwm values
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (488 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 497/742] hwmon: (dell-smm) Reject a fan_max that the BIOS cannot take Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 499/742] hwmon: (nct6775) Fix incorrect struct cast in beep callbacks Greg Kroah-Hartman
` (236 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Rosen Penev, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <rosenp@gmail.com>
commit 7494b0c50c9fcd9f9f5235777bb506dd45676557 upstream.
dell_smm_write() scales the value written to pwmN with
DIV_ROUND_CLOSEST(val, data->i8k_pwm_mult)
before clamping the result to the valid fan states. The rounding adds
i8k_pwm_mult / 2 to val first, which overflows for values near
LONG_MAX and wraps to a large negative number. That is then clamped to
0, so writing a huge value turns the fan off instead of running it at
the highest speed. With the default fan_max of 2, writing any value
from LONG_MAX - 63 up to LONG_MAX selects fan state 0.
The pwm range is well defined, so return -EINVAL for values outside
0 to 255, as is the convention for pwm attributes.
Fixes: e7f5f275c62a ("i8k: Implement hwmon based fan speed control")
Cc: stable@vger.kernel.org
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20261118040417.19049-1-rosenp@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/dell-smm-hwmon.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -1030,6 +1030,9 @@ static int dell_smm_write(struct device
case hwmon_pwm:
switch (attr) {
case hwmon_pwm_input:
+ if (val < 0 || val > 255)
+ return -EINVAL;
+
pwm = clamp_val(DIV_ROUND_CLOSEST(val, data->i8k_pwm_mult), 0,
data->i8k_fan_max);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 499/742] hwmon: (nct6775) Fix incorrect struct cast in beep callbacks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (489 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 498/742] hwmon: (dell-smm) Reject out-of-range pwm values Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 500/742] hwmon: (nct6775) Fix swapped temperature tolerance register writes Greg Kroah-Hartman
` (235 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ziheng Wei, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ziheng Wei <zihengw03@163.com>
commit 07571b42cf41d0e42fb890713340a8f0a3c03d56 upstream.
On big-endian architectures, writing the in[1-*]_beep, fan[1-*]_beep
and temp[1-*]_beep sysfs attributes in the nct6775 hardware monitoring
driver always changes channel 0 due to an incorrect struct downcast in
the beep store callbacks.
The driver defines these sysfs attributes using SENSOR_TEMPLATE(),
which initializes them as struct sensor_device_attribute (where the
index is a 32-bit int). However, the sysfs store callbacks
nct6775_store_beep() and store_temp_beep() incorrectly downcast the
attribute to a struct sensor_device_attribute_2 (where the index is
an 8-bit u8).
Because both structs start with struct device_attribute,
container_of() resolves to the same base address. On big-endian
architectures, reading the 8-bit index field from the memory layout
of a 32-bit int fetches the most significant byte (which is 0),
rather than the intended channel number.
This type mismatch causes all beep writes to change the beep setting
of channel 0, regardless of which channel the user targeted.
Fix the type casts in the two store callbacks.
Not runtime-tested: the only big-endian machine available to me (s390x
under QEMU) cannot build the platform driver (no HAS_IOPORT).
Fixes: 30846993047b ("hwmon: (nct6775) Add support for beep attributes")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
Link: https://patch.msgid.link/20261115080203.910033-2-zihengw03@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/nct6775-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1820,7 +1820,7 @@ EXPORT_SYMBOL_GPL(nct6775_show_beep);
ssize_t
nct6775_store_beep(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
- struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
+ struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
struct nct6775_data *data = dev_get_drvdata(dev);
int nr = data->BEEP_BITS[sattr->index];
int regindex = nr >> 3;
@@ -1874,7 +1874,7 @@ static ssize_t
store_temp_beep(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
+ struct sensor_device_attribute *sattr = to_sensor_dev_attr(attr);
struct nct6775_data *data = dev_get_drvdata(dev);
int nr, bit, regindex;
unsigned long val;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 500/742] hwmon: (nct6775) Fix swapped temperature tolerance register writes
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (490 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 499/742] hwmon: (nct6775) Fix incorrect struct cast in beep callbacks Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 501/742] hwmon: (nct6775) Fix tolerance bitmask when reading REG_FAN_MODE Greg Kroah-Hartman
` (234 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Anton Lundin, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <linux@roeck-us.net>
commit 3cc60eb1b9aa07da81593f8f027efefb67185144 upstream.
sensor_dev_template_pwm_temp_tolerance uses index 0 (backed by
REG_FAN_MODE via pwm_update_registers()) while
sensor_dev_template_pwm_crit_temp_tolerance uses index 1 (backed by
REG_CRITICAL_TEMP_TOLERANCE). However, store_temp_tolerance() checks
if (index) with inverted branches.
As a result, writing to pwm*_temp_tolerance writes the new tolerance to
REG_CRITICAL_TEMP_TOLERANCE instead of REG_FAN_MODE, while writing to
pwm*_crit_temp_tolerance updates REG_FAN_MODE with temp_tolerance[0] and
leaves REG_CRITICAL_TEMP_TOLERANCE unchanged.
Invert the index check in store_temp_tolerance() so index 0 updates fan
mode registers via pwm_update_registers() and index 1 writes to
REG_CRITICAL_TEMP_TOLERANCE.
Fixes: cdcaeceb74ff ("hwmon: (nct6775) Add support for automatic fan control")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Cc: Anton Lundin <glance@ac2.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/nct6775-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -2960,7 +2960,7 @@ store_temp_tolerance(struct device *dev,
mutex_lock(&data->update_lock);
data->temp_tolerance[index][nr] = val;
- if (index)
+ if (!index)
err = pwm_update_registers(data, nr);
else
err = nct6775_write_value(data, data->REG_CRITICAL_TEMP_TOLERANCE[nr], val);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 501/742] hwmon: (nct6775) Fix tolerance bitmask when reading REG_FAN_MODE
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (491 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 500/742] hwmon: (nct6775) Fix swapped temperature tolerance register writes Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 502/742] hwmon: (sht3x) Fix overflow when writing alert limits Greg Kroah-Hartman
` (233 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Anton Lundin, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <linux@roeck-us.net>
commit 39cd14ca605d1aa55a0ad26767014a88b5c39f20 upstream.
On NCT6775, bits 0..3 of REG_FAN_MODE hold the temperature or fan speed
tolerance (tolerance_mask is 0x0f), whereas on NCT5525, NCT6106,
NCT6116, NCT6126, and NCT6776+, only bits 0..2 hold the temperature
tolerance or low 3 bits of speed tolerance (tolerance_mask is 0x07).
However, nct6775_update_pwm() masks fanmodecfg with a hardcoded 0x0f.
When bit 3 of REG_FAN_MODE is set on chips where tolerance_mask is 0x07,
nct6775_update_pwm() includes bit 3 in temp_tolerance[0] and
target_speed_tolerance, corrupting reported tolerance values and causing
pwm_update_registers() to OR bit 3 back into REG_FAN_MODE.
Mask fanmodecfg with data->tolerance_mask instead of 0x0f in
nct6775_update_pwm().
Fixes: cdcaeceb74ff ("hwmon: (nct6775) Add support for automatic fan control")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Cc: Anton Lundin <glance@ac2.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/nct6775-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1419,10 +1419,10 @@ static int nct6775_update_pwm(struct dev
if (!data->temp_tolerance[0][i] ||
data->pwm_enable[i] != speed_cruise)
- data->temp_tolerance[0][i] = fanmodecfg & 0x0f;
+ data->temp_tolerance[0][i] = fanmodecfg & data->tolerance_mask;
if (!data->target_speed_tolerance[i] ||
data->pwm_enable[i] == speed_cruise) {
- u8 t = fanmodecfg & 0x0f;
+ u8 t = fanmodecfg & data->tolerance_mask;
if (data->REG_TOLERANCE_H) {
err = nct6775_read_value(data, data->REG_TOLERANCE_H[i], ®);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 502/742] hwmon: (sht3x) Fix overflow when writing alert limits
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (492 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 501/742] hwmon: (nct6775) Fix tolerance bitmask when reading REG_FAN_MODE Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 503/742] hwmon: (w83791d) Fix incorrect struct cast in show_temp1() and store_temp1() Greg Kroah-Hartman
` (232 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Wayne Ho, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayne Ho <wayneho219@gmail.com>
commit e6872defbb2eb1dc61b3ea168ca13e1362efbd86 upstream.
limit_write() encodes the limits with 32-bit arithmetic, which overflows
for the largest accepted values:
(130000 + 45000) * 24543 = 4295025000 > U32_MAX
100000 * 42950 = 4295000000 > U32_MAX
Writing 130000 to temp1_max therefore programs -45 degrees C, and
writing 100000 to humidity1_max programs 0 %RH, so a limit set to its
maximum makes the alert fire instead of never firing. Reading the
attributes back returns the cached values, so this is not visible from
sysfs.
Use 64-bit arithmetic and clamp each result to its field width. Even
with 64-bit arithmetic, 130000 encodes to 0x200, which overflows the
9-bit temperature field, and 100000 encodes to 0x10000, which is still 0
after masking.
Prepared with the help of an AI coding assistant (Claude); I reproduced
the bug and tested the fix on hardware.
Fixes: 7c84f7f80d6f ("hwmon: add support for Sensirion SHT3x sensors")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/linux-hwmon/20260725222229.EA69B1F000E9@smtp.kernel.org/
Signed-off-by: Wayne Ho <wayneho219@gmail.com>
Link: https://patch.msgid.link/20261113054857.97048-1-wayneho219@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/sht3x.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/hwmon/sht3x.c
+++ b/drivers/hwmon/sht3x.c
@@ -387,8 +387,8 @@ static size_t limit_write(struct device
* adapted for fixed point arithmetic and packed the same as
* in limit_read()
*/
- raw = ((u32)(temperature + 45000) * 24543) >> (16 + 7);
- raw |= ((humidity * 42950) >> 16) & 0xfe00;
+ raw = min(((u64)(temperature + 45000) * 24543) >> (16 + 7), 0x1ff);
+ raw |= min(((u64)humidity * 42950) >> 16, 0xffff) & 0xfe00;
put_unaligned_be16(raw, position);
position += SHT3X_WORD_LEN;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 503/742] hwmon: (w83791d) Fix incorrect struct cast in show_temp1() and store_temp1()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (493 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 502/742] hwmon: (sht3x) Fix overflow when writing alert limits Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 504/742] hwmon: (w83792d) " Greg Kroah-Hartman
` (231 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ziheng Wei, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ziheng Wei <zihengw03@163.com>
commit fb47eb0528d275362b01423ceb956e3ce1f9d715 upstream.
On big-endian architectures, accessing the temp1_max and temp1_max_hyst
sysfs attributes in the w83791d hardware monitoring driver uses a huge
out-of-bounds index, because show_temp1() and store_temp1() downcast the
attribute to the wrong struct.
The driver defines the temp1_* attributes with SENSOR_ATTR_2(), which
initializes them as struct sensor_device_attribute_2 (where the index is
an 8-bit u8). The temp1_input attribute has index 0, temp1_max has
index 1 and temp1_max_hyst has index 2. However, show_temp1() and
store_temp1() downcast the attribute to struct sensor_device_attribute
(where the index is a 32-bit int) and use it to index data->temp1[].
Because both structs start with struct device_attribute, container_of()
resolves to the same base address, but the field widths differ. On
big-endian architectures, reading the 32-bit int from the memory layout
of the two u8 fields yields index << 24: 0x01000000 for temp1_max and
0x02000000 for temp1_max_hyst, instead of 1 and 2. data->temp1[] has
only 3 elements, so the access runs off the end of the array by up to
32 MiB.
Fix the type casts in show_temp1() and store_temp1().
Confirmed on a big-endian s390x QEMU guest with the driver bound to an
emulated chip: temp1_max and temp1_max_hyst read 0 instead of the
register values. Not tested on real hardware.
Fixes: 9873964d6eb2 ("[PATCH] HWMON: w83791d: New hardware monitoring driver for the Winbond W83791D")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
Link: https://patch.msgid.link/20261115080203.910033-3-zihengw03@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/w83791d.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -924,7 +924,7 @@ static struct sensor_device_attribute sd
static ssize_t show_temp1(struct device *dev, struct device_attribute *devattr,
char *buf)
{
- struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
struct w83791d_data *data = w83791d_update_device(dev);
return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp1[attr->index]));
}
@@ -932,7 +932,7 @@ static ssize_t show_temp1(struct device
static ssize_t store_temp1(struct device *dev, struct device_attribute *devattr,
const char *buf, size_t count)
{
- struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+ struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
struct i2c_client *client = to_i2c_client(dev);
struct w83791d_data *data = i2c_get_clientdata(client);
int nr = attr->index;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 504/742] hwmon: (w83792d) Fix incorrect struct cast in show_temp1() and store_temp1()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (494 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 503/742] hwmon: (w83791d) Fix incorrect struct cast in show_temp1() and store_temp1() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 505/742] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() Greg Kroah-Hartman
` (230 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ziheng Wei, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ziheng Wei <zihengw03@163.com>
commit d4f7d626cc1a966dca930a5ba07e8c4739adceb0 upstream.
On big-endian architectures, accessing the temp1_max and temp1_max_hyst
sysfs attributes in the w83792d hardware monitoring driver uses a huge
out-of-bounds index, because show_temp1() and store_temp1() downcast the
attribute to the wrong struct.
The driver defines the temp1_* attributes with SENSOR_DEVICE_ATTR_2(),
which initializes them as struct sensor_device_attribute_2 (where the
index is an 8-bit u8). The temp1_input attribute has index 0, temp1_max
has index 1 and temp1_max_hyst has index 2. However, show_temp1() and
store_temp1() downcast the attribute to struct sensor_device_attribute
(where the index is a 32-bit int) and use it to index data->temp1[].
Because both structs start with struct device_attribute, container_of()
resolves to the same base address, but the field widths differ. On
big-endian architectures, reading the 32-bit int from the memory layout
of the two u8 fields yields index << 24: 0x01000000 for temp1_max and
0x02000000 for temp1_max_hyst, instead of 1 and 2. data->temp1[] has
only 3 elements, so the access runs off the end of the array by up to
32 MiB.
Fix the type casts in show_temp1() and store_temp1().
Confirmed on a big-endian s390x QEMU guest with the driver bound to an
emulated chip: temp1_max and temp1_max_hyst read 0 instead of the
register values. Not tested on real hardware.
Fixes: 1f8dae31fe8d ("[PATCH] hwmon: w83792d use arrays of attributes")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
Link: https://patch.msgid.link/20261115080203.910033-4-zihengw03@163.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/w83792d.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -487,7 +487,7 @@ store_fan_div(struct device *dev, struct
static ssize_t show_temp1(struct device *dev, struct device_attribute *attr,
char *buf)
{
- struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+ struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
int nr = sensor_attr->index;
struct w83792d_data *data = w83792d_update_device(dev);
return sprintf(buf, "%d\n", TEMP1_FROM_REG(data->temp1[nr]));
@@ -496,7 +496,7 @@ static ssize_t show_temp1(struct device
static ssize_t store_temp1(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+ struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr);
int nr = sensor_attr->index;
struct i2c_client *client = to_i2c_client(dev);
struct w83792d_data *data = i2c_get_clientdata(client);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 505/742] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (495 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 504/742] hwmon: (w83792d) " Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 506/742] Input: da7280 - do not advertise FF_GAIN Greg Kroah-Hartman
` (229 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Wentao Liang, Dmitry Torokhov
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <vulab@iscas.ac.cn>
commit f5f8cc539f8b2bd5324c03dfce8cca57284653e6 upstream.
pm_runtime_get_sync() unconditionally increments the runtime PM usage
counter. If mutex_lock_interruptible() is interrupted, the function
returns without dropping that reference, so the usage count stays
elevated for as long as the driver is bound and the device can no longer
be autosuspended. Drop the reference on the error path.
Use pm_runtime_put_autosuspend() rather than the synchronous variant
there: nothing has been done to the device on this path, so there is
nothing to wait for, and with the 2 s autosuspend delay the driver
configures the put only arms the autosuspend timer instead of suspending
the device.
Fixes: 672865080a8f ("Input: cyapa - add runtime power management support")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/1794120347.2701234.vulab@iscas.ac.cn
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/input/mouse/cyapa.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/drivers/input/mouse/cyapa.c
+++ b/drivers/input/mouse/cyapa.c
@@ -901,8 +901,10 @@ static ssize_t cyapa_update_rt_suspend_s
pm_runtime_get_sync(dev);
error = mutex_lock_interruptible(&cyapa->state_sync_lock);
- if (error)
+ if (error) {
+ pm_runtime_put_autosuspend(dev);
return error;
+ }
cyapa->runtime_suspend_sleep_time = min_t(u16, time, 1000);
cyapa->runtime_suspend_power_mode =
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 506/742] Input: da7280 - do not advertise FF_GAIN
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (496 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 505/742] Input: cyapa - fix runtime PM leak in cyapa_update_rt_suspend_scanrate() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 507/742] Input: goodix - reject a bak_ref length that cannot hold the checksum Greg Kroah-Hartman
` (228 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ivan Verbovoy, Dmitry Torokhov
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Verbovoy <ivanverbovoy@gmail.com>
commit c1f4db7e869ce7dafd1811a75b392740985e1199 upstream.
The driver sets FF_GAIN in the device's force feedback capabilities but
provides no set_gain() callback. input_ff_event() checks the capability
bit, not the callback, before calling ff->set_gain(), so an EV_FF/FF_GAIN
event written to the event node by any process with write access to it
calls through a NULL pointer.
The driver has no global gain to set: a constant effect carries its own
level, and a periodic effect plays a pattern from the device's waveform
memory. Drop FF_GAIN from the capabilities, so that input_ff_event()
ignores such an event.
Fixes: cd3f609823a5 ("Input: new da7280 haptic driver")
Cc: stable@vger.kernel.org
Signed-off-by: Ivan Verbovoy <ivanverbovoy@gmail.com>
Link: https://patch.msgid.link/20261109-da7280-fixes-v1-1-09cc3650261c@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/input/misc/da7280.c | 1 -
1 file changed, 1 deletion(-)
--- a/drivers/input/misc/da7280.c
+++ b/drivers/input/misc/da7280.c
@@ -1227,7 +1227,6 @@ static int da7280_probe(struct i2c_clien
input_set_capability(haptics->input_dev, EV_FF, FF_PERIODIC);
input_set_capability(haptics->input_dev, EV_FF, FF_CUSTOM);
input_set_capability(haptics->input_dev, EV_FF, FF_CONSTANT);
- input_set_capability(haptics->input_dev, EV_FF, FF_GAIN);
error = input_ff_create(haptics->input_dev,
DA7280_FF_EFFECT_COUNT_MAX);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 507/742] Input: goodix - reject a bak_ref length that cannot hold the checksum
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (497 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 506/742] Input: da7280 - do not advertise FF_GAIN Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 508/742] Input: trackpoint - add new TP JYT_NDT device variant id 7 Greg Kroah-Hartman
` (227 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Liu Chao, Dmitry Torokhov
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Chao <liuc63@xiaopeng.com>
commit b3249e446d47c65dc09611705ad4d0a7587405ac upstream.
driver_num and sensor_num are taken from the touchscreen config. A
config with driver_num 1 and sensor_num 0 yields a bak_ref length of
0, for which devm_kzalloc() returns ZERO_SIZE_PTR. That pointer
passes the !ts->bak_ref check and the subsequent
ts->bak_ref[ts->bak_ref_len - 1] = 1 writes before the allocation.
Reject a length that leaves no room for the trailing checksum before
allocating, and skip saving a bak_ref that was never allocated.
Without the second check a rejected length leaves bak_ref NULL while
bak_ref_len still holds the bogus value, and goodix_save_bak_ref()
then writes through the same index on suspend.
Fixes: 09182ed20c04 ("Input: goodix - add support for controllers without flash")
Cc: stable@vger.kernel.org
Signed-off-by: Liu Chao <liuc63@xiaopeng.com>
Link: https://patch.msgid.link/20261106075129.3106093-1-liuc63@xiaopeng.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/input/touchscreen/goodix_fwupload.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/drivers/input/touchscreen/goodix_fwupload.c
+++ b/drivers/input/touchscreen/goodix_fwupload.c
@@ -281,6 +281,8 @@ static int goodix_prepare_bak_ref(struct
driver_num, sensor_num, have_key);
ts->bak_ref_len = (driver_num * (sensor_num - 2) + 2) * 2;
+ if (ts->bak_ref_len < 2)
+ return -EINVAL;
ts->bak_ref = devm_kzalloc(&ts->client->dev,
ts->bak_ref_len, GFP_KERNEL);
@@ -409,7 +411,7 @@ void goodix_save_bak_ref(struct goodix_t
int error;
u8 val;
- if (!ts->firmware_name)
+ if (!ts->firmware_name || !ts->bak_ref)
return;
error = goodix_i2c_read(ts->client, GOODIX_REG_STATUS, &val, 1);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 508/742] Input: trackpoint - add new TP JYT_NDT device variant id 7
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (498 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 507/742] Input: goodix - reject a bak_ref length that cannot hold the checksum Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 509/742] Input: xpad - add GameSir G7 Pro support Greg Kroah-Hartman
` (226 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Yuan Yao, Dmitry Torokhov
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Yao <yaoyuan0329os@gmail.com>
commit ce8010f11f3ea62f8675e9bc921ee485aef82019 upstream.
The new trackpoint variant id 7 is found on Lenovo Thinkpad X14
Gen1 laptop(Product Name: 21XMA006CD), it belongs to JYT_NDT with
confirmation from Vishnu Sankar in Lenovo. now it's incorrectly
probed as Generic or Logitech PS/2 mouse.
Add the variant id 7 to match the TP_READ_ID command return
value, probe the device as trackpoint correctly.
BEFORE:
input: PS/2 Generic Mouse as /devices/platform/i8042/serio1/input/input63
AFTER:
psmouse serio1: trackpoint: JYT_NDT TrackPoint firmware: 0xa1, buttons: 3/3
input: TPPS/2 JYT_NDT TrackPoint as /devices/platform/i8042/serio1/input/input8
Signed-off-by: Yuan Yao <yaoyuan@linux.alibaba.com>
Link: https://patch.msgid.link/20261113112202.10304-2-yaoyuan@linux.alibaba.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/input/mouse/trackpoint.c | 2 ++
drivers/input/mouse/trackpoint.h | 1 +
2 files changed, 3 insertions(+)
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -25,6 +25,7 @@ static const char * const trackpoint_var
[TP_VARIANT_NXP] = "NXP",
[TP_VARIANT_JYT_SYNAPTICS] = "JYT_Synaptics",
[TP_VARIANT_SYNAPTICS] = "Synaptics",
+ [TP_VARIANT_JYT_NDT] = "JYT_NDT"
};
/*
@@ -285,6 +286,7 @@ static int trackpoint_start_protocol(str
case TP_VARIANT_ELAN:
case TP_VARIANT_NXP:
case TP_VARIANT_JYT_SYNAPTICS:
+ case TP_VARIANT_JYT_NDT:
case TP_VARIANT_SYNAPTICS:
if (variant_id)
*variant_id = param[0];
--- a/drivers/input/mouse/trackpoint.h
+++ b/drivers/input/mouse/trackpoint.h
@@ -30,6 +30,7 @@
#define TP_VARIANT_NXP 0x04
#define TP_VARIANT_JYT_SYNAPTICS 0x05
#define TP_VARIANT_SYNAPTICS 0x06
+#define TP_VARIANT_JYT_NDT 0x07
/*
* Commands
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 509/742] Input: xpad - add GameSir G7 Pro support
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (499 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 508/742] Input: trackpoint - add new TP JYT_NDT device variant id 7 Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 510/742] Input: xpad - add support to Hori Real Arcade Pro 4 Greg Kroah-Hartman
` (225 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sergei Kuznetsov, Dmitry Torokhov
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergei Kuznetsov <kernel@phnx47.net>
commit d1eb0afa9140c740ff29985f9b89b1926b1b502d upstream.
Add the GameSir G7 Pro (0x3537:0x109c) in Xbox mode, connected through
its 2.4G dongle. The controller uses the GIP protocol and was already
bound through the GameSir vendor match, but showed up as "Generic X-Box
pad" and its Share button was not reported.
Set MAP_SHARE_BUTTON so the Share button is reported as KEY_RECORD.
Signed-off-by: Sergei Kuznetsov <kernel@phnx47.net>
Link: https://patch.msgid.link/20261023121314.8024-1-kernel@phnx47.net
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/input/joystick/xpad.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -409,6 +409,7 @@ static const struct xpad_device {
{ 0x3537, 0x100f, "GameSir Nova 2 Lite", 0, XTYPE_XBOX360 },
{ 0x3537, 0x1010, "GameSir G7 SE", 0, XTYPE_XBOXONE },
{ 0x3537, 0x1040, "GameSir Nova Lite", 0, XTYPE_XBOX360 },
+ { 0x3537, 0x109c, "GameSir G7 Pro", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
{ 0x3651, 0x1000, "CRKD SG", 0, XTYPE_XBOX360 },
{ 0x366c, 0x0005, "ByoWave Proteus Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE, FLAG_DELAY_INIT },
{ 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX },
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 510/742] Input: xpad - add support to Hori Real Arcade Pro 4
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (500 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 509/742] Input: xpad - add GameSir G7 Pro support Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 511/742] Input: xpad.c - add support for Hyperkin Xenon, Hori Taiko Controller DX, and 8BitDo M30 Greg Kroah-Hartman
` (224 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Juan Parrado, Dmitry Torokhov
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juan Parrado <jparrado.1817@gmail.com>
commit 9cfed185db8f1c12bf2629fb37c77d85bf93b193 upstream.
The HORI Real Arcade Pro 4 in PC mode is currently recognized by xpad.c as
a 'Generic X-Box pad' and works out of the box. However, this generic name
does not match the actual device name, making it difficult for users to
distinguish this controller when multiple devices are connected.
Tested on physical hardware. The proposed change works perfectly as is.
The MAP_TRIGGERS_TO_BUTTONS parameter does not work here. Other arcade
sticks use an identical configuration, such as the 'Street Fighter IV
FightPad' and the 'Hori Real Arcade Pro.EX Premium VLX'.
Signed-off-by: Juan Parrado <jparrado.1817@gmail.com>
Link: https://patch.msgid.link/20261109194118.18127-1-jparrado1817@gmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/input/joystick/xpad.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -255,6 +255,7 @@ static const struct xpad_device {
{ 0x0f0d, 0x0063, "Hori Real Arcade Pro Hayabusa (USA) Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
{ 0x0f0d, 0x0067, "HORIPAD ONE", 0, XTYPE_XBOXONE },
{ 0x0f0d, 0x0078, "Hori Real Arcade Pro V Kai Xbox One", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
+ { 0x0f0d, 0x008c, "Real Arcade Pro 4", 0, XTYPE_XBOX360 },
{ 0x0f0d, 0x00c5, "Hori Fighting Commander ONE", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE },
{ 0x0f0d, 0x00dc, "HORIPAD FPS for Nintendo Switch", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
{ 0x0f0d, 0x0151, "Hori Racing Wheel Overdrive for Xbox Series X", 0, XTYPE_XBOXONE },
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 511/742] Input: xpad.c - add support for Hyperkin Xenon, Hori Taiko Controller DX, and 8BitDo M30
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (501 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 510/742] Input: xpad - add support to Hori Real Arcade Pro 4 Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 512/742] iommufd: fix cleanup when adding memfd folio pins fails Greg Kroah-Hartman
` (223 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Juan Parrado, Dmitry Torokhov
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juan Parrado <jparrado.1817@gmail.com>
commit 9def7caa2e55d0c5708385ae0d0039e9eaa26c47 upstream.
Add specific support to various controllers:
- HORI Taiko Controller DX
- 8BitDo M30 Wired Controller for Xbox
- Hyperkin Xenon Controller
Signed-off-by: Juan Parrado <jparrado1817@gmail.com>
Link: https://patch.msgid.link/20261109102127.9417-1-jparrado1817@gmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/input/joystick/xpad.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -260,6 +260,7 @@ static const struct xpad_device {
{ 0x0f0d, 0x00dc, "HORIPAD FPS for Nintendo Switch", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
{ 0x0f0d, 0x0151, "Hori Racing Wheel Overdrive for Xbox Series X", 0, XTYPE_XBOXONE },
{ 0x0f0d, 0x0152, "Hori Racing Wheel Overdrive for Xbox Series X", 0, XTYPE_XBOXONE },
+ { 0x0f0d, 0x01b1, "HORI Taiko Controller DX", 0, XTYPE_XBOX360 },
{ 0x0f0d, 0x01b2, "HORI Taiko No Tatsujin Drum Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
{ 0x0f30, 0x010b, "Philips Recoil", 0, XTYPE_XBOX },
{ 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
@@ -381,6 +382,7 @@ static const struct xpad_device {
{ 0x294b, 0x3404, "Snakebyte GAMEPAD RGB X", 0, XTYPE_XBOXONE },
{ 0x2993, 0x2001, "TECNO Pocket Go", 0, XTYPE_XBOX360 },
{ 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE },
+ { 0x2dc8, 0x200a, "8BitDo M30 Wired Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
{ 0x2dc8, 0x200f, "8BitDo Ultimate 3-mode Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
{ 0x2dc8, 0x201e, "8BitDo Pro 2 Wired Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
{ 0x2dc8, 0x3106, "8BitDo Ultimate Wireless / Pro 2 Wired Controller", 0, XTYPE_XBOX360 },
@@ -390,6 +392,7 @@ static const struct xpad_device {
{ 0x2dc8, 0x6001, "8BitDo SN30 Pro", 0, XTYPE_XBOX360 },
{ 0x2e24, 0x0423, "Hyperkin DuchesS Xbox One pad", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
{ 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE },
+ { 0x2e24, 0x072e, "Hyperkin Xenon Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
{ 0x2e24, 0x1688, "Hyperkin X91 X-Box One pad", 0, XTYPE_XBOXONE },
{ 0x2e95, 0x0504, "SCUF Gaming Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
{ 0x31e3, 0x1100, "Wooting One", 0, XTYPE_XBOX360 },
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 512/742] iommufd: fix cleanup when adding memfd folio pins fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (502 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 511/742] Input: xpad.c - add support for Hyperkin Xenon, Hori Taiko Controller DX, and 8BitDo M30 Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 513/742] ip6mr: prevent info-leak in ip6mr_cache_report() Greg Kroah-Hartman
` (222 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Lance Yang, Jason Gunthorpe,
David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit b8ba6cc9943222676d46ac77d3d3de2685a55bf8 upstream.
folio_add_pins() can fail after memfd_pin_folios() succeeded pinning a
folio. Upcoming folio refcount limit checks will make this easier to
trigger.
Let's fix three problems in the error handling:
1. pfn_reader_release_pins() uses the allocated array size instead of the
number of folios returned by memfd_pin_folios(). With large folios,
cleanup can unpin uninitialized entries. Remember the number of returned
folios and use that during cleanup.
2. pin_memfd_pages() returns on failure without releasing the pins acquired
by the current call. Release the per-page pins for folios already
expanded into the page array, and the single pins for the remaining
folios.
3. pfn_reader_next() returns on failure before updating batch_end_index,
even if the batch already contains successfully expanded folios. Update
it before propagating the error so cleanup releases those pins as well.
Fixes: 92687c793644 ("iommufd: pfn_reader for file mappings")
Cc: stable@vger.kernel.org
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-4-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/iommu/iommufd/pages.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
--- a/drivers/iommu/iommufd/pages.c
+++ b/drivers/iommu/iommufd/pages.c
@@ -781,6 +781,7 @@ struct pfn_reader_user {
struct file *file;
struct folio **ufolios;
size_t ufolios_len;
+ unsigned long ufolios_count;
unsigned long ufolios_offset;
struct folio **ufolios_next;
};
@@ -800,6 +801,7 @@ static void pfn_reader_user_init(struct
user->file = (pages->type == IOPT_ADDRESS_FILE) ? pages->file : NULL;
user->ufolios = NULL;
user->ufolios_len = 0;
+ user->ufolios_count = 0;
user->ufolios_next = NULL;
user->ufolios_offset = 0;
}
@@ -843,6 +845,7 @@ static long pin_memfd_pages(struct pfn_r
offset >>= PAGE_SHIFT;
user->ufolios_next = user->ufolios;
+ user->ufolios_count = nfolios;
user->ufolios_offset = offset;
for (i = 0; i < nfolios; i++) {
@@ -859,8 +862,12 @@ static long pin_memfd_pages(struct pfn_r
} else {
int rc = folio_add_pins(folio, npin - 1);
- if (rc)
+ if (rc) {
+ unpin_user_pages(user->upages,
+ upages - user->upages);
+ unpin_folios(user->ufolios + i, nfolios - i);
return rc;
+ }
while (npin--)
*upages++ = folio_page(folio, offset++);
@@ -1251,14 +1258,14 @@ static int pfn_reader_next(struct pfn_re
return -EINVAL;
rc = pfn_reader_fill_span(pfns);
+ pfns->batch_end_index = pfns->batch_start_index +
+ pfns->batch.total_pfns;
if (rc)
return rc;
if (WARN_ON(!pfns->batch.total_pfns))
return -EINVAL;
- pfns->batch_end_index =
- pfns->batch_start_index + pfns->batch.total_pfns;
if (pfns->batch_end_index == pfns->span.last_used + 1)
interval_tree_double_span_iter_next(&pfns->span);
@@ -1320,7 +1327,7 @@ static void pfn_reader_release_pins(stru
if (!user->file) {
unpin_user_pages(user->upages + start_index, npages);
} else {
- long n = user->ufolios_len / sizeof(*user->ufolios);
+ const unsigned long n = user->ufolios_count;
unpin_folios(user->ufolios_next,
user->ufolios + n - user->ufolios_next);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 513/742] ip6mr: prevent info-leak in ip6mr_cache_report()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (503 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 512/742] iommufd: fix cleanup when adding memfd folio pins fails Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 514/742] kbuild: rust: disable function merging unconditionally Greg Kroah-Hartman
` (221 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Henry Martin, Ido Schimmel,
Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <bsdhenrymartin@gmail.com>
commit ea538b5790eed4f042ea787ea761cb1a695f8138 upstream.
The non-WHOLEPKT branch copies the IPv6 header at offset 0 and then
appends 40 bytes with skb_put(), but the mrt6msg is written at offset 0
after skb_reset_transport_header(), so the appended 40 bytes are never
initialized. They hold stale heap contents.
The report is queued to the mroute6 socket and copied into the
IP6MRA_CREPORT_PKT netlink attribute, disclosing the stale bytes to
user space. The stale bytes can contain kernel heap and image
pointers, and the report is reachable from an unprivileged user
namespace (MRT6_INIT in a new netns, plus the non-root
RTNLGRP_IPV6_MROUTE_R group).
Use skb_put_zero() instead, as the IPv4 code does since
commit 4f34002e2e376 ("ipmr: prevent info-leak in pmr_cache_report()").
This issue was discovered by Tencent CodeBuddy Security.
Fixes: 7bc570c8b4f75 ("[IPV6] MROUTE: Support multicast forwarding.")
Cc: stable@vger.kernel.org
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20261112042415.617221-1-bsdhenrymartin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/ipv6/ip6mr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1153,7 +1153,7 @@ static int ip6mr_cache_report(const stru
/*
* Add our header
*/
- skb_put(skb, sizeof(*msg));
+ skb_put_zero(skb, sizeof(*msg));
skb_reset_transport_header(skb);
msg = (struct mrt6msg *)skb_transport_header(skb);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 514/742] kbuild: rust: disable function merging unconditionally
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (504 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 513/742] ip6mr: prevent info-leak in ip6mr_cache_report() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 515/742] lib/crc: Dont include <linux/types.h> in NEON intrinsics code Greg Kroah-Hartman
` (220 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alice Ryhl, Gary Guo, Sami Tolvanen,
Miguel Ojeda
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Ryhl <aliceryhl@google.com>
commit 73bdf8773de4af2c2b7f49370191ae6d5aeddea5 upstream.
Function merging causes various different issues:
* For CONFIG_CFI there's an LLVM bug causing functions with different
CFI hashes to get merged. This can lead to crashes at runtime.
* For gendwarfksyms it causes functions with different CRCs to get
merged. This leads to broken MODVERSIONS information if the function
changes in the future so that it can no longer be merged.
* Wrong backtraces when a crash occurs in a merged function.
* Possibly also issues with pahole/BTF as the merged function's debug
info is lost.
These issues are new to Rust because in clang, function merging is off
by default, so these things have never come up before. Because of this,
turn this option off for all configurations.
[ The LLVM bug is tracked at [1]. Nick asked what function merging
refers to here, and Alice writes [2]:
No, this isn't linker ICF. rustc doesn't pass --icf, and in any case
kbuild invokes rustc with --emit=obj and does the final link itself, so
rustc's linker arguments never come into play.
What I'm referring to is LLVM's MergeFunctions IR pass
(llvm/lib/Transforms/IPO/MergeFunctions.cpp). It runs as part of the
optimization pipeline, within a single codegen unit, before any object
file is emitted. Clang only enables it with the cc1-only flag
-fmerge-functions, which the kernel never passes, so C code in the
kernel never sees it.
rustc, however, enables it by default whenever optimizing for speed or
size (opt-level 2, 3, s or z), which covers both kernel configurations.
It uses the "aliases" mode: when two functions have identical bodies,
one is deleted and its symbol becomes a GlobalAlias to the other. You
can turn it off with -Zmerge-functions=disabled.
- Miguel ]
Link: https://lore.kernel.org/all/avy_9SPRaPSKD8b4@google.com/
Fixes: ac61506bf2d1 ("rust: Use gendwarfksyms + extended modversions for CONFIG_MODVERSIONS")
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Cc: stable@vger.kernel.org
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Link: https://github.com/llvm/llvm-project/issues/217629 [1]
Link: https://lore.kernel.org/rust-for-linux/CAH5fLgidhnPbP=xXQ3162w6q0U6rWHPZ9Mu6-E5va4_CXyanOg@mail.gmail.com/ [2]
Link: https://patch.msgid.link/20261118-rust-merge-functions-v1-1-fe86126522b9@google.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/Makefile
+++ b/Makefile
@@ -617,6 +617,7 @@ KBUILD_RUSTFLAGS := $(rust_common_flags)
-Csymbol-mangling-version=v0 \
-Crelocation-model=static \
-Zfunction-sections=n \
+ -Zmerge-functions=disabled \
-Wclippy::float_arithmetic
KBUILD_RUSTFLAGS_OPTION_CHKS :=
@@ -1129,8 +1130,7 @@ endif
ifdef CONFIG_RUST
# Always pass -Zsanitizer-cfi-normalize-integers as CONFIG_RUST selects
# CONFIG_CFI_ICALL_NORMALIZE_INTEGERS.
- # Disable function merging as LLVM incorrectly merges functions with different KCFI types.
- RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers -Zmerge-functions=disabled
+ RUSTC_FLAGS_CFI := -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers
KBUILD_RUSTFLAGS += $(RUSTC_FLAGS_CFI)
export RUSTC_FLAGS_CFI
endif
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 515/742] lib/crc: Dont include <linux/types.h> in NEON intrinsics code
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (505 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 514/742] kbuild: rust: disable function merging unconditionally Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 516/742] mac802154: llsec: reject secured frames with security level 0 Greg Kroah-Hartman
` (219 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ard Biesheuvel, Thomas Huth,
Nathan Chancellor, Eric Biggers, Catalin Marinas
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <ardb@kernel.org>
commit ff049836f05f5e46f702858a7cb949998e85a310 upstream.
The kernel's definitions of uint64_t and int64_t in <linux/types.h> are based
on [unsigned] long long, whereas the ones provided by <stdint.h>, which is
included by <arm_neon.h>, are based on [unsigned] long on arm64. On 32-bit ARM,
a similar mismatch exists for intptr_t.
Including both into the same compilation unit currently only works because
asm/neon-intrinsics.h overrides the predefined macros that the compiler's
freestanding <stdint.h> uses to define these types. In order to be able to get
rid of those overrides, stop including <linux/types.h> into the CRC64 NEON
intrinsics code.
Instead, use <stddef.h> for the definition of size_t, and rely on
<asm/neon-intrinsics.h> to provide the u8 and u64 types used in the prototype
of crc64_nvme_neon(), which is shared with code that does include
<linux/types.h>. Use uint64_t for the arrays of constants that are passed to
vld1q_u64(), so that they match its prototype regardless of how uint64_t is
defined.
No change in generated code.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
lib/crc/crc64-neon.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
--- a/lib/crc/crc64-neon.c
+++ b/lib/crc/crc64-neon.c
@@ -3,7 +3,7 @@
* Accelerated CRC64 (NVMe) using ARM NEON C intrinsics
*/
-#include <linux/types.h>
+#include <stddef.h>
#include <asm/neon-intrinsics.h>
#include "crc64-neon.h"
@@ -11,11 +11,11 @@
u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len);
/* x^191 mod G, x^127 mod G */
-static const u64 fold_consts_val[2] = { 0xeadc41fd2ba3d420ULL,
- 0x21e9761e252621acULL };
+static const uint64_t fold_consts_val[2] = { 0xeadc41fd2ba3d420ULL,
+ 0x21e9761e252621acULL };
/* floor(x^127 / G), (G - x^64) / x */
-static const u64 bconsts_val[2] = { 0x27ecfa329aef9f77ULL,
- 0x34d926535897936aULL };
+static const uint64_t bconsts_val[2] = { 0x27ecfa329aef9f77ULL,
+ 0x34d926535897936aULL };
u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len)
{
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 516/742] mac802154: llsec: reject secured frames with security level 0
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (506 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 515/742] lib/crc: Dont include <linux/types.h> in NEON intrinsics code Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 517/742] maple_tree: fix rcu reader NULL dereference after the tree is emptied Greg Kroah-Hartman
` (218 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Joas Antonio dos Santos,
Miquel Raynal, Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <joasantonio108@gmail.com>
commit 3e8c853c959e9637ed66ae1e55e0d3bb97372cc5 upstream.
mac802154_llsec_decrypt() handles every received frame that has the
Security Enabled bit set. The security level is taken from the
auxiliary security header of the frame and is not required to be
non-zero. The only check that looks at level 0 rejects the frame only
if level 0 is not allowed by the matching seclevel entry, the entry has
device_override set and the device is not seclevel_exempt:
if (!(seclevel.sec_levels & BIT(hdr.sec.level)) &&
(hdr.sec.level == 0 && seclevel.device_override &&
!dev->dev.seclevel_exempt)) {
Otherwise the frame reaches llsec_do_decrypt(), which sends every level
other than IEEE802154_SCF_SECLEVEL_ENC to llsec_do_decrypt_auth().
There ieee802154_sechdr_authtag_len() returns 0 for level 0 and
req = aead_request_alloc(llsec_tfm_by_len(key, authlen), GFP_ATOMIC);
looks for a transform with an authentication tag size of 0. The key
only has transforms for tag sizes 4, 8 and 16, so llsec_tfm_by_len()
runs into its BUG().
The frame is not authenticated at that point. A station in radio range
can crash a node that has llsec enabled if it sends a frame that matches
a configured key entry and a device table entry (source address, key id
mode and key id are sent in the clear and can be observed), uses a frame
type that has a seclevel entry and carries a frame counter that is not
lower than the stored one. No key material is needed. The frame
counter of that device is also updated before the BUG() is reached.
A frame with the Security Enabled bit set and security level 0 carries
no protection and cannot be processed by the incoming security
procedure. Reject it before any key or device state is looked up. The
transmit side already leaves such frames alone in
mac802154_llsec_encrypt().
Found by LLM-assisted source review.
Fixes: 4c14a2fb5d14 ("mac802154: add llsec decryption method")
Cc: stable@vger.kernel.org
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://patch.msgid.link/20261110-llsec-seclevel-none-v1-1-06ef143e467f@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/mac802154/llsec.c | 2 ++
1 file changed, 2 insertions(+)
--- a/net/mac802154/llsec.c
+++ b/net/mac802154/llsec.c
@@ -1019,6 +1019,8 @@ int mac802154_llsec_decrypt(struct mac80
return 0;
if (hdr.fc.version == 0)
return -EINVAL;
+ if (hdr.sec.level == IEEE802154_SCF_SECLEVEL_NONE)
+ return -EINVAL;
read_lock_bh(&sec->lock);
if (!sec->params.enabled) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 517/742] maple_tree: fix rcu reader NULL dereference after the tree is emptied
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (507 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 516/742] mac802154: llsec: reject secured frames with security level 0 Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 518/742] maple_tree: update internal warning and bug_on code Greg Kroah-Hartman
` (217 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Liam R. Howlett (Google),
Andrew Morton, Chris Mason, Lorenzo Stoakes, Alice Ryhl,
Andrew Ballance
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liam R. Howlett (Google) <liam@infradead.org>
commit e8a71f284ba7eeddd9475bb0b65200e95428b497 upstream.
Patch series "maple_tree fixes for 7.3", v2.
Two bugs found by an LLM review, and one problem Lorenzo Stoakes
reported off list.
An RCU reader that restarts after its node dies can dereference NULL if
the tree was emptied, or holds a single entry in the root pointer.
Patch 1 fixes it and patch 2 adds a test.
With CONFIG_DEBUG_MAPLE_TREE, MT_WARN_ON() and the other WARN macros
print the tree and call dump_stack() rather than WARN(), so syzbot never
sees them. Patch 3 makes them WARN once per call site, after the dump,
and makes the BUG macros BUG() after theirs. The userspace tests make
WARN() fatal to keep failing as they did on dump_stack().
This patch (of 3):
RCU readers may hit a NULL dereference if the tree is emptied while the
walker is restarted from a dead node. Avoid the NULL dereference by
checking for an emptied/pointer tree (0->ptr, 1-ULONG_MAX -> NULL) and
set the maple state limits correctly.
A reader of /proc/<pid>/maps racing with an munmap() of the whole
address space can hit this. The first implementation has the same
problem in both directions.
Initial fix was generated by LLM and sent by Chris Mason in private.
[akpm@linux-foundation.org: fix reverse iterator state when the root disappears]
Link: https://lore.kernel.org/20261104104137.2058705ac29734a7ab5666c1@linux-foundation.org
Link: https://lore.kernel.org/20261103020724.2614498-1-liam@infradead.org
Link: https://lore.kernel.org/20261103020724.2614498-2-liam@infradead.org
Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Chris Mason <mason@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Andrew Ballance <andrewjballance@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
lib/maple_tree.c | 120 ++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 93 insertions(+), 27 deletions(-)
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -3891,14 +3891,64 @@ retry:
goto retry;
}
-static __always_inline bool mas_rewalk_if_dead(struct ma_state *mas,
- struct maple_node *node, const unsigned long index)
+/*
+ * mas_next_no_node() - Finish a next walk that restarted into a tree without
+ * nodes.
+ * @mas: The inactive maple state (ma_none or ma_root)
+ *
+ * The arrival here is either because there is a root value or nothing. Either
+ * way, the next entry is nothing. So set the limits and overwrite the status.
+ *
+ * Return: NULL
+ */
+static inline void *mas_next_no_node(struct ma_state *mas)
{
- if (unlikely(ma_dead_node(node))) {
- mas_rewalk(mas, index);
- return true;
+ if (mas_is_ptr(mas))
+ mas->index = 1;
+ else
+ mas->index = 0;
+
+ mas->last = ULONG_MAX;
+ mas->status = ma_none;
+ return NULL;
+}
+
+/*
+ * mas_prev_no_node() - Finish a prev walk that restarted into a tree without
+ * nodes.
+ * @mas: The inactive maple state (ma_none or ma_root)
+ * @index: The start of the range the walk left
+ * @min: The lowest index to return
+ *
+ * The arrival here is either because there is a root value or nothing. With
+ * nothing, leave the limits mas_walk() sets for an empty tree. A root value
+ * sits at 0: stop on it as mas_prev_setup() does, unless the walk was at 0.
+ *
+ * Return: The root entry if @index and @min allow it, NULL otherwise. A node
+ * if the root changed again since the walk; the caller restarts.
+ */
+static inline void *mas_prev_no_node(struct ma_state *mas, unsigned long index,
+ unsigned long min)
+{
+ void *entry;
+
+ mas->index = 0;
+ if (mas_is_none(mas)) {
+ mas->last = ULONG_MAX;
+ return NULL;
}
- return false;
+
+ mas->last = 0;
+ if (!index || min)
+ return NULL;
+
+ entry = mas_root(mas);
+ if (!entry) {
+ mas->status = ma_none;
+ mas->last = ULONG_MAX;
+ }
+
+ return entry;
}
/*
@@ -4006,14 +4056,14 @@ retry:
node = mas_mn(mas);
type = mte_node_type(mas->node);
pivots = ma_pivots(node, type);
- if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
- goto retry;
+ if (unlikely(ma_dead_node(node)))
+ goto dead;
if (mas->min <= min) {
pivot = mas_safe_min(mas, pivots, mas->offset);
- if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
- goto retry;
+ if (unlikely(ma_dead_node(node)))
+ goto dead;
if (pivot <= min)
goto underflow;
@@ -4028,10 +4078,8 @@ again:
if (mas->index <= min)
goto underflow;
- if (mas_prev_node(mas, min)) {
- mas_rewalk(mas, save_point);
- goto retry;
- }
+ if (mas_prev_node(mas, min))
+ goto dead;
if (WARN_ON_ONCE(mas_is_underflow(mas)))
return NULL;
@@ -4045,8 +4093,8 @@ again:
slots = ma_slots(node, type);
entry = mas_slot(mas, slots, mas->offset);
- if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
- goto retry;
+ if (unlikely(ma_dead_node(node)))
+ goto dead;
if (likely(entry))
return entry;
@@ -4063,6 +4111,17 @@ again:
underflow:
mas->status = ma_underflow;
return NULL;
+
+dead:
+ mas_rewalk(mas, save_point);
+ if (likely(mas_is_active(mas)))
+ goto retry;
+
+ entry = mas_prev_no_node(mas, save_point, min);
+ if (unlikely(xa_is_node(entry))) /* The root changed again */
+ goto dead;
+
+ return entry;
}
/*
@@ -4176,8 +4235,8 @@ retry:
node = mas_mn(mas);
type = mte_node_type(mas->node);
pivots = ma_pivots(node, type);
- if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
- goto retry;
+ if (unlikely(ma_dead_node(node)))
+ goto dead;
if (mas->max >= max) {
if (likely(mas->offset < mas->end))
@@ -4185,8 +4244,8 @@ retry:
else
pivot = mas->max;
- if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
- goto retry;
+ if (unlikely(ma_dead_node(node)))
+ goto dead;
if (pivot >= max) { /* Was at the limit, next will extend beyond */
mas->status = ma_overflow;
@@ -4208,10 +4267,8 @@ again:
return NULL;
}
- if (mas_next_node(mas, node, max)) {
- mas_rewalk(mas, save_point);
- goto retry;
- }
+ if (mas_next_node(mas, node, max))
+ goto dead;
if (WARN_ON_ONCE(mas_is_overflow(mas)))
return NULL;
@@ -4226,8 +4283,8 @@ again:
slots = ma_slots(node, type);
entry = mt_slot(mas->tree, slots, mas->offset);
- if (unlikely(mas_rewalk_if_dead(mas, node, save_point)))
- goto retry;
+ if (unlikely(ma_dead_node(node)))
+ goto dead;
if (entry)
return entry;
@@ -4244,6 +4301,13 @@ again:
}
return entry;
+
+dead:
+ mas_rewalk(mas, save_point);
+ if (likely(mas_is_active(mas)))
+ goto retry;
+
+ return mas_next_no_node(mas);
}
/*
@@ -5450,7 +5514,9 @@ void *mas_find(struct ma_state *mas, uns
/* Retries on dead nodes handled by mas_next_slot */
entry = mas_next_slot(mas, max, false);
/* Ignore overflow */
- mas->status = ma_active;
+ if (mas_is_overflow(mas))
+ mas->status = ma_active;
+
return entry;
}
EXPORT_SYMBOL_GPL(mas_find);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 518/742] maple_tree: update internal warning and bug_on code
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (508 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 517/742] maple_tree: fix rcu reader NULL dereference after the tree is emptied Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 519/742] mptcp: Avoid unsequenced accesses to jiffies in mptcp_reset_tout_timer() Greg Kroah-Hartman
` (216 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Liam R. Howlett (Google),
Andrew Morton, Lorenzo Stoakes, Chris Mason, Alice Ryhl,
Andrew Ballance
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liam R. Howlett (Google) <liam@infradead.org>
commit f51d35b81fb572c551e82ff72575d6dbb8e35ba9 upstream.
When CONFIG_DEBUG_MAPLE_TREE is set, call WARN_ON() once per site after
the custom information is dumped about the tree. Without using the
kernel's WARN_ON calls, syzbot will not catch issues detected by this
code. The BUG_ON variants now stop instead of dumping and continuing.
Update the non-debug code to call WARN_ON_ONCE() as well.
The userspace tests asserted on dump_stack() but only print on
WARN_ON(), so make WARN() fatal in maple-shared.h and have the maple
test exit with the result of maple_tree_seed().
Link: https://lore.kernel.org/20261103020724.2614498-4-liam@infradead.org
Fixes: f0a1f866aba1 ("maple_tree: add debug BUG_ON and WARN_ON variants")
Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Lorenzo Stoakes <ljs@kernel.org>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Cc: Chris Mason <mason@kernel.org>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Andrew Ballance <andrewjballance@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/maple_tree.h | 48 ++++++++++++++++++------------------
tools/testing/radix-tree/maple.c | 13 ++++++---
tools/testing/shared/maple-shared.h | 33 ++++++++++++++++++++++++
3 files changed, 66 insertions(+), 28 deletions(-)
--- a/include/linux/maple_tree.h
+++ b/include/linux/maple_tree.h
@@ -682,7 +682,7 @@ void mt_cache_shrink(void);
pr_info("Pass: %u Run:%u\n", \
atomic_read(&maple_tree_tests_passed), \
atomic_read(&maple_tree_tests_run)); \
- dump_stack(); \
+ BUG_ON(1); \
} else { \
atomic_inc(&maple_tree_tests_passed); \
} \
@@ -698,7 +698,7 @@ void mt_cache_shrink(void);
pr_info("Pass: %u Run:%u\n", \
atomic_read(&maple_tree_tests_passed), \
atomic_read(&maple_tree_tests_run)); \
- dump_stack(); \
+ BUG_ON(1); \
} else { \
atomic_inc(&maple_tree_tests_passed); \
} \
@@ -715,7 +715,7 @@ void mt_cache_shrink(void);
pr_info("Pass: %u Run:%u\n", \
atomic_read(&maple_tree_tests_passed), \
atomic_read(&maple_tree_tests_run)); \
- dump_stack(); \
+ BUG_ON(1); \
} else { \
atomic_inc(&maple_tree_tests_passed); \
} \
@@ -724,16 +724,16 @@ void mt_cache_shrink(void);
#define MT_WARN_ON(__tree, __x) ({ \
int ret = !!(__x); \
atomic_inc(&maple_tree_tests_run); \
- if (ret) { \
- pr_info("WARN at %s:%d (%u)\n", \
- __func__, __LINE__, __x); \
+ if (!ret) { \
+ atomic_inc(&maple_tree_tests_passed); \
+ } else if (__ONCE_LITE_IF(ret)) { \
+ pr_info("WARN at %s:%d\n", \
+ __func__, __LINE__); \
mt_dump(__tree, mt_dump_hex); \
pr_info("Pass: %u Run:%u\n", \
atomic_read(&maple_tree_tests_passed), \
atomic_read(&maple_tree_tests_run)); \
- dump_stack(); \
- } else { \
- atomic_inc(&maple_tree_tests_passed); \
+ WARN_ON(1); \
} \
unlikely(ret); \
})
@@ -741,17 +741,17 @@ void mt_cache_shrink(void);
#define MAS_WARN_ON(__mas, __x) ({ \
int ret = !!(__x); \
atomic_inc(&maple_tree_tests_run); \
- if (ret) { \
- pr_info("WARN at %s:%d (%u)\n", \
- __func__, __LINE__, __x); \
+ if (!ret) { \
+ atomic_inc(&maple_tree_tests_passed); \
+ } else if (__ONCE_LITE_IF(ret)) { \
+ pr_info("WARN at %s:%d\n", \
+ __func__, __LINE__); \
mas_dump(__mas); \
mt_dump((__mas)->tree, mt_dump_hex); \
pr_info("Pass: %u Run:%u\n", \
atomic_read(&maple_tree_tests_passed), \
atomic_read(&maple_tree_tests_run)); \
- dump_stack(); \
- } else { \
- atomic_inc(&maple_tree_tests_passed); \
+ WARN_ON(1); \
} \
unlikely(ret); \
})
@@ -759,18 +759,18 @@ void mt_cache_shrink(void);
#define MAS_WR_WARN_ON(__wrmas, __x) ({ \
int ret = !!(__x); \
atomic_inc(&maple_tree_tests_run); \
- if (ret) { \
- pr_info("WARN at %s:%d (%u)\n", \
- __func__, __LINE__, __x); \
+ if (!ret) { \
+ atomic_inc(&maple_tree_tests_passed); \
+ } else if (__ONCE_LITE_IF(ret)) { \
+ pr_info("WARN at %s:%d\n", \
+ __func__, __LINE__); \
mas_wr_dump(__wrmas); \
mas_dump((__wrmas)->mas); \
mt_dump((__wrmas)->mas->tree, mt_dump_hex); \
pr_info("Pass: %u Run:%u\n", \
atomic_read(&maple_tree_tests_passed), \
atomic_read(&maple_tree_tests_run)); \
- dump_stack(); \
- } else { \
- atomic_inc(&maple_tree_tests_passed); \
+ WARN_ON(1); \
} \
unlikely(ret); \
})
@@ -778,9 +778,9 @@ void mt_cache_shrink(void);
#define MT_BUG_ON(__tree, __x) BUG_ON(__x)
#define MAS_BUG_ON(__mas, __x) BUG_ON(__x)
#define MAS_WR_BUG_ON(__mas, __x) BUG_ON(__x)
-#define MT_WARN_ON(__tree, __x) WARN_ON(__x)
-#define MAS_WARN_ON(__mas, __x) WARN_ON(__x)
-#define MAS_WR_WARN_ON(__mas, __x) WARN_ON(__x)
+#define MT_WARN_ON(__tree, __x) WARN_ON_ONCE(__x)
+#define MAS_WARN_ON(__mas, __x) WARN_ON_ONCE(__x)
+#define MAS_WR_WARN_ON(__mas, __x) WARN_ON_ONCE(__x)
#endif /* CONFIG_DEBUG_MAPLE_TREE */
/**
--- a/tools/testing/radix-tree/maple.c
+++ b/tools/testing/radix-tree/maple.c
@@ -36496,22 +36496,27 @@ static void regression_tests(void)
test_spanning_store_regression();
}
-void maple_tree_tests(void)
+int maple_tree_tests(void)
{
+ int ret;
+
#if !defined(BENCH)
regression_tests();
farmer_tests();
#endif
- maple_tree_seed();
+ ret = maple_tree_seed();
maple_tree_harvest();
+ return ret;
}
int __weak main(void)
{
+ int ret;
+
maple_tree_init();
- maple_tree_tests();
+ ret = maple_tree_tests();
rcu_barrier();
if (nr_allocated)
printf("nr_allocated = %d\n", nr_allocated);
- return 0;
+ return ret ? EXIT_FAILURE : EXIT_SUCCESS;
}
--- a/tools/testing/shared/maple-shared.h
+++ b/tools/testing/shared/maple-shared.h
@@ -8,6 +8,7 @@
#include "shared.h"
#include <stdlib.h>
#include <time.h>
+#include <assert.h>
#include "linux/init.h"
void maple_rcu_cb(struct rcu_head *head);
@@ -20,5 +21,37 @@ do {
call_rcu(&((_p_struct)->_memb), rcu_cb); \
} while(0);
+/* Make WARN() fatal */
+#undef WARN
+#undef WARN_ON
+#undef WARN_ONCE
+#undef WARN_ON_ONCE
+#define WARN(condition, format...) ({ \
+ int __ret_warn_on = !!(condition); \
+ if (unlikely(__ret_warn_on)) { \
+ __WARN_printf(format); \
+ assert(0); \
+ } \
+ unlikely(__ret_warn_on); \
+})
+#define WARN_ON(condition) \
+ WARN(condition, "assertion failed at %s:%d\n", __FILE__, __LINE__)
+#define WARN_ONCE(condition, format...) WARN(condition, format)
+#define WARN_ON_ONCE(condition) WARN_ON(condition)
+
+/* Once state for the debug macros */
+#ifndef __ONCE_LITE_IF
+#define __ONCE_LITE_IF(condition) \
+ ({ \
+ static bool __already_done; \
+ bool __ret_once = false; \
+ \
+ if ((condition) && !__already_done) { \
+ __already_done = true; \
+ __ret_once = true; \
+ } \
+ __ret_once; \
+ })
+#endif
#endif /* __MAPLE_SHARED_H__ */
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 519/742] mptcp: Avoid unsequenced accesses to jiffies in mptcp_reset_tout_timer()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (509 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 518/742] maple_tree: update internal warning and bug_on code Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 520/742] net/tls: serialize context removal in tls_device_down() Greg Kroah-Hartman
` (215 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Nathan Chancellor,
Matthieu Baerts (NGI0), Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <nathan@kernel.org>
commit 728a2abd15a767f662a44030931ea7b2959b4e88 upstream.
After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appears in mptcp_reset_tout_timer(),
which can break the build with CONFIG_WERROR=y / W=e:
net/mptcp/protocol.c:3044:20: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced]
3044 | tcp_jiffies32 + jiffies + mptcp_close_timeout(sk);
| ~~~~~~~~~~~~~ ^
Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.3, unless otherwise specified, side effects and
value computations of subexpressions are unsequenced within expressions.
Add an explicit sequence point by splitting the addition expression in
half, eliminating the undefined behavior and clearing up the warning.
Cc: stable@vger.kernel.org
Fixes: 76a13b315709 ("mptcp: invoke MP_FAIL response when needed")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2193
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20261114-mptcp-wunsequenced-v1-1-707a73a6c172@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/mptcp/protocol.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -3042,7 +3042,8 @@ void mptcp_reset_tout_timer(struct mptcp
return;
close_timeout = (unsigned long)inet_csk(sk)->icsk_mtup.probe_timestamp -
- tcp_jiffies32 + jiffies + mptcp_close_timeout(sk);
+ tcp_jiffies32;
+ close_timeout += jiffies + mptcp_close_timeout(sk);
/* the close timeout takes precedence on the fail one, and here at least one of
* them is active
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 520/742] net/tls: serialize context removal in tls_device_down()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (510 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 519/742] mptcp: Avoid unsequenced accesses to jiffies in mptcp_reset_tout_timer() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 521/742] ipv6: gro: limit the number of extension headers Greg Kroah-Hartman
` (214 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Jaeyeong Lee, Paolo Abeni
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaeyeong Lee <lee@jaeyeong.cc>
commit 81c8333141b9aa465d98bb4c035284556e699701 upstream.
tls_device_down() moves each context to tls_device_down_list while
holding tls_device_lock. It then drops its reference and removes the
context after releasing the lock.
tls_device_queue_ctx_destruction() removes contexts from the same list
under tls_device_lock. If it removes an adjacent context while
tls_device_down() is deleting its node, the two list updates can
interleave. One update can then target a context freed by the other path,
causing a use-after-free write.
Drop the reference and remove the context in the existing
tls_device_lock critical section. Keep tls_device_free_ctx() after
releasing the lock.
This issue was found with a static analysis tool.
Fixes: f6336724a4d4 ("net/tls: Remove the context from the list in tls_device_down")
Cc: stable@vger.kernel.org
Signed-off-by: Jaeyeong Lee <lee@jaeyeong.cc>
Link: https://patch.msgid.link/20261112043209.102404-1-lee@jaeyeong.cc
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/tls/tls_device.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -1350,6 +1350,8 @@ static int tls_device_down(struct net_de
spin_unlock_irqrestore(&tls_device_lock, flags);
list_for_each_entry_safe(ctx, tmp, &list, list) {
+ bool free_ctx;
+
/* Stop offloaded TX and switch to the fallback.
* tls_is_skb_tx_device_offloaded will return false.
*/
@@ -1387,17 +1389,19 @@ static int tls_device_down(struct net_de
*/
spin_lock_irqsave(&tls_device_lock, flags);
list_move_tail(&ctx->list, &tls_device_down_list);
+ /* Serialize the final removal with sk_destruct. */
+ free_ctx = refcount_dec_and_test(&ctx->refcount);
+ if (free_ctx)
+ list_del(&ctx->list);
spin_unlock_irqrestore(&tls_device_lock, flags);
/* Device contexts for RX and TX will be freed in on sk_destruct
* by tls_device_free_ctx. rx_conf and tx_conf stay in TLS_HW.
- * Now release the ref taken above.
*/
- if (refcount_dec_and_test(&ctx->refcount)) {
+ if (free_ctx) {
/* sk_destruct ran after tls_device_down took a ref, and
* it returned early. Complete the destruction here.
*/
- list_del(&ctx->list);
tls_device_free_ctx(ctx);
}
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 521/742] ipv6: gro: limit the number of extension headers
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (511 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 520/742] net/tls: serialize context removal in tls_device_down() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 522/742] ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs() Greg Kroah-Hartman
` (213 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Hyunwoo Kim, Eric Dumazet,
Daniel Borkmann, David Ahern, Ido Schimmel, Aaron Conole,
Justin Iurman, Paolo Abeni
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <edumazet@kernel.org>
commit 050f2adb60434a2b4dee2cf3350269379a32cf72 upstream.
Hyunwoo Kim reported that a long chain of IPv6 extension headers
can push the transport header offset of a GRO packet beyond what
the 16-bit skb->transport_header can store. The truncated offset
is later used by gro_receive_network_flush() to locate the network
header of a packet held in the GRO list, leading to an out-of-bounds
read.
Since commit 3744b0964d52 ("ipv6: Implement limits on extension header
parsing"), ip6_protocol_deliver_rcu() drops packets carrying more than
IP6_MAX_EXT_HDRS_CNT extension headers, but ipv6_gro_pull_exthdrs()
was left unbounded.
There is no point trying to aggregate packets that the stack is going
to drop anyway if they are locally delivered. Apply the same limit in
ipv6_gro_pull_exthdrs().
When the limit is hit, @proto still designates an extension header.
Extension header offloads have no gro_receive() callback, so
ipv6_gro_receive() takes its existing "goto out" path with flush set,
and the packet is given to the normal receive path. Local delivery
drops it with SKB_DROP_REASON_IPV6_TOO_MANY_EXTHDRS, while forwarded
packets are simply not aggregated.
An extension header being at most 2048 bytes, this bounds a chain
to 24576 bytes.
Note that offsets can still accumulate over nested encapsulations,
so the places storing them should be hardened separately.
Fixes: 4b0ebbca3e16 ("net: gro: move L3 flush checks to tcp_gro_receive and udp_gro_receive_segment")
Cc: stable@vger.kernel.org
Reported-by: Hyunwoo Kim <imv4bel@gmail.com>
Link: https://lore.kernel.org/netdev/avTTQNyvwPP6LtGx@v4bel/
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@kernel.org>
Cc: Ido Schimmel <idosch@nvidia.com>
Tested-by: Hyunwoo Kim <imv4bel@gmail.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Aaron Conole <aconole@redhat.com>
Link: https://patch.msgid.link/20261113124625.4010206-2-edumazet@kernel.org
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/ipv6/ip6_offload.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -26,6 +26,7 @@ static int ipv6_gro_pull_exthdrs(struct
{
const struct net_offload *ops = NULL;
struct ipv6_opt_hdr *opth;
+ int exthdr_cnt = 0;
for (;;) {
int len;
@@ -38,6 +39,13 @@ static int ipv6_gro_pull_exthdrs(struct
if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
break;
+ /* Same limit as ip6_protocol_deliver_rcu().
+ * @proto is left pointing to an extension header,
+ * so that the caller does not aggregate this packet.
+ */
+ if (unlikely(exthdr_cnt++ >= IP6_MAX_EXT_HDRS_CNT))
+ break;
+
opth = skb_gro_header(skb, off + sizeof(*opth), off);
if (unlikely(!opth))
break;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 522/742] ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (512 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 521/742] ipv6: gro: limit the number of extension headers Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 523/742] ipvs: ftp: skip conntrack templates in ip_vs_ftp_out Greg Kroah-Hartman
` (212 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Ido Schimmel,
Justin Iurman, Paolo Abeni
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <edumazet@kernel.org>
commit 425b1fe50b71628299d33faff28057e7fa4c60c7 upstream.
skb->transport_header is a 16-bit offset from skb->head, and U16_MAX is
reserved as the "not set" value. skb_set_transport_header() silently
truncates an offset that does not fit.
ipv6_mc_check_exthdrs() stores the offset returned by ipv6_skip_exthdr(),
which depends on the extension headers found in the packet. Should the
value be truncated, ipv6_mc_check_icmpv6() and ipv6_mc_check_mld_msg()
would then validate and parse the MLD message at the wrong place.
Since commit 3744b0964d52 ("ipv6: Implement limits on extension header
parsing") a single chain is bounded to IP6_MAX_EXT_HDRS_CNT headers
(24576 bytes), so this needs a large skb->data - skb->head on top of it,
for instance after several nested decapsulations, each of them possibly
pulling its own extension header chain. No reproducer was written,
this is hardening.
Use skb_set_transport_header_careful() and treat such a packet as
broken (-EINVAL).
Fixes: 9afd85c9e455 ("net: Export IGMP/MLD message validation code")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20261113124625.4010206-3-edumazet@kernel.org
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/ipv6/mcast_snoop.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/net/ipv6/mcast_snoop.c
+++ b/net/ipv6/mcast_snoop.c
@@ -56,7 +56,8 @@ static int ipv6_mc_check_exthdrs(struct
if (nexthdr != IPPROTO_ICMPV6)
return -ENOMSG;
- skb_set_transport_header(skb, offset);
+ if (!skb_set_transport_header_careful(skb, offset))
+ return -EINVAL;
return 0;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 523/742] ipvs: ftp: skip conntrack templates in ip_vs_ftp_out
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (513 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 522/742] ipv6: mcast: use skb_set_transport_header_careful() in ipv6_mc_check_exthdrs() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 524/742] ipvs: reject FTP control ports as data ports Greg Kroah-Hartman
` (211 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Theodor Arsenij Larionov Trichkine,
Julian Anastasov, Pablo Neira Ayuso
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
commit 4656934d460da68382cf91766a1ff2d0610554ae upstream.
A CT target hooked after conntrack attaches its template to a packet
that conntrack left without an entry. On an IPVS FTP PASV/EPSV reply,
ip_vs_ftp_out() then mangles with the template and creates an
expectation with the template as master. Deleting the CT rule frees
the template and leaves the expectation, so a later expectation flush
reads freed memory:
BUG: KASAN: slab-use-after-free in nf_ct_unlink_expect_report
Reachable with CAP_NET_ADMIN in a user namespace.
Skip templates, as nft_ct and nfnetlink_queue do.
Fixes: f4bc17cdd205 ("ipvs: netfilter connection tracking changes")
Cc: stable@vger.kernel.org
Signed-off-by: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/netfilter/ipvs/ip_vs_ftp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -368,7 +368,7 @@ static int ip_vs_ftp_out(struct ip_vs_ap
buf_len = strlen(buf);
ct = nf_ct_get(skb, &ctinfo);
- if (ct) {
+ if (ct && !nf_ct_is_template(ct)) {
bool mangled;
/* If mangling fails this function will return 0
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 524/742] ipvs: reject FTP control ports as data ports
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (514 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 523/742] ipvs: ftp: skip conntrack templates in ip_vs_ftp_out Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 525/742] ipvs: skip cport 0 connections in ip_vs_conn_out_get() Greg Kroah-Hartman
` (210 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Vega, Luxing Yin, Zihan Xi,
Julian Anastasov, Pablo Neira Ayuso
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <zihanx@nebusec.ai>
commit a107e150e105836bb5349cdee14541d4995009ea upstream.
The FTP helper must not treat a configured control port as a data port.
Accepting such a port can leave IPVS connections in a state that leads
to recursive expiration and kernel stack exhaustion.
Reject zero and configured control ports before creating passive data
connections. For active mode, reject a zero client port and a derived
data port that is itself a configured control port.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Reported-by: Vega <vega@nebusec.ai>
Co-developed-by: Luxing Yin <root@tr0jan.top>
Signed-off-by: Luxing Yin <root@tr0jan.top>
Signed-off-by: Zihan Xi <zihanx@nebusec.ai>
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/netfilter/ipvs/ip_vs_ftp.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -62,6 +62,17 @@ static unsigned short ports[IP_VS_APP_MA
module_param_array(ports, ushort, &ports_count, 0444);
MODULE_PARM_DESC(ports, "Ports to monitor for FTP control commands");
+static bool is_control_port(u16 port)
+{
+ unsigned int i;
+
+ for (i = 0; i < ports_count; i++) {
+ if (ports[i] == port)
+ return true;
+ }
+ return false;
+}
+
static char *ip_vs_ftp_data_ptr(struct sk_buff *skb, struct ip_vs_iphdr *ipvsh)
{
@@ -319,6 +330,10 @@ static int ip_vs_ftp_out(struct ip_vs_ap
return 1;
}
+ /* Do not redirect data to control ports */
+ if (!port || is_control_port(ntohs(port)))
+ return 0;
+
/* Now update or create a connection entry for it */
{
struct ip_vs_conn_param p;
@@ -529,6 +544,9 @@ static int ip_vs_ftp_in(struct ip_vs_app
return 1;
}
+ if (!port || is_control_port(ntohs(cp->vport) - 1))
+ return 0;
+
/* Passive mode off */
cp->app_data = (void *) IP_VS_FTP_ACTIVE;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 525/742] ipvs: skip cport 0 connections in ip_vs_conn_out_get()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (515 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 524/742] ipvs: reject FTP control ports as data ports Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 526/742] ipvs: validate cport in received sync records Greg Kroah-Hartman
` (209 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Julian Anastasov, Axel Mierczuk,
Pablo Neira Ayuso
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Mierczuk <axel.mierczuk@1password.com>
commit 5c8d6e2596e0935e2ace0b94e86ffb99e8434cd9 upstream.
ip_vs_conn_out_get() does not filter templates. A template with
cport 0 is matched by a packet sent to client port 0 that traverses
the out hook, and handle_response() then runs ip_vs_set_state() and
the timeout update on a connection that must never see packets. A
backup server receives such templates over the unauthenticated sync
protocol. An ordinary connection scheduled for a client that uses
source port 0 has cport 0 as well and is matched the same way.
Apply the rule used by __ip_vs_conn_in_get(): a lookup for client
port 0 matches only connections flagged IP_VS_CONN_F_NO_CPORT, which
still wait for their cport, and a lookup for a nonzero client port
matches only connections without this flag. Test p->vport, which was
already compared with cp->cport, instead of reading cp->cport again.
ip_vs_ftp_out() relies on the first case: it looks up the data
connection with client port 0 to find the IP_VS_CONN_F_NO_CPORT entry
created for an earlier PASV or EPSV reply. That lookup keeps working.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Suggested-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Axel Mierczuk <axel.mierczuk@1password.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/netfilter/ipvs/ip_vs_conn.c | 2 ++
1 file changed, 2 insertions(+)
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -579,6 +579,8 @@ struct ip_vs_conn *ip_vs_conn_out_get(co
ip_vs_addr_equal(p->af, p->vaddr,
&cp->caddr) &&
ip_vs_addr_equal(p->af, p->caddr, saddr) &&
+ (!p->vport ^
+ (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) &&
p->protocol == cp->protocol) {
if (__ip_vs_conn_get(cp))
goto out;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 526/742] ipvs: validate cport in received sync records
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (516 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 525/742] ipvs: skip cport 0 connections in ip_vs_conn_out_get() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 527/742] ipvs: wait grace period before reusing destinations Greg Kroah-Hartman
` (208 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Julian Anastasov, Axel Mierczuk,
Pablo Neira Ayuso
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Mierczuk <axel.mierczuk@1password.com>
commit 1d1e8bc81f790a48cd643b1b1762de43334d4f14 upstream.
Local templates have cport 0 and IP_VS_CONN_F_NO_CPORT clear, so
ip_vs_conn_in_get() cannot match them. A template received over the
unauthenticated sync protocol with a nonzero cport can reach the
protocol state machine. Before template state validation, this
could cause out-of-bounds reads, crashes and kernel data leaks.
Ordinary records with cport 0 and IP_VS_CONN_F_NO_CPORT clear, or
with a nonzero cport and IP_VS_CONN_F_NO_CPORT set, create connections
that incoming lookups cannot match. The latter also keeps the
cport-zero fallback in ip_vs_conn_in_get() enabled.
Reject all three cases. Continue accepting ordinary connections with
cport 0 and IP_VS_CONN_F_NO_CPORT. The companion commit f96e91748f63
("ipvs: filter some flags received in the backup server") rejects
template records carrying IP_VS_CONN_F_NO_CPORT.
Fixes: 87375ab47cd0 ("[IPVS]: ip_vs_ftp breaks connections using persistence")
Cc: stable@vger.kernel.org
Suggested-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Axel Mierczuk <axel.mierczuk@1password.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/netfilter/ipvs/ip_vs_sync.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -870,6 +870,25 @@ static void ip_vs_proc_conn(struct netns
struct ip_vs_dest *dest;
struct ip_vs_conn *cp;
+ /* Templates require cport 0. Ordinary connections require
+ * NO_CPORT exactly when cport is 0.
+ */
+ if (flags & IP_VS_CONN_F_TEMPLATE) {
+ if (param->cport) {
+ IP_VS_DBG(2, "BACKUP, template with cport dropped\n");
+ kfree(param->pe_data);
+ return;
+ }
+ } else if (!param->cport && !(flags & IP_VS_CONN_F_NO_CPORT)) {
+ IP_VS_DBG(2, "BACKUP, conn without cport dropped\n");
+ kfree(param->pe_data);
+ return;
+ } else if (param->cport && (flags & IP_VS_CONN_F_NO_CPORT)) {
+ IP_VS_DBG(2, "BACKUP, conn with cport and NO_CPORT dropped\n");
+ kfree(param->pe_data);
+ return;
+ }
+
if (!(flags & IP_VS_CONN_F_TEMPLATE)) {
cp = ip_vs_conn_in_get(param);
if (cp && ((cp->dport != dport) ||
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 527/742] ipvs: wait grace period before reusing destinations
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (517 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 526/742] ipvs: validate cport in received sync records Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 528/742] KVM: PPC: Book3S HV: Avoid spurious interrupts caused by LPCR_MER bit Greg Kroah-Hartman
` (207 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Vega, Darong Lu, Jiayuan Chen,
Ren Wei, Julian Anastasov, Pablo Neira Ayuso
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darong Lu <zzyy19904204639@163.com>
commit 5367e14e92bbb0779612d36cce7c6e95d3bc5e68 upstream.
An IPVS destination can be removed from a service and immediately reused
from dest_trash before an RCU grace period has elapsed. Reusing its n_list
or d_list can make existing readers follow links into another service or
real-server hash chain.
The grace-period cookie is also saved when a live destination is unhashed
for an edit and consumed when it is rehashed. Describe rcu_state as the
cookie for an unlink, covering both trash and rehash cases.
When a destination is retrieved from dest_trash, ip_vs_add_dest() currently
restarts its estimator before waiting for the grace period.
If the estimator was on a tick chain, ip_vs_stop_estimator() removed
est->list with hlist_del_rcu(), so an estimator kthread can still be
traversing that node.
ip_vs_start_estimator() rewrites the node on its temporary list on success,
or initializes it on failure, before the current wait. A reader can then
follow the changed link or stop traversing the chain early.
Wait immediately after retrieving the destination, before starting its
estimator. The conditional grace-period wait then covers the destination
list, real-server hash and estimator list on both estimator success and
failure paths.
Fixes: bcbde4c0a755 ("ipvs: make the service replacement more robust")
Cc: stable@vger.kernel.org
Reported-by: Vega <vega@nebusec.ai>
Reported-by: Darong Lu <zzyy19904204639@163.com>
Co-developed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Signed-off-by: Darong Lu <zzyy19904204639@163.com>
Signed-off-by: Ren Wei <weir@nebusec.ai>
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/net/ip_vs.h | 4 +
net/netfilter/ipvs/ip_vs_ctl.c | 110 ++++++++++++++++++++++++++++++++---------
2 files changed, 91 insertions(+), 23 deletions(-)
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -1021,7 +1021,9 @@ struct ip_vs_dest {
struct rcu_head rcu_head;
struct list_head t_list; /* in dest_trash */
- unsigned int in_rs_table:1; /* we are in rs_table */
+ unsigned long rcu_state; /* GP cookie on unlink (trash or rehash) */
+ unsigned int in_rs_table:1, /* we are in rs_table */
+ need_gp:1; /* Need GP on rehash */
};
/* The scheduler object */
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -64,7 +64,8 @@ int ip_vs_get_debug_level(void)
/* Protos */
-static void __ip_vs_del_service(struct ip_vs_service *svc, bool cleanup);
+static void __ip_vs_del_service(struct ip_vs_service *svc,
+ struct list_head *dest_trash, bool cleanup);
#ifdef CONFIG_IP_VS_IPV6
@@ -918,6 +919,11 @@ static void ip_vs_rs_hash(struct netns_i
*/
hash = ip_vs_rs_hashkey(dest->af, &dest->addr, port);
+ /* Need RCU grace period when rehashing */
+ if (dest->need_gp) {
+ cond_synchronize_rcu(dest->rcu_state);
+ dest->need_gp = 0;
+ }
hlist_add_head_rcu(&dest->d_list, &ipvs->rs_table[hash]);
dest->in_rs_table = 1;
}
@@ -1111,6 +1117,8 @@ ip_vs_trash_get_dest(struct ip_vs_servic
struct ip_vs_dest *dest;
struct netns_ipvs *ipvs = svc->ipvs;
+ lockdep_assert_held(&ipvs->service_mutex);
+
/*
* Find the destination in trash
*/
@@ -1144,24 +1152,57 @@ out:
return dest;
}
-/* Put destination in trash */
-static void ip_vs_trash_put_dest(struct netns_ipvs *ipvs,
+/* Add destination in temp list for trash */
+static void ip_vs_trash_add_dest(struct netns_ipvs *ipvs,
struct ip_vs_dest *dest, unsigned long istart,
- bool cleanup)
+ struct list_head *dest_trash)
{
- spin_lock_bh(&ipvs->dest_trash_lock);
IP_VS_DBG_BUF(3, "Moving dest %s:%u into trash, dest->refcnt=%d\n",
IP_VS_DBG_ADDR(dest->af, &dest->addr), ntohs(dest->port),
refcount_read(&dest->refcnt));
+ /* dest lives in trash with reference */
+ list_add(&dest->t_list, dest_trash);
+ dest->idle_start = istart;
+}
+
+/* Put destinations in trash */
+static void ip_vs_trash_put_dests(struct netns_ipvs *ipvs,
+ struct list_head *dest_trash, bool cleanup)
+{
+ spin_lock_bh(&ipvs->dest_trash_lock);
if (list_empty(&ipvs->dest_trash) && !cleanup)
mod_timer(&ipvs->dest_trash_timer,
jiffies + (IP_VS_DEST_TRASH_PERIOD >> 1));
- /* dest lives in trash with reference */
- list_add(&dest->t_list, &ipvs->dest_trash);
- dest->idle_start = istart;
+ list_splice(dest_trash, &ipvs->dest_trash);
spin_unlock_bh(&ipvs->dest_trash_lock);
}
+/* Put destination back in trash */
+static void ip_vs_trash_put_back(struct netns_ipvs *ipvs,
+ struct ip_vs_dest *dest)
+{
+ LIST_HEAD(dest_trash);
+
+ ip_vs_trash_add_dest(ipvs, dest, dest->idle_start, &dest_trash);
+ ip_vs_trash_put_dests(ipvs, &dest_trash, false);
+}
+
+/* Put destinations in trash and save the RCU state */
+static void ip_vs_trash_save_dests(struct netns_ipvs *ipvs,
+ struct list_head *dest_trash, bool cleanup)
+{
+ struct ip_vs_dest *dest;
+ unsigned long rcu_state;
+
+ if (!list_empty(dest_trash)) {
+ /* Remember when dests were removed and added to dest_trash */
+ rcu_state = get_state_synchronize_rcu();
+ list_for_each_entry(dest, dest_trash, t_list)
+ dest->rcu_state = rcu_state;
+ ip_vs_trash_put_dests(ipvs, dest_trash, cleanup);
+ }
+}
+
static void ip_vs_dest_rcu_free(struct rcu_head *head)
{
struct ip_vs_dest *dest;
@@ -1377,8 +1418,16 @@ __ip_vs_update_dest(struct ip_vs_service
if ((udest->conn_flags & IP_VS_CONN_F_FWD_MASK) !=
IP_VS_DFWD_METHOD(dest) ||
udest->tun_type != dest->tun_type ||
- udest->tun_port != dest->tun_port)
+ udest->tun_port != dest->tun_port) {
+ bool unlinked = dest->in_rs_table;
+
ip_vs_rs_unhash(dest);
+ if (unlinked) {
+ dest->rcu_state = get_state_synchronize_rcu();
+ /* Need grace period in this or next dest update */
+ dest->need_gp = 1;
+ }
+ }
/* set the tunnel info */
dest->tun_type = udest->tun_type;
@@ -1562,6 +1611,11 @@ ip_vs_add_dest(struct ip_vs_service *svc
dest = ip_vs_trash_get_dest(svc, udest->af, &daddr, dport);
if (dest != NULL) {
+ /* Readers may still follow the n_list, d_list or estimator list
+ * links. Wait before reusing any of them.
+ */
+ cond_synchronize_rcu(dest->rcu_state);
+
IP_VS_DBG_BUF(3, "Get destination %s:%u from trash, "
"dest->refcnt=%d, service %u/%s:%u\n",
IP_VS_DBG_ADDR(udest->af, &daddr), ntohs(dport),
@@ -1572,11 +1626,14 @@ ip_vs_add_dest(struct ip_vs_service *svc
ret = ip_vs_start_estimator(svc->ipvs, &dest->stats);
/* On error put back dest into the trash */
- if (ret < 0)
- ip_vs_trash_put_dest(svc->ipvs, dest, dest->idle_start,
- false);
- else
+ if (ret < 0) {
+ ip_vs_trash_put_back(svc->ipvs, dest);
+ } else {
+ /* need_gp matters only on dest edit, reinit it */
+ dest->need_gp = 0;
+
__ip_vs_update_dest(svc, dest, udest, 1);
+ }
} else {
/*
* Allocate and initialize the dest structure
@@ -1640,7 +1697,7 @@ ip_vs_edit_dest(struct ip_vs_service *sv
* Delete a destination (must be already unlinked from the service)
*/
static void __ip_vs_del_dest(struct netns_ipvs *ipvs, struct ip_vs_dest *dest,
- bool cleanup)
+ struct list_head *dest_trash, bool cleanup)
{
ip_vs_stop_estimator(ipvs, &dest->stats);
@@ -1649,7 +1706,7 @@ static void __ip_vs_del_dest(struct netn
*/
ip_vs_rs_unhash(dest);
- ip_vs_trash_put_dest(ipvs, dest, 0, cleanup);
+ ip_vs_trash_add_dest(ipvs, dest, 0, dest_trash);
/* Queue up delayed work to expire all no destination connections.
* No-op when CONFIG_SYSCTL is disabled.
@@ -1699,6 +1756,7 @@ ip_vs_del_dest(struct ip_vs_service *svc
{
struct ip_vs_dest *dest;
__be16 dport = udest->port;
+ LIST_HEAD(dest_trash);
/* We use function that requires RCU lock */
rcu_read_lock();
@@ -1718,7 +1776,9 @@ ip_vs_del_dest(struct ip_vs_service *svc
/*
* Delete the destination
*/
- __ip_vs_del_dest(svc->ipvs, dest, false);
+ __ip_vs_del_dest(svc->ipvs, dest, &dest_trash, false);
+
+ ip_vs_trash_save_dests(svc->ipvs, &dest_trash, false);
return 0;
}
@@ -2063,7 +2123,8 @@ out:
* - The service must be unlinked, unlocked and not referenced!
* - We are called under _bh lock
*/
-static void __ip_vs_del_service(struct ip_vs_service *svc, bool cleanup)
+static void __ip_vs_del_service(struct ip_vs_service *svc,
+ struct list_head *dest_trash, bool cleanup)
{
struct ip_vs_dest *dest, *nxt;
struct ip_vs_scheduler *old_sched;
@@ -2097,7 +2158,7 @@ static void __ip_vs_del_service(struct i
*/
list_for_each_entry_safe(dest, nxt, &svc->destinations, n_list) {
__ip_vs_unlink_dest(svc, dest, 0);
- __ip_vs_del_dest(svc->ipvs, dest, cleanup);
+ __ip_vs_del_dest(svc->ipvs, dest, dest_trash, cleanup);
}
/*
@@ -2120,7 +2181,8 @@ static void __ip_vs_del_service(struct i
/*
* Unlink a service from list and try to delete it if its refcnt reached 0
*/
-static void ip_vs_unlink_service(struct ip_vs_service *svc, bool cleanup)
+static void ip_vs_unlink_service(struct ip_vs_service *svc,
+ struct list_head *dest_trash, bool cleanup)
{
ip_vs_unregister_conntrack(svc);
/* Hold svc to avoid double release from dest_trash */
@@ -2130,7 +2192,7 @@ static void ip_vs_unlink_service(struct
*/
ip_vs_svc_unhash(svc);
- __ip_vs_del_service(svc, cleanup);
+ __ip_vs_del_service(svc, dest_trash, cleanup);
}
/*
@@ -2140,12 +2202,14 @@ static int ip_vs_del_service(struct ip_v
{
struct netns_ipvs *ipvs;
struct ip_vs_rht *t, *p;
+ LIST_HEAD(dest_trash);
int ns;
if (svc == NULL)
return -EEXIST;
ipvs = svc->ipvs;
- ip_vs_unlink_service(svc, false);
+ ip_vs_unlink_service(svc, &dest_trash, false);
+ ip_vs_trash_save_dests(ipvs, &dest_trash, false);
/* Drop the table if no more services */
ns = ip_vs_get_num_services(ipvs);
@@ -2196,6 +2260,7 @@ static int ip_vs_flush(struct netns_ipvs
struct hlist_bl_node *ne;
struct hlist_bl_node *e;
struct ip_vs_rht *t, *p;
+ LIST_HEAD(dest_trash);
/* Stop the resizer and drop the tables */
if (!test_and_set_bit(IP_VS_WORK_SVC_NORESIZE, &ipvs->work_flags))
@@ -2205,8 +2270,9 @@ static int ip_vs_flush(struct netns_ipvs
if (ip_vs_get_num_services(ipvs)) {
ip_vs_rht_walk_buckets(ipvs->svc_table, head) {
hlist_bl_for_each_entry_safe(svc, e, ne, head, s_list)
- ip_vs_unlink_service(svc, cleanup);
+ ip_vs_unlink_service(svc, &dest_trash, cleanup);
}
+ ip_vs_trash_save_dests(ipvs, &dest_trash, cleanup);
}
/* Unregister the hash table and release it after RCU grace period */
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 528/742] KVM: PPC: Book3S HV: Avoid spurious interrupts caused by LPCR_MER bit
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (518 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 527/742] ipvs: wait grace period before reusing destinations Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 529/742] KVM: PPC: Book3S HV: Disable preemption around host-side HPT lock users Greg Kroah-Hartman
` (206 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Timothy Pearson, Gautam Menghani,
Ritesh Harjani (IBM), Madhavan Srinivasan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautam Menghani <gautam@linux.ibm.com>
commit 9751c361cb234f000261879b1b5015bf08f6a428 upstream.
A huge number of spurious interrupts can be seen immediately after a KVM
on PowerNV guest boots up in XIVE mode.
$ cat /proc/interrupts | grep SPU
SPU: 223705 192439 273526 147623 Spurious interrupts
This bug was introduced by commit ecd10702baae5 ("KVM: PPC: Book3S HV:
Handle pending exceptions on guest entry with MSR_EE"). The root cause
is that once LPCR_MER bit is set, it is supposed to be reset by
software. But when a vCPU starts running with LPCR_MER set, the vCPU does
not exit back to the host until the decrementer expires or there is an
hcall, etc. This is because KVM on PowerNV guests have support for
native XIVE, so they are not dependent on host for interrupt emulation.
Due to this behaviour, a huge number of spurious interrupts are seen
since LPCR_MER continues to be set and LPCR_MER cannot be reset until the
vCPU exits to the host.
Fix this behaviour by not using the LPCR_MER bit whenever native XIVE is
available (currently in case of KVM on PowerNV only), as the XIVE hardware
can present interrupts to the KVM guest vCPU directly. So the LPCR_MER
functionality is not required. This reduces the number of spurious
interrupts drastically.
Fixes: ecd10702baae5 ("KVM: PPC: Book3S HV: Handle pending exceptions on guest entry with MSR_EE")
Cc: stable@vger.kernel.org # 6.8+
Reported-by: Timothy Pearson <tpearson@raptorengineering.com>
Closes: https://lore.kernel.org/linuxppc-dev/582904882.11159.1786719390349.JavaMail.zimbra@raptorengineeringinc.com
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261102091700.253381-1-gautam@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/kvm/book3s_hv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -4984,7 +4984,7 @@ int kvmhv_run_single_vcpu(struct kvm_vcp
if (!kvmhv_on_pseries() && (__kvmppc_get_msr_hv(vcpu) & MSR_EE))
kvmppc_inject_interrupt_hv(vcpu,
BOOK3S_INTERRUPT_EXTERNAL, 0);
- else
+ else if (!kvmppc_xive_enabled(vcpu))
lpcr |= LPCR_MER;
} else {
/*
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 529/742] KVM: PPC: Book3S HV: Disable preemption around host-side HPT lock users
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (519 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 528/742] KVM: PPC: Book3S HV: Avoid spurious interrupts caused by LPCR_MER bit Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 530/742] KVM: PPC: Book3S HV: Ensure that calls to idr_alloc are synchronized Greg Kroah-Hartman
` (205 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Amit Machhiwal, Ritesh Harjani (IBM),
Madhavan Srinivasan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Machhiwal <amachhiw@linux.ibm.com>
commit 4e6e66ecf62185828f731914000a6b0baff355db upstream.
A previous change ("KVM: PPC: Book3S HV: Add preempt_disable() around
virtual-mode HPTE bit-lock users") at [1] added preempt_disable() around
guest vCPU HPT hcalls and page fault handlers executed in virtual mode.
This ensures vCPU threads cannot be preempted while holding
HPTE_V_HVLOCK or the reverse-map lock.
However, several host-side virtual-mode paths in book3s_64_mmu_hv.c also
acquire HPTE_V_HVLOCK and lock_rmap() in process context with preemption
enabled. Specifically, kvm_unmap_rmapp() and kvm_age_rmapp() take both
locks during MMU notifier callbacks and memslot flushes, while
resize_hpt_rehash_hpte() acquires HPTE_V_HVLOCK during HPT resizing. If
a host thread is preempted while holding either bit-lock, any guest vCPU
thread scheduled on the same CPU spinning for the same lock with
preemption disabled will never yield, resulting in a permanent CPU hang.
Fix this by disabling preemption across these host-side critical
sections.
For kvm_unmap_rmapp() and kvm_age_rmapp(), place preempt_disable()
before lock_rmap() so that both the rmap chain lock and the subsequent
HPTE_V_HVLOCK bit-lock are held under a single non-preemptible window.
To preserve the ABBA lock ordering between the two locks, re-enable
preemption after dropping the rmap lock on any retry or early-exit path
before spinning on cpu_relax(), allowing the lock holder to be
scheduled.
For kvm_htab_write(), the HPT migration restore path, replace the direct
calls to kvmppc_do_h_remove() with kvmppc_virtmode_do_h_remove(), a thin
wrapper that brackets kvmppc_do_h_remove() with preempt_disable() and
preempt_enable(), mirroring the existing kvmppc_virtmode_do_h_enter()
helper.
For resize_hpt_rehash_hpte(), place preempt_disable() before the
try_lock_hpte() spin loop and preempt_enable() after unlock_hpte() at
the function exit.
[1] https://git.kernel.org/powerpc/c/abbbe5ff83e7c9ed3a4d61b73011f1df7bf87907
Fixes: 6165d5dd99db ("KVM: PPC: Book3S HV: add virtual mode handlers for HPT hcalls and page faults")
Cc: stable@vger.kernel.org # v5.14+
Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261014185215.71832-1-amachhiw@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/kvm/book3s_64_mmu_hv.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -47,6 +47,9 @@
static long kvmppc_virtmode_do_h_enter(struct kvm *kvm, unsigned long flags,
long pte_index, unsigned long pteh,
unsigned long ptel, unsigned long *pte_idx_ret);
+static void kvmppc_virtmode_do_h_remove(struct kvm *kvm, unsigned long flags,
+ unsigned long pte_index, unsigned long avpn,
+ unsigned long *hpret);
struct kvm_resize_hpt {
/* These fields read-only after init */
@@ -308,6 +311,22 @@ static long kvmppc_virtmode_do_h_enter(s
}
+/*
+ * Virtual-mode H_REMOVE. kvmppc_do_h_remove() is also called from real mode,
+ * where preempt_disable() is not usable, so the guard stays here. The function
+ * spins on HPTE_V_HVLOCK and then lock_rmap() (via remove_revmap_chain());
+ * preemption must be disabled across both bit-locks so that spinning callers
+ * holding preempt_disable() can make forward progress.
+ */
+static void kvmppc_virtmode_do_h_remove(struct kvm *kvm, unsigned long flags,
+ unsigned long pte_index, unsigned long avpn,
+ unsigned long *hpret)
+{
+ preempt_disable();
+ kvmppc_do_h_remove(kvm, flags, pte_index, avpn, hpret);
+ preempt_enable();
+}
+
static struct kvmppc_slb *kvmppc_mmu_book3s_hv_find_slbe(struct kvm_vcpu *vcpu,
gva_t eaddr)
{
@@ -810,9 +829,11 @@ static void kvm_unmap_rmapp(struct kvm *
rmapp = &memslot->arch.rmap[gfn - memslot->base_gfn];
for (;;) {
+ preempt_disable();
lock_rmap(rmapp);
if (!(*rmapp & KVMPPC_RMAP_PRESENT)) {
unlock_rmap(rmapp);
+ preempt_enable();
break;
}
@@ -826,6 +847,7 @@ static void kvm_unmap_rmapp(struct kvm *
if (!try_lock_hpte(hptep, HPTE_V_HVLOCK)) {
/* unlock rmap before spinning on the HPTE lock */
unlock_rmap(rmapp);
+ preempt_enable();
while (be64_to_cpu(hptep[0]) & HPTE_V_HVLOCK)
cpu_relax();
continue;
@@ -834,6 +856,7 @@ static void kvm_unmap_rmapp(struct kvm *
kvmppc_unmap_hpte(kvm, i, memslot, rmapp, gfn);
unlock_rmap(rmapp);
__unlock_hpte(hptep, be64_to_cpu(hptep[0]));
+ preempt_enable();
}
}
@@ -890,6 +913,7 @@ static bool kvm_age_rmapp(struct kvm *kv
rmapp = &memslot->arch.rmap[gfn - memslot->base_gfn];
retry:
+ preempt_disable();
lock_rmap(rmapp);
if (*rmapp & KVMPPC_RMAP_REFERENCED) {
*rmapp &= ~KVMPPC_RMAP_REFERENCED;
@@ -897,6 +921,7 @@ static bool kvm_age_rmapp(struct kvm *kv
}
if (!(*rmapp & KVMPPC_RMAP_PRESENT)) {
unlock_rmap(rmapp);
+ preempt_enable();
return ret;
}
@@ -912,6 +937,7 @@ static bool kvm_age_rmapp(struct kvm *kv
if (!try_lock_hpte(hptep, HPTE_V_HVLOCK)) {
/* unlock rmap before spinning on the HPTE lock */
unlock_rmap(rmapp);
+ preempt_enable();
while (be64_to_cpu(hptep[0]) & HPTE_V_HVLOCK)
cpu_relax();
goto retry;
@@ -931,6 +957,7 @@ static bool kvm_age_rmapp(struct kvm *kv
} while ((i = j) != head);
unlock_rmap(rmapp);
+ preempt_enable();
return ret;
}
@@ -1219,6 +1246,7 @@ static unsigned long resize_hpt_rehash_h
if (!(vpte & HPTE_V_VALID) && !(vpte & HPTE_V_ABSENT))
return 0; /* nothing to do */
+ preempt_disable();
while (!try_lock_hpte(hptep, HPTE_V_HVLOCK))
cpu_relax();
@@ -1346,6 +1374,7 @@ static unsigned long resize_hpt_rehash_h
out:
unlock_hpte(hptep, vpte);
+ preempt_enable();
return ret;
}
@@ -1868,7 +1897,7 @@ static ssize_t kvm_htab_write(struct fil
nb += HPTE_SIZE;
if (be64_to_cpu(hptp[0]) & (HPTE_V_VALID | HPTE_V_ABSENT))
- kvmppc_do_h_remove(kvm, 0, i, 0, tmp);
+ kvmppc_virtmode_do_h_remove(kvm, 0, i, 0, tmp);
err = -EIO;
ret = kvmppc_virtmode_do_h_enter(kvm, H_EXACT, i, v, r,
tmp);
@@ -1897,7 +1926,7 @@ static ssize_t kvm_htab_write(struct fil
for (j = 0; j < hdr.n_invalid; ++j) {
if (be64_to_cpu(hptp[0]) & (HPTE_V_VALID | HPTE_V_ABSENT))
- kvmppc_do_h_remove(kvm, 0, i, 0, tmp);
+ kvmppc_virtmode_do_h_remove(kvm, 0, i, 0, tmp);
++i;
hptp += 2;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 530/742] KVM: PPC: Book3S HV: Ensure that calls to idr_alloc are synchronized
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (520 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 529/742] KVM: PPC: Book3S HV: Disable preemption around host-side HPT lock users Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 531/742] KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call Greg Kroah-Hartman
` (204 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ritesh Harjani (IBM),
Gautam Menghani, Madhavan Srinivasan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautam Menghani <gautam@linux.ibm.com>
commit d8c6ab0aeeca7cc2adfcf0ce1f796c6a86314ec0 upstream.
Calls to idr_alloc() in __prealloc_nested() are not currently synchronized.
According to the documentation [1], the caller should provide their own
locking to prevent concurrent modifications to the idr to prevent bugs.
__prealloc_nested() calls idr_alloc() with GFP_KERNEL which can
sleep and mmu_lock is a spinlock. So idr_alloc() cannot be moved under
mmu_lock. In such cases the idr Documentation says:
If you need to take a lock while allocating a new ID from the IDR,
you may need to pass a restrictive set of GFP flags, which can lead
to the IDR being unable to allocate memory. To work around this,
you can call idr_preload() before taking the lock, and then
idr_preload_end() after the allocation.
Hence preload the idr memory with idr_preload() before taking mmu_lock,
which allows us to use idr_alloc(..., GFP_NOWAIT) under the spinlock.
This also allows to kill __prealloc_nested() and __add_nested(), as they
are not needed anymore with idr_preload().
[1]: lib/idr.c
Fixes: c0f00a18e2a8 ("KVM: PPC: Book3S HV Nested: Change nested guest lookup to use idr")
Cc: stable@vger.kernel.org # 5.19+
Co-developed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261012082922.218799-2-gautam@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/kvm/book3s_hv_nested.c | 34 ++++++++++------------------------
1 file changed, 10 insertions(+), 24 deletions(-)
--- a/arch/powerpc/kvm/book3s_hv_nested.c
+++ b/arch/powerpc/kvm/book3s_hv_nested.c
@@ -702,20 +702,6 @@ static struct kvm_nested_guest *__find_n
return idr_find(&kvm->arch.kvm_nested_guest_idr, lpid);
}
-static bool __prealloc_nested(struct kvm *kvm, int lpid)
-{
- if (idr_alloc(&kvm->arch.kvm_nested_guest_idr,
- NULL, lpid, lpid + 1, GFP_KERNEL) != lpid)
- return false;
- return true;
-}
-
-static void __add_nested(struct kvm *kvm, int lpid, struct kvm_nested_guest *gp)
-{
- if (idr_replace(&kvm->arch.kvm_nested_guest_idr, gp, lpid))
- WARN_ON(1);
-}
-
static void __remove_nested(struct kvm *kvm, int lpid)
{
idr_remove(&kvm->arch.kvm_nested_guest_idr, lpid);
@@ -862,21 +848,21 @@ struct kvm_nested_guest *kvmhv_get_neste
if (!newgp)
return NULL;
- if (!__prealloc_nested(kvm, l1_lpid)) {
- kvmhv_release_nested(newgp);
- return NULL;
- }
-
+ idr_preload(GFP_KERNEL);
spin_lock(&kvm->mmu_lock);
gp = __find_nested(kvm, l1_lpid);
if (!gp) {
- __add_nested(kvm, l1_lpid, newgp);
- ++newgp->refcnt;
- gp = newgp;
- newgp = NULL;
+ if (idr_alloc(&kvm->arch.kvm_nested_guest_idr, newgp,
+ l1_lpid, l1_lpid + 1, GFP_NOWAIT) >= 0) {
+ ++newgp->refcnt;
+ gp = newgp;
+ newgp = NULL;
+ }
}
- ++gp->refcnt;
+ if (gp)
+ ++gp->refcnt;
spin_unlock(&kvm->mmu_lock);
+ idr_preload_end();
if (newgp)
kvmhv_release_nested(newgp);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 531/742] KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (521 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 530/742] KVM: PPC: Book3S HV: Ensure that calls to idr_alloc are synchronized Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 532/742] KVM: PPC: Book3S HV: XICS: Avoid NULL ptr deref in kvmppc_xive_cleanup_vcpu() Greg Kroah-Hartman
` (203 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Gautam Menghani,
Ritesh Harjani (IBM), Madhavan Srinivasan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautam Menghani <gautam@linux.ibm.com>
commit b04be22bf6ea06b92bff7850328a8057b8d964ae upstream.
Since there is no srcu read lock around kvmppc_h_page_init(), a
"suspicious rcu_dereference_check() usage" can be triggered by running
host linux with CONFIG_PROVE_RCU=y and the following code in the guest:
plpar_hcall_norets(H_PAGE_INIT, H_ZERO_PAGE, phys_addr, 0);
=============================
WARNING: suspicious RCU usage
7.0.0-dirty #227 Not tainted
-----------------------------
./include/linux/kvm_host.h:1074 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by qemu-system-ppc/2093:
#0: c000000354197ab0 (&vcpu->mutex){+.+.}-{3:3}, at: kvm_vcpu_ioctl+0x10c/0xaf0
stack backtrace:
CPU: 30 UID: 0 PID: 2093 Comm: qemu-system-ppc Not tainted 7.0.0-dirty #227 PREEMPT(full)
Hardware name: IBM,9080-HEX POWER10 (architected) 0x800200 0xf000006 of:IBM,FW1060.60 (NH1060_158) hv:phyp pSeries
Call Trace:
[c00000033e1bf430] [c000000001b3dbd4] dump_stack_lvl+0xc8/0x130 (unreliable)
[c00000033e1bf470] [c0000000003da964] lockdep_rcu_suspicious+0x1f4/0x290
[c00000033e1bf520] [c000000000231424] gfn_to_memslot+0x1b4/0x1c0
[c00000033e1bf560] [c00000000023637c] kvm_clear_guest+0x9c/0x110
[c00000033e1bf5c0] [c0000000002714a4] kvmppc_h_page_init+0x160/0x1a0
[c00000033e1bf610] [c00000000026c040] kvmppc_pseries_do_hcall+0x1930/0x1940
[c00000033e1bf6d0] [c00000000026fb18] kvmppc_vcpu_run_hv+0x268/0x800
[c00000033e1bf7a0] [c000000000246b30] kvmppc_vcpu_run+0x30/0x50
[c00000033e1bf7c0] [c000000000241ed4] kvm_arch_vcpu_ioctl_run+0x364/0x530
[c00000033e1bf860] [c00000000022b870] kvm_vcpu_ioctl+0x1b0/0xaf0
[c00000033e1bfa50] [c0000000009b4514] sys_ioctl+0x144/0x190
[c00000033e1bfab0] [c000000000034330] system_call_exception+0x170/0x370
[c00000033e1bfe50] [c00000000000d05c] system_call_vectored_common+0x15c/0x2ec
Fix this by taking a srcu read lock around kvmppc_h_page_init().
Fixes: 2d34d1c3bbfd ("KVM: PPC: Book3S HV: Implement virtual mode H_PAGE_INIT handler")
Cc: stable@vger.kernel.org # 5.2+
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261012082922.218799-5-gautam@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/kvm/book3s_hv.c | 2 ++
1 file changed, 2 insertions(+)
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1388,9 +1388,11 @@ int kvmppc_pseries_do_hcall(struct kvm_v
ret = kvmhv_copy_tofrom_guest_nested(vcpu);
break;
case H_PAGE_INIT:
+ idx = srcu_read_lock(&kvm->srcu);
ret = kvmppc_h_page_init(vcpu, kvmppc_get_gpr(vcpu, 4),
kvmppc_get_gpr(vcpu, 5),
kvmppc_get_gpr(vcpu, 6));
+ srcu_read_unlock(&kvm->srcu, idx);
break;
case H_SVM_PAGE_IN:
ret = H_UNSUPPORTED;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 532/742] KVM: PPC: Book3S HV: XICS: Avoid NULL ptr deref in kvmppc_xive_cleanup_vcpu()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (522 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 531/742] KVM: PPC: Book3S HV: Take SRCU read lock around kvmppc_h_page_init() call Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 533/742] KVM: PPC: Book3S HV: XICS: Update irq_type for cleanup to work Greg Kroah-Hartman
` (202 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Gautam Menghani,
Ritesh Harjani (IBM), Madhavan Srinivasan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautam Menghani <gautam@linux.ibm.com>
commit 7279692d70f3e399b3dd2d07ffa365e9f533761f upstream.
In kvmppc_xive_connect_vcpu() if there is a failure before
xc->vp_ipi_data is setup, it can result in a NULL pointer dereference in
kvmppc_xive_cleanup_vcpu() when accessing the MMIO page in
xive_vm_esb_load(). Fix this by adding a check before masking
the VP IPI before accessing the MMIO pages.
Fixes: 5af50993850a ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller")
Cc: stable@vger.kernel.org # 4.12+
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261012082922.218799-4-gautam@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/kvm/book3s_xive.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/arch/powerpc/kvm/book3s_xive.c
+++ b/arch/powerpc/kvm/book3s_xive.c
@@ -1818,7 +1818,8 @@ void kvmppc_xive_cleanup_vcpu(struct kvm
kvmppc_xive_disable_vcpu_interrupts(vcpu);
/* Mask the VP IPI */
- xive_vm_esb_load(&xc->vp_ipi_data, XIVE_ESB_SET_PQ_01);
+ if (xc->vp_ipi_data.eoi_mmio)
+ xive_vm_esb_load(&xc->vp_ipi_data, XIVE_ESB_SET_PQ_01);
/* Free escalations */
for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 533/742] KVM: PPC: Book3S HV: XICS: Update irq_type for cleanup to work
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (523 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 532/742] KVM: PPC: Book3S HV: XICS: Avoid NULL ptr deref in kvmppc_xive_cleanup_vcpu() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 534/742] mm, swap: stop cluster list scans once swapoff clears SWP_WRITEOK Greg Kroah-Hartman
` (201 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Gautam Menghani,
Ritesh Harjani (IBM), Madhavan Srinivasan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gautam Menghani <gautam@linux.ibm.com>
commit b9d9a8741752c5b42c65b1c8dffba867889b74e5 upstream.
In kvmppc_xive_connect_vcpu(), if any failures are encountered, the
control flow jumps to the 'bail' label where kvmppc_xive_cleanup_vcpu()
is called. This cleanup function exits prematurely since
vcpu->arch.irq_type is set to KVMPPC_IRQ_DEFAULT at this point. This ends
up resulting in wasted memory.
Fix this by setting irq_type to KVMPPC_IRQ_XICS before vcpu configuration
starts. This makes XICS initialization symmetrical to XIVE
initialization done in kvmppc_xive_native_connect_vcpu().
Fixes: 5af50993850a ("KVM: PPC: Book3S HV: Native usage of the XIVE interrupt controller")
Cc: stable@vger.kernel.org # 4.12+
Signed-off-by: Gautam Menghani <gautam@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261012082922.218799-3-gautam@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/kvm/book3s_xive.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/arch/powerpc/kvm/book3s_xive.c
+++ b/arch/powerpc/kvm/book3s_xive.c
@@ -1938,6 +1938,7 @@ int kvmppc_xive_connect_vcpu(struct kvm_
xc->vp_id = vp_id;
xc->mfrr = 0xff;
xc->valid = true;
+ vcpu->arch.irq_type = KVMPPC_IRQ_XICS;
r = xive_native_get_vp_info(xc->vp_id, &xc->vp_cam, &xc->vp_chip_id);
if (r)
@@ -2026,7 +2027,6 @@ bail:
return r;
}
- vcpu->arch.irq_type = KVMPPC_IRQ_XICS;
return 0;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 534/742] mm, swap: stop cluster list scans once swapoff clears SWP_WRITEOK
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (524 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 533/742] KVM: PPC: Book3S HV: XICS: Update irq_type for cleanup to work Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 535/742] mm/damon/core: reset watermark wait state on each iteration Greg Kroah-Hartman
` (200 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Mani Tofigh, Andrew Morton,
Kairui Song, Chris Li, Kemeng Shi, Nhat Pham, Baoquan He,
Barry Song, Youngjun Park, Tal Zussman, Kairui Song
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mani Tofigh <mt4022@columbia.edu>
commit 53a6f71c147a445a6c305513acaa25f2e01a44e9 upstream.
SWP_WRITEOK is cleared under si->lock when swapoff starts so that no
new swap entries are allocated from the device, and try_to_unuse()
then waits for writeback of the folios that still use the device.
However, an order-0 allocation that chose the device can race with
swapoff clearing the flag and then loop forever. It takes a cluster
from the fragment cluster list of a higher order with
isolate_lock_cluster(), the allocation from that cluster fails because
SWP_WRITEOK is clear, and relocate_cluster() puts the cluster back on
the same list, so the loop keeps finding clusters on it.
The looping task is in reclaim, and it may have set writeback on a
folio whose write has been queued but not yet submitted. swapoff then
waits for that folio, while the reclaiming task, stuck in the loop,
never reaches the point where it submits the write:
CPU0 (reclaim) CPU1 (swapoff)
-------------- --------------
shrink_folio_list()
pageout(F)
/* F under writeback,
write not submitted */
folio_alloc_swap(G) /* order 0 */
swap_alloc_slow()
del_from_avail_list(si, true)
si->flags &= ~SWP_WRITEOK
try_to_unuse()
folio_wait_writeback(F)
cluster_alloc_swap_entry()
isolate_lock_cluster()
/* allocation fails:
!SWP_WRITEOK */
relocate_cluster()
/* repeats forever */
swap_write_submit()
/* never reached */
This results in a soft lockup on CPU0 and a swapoff that never returns.
isolate_lock_cluster() used to check SWP_WRITEOK under si->lock until
commit 07adc4cf1ecd ("mm, swap: implement dynamic allocation of swap
table") removed that check. Restore the check. Since swapoff clears
the flag under the same lock, isolate_lock_cluster() then returns NULL,
which ends the scan; the swap slot allocation for G fails, and reclaim
goes on to submit the write of F.
Given that this is a race, its reproducibility is non-deterministic.
We reproduce it by using a non-rotational swap device that is not
synchronous, with 64K mTHP enabled, where one CPU repeatedly pages out
two 64K folios and a 4K page with madvise(MADV_PAGEOUT), while other
CPUs run swapoff and swapon on the same device. In my tests it
triggers within 20s in each run, and with the fix applied, it runs for
300s without any hang/kernel report. This bug was found and
reproduced deterministically using a deterministic hypervisor that is
currently under development.
Link: https://lore.kernel.org/20261026-swapoff-writeok-v1-1-4f4cd420aa33@columbia.edu
Fixes: 07adc4cf1ecd ("mm, swap: implement dynamic allocation of swap table")
Signed-off-by: Mani Tofigh <mt4022@columbia.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Kairui Song <kasong@tencent.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Barry Song <baohua@kernel.org>
Cc: Youngjun Park <youngjun.park@lge.com>
Cc: Tal Zussman <tz2294@columbia.edu>
Cc: Kairui Song <ryncsn@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/swapfile.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -627,6 +627,10 @@ static struct swap_cluster_info *isolate
u8 flags = CLUSTER_FLAG_NONE;
spin_lock(&si->lock);
+
+ if (unlikely(!(si->flags & SWP_WRITEOK)))
+ goto out;
+
list_for_each_entry(ci, list, list) {
if (!spin_trylock(&ci->lock))
continue;
@@ -642,6 +646,7 @@ static struct swap_cluster_info *isolate
found = ci;
break;
}
+out:
spin_unlock(&si->lock);
/* Cluster's table is freed when and only when it's on the free list. */
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 535/742] mm/damon/core: reset watermark wait state on each iteration
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (525 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 534/742] mm, swap: stop cluster list scans once swapoff clears SWP_WRITEOK Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 536/742] mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test Greg Kroah-Hartman
` (199 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Aveline Noir, SJ Park, Andrew Morton,
Wang Xiaolei
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aveline Noir <jm5905938@gmail.com>
commit 5fe092741502770107a0be7b3885ce55f7761f01 upstream.
Patch series "mm/damon: fix watermark state, kunit pid leak and selftest
fake pass".
Three hotfixes for core, kunit and selftest. Fix kdamond deactivation
from missed watermark reset with patch 1. Fix pid leak in kunit test
with patch 2. Fix a selftest wrongly passing when it should skip, with
patch 3.
Note for reviewers. This series is a collection of fixes that were
initially developed by different people. Changelog is in each patch.
This patch (of 3):
Found while reviewing the DAMON source code that if an online commit
removes all schemes while kdamond is waiting for watermark activation,
the scheme loop becomes empty but min_wait_time keeps the previous
positive value. kdamond then keeps sleeping instead of resuming
monitoring without schemes.
The way to wake up the kdamond again without DAMON is bit complicated.
Install a scheme having watermarks that can activate the kdamond again,
and remove the scheme again. Doable but cumbersome and complicated.
Initialize min_wait_time and init_wait_time on each loop iteration so
the wait is calculated from the current schemes and an empty scheme
list resumes monitoring.
Link: https://lore.kernel.org/20261102144627.88843-1-sj@kernel.org
Link: https://lore.kernel.org/20261102144627.88843-2-sj@kernel.org
Fixes: da87878010e5 ("mm/damon/sysfs: support online inputs update")
Signed-off-by: Aveline Noir <jm5905938@gmail.com>
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
Cc: Wang Xiaolei <xiaoleiwangxiaolei@gmail.com>
Cc: <stable@vger.kernel.org> # 5.19.x
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/damon/core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3797,10 +3797,11 @@ static int kdamond_wait_activation(struc
{
struct damos *s;
unsigned long wait_time;
- unsigned long min_wait_time = 0;
- bool init_wait_time = false;
while (!kdamond_need_stop(ctx)) {
+ unsigned long min_wait_time = 0;
+ bool init_wait_time = false;
+
damon_for_each_scheme(s, ctx) {
wait_time = damos_wmark_wait_us(s);
if (!init_wait_time || wait_time < min_wait_time) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 536/742] mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (526 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 535/742] mm/damon/core: reset watermark wait state on each iteration Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 537/742] mm/filemap: stop fault-around when the walk steps back Greg Kroah-Hartman
` (198 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Wang Xiaolei, SJ Park, Andrew Morton,
Michal Hocko, Mike Rapoport, Suren Baghdasaryan, Vlastimil Babka,
Liam R. Howlett, Brendan Higgins, David Gow, Aveline Noir
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Xiaolei <xiaoleiwangxiaolei@gmail.com>
commit 9d2cc214935ad78b8f54bf886f0b4e3f387fa44f upstream.
damon_sysfs_test_add_targets() creates its monitoring context with
damon_new_ctx(), which leaves ctx->ops zero-initialized. Since
DAMON_OPS_VADDR is zero, damon_target_has_pid() returns true for the
context, and damon_sysfs_add_targets() therefore calls
damon_set_target_pid() for each target it adds. That function grabs a
reference to the target's struct pid via find_get_pid().
The test then tears the context down with damon_destroy_ctx(), which
releases such a reference from ctx->ops.cleanup_target(). For the vaddr
operations set that callback is damon_va_cleanup_target(), and it is the
only place where the reference is put. The test never selects an
operations set, though, so cleanup_target is NULL and both references --
one for each of the two damon_sysfs_add_targets() calls -- are leaked on
every run of the test. Running the test with CONFIG_DEBUG_KMEMLEAK
enabled reports the leaked struct pid objects as unreferenced.
Fix this by selecting the vaddr operations set for the context before
adding the targets, mirroring what the sysfs interface does.
damon_select_ops() fails if the vaddr operations set is not registered,
in which case the test cannot exercise the pid handling and skips
itself.
Link: https://lore.kernel.org/20261102144627.88843-3-sj@kernel.org
Fixes: b8ee5575f763 ("mm/damon/sysfs-test: add a unit test for damon_sysfs_set_targets()")
Signed-off-by: Wang Xiaolei <xiaoleiwangxiaolei@gmail.com>
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: "Liam R. Howlett" <liam@infradead.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@davidgow.net>
Cc: Aveline Noir <jm5905938@gmail.com>
Cc: <stable@vger.kernel.org> # 6.7.x
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/damon/tests/sysfs-kunit.h | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/mm/damon/tests/sysfs-kunit.h
+++ b/mm/damon/tests/sysfs-kunit.h
@@ -79,6 +79,15 @@ static void damon_sysfs_test_add_targets
kunit_skip(test, "ctx alloc fail");
}
+ if (damon_select_ops(ctx, DAMON_OPS_VADDR)) {
+ damon_destroy_ctx(ctx);
+ kfree(sysfs_targets->targets_arr);
+ kfree(sysfs_targets);
+ kfree(sysfs_target->regions);
+ kfree(sysfs_target);
+ kunit_skip(test, "vaddr ops not registered");
+ }
+
damon_sysfs_add_targets(ctx, sysfs_targets);
KUNIT_EXPECT_EQ(test, 1u, nr_damon_targets(ctx));
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 537/742] mm/filemap: stop fault-around when the walk steps back
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (527 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 536/742] mm/damon/tests/sysfs-kunit: fix leaked pid reference in add_targets test Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 538/742] mm/huge_memory: prevent losing PG_waiters in __split_folio_to_order() Greg Kroah-Hartman
` (197 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jose Fernandez (Anthropic),
Andrew Morton, Jan Kara, Matthew Wilcox (Oracle),
David Hildenbrand, Krystian Kaniewski, Pedro Falcato
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jose Fernandez (Anthropic) <jose.fernandez@linux.dev>
commit cf5518aa1832d82b391ac2492863ae6a7315827c upstream.
filemap_map_pages() can dereference a PTE pointer outside the page table
it locked. KASAN has reported this as a use-after-free read [1]. The
same path can also write out of bounds. When the stray entry reads as
none, the fault-around loop maps a page there with set_pte_range().
Its fault-around loop walks the page cache and moves vmf->pte by the
change in index. A lower index moves it back. xas_find() can step back
to a lower index when a multi-index entry is split during the walk.
[1] fixes xas_find(), but the loop still relies on the walk never stepping
back. Stop the fault-around when the walk steps back. ->fault() maps the
faulting page if the loop did not.
Link: https://lore.kernel.org/20261031-jf-mm-filemap-map-pages-lower-bound-v2-1-21029744e589@linux.dev
Link: https://lore.kernel.org/20260904121301.200049-1-krystianmkaniewski@gmail.com [1]
Fixes: 6b24ca4a1a8d ("mm: Use multi-index entries in the page cache")
Signed-off-by: Jose Fernandez (Anthropic) <jose.fernandez@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Krystian Kaniewski <krystianmkaniewski@gmail.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/filemap.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3950,6 +3950,13 @@ vm_fault_t filemap_map_pages(struct vm_f
unsigned long end;
vm_fault_t map_ret;
+ /* A lower index could move vmf->pte out of its page table. */
+ if (unlikely(xas.xa_index < last_pgoff)) {
+ folio_unlock(folio);
+ folio_put(folio);
+ break;
+ }
+
addr += (xas.xa_index - last_pgoff) << PAGE_SHIFT;
vmf->pte += xas.xa_index - last_pgoff;
last_pgoff = xas.xa_index;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 538/742] mm/huge_memory: prevent losing PG_waiters in __split_folio_to_order()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (528 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 537/742] mm/filemap: stop fault-around when the walk steps back Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 539/742] mm/kasan/kunit: add double-free tests involving kfree_rcu_sheaf() Greg Kroah-Hartman
` (196 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kiryl Shutsemau, David Hildenbrand,
Ye Liu, Zi Yan, Baolin Wang, Ye Liu
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zi Yan <ziy@nvidia.com>
commit 7183af7f01c839ecef87840a90c0d8c5843f37d7 upstream.
__split_folio_to_order() calls prep_compound_page() on each new head page
to create a compound page after clear_compound_head(). prep_compound_page()
uses non atomic __SetPageHead(). It is mostly OK, since the folio is locked
and frozen and no one else is supposed to modify the folio's flags.
However, code calling migration_entry_wait() can reach the folio by PFN,
then access its flags. It is because softleaf_entry_wait_on_locked() used
by migration_entry_wait() sets PG_waiters concurrently without taking a
reference and the frozen refcount during split cannot block it. Meanwhile,
__SetPageHead() does a plain read and write, so PG_waiters atomically set
by softleaf_entry_wait_on_locked() will be lost if the set happens after
__SetPageHead()'s read and before its write.
One example code interleaving:
CPU0: __split_folio_to_order(new_order>0) CPU1: do_swap_page()
1. clear_compound_head(new_head)
new_head->compound_info = 0
(page_folio(new_head) == new_head now)
2. migration_entry_wait()
softleaf_to_folio(entry)
page_folio() -> new_head
(not the old head any more)
3. prep_compound_page(new_head, new_order)
__SetPageHead(new_head)
tmp = new_head->flags.f <-- load; PG_waiters == 0 in tmp
4. folio_set_waiters(new_head)
set_bit(PG_waiters, &flags.f)
enqueue on waitqueue, sleep
5. new_head->flags.f = tmp | (1UL << PG_head)
<-- store; overwrites step 4, PG_waiters == 0 again
Later, folio_unlock(new_folio) sees no PG_waiters, skips folio_wake_bit(),
and CPU1 can remain blocked indefinitely.
Fix it by setting PG_head along with other flags in new_folio->flags before
smp_wmb() and clear_compound_head(). The remaining compound page metadata
is set after clear_compound_head(). In that way, after
clear_compound_head() makes new_folio visible, nothing overwrites the
PG_waiters from softleaf_entry_wait_on_locked() by modifying
new_folio->flags non-atomically.
While at it, use data_race() to suppress the KCSAN issue reported by Ye
Liu's patch (the second Closes) on reading folio->flags in
__split_folio_to_order().
Suggested-by: Kiryl Shutsemau <kas@kernel.org>
Reported-by: David Hildenbrand <david@kernel.org>
Closes: https://lore.kernel.org/all/DMHE8BEEER1H.2BIY52NXATPIA@nvidia.com/
Reported-by: Ye Liu <ye.liu@linux.dev>
Closes: https://lore.kernel.org/all/20261029-data_race_huge_mem-v1-1-112e331291c1@linux.dev/
Fixes: c010d47f107f6 ("mm: thp: split huge page to any lower order pages")
Cc: stable@vger.kernel.org
Signed-off-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Ye Liu <liuye@kylinos.cn>
Link: https://patch.msgid.link/20261110-fix-split_folio_to_order-race-v4-1-cc5042f33408@nvidia.com
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/huge_memory.c | 32 ++++++++++++++++++++++++++++----
mm/internal.h | 2 ++
mm/page_alloc.c | 17 +++++++++++++++--
3 files changed, 45 insertions(+), 6 deletions(-)
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3773,6 +3773,7 @@ static void __split_folio_to_order(struc
* Don't pass it around before clear_compound_head().
*/
struct folio *new_folio = (struct folio *)new_head;
+ memdesc_flags_t new_flags;
VM_BUG_ON_PAGE(atomic_read(&new_folio->_mapcount) != -1, new_head);
@@ -3789,8 +3790,15 @@ static void __split_folio_to_order(struc
* unreferenced sub-pages of an anonymous THP: we can simply drop
* PG_anon_exclusive (-> PG_mappedtodisk) for these here.
*/
- new_folio->flags.f &= ~PAGE_FLAGS_CHECK_AT_PREP;
- new_folio->flags.f |= (folio->flags.f &
+ new_flags.f = new_folio->flags.f & ~PAGE_FLAGS_CHECK_AT_PREP;
+ /*
+ * data_race() is used because folio->flags is only read here,
+ * but a reference-less writer can still write to it, e.g.,
+ * PG_waiters update from softleaf_entry_wait_on_locked().
+ * The flag is not transferred to new_flags as it is
+ * folio specific, so it is not lost.
+ */
+ new_flags.f |= data_race(folio->flags.f) &
((1L << PG_referenced) |
(1L << PG_swapbacked) |
(1L << PG_swapcache) |
@@ -3808,7 +3816,19 @@ static void __split_folio_to_order(struc
#endif
(1L << PG_dirty) |
(1L << PG_dropbehind) |
- LRU_GEN_MASK | LRU_REFS_MASK));
+ LRU_GEN_MASK | LRU_REFS_MASK);
+
+ /*
+ * Set PG_head before smp_wmb() and clear_compound_head().
+ * After clear_compound_head() marks new_head as a folio of its
+ * own, new_head->flags must not be modified by plain RMWs.
+ * A plain RMW can cause a loss of atomic PG_* updates from
+ * a reference-less writer, e.g., setting PG_waiters via
+ * softleaf_entry_wait_on_locked().
+ */
+ if (new_order)
+ new_flags.f |= 1L << PG_head;
+ WRITE_ONCE(new_folio->flags.f, new_flags.f);
new_folio->mapping = folio->mapping;
new_folio->index = folio->index + i;
@@ -3834,7 +3854,11 @@ static void __split_folio_to_order(struc
*/
clear_compound_head(new_head);
if (new_order) {
- prep_compound_page(new_head, new_order);
+ /*
+ * PG_head is set above, so only set up the remaining
+ * metadata on head page and tail pages.
+ */
+ __prep_compound_page(new_head, new_order);
folio_set_large_rmappable(new_folio);
}
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -838,6 +838,8 @@ static inline void init_compound_tail(st
prep_compound_tail(tail, head, order);
}
+void __prep_compound_page(struct page *page, unsigned int order);
+
#if defined CONFIG_COMPACTION || defined CONFIG_CMA
/*
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -699,18 +699,31 @@ static inline bool pcp_allowed_order(uns
* This usage means that zero-order pages may not be compound.
*/
-void prep_compound_page(struct page *page, unsigned int order)
+/*
+ * Set up the metadata on head page and tail pages.
+ * Caller must set PG_head before this.
+ */
+void __prep_compound_page(struct page *page, unsigned int order)
{
int i;
int nr_pages = 1 << order;
- __SetPageHead(page);
for (i = 1; i < nr_pages; i++)
prep_compound_tail(page + i, page, order);
prep_compound_head(page, order);
}
+/*
+ * PG_head is set non-atomically. It should be used when no one else can modify
+ * @page's flags.
+ */
+void prep_compound_page(struct page *page, unsigned int order)
+{
+ __SetPageHead(page);
+ __prep_compound_page(page, order);
+}
+
static inline void set_buddy_order(struct page *page, unsigned int order)
{
set_page_private(page, order);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 539/742] mm/kasan/kunit: add double-free tests involving kfree_rcu_sheaf()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (529 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 538/742] mm/huge_memory: prevent losing PG_waiters in __split_folio_to_order() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 540/742] mm/kasan: detect double-free " Greg Kroah-Hartman
` (195 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Andrew Morton,
Alexander Potapenko, Harry Yoo, Andrey Ryabinin, Vlastimil Babka,
Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino, Hao Li,
Christoph Lameter, David Rientjes, Roman Gushchin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <kuniyu@google.com>
commit 97a5aa11cc0cfe4dedd436c32793320b490c4331 upstream.
The new test cases verify that KASAN immediately detects all
three combinations of double-free involving kfree_rcu_sheaf():
1. kmem_cache_free() -> kfree_rcu()
2. kfree_rcu() -> kmem_cache_free()
3. kfree_rcu() -> kfree_rcu()
Each test also evicts the object from the KASAN quarantine and
reallocates it as a victim object before flushing the RCU sheaf
to ensure the live victim object is not poisoned by the rejected
double-free.
Without the patch, all tests fail to detect the 2nd free, and
the victim is poisoned:
# kmem_cache_double_free_rcu_1: EXPECTATION FAILED at mm/kasan/kasan_test_c.c:1096
KASAN failure expected in "kfree_rcu(p, rcu)", but none occurred
... <splat below is logged here>
# kmem_cache_double_free_rcu_1: EXPECTATION FAILED at mm/kasan/kasan_test_c.c:1156
Expected (<...snipped READ_ONCE()...>&(victim->i)); }) == 42, but
<...snipped READ_ONCE()...>victim->i == 117729280 (0x7046800)
# kasan: pass:0 fail:3 skip:0 total:3
# Totals: pass:0 fail:3 skip:0 total:3
not ok 1 kasan
In all cases, KASAN logs a false-positive use-after-free splat at
READ_ONCE(victim->i), and it has no information about the suspect;
the two stack traces ("Call Trace:" and "Allocated by") are of the
live victim, and "Freed by" is of the RCU task.
BUG: KASAN: slab-use-after-free in __kmem_cache_double_free_rcu+0x9ee/0xaf0
Read of size 4 at addr ffff8881076c2938 by task kunit_try_catch/513
...
Freed by task 0:
...
__rcu_free_sheaf_prepare+0xf6/0x240
rcu_free_sheaf_nobarn+0x31/0xe0
rcu_core+0x75e/0x16b0
With the patch, all tests can detect the 2nd free immediately and
prevent the victim from being poisoned:
# kasan: pass:3 fail:0 skip:0 total:3
# Totals: pass:3 fail:0 skip:0 total:3
ok 1 kasan
All the stack traces point to the same object for double-free,
and the two free traces are shown in "Call Trace:" and "Freed by"
(or "Last potentially related work creation:" in the 2nd/3rd test
cases).
BUG: KASAN: double-free in kvfree_call_rcu+0xb6/0x3c0
Free of addr ffff888108495938 by task kunit_try_catch/511
...
Call Trace:
<TASK>
...
check_slab_allocation+0x10d/0x120
__kfree_rcu_sheaf+0x1c/0x2d0
kvfree_call_rcu+0xb6/0x3c0
__kmem_cache_double_free_rcu+0x310/0xaf0
Allocated by task 511:
...
kmem_cache_alloc_noprof+0x14f/0x3c0
__kmem_cache_double_free_rcu+0x152/0xaf0
Freed by task 511:
...
kmem_cache_free+0x14f/0x3c0
__kmem_cache_double_free_rcu+0x2c6/0xaf0
Notably, in the 2nd/3rd test cases, we can detect the 2nd free
before the object is poisoned:
Memory state around the buggy address:
ffff888106dc7800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888106dc7880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888106dc7900: fc fc fc fc fc fc fc 00 00 00 fc fc fc fc fc fc
^
...
ok 2 kmem_cache_double_free_rcu_2
Link: https://lore.kernel.org/20261028194014.3671161-3-kuniyu@google.com
Fixes: ec66e0d59952 ("slab: add sheaf support for batching kfree_rcu() operations")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Alexander Potapenko <glider@google.com>
Cc: Harry Yoo <harry@kernel.org>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Harry Yoo <harry@kernel.org>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Hao Li <hao.li@linux.dev>
Cc: Christoph Lameter <cl@gentwo.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/kasan/kasan_test_c.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 139 insertions(+)
--- a/mm/kasan/kasan_test_c.c
+++ b/mm/kasan/kasan_test_c.c
@@ -30,6 +30,7 @@
#include <asm/page.h>
#include "kasan.h"
+#include "../slab.h"
#define OOB_TAG_OFF (IS_ENABLED(CONFIG_KASAN_GENERIC) ? 0 : KASAN_GRANULE_SIZE)
@@ -1070,6 +1071,139 @@ static void kmem_cache_double_free(struc
kmem_cache_destroy(cache);
}
+#ifndef MODULE
+static void __kmem_cache_double_free_rcu(struct kunit *test, int mode)
+{
+ struct kasan_rcu_info *p, *victim = NULL, **objs;
+ struct kmem_cache *cache;
+ int i, n = 0;
+
+ KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_KASAN_GENERIC);
+ KASAN_TEST_NEEDS_CONFIG_OFF(test, CONFIG_PREEMPT_RT);
+
+ cache = kmem_cache_create("test_cache", sizeof(*p), 0, SLAB_NO_MERGE,
+ NULL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, cache);
+
+ if (!cache->sheaf_capacity) {
+ kmem_cache_destroy(cache);
+ kunit_skip(test, "Test requires sheaves");
+ }
+
+ objs = kunit_kcalloc(test, cache->sheaf_capacity * 2, sizeof(*objs),
+ GFP_KERNEL);
+ if (!objs) {
+ kunit_err(test, "Allocation failed: %s\n", __func__);
+ goto out;
+ }
+
+ migrate_disable();
+
+ p = kmem_cache_alloc(cache, GFP_KERNEL);
+ if (!p) {
+ migrate_enable();
+ kunit_err(test, "Allocation failed: %s\n", __func__);
+ goto out;
+ }
+
+ switch (mode) {
+ case 1:
+ kmem_cache_free(cache, p);
+ /* p is already in quarantine. */
+ KUNIT_EXPECT_KASAN_FAIL(test, kfree_rcu(p, rcu));
+ migrate_enable();
+ break;
+ case 2:
+ /* The actual free order is inverse. */
+ kfree_rcu(p, rcu);
+ KUNIT_EXPECT_KASAN_FAIL(test, kmem_cache_free(cache, p));
+ migrate_enable();
+ break;
+ case 3:
+ kfree_rcu(p, rcu);
+
+ for (i = 0; i < cache->sheaf_capacity - 1; i++) {
+ objs[i] = kmem_cache_alloc(cache, GFP_KERNEL);
+ kfree_rcu(objs[i], rcu);
+ }
+
+ KUNIT_EXPECT_KASAN_FAIL(test, kfree_rcu(p, rcu));
+ migrate_enable();
+
+ /*
+ * Move the 1st full sheaf to quarantine, keeping the
+ * 2nd in pcs->rcu_free.
+ */
+ rcu_barrier();
+ break;
+ }
+
+ /*
+ * Move p to quarantine if not poisoned yet (case 2,
+ * or fallback in case 3).
+ */
+ if (kasan_byte_accessible(p))
+ kvfree_rcu_barrier_on_cache(cache);
+
+ /*
+ * Evict p from quarantine and reallocate it as a live victim object
+ * before the RCU sheaf is flushed.
+ */
+ kasan_quarantine_remove_cache(cache);
+
+ for (i = 0; i < cache->sheaf_capacity * 2; i++) {
+ objs[n] = kmem_cache_alloc(cache, GFP_KERNEL);
+ if (!objs[n])
+ break;
+ if (objs[n] == p) {
+ victim = objs[n];
+ break;
+ }
+ n++;
+ }
+
+ for (i = 0; i < n; i++)
+ kmem_cache_free(cache, objs[i]);
+
+ KUNIT_EXPECT_PTR_EQ(test, victim, p);
+ if (victim != p)
+ goto out;
+
+ WRITE_ONCE(victim->i, 42);
+
+ /*
+ * If kfree_rcu() failed to reject the double-free above,
+ * flushing the RCU sheaf will silently poison the live
+ * victim and cause a false-positive UAF on victim->i.
+ */
+ kvfree_rcu_barrier_on_cache(cache);
+ KUNIT_EXPECT_EQ(test, READ_ONCE(victim->i), 42);
+
+ if (!READ_ONCE(test_status.report_found))
+ kmem_cache_free(cache, victim);
+out:
+ kmem_cache_destroy(cache);
+}
+
+static void kmem_cache_double_free_rcu_1(struct kunit *test)
+{
+ /* kmem_cache_free() -> kfree_rcu() */
+ __kmem_cache_double_free_rcu(test, 1);
+}
+
+static void kmem_cache_double_free_rcu_2(struct kunit *test)
+{
+ /* kfree_rcu() -> kmem_cache_free() */
+ __kmem_cache_double_free_rcu(test, 2);
+}
+
+static void kmem_cache_double_free_rcu_3(struct kunit *test)
+{
+ /* kfree_rcu() -> kfree_rcu() */
+ __kmem_cache_double_free_rcu(test, 3);
+}
+#endif
+
static void kmem_cache_invalid_free(struct kunit *test)
{
char *p;
@@ -2239,6 +2373,11 @@ static struct kunit_case kasan_kunit_tes
KUNIT_CASE(kfree_via_phys),
KUNIT_CASE(kmem_cache_oob),
KUNIT_CASE(kmem_cache_double_free),
+#ifndef MODULE
+ KUNIT_CASE(kmem_cache_double_free_rcu_1),
+ KUNIT_CASE(kmem_cache_double_free_rcu_2),
+ KUNIT_CASE(kmem_cache_double_free_rcu_3),
+#endif
KUNIT_CASE(kmem_cache_invalid_free),
KUNIT_CASE(kmem_cache_rcu_uaf),
KUNIT_CASE(kmem_cache_rcu_reuse),
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 540/742] mm/kasan: detect double-free involving kfree_rcu_sheaf()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (530 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 539/742] mm/kasan/kunit: add double-free tests involving kfree_rcu_sheaf() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 541/742] mm/khugepaged: dont map folios that are not uptodate in MADV_COLLAPSE Greg Kroah-Hartman
` (194 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Andrew Morton,
Vlastimil Babka (SUSE), Alexander Potapenko, Andrey Ryabinin,
Harry Yoo, Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino,
Hao Li, Christoph Lameter, David Rientjes, Roman Gushchin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <kuniyu@google.com>
commit e212c463eee96b2568d8c85ca4ee63049dbb18f2 upstream.
Patch series "mm/kasan: Detect double-free involving kfree_rcu_sheaf().",
v3.
Recently, syzbot has reported several weird use-after-free splats.
What they have in common is that "Freed by" points to rcu_free_sheaf(),
whereas the object shown in "Call Trace:" and "Allocated by" is never
supposed to be freed via kfree_rcu().
This means the object was a victim of a double-free somewhere else and
was silently poisoned by rcu_free_sheaf() after being reallocated.
This happens because kfree_rcu_sheaf() queues an object into the RCU
sheaf without invoking any KASAN hooks.
This series enables KASAN to detect double-free involving
kfree_rcu_sheaf() immediately and adds KUnit tests for it.
This patch (of 2):
syzbot reported a weird use-after-free splat. [0]
In the report, an object in the kmalloc-64 cache was freed via
rcu_free_sheaf() while it was still in use, even though the
object should always be freed with kfree() (in xfrm_hash_free()),
implying that the object was a victim of a double-free involving
kfree_rcu() somewhere else.
When kvfree_call_rcu() frees an object via kfree_rcu_sheaf() and
queues it into pcs->rcu_free, debug facilities are skipped, e.g.,
kasan_slab_pre_free(), kasan_record_aux_stack(),
debug_rcu_head_queue(), etc.
As a result, KASAN cannot detect the double-free at the call site.
If the object is still in the KASAN quarantine when the sheaf is
flushed, KASAN can detect the double-free in rcu_free_sheaf(), but
with no trace of the suspect.
Worse yet, once the object is evicted from the quarantine and
reallocated before the sheaf is flushed, rcu_free_sheaf() silently
poisons the live object, resulting in a false-positive use-after-free
report on the new user.
If __kfree_rcu_sheaf() simply calls kasan_slab_pre_free(), we
can detect the second kfree_rcu(), but only while the object is
poisoned in the KASAN quarantine after the first free:
kfree() --(poisoned)--------------------> kfree_rcu()
kfree_rcu() -> rcu_free_sheaf() -(poisoned)-> kfree_rcu()
An object queued in pcs->rcu_free remains unpoisoned until the
sheaf becomes full and rcu_free_sheaf() runs after the RCU
grace period, so a subsequent kfree_rcu() or kfree() before
rcu_free_sheaf() cannot be detected by shadow bytes alone:
kfree_rcu() -(unpoisoned)-> kfree_rcu() -> rcu_free_sheaf() (too late!)
kfree_rcu() -(unpoisoned)-> kfree() -> rcu_free_sheaf() (too late!)
These cases can be detected if we call debug_rcu_head_queue()
before kfree_rcu_sheaf(), but ODEBUG splat only shows the second
free.
To detect these cases with KASAN, we just need a 1-bit flag
to indicate the state, which can reuse an unused bit in struct
kasan_track.pid. (PID_MAX_LIMIT is 1<<22)
The bit is marked along with recording the stack trace when
deferring slab frees in kfree_rcu_sheaf() and checked in
check_slab_allocation() so that any double-free pattern above
can be detected immediately.
Link: https://lore.kernel.org/20261028194014.3671161-1-kuniyu@google.com
Link: https://lore.kernel.org/20261028194014.3671161-2-kuniyu@google.com
Link: https://lore.kernel.org/all/6ac959ee.70ed5d86.2ac85.007d.GAE@google.com/ #[0]
Fixes: ec66e0d59952 ("slab: add sheaf support for batching kfree_rcu() operations")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Tested-by: Alexander Potapenko <glider@google.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Reviewed-by: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Harry Yoo <harry@kernel.org>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Hao Li <hao.li@linux.dev>
Cc: Christoph Lameter <cl@gentwo.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/kasan.h | 15 +++++++++++----
mm/kasan/common.c | 13 ++++++++-----
mm/kasan/generic.c | 17 ++++++++++++++++-
mm/kasan/kasan.h | 34 +++++++++++++++++++++++++++++++++-
mm/slub.c | 13 ++++++++++---
5 files changed, 78 insertions(+), 14 deletions(-)
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -180,10 +180,12 @@ static __always_inline void * __must_che
}
bool __kasan_slab_pre_free(struct kmem_cache *s, void *object,
- unsigned long ip);
+ unsigned long ip, bool after_rcu_delay);
/**
* kasan_slab_pre_free - Check whether freeing a slab object is safe.
+ * @s: Cache the object belongs to.
* @object: Object to be freed.
+ * @after_rcu_delay: Whether the free follows an RCU grace period.
*
* This function checks whether freeing the given object is safe. It may
* check for double-free and invalid-free bugs and report them.
@@ -193,10 +195,12 @@ bool __kasan_slab_pre_free(struct kmem_c
* @Return true if freeing the object is unsafe; false otherwise.
*/
static __always_inline bool kasan_slab_pre_free(struct kmem_cache *s,
- void *object)
+ void *object,
+ bool after_rcu_delay)
{
if (kasan_enabled())
- return __kasan_slab_pre_free(s, object, _RET_IP_);
+ return __kasan_slab_pre_free(s, object, _RET_IP_,
+ after_rcu_delay);
return false;
}
@@ -424,7 +428,8 @@ static inline void *kasan_init_slab_obj(
return (void *)object;
}
-static inline bool kasan_slab_pre_free(struct kmem_cache *s, void *object)
+static inline bool kasan_slab_pre_free(struct kmem_cache *s, void *object,
+ bool after_rcu_delay)
{
return false;
}
@@ -495,6 +500,7 @@ void kasan_cache_create(struct kmem_cach
void kasan_cache_shrink(struct kmem_cache *cache);
void kasan_cache_shutdown(struct kmem_cache *cache);
void kasan_record_aux_stack(void *ptr);
+void kasan_mark_rcu_free_pending(void *ptr);
#else /* CONFIG_KASAN_GENERIC */
@@ -512,6 +518,7 @@ static inline void kasan_cache_create(st
static inline void kasan_cache_shrink(struct kmem_cache *cache) {}
static inline void kasan_cache_shutdown(struct kmem_cache *cache) {}
static inline void kasan_record_aux_stack(void *ptr) {}
+static inline void kasan_mark_rcu_free_pending(void *ptr) {}
#endif /* CONFIG_KASAN_GENERIC */
--- a/mm/kasan/common.c
+++ b/mm/kasan/common.c
@@ -68,6 +68,7 @@ void kasan_set_track(struct kasan_track
track->timestamp = ts_nsec >> 9;
#endif /* CONFIG_KASAN_EXTRA_INFO */
track->pid = current->pid;
+ track->rcu_free = 0;
track->stack = stack;
}
@@ -231,7 +232,7 @@ void * __must_check __kasan_init_slab_ob
/* Returns true when freeing the object is not safe. */
static bool check_slab_allocation(struct kmem_cache *cache, void *object,
- unsigned long ip)
+ unsigned long ip, bool after_rcu_delay)
{
void *tagged_object = object;
@@ -242,7 +243,8 @@ static bool check_slab_allocation(struct
return true;
}
- if (!kasan_byte_accessible(tagged_object)) {
+ if (!kasan_byte_accessible(tagged_object) ||
+ kasan_check_rcu_free(cache, object, after_rcu_delay)) {
kasan_report_invalid_free(tagged_object, ip, KASAN_REPORT_DOUBLE_FREE);
return true;
}
@@ -259,17 +261,18 @@ static inline void poison_slab_object(st
kasan_poison(object, round_up(cache->object_size, KASAN_GRANULE_SIZE),
KASAN_SLAB_FREE, init);
+ kasan_clear_rcu_free(cache, object);
if (kasan_stack_collection_enabled())
kasan_save_free_info(cache, tagged_object);
}
bool __kasan_slab_pre_free(struct kmem_cache *cache, void *object,
- unsigned long ip)
+ unsigned long ip, bool after_rcu_delay)
{
if (is_kfence_address(object))
return false;
- return check_slab_allocation(cache, object, ip);
+ return check_slab_allocation(cache, object, ip, after_rcu_delay);
}
bool __kasan_slab_free(struct kmem_cache *cache, void *object, bool init,
@@ -544,7 +547,7 @@ bool __kasan_mempool_poison_object(void
slab = page_slab(page);
- if (check_slab_allocation(slab->slab_cache, ptr, ip))
+ if (check_slab_allocation(slab->slab_cache, ptr, ip, false))
return false;
poison_slab_object(slab->slab_cache, ptr, false);
--- a/mm/kasan/generic.c
+++ b/mm/kasan/generic.c
@@ -533,10 +533,13 @@ size_t kasan_metadata_size(struct kmem_c
}
/*
+ * Records an auxiliary stack trace for the object at @addr and, if @rcu_free
+ * is set, marks the object as pending an RCU-delayed free.
+ *
* This function avoids dynamic memory allocations and thus can be called from
* contexts that do not allow allocating memory.
*/
-void kasan_record_aux_stack(void *addr)
+static void __kasan_record_aux_stack(void *addr, bool rcu_free)
{
struct slab *slab = kasan_addr_to_slab(addr);
struct kmem_cache *cache;
@@ -552,10 +555,22 @@ void kasan_record_aux_stack(void *addr)
if (!alloc_meta)
return;
+ if (rcu_free)
+ alloc_meta->alloc_track.rcu_free = 1;
alloc_meta->aux_stack[1] = alloc_meta->aux_stack[0];
alloc_meta->aux_stack[0] = kasan_save_stack(0, 0);
}
+void kasan_record_aux_stack(void *addr)
+{
+ __kasan_record_aux_stack(addr, false);
+}
+
+void kasan_mark_rcu_free_pending(void *addr)
+{
+ __kasan_record_aux_stack(addr, true);
+}
+
void kasan_save_alloc_info(struct kmem_cache *cache, void *object, gfp_t flags)
{
struct kasan_alloc_meta *alloc_meta;
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -191,7 +191,10 @@ static inline bool kasan_requires_meta(v
#define KASAN_STACK_DEPTH 64
struct kasan_track {
- u32 pid;
+#define KASAN_PID_BITS const_ilog2(PID_MAX_LIMIT)
+ u32 pid:KASAN_PID_BITS;
+ u32 rcu_free:1;
+ u32 unused:32 - (KASAN_PID_BITS + 1);
depot_stack_handle_t stack;
#ifdef CONFIG_KASAN_EXTRA_INFO
u64 cpu:20;
@@ -390,8 +393,37 @@ struct kasan_alloc_meta *kasan_get_alloc
struct kasan_free_meta *kasan_get_free_meta(struct kmem_cache *cache,
const void *object);
void kasan_init_object_meta(struct kmem_cache *cache, const void *object);
+
+static inline bool kasan_check_rcu_free(struct kmem_cache *cache,
+ const void *object,
+ bool after_rcu_delay)
+{
+ struct kasan_alloc_meta *alloc_meta;
+
+ alloc_meta = kasan_get_alloc_meta(cache, object);
+ if (!alloc_meta)
+ return false;
+
+ return alloc_meta->alloc_track.rcu_free != after_rcu_delay;
+}
+
+static inline void kasan_clear_rcu_free(struct kmem_cache *cache,
+ const void *object)
+{
+ struct kasan_alloc_meta *alloc_meta;
+
+ alloc_meta = kasan_get_alloc_meta(cache, object);
+ if (alloc_meta)
+ alloc_meta->alloc_track.rcu_free = 0;
+}
#else
static inline void kasan_init_object_meta(struct kmem_cache *cache, const void *object) { }
+static inline bool kasan_check_rcu_free(struct kmem_cache *cache, const void *object,
+ bool after_rcu_delay)
+{
+ return false;
+}
+static inline void kasan_clear_rcu_free(struct kmem_cache *cache, const void *object) { }
#endif
depot_stack_handle_t kasan_save_stack(gfp_t flags, depot_flags_t depot_flags);
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2691,7 +2691,7 @@ bool slab_free_hook(struct kmem_cache *s
* Give KASAN a chance to notice an invalid free operation before we
* modify the object.
*/
- if (kasan_slab_pre_free(s, x))
+ if (kasan_slab_pre_free(s, x, after_rcu_delay))
return false;
#ifdef CONFIG_SLUB_RCU_DEBUG
@@ -2707,7 +2707,7 @@ bool slab_free_hook(struct kmem_cache *s
* We have to do this manually because the rcu_head is
* not located inside the object.
*/
- kasan_record_aux_stack(x);
+ kasan_mark_rcu_free_pending(x);
delayed_free->object = x;
call_rcu(&delayed_free->head, slab_free_after_rcu_debug);
@@ -6258,6 +6258,12 @@ bool __kfree_rcu_sheaf(struct kmem_cache
}
do_free:
+ if (unlikely(kasan_slab_pre_free(s, obj, false))) {
+ local_unlock(&s->cpu_sheaves->lock);
+ goto out;
+ }
+
+ kasan_mark_rcu_free_pending(obj);
rcu_sheaf = pcs->rcu_free;
@@ -6298,6 +6304,7 @@ do_free:
local_unlock(&s->cpu_sheaves->lock);
stat(s, FREE_RCU_SHEAF);
+out:
if (!IS_ENABLED(CONFIG_PREEMPT_RT))
lock_map_release(&kfree_rcu_sheaf_map);
return true;
@@ -6931,7 +6938,7 @@ void kfree_nolock(const void *object)
* -> kfree_nolock() -> kasan_report_invalid_free() on the same CPU
* is double buggy and deserves to deadlock.
*/
- if (kasan_slab_pre_free(s, x))
+ if (kasan_slab_pre_free(s, x, false))
return;
/*
* memcg, kasan_slab_pre_free are done for 'x'.
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 541/742] mm/khugepaged: dont map folios that are not uptodate in MADV_COLLAPSE
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (531 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 540/742] mm/kasan: detect double-free " Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 542/742] mm/memfd: handle GUP pins more reliably when write-sealing Greg Kroah-Hartman
` (193 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Chris Mason, Lorenzo Stoakes (ARM),
Hugh Dickins, Zi Yan, Zach OKeefe, SJ Park, Baolin Wang,
Lance Yang, Kiryl Shutsemau (Meta), Pedro Falcato,
David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit 043a2260b96ffc13121a1dd65282e67eb2e1d8a8 upstream.
madvise(MADV_COLLAPSE) can map PMD-sized pagecache folios that are not
uptodate. For example, shmem fallocate() can put such folios into the
page cache.
collapse_file() already refuses to proceed with folios that are not
uptodate. Let's just do the same in try_collapse_pte_mapped_thp() and skip
such folios, leaving handling to the page faults.
Note that collapse_file() effectively clears shmem folios through
shmem_get_folio(); let's keep this fix simple and simply let the page
fault path deal with that.
Fixes: 34488399fa08 ("mm/madvise: add file and shmem support to MADV_COLLAPSE")
Reported-by: Chris Mason <mason@kernel.org>
Cc: stable@vger.kernel.org
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Zach O'Keefe <zokeefe@google.com>
Reviewed-by: SJ Park <sj@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Link: https://patch.msgid.link/20261105-set_huge_pmd_uptodate-v1-1-a78d8a1b7117@kernel.org
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/khugepaged.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1912,6 +1912,12 @@ static enum scan_result try_collapse_pte
goto drop_folio;
}
+ /* Leave any uninitialized folios to the page fault path. */
+ if (!folio_test_uptodate(folio)) {
+ result = SCAN_FAIL;
+ goto drop_folio;
+ }
+
result = find_pmd_or_thp_or_none(mm, haddr, &pmd);
switch (result) {
case SCAN_SUCCEED:
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 542/742] mm/memfd: handle GUP pins more reliably when write-sealing
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (532 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 541/742] mm/khugepaged: dont map folios that are not uptodate in MADV_COLLAPSE Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 543/742] mm/memory-failure: fix folio refcount leak and min_order_for_split() locking Greg Kroah-Hartman
` (192 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Chris Mason, Lorenzo Stoakes (ARM),
Lance Yang, David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit d369ba5a46c65c54b94c94713ca1fb4ad6a87ebf upstream.
memfd_wait_for_pins() detects GUP references by comparing a folio's
actual refcount with its expected refcount. As spelled out by
folio_expected_ref_count(), obtaining the expected refcount when there
can be concurrent folio (un)mapping is racy.
So it is possible that a changing folio mapcount can race with our
check for GUP references, and F_SEAL_WRITE might succeed even if there
are some, allowing file contents to be modified after sealing.
For folios with a reliable pincount, detect FOLL_PIN references using
folio_maybe_dma_pinned() before falling back to the refcount comparison.
For small folios without that, the 1024 pinning BIAS makes it very hard
(although not impossible) to misguide the refcount comparison.
This improves FOLL_PIN detection for folios with a pincount. Handling
FOLL_GET and small folios requires a more fundamental change.
Fortunately, most interfaces that allow for GUP'ing such pages use
FOLL_PIN, in particular interfaces using FOLL_LONGTERM. However, we
still have some FOLL_GET leftovers ...
Fixes: 05f65b5c7090 ("shm: wait for pins to be released when sealing")
Cc: stable@vger.kernel.org
Cc: Chris Mason <mason@kernel.org>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Link: https://patch.msgid.link/20261103-fixes_core_2-v1-1-f332954f1df4@kernel.org
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/memfd.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/mm/memfd.c
+++ b/mm/memfd.c
@@ -32,6 +32,13 @@
static bool memfd_folio_has_extra_refs(struct folio *folio)
{
+ /*
+ * Use the precise pincount where available to avoid racy refcount
+ * comparisons.
+ */
+ if (folio_has_pincount(folio) && folio_maybe_dma_pinned(folio))
+ return true;
+
return folio_ref_count(folio) != folio_expected_ref_count(folio);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 543/742] mm/memory-failure: fix folio refcount leak and min_order_for_split() locking
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (533 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 542/742] mm/memfd: handle GUP pins more reliably when write-sealing Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 544/742] mm/mempolicy: use one node set for interleave weights Greg Kroah-Hartman
` (191 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, David Hildenbrand (Arm),
Andrew Morton, Li Youhong, Usama Arif, Lorenzo Stoakes (ARM),
Zi Yan, Baolin Wang, Miaohe Lin, Liam R. Howlett, Ryan Roberts,
Dev Jain, Barry Song, Lance Yang, Naoya Horiguchi, Wei Yang,
Nico Pache, Luis Chamberlain, Tal Zussman
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit cd5f5bf781b4ead6a6571818d5613ea2ed0145f3 upstream.
hwpoison code can end up calling min_order_for_split() without holding the
folio lock. There isn't really something that would prevent concurrent
truncation. Consequently folio->mapping can get set to NULL after
checking for "!folio->mapping", and if the compiler reloads
folio->mapping, mapping_min_folio_order() would try to dereference NULL.
While very unlikely to happen in practice, let's just enforce that
min_order_for_split() is called with the folio lock held. We can
significantly cleanup the calling hwpoison code, and just get rid of
try_to_split_thp_page() to hold the folio lock for a bit longer.
Just work on folios now, which further cleans up the code. We just have
to be careful about doing the page_folio() after splitting, which we have
to do already either way. Do not change the way we split for now, this
needs more thought and should be done separately.
Cleaning this up we fix another issue: in soft_offline_in_use_page(), we
would currently have leaked a folio reference.
In min_order_for_split(), document and assert that we need the folio lock.
Drop the questionable VM_BUG_ON_PAGE(!page_count(p), p) check entirely.
While updating the comment in soft_offline_in_use_page(), just drop the
"NOTE" part that does not add any value to current code.
The folio->mapping problem was identified by Sashiko, and Li Youhong
reported it by sending a proposal fix.
This likely does not really warrant CCing stable, but I expect little
conflicts when doing the backport, so let's just CC stable because of the
refcount leak.
Link: https://lore.kernel.org/20261030-try_to_split_thp_page-v2-1-c957c9b42eab@kernel.org
Fixes: 689b8986776c ("mm/memory-failure: improve large block size folio handling")
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Li Youhong <liyouhong@kylinos.cn>
Closes: https://lore.kernel.org/r/20260804035828.2684059-1-dayou5941@163.com
Acked-by: Usama Arif <usama.arif@linux.dev>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Nico Pache <nico.pache@linux.dev>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Tal Zussman <tz2294@columbia.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/huge_memory.c | 4 +++
mm/memory-failure.c | 63 +++++++++++++++++-----------------------------------
2 files changed, 25 insertions(+), 42 deletions(-)
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -4564,10 +4564,14 @@ int folio_split(struct folio *folio, uns
* If a file-backed folio is truncated, 0 will be returned. Any subsequent
* split attempt should get -EBUSY from split checking code.
*
+ * Context: @folio must be locked.
+ *
* Return: @folio's minimum order for split
*/
unsigned int min_order_for_split(struct folio *folio)
{
+ VM_WARN_ON_ONCE_FOLIO(!folio_test_locked(folio), folio);
+
if (folio_test_anon(folio))
return 0;
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1705,26 +1705,6 @@ static int identify_page_state(unsigned
return page_action(ps, p, pfn);
}
-/*
- * When 'release' is 'false', it means that if thp split has failed,
- * there is still more to do, hence the page refcount we took earlier
- * is still needed.
- */
-static int try_to_split_thp_page(struct page *page, unsigned int new_order,
- bool release)
-{
- int ret;
-
- lock_page(page);
- ret = split_huge_page_to_order(page, new_order);
- unlock_page(page);
-
- if (ret && release)
- put_page(page);
-
- return ret;
-}
-
static void unmap_and_kill(struct list_head *to_kill, unsigned long pfn,
struct address_space *mapping, pgoff_t index, int flags)
{
@@ -2509,9 +2489,6 @@ try_again:
folio_unlock(folio);
if (folio_test_large(folio)) {
- const int new_order = min_order_for_split(folio);
- int err;
-
/*
* The flag must be set after the refcount is bumped
* otherwise it may race with THP split.
@@ -2526,24 +2503,25 @@ try_again:
* page is a valid handlable page.
*/
folio_set_has_hwpoisoned(folio);
- err = try_to_split_thp_page(p, new_order, /* release= */ false);
+
+ folio_lock(folio);
+ split_huge_page_to_order(p, min_order_for_split(folio));
+ folio = page_folio(p);
+ folio_unlock(folio);
+
/*
* If splitting a folio to order-0 fails, kill the process.
* Split the folio regardless to minimize unusable pages.
* Because the memory failure code cannot handle large
* folios, this split is always treated as if it failed.
*/
- if (err || new_order) {
- /* get folio again in case the original one is split */
- folio = page_folio(p);
+ if (folio_test_large(folio)) {
res = -EHWPOISON;
kill_procs_now(p, pfn, flags, folio);
- put_page(p);
+ folio_put(folio);
action_result(pfn, MF_MSG_UNSPLIT_THP, MF_FAILED);
goto unlock_mutex;
}
- VM_BUG_ON_PAGE(!page_count(p), p);
- folio = page_folio(p);
}
/*
@@ -2861,25 +2839,26 @@ static int soft_offline_in_use_page(stru
.reason = MR_MEMORY_FAILURE,
};
+ folio_lock(folio);
if (!huge && folio_test_large(folio)) {
- const int new_order = min_order_for_split(folio);
-
/*
- * If new_order (target split order) is not 0, do not split the
- * folio at all to retain the still accessible large folio.
- * NOTE: if minimizing the number of soft offline pages is
- * preferred, split it to non-zero new_order like it is done in
- * memory_failure().
+ * If we cannot split to order-0, do not split the folio at all
+ * to retain the still accessible large folio.
*/
- if (new_order || try_to_split_thp_page(page, /* new_order= */ 0,
- /* release= */ true)) {
+ if (!min_order_for_split(folio))
+ ret = split_huge_page_to_order(page, 0) ? -EBUSY : 0;
+ else
+ ret = -EBUSY;
+ folio = page_folio(page);
+
+ if (ret) {
+ folio_unlock(folio);
+ folio_put(folio);
pr_info("%#lx: thp split failed\n", pfn);
- return -EBUSY;
+ return ret;
}
- folio = page_folio(page);
}
- folio_lock(folio);
if (!huge)
folio_wait_writeback(folio);
if (PageHWPoison(page)) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 544/742] mm/mempolicy: use one node set for interleave weights
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (534 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 543/742] mm/memory-failure: fix folio refcount leak and min_order_for_split() locking Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 545/742] mm/migrate: move NR_FILE_THPS on cross-node migration Greg Kroah-Hartman
` (190 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Andrew Morton, Gregory Price (Meta),
Joshua Hahn, David Hildenbrand, Zi Yan, Rakie Kim, Ying Huang,
Harry Yoo
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Morton <akpm@linux-foundation.org>
commit d7e3ce464470d0ff90b4a0ac87df9b3b7d8258da upstream.
Switching weighted interleave back to automatic mode while memory is being
onlined can cause a kernel divide error on x86, and a panic if
panic_on_oops is set.
reduce_interleave_weights() scans N_MEMORY three times, but hotplug can
cause N_MEMORY to change at runtime - and torn reads on that nodemask can
cause a total sum of zero bandwidth. A node that was hot-unplugged and
then hotplugged back can then cause this loop to generate a div/0.
Record the nodes visited while summing their bandwidth, then use that same
set when scaling and reducing the weights. This gives us a consistent
state even if N_MEMORY changes.
Link: https://lore.kernel.org/20261030161046.1497894-1-gourry@gourry.net
Fixes: e341f9c3c841 ("mm/mempolicy: Weighted Interleave Auto-tuning")
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Ying Huang <ying.huang@linux.alibaba.com>
Cc: Harry Yoo <harry@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/mempolicy.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -187,15 +187,22 @@ static u8 get_il_weight(int node)
*/
static void reduce_interleave_weights(unsigned int *bw, u8 *new_iw)
{
+ nodemask_t nodes = NODE_MASK_NONE;
u64 sum_bw = 0;
unsigned int cast_sum_bw, scaling_factor = 1, iw_gcd = 0;
int nid;
- for_each_node_state(nid, N_MEMORY)
+ /*
+ * N_MEMORY can change while wi_state_lock is held. Remember the
+ * nodes contributing to sum_bw so all passes use the same set.
+ */
+ for_each_node_state(nid, N_MEMORY) {
+ node_set(nid, nodes);
sum_bw += bw[nid];
+ }
/* Scale bandwidths to whole numbers in the range [1, weightiness] */
- for_each_node_state(nid, N_MEMORY) {
+ for_each_node_mask(nid, nodes) {
/*
* Try not to perform 64-bit division.
* If sum_bw < scaling_factor, then sum_bw < U32_MAX.
@@ -214,7 +221,7 @@ static void reduce_interleave_weights(un
}
/* 1:2 is strictly better than 16:32. Reduce by the weights' GCD. */
- for_each_node_state(nid, N_MEMORY)
+ for_each_node_mask(nid, nodes)
new_iw[nid] /= iw_gcd;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 545/742] mm/migrate: move NR_FILE_THPS on cross-node migration
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (535 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 544/742] mm/mempolicy: use one node set for interleave weights Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 546/742] mm/migrate: move NR_KERNEL_FILE_PAGES " Greg Kroah-Hartman
` (189 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ridong Chen, Andrew Morton,
David Hildenbrand (Arm), Zi Yan, Matthew Brost, Joshua Hahn,
Byungchul Park, Gregory Price, Ying Huang, Alistair Popple,
Matthew Wilcox (Oracle), Garg, Shivank
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ridong Chen <chenridong@xiaomi.com>
commit a2108a958143de74b4e5ddca12b01f05ecd030f9 upstream.
When a page cache folio is migrated to another node,
__folio_migrate_mapping() moves the per-node and per-memcg counters
that are keyed off the folio's node: NR_FILE_PAGES, NR_SHMEM,
NR_SHMEM_THPS, NR_SWAPCACHE and NR_FILE_DIRTY. NR_FILE_THPS is not
moved, although __filemap_add_folio() charges it to the source node and
filemap_unaccount_folio() takes it off whatever node the folio lives on
when it is removed.
Commit 0b52c420350e ("mm: fix shmem THP counters on migration") added
the NR_SHMEM_THPS case but not its file-backed counterpart. Now that
ext4, xfs, btrfs and erofs can all have PMD-sized page cache folios,
migrating them via NUMA balancing, mbind(), migratepages, demotion or
memory offlining leaks FileHugePages on the source node and underflows
it on the destination, in both /sys/devices/system/node/nodeN/meminfo
and memory.numa_stat. The global value is unaffected, which is why this
went unnoticed.
Reproducer, on a 2-node QEMU guest with THP set to "always":
1. read a 256M ext4 file through a MADV_HUGEPAGE mapping while bound
to node 0, so its page cache is 128 PMD-sized folios on node 0;
2. move the mapping to node 1 with mbind(MPOL_MF_MOVE);
3. unmap the file and drop its page cache.
nr_file_hugepages in /sys/devices/system/node/nodeN/vmstat after each
step (in units of PMD-sized folios):
without this patch with this patch
node0 node1 node0 node1
1. cached 128 0 128 0
2. migrated 128 0 0 128
3. dropped 128 0 (*) 0 0
(*) the counter has underflowed to -128; negative values read as 0.
Without the patch the 128 folios stay accounted to node 0 forever, and
every further round adds another 128. The same happens to the per-memcg
per-node counter: after step 3, memory.stat of the cgroup shows
"file_thp 0", while memory.numa_stat still shows
"file_thp N0=268435456 N1=0". With the patch both are 0.
Move NR_FILE_THPS together with NR_FILE_PAGES, using the same condition
filemap_unaccount_folio() uses to take it off, so that THPs in the swap
cache are left alone.
Link: https://lore.kernel.org/20261025110209.4105994-1-ridong.chen@linux.dev
Fixes: d68eccad3706 ("mm/filemap: Allow large folios to be added to the page cache")
Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: Ying Huang <ying.huang@linux.alibaba.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: "Garg, Shivank" <shivankg@amd.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/migrate.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -700,6 +700,10 @@ static int __folio_migrate_mapping(struc
mod_lruvec_state(old_lruvec, NR_SHMEM_THPS, -nr);
mod_lruvec_state(new_lruvec, NR_SHMEM_THPS, nr);
}
+ } else if (!folio_test_swapbacked(folio) &&
+ folio_test_pmd_mappable(folio)) {
+ mod_lruvec_state(old_lruvec, NR_FILE_THPS, -nr);
+ mod_lruvec_state(new_lruvec, NR_FILE_THPS, nr);
}
#ifdef CONFIG_SWAP
if (folio_test_swapcache(folio)) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 546/742] mm/migrate: move NR_KERNEL_FILE_PAGES on cross-node migration
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (536 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 545/742] mm/migrate: move NR_FILE_THPS on cross-node migration Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 547/742] mm/rmap: fix PTE table overruns during batched reference checks Greg Kroah-Hartman
` (188 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ridong Chen, Andrew Morton,
Shivank Garg, David Hildenbrand (Arm), Zi Yan, Shakeel Butt,
Matthew Brost, Joshua Hahn, Byungchul Park, Gregory Price,
Ying Huang, Alistair Popple, Boris Burkov
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ridong Chen <chenridong@xiaomi.com>
commit 4ac11db025da54f389796920b253221d1afe6aac upstream.
NR_KERNEL_FILE_PAGES counts page cache folios of mappings flagged
AS_KERNEL_FILE (currently the btrfs btree inode). It is a per-node
counter: filemap_add_folio() adds to folio_pgdat() of the new folio and
filemap_unaccount_folio() subtracts from folio_pgdat() of the folio
being removed.
__folio_migrate_mapping() does not move it when such a folio is
migrated to another node, so the source node keeps the count forever
and the destination node underflows once the folio is freed. btree
folios are migratable through btree_migrate_folio(), so demotion,
DAMON-based migration (DAMOS_MIGRATE_{HOT,COLD}) or memory offlining
all hit this.
Reproducer, on a QEMU guest with two memory tiers (node0 is DRAM with
all CPUs, node1 is a CPU-less slower node described via HMAT) and
/sys/kernel/mm/numa/demotion_enabled set:
1. mount a btrfs and create 20000 empty files, so that btree folios
are cached on node0;
2. echo 2G > /sys/devices/system/node/node0/reclaim, which demotes
them to node1;
3. umount and drop caches.
nr_kernel_file_pages in /sys/devices/system/node/nodeN/vmstat after
each step:
without this patch with this patch
node0 node1 node0 node1
1. cached 1868 0 1868 0
2. demoted 1868 0 36 1832
3. dropped 1832 0 (*) 0 0
(*) the counter has underflowed to -1832; negative values read as 0.
The global value in /proc/vmstat is 0 after step 3 in both cases.
Move it together with the other node-keyed page cache counters. It is
a node-only counter, so use the node accessor, matching how it is
accounted elsewhere. Interrupts are disabled here, as for the zone
counters below.
This was pointed out by Shivank while reviewing the NR_FILE_THPS fix
for the same function.
Link: https://lore.kernel.org/20261027043214.2248986-1-ridong.chen@linux.dev
Fixes: e3a9ac4e866e ("mm: add vmstat for kernel_file pages")
Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Shivank Garg <shivankg@amd.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Shivank Garg <shivankg@amd.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: Gregory Price <gourry@gourry.net>
Cc: Ying Huang <ying.huang@linux.alibaba.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Boris Burkov <boris@bur.io>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/migrate.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -705,6 +705,12 @@ static int __folio_migrate_mapping(struc
mod_lruvec_state(old_lruvec, NR_FILE_THPS, -nr);
mod_lruvec_state(new_lruvec, NR_FILE_THPS, nr);
}
+ if (test_bit(AS_KERNEL_FILE, &mapping->flags)) {
+ __mod_node_page_state(oldzone->zone_pgdat,
+ NR_KERNEL_FILE_PAGES, -nr);
+ __mod_node_page_state(newzone->zone_pgdat,
+ NR_KERNEL_FILE_PAGES, nr);
+ }
#ifdef CONFIG_SWAP
if (folio_test_swapcache(folio)) {
mod_lruvec_state(old_lruvec, NR_SWAPCACHE, -nr);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 547/742] mm/rmap: fix PTE table overruns during batched reference checks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (537 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 546/742] mm/migrate: move NR_KERNEL_FILE_PAGES " Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 548/742] mm/rmap: fix PTE table overruns during batched unmap Greg Kroah-Hartman
` (187 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Chris Mason, Baolin Wang,
David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit 2d9b9352ef885837f246225e9b814a05e9ed2a4a upstream.
With a folded PMD, pmd_addr_end() simply returns the supplied end.
folio_referenced_one() can therefore walk past the PTE table when
checking references to a large folio.
Folded PMDs are uncommon, but can occur even on arm64, for example
with 64K pages and a 42-bit virtual address space.
Use pte_table_clamped_end() to clamp the range to the PTE table and
VMA boundaries.
Fixes: 52e054f71840 ("mm: rmap: support batched checks of the references for large folios")
Cc: stable@vger.kernel.org
Reported-by: Chris Mason <mason@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://patch.msgid.link/20261111-pte_table_clamped_end-v1-3-2dbe339c487a@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/rmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -975,7 +975,7 @@ static bool folio_referenced_one(struct
pteval = ptep_get(pvmw.pte);
if (pvmw.pte && pte_present(pteval) && folio_test_large(folio)) {
- const unsigned long end_addr = pmd_addr_end(address, vma->vm_end);
+ const unsigned long end_addr = pte_table_clamped_end(address, vma->vm_end);
const unsigned int max_nr = (end_addr - address) >> PAGE_SHIFT;
nr = folio_pte_batch(folio, pvmw.pte, pteval, max_nr);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 548/742] mm/rmap: fix PTE table overruns during batched unmap
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (538 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 547/742] mm/rmap: fix PTE table overruns during batched reference checks Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 549/742] mm/shmem: fix swapin livelock on a mismatched large swap cache folio Greg Kroah-Hartman
` (186 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Chris Mason, Baolin Wang,
David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit d8bbf585893c7868234b71d7e7f32484ed0d8458 upstream.
With a folded PMD, pmd_addr_end() simply returns the supplied end.
folio_unmap_pte_batch() can therefore walk past the PTE table when
unmapping a large folio.
Folded PMDs are uncommon, but can occur even on arm64, for example
with 64K pages and a 42-bit virtual address space.
Use pte_table_clamped_end() to clamp the range to the PTE table and
VMA boundaries.
Fixes: 354dffd29575 ("mm: support batched unmap for lazyfree large folios during reclamation")
Cc: stable@vger.kernel.org
Reported-by: Chris Mason <mason@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://patch.msgid.link/20261111-pte_table_clamped_end-v1-2-2dbe339c487a@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/rmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1980,7 +1980,7 @@ static inline unsigned int folio_unmap_p
return 1;
/* We may only batch within a single VMA and a single page table. */
- end_addr = pmd_addr_end(addr, vma->vm_end);
+ end_addr = pte_table_clamped_end(addr, vma->vm_end);
max_nr = (end_addr - addr) >> PAGE_SHIFT;
/* We only support lazyfree or file folios batching for now ... */
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 549/742] mm/shmem: fix swapin livelock on a mismatched large swap cache folio
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (539 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 548/742] mm/rmap: fix PTE table overruns during batched unmap Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 550/742] mm/userfaultfd: fix PTE table overruns in UFFDIO_MOVE Greg Kroah-Hartman
` (185 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Mani Tofigh, Andrew Morton,
Baolin Wang, Hugh Dickins, Kairui Song, Chris Li, Kemeng Shi,
Nhat Pham, Baoquan He, Barry Song, Youngjun Park,
David Hildenbrand, Tal Zussman
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mani Tofigh <mt4022@columbia.edu>
commit fc2c19648d681cc5fb00efa938b78460c2e5b44d upstream.
On a SWP_SYNCHRONOUS_IO swap device, a large shmem folio can be left in
the swap cache over swap slots that another file now uses. Reading that
other file then loops forever in shmem_get_folio_gfp():
shmem_swapin_folio() finds the large folio, rounds the index and the swap
entry down to the folio's size, finds no matching entry in the file and
returns -EEXIST, and the retry finds the same folio again. Since the task
keeps the mapping locked, a munmap() of the same mapping waits forever.
The folio is left behind when the slots are freed and reused while the
swapin is still allocating it:
Task A (reads X) Task B
---------------- ------
shmem_swapin_folio()
allocate a large folio
for X's slots
punch a hole in X
/* X's slots freed */
swap out file Y
/* Y reuses those slots */
add the folio to the swap
cache over those slots
shmem_confirm_swap() fails
/* -EEXIST, the folio stays
in the swap cache */
Task C (reads Y)
----------------
shmem_swapin_folio()
finds the large folio
rounds down to its start,
where Y has no entry
/* -EEXIST, retried forever */
Before commit c246d236b18b ("mm/shmem: never bypass the swap cache for
SWP_SYNCHRONOUS_IO"), a direct swapin that failed this way freed its folio
instead of leaving it in the swap cache.
do_swap_page() already drops a large swap cache folio that does not fit
for anonymous memory. Do the same in shmem_swapin_folio() and on a
-EEXIST, remove a large folio that is not anonymous/dirty/under-writeback
from the swap cache so that the retry swaps in a folio that fits.
The reproducer below fills a small brd swap device so that a 64K shmem
folio and the 4K pages of another file land in the same slots, and races a
read of the first file with a hole punch and a swapout of the second.
This bug was identified and confirmed with the help of a deterministic
hypervisor currently under development, but the non-deterministic C
reproducer can typically trigger it in the 2-4s time range. With the fix,
nothing is triggered after 600 seconds.
Link: https://lore.kernel.org/20261027-shmem-swapin-mismatch-v1-1-84e30aa3b9e5@columbia.edu
Fixes: c246d236b18b ("mm/shmem: never bypass the swap cache for SWP_SYNCHRONOUS_IO")
Signed-off-by: Mani Tofigh <mt4022@columbia.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Kairui Song <kasong@tencent.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Barry Song <baohua@kernel.org>
Cc: Youngjun Park <youngjun.park@lge.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Tal Zussman <tz2294@columbia.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/shmem.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2405,11 +2405,14 @@ static int shmem_swapin_folio(struct ino
* and swap cache folios are never partially freed.
*/
folio_lock(folio);
- if (!folio_matches_swap_entry(folio, swap) ||
- shmem_confirm_swap(mapping, index, swap) < 0) {
+ if (!folio_matches_swap_entry(folio, swap)) {
error = -EEXIST;
goto unlock;
}
+ if (shmem_confirm_swap(mapping, index, swap) < 0) {
+ error = -EEXIST;
+ goto failed;
+ }
if (!folio_test_uptodate(folio)) {
error = -EIO;
goto failed;
@@ -2450,6 +2453,15 @@ failed:
error = -EEXIST;
if (error == -EIO)
shmem_set_folio_swapin_error(inode, index, folio, swap);
+ /*
+ * A large folio that does not fit the mapping, e.g. because its swap
+ * entries were freed and reused, would be found again on every retry.
+ * Drop it from the swap cache so the retry can swap in a fitting one.
+ */
+ if (error == -EEXIST && folio && folio_test_large(folio) &&
+ !folio_test_anon(folio) && !folio_test_dirty(folio) &&
+ !folio_test_writeback(folio))
+ swap_cache_del_folio(folio);
unlock:
if (folio)
folio_unlock(folio);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 550/742] mm/userfaultfd: fix PTE table overruns in UFFDIO_MOVE
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (540 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 549/742] mm/shmem: fix swapin livelock on a mismatched large swap cache folio Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 551/742] mm/vma: undo userfaultfd unmap preparation when unmapping fails Greg Kroah-Hartman
` (184 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Chris Mason, Baolin Wang,
Lokesh Gidra, David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit 169169e26ab498e4a3ee07313e986176f4bc52f0 upstream.
With a folded PMD, pmd_addr_end() simply returns the supplied end.
move_present_ptes() can therefore walk past the source or destination
PTE table during UFFDIO_MOVE.
pmd_addr_end() is only intended for page table traversal, in patterns
like "next = pmd_addr_end(addr, end);". With folded PMDs, a higher level
has already clamped the range to the PTE table.
Folded PMDs are uncommon, but can occur even on arm64, for example
with 64K pages and a 42-bit virtual address space.
Extract the calculation from folio_pte_range() into
pte_table_clamped_end() and use it to clamp both ranges. This preserves
the wraparound handling from commit f681d4580d5c ("mm: fix address
wraparound when scanning large folio PTEs").
Fixes: 50944692052b ("userfaultfd: opportunistic TLB-flush batching for present pages in MOVE")
Cc: stable@vger.kernel.org
Reported-by: Chris Mason <mason@kernel.org>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://patch.msgid.link/20261111-pte_table_clamped_end-v1-1-2dbe339c487a@kernel.org
Reviewed-by: Lokesh Gidra <lokeshgidra@google.com>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/pgtable.h | 24 ++++++++++++++++++++++++
mm/memory.c | 7 +------
mm/userfaultfd.c | 4 ++--
3 files changed, 27 insertions(+), 8 deletions(-)
--- a/include/linux/pgtable.h
+++ b/include/linux/pgtable.h
@@ -12,6 +12,7 @@
#ifdef CONFIG_MMU
#include <linux/mm_types.h>
+#include <linux/minmax.h>
#include <linux/bug.h>
#include <linux/errno.h>
#include <asm-generic/pgtable_uffd.h>
@@ -1518,6 +1519,29 @@ static inline void arch_swap_restore(swp
})
#endif
+/**
+ * pte_table_clamped_end() - Limit a range to a single PTE table.
+ * @addr: Start address.
+ * @end: Exclusive end address.
+ *
+ * Only use pmd_addr_end() when traversing page tables, in a pattern like::
+ *
+ * next = pmd_addr_end(addr, end);
+ *
+ * Higher levels already bound the range when PMDs are folded. Use this
+ * helper elsewhere to clamp the range regardless of PMD folding.
+ *
+ * Return: The exclusive end of the PTE table containing @addr, capped at @end.
+ */
+static inline unsigned long pte_table_clamped_end(unsigned long addr,
+ unsigned long end)
+{
+ const unsigned long pmd_end = (addr & PMD_MASK) + PMD_SIZE;
+
+ /* Compare inclusive ends to avoid wraparounds. */
+ return min(pmd_end - 1, end - 1) + 1;
+}
+
/*
* When walking page tables, we usually want to skip any p?d_none entries;
* and any p?d_bad entries - reporting the error before resetting to none.
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4896,13 +4896,8 @@ static void folio_pte_range(const struct
{
/* Stay within the page table and VMA boundaries. */
const unsigned long pmd_start = addr & PMD_MASK;
- const unsigned long pmd_end = pmd_start + PMD_SIZE;
const unsigned long lower = max(pmd_start, vma->vm_start);
- /*
- * We cannot use pmd_addr_end(), as it does not clamp reliably. To
- * avoid wraparounds, compute using the inclusive end.
- */
- const unsigned long upper = min(pmd_end - 1, vma->vm_end - 1) + 1;
+ const unsigned long upper = pte_table_clamped_end(addr, vma->vm_end);
const unsigned long offset = idx << PAGE_SHIFT;
/*
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -1293,8 +1293,8 @@ static long move_present_ptes(struct mm_
unsigned long src_start = src_addr;
unsigned long src_end;
- len = pmd_addr_end(dst_addr, dst_addr + len) - dst_addr;
- src_end = pmd_addr_end(src_addr, src_addr + len);
+ len = pte_table_clamped_end(dst_addr, dst_addr + len) - dst_addr;
+ src_end = pte_table_clamped_end(src_addr, src_addr + len);
flush_cache_range(src_vma, src_addr, src_end);
double_pt_lock(dst_ptl, src_ptl);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 551/742] mm/vma: undo userfaultfd unmap preparation when unmapping fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (541 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 550/742] mm/userfaultfd: fix PTE table overruns in UFFDIO_MOVE Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 552/742] mm: fix missing page-table destructor in pagetable_free() Greg Kroah-Hartman
` (183 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Mike Rapoport (Microsoft),
Andrew Morton, Noah Weinberger, Tal Zussman, Liam R. Howlett,
Lorenzo Stoakes, David Hildenbrand, Jann Horn, Pedro Falcato,
Peter Xu, Vlastimil Babka
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Rapoport (Microsoft) <rppt@kernel.org>
commit f987d9f38a46216d45326b7a61c619c574b45837 upstream.
vms_gather_munmap_vmas() collects VMAs to unmap and calls
userfaultfd_unmap_prep() for each of these VMAs. This takes a reference
to the userfaultfd context, raises ctx->mmap_changing and queues an
UFFD_EVENT_UNMAP on the caller's list.
If gathering fails half way, e.g. because one of the VMAs is sealed, or
the operation fails after the VMAs were gathered, the original mappings
stay intact but the queued events remain on the list.
Depending on the caller they are either delivered although nothing was
unmapped (munmap(), mremap(), mmap(MAP_FIXED)), or silently dropped
(brk()). In the latter case the userfaultfd context and the mm_struct it
pins are leaked and mmap_changing is never lowered, so UFFDIO_COPY,
UFFDIO_ZEROPAGE and all other ioctls that check mmap_changing fail with
-EAGAIN forever.
With mseal() this is trivially triggered by an unprivileged process.
Collect the events in do_vmi_align_munmap() on a local list and splice
it to the caller's list only when the unmap completes, because mremap()
may already have events for earlier unmaps on that list.
Drop the pending events with a new userfaultfd_unmap_abort() helper when
do_vmi_align_munmap() or __mmap_setup() fail.
Link: https://lore.kernel.org/20261101-uffd-unmap-abort-v1-1-1588d7a7c61a@kernel.org
Fixes: 65ac132027a8 ("userfaultfd: fix regression in userfaultfd_unmap_prep()")
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Noah Weinberger <NoahWeinberger2003@proton.me>
Reviewed-by: Tal Zussman <tz2294@columbia.edu>
Tested-by: Tal Zussman <tz2294@columbia.edu>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/userfaultfd_k.h | 5 +++++
mm/userfaultfd.c | 19 +++++++++++++++++++
mm/vma.c | 28 +++++++++++++++++++++++-----
tools/testing/vma/include/stubs.h | 4 ++++
4 files changed, 51 insertions(+), 5 deletions(-)
--- a/include/linux/userfaultfd_k.h
+++ b/include/linux/userfaultfd_k.h
@@ -278,6 +278,7 @@ extern int userfaultfd_unmap_prep(struct
unsigned long start, unsigned long end, struct list_head *uf);
extern void userfaultfd_unmap_complete(struct mm_struct *mm,
struct list_head *uf);
+void userfaultfd_unmap_abort(struct list_head *uf);
extern bool userfaultfd_wp_unpopulated(struct vm_area_struct *vma);
extern bool userfaultfd_wp_async(struct vm_area_struct *vma);
extern bool userfaultfd_rwp_async(struct vm_area_struct *vma);
@@ -444,6 +445,10 @@ static inline void userfaultfd_unmap_com
{
}
+static inline void userfaultfd_unmap_abort(struct list_head *uf)
+{
+}
+
static inline bool uffd_disable_fault_around(struct vm_area_struct *vma)
{
return false;
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -3320,6 +3320,25 @@ void userfaultfd_unmap_complete(struct m
}
}
+void userfaultfd_unmap_abort(struct list_head *uf)
+{
+ struct userfaultfd_unmap_ctx *unmap_ctx, *n;
+
+ if (!uf)
+ return;
+
+ list_for_each_entry_safe(unmap_ctx, n, uf, list) {
+ struct userfaultfd_ctx *ctx = unmap_ctx->ctx;
+
+ atomic_dec(&ctx->mmap_changing);
+ VM_WARN_ON_ONCE(atomic_read(&ctx->mmap_changing) < 0);
+ userfaultfd_ctx_put(ctx);
+
+ list_del(&unmap_ctx->list);
+ kfree(unmap_ctx);
+ }
+}
+
static int userfaultfd_release(struct inode *inode, struct file *file)
{
struct userfaultfd_ctx *ctx = file->private_data;
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -1698,9 +1698,18 @@ int do_vmi_align_munmap(struct vma_itera
mt_init_flags(&mt_detach, vmi->mas.tree->ma_flags & MT_FLAGS_LOCK_MASK);
mt_on_stack(mt_detach);
struct vma_munmap_struct vms;
+ struct list_head *uf_unmaps;
+ LIST_HEAD(uf_new_unmaps);
int error;
- init_vma_munmap(&vms, vmi, vma, start, end, uf, unlock);
+ /*
+ * @uf may already hold events of earlier successful unmaps, e.g. in
+ * mremap().
+ * Collect new events on a separate list so they can be dropped if this
+ * unmap fails, and splice them into @uf on success.
+ */
+ uf_unmaps = uf ? &uf_new_unmaps : NULL;
+ init_vma_munmap(&vms, vmi, vma, start, end, uf_unmaps, unlock);
error = vms_gather_munmap_vmas(&vms, &mas_detach);
if (error)
goto gather_failed;
@@ -1710,12 +1719,15 @@ int do_vmi_align_munmap(struct vma_itera
goto clear_tree_failed;
/* Point of no return */
+ if (uf)
+ list_splice_tail(&uf_new_unmaps, uf);
vms_complete_munmap_vmas(&vms, &mas_detach);
return 0;
clear_tree_failed:
reattach_vmas(&mas_detach);
gather_failed:
+ userfaultfd_unmap_abort(&uf_new_unmaps);
validate_mm(mm);
return error;
}
@@ -2607,7 +2619,7 @@ static int __mmap_setup(struct mmap_stat
if (error) {
/* On error VMAs will already have been reattached. */
vms->nr_pages = 0;
- return error;
+ goto abort_unmaps;
}
map->next = vms->next;
@@ -2617,8 +2629,10 @@ static int __mmap_setup(struct mmap_stat
}
/* Check against address space limit. */
- if (!may_expand_vm(map->mm, &map->vma_flags, map->pglen - vms->nr_pages))
- return -ENOMEM;
+ if (!may_expand_vm(map->mm, &map->vma_flags, map->pglen - vms->nr_pages)) {
+ error = -ENOMEM;
+ goto abort_unmaps;
+ }
/* Private writable mapping: check memory availability. */
if (accountable_mapping(map)) {
@@ -2628,7 +2642,7 @@ static int __mmap_setup(struct mmap_stat
if (uncharged) {
error = security_vm_enough_memory_mm(map->mm, uncharged);
if (error)
- return error;
+ goto abort_unmaps;
}
/* Our new mapping owns the entire charge now. */
@@ -2647,6 +2661,10 @@ static int __mmap_setup(struct mmap_stat
set_desc_from_map(desc, map);
return 0;
+
+abort_unmaps:
+ userfaultfd_unmap_abort(uf);
+ return error;
}
--- a/tools/testing/vma/include/stubs.h
+++ b/tools/testing/vma/include/stubs.h
@@ -148,6 +148,10 @@ static inline int userfaultfd_unmap_prep
return 0;
}
+static inline void userfaultfd_unmap_abort(struct list_head *uf)
+{
+}
+
static inline void mmap_write_downgrade(struct mm_struct *mm)
{
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 552/742] mm: fix missing page-table destructor in pagetable_free()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (542 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 551/742] mm/vma: undo userfaultfd unmap preparation when unmapping fails Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 553/742] mm: limit pagecache folio refcount when mapping pages Greg Kroah-Hartman
` (182 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Muchun Song, Andrew Morton,
Jose A. Perez de Azpillaga, Kevin Brodsky, Dave Hansen,
David Hildenbrand (Arm), Anshuman Khandual, Oscar Salvador,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Björn Töpel, Catalin Marinas, Will Deacon, Mark Rutland,
Alexander Gordeev, Alistair Popple
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muchun Song <muchun.song@linux.dev>
commit 2a700ab992286e1d3893289909ec46569a725257 upstream.
Patch series "mm: Fix page-table teardown during memory hot-remove", v3.
Memory hot-remove can free page-table pages allocated through paths with
different constructor state. Some paths run the page-table constructor,
while generic sparse-vmemmap population may not. The x86, RISC-V, and
arm64 teardown paths did not handle that distinction consistently,
leaving constructor/destructor accounting unbalanced.
Make pagetable_free() handle any remaining constructor state before
freeing a page-table page. Callers that already ran pagetable_dtor()
have cleared that state, so the destructor is not run twice. The RISC-V
and arm64 fixes then use this common helper for their memory-hot-remove
paths.
The architecture fixes depend on the common MM change in patch 1, so
this remains a single series. I expect it to go through the MM tree,
with review or acks from the relevant architecture maintainers.
This patch (of 4):
Since commit 49f599666420 ("mm: call ctor/dtor for kernel PTEs"),
pte_alloc_one_kernel() runs the page-table constructor for kernel PTE
tables.
HVO (HugeTLB Vmemmap Optimization) uses pte_alloc_one_kernel() when
splitting a PMD. Restoring the vmemmap backing pages does not collapse
the PTE table, so a later memory hot-remove eventually frees it through
pagetable_free() on x86-64. That releases the page without running the
matching destructor and leaves NR_PAGETABLE elevated.
Make pagetable_free() the common free-side primitive for page-table
pages. It checks PageTable() and runs the destructor only when the
constructor state is still present. Callers that explicitly ran
pagetable_dtor() have already cleared PageTable(), so they are not
destructed twice; pages that never ran a constructor are freed directly.
Link: https://lore.kernel.org/20261023063428.3658761-1-songmuchun@bytedance.com
Link: https://lore.kernel.org/20261023063428.3658761-2-songmuchun@bytedance.com
Fixes: 49f599666420 ("mm: call ctor/dtor for kernel PTEs")
Signed-off-by: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
Acked-by: Dave Hansen <dave.hansen@intel.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Björn Töpel <bjorn@rivosinc.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: <stable@vger.kernel.org> # bf9e4e30f353: x86/mm: use pagetable_free()
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/mm.h | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -3816,23 +3816,6 @@ static inline void pagetable_free_kernel
__pagetable_free(pt);
}
#endif
-/**
- * pagetable_free - Free pagetables
- * @pt: The page table descriptor
- *
- * pagetable_free frees the memory of all page tables described by a page
- * table descriptor and the memory for the descriptor itself.
- */
-static inline void pagetable_free(struct ptdesc *pt)
-{
- if (ptdesc_test_kernel(pt)) {
- ptdesc_clear_kernel(pt);
- pagetable_free_kernel(pt);
- } else {
- __pagetable_free(pt);
- }
-}
-
#if defined(CONFIG_SPLIT_PTE_PTLOCKS)
#if ALLOC_SPLIT_PTLOCKS
void __init ptlock_cache_init(void);
@@ -3925,6 +3908,26 @@ static inline void pagetable_dtor(struct
lruvec_stat_sub_folio(folio, NR_PAGETABLE);
}
+/**
+ * pagetable_free - Free pagetables
+ * @pt: The page table descriptor
+ *
+ * pagetable_free frees the memory of all page tables described by a page
+ * table descriptor and the memory for the descriptor itself.
+ */
+static inline void pagetable_free(struct ptdesc *pt)
+{
+ if (PageTable(ptdesc_page(pt)))
+ pagetable_dtor(pt);
+
+ if (ptdesc_test_kernel(pt)) {
+ ptdesc_clear_kernel(pt);
+ pagetable_free_kernel(pt);
+ } else {
+ __pagetable_free(pt);
+ }
+}
+
static inline void pagetable_dtor_free(struct ptdesc *ptdesc)
{
pagetable_dtor(ptdesc);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 553/742] mm: limit pagecache folio refcount when mapping pages
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (543 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 552/742] mm: fix missing page-table destructor in pagetable_free() Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 554/742] mm: limit pagecache folio refcount when splicing into pipes Greg Kroah-Hartman
` (181 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Chris Mason,
Jose A. Perez de Azpillaga, Zi Yan, Pedro Falcato,
David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit 26b8f029ce5224dd5c5f45a4bc964a209c259914 upstream.
With large file folios, overflowing the folio mapcount and refcount
became possible more easily. For anon folios it is currently not really
an issue: each large anon folio can only be mapped once into a process; on
4k kernels it would be more processes than usually allowed on a system,
and on 16k or 64k kernels the processes alone would consume hundreds of
GiB. Something to be sorted out at some point, but it's not as urgent.
Being able to overflow the refcount is not really big news, but it's about
time that we do something about it because some modern technology might
find ways to abuse it :)
One of the enablers for that was commit ddc58f27f9ee ("mm: drop tail page
refcounting"), however, file thp support was added later.
File folios can be mapped multiple times into the same process, allowing
for processes to hold many references to the same folio.
As a short-term solution, let's introduce two folio refcount limits:
one for ordinary consumers and one for admins. Leave some headroom
before the refcount goes negative, which we really don't want (having
the mapcount go negative is also not expected).
Start reporting SIGBUS and a ratelimited warning if we run into limits.
When restoring mappings from migration entries, instead zap the pte/pmd
entry. We allow for slightly exceeding the limit to keep things simpler.
During fork(), prefer not copying page table entries over failing fork.
For fault-around, check in next_uptodate_folio() before trying to lock
the folio.
Export folio_ref_count_over_limit_slowpath() using EXPORT_SYMBOL_GPL
right away so modules can use it through try_get_page(), where we will
use it next.
Use has_capability_noaudit(current, CAP_SYS_RESOURCE),
so filesystem credential overrides do not affect access to the admin
reserve, and to not generate auditing messages simply because we access
optional reserves.
Don't grant access to the admin reserve from kernel threads, from
interrupt context, where "current" is just the interrupted task, or with
IRQs disabled, as even unaudited capability checks can take locks.
This is far from ideal, but better than all easy alternatives we can
backport comfortably. For now it fixes the big problem: letting
the refcount (+mapcount) go negative and cause trouble.
This is only a temporary fix. Keep the mapping checks explicit and
separate from reference acquisition: most are expected to disappear when
we rework the underlying refcounting.
Check order 0 folios as well for consistency: each
folio_add_file_rmap*() and folio_dup_file_rmap*() needs a prior check.
Adjust the check in folio_get() to just check for invalid refcounts and
drop folio_ref_zero_or_close_to_overflow(): we really don't want
negative refcounts or negative mapcounts. Convert to VM_WARN_ON_FOLIO as
we touch it.
Also, just document -EHWPOISON for copy_present_ptes() while at it.
Note: When zapping file migration entries, uffd-wp is preserved using PTE
markers, but uffd-rwp protection is lost because there is no corresponding
marker. try_to_unmap() already has the same problem when unmapping file
folios, so we'll happily ignore it.
Reported-by: Chris Mason <mason@kernel.org>
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Acked-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-1-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/mm.h | 36 ++++++++++++++++++++++++++++++++----
mm/filemap.c | 2 ++
mm/folio.c | 26 ++++++++++++++++++++++++++
mm/huge_memory.c | 32 ++++++++++++++++++++++++++++++--
mm/memory.c | 37 +++++++++++++++++++++++++++++++++----
mm/migrate.c | 11 +++++++++++
mm/userfaultfd.c | 4 ++++
7 files changed, 138 insertions(+), 10 deletions(-)
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2108,9 +2108,37 @@ vm_fault_t finish_fault(struct vm_fault
* back into memory.
*/
-/* 127: arbitrary random number, small enough to assemble well */
-#define folio_ref_zero_or_close_to_overflow(folio) \
- ((unsigned int) folio_ref_count(folio) + 127u <= 127u)
+/* Leave separate reserves for administrators and concurrent reference gains. */
+#define FOLIO_REF_COUNT_LIMIT (INT_MAX - (1U << 26))
+#define FOLIO_REF_COUNT_ADMIN_LIMIT (INT_MAX - (1U << 25))
+
+bool folio_ref_count_over_limit_slowpath(const struct folio *folio,
+ unsigned int ref_count);
+
+/**
+ * folio_ref_count_over_limit - Check whether to refuse more folio references.
+ * @folio: The folio.
+ *
+ * Check before adding page table mappings or other significant refcount users
+ * to pagecache folios (!hugetlb), either before acquiring references or
+ * afterwards with rollback if the operation is refused.
+ *
+ * Checking other folios does no harm.
+ *
+ * This check is an approximation; we leave some headroom such that concurrent
+ * increments, batches, temporary references, or other bounded refcount
+ * consumers are not a problem.
+ *
+ * Return: True if the caller should refuse the operation, false otherwise.
+ */
+static inline bool folio_ref_count_over_limit(const struct folio *folio)
+{
+ const unsigned int ref_count = folio_ref_count(folio);
+
+ if (likely(ref_count < FOLIO_REF_COUNT_LIMIT))
+ return false;
+ return folio_ref_count_over_limit_slowpath(folio, ref_count);
+}
/**
* folio_get - Increment the reference count on a folio.
@@ -2122,7 +2150,7 @@ vm_fault_t finish_fault(struct vm_fault
*/
static inline void folio_get(struct folio *folio)
{
- VM_BUG_ON_FOLIO(folio_ref_zero_or_close_to_overflow(folio), folio);
+ VM_WARN_ON_FOLIO(folio_ref_count(folio) <= 0, folio);
folio_ref_inc(folio);
}
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3756,6 +3756,8 @@ static struct folio *next_uptodate_folio
continue;
if (!folio_try_get(folio))
continue;
+ if (unlikely(folio_ref_count_over_limit(folio)))
+ goto skip;
if (folio_test_locked(folio))
goto skip;
/* Has the page moved or been split? */
--- a/mm/folio.c
+++ b/mm/folio.c
@@ -107,6 +107,32 @@ void __folio_put(struct folio *folio)
}
EXPORT_SYMBOL(__folio_put);
+bool folio_ref_count_over_limit_slowpath(const struct folio *folio,
+ unsigned int ref_count)
+{
+ if (ref_count >= FOLIO_REF_COUNT_ADMIN_LIMIT)
+ goto over_limit;
+ /* Background threads must not consume admin reserves. */
+ if (current->flags & PF_KTHREAD)
+ goto over_limit;
+ /* Neither must interrupt contexts on behalf of the interrupted task. */
+ if (!in_task())
+ goto over_limit;
+ /* Capability checks are not safe with IRQs disabled. */
+ if (irqs_disabled())
+ goto over_limit;
+ /* Use the task's credentials, which filesystem overrides cannot change. */
+ if (has_capability_noaudit(current, CAP_SYS_RESOURCE))
+ return false;
+
+over_limit:
+ pr_warn_ratelimited("folio:%p refcount:%d mapcount:%d mapping:%p index:%#lx reached refcount limit\n",
+ folio, (int)ref_count, folio_mapcount(folio),
+ folio_mapping(folio), folio->index);
+ return true;
+}
+EXPORT_SYMBOL_GPL(folio_ref_count_over_limit_slowpath);
+
typedef void (*move_fn_t)(struct lruvec *lruvec, struct folio *folio);
static void lru_add(struct lruvec *lruvec, struct folio *folio)
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1630,6 +1630,7 @@ static vm_fault_t insert_pmd(struct vm_a
{
struct mm_struct *mm = vma->vm_mm;
pgtable_t pgtable = NULL;
+ vm_fault_t ret = VM_FAULT_NOPAGE;
spinlock_t *ptl;
pmd_t entry;
@@ -1666,6 +1667,10 @@ static vm_fault_t insert_pmd(struct vm_a
if (is_huge_zero_folio(fop.folio)) {
entry = pmd_mkspecial(entry);
} else {
+ if (unlikely(folio_ref_count_over_limit(fop.folio))) {
+ ret = VM_FAULT_SIGBUS;
+ goto out_unlock;
+ }
folio_get(fop.folio);
folio_add_file_rmap_pmd(fop.folio, &fop.folio->page, vma);
add_mm_counter(mm, mm_counter_file(fop.folio), HPAGE_PMD_NR);
@@ -1692,7 +1697,7 @@ out_unlock:
spin_unlock(ptl);
if (pgtable)
pte_free(mm, pgtable);
- return VM_FAULT_NOPAGE;
+ return ret;
}
/**
@@ -1760,6 +1765,7 @@ static vm_fault_t insert_pud(struct vm_a
pud_t *pud, struct folio_or_pfn fop, pgprot_t prot, bool write)
{
struct mm_struct *mm = vma->vm_mm;
+ vm_fault_t ret = VM_FAULT_NOPAGE;
spinlock_t *ptl;
pud_t entry;
@@ -1785,6 +1791,10 @@ static vm_fault_t insert_pud(struct vm_a
if (fop.is_folio) {
entry = folio_mk_pud(fop.folio, vma->vm_page_prot);
+ if (unlikely(folio_ref_count_over_limit(fop.folio))) {
+ ret = VM_FAULT_SIGBUS;
+ goto out_unlock;
+ }
folio_get(fop.folio);
folio_add_file_rmap_pud(fop.folio, &fop.folio->page, vma);
add_mm_counter(mm, mm_counter_file(fop.folio), HPAGE_PUD_NR);
@@ -1800,7 +1810,7 @@ static vm_fault_t insert_pud(struct vm_a
update_mmu_cache_pud(vma, addr, pud);
out_unlock:
spin_unlock(ptl);
- return VM_FAULT_NOPAGE;
+ return ret;
}
/**
@@ -2096,6 +2106,14 @@ int copy_huge_pud(struct vm_area_struct
if (page) {
struct folio *folio = page_folio(page);
+ if (unlikely(folio_ref_count_over_limit(folio))) {
+ /*
+ * VM_MIXEDMAP may contain driver-inserted pages with no
+ * fault handler to reconstruct the mapping.
+ */
+ ret = (dst_vma->vm_flags & VM_MIXEDMAP) ? -ENOMEM : 0;
+ goto out_unlock;
+ }
folio_get(folio);
/*
* TODO: once we support anonymous pages, use
@@ -5238,6 +5256,16 @@ void remove_migration_pmd(struct page_vm
if (!(pvmw->pmd && !pvmw->pte))
return;
+ if (!folio_test_anon(folio) && unlikely(folio_ref_count_over_limit(folio))) {
+ /* Leave the file mapping absent so it can be faulted in. */
+ pmd_clear(pvmw->pmd);
+ if (arch_needs_pgtable_deposit())
+ zap_deposited_table(mm, pvmw->pmd);
+ update_hiwater_rss(mm);
+ add_mm_counter(mm, mm_counter_file(folio), -HPAGE_PMD_NR);
+ return;
+ }
+
entry = softleaf_from_pmd(*pvmw->pmd);
folio_get(folio);
pmde = folio_mk_pmd(folio, READ_ONCE(vma->vm_page_prot));
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1205,7 +1205,10 @@ static __always_inline void __copy_prese
* consecutive pages of the same folio by copying them as well.
*
* Returns -EAGAIN if one preallocated page is required to copy the next PTE.
- * Otherwise, returns the number of copied PTEs (at least 1).
+ * Returns -ENOMEM if the file folio refcount is too high and the PTE must
+ * be copied.
+ * Returns -EHWPOISON if copying a page fails.
+ * Otherwise, returns the number of processed PTEs (at least 1).
*/
static inline int
copy_present_ptes(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma,
@@ -1223,6 +1226,20 @@ copy_present_ptes(struct vm_area_struct
folio = page_folio(page);
+ if (!folio_test_anon(folio) && unlikely(folio_ref_count_over_limit(folio))) {
+ /*
+ * VM_MIXEDMAP may contain pages inserted by a driver at mmap
+ * time, with no fault handler to restore a missing PTE.
+ */
+ if (dst_vma->vm_flags & VM_MIXEDMAP)
+ return -ENOMEM;
+ if (userfaultfd_pte_rwp(dst_vma, pte))
+ return -ENOMEM;
+ /* Preserve uffd-wp protection when faulting the page back in. */
+ cond_install_uffd_wp_ptes(dst_vma, addr, dst_pte, pte, 1);
+ return 1;
+ }
+
/*
* If we likely have to copy, just don't bother with batching. Make
* sure that the common "small folio" case is as fast as possible
@@ -1404,9 +1421,9 @@ again:
/*
* If we need a pre-allocated page for this pte, drop the
* locks, allocate, and try again.
- * If copy failed due to hwpoison in source page, break out.
+ * Other errors abort the copy after releasing the page table locks.
*/
- if (unlikely(ret == -EAGAIN || ret == -EHWPOISON))
+ if (unlikely(ret < 0))
break;
if (unlikely(prealloc)) {
/*
@@ -1436,7 +1453,7 @@ again:
goto out;
}
entry.val = 0;
- } else if (ret == -EBUSY || unlikely(ret == -EHWPOISON)) {
+ } else if (ret == -EBUSY || ret == -ENOMEM || unlikely(ret == -EHWPOISON)) {
goto out;
} else if (ret == -EAGAIN) {
prealloc = folio_prealloc(src_mm, src_vma, addr, false);
@@ -2510,6 +2527,8 @@ static int insert_page_into_pte_locked(s
if (unlikely(is_zero_folio(folio))) {
pteval = pte_mkspecial(pteval);
} else {
+ if (unlikely(folio_ref_count_over_limit(folio)))
+ return -EOVERFLOW;
folio_get(folio);
pteval = mk_pte(page, prot);
if (mkwrite) {
@@ -5678,6 +5697,9 @@ vm_fault_t do_set_pmd(struct vm_fault *v
if (unlikely(folio_test_has_hwpoisoned(folio)))
return ret;
+ if (unlikely(folio_ref_count_over_limit(folio)))
+ return VM_FAULT_SIGBUS;
+
/*
* Archs like ppc64 need additional space to store information
* related to pte entry. Use the preallocated table for that.
@@ -5732,6 +5754,9 @@ vm_fault_t do_set_pmd(struct vm_fault *v
* @page: The first page to create a PTE for.
* @nr: The number of PTEs to create.
* @addr: The first address to create a PTE for.
+ *
+ * For file mappings, the caller must check folio_ref_count_over_limit()
+ * before installing PTEs.
*/
void set_pte_range(struct vm_fault *vmf, struct folio *folio,
struct page *page, unsigned int nr, unsigned long addr)
@@ -5898,6 +5923,10 @@ fallback:
goto fallback;
}
+ if (!is_cow && unlikely(folio_ref_count_over_limit(folio))) {
+ ret = VM_FAULT_SIGBUS;
+ goto unlock;
+ }
folio_ref_add(folio, nr_pages - 1);
set_pte_range(vmf, folio, page, nr_pages, addr);
type = is_cow ? MM_ANONPAGES : mm_counter_file(folio);
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -385,6 +385,17 @@ static bool remove_migration_pte(struct
try_to_map_unused_to_zeropage(&pvmw, folio, old_pte, idx))
continue;
+ if (!folio_test_anon(folio) && !folio_test_hugetlb(folio) &&
+ unlikely(folio_ref_count_over_limit(folio))) {
+ /* File contents remain available for a later fault. */
+ pte_clear(vma->vm_mm, pvmw.address, pvmw.pte);
+ cond_install_uffd_wp_ptes(vma, pvmw.address,
+ pvmw.pte, old_pte, 1);
+ update_hiwater_rss(vma->vm_mm);
+ dec_mm_counter(vma->vm_mm, mm_counter_file(folio));
+ continue;
+ }
+
folio_get(folio);
new = folio_page(folio, idx);
pte = mk_pte(new, READ_ONCE(vma->vm_page_prot));
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -400,6 +400,10 @@ static int mfill_atomic_install_pte(pmd_
goto out_unlock;
if (page_in_cache) {
+ if (unlikely(folio_ref_count_over_limit(folio))) {
+ ret = -ENOMEM;
+ goto out_unlock;
+ }
folio_add_file_rmap_pte(folio, page, dst_vma);
} else {
folio_add_new_anon_rmap(folio, dst_vma, dst_addr, RMAP_EXCLUSIVE);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 554/742] mm: limit pagecache folio refcount when splicing into pipes
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (544 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 553/742] mm: limit pagecache folio refcount when mapping pages Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:06 ` [PATCH 7.3 555/742] mm/gup: limit pagecache folio refcount when grabbing references Greg Kroah-Hartman
` (180 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jose A. Perez de Azpillaga,
Pedro Falcato, David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit c6c9a4c1c9a1669693330205cb9d86fafd3cf235 upstream.
Similar to mapping pagecache folios into page tables, let's reject
additional references when splicing folios into a pipe if the refcount
is at its limit.
This will prevent more cases of possible folio refcount overflows with
large pagecache folios.
Introduce folio_get_checked() for checked reference acquisition when
the caller already holds a reference. It warns and fails on a non-positive
refcount and rejects additional references at the limit.
Add __folio_ref_count_over_limit() so folio_get_checked() can reuse the
refcount instead of having to read it a second time.
Use folio_get_checked() in splice_folio_into_pipe() and
fuse_ref_folio(), returning -EFAULT on failure, like we already do for
pipe-buffer duplication. Similarly, make try_get_page() use it instead.
Likely try_get_page() should be renamed (or removed) later, as it doesn't
match the folio_try_get() semantics and is confusing.
If we hit the limit after splicing some data, return the number of bytes
already spliced. Teach the callers to handle errors, and stop
filemap_splice_read() if we only spliced part of a folio, so we don't
skip ahead to the next folio: note that we wouldn't run into this
scenario before as we always spliced the requested range.
The check in try_get_page() also covers pipe-buffer duplication by tee()
and partial pipe-to-pipe splicing.
Note that we deliberately will not fall back to the slow path of copying
the folio, particularly as the folio might have an invalid refcount. If
it is ever really required, we can revisit.
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-2-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/fuse/dev.c | 4 +++-
include/linux/mm.h | 49 +++++++++++++++++++++++++++++++++++++++++--------
mm/filemap.c | 26 ++++++++++++++++----------
mm/internal.h | 4 ++--
mm/shmem.c | 7 +++++--
5 files changed, 67 insertions(+), 23 deletions(-)
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1230,7 +1230,9 @@ static int fuse_ref_folio(struct fuse_co
if (cs->nr_segs >= cs->pipe->max_usage)
return -EIO;
- folio_get(folio);
+ if (!folio_get_checked(folio))
+ return -EFAULT;
+
err = unlock_request(cs->req);
if (err) {
folio_put(folio);
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2116,8 +2116,9 @@ bool folio_ref_count_over_limit_slowpath
unsigned int ref_count);
/**
- * folio_ref_count_over_limit - Check whether to refuse more folio references.
+ * __folio_ref_count_over_limit - Check whether to refuse more folio references.
* @folio: The folio.
+ * @ref_count: The sampled folio reference count.
*
* Check before adding page table mappings or other significant refcount users
* to pagecache folios (!hugetlb), either before acquiring references or
@@ -2131,16 +2132,28 @@ bool folio_ref_count_over_limit_slowpath
*
* Return: True if the caller should refuse the operation, false otherwise.
*/
-static inline bool folio_ref_count_over_limit(const struct folio *folio)
+static inline bool __folio_ref_count_over_limit(const struct folio *folio,
+ unsigned int ref_count)
{
- const unsigned int ref_count = folio_ref_count(folio);
-
if (likely(ref_count < FOLIO_REF_COUNT_LIMIT))
return false;
return folio_ref_count_over_limit_slowpath(folio, ref_count);
}
/**
+ * folio_ref_count_over_limit - Check whether to refuse more folio references.
+ * @folio: The folio.
+ *
+ * See __folio_ref_count_over_limit().
+ *
+ * Return: True if the caller should refuse the operation, false otherwise.
+ */
+static inline bool folio_ref_count_over_limit(const struct folio *folio)
+{
+ return __folio_ref_count_over_limit(folio, folio_ref_count(folio));
+}
+
+/**
* folio_get - Increment the reference count on a folio.
* @folio: The folio.
*
@@ -2164,15 +2177,35 @@ static inline void get_page(struct page
folio_get(folio);
}
-static inline __must_check bool try_get_page(struct page *page)
+/**
+ * folio_get_checked - Try to acquire a reference to a live folio.
+ * @folio: The folio.
+ *
+ * The caller must already hold a reference to @folio. Warn and fail on a
+ * non-positive refcount, and refuse additional references at the limit.
+ *
+ * Use folio_try_get() for speculative reference acquisition where the
+ * refcount can legitimately be zero.
+ *
+ * Return: True if the refcount was incremented, false otherwise.
+ */
+static inline __must_check bool folio_get_checked(struct folio *folio)
{
- page = compound_head(page);
- if (WARN_ON_ONCE(page_ref_count(page) <= 0))
+ const int ref_count = folio_ref_count(folio);
+
+ if (WARN_ON_ONCE(ref_count <= 0))
+ return false;
+ if (unlikely(__folio_ref_count_over_limit(folio, ref_count)))
return false;
- page_ref_inc(page);
+ folio_ref_inc(folio);
return true;
}
+static inline __must_check bool try_get_page(struct page *page)
+{
+ return folio_get_checked(page_folio(page));
+}
+
/**
* folio_put - Decrement the reference count on a folio.
* @folio: The folio.
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3029,10 +3029,11 @@ generic_file_read_iter(struct kiocb *ioc
EXPORT_SYMBOL(generic_file_read_iter);
/*
- * Splice subpages from a folio into a pipe.
+ * Splice subpages from a folio into a pipe. Return the number of bytes spliced,
+ * or -EFAULT if we cannot splice from the folio.
*/
-size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
- struct folio *folio, loff_t fpos, size_t size)
+ssize_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
+ struct folio *folio, loff_t fpos, size_t size)
{
struct page *page;
size_t spliced = 0, offset = offset_in_folio(folio, fpos);
@@ -3045,13 +3046,15 @@ size_t splice_folio_into_pipe(struct pip
struct pipe_buffer *buf = pipe_head_buf(pipe);
size_t part = min_t(size_t, PAGE_SIZE - offset, size - spliced);
+ if (!folio_get_checked(folio))
+ return spliced ? spliced : -EFAULT;
+
*buf = (struct pipe_buffer) {
.ops = &page_cache_pipe_buf_ops,
.page = page,
.offset = offset,
.len = part,
};
- folio_get(folio);
pipe->head++;
page++;
spliced += part;
@@ -3076,9 +3079,10 @@ size_t splice_folio_into_pipe(struct pip
* Return: On success, the number of bytes read will be returned and *@ppos
* will be updated if appropriate; 0 will be returned if there is no more data
* to be read; -EAGAIN will be returned if the pipe had no space, and some
- * other negative error code will be returned on error. A short read may occur
- * if the pipe has insufficient space, we reach the end of the data or we hit a
- * hole.
+ * other negative error code will be returned on error; -EFAULT will be returned
+ * if acquiring a folio reference fails and no data has been spliced.
+ * A short read may occur if the pipe has insufficient space, we reach the
+ * end of the data, hit a hole or hit a folio refcount limit.
*/
ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
struct pipe_inode_info *pipe,
@@ -3136,7 +3140,7 @@ ssize_t filemap_splice_read(struct file
for (i = 0; i < folio_batch_count(&fbatch); i++) {
struct folio *folio = fbatch.folios[i];
- size_t n;
+ ssize_t n;
if (folio_pos(folio) >= end_offset)
goto out;
@@ -3152,13 +3156,15 @@ ssize_t filemap_splice_read(struct file
n = min_t(loff_t, len, isize - *ppos);
n = splice_folio_into_pipe(pipe, folio, *ppos, n);
- if (!n)
+ if (n <= 0) {
+ error = n;
goto out;
+ }
len -= n;
total_spliced += n;
*ppos += n;
in->f_ra.prev_pos = *ppos;
- if (pipe_is_full(pipe))
+ if (pipe_is_full(pipe) || *ppos < folio_next_pos(folio))
goto out;
}
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1278,8 +1278,8 @@ struct migration_target_control {
/*
* mm/filemap.c
*/
-size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
- struct folio *folio, loff_t fpos, size_t size);
+ssize_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
+ struct folio *folio, loff_t fpos, size_t size);
static inline bool vma_is_single_threaded_private(struct vm_area_struct *vma)
{
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3552,7 +3552,8 @@ static ssize_t shmem_file_splice_read(st
struct inode *inode = file_inode(in);
struct address_space *mapping = inode->i_mapping;
struct folio *folio = NULL;
- size_t total_spliced = 0, used, npages, n, part;
+ size_t total_spliced = 0, used, npages, part;
+ ssize_t n;
loff_t isize;
int error = 0;
@@ -3638,8 +3639,10 @@ static ssize_t shmem_file_splice_read(st
n = splice_zeropage_into_pipe(pipe, *ppos, part);
}
- if (!n)
+ if (n <= 0) {
+ error = n;
break;
+ }
len -= n;
total_spliced += n;
*ppos += n;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 555/742] mm/gup: limit pagecache folio refcount when grabbing references
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (545 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 554/742] mm: limit pagecache folio refcount when splicing into pipes Greg Kroah-Hartman
@ 2026-12-04 10:06 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 556/742] mm/mmu_gather: flush pending references early before the folio limit Greg Kroah-Hartman
` (179 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:06 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jose A. Perez de Azpillaga,
Pedro Falcato, David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit 2d9bcd380585abc436f055fbb618b34f98882004 upstream.
Let's add __folio_ref_count_over_limit() checks in fast and slow GUP
before acquiring additional references or pins.
Keep it simple and use the check for all folio types.
Also propagate try_grab_folio() errors when grabbing additional
references in __get_user_pages() and in memfd_pin_folios(), so hitting
the limit returns -ENOMEM instead of -EFAULT and -EINVAL, respectively.
Keep the existing invalid-refcount warnings.
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-5-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/mm.h | 11 +++++------
mm/gup.c | 32 +++++++++++++++++++++-----------
2 files changed, 26 insertions(+), 17 deletions(-)
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2124,6 +2124,9 @@ bool folio_ref_count_over_limit_slowpath
* to pagecache folios (!hugetlb), either before acquiring references or
* afterwards with rollback if the operation is refused.
*
+ * Also required when pinning folios without a dedicated pincount that use
+ * GUP_PIN_COUNTING_BIAS.
+ *
* Checking other folios does no harm.
*
* This check is an approximation; we leave some headroom such that concurrent
@@ -2834,12 +2837,8 @@ static inline bool folio_maybe_dma_pinne
return atomic_read(&folio->_pincount) > 0;
/*
- * folio_ref_count() is signed. If that refcount overflows, then
- * folio_ref_count() returns a negative value, and callers will avoid
- * further incrementing the refcount.
- *
- * Here, for that overflow case, use the sign bit to count a little
- * bit higher via unsigned math, and thus still get an accurate result.
+ * Use unsigned math so even an unexpected negative refcount is
+ * treated as possibly pinned.
*/
return ((unsigned int)folio_ref_count(folio)) >=
GUP_PIN_COUNTING_BIAS;
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -74,10 +74,14 @@ static inline void sanity_check_pinned_p
static inline struct folio *try_get_folio(struct page *page, int refs)
{
struct folio *folio;
+ int ref_count;
retry:
folio = page_folio(page);
- if (WARN_ON_ONCE(folio_ref_count(folio) < 0))
+ ref_count = folio_ref_count(folio);
+ if (WARN_ON_ONCE(ref_count < 0))
+ return NULL;
+ if (unlikely(__folio_ref_count_over_limit(folio, ref_count)))
return NULL;
if (unlikely(!folio_ref_try_add(folio, refs)))
return NULL;
@@ -140,7 +144,13 @@ static void gup_put_folio(struct folio *
int __must_check try_grab_folio(struct folio *folio, int refs,
unsigned int flags)
{
- if (WARN_ON_ONCE(folio_ref_count(folio) <= 0))
+ const int ref_count = folio_ref_count(folio);
+
+ if (WARN_ON_ONCE(ref_count <= 0))
+ return -ENOMEM;
+
+ if ((flags & (FOLL_GET | FOLL_PIN)) &&
+ unlikely(__folio_ref_count_over_limit(folio, ref_count)))
return -ENOMEM;
if (unlikely(!(flags & FOLL_PCI_P2PDMA) && folio_is_pci_p2pdma(folio)))
@@ -1482,17 +1492,17 @@ next_page:
struct folio *folio = page_folio(page);
/*
- * Since we already hold refcount on the
- * large folio, this should never fail.
+ * Grabbing more references can fail once we
+ * hit folio refcount limits.
*/
- if (try_grab_folio(folio, page_increm - 1,
- gup_flags)) {
+ ret = try_grab_folio(folio, page_increm - 1,
+ gup_flags);
+ if (ret) {
/*
- * Release the 1st page ref if the
- * folio is problematic, fail hard.
+ * Release the folio reference we
+ * already took.
*/
gup_put_folio(folio, 1, gup_flags);
- ret = -EFAULT;
goto out;
}
}
@@ -3524,10 +3534,10 @@ long memfd_pin_folios(struct file *memfd
break;
}
- if (try_grab_folio(folio, 1, FOLL_PIN)) {
+ ret = try_grab_folio(folio, 1, FOLL_PIN);
+ if (ret) {
folio_unlock(folio);
folio_batch_release(&fbatch);
- ret = -EINVAL;
goto err;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 556/742] mm/mmu_gather: flush pending references early before the folio limit
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (546 preceding siblings ...)
2026-12-04 10:06 ` [PATCH 7.3 555/742] mm/gup: limit pagecache folio refcount when grabbing references Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 557/742] PPC32: Fix hard_irq_disable to follow tracing and lockdep state Greg Kroah-Hartman
` (178 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Chris Mason,
Jose A. Perez de Azpillaga, Lance Yang, Pedro Falcato,
David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <david@kernel.org>
commit 317bd7d28b248fd4d4e14614d7c30b17a36ef4d7 upstream.
When a task zaps mappings (e.g., MADV_DONTNEED), it can drop the PT lock
and defer dropping the folio references. In the meantime, page faults
can refault pagecache folios, creating more references for the same
folios. These deferred references can build up over multiple VMAs.
Let's just request a flush after enqueueing folios whose refcount reached
a certain threshold. Start flushing well before new references are refused,
regardless of the caller's privileges.
When returning "true" from __tlb_remove_folio_pages_size(), PTE zapping
will flush the TLB before dropping the PT lock, but drop the references
afterwards. Refaults can still race with that, but flushing early reduces
the risk of letting others hit the limit.
This is a temporary measure until we have something better.
Reported-by: Chris Mason <mason@kernel.org>
Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
Cc: stable@vger.kernel.org
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Lance Yang <lance.yang@linux.dev>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Link: https://patch.msgid.link/20261112-refcount_overflow_stable-v4-3-ad3deef0bd23@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/asm-generic/tlb.h | 4 ++--
include/linux/mm.h | 1 +
mm/memory.c | 4 ++--
mm/mmu_gather.c | 10 ++++++----
4 files changed, 11 insertions(+), 8 deletions(-)
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -78,8 +78,8 @@
* - __tlb_remove_folio_pages_size()
*
* __tlb_remove_folio_pages_size() is the basic primitive that queues pages
- * for freeing. It will return a boolean indicating if the queue is (now)
- * full and a call to tlb_flush_mmu() is required.
+ * for freeing. It returns true when a call to tlb_flush_mmu() is required,
+ * either because the queue is full or a folio is near its refcount limit.
*
* tlb_remove_page() and tlb_remove_page_size() imply the call to
* tlb_flush_mmu() when required and has no return value.
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2111,6 +2111,7 @@ vm_fault_t finish_fault(struct vm_fault
/* Leave separate reserves for administrators and concurrent reference gains. */
#define FOLIO_REF_COUNT_LIMIT (INT_MAX - (1U << 26))
#define FOLIO_REF_COUNT_ADMIN_LIMIT (INT_MAX - (1U << 25))
+#define FOLIO_REF_COUNT_FLUSH_LIMIT (INT_MAX - (1U << 27))
bool folio_ref_count_over_limit_slowpath(const struct folio *folio,
unsigned int ref_count);
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2113,8 +2113,8 @@ retry:
pte_unmap_unlock(start_pte, ptl);
/*
- * If we forced a TLB flush (either due to running out of
- * batch buffers or because we needed to flush dirty TLB
+ * If we forced a TLB flush (either to release batched
+ * references or because we needed to flush dirty TLB
* entries before releasing the ptl), free the batched
* memory too. Come back again if we didn't do everything.
*/
--- a/mm/mmu_gather.c
+++ b/mm/mmu_gather.c
@@ -179,10 +179,7 @@ static bool __tlb_remove_folio_pages_siz
#endif
batch = tlb->active;
- /*
- * Add the page and check if we are full. If so
- * force a flush.
- */
+ /* Add the pages before deciding whether we need to flush. */
if (likely(nr_pages == 1)) {
batch->encoded_pages[batch->nr++] = encode_page(page, flags);
} else {
@@ -190,6 +187,11 @@ static bool __tlb_remove_folio_pages_siz
batch->encoded_pages[batch->nr++] = encode_page(page, flags);
batch->encoded_pages[batch->nr++] = encode_nr_pages(nr_pages);
}
+ /* Flush pending references well before new references are refused. */
+ if (unlikely((unsigned int)folio_ref_count(page_folio(page)) >=
+ FOLIO_REF_COUNT_FLUSH_LIMIT))
+ return true;
+
/*
* Make sure that we can always add another "page" + "nr_pages",
* requiring two entries instead of only a single one.
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 557/742] PPC32: Fix hard_irq_disable to follow tracing and lockdep state
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (547 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 556/742] mm/mmu_gather: flush pending references early before the folio limit Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 558/742] qca_spi: Avoid unsequenced accesses to jiffies in qcaspi_netdev_tx_timeout() Greg Kroah-Hartman
` (177 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ritesh Harjani (IBM),
Shrikanth Hegde, Mukesh Kumar Chaurasiya (IBM),
Madhavan Srinivasan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shrikanth Hegde <sshegde@linux.ibm.com>
commit 2672bdcc7857073722c4772831a24b14832ee88a upstream.
On PPC32, the code for hard_irq_disable has diverged and it doesn't
do lockdep/tracing anymore, leading to use of both local_irq_disable
and hard_irq_disable on PPC32 to overcome those.
That is un-necessary, instead simply calling local_irq_disable is
enough. It disables EE bit and does lockdep tracking.
Subsequent patch uses this API in KVM code to avoid the warnings.
Wider use of it is possible, but it will be taken subsequently.
Cc: stable@vger.kernel.org # v7.2+
Suggested-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261118051419.783878-2-sshegde@linux.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/include/asm/hw_irq.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -464,7 +464,7 @@ static inline bool arch_irqs_disabled(vo
return arch_irqs_disabled_flags(arch_local_save_flags());
}
-#define hard_irq_disable() arch_local_irq_disable()
+#define hard_irq_disable() local_irq_disable()
static inline bool regs_irqs_disabled(struct pt_regs *regs)
{
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 558/742] qca_spi: Avoid unsequenced accesses to jiffies in qcaspi_netdev_tx_timeout()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (548 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 557/742] PPC32: Fix hard_irq_disable to follow tracing and lockdep state Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 559/742] rcu/nocb: Avoid unsequenced accesses to jiffies in show_rcu_nocb_state() Greg Kroah-Hartman
` (176 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Nathan Chancellor, Stefan Wahren,
Nick Desaulniers, Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <nathan@kernel.org>
commit 695d0824cb6b27ff1a1cdeabb2d5138f00b15251 upstream.
After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appears in
qcaspi_netdev_tx_timeout(), which can break the build with
CONFIG_WERROR=y / W=e:
drivers/net/ethernet/qualcomm/qca_spi.c:805:16: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced]
805 | jiffies, jiffies - dev_trans_start(dev));
| ~~~~~~~ ^
Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.2.2.10/12, the evaluation of arguments in a
function call is indeterminately sequenced, meaning any side effects in
the arguments are unsequenced.
Printing jiffies on its own is not that useful for debugging transmit
timeouts, so get rid of it to clear up the warning.
Cc: stable@vger.kernel.org
Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2197
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://patch.msgid.link/20261115-qca_spi-wunsequenced-v2-1-8cf32f12d546@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/qualcomm/qca_spi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -801,8 +801,8 @@ qcaspi_netdev_tx_timeout(struct net_devi
{
struct qcaspi *qca = netdev_priv(dev);
- netdev_info(qca->net_dev, "Transmit timeout at %ld, latency %ld\n",
- jiffies, jiffies - dev_trans_start(dev));
+ netdev_info(qca->net_dev, "Transmit timeout, latency %ld\n",
+ jiffies - dev_trans_start(dev));
qca->net_dev->stats.tx_errors++;
/* Trigger tx queue flush and QCA7000 reset */
set_bit(SPI_RESET, &qca->flags);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 559/742] rcu/nocb: Avoid unsequenced accesses to jiffies in show_rcu_nocb_state()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (549 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 558/742] qca_spi: Avoid unsequenced accesses to jiffies in qcaspi_netdev_tx_timeout() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 560/742] RDMA/ionic: Use a linear QID space when udma_shift is zero Greg Kroah-Hartman
` (175 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Nathan Chancellor, Joel Fernandes
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <nathan@kernel.org>
commit c3f98ff6309a29979e1867bc3c9d4172755ca122 upstream.
After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appears in show_rcu_nocb_state(),
which can break the build with CONFIG_WERROR=y / W=e:
In file included from kernel/rcu/tree.c:5123:
kernel/rcu/tree_nocb.h:1651:3: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced]
1650 | jiffies - rdp->nocb_bypass_first,
| ~~~~~~~
1651 | jiffies - rdp->nocb_nobypass_last,
| ^
Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.2.2.10/12, the evaluation of arguments in a
function call is indeterminately sequenced, meaning any side effects in
the arguments are unsequenced.
Add a local variable to hold the value of jiffies before the function
call so that there are no unsequenced side effects, clearing up the
warning.
Cc: stable@vger.kernel.org
Fixes: f7a81b12d6af ("rcu/nocb: Print no-CBs diagnostics when rcutorture writer unduly delayed")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2192
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Joel Fernandes <jfern@kernel.org>
Signed-off-by: Joel Fernandes <jfern@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/rcu/tree_nocb.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/kernel/rcu/tree_nocb.h
+++ b/kernel/rcu/tree_nocb.h
@@ -1618,6 +1618,7 @@ static void show_rcu_nocb_state(struct r
struct rcu_segcblist *rsclp = &rdp->cblist;
bool waslocked;
bool wassleep;
+ unsigned long j;
if (rdp->nocb_gp_rdp == rdp)
show_rcu_nocb_gp_state(rdp);
@@ -1639,6 +1640,7 @@ static void show_rcu_nocb_state(struct r
rsclp->gp_seq[RCU_NEXT_READY_TAIL].exp);
sprintf(bufn, "%ld", rsclp->seglen[RCU_NEXT_TAIL]);
sprintf(bufb, "%ld", rcu_cblist_n_cbs(&rdp->nocb_bypass));
+ j = jiffies;
pr_info(" CB %d^%d->%d %c%c%c%c%c F%ld L%ld C%d %c%s%c%s%c%s%c%s%c%s q%ld %c CPU %d%s\n",
rdp->cpu, rdp->nocb_gp_rdp->cpu,
nocb_next_rdp ? nocb_next_rdp->cpu : -1,
@@ -1647,8 +1649,8 @@ static void show_rcu_nocb_state(struct r
"lL"[raw_spin_is_locked(&rdp->nocb_lock)],
"sS"[!!rdp->nocb_cb_sleep],
".W"[swait_active(&rdp->nocb_cb_wq)],
- jiffies - rdp->nocb_bypass_first,
- jiffies - rdp->nocb_nobypass_last,
+ j - rdp->nocb_bypass_first,
+ j - rdp->nocb_nobypass_last,
rdp->nocb_nobypass_count,
".D"[rcu_segcblist_ready_cbs(rsclp)],
rcu_segcblist_segempty(rsclp, RCU_DONE_TAIL) ? "" : bufd,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 560/742] RDMA/ionic: Use a linear QID space when udma_shift is zero
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (550 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 559/742] rcu/nocb: Avoid unsequenced accesses to jiffies in show_rcu_nocb_state() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 561/742] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G Greg Kroah-Hartman
` (174 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Keith Lucas, Abhijit Gangurde,
Leon Romanovsky
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhijit Gangurde <abhijit.gangurde@amd.com>
commit 687a1e161457b267963f8334fd143896515cec25 upstream.
Firmware reports udma_shift as the log2 of the number of queues in
a queue group. A value of zero means the queues are not striped
across two UDMAs, so the QID space is linear and the device has one UDMA.
The interleaved bitid/qid transform treats bit 0 as the UDMA selector
when the group shift is zero. QID 1 then becomes bitid
1 << half_qid_shift, and freeing that QID releases the wrong allocator
index. Skip the transform and select one UDMA so QP and CQ allocation
uses the QID directly.
Fixes: e8521822c733 ("RDMA/ionic: Register device ops for control path")
Reported-by: Keith Lucas <keith.lucas@oracle.com>
Link: https://lore.kernel.org/r/20261021161651.4020222-1-haakon.bugge@oracle.com
Cc: stable@vger.kernel.org # 6.18
Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com>
Link: https://patch.msgid.link/20261030082402.841751-1-abhijit.gangurde@amd.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/infiniband/hw/ionic/ionic_lif_cfg.c | 2 +-
drivers/infiniband/hw/ionic/ionic_res.h | 23 ++++++++++++++++-------
2 files changed, 17 insertions(+), 8 deletions(-)
--- a/drivers/infiniband/hw/ionic/ionic_lif_cfg.c
+++ b/drivers/infiniband/hw/ionic/ionic_lif_cfg.c
@@ -83,7 +83,7 @@ void ionic_fill_lif_cfg(struct ionic_lif
cfg->cq_qtype = ident->rdma.cq_qtype.qtype;
cfg->eq_qtype = ident->rdma.eq_qtype.qtype;
cfg->udma_qgrp_shift = ident->rdma.udma_shift;
- cfg->udma_count = 2;
+ cfg->udma_count = cfg->udma_qgrp_shift ? 2 : 1;
cfg->max_stride = ident->rdma.max_stride;
cfg->expdb_mask = ionic_get_expdb(lif);
--- a/drivers/infiniband/hw/ionic/ionic_res.h
+++ b/drivers/infiniband/hw/ionic/ionic_res.h
@@ -125,10 +125,14 @@ static inline void ionic_resid_put(struc
static inline u32 ionic_bitid_to_qid(u32 bitid, u8 qgrp_shift,
u8 half_qid_shift)
{
- u32 udma_bit =
- (bitid & BIT(half_qid_shift)) >> (half_qid_shift - qgrp_shift);
- u32 grp_bits = (bitid & GENMASK(half_qid_shift - 1, qgrp_shift)) << 1;
- u32 idx_bits = bitid & (BIT(qgrp_shift) - 1);
+ u32 udma_bit, grp_bits, idx_bits;
+
+ if (!qgrp_shift)
+ return bitid;
+
+ udma_bit = (bitid & BIT(half_qid_shift)) >> (half_qid_shift - qgrp_shift);
+ grp_bits = (bitid & GENMASK(half_qid_shift - 1, qgrp_shift)) << 1;
+ idx_bits = bitid & (BIT(qgrp_shift) - 1);
return grp_bits | udma_bit | idx_bits;
}
@@ -145,9 +149,14 @@ static inline u32 ionic_bitid_to_qid(u32
*/
static inline u32 ionic_qid_to_bitid(u32 qid, u8 qgrp_shift, u8 half_qid_shift)
{
- u32 udma_bit = (qid & BIT(qgrp_shift)) << (half_qid_shift - qgrp_shift);
- u32 grp_bits = (qid & GENMASK(half_qid_shift, qgrp_shift + 1)) >> 1;
- u32 idx_bits = qid & (BIT(qgrp_shift) - 1);
+ u32 udma_bit, grp_bits, idx_bits;
+
+ if (!qgrp_shift)
+ return qid;
+
+ udma_bit = (qid & BIT(qgrp_shift)) << (half_qid_shift - qgrp_shift);
+ grp_bits = (qid & GENMASK(half_qid_shift, qgrp_shift + 1)) >> 1;
+ idx_bits = qid & (BIT(qgrp_shift) - 1);
return udma_bit | grp_bits | idx_bits;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 561/742] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (551 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 560/742] RDMA/ionic: Use a linear QID space when udma_shift is zero Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 562/742] RDMA/mlx5: Skip vport context query on FW without ib_virt support Greg Kroah-Hartman
` (173 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dezhen Lu, Jason Gunthorpe,
Leon Romanovsky
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
commit b5c11bf9759834731440806708143c40638dc2ff upstream.
devx_umem_find_best_pgsize() computes the page size in an unsigned long
but returns it as unsigned int, and devx_umem_reg_cmd_alloc() stores it
in an unsigned int. When the DMA mapping of the umem is contiguous and
aligned to 4 GiB or more, and the umem length is a multiple of that
size, ib_umem_find_best_pgoff() selects a page size >= 2^32. Since the
value is a power of two, the truncation turns it into 0 and the
registration fails with -EINVAL.
The umem log_page_size field is 5 bits wide on top of
MLX5_ADAPTER_PAGE_SHIFT, so the command can encode these page sizes.
Seen on two GH200 nodes (ConnectX-7, firmware 32.38.3056 and
32.43.1014) with a dma-buf exported from cudaMalloc memory: registering
4 GiB or 8 GiB umems at 4 GiB-aligned offsets of the dma-buf fails with
EINVAL every time, while 2 GiB umems at the same offsets and
ibv_reg_dmabuf_mr() of the same ranges succeed. Restricting the user
pgsz_bitmap to <= 2 GiB makes all of them succeed.
Other large physically contiguous buffers, such as a 16 GiB hugetlb
page on an arm64 kernel with 64K base pages, should hit the same path.
Use unsigned long for the page size, as commit f0c2427412b4
("RDMA/mlx5: Fix page_size variable overflow") already did for the MR
paths.
The bug was found by an AI coding assistant (Claude Opus 5.5, Anthropic)
during an audit of 32-bit truncations of page sizes and offsets in
drivers/infiniband/core and drivers/infiniband/hw/mlx5. The assistant
also wrote the reproducer and this patch. The reproducer was run on the
GH200 nodes described above.
Fixes: 7610ab57de56 ("RDMA/mlx5: Allow larger pages in DevX umem")
Cc: stable@vger.kernel.org
Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
Link: https://patch.msgid.link/20261103142804.67210-1-dezhen.lu@student.uni-tuebingen.de
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/infiniband/hw/mlx5/devx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/infiniband/hw/mlx5/devx.c
+++ b/drivers/infiniband/hw/mlx5/devx.c
@@ -2294,8 +2294,8 @@ static int devx_umem_get(struct mlx5_ib_
return 0;
}
-static unsigned int devx_umem_find_best_pgsize(struct ib_umem *umem,
- unsigned long pgsz_bitmap)
+static unsigned long devx_umem_find_best_pgsize(struct ib_umem *umem,
+ unsigned long pgsz_bitmap)
{
unsigned long page_size;
@@ -2333,7 +2333,7 @@ static int devx_umem_reg_cmd_alloc(struc
int access)
{
unsigned long pgsz_bitmap;
- unsigned int page_size;
+ unsigned long page_size;
__be64 *mtt;
void *umem;
int ret;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 562/742] RDMA/mlx5: Skip vport context query on FW without ib_virt support
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (552 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 561/742] RDMA/mlx5: Fix DevX umem page size truncation for pages >= 4G Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 563/742] RDMA/rtrs: Register client event handler after capability check Greg Kroah-Hartman
` (172 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tony Battersby, Moshe Shemesh,
Edward Srouji, Leon Romanovsky
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Moshe Shemesh <moshe@nvidia.com>
commit e7732ec135b501e87ab060d992b3b5f2ec4396c9 upstream.
Since commit b02289b3d60f ("RDMA: Validate grh_required when handling
AVs"), mlx5_port_immutable() unconditionally issues
QUERY_HCA_VPORT_CONTEXT on InfiniBand ports to read grh_required.
Devices that do not support the InfiniBand virtualization interface
(ib_virt cleared) are not guaranteed to implement this command. For
example, Connect-IB with FW 10.10.5020 rejects it and mlx5_ib fails to
probe:
mlx5_core 0000:01:00.0: mlx5_cmd_out_err:810:(pid 731): QUERY_HCA_VPORT_CONTEXT(0x762) op_mod(0x0) failed, status bad operation(0x2), syndrome (0x3590f5), err(-22)
infiniband mlx5_0: Couldn't create per-port data
mlx5_ib.rdma: probe of mlx5_core.rdma.0 failed with error -12
All other HCA vport context users in mlx5_ib are already gated on
ib_virt, either directly, as in set_has_smi_cap(),
mlx5_ib_get_plane_num() and mlx5_ib_modify_port(), or via
mlx5_use_mad_ifc(), which selects MAD_IFC for port queries when
ib_virt is not supported.
Skipping the query loses nothing. grh_required indicates a GID-based
vport, which only exists with InfiniBand virtualization. Without
ib_virt the port is always LID-based and the field is zero, even on
firmware that accepts the command. This also matches the behavior
before b02289b3d60f, when grh_required was filled in only by
mlx5_query_hca_port() and was never set on the MAD_IFC path.
Fixes: b02289b3d60f ("RDMA: Validate grh_required when handling AVs")
Cc: stable@vger.kernel.org
Reported-by: Tony Battersby <tonyb@cybernetics.com>
Closes: https://lore.kernel.org/all/064dfa67-8fd4-40f0-b925-6d1e0cd42e6a@cybernetics.com/
Tested-by: Tony Battersby <tonyb@cybernetics.com>
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Edward Srouji <edwards@nvidia.com>
Link: https://patch.msgid.link/20261112-moshe-ib-virt-guard-v1-1-6d2caf8bdb1b@nvidia.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/infiniband/hw/mlx5/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -3617,7 +3617,8 @@ static int mlx5_port_immutable(struct ib
if (err)
return err;
- if (ll == IB_LINK_LAYER_INFINIBAND) {
+ if (ll == IB_LINK_LAYER_INFINIBAND &&
+ MLX5_CAP_GEN(dev->mdev, ib_virt)) {
if (ibdev->type == RDMA_DEVICE_TYPE_SMI)
port_num = smi_to_native_portnum(dev, port_num);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 563/742] RDMA/rtrs: Register client event handler after capability check
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (553 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 562/742] RDMA/mlx5: Skip vport context query on FW without ib_virt support Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 564/742] RDMA/siw: Fix use-after-free in siw_mem_id2obj() Greg Kroah-Hartman
` (171 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jaeyeong Lee, Jack Wang,
Leon Romanovsky
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaeyeong Lee <lee@jaeyeong.cc>
commit 90d95fbc1bcc8464f6d8c6891c62bad4c0dc2d58 upstream.
rtrs_clt_ib_dev_init() registers dev->event_handler before checking
IB_DEVICE_MEM_MGT_EXTENSIONS. If the device does not provide that
capability, init returns -ENOTSUPP and rtrs_ib_dev_find_or_add() frees
dev through out_free_pd without calling the deinit callback. The embedded
event handler therefore remains on the IB device's list after its storage
has been freed.
A later IB event walks the dangling list entry and accesses freed memory.
The issue was found by static analysis. A focused out-of-tree test module
on an x86_64 QEMU/KASAN kernel temporarily cleared only
IB_DEVICE_MEM_MGT_EXTENSIONS on a SIW device, exercised the real
rtrs_clt_ib_dev_init() callback through rtrs_ib_dev_find_or_add(), restored
the capabilities, and dispatched IB_EVENT_DEVICE_FATAL. KASAN reported
an 8-byte slab-use-after-free read in ib_dispatch_event_clients(), with
both the allocation and free originating in rtrs_ib_dev_find_or_add().
Move the capability check before event handler registration. The check is
a prerequisite for successful client initialization. Registration cannot
fail and init returns success immediately afterwards, so every installed
handler is now owned by a successfully initialized device and is removed
by the existing deinit callback.
Fixes: 667db86bcbe8 ("RDMA/rtrs: Register ib event handler")
Cc: stable@vger.kernel.org
Signed-off-by: Jaeyeong Lee <lee@jaeyeong.cc>
Link: https://patch.msgid.link/179378222423.73361.3247716499619173751@jaeyeong.cc
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -3186,16 +3186,16 @@ void rtrs_clt_ib_event_handler(struct ib
static int rtrs_clt_ib_dev_init(struct rtrs_ib_dev *dev)
{
- INIT_IB_EVENT_HANDLER(&dev->event_handler, dev->ib_dev,
- rtrs_clt_ib_event_handler);
- ib_register_event_handler(&dev->event_handler);
-
if (!(dev->ib_dev->attrs.device_cap_flags &
IB_DEVICE_MEM_MGT_EXTENSIONS)) {
pr_err("Memory registrations not supported.\n");
return -ENOTSUPP;
}
+ INIT_IB_EVENT_HANDLER(&dev->event_handler, dev->ib_dev,
+ rtrs_clt_ib_event_handler);
+ ib_register_event_handler(&dev->event_handler);
+
return 0;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 564/742] RDMA/siw: Fix use-after-free in siw_mem_id2obj()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (554 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 563/742] RDMA/rtrs: Register client event handler after capability check Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 565/742] RDMA/srpt: bound the indirect descriptor table to the IU Greg Kroah-Hartman
` (170 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Deep Shah, Leon Romanovsky
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deep Shah <deepshah146@gmail.com>
commit a70672b9b3ac7d8945f67cd199c1bb680d5d5f64 upstream.
siw_mem_id2obj() finds a siw_mem with xa_load() under rcu_read_lock()
and then takes a reference with kref_get_unless_zero(). This is only
safe if the object stays allocated until RCU readers are done with it.
siw_free_mem() frees it with kfree() as soon as the last reference is
dropped, so a lookup that races with the final put reads freed memory.
This happens when an MR is deregistered while an incoming RDMA WRITE
looks up its STag:
BUG: KASAN: slab-use-after-free in siw_mem_id2obj+0xe5/0x310
Read of size 4 at addr ff110001042aed88 by task repro-rcu2/90
Call Trace:
<IRQ>
siw_mem_id2obj+0xe5/0x310
siw_proc_write+0x282/0x430
siw_tcp_rx_data+0x12e/0xbf0
__tcp_read_sock+0x12c/0x440
siw_qp_llp_data_ready+0x147/0x260
Allocated by task 89:
siw_mr_add_mem+0xb2/0x2a0
siw_reg_user_mr+0x19f/0x380
ib_uverbs_reg_mr+0x2a7/0x4c0
Freed by task 89:
kfree+0x301/0x530
siw_dereg_mr+0x31/0x50
ib_dereg_mr_user+0xb9/0x200
Free siw_mem with kfree_rcu(). A lookup that loses the race then sees
a zero refcount and fails. The umem or PBL is still released at the
last put, since a failed lookup never touches it.
Fixes: 2251334dcac9 ("rdma/siw: application buffer management")
Cc: stable@vger.kernel.org
Signed-off-by: Deep Shah <deepshah146@gmail.com>
Link: https://patch.msgid.link/20261102064437.23976-1-deepshah146@gmail.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/infiniband/sw/siw/siw.h | 1 +
drivers/infiniband/sw/siw/siw_mem.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
--- a/drivers/infiniband/sw/siw/siw.h
+++ b/drivers/infiniband/sw/siw/siw.h
@@ -157,6 +157,7 @@ struct siw_mem {
void *mem_obj;
};
struct ib_pd *pd;
+ struct rcu_head rcu;
};
struct siw_mr {
--- a/drivers/infiniband/sw/siw/siw_mem.c
+++ b/drivers/infiniband/sw/siw/siw_mem.c
@@ -115,7 +115,7 @@ void siw_free_mem(struct kref *ref)
else
kfree(mem->pbl);
}
- kfree(mem);
+ kfree_rcu(mem, rcu);
}
/*
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 565/742] RDMA/srpt: bound the indirect descriptor table to the IU
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (555 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 564/742] RDMA/siw: Fix use-after-free in siw_mem_id2obj() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 566/742] RDMA/srpt: reject zero-length buffer descriptors Greg Kroah-Hartman
` (169 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Yehyeong Lee, Bart Van Assche,
Leon Romanovsky
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
commit 82d46dedf750addfad5480f79165cacb81c89650 upstream.
srpt_get_desc_tbl() takes the number of INDIRECT descriptors from
idb->table_desc.len, which the initiator controls, and checks it only
against data_out_desc_cnt + data_in_desc_cnt, two more initiator fields.
Both are u8, so the pair admits up to 510 descriptors, and nothing
compares the table against the receive IU it has to live in.
srpt_alloc_rw_ctxs() then walks idb->desc_list for that many entries.
With the default srp_max_req_size of 8276 the table fits as long as the
additional CDB is short, but ADDITIONAL CDB LENGTH is an initiator field
too, and at its maximum of 252 bytes 510 descriptors end at
48 + 252 + 20 + 510 * 16 = 8480, which is past the end of the object.
BUG: KASAN: slab-out-of-bounds in srpt_alloc_rw_ctxs+0x631/0x870
Read of size 4 at addr ffff888002d6a05c by task kunit_try_catch/43
CPU: 0 UID: 0 PID: 43 Comm: kunit_try_catch Tainted: G N 7.3.0-12378-g6fba331225f5-dirty #1 PREEMPT(lazy)
Tainted: [N]=TEST
Call Trace:
<TASK>
dump_stack_lvl+0x3f/0x50
print_report+0xcd/0x620
? alloc_pages_node_noprof+0xa2/0x140
? srpt_alloc_rw_ctxs+0x631/0x870
kasan_report+0xde/0x110
? srpt_alloc_rw_ctxs+0x631/0x870
srpt_alloc_rw_ctxs+0x631/0x870
srpt_test_parse+0x114/0x580
? __pfx_srpt_test_ctx_common.constprop.0+0x10/0x10
? __pfx_srpt_test_parse+0x10/0x10
? srpt_test_ctx_init.constprop.0+0x4cb/0x6c0
srpt_test_run.constprop.0+0xc1/0xa60
? pick_task_fair+0x126/0x1950
? __pfx_srpt_test_run.constprop.0+0x10/0x10
? update_curr.constprop.0+0x4a/0x390
? __set_cpus_allowed_ptr+0x181/0x240
? __pfx_read_tsc+0x10/0x10
? ktime_get_ts64+0x192/0x250
kunit_try_run_case+0x1ca/0x4b0
? __pfx_kunit_try_run_case+0x10/0x10
? kthread_affine_node+0x24b/0x370
? __pfx_kthread_affine_node+0x10/0x10
? __pfx_kunit_try_run_case+0x10/0x10
? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
kunit_generic_run_threadfn_adapter+0x7b/0xe0
kthread+0x36e/0x500
? __pfx_kthread+0x10/0x10
ret_from_fork+0x34d/0x620
? __pfx_ret_from_fork+0x10/0x10
? __switch_to+0x22/0xdd0
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x19/0x30
</TASK>
Allocated by task 43:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_slab_alloc+0x6e/0x70
kmem_cache_alloc_noprof+0xfc/0x2b0
srpt_test_ctx_common.constprop.0+0x46f/0x9b0
srpt_test_ctx_init.constprop.0+0x30/0x6c0
srpt_test_run.constprop.0+0xb6/0xa60
kunit_try_run_case+0x1ca/0x4b0
kunit_generic_run_threadfn_adapter+0x7b/0xe0
kthread+0x36e/0x500
ret_from_fork+0x34d/0x620
ret_from_fork_asm+0x19/0x30
The buggy address belongs to the object at ffff888002d68000
which belongs to the cache srpt-kunit-iu of size 8276
The buggy address is located 8 bytes to the right of
allocated 8276-byte region [ffff888002d68000, ffff888002d6a054)
The KUnit harness that forces this is not part of this patch.
A table_desc.len below one descriptor is the other way in. It gives nbufs
zero, which the count check admits and a span check cannot catch either,
since an empty table fits in any IU. srpt_alloc_rw_ctxs() then returns
success with n_rw_ctx zero, no scatterlist is chained, and
srpt_write_pending() reaches ib_post_send() with an empty work request
list. rvt_post_send() evaluates !wr->next before the loop that tests wr
against NULL, so an rdmavt device faults there whenever its send queue is
idle.
Reject a table that does not fit by comparing the span it occupies
against byte_len, and reject an empty one. The span is the table offset
plus struct_size(idb, desc_list, nbufs), and nbufs is at most 510 once
the existing count check has passed, so it cannot saturate.
The header always lies inside the allocated buffer, since the largest
offset srpt_get_desc_buf() can return is 48 + 252 and the header is 20
bytes, so it ends at 320 while srp_max_req_size is at least
MIN_MAX_REQ_SIZE, which is 996. It does not always lie inside the bytes
the initiator actually sent, which is why the span starts at the table
offset and covers the header as well.
Fixes: a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
Cc: stable@vger.kernel.org
Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
Link: https://patch.msgid.link/20261025013748.3755639-2-yhlee@isslab.korea.ac.kr
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/infiniband/ulp/srpt/ib_srpt.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -1117,6 +1117,7 @@ static int srpt_get_desc_tbl(struct srpt
struct srp_indirect_buf *idb = srpt_get_desc_buf(srp_cmd);
int nbufs = be32_to_cpu(idb->table_desc.len) /
sizeof(struct srp_direct_buf);
+ size_t desc_off = (uintptr_t)idb - (uintptr_t)srp_cmd;
if (nbufs >
(srp_cmd->data_out_desc_cnt + srp_cmd->data_in_desc_cnt)) {
@@ -1128,6 +1129,18 @@ static int srpt_get_desc_tbl(struct srpt
return -EINVAL;
}
+ if (nbufs == 0) {
+ pr_err("received SRP_CMD with an empty indirect descriptor table\n");
+ return -EINVAL;
+ }
+
+ if (desc_off + struct_size(idb, desc_list, nbufs) >
+ recv_ioctx->byte_len) {
+ pr_err("received SRP_CMD indirect table (%d descriptors) that does not fit the %d-byte IU\n",
+ nbufs, recv_ioctx->byte_len);
+ return -EINVAL;
+ }
+
*data_len = be32_to_cpu(idb->len);
return srpt_alloc_rw_ctxs(ioctx, idb->desc_list, nbufs,
sg, sg_cnt);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 566/742] RDMA/srpt: reject zero-length buffer descriptors
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (556 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 565/742] RDMA/srpt: bound the indirect descriptor table to the IU Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 567/742] RDMA/srpt: widen the indirect RDMA context counters Greg Kroah-Hartman
` (168 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Yehyeong Lee, Bart Van Assche,
Leon Romanovsky
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
commit 252fc17ff4fbc2c6ead5e2f9404c9d0c490f0965 upstream.
srpt_alloc_rw_ctxs() takes each buffer descriptor length straight from the
wire and hands it to target_alloc_sgl(), which has no length check of its
own.
For the single descriptor of a DIRECT request, and for the last descriptor
of an INDIRECT table, chainable is false, so a zero length makes
sgl_alloc_order() compute nalloc zero. kmalloc_objs() answers that with
ZERO_SIZE_PTR, which is not NULL, so the allocation looks like it
succeeded and sg_init_table(sgl, 0) runs. That reaches sg_init_marker(),
which does sg_mark_end(&sgl[nents - 1]) with nents unsigned, so the index
is 4294967295 rather than minus one and the read modify write of page_link
lands far outside any allocation.
Oops: general protection fault, probably for non-canonical address 0xdffffc03fffffffe: 0000 [#1] KASAN PTI
KASAN: probably user-memory-access in range [0x0000001ffffffff0-0x0000001ffffffff7]
CPU: 0 UID: 0 PID: 43 Comm: kunit_try_catch Tainted: G N 7.3.0-12378-g6fba331225f5-dirty #1 PREEMPT(lazy)
Tainted: [N]=TEST
RIP: 0010:sgl_alloc_order+0xb6/0x370
Code: ef 01 4c 89 e2 49 89 c4 31 f6 49 c1 e7 05 48 89 c7 e8 ae e0 cb ff 4d 01 e7 48 b8 00 00 00 00 00 fc ff df 4c 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 6b 02 00 00 49 bc 00 00 00 00 00 fc ff df 49 8b
RSP: 0000:ffff888002d4fa38 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000001000 RCX: 0000000000000000
RDX: 00000003fffffffe RSI: 0000000000000000 RDI: 0000000000000010
RBP: 0000000000000000 R08: ffff888002b158a0 R09: 0000000000000000
R10: 0000000000000010 R11: 0000000000000037 R12: 0000000000000010
R13: ffff888002d6803c R14: 0000000000000000 R15: 0000001ffffffff0
FS: 0000000000000000(0000) GS:0000000000000000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffff88802f1c8000 CR3: 000000002e458000 CR4: 00000000000006f0
Call Trace:
<TASK>
target_alloc_sgl+0x2b/0x70
srpt_alloc_rw_ctxs+0x2ef/0x870
srpt_test_parse+0x114/0x580
? __pfx_srpt_test_parse+0x10/0x10
? srpt_test_ctx_init_direct+0x17d/0x280
srpt_direct_len0_test+0xa4/0x280
? __pfx_srpt_direct_len0_test+0x10/0x10
? __set_cpus_allowed_ptr+0x181/0x240
? __pfx_read_tsc+0x10/0x10
? ktime_get_ts64+0x192/0x250
kunit_try_run_case+0x1ca/0x4b0
? __pfx_kunit_try_run_case+0x10/0x10
? kthread_affine_node+0x24b/0x370
? __pfx_kthread_affine_node+0x10/0x10
? __pfx_kunit_try_run_case+0x10/0x10
? __pfx_kunit_generic_run_threadfn_adapter+0x10/0x10
kunit_generic_run_threadfn_adapter+0x7b/0xe0
kthread+0x36e/0x500
? __pfx_kthread+0x10/0x10
ret_from_fork+0x34d/0x620
? __pfx_ret_from_fork+0x10/0x10
? __switch_to+0x22/0xdd0
? __pfx_kthread+0x10/0x10
ret_from_fork_asm+0x19/0x30
</TASK>
The KUnit harness that forces this is not part of this patch.
A zero length descriptor elsewhere in a table is chainable, so one entry
is allocated and that write does not happen, but the entry count comes
back zero and the mapping in rdma_rw_ctx_init() then refuses it.
The target core never hands the same allocator a zero length. Its own call
in transport_generic_new_cmd() sits behind a cmd->data_length test.
Reject a descriptor whose length is zero. The existing unwind label covers
the first iteration, where its loop body does not run because nothing has
been allocated yet.
Fixes: b99f8e4d7bcd ("IB/srpt: convert to the generic RDMA READ/WRITE API")
Cc: stable@vger.kernel.org
Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
Link: https://patch.msgid.link/20261025013748.3755639-3-yhlee@isslab.korea.ac.kr
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/infiniband/ulp/srpt/ib_srpt.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -979,6 +979,12 @@ static int srpt_alloc_rw_ctxs(struct srp
u32 size = be32_to_cpu(db->len);
u32 rkey = be32_to_cpu(db->key);
+ if (size == 0) {
+ pr_err("received SRP_CMD buffer descriptor with zero length\n");
+ ret = -EINVAL;
+ goto unwind;
+ }
+
ret = target_alloc_sgl(&ctx->sg, &ctx->nents, size, false,
i < nbufs - 1);
if (ret)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 567/742] RDMA/srpt: widen the indirect RDMA context counters
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (557 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 566/742] RDMA/srpt: reject zero-length buffer descriptors Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 568/742] perf record: Reject CPU indices equal to the mask size Greg Kroah-Hartman
` (167 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Bart Van Assche, Yehyeong Lee,
Leon Romanovsky
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
commit 013eb66a8ef25ef531bf41d79815948ab4938571 upstream.
srpt_send_ioctx::n_rdma and ::n_rw_ctx are u8, and neither of the values
stored in them is bounded by 255.
n_rw_ctx counts the INDIRECT descriptors a command carries, and the count
guard in srpt_get_desc_tbl() admits data_out_desc_cnt plus
data_in_desc_cnt, so up to 510. At 256 descriptors n_rw_ctx wraps to
zero, and srpt_release_cmd() frees the contexts only when it is non-zero,
so every scatterlist and RDMA context the command allocated leaks.
n_rdma is not a descriptor count at all. It is the sum of the
rdma_rw_ctx_init() return values, which is the number of work requests
each context needs, accumulated by ioctx->n_rdma += ret. A handful of
descriptors for large transfers can pass 255 on their own, with no
unusual descriptor count involved. A wrapped n_rdma is then handed to
atomic_sub_return(ioctx->n_rdma, &ch->sq_wr_avail) and tested by
WARN_ON(ioctx->n_rdma <= 0), so the send queue work request accounting
drifts too.
Make both counters int, the type the values they accumulate already have.
Fixes: b99f8e4d7bcd ("IB/srpt: convert to the generic RDMA READ/WRITE API")
Cc: stable@vger.kernel.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
Link: https://patch.msgid.link/20261025013748.3755639-4-yhlee@isslab.korea.ac.kr
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/infiniband/ulp/srpt/ib_srpt.c | 2 +-
drivers/infiniband/ulp/srpt/ib_srpt.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -959,7 +959,7 @@ static int srpt_alloc_rw_ctxs(struct srp
struct srpt_rdma_ch *ch = ioctx->ch;
struct scatterlist *prev = NULL;
unsigned prev_nents;
- u8 n_rdma, n_rw_ctx;
+ int n_rdma, n_rw_ctx;
int ret, i;
if (nbufs == 1) {
--- a/drivers/infiniband/ulp/srpt/ib_srpt.h
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.h
@@ -223,8 +223,8 @@ struct srpt_send_ioctx {
struct ib_cqe rdma_cqe;
enum srpt_command_state state;
struct se_cmd cmd;
- u8 n_rdma;
- u8 n_rw_ctx;
+ int n_rdma;
+ int n_rw_ctx;
bool queue_status_only;
u8 sense_data[TRANSPORT_SENSE_BUFFER];
};
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 568/742] perf record: Reject CPU indices equal to the mask size
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (558 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 567/742] RDMA/srpt: widen the indirect RDMA context counters Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 569/742] powerpc/eeh: NUL-terminate force recovery input Greg Kroah-Hartman
` (166 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Paul Moses, Namhyung Kim,
Adrian Hunter, Alexander Shishkin, Athira Rajeev, Ian Rogers,
Ingo Molnar, James Clark, Jiri Olsa, Mark Rutland, Peter Zijlstra,
Arnaldo Carvalho de Melo
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moses <p@1g4.org>
commit 82b4a28e758816365405e01d9ed09027d13ef77a upstream.
record__mmap_cpu_mask_init() rejects CPU indices greater than nbits but
accepts nbits itself. Valid indices end at nbits - 1. When nbits is a
multiple of BITS_PER_LONG, __set_bit() accesses the word immediately past
the bitmap allocation.
User specified recording thread masks reach this write before they are
intersected with the selected CPU mask. For example, an affinity mask
containing CPU 64 overruns a bitmap allocated for 64 possible CPUs.
==40343==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7bbab4000018 at pc 0x6195de57af45 bp 0x7ffe25545d20 sp 0x7ffe25545d18
READ of size 8 at 0x7bbab4000018 thread T0
Reject indices greater than or equal to nbits before setting a bit.
Fixes: cbd7bfc7fd99acdd ("tools/perf: Fix out of bound access to cpu mask array")
Signed-off-by: Paul Moses <p@1g4.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
tools/perf/builtin-record.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -3704,8 +3704,8 @@ static int record__mmap_cpu_mask_init(st
return 0;
perf_cpu_map__for_each_cpu_skip_any(cpu, idx, cpus) {
- /* Return ENODEV is input cpu is greater than max cpu */
- if ((unsigned long)cpu.cpu > mask->nbits)
+ /* Return ENODEV if the CPU index is outside the mask. */
+ if ((unsigned long)cpu.cpu >= mask->nbits)
return -ENODEV;
__set_bit(cpu.cpu, mask->bits);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 569/742] powerpc/eeh: NUL-terminate force recovery input
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (559 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 568/742] perf record: Reject CPU indices equal to the mask size Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 570/742] powerpc/xmon: Avoid unsequenced accesses to tsk in show_task() Greg Kroah-Hartman
` (165 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jiale Yao, Ritesh Harjani (IBM),
Madhavan Srinivasan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <yaojiale02@163.com>
commit f294ebd827e7a2b831b1eef4aaf437f07b2c235e upstream.
eeh_force_recover_write() can fill its entire stack buffer from userspace
and then pass the unterminated data to strncmp() and sscanf(). This can
make the string helpers read beyond the buffer.
Reserve the last byte and initialize the buffer so every accepted input is
NUL-terminated. Propagate copy errors before parsing as well.
Fixes: 954bd99435b8 ("powerpc/eeh: Add eeh_force_recover to debugfs")
Cc: stable@vger.kernel.org
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261029052948.2525048-1-yaojiale02@163.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/kernel/eeh.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1728,10 +1728,12 @@ static ssize_t eeh_force_recover_write(s
struct pci_controller *hose;
uint32_t phbid, pe_no;
struct eeh_pe *pe;
- char buf[20];
+ char buf[20] = {};
int ret;
- ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
+ ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+ if (ret < 0)
+ return ret;
if (!ret)
return -EFAULT;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 570/742] powerpc/xmon: Avoid unsequenced accesses to tsk in show_task()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (560 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 569/742] powerpc/eeh: NUL-terminate force recovery input Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 571/742] powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller Greg Kroah-Hartman
` (164 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Nathan Chancellor,
Ritesh Harjani (IBM), Madhavan Srinivasan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <nathan@kernel.org>
commit 9ea01307e6c824eb0b8934d95d52bbacae17887d upstream.
After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appears in show_task(), which can
break the build with CONFIG_PPC_WERROR=y / CONFIG_WERROR=y / W=e:
arch/powerpc/xmon/xmon.c:3262:3: error: unsequenced accesses to volatile qualified 'tsk' [-Werror,-Wunsequenced]
3261 | printf("%16px %16lx %16px %6d %6d %c %2d %s\n", tsk,
| ~~~
3262 | tsk->thread.ksp, tsk->thread.regs,
| ^
Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.2.2.10/12, the evaluation of arguments in a
function call is indeterminately sequenced, meaning any side effects in
the arguments are unsequenced.
tsk was made volatile in commit a2305e3de819 ("powerpc: mark local
variables around longjmp as volatile") to ensure its value in
show_tasks() was properly restored after returning from a potential
longjmp(). Aside from that, the value is not being modified through
other means, so rename the volatile parameter and add a local variable
named tsk to hold its value throughout show_task(), clearing up the
warning.
Cc: stable@vger.kernel.org
Fixes: a2305e3de819 ("powerpc: mark local variables around longjmp as volatile")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2199
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20261115-xmon-wunsequenced-v1-1-42ae3fe45bf4@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/xmon/xmon.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -3240,8 +3240,9 @@ memzcan(void)
printf("%.8lx\n", a - mskip);
}
-static void show_task(struct task_struct *volatile tsk)
+static void show_task(struct task_struct *volatile vol_tsk)
{
+ struct task_struct *tsk = vol_tsk;
unsigned int p_state = READ_ONCE(tsk->__state);
char state;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 571/742] powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (561 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 570/742] powerpc/xmon: Avoid unsequenced accesses to tsk in show_task() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 572/742] ring-buffer: Check remote reader page commit before meta entries Greg Kroah-Hartman
` (163 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Bradley Morgan,
Christophe Leroy (CS GROUP), Madhavan Srinivasan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bradley Morgan <brads@mainlining.org>
commit dc6eb6f08be536223e8289c7a8b1f515b1355721 upstream.
Commit 7dfbfb87c243 ("powerpc/ftrace: Activate
HAVE_DYNAMIC_FTRACE_WITH_REGS on PPC32") made count_relocs()
undercount the PLT entries the loader
consumes: module_finalize_ftrace() now creates two trampolines
(mod->arch.tramp for ftrace_caller() and mod->arch.tramp_regs for
ftrace_regs_caller()), while count_relocs() reserves only one entry
for ftrace.
So the core .plt ends up one ppc_plt_entry (16 bytes) short. The
walk in do_plt_call() scans for a free slot with
"while (entry->jump[0])" and has no bound check, so once the last
reserved slot is used up, the walk steps past the end of the section
and patch_instruction() writes the 4-instruction trampoline into
whatever module memory follows the .plt.
Count the second entry, mirroring what module_64.c does for the same
pair of stubs.
Signed-off-by: Bradley Morgan <brads@mainlining.org>
Fixes: 7dfbfb87c243 ("powerpc/ftrace: Activate HAVE_DYNAMIC_FTRACE_WITH_REGS on PPC32")
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260923175631.235276-1-brads@mainlining.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/powerpc/kernel/module_32.c | 3 +++
1 file changed, 3 insertions(+)
--- a/arch/powerpc/kernel/module_32.c
+++ b/arch/powerpc/kernel/module_32.c
@@ -41,6 +41,9 @@ static unsigned int count_relocs(const E
#ifdef CONFIG_DYNAMIC_FTRACE
_count_relocs++; /* add one for ftrace_caller */
+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
+ _count_relocs++; /* add one for ftrace_regs_caller */
+#endif
#endif
return _count_relocs;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 572/742] ring-buffer: Check remote reader page commit before meta entries
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (562 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 571/742] powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 573/742] ring-buffer: Do not check si_mem_available() before deferred init completes Greg Kroah-Hartman
` (162 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Vincent Donnefort, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <vdonnefort@google.com>
commit 27d44f1c58092c56cf38adf831ca4cfe05b4a03c upstream.
__rb_get_reader_page_from_remote() bails out when rb_num_of_entries() is
zero before verifying if there is more data committed on the current
reader_page (rb_page_size()), while simple_ring_buffer updates
page::commit before meta::entries. As a consequence, a race between the
writer and reader could lead to __rb_get_reader_page_from_remote()
returning NULL, while more data is available for reading on the ring
buffer.
CPU0 (writer) CPU1 (reader)
------------- -------------
local_set(&page->commit, write);
__rb_get_reader_page_from_remote()
!rb_read_remote_meta_page()
return NULL;
simple_rb_meta_inc(meta->entries, 1);
This is an issue for rb_advance_reader() which always expects
rb_get_reader_page() to return a page.
Fix this issue by swapping the checks in
__rb_get_reader_page_from_remote(): first it verifies if there is more
to read in the current reader page, then it verifies if there's anything
at all in the ring buffer.
Also, if the reader observes the meta::entries update before
page::commit while the writer moves tail_page, it could swap reader_page
out and drop unread events. Order page::commit before meta::entries on
the writer and rb_read_remote_meta_page() before rb_page_size() on the
reader size.
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261113152729.837429-3-vdonnefort@google.com
Fixes: 2e67fabd8b77 ("ring-buffer: Introduce ring-buffer remotes")
Fixes: 34e5b958bdad ("tracing: Introduce simple_ring_buffer")
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/ring_buffer.c | 19 +++++++++++++------
kernel/trace/simple_ring_buffer.c | 6 ++++++
2 files changed, 19 insertions(+), 6 deletions(-)
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -5615,14 +5615,12 @@ unsigned long ring_buffer_overruns(struc
}
EXPORT_SYMBOL_GPL(ring_buffer_overruns);
-static bool rb_read_remote_meta_page(struct ring_buffer_per_cpu *cpu_buffer)
+static void rb_read_remote_meta_page(struct ring_buffer_per_cpu *cpu_buffer)
{
local_set(&cpu_buffer->entries, READ_ONCE(cpu_buffer->meta_page->entries));
local_set(&cpu_buffer->overrun, READ_ONCE(cpu_buffer->meta_page->overrun));
local_set(&cpu_buffer->pages_touched, READ_ONCE(cpu_buffer->meta_page->pages_touched));
local_set(&cpu_buffer->pages_lost, READ_ONCE(cpu_buffer->meta_page->pages_lost));
-
- return rb_num_of_entries(cpu_buffer);
}
static void rb_update_remote_head(struct ring_buffer_per_cpu *cpu_buffer)
@@ -5825,8 +5823,13 @@ __rb_get_reader_page_from_remote(struct
{
struct buffer_page *new_reader, *prev_reader, *prev_head, *new_head, *last;
- if (!rb_read_remote_meta_page(cpu_buffer))
- return NULL;
+ rb_read_remote_meta_page(cpu_buffer);
+
+ /*
+ * Order meta::entries read before page::commit, most likely paired with
+ * simple_ring_buffer_commit().
+ */
+ smp_rmb();
/* More to read on the reader page */
if (cpu_buffer->reader_page->read < rb_page_size(cpu_buffer->reader_page)) {
@@ -5835,6 +5838,9 @@ __rb_get_reader_page_from_remote(struct
return cpu_buffer->reader_page;
}
+ if (!rb_num_of_entries(cpu_buffer))
+ return NULL;
+
prev_reader = cpu_buffer->subbuf_ids[cpu_buffer->meta_page->reader.id];
if (cpu_buffer->remote->swap_reader_page(cpu_buffer->cpu,
@@ -6903,7 +6909,8 @@ int ring_buffer_poll_remote(struct trace
cpu_buffer = buffer->buffers[cpu];
guard(raw_spinlock)(&cpu_buffer->reader_lock);
- if (rb_read_remote_meta_page(cpu_buffer))
+ rb_read_remote_meta_page(cpu_buffer);
+ if (rb_num_of_entries(cpu_buffer))
rb_wakeups(buffer, cpu_buffer);
return 0;
--- a/kernel/trace/simple_ring_buffer.c
+++ b/kernel/trace/simple_ring_buffer.c
@@ -296,6 +296,12 @@ void simple_ring_buffer_commit(struct si
{
local_set(&cpu_buffer->tail_page->page->commit,
cpu_buffer->tail_page->write);
+
+ /*
+ * Order page::commit before meta::entries. Paired with
+ * __rb_get_reader_page_from_remote().
+ */
+ smp_wmb();
simple_rb_meta_inc(cpu_buffer->meta->entries, 1);
/*
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 573/742] ring-buffer: Do not check si_mem_available() before deferred init completes
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (563 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 572/742] ring-buffer: Check remote reader page commit before meta entries Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 574/742] ring-buffer: Order remote page commit with data and timestamp Greg Kroah-Hartman
` (161 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Michal Suchánek,
Vincent Donnefort, Amit Machhiwal, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Machhiwal <amachhiw@linux.ibm.com>
commit abf7185109d3986c1f945641d2fb20e44527f7c6 upstream.
With CONFIG_DEFERRED_STRUCT_PAGE_INIT=y, only about one memory section
per node is initialized early in boot (16 MiB on powerpc). The rest is
initialized on demand by deferred_grow_zone() when an allocation would
otherwise fail, or later by page_alloc_init_late().
Until then NR_FREE_PAGES can be close to zero, because early allocations
(SLUB, vmalloc, ftrace records) use up the first section.
si_mem_available() is derived from NR_FREE_PAGES, so it under-reports.
__rb_allocate_pages() returns -ENOMEM when si_mem_available() is below
the requested size. This check wrongly fails the buffers allocated for
the boot CPU in early_trace_init() and for secondary CPUs in smp_init(),
both of which run before page_alloc_init_late(). The resulting boot log
shows:
ERROR: Failed to allocate trace buffer
ERROR: tracer: failed to allocate ring buffer!
Skip the check until SYSTEM_FREEING_INITMEM on
CONFIG_DEFERRED_STRUCT_PAGE_INIT kernels. The allocation itself still
fails if memory really is short.
This is the second half of the fix for the early boot crash reported on
ppc64le KVM guests. Commit b3b974008388 ("tracing: Do not initialize
tracefs work if tracing is disabled") stopped the NULL pointer
dereference in __find_event_file() that followed the failed allocation.
This patch fixes the allocation failure itself.
Cc: stable@vger.kernel.org
Fixes: 2a872fa4e9c8 ("ring-buffer: Check if memory is available before allocation")
Link: https://patch.msgid.link/20261118183235.63310-1-amachhiw@linux.ibm.com
Reported-by: Michal Suchánek <msuchanek@suse.de>
Closes: https://lore.kernel.org/all/arYskzbiaNzBR9MD@kunlun.suse.cz/
Reviewed-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/ring_buffer.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -2463,8 +2463,17 @@ static int __rb_allocate_pages(struct ri
* memory. It may not be accurate. But we don't care, we just want
* to prevent doing any allocation when it is obvious that it is
* not going to succeed.
+ *
+ * With CONFIG_DEFERRED_STRUCT_PAGE_INIT, si_mem_available()
+ * will reflect the actual available memory only after
+ * SYSTEM_FREEING_INITMEM.
*/
- i = si_mem_available();
+ if (IS_ENABLED(CONFIG_DEFERRED_STRUCT_PAGE_INIT) &&
+ unlikely(system_state < SYSTEM_FREEING_INITMEM))
+ i = LONG_MAX;
+ else
+ i = si_mem_available();
+
if (i < (nr_pages << subbuf_order))
return -ENOMEM;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 574/742] ring-buffer: Order remote page commit with data and timestamp
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (564 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 573/742] ring-buffer: Do not check si_mem_available() before deferred init completes Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 575/742] ring-buffer: Skip remote reader page swap when on tail Greg Kroah-Hartman
` (160 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Vincent Donnefort, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <vdonnefort@google.com>
commit d1a4551c99aa6a29c1c4e6466dfebaa4449ad0ed upstream.
__rb_get_reader_page_from_remote() uses page::commit to check if more
data is available for consumption. However, it needs to make sure that
data and page::time_stamp are not stale. Enforce page::commit order with
page::data and page::time_stamp, and defer updating read_stamp on page
swap until rb_page_size() confirms committed data is present.
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261113152729.837429-4-vdonnefort@google.com
Fixes: 2e67fabd8b77 ("ring-buffer: Introduce ring-buffer remotes")
Fixes: 34e5b958bdad ("tracing: Introduce simple_ring_buffer")
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/ring_buffer.c | 23 ++++++++++++++++-------
kernel/trace/simple_ring_buffer.c | 5 +++++
2 files changed, 21 insertions(+), 7 deletions(-)
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -5841,11 +5841,8 @@ __rb_get_reader_page_from_remote(struct
smp_rmb();
/* More to read on the reader page */
- if (cpu_buffer->reader_page->read < rb_page_size(cpu_buffer->reader_page)) {
- if (!cpu_buffer->reader_page->read)
- cpu_buffer->read_stamp = cpu_buffer->reader_page->page->time_stamp;
- return cpu_buffer->reader_page;
- }
+ if (cpu_buffer->reader_page->read < rb_page_size(cpu_buffer->reader_page))
+ goto out;
if (!rb_num_of_entries(cpu_buffer))
return NULL;
@@ -5891,10 +5888,22 @@ __rb_get_reader_page_from_remote(struct
cpu_buffer->reader_page = new_reader;
cpu_buffer->reader_page->read = 0;
cpu_buffer->pages = &new_head->list;
- cpu_buffer->read_stamp = new_reader->page->time_stamp;
cpu_buffer->lost_events = cpu_buffer->meta_page->reader.lost_events;
- return rb_page_size(cpu_buffer->reader_page) ? cpu_buffer->reader_page : NULL;
+ if (!rb_page_size(cpu_buffer->reader_page))
+ return NULL;
+
+out:
+ /*
+ * Order page::commit read before page::data and page::time_stamp, most
+ * likely paired with simple_ring_buffer_commit().
+ */
+ smp_rmb();
+
+ if (!cpu_buffer->reader_page->read)
+ cpu_buffer->read_stamp = cpu_buffer->reader_page->page->time_stamp;
+
+ return cpu_buffer->reader_page;
}
static struct buffer_page *
--- a/kernel/trace/simple_ring_buffer.c
+++ b/kernel/trace/simple_ring_buffer.c
@@ -294,6 +294,11 @@ EXPORT_SYMBOL_GPL(simple_ring_buffer_res
*/
void simple_ring_buffer_commit(struct simple_rb_per_cpu *cpu_buffer)
{
+ /*
+ * Order page::data and page::time_stamp before page::commit. Paired
+ * with __rb_get_reader_page_from_remote().
+ */
+ smp_wmb();
local_set(&cpu_buffer->tail_page->page->commit,
cpu_buffer->tail_page->write);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 575/742] ring-buffer: Skip remote reader page swap when on tail
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (565 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 574/742] ring-buffer: Order remote page commit with data and timestamp Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 576/742] riscv: Fix SR_SUM leakage across context switches Greg Kroah-Hartman
` (159 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Vincent Donnefort, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <vdonnefort@google.com>
commit 2a6d7231c79ecb0e6a1d4e6549302e0c47175d22 upstream.
When the reader page is also the tail, swap should not be permitted or
it would insert the tail behind the head, breaking the integrity of the
ring buffer. While __rb_get_reader_page() does correctly prevent this
situation, the simple_ring_buffer implementation misses it.
Once the reader catches up with the tail, make
simple_ring_buffer_swap_reader_page() return 0. The remote reader now
can expect an unchanged reader. When it is the case, there's nothing
more to read.
Also, when the simple_ring_buffer writer moves the tail to a new page,
it resets the new tail counters and more specifically page::commit. As
moving the tail unblocks page swap, order the page reset before the
tail_page update. This ensures the reader can't swap the reader page
with the new tail and observe a stale commit value.
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261113152729.837429-2-vdonnefort@google.com
Fixes: 2e67fabd8b77 ("ring-buffer: Introduce ring-buffer remotes")
Fixes: 34e5b958bdad ("tracing: Introduce simple_ring_buffer")
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/ring_buffer.c | 3 ++-
kernel/trace/simple_ring_buffer.c | 15 ++++++++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -5860,7 +5860,8 @@ __rb_get_reader_page_from_remote(struct
new_reader = cpu_buffer->subbuf_ids[cpu_buffer->meta_page->reader.id];
- WARN_ON_ONCE(prev_reader == new_reader);
+ if (prev_reader == new_reader)
+ return NULL;
prev_head = new_reader; /* New reader was also the previous head */
new_head = prev_head;
--- a/kernel/trace/simple_ring_buffer.c
+++ b/kernel/trace/simple_ring_buffer.c
@@ -139,6 +139,13 @@ int simple_ring_buffer_swap_reader_page(
reader = cpu_buffer->reader_page;
+ /*
+ * The reader is already the tail page. See simple_rb_move_tail() for
+ * memory ordering.
+ */
+ if (reader == smp_load_acquire(&cpu_buffer->tail_page))
+ return 0;
+
do {
/* Run after the writer to find the head */
ret = simple_rb_find_head(cpu_buffer);
@@ -196,7 +203,13 @@ static struct simple_buffer_page *simple
}
simple_bpage_reset(new_tail);
- cpu_buffer->tail_page = new_tail;
+
+ /*
+ * Setting a new tail may unblock the swap in
+ * simple_ring_buffer_swap_reader_page(). Ensure the reader observes the
+ * page::commit reset.
+ */
+ smp_store_release(&cpu_buffer->tail_page, new_tail);
simple_rb_meta_inc(cpu_buffer->meta->pages_touched, 1);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 576/742] riscv: Fix SR_SUM leakage across context switches
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (566 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 575/742] ring-buffer: Skip remote reader page swap when on tail Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 577/742] riscv: mm: reserve the DTB before scanning reserved memory Greg Kroah-Hartman
` (158 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Yunhui Cui, Jisheng Zhang, Andy Chiu,
Yicong Yang, Paul Walmsley
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yunhui Cui <cuiyunhui@bytedance.com>
commit 807b09be9c8f234ce758bcf43101f34e0a036b83 upstream.
__switch_to() saves the sstatus value of prev and restores the SR_SUM bit
of next with csrs. However, csrs only sets bits. If prev has SR_SUM set
and next has SR_SUM clear in its saved state, the old SR_SUM bit remains
set in sstatus.
This lets next run with user memory access enabled even though its saved
SR_SUM state is clear.
Use csrrc to save the sstatus value of prev and clear SR_SUM from the
live CSR before restoring the saved SR_SUM state of next. This keeps
prev's SR_SUM state intact, while preventing it from leaking to next.
Fixes: 788aa64c01f1 ("riscv: save the SR_SUM status over switches")
Cc: stable@vger.kernel.org
Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
Reviewed-by: Jisheng Zhang <jszhang@kernel.org>
Reviewed-by: Andy Chiu <tchiu@tenstorrent.com>
Reviewed-by: Yicong Yang <yang.yicong@picoheart.com>
Link: https://patch.msgid.link/20261022083212.84721-1-cuiyunhui@bytedance.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/riscv/kernel/entry.S | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/arch/riscv/kernel/entry.S
+++ b/arch/riscv/kernel/entry.S
@@ -443,15 +443,15 @@ SYM_FUNC_START(__switch_to)
REG_S s10, TASK_THREAD_S10_RA(a3)
REG_S s11, TASK_THREAD_S11_RA(a3)
- /* save the user space access flag */
- csrr s0, CSR_STATUS
+ /* Save and clear the user space access flag. */
+ li s1, SR_SUM
+ csrrc s0, CSR_STATUS, s1
REG_S s0, TASK_THREAD_SUM_RA(a3)
/* Save the kernel shadow call stack pointer */
scs_save_current
/* Restore context from next->thread */
REG_L s0, TASK_THREAD_SUM_RA(a4)
- li s1, SR_SUM
and s0, s0, s1
csrs CSR_STATUS, s0
REG_L ra, TASK_THREAD_RA_RA(a4)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 577/742] riscv: mm: reserve the DTB before scanning reserved memory
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (567 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 576/742] riscv: Fix SR_SUM leakage across context switches Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 578/742] riscv: signal: protect regs->status RMW from concurrent preemption Greg Kroah-Hartman
` (157 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Marek Szyprowski, Paul Walmsley
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <m.szyprowski@samsung.com>
commit fc91dacd0c2b4f9ca7e0ce30016f5aee6256cba5 upstream.
early_init_fdt_scan_reserved_mem() allocates memory from memblock while
it scans /reserved-memory: the reserved_mem array, and the regions that
are placed dynamically by size. On RISC-V the DTB was only reserved
after that scan, so memblock could hand out the memory the DTB occupies
while the DTB was still being parsed.
Reserve the DTB before the scan, so that memblock never allocates from
it.
Fixes: ef69d2559fe9 ("riscv: Move early dtb mapping into the fixmap region")
Closes: https://lore.kernel.org/all/b71ac175-fba5-4f61-bbdb-0b98dec9ccee@samsung.com/
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://patch.msgid.link/20261104104604.3370384-1-m.szyprowski@samsung.com
Cc: stable@vger.kernel.org
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/riscv/mm/init.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -291,13 +291,6 @@ static void __init setup_bootmem(void)
reserve_initrd_mem();
/*
- * No allocation should be done before reserving the memory as defined
- * in the device tree, otherwise the allocation could end up in a
- * reserved region.
- */
- early_init_fdt_scan_reserved_mem();
-
- /*
* If DTB is built in, no need to reserve its memblock.
* Otherwise, do reserve it but avoid using
* early_init_fdt_reserve_self() since __pa() does
@@ -305,6 +298,13 @@ static void __init setup_bootmem(void)
*/
if (!IS_ENABLED(CONFIG_BUILTIN_DTB))
memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va));
+
+ /*
+ * No allocation should be done before reserving the memory as defined
+ * in the device tree, otherwise the allocation could end up in a
+ * reserved region.
+ */
+ early_init_fdt_scan_reserved_mem();
}
#ifdef CONFIG_RELOCATABLE
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 578/742] riscv: signal: protect regs->status RMW from concurrent preemption
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (568 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 577/742] riscv: mm: reserve the DTB before scanning reserved memory Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 579/742] riscv: unaligned: fix __setup handlers Greg Kroah-Hartman
` (156 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Andy Chiu, Guobin Zhang,
Paul Walmsley
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guobin Zhang <guobin.zhang@intel.com>
commit 018fe0700c569b50465b27d68deee7e9157e8e5f upstream.
__fstate_clean() performs a non-atomic read-modify-write (RMW) on
task_pt_regs(current)->status to clear the FS bits. This RMW is
unprotected - it runs with preemption enabled and IRQs on during
signal delivery (setup_rt_frame -> fstate_save) and sigreturn
(restore_fp_state -> fstate_restore).
If a reschedule IPI or timer interrupt triggers preemption between
the load and store of this RMW, __switch_to_vector() calls
riscv_v_vstate_set_restore() which modifies the VS bits of the
same regs->status. When the preempted task resumes, it stores back
the stale value captured before preemption, overwriting the VS
update and restoring VS=DIRTY while TIF_RISCV_V_DEFER_RESTORE
remains set - a combination that should never occur and leads to
vector state corruption.
The race window:
__fstate_clean (signal path) set_restore (schedule path)
----------------------------- -----------------------------
ld a0, regs->status // VS=DIRTY, FS=DIRTY
<- preempted (reschedule IPI)
regs->status VS = INITIAL
set TIF_RISCV_V_DEFER_RESTORE
<- resumed
andi a0, ~FS
ori a0, FS_CLEAN // stale a0 still has VS=DIRTY
sd a0, regs->status // overwrites VS=INITIAL with VS=DIRTY
-> result: VS=DIRTY + DEFER -> ANOMALY
Fix by adding preempt_disable/enable in fstate_save() and
fstate_restore(), which covers the RMW in __fstate_clean(), and
around the RMW in fstate_off(). Add fstate_{save,restore}_preempt_off()
for code that already runs with preemption disabled (the scheduler and
kernel_mode_fpu).
riscv_v_vstate_set_restore() has the identical hazard: it is called
from __restore_v_state() (sigreturn path) with preemption enabled, and
it can race the same way against the scheduler's own call to
riscv_v_vstate_set_restore() for the same task in __switch_to_vector().
Wrap that call site with preempt_disable/enable as well.
Add WARN_ON_ONCE(preemptible()) to riscv_v_vstate_restore()
to catch any future unprotected callers at development time.
Suggested-by: Andy Chiu <tchiu@tenstorrent.com>
Signed-off-by: Guobin Zhang <guobin.zhang@intel.com>
Reviewed-by: Andy Chiu <tchiu@tenstorrent.com>
Link: https://patch.msgid.link/20261020-vector_fpu_regs_status_rmw_fix-v2-1-474a59155e96@intel.com
Cc: stable@vger.kernel.org
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/riscv/include/asm/switch_to.h | 30 ++++++++++++++++++++++++------
arch/riscv/include/asm/vector.h | 2 ++
arch/riscv/kernel/kernel_mode_fpu.c | 4 ++--
arch/riscv/kernel/signal.c | 2 ++
4 files changed, 30 insertions(+), 8 deletions(-)
--- a/arch/riscv/include/asm/switch_to.h
+++ b/arch/riscv/include/asm/switch_to.h
@@ -28,11 +28,13 @@ static inline void __fstate_clean(struct
static inline void fstate_off(struct task_struct *task,
struct pt_regs *regs)
{
+ preempt_disable();
regs->status = (regs->status & ~SR_FS) | SR_FS_OFF;
+ preempt_enable();
}
-static inline void fstate_save(struct task_struct *task,
- struct pt_regs *regs)
+static inline void fstate_save_preempt_off(struct task_struct *task,
+ struct pt_regs *regs)
{
if ((regs->status & SR_FS) == SR_FS_DIRTY) {
__fstate_save(task);
@@ -40,8 +42,8 @@ static inline void fstate_save(struct ta
}
}
-static inline void fstate_restore(struct task_struct *task,
- struct pt_regs *regs)
+static inline void fstate_restore_preempt_off(struct task_struct *task,
+ struct pt_regs *regs)
{
if ((regs->status & SR_FS) != SR_FS_OFF) {
__fstate_restore(task);
@@ -49,14 +51,30 @@ static inline void fstate_restore(struct
}
}
+static inline void fstate_save(struct task_struct *task,
+ struct pt_regs *regs)
+{
+ preempt_disable();
+ fstate_save_preempt_off(task, regs);
+ preempt_enable();
+}
+
+static inline void fstate_restore(struct task_struct *task,
+ struct pt_regs *regs)
+{
+ preempt_disable();
+ fstate_restore_preempt_off(task, regs);
+ preempt_enable();
+}
+
static inline void __switch_to_fpu(struct task_struct *prev,
struct task_struct *next)
{
struct pt_regs *regs;
regs = task_pt_regs(prev);
- fstate_save(prev, regs);
- fstate_restore(next, task_pt_regs(next));
+ fstate_save_preempt_off(prev, regs);
+ fstate_restore_preempt_off(next, task_pt_regs(next));
}
static __always_inline bool has_fpu(void)
--- a/arch/riscv/include/asm/vector.h
+++ b/arch/riscv/include/asm/vector.h
@@ -320,6 +320,8 @@ static inline void riscv_v_vstate_save(s
static inline void riscv_v_vstate_restore(struct __riscv_v_ext_state *vstate,
struct pt_regs *regs)
{
+ WARN_ON_ONCE(preemptible());
+
if (riscv_v_vstate_query(regs)) {
__riscv_v_vstate_restore(vstate, vstate->datap);
__riscv_v_vstate_clean(regs);
--- a/arch/riscv/kernel/kernel_mode_fpu.c
+++ b/arch/riscv/kernel/kernel_mode_fpu.c
@@ -14,7 +14,7 @@
void kernel_fpu_begin(void)
{
preempt_disable();
- fstate_save(current, task_pt_regs(current));
+ fstate_save_preempt_off(current, task_pt_regs(current));
csr_set(CSR_SSTATUS, SR_FS);
}
EXPORT_SYMBOL_GPL(kernel_fpu_begin);
@@ -22,7 +22,7 @@ EXPORT_SYMBOL_GPL(kernel_fpu_begin);
void kernel_fpu_end(void)
{
csr_clear(CSR_SSTATUS, SR_FS);
- fstate_restore(current, task_pt_regs(current));
+ fstate_restore_preempt_off(current, task_pt_regs(current));
preempt_enable();
}
EXPORT_SYMBOL_GPL(kernel_fpu_end);
--- a/arch/riscv/kernel/signal.c
+++ b/arch/riscv/kernel/signal.c
@@ -123,7 +123,9 @@ static long __restore_v_state(struct pt_
* to avoid getting the vstate incorrectly clobbered by the
* discarded vector state.
*/
+ preempt_disable();
riscv_v_vstate_set_restore(current, regs);
+ preempt_enable();
/* Copy everything of __sc_riscv_v_state except datap. */
err = __copy_from_user(¤t->thread.vstate, &state->v_state,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 579/742] riscv: unaligned: fix __setup handlers
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (569 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 578/742] riscv: signal: protect regs->status RMW from concurrent preemption Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 580/742] rust: iov: fix return lifetime of `copy_from_iter_raw()` Greg Kroah-Hartman
` (155 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Vladimir Kondratiev, Jisheng Zhang,
Paul Walmsley
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
commit 27fc871b963183d9371cc838c1a543033d91357f upstream.
Returning -EINVAL from a __setup() callback cause invalid
unaligned_scalar_speed= and unaligned_vector_speed=
values to be treated as handled. obsolete_checksetup() treats any
non-zero return value from setup_func() as success, so an unrecognized
argument is silently accepted instead of being reported as an unknown
boot option.
__setup() handlers return 0 on failure.
Fixes: aecb09e091dc ("riscv: Add parameter for skipping access speed tests")
Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Reviewed-by: Jisheng Zhang <jszhang@kernel.org>
Link: https://patch.msgid.link/20261111-fix-riscv-unaligned-v1-1-0722514fc1e4@mobileye.com
Cc: stable@vger.kernel.org
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/riscv/kernel/unaligned_access_speed.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/arch/riscv/kernel/unaligned_access_speed.c
+++ b/arch/riscv/kernel/unaligned_access_speed.c
@@ -322,7 +322,7 @@ static int __init set_unaligned_scalar_s
else if (!strcmp(str, speed_str[RISCV_HWPROBE_MISALIGNED_SCALAR_UNSUPPORTED]))
unaligned_scalar_speed_param = RISCV_HWPROBE_MISALIGNED_SCALAR_UNSUPPORTED;
else
- return -EINVAL;
+ return 0;
return 1;
}
@@ -337,7 +337,7 @@ static int __init set_unaligned_vector_s
else if (!strcmp(str, speed_str[RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED]))
unaligned_vector_speed_param = RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED;
else
- return -EINVAL;
+ return 0;
return 1;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 580/742] rust: iov: fix return lifetime of `copy_from_iter_raw()`
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (570 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 579/742] riscv: unaligned: fix __setup handlers Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 581/742] rust: str: tie Formatter to its backing buffer Greg Kroah-Hartman
` (154 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, spidermana, Marwan Mohamed Zein,
Miguel Ojeda
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marwan Mohamed Zein <marawanzein222@gmail.com>
commit df71affdd95ea60fa3fb31e666389a53fd3297db upstream.
The returned slice is derived from `out`, but lifetime elision
ties it to `self` because this is a method. Explicitly bind the
return lifetime to `out` so the returned slice cannot outlive
its backing buffer.
Fixes: 06cb58b310ea ("rust: iov: add iov_iter abstractions for ITER_SOURCE")
Cc: stable@vger.kernel.org
Reported-by: spidermana <xuyiwen14@gmail.com>
Closes: https://github.com/Rust-for-Linux/linux/issues/1265
Signed-off-by: Marwan Mohamed Zein <marawanzein222@gmail.com>
Link: https://patch.msgid.link/20261114132156.49243-1-marawanzein222@gmail.com
[ Reworded title. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
rust/kernel/iov.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/rust/kernel/iov.rs
+++ b/rust/kernel/iov.rs
@@ -161,7 +161,7 @@ impl<'data> IovIterSource<'data> {
///
/// This will never write uninitialized bytes to the provided buffer.
#[inline]
- pub fn copy_from_iter_raw(&mut self, out: &mut [MaybeUninit<u8>]) -> &mut [u8] {
+ pub fn copy_from_iter_raw<'a>(&mut self, out: &'a mut [MaybeUninit<u8>]) -> &'a mut [u8] {
let capacity = out.len();
let out = out.as_mut_ptr().cast::<u8>();
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 581/742] rust: str: tie Formatter to its backing buffer
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (571 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 580/742] rust: iov: fix return lifetime of `copy_from_iter_raw()` Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 582/742] s390/appldata: Fix error handling in appldata_generic_handler() Greg Kroah-Hartman
` (153 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Georgios Androutsopoulos,
Peder Bergan, Gary Guo, Andreas Hindborg, Alice Ryhl,
Miguel Ojeda
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peder Bergan <peder.bergan@gmail.com>
commit cf2212fd3053857f800cc22d903118d522131ca8 upstream.
Formatter::new() returns a Formatter whose lifetime is independent of the
borrow of its backing buffer. Safe code can therefore drop the buffer and
then write through the formatter, causing a use-after-free.
Tie the buffer borrow to the formatter's lifetime so that the borrow
checker rejects such callers and prevents overlapping mutable access.
Fixes: 87482d6d9104 ("rust: str: allow `str::Formatter` to format into `&mut [u8]`.")
Cc: stable@vger.kernel.org
Reported-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
Closes: https://github.com/Rust-for-Linux/linux/issues/1261
Signed-off-by: Peder Bergan <peder.bergan@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20261117-formatter-lifetime-v2-1-e216d86ffb57@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
rust/kernel/str.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/rust/kernel/str.rs
+++ b/rust/kernel/str.rs
@@ -645,7 +645,7 @@ impl fmt::Write for RawFormatter {
/// Fails if callers attempt to write more than will fit in the buffer.
pub struct Formatter<'a>(RawFormatter, PhantomData<&'a mut ()>);
-impl Formatter<'_> {
+impl<'a> Formatter<'a> {
/// Creates a new instance of [`Formatter`] with the given buffer.
///
/// # Safety
@@ -658,7 +658,7 @@ impl Formatter<'_> {
}
/// Create a new [`Self`] instance.
- pub fn new(buffer: &mut [u8]) -> Self {
+ pub fn new(buffer: &'a mut [u8]) -> Self {
// SAFETY: `buffer` is valid for writes for the entire length for
// the lifetime of `Self`.
unsafe { Formatter::from_buffer(buffer.as_mut_ptr(), buffer.len()) }
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 582/742] s390/appldata: Fix error handling in appldata_generic_handler()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (572 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 581/742] rust: str: tie Formatter to its backing buffer Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 583/742] s390/dcssblk: Initialize device semaphore before sysfs registration Greg Kroah-Hartman
` (152 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Gerald Schaefer, Heiko Carstens,
Alexander Gordeev
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
commit 0f01f3156f260a5fbce3b4017e1f1ff93cb29465 upstream.
appldata_generic_handler() always returns 0 after starting or stopping
monitor recording.
So "echo {0,1} > /proc/sys/appldata/{os,mem,net_sum}" returns success even
when DIAG 0xDC failed. A failed start would keep ops->active as 0, so
reading the sysctl later would correctly reflect this.
A failed stop would falsely set ops->active to 0 and decrement module
refcount. This would allow the data gathering module to be removed, and
the data buffer to be freed, while z/VM monitor service is still collecting
data from that buffer.
Fix this by returning -EIO when appldata_diag() failed, and only set
ops->active to 0 and decrement module refcount when it succeeded on stop
path.
Cc: stable@vger.kernel.org
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/s390/appldata/appldata_base.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -318,21 +318,25 @@ appldata_generic_handler(const struct ct
pr_err("Starting the data collection for %s "
"failed with rc=%d\n", ops->name, rc);
module_put(ops->owner);
+ rc = -EIO;
} else
ops->active = 1;
} else if (!active && (ops->active == 1)) {
- ops->active = 0;
rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC,
(unsigned long) ops->data, ops->size,
ops->mod_lvl);
- if (rc != 0)
+ if (rc != 0) {
pr_err("Stopping the data collection for %s "
"failed with rc=%d\n", ops->name, rc);
- module_put(ops->owner);
+ rc = -EIO;
+ } else {
+ ops->active = 0;
+ module_put(ops->owner);
+ }
}
mutex_unlock(&appldata_ops_mutex);
module_put(ops->owner);
- return 0;
+ return rc;
}
/*************************** /proc stuff <END> *******************************/
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 583/742] s390/dcssblk: Initialize device semaphore before sysfs registration
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (573 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 582/742] s390/appldata: Fix error handling in appldata_generic_handler() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 584/742] scsi: mpi3mr: Validate reply frame size bounds Greg Kroah-Hartman
` (151 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Alexander Gordeev, Jiale Yao,
Heiko Carstens
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <yaojiale02@163.com>
commit 64ee7f863655e67f26947420516daba4e232675d upstream.
device_create_file() makes the add and remove attributes writable before
the device list semaphore is initialized. A sysfs write racing module
initialization can therefore acquire an uninitialized rwsem.
Initialize the semaphore before registering the root device and its
attributes.
[hca@linux.ibm.com: Use DECLARE_RWSEM() instead of moving init_rwsem()]
Cc: stable@vger.kernel.org
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/s390/block/dcssblk.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -101,7 +101,7 @@ static DEVICE_ATTR(remove, S_IWUSR, NULL
static struct device *dcssblk_root_dev;
static LIST_HEAD(dcssblk_devices);
-static struct rw_semaphore dcssblk_devices_sem;
+static DECLARE_RWSEM(dcssblk_devices_sem);
/*
* release function for segment device.
@@ -1026,7 +1026,6 @@ dcssblk_init(void)
if (rc < 0)
goto out_root;
dcssblk_major = rc;
- init_rwsem(&dcssblk_devices_sem);
dcssblk_check_params();
return 0;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 584/742] scsi: mpi3mr: Validate reply frame size bounds
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (574 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 583/742] s390/dcssblk: Initialize device semaphore before sysfs registration Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 585/742] scsi: rdac: Keep the error status when controller lookup fails Greg Kroah-Hartman
` (150 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Milan P. Gandhi,
Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Milan P. Gandhi <mgandhi@redhat.com>
commit e550f2b2b4aab4c5f12db89d04d8978ce4ed7b4e upstream.
Firmware provides reply_frame_size in dwords, which the driver multiplies
by 4 to compute facts.reply_sz (u16). If the reported size exceeds U16_MAX
/ 4, the multiplication overflows u16 before assignment, causing
under-allocated DMA reply buffers.
Furthermore, several paths assume a minimal reply frame size:
- logdata_entry_sz calculations underflow or hit zero when reply_sz <= 20
bytes, leading to zero-size allocations and divide-by-zero crashes.
- Unsolicited status descriptors and fixed replies (such as struct
mpi3_iounit_control_reply, 64 bytes) require at least 16 dwords.
Validate reply_frame_size in mpi3mr_issue_iocfacts() to ensure it is within
[16, U16_MAX / 4] dwords before processing facts data.
Fixes: 824a156633df ("scsi: mpi3mr: Base driver code")
Cc: stable@vger.kernel.org
Signed-off-by: Milan P. Gandhi <mgandhi@redhat.com>
Link: https://patch.msgid.link/20261105122401.266559-1-mgandhi@redhat.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/scsi/mpi3mr/mpi3mr.h | 1 +
drivers/scsi/mpi3mr/mpi3mr_fw.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
--- a/drivers/scsi/mpi3mr/mpi3mr.h
+++ b/drivers/scsi/mpi3mr/mpi3mr.h
@@ -83,6 +83,7 @@ extern atomic64_t event_counter;
#define MPI3MR_ADMIN_REPLY_Q_SIZE (8 * MPI3MR_PAGE_SIZE_4K)
#define MPI3MR_ADMIN_REQ_FRAME_SZ 128
#define MPI3MR_ADMIN_REPLY_FRAME_SZ 16
+#define MPI3MR_MIN_REPLY_FRAME_SZ_DWORDS 16 /* 64 bytes */
/* Operational queue management definitions */
#define MPI3MR_OP_REQ_Q_QD 512
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -3160,6 +3160,7 @@ static int mpi3mr_issue_iocfacts(struct
struct mpi3_ioc_facts_data *facts_data)
{
struct mpi3_ioc_facts_request iocfacts_req;
+ u16 reply_frame_size;
void *data = NULL;
dma_addr_t data_dma;
u32 data_len = sizeof(*facts_data);
@@ -3217,6 +3218,23 @@ static int mpi3mr_issue_iocfacts(struct
goto out_unlock;
}
memcpy(facts_data, (u8 *)data, data_len);
+
+ reply_frame_size = le16_to_cpu(facts_data->reply_frame_size);
+ /*
+ * Validate reply_frame_size:
+ * - Must be at least 16 dwords (64 bytes) to accommodate fixed reply
+ * structures and avoid underflow/divide-by-zero in logdata sizing.
+ * - Must not exceed U16_MAX / 4 to prevent integer overflow.
+ */
+ if (reply_frame_size < MPI3MR_MIN_REPLY_FRAME_SZ_DWORDS ||
+ reply_frame_size > (U16_MAX / 4)) {
+ ioc_err(mrioc, "Invalid reply_frame_size %u (must be %u..%u dwords)\n",
+ reply_frame_size, MPI3MR_MIN_REPLY_FRAME_SZ_DWORDS,
+ (unsigned int)(U16_MAX / 4));
+ retval = -EINVAL;
+ goto out_unlock;
+ }
+
mpi3mr_process_factsdata(mrioc, facts_data);
out_unlock:
mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 585/742] scsi: rdac: Keep the error status when controller lookup fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (575 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 584/742] scsi: mpi3mr: Validate reply frame size bounds Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 586/742] scsi: sd_zbc: Cap zone report count by buffer size Greg Kroah-Hartman
` (149 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Shao Mingyin,
Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit 46846939d5f33c9333612662c52475f92e753407 upstream.
initialize_controller() records SCSI_DH_RES_TEMP_UNAVAIL when
get_controller() fails, but then overwrites it with SCSI_DH_OK
unconditionally. It therefore reports success with h->ctlr == NULL and
rdac_bus_attach() continues with check_ownership(), which dereferences
h->ctlr:
BUG: kernel NULL pointer dereference, address: 0000000000000000
...
check_ownership
rdac_bus_attach
get_controller() only fails when its GFP_ATOMIC allocation fails, so the
crash happens exactly when memory is already scarce.
Only report success after the controller was found and the device was added
to its list.
Fixes: 327825574132 ("scsi_dh_rdac: switch to scsi_execute_req_flags()")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261026195409354OWEI2b6HO7swSphvv1FOc@zte.com.cn
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/scsi/device_handler/scsi_dh_rdac.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -450,14 +450,14 @@ static int initialize_controller(struct
spin_lock(&list_lock);
h->ctlr = get_controller(index, array_name, array_id, sdev);
- if (!h->ctlr)
+ if (!h->ctlr) {
err = SCSI_DH_RES_TEMP_UNAVAIL;
- else {
+ } else {
h->sdev = sdev;
list_add_rcu(&h->node, &h->ctlr->dh_list);
+ err = SCSI_DH_OK;
}
spin_unlock(&list_lock);
- err = SCSI_DH_OK;
}
return err;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 586/742] scsi: sd_zbc: Cap zone report count by buffer size
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (576 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 585/742] scsi: rdac: Keep the error status when controller lookup fails Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 587/742] parisc: Fix register corruption in 32-bit dynamic ftrace Greg Kroah-Hartman
` (148 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, co+4a4f9998e2b4b490, Boyan Liu,
Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boyan Liu <yymhvert@gmail.com>
commit 612293fb469c81408829e6325bae25725968986f upstream.
sd_zbc_report_zones() limits descriptor parsing to the requested zone
count and the device-reported ZONE LIST LENGTH, but not to the number of
descriptors that fit in the allocated report buffer. A malicious or
malfunctioning device can report an oversized length and cause
out-of-bounds reads while the descriptors are parsed:
BUG: KASAN: slab-out-of-bounds in sd_zbc_report_zones (drivers/scsi/sd_zbc.c:256)
Read of size 8 at addr ffff88802c8d2610 by task kworker/u8:2/37
Call Trace:
sd_zbc_report_zones (drivers/scsi/sd_zbc.c:256)
blk_revalidate_disk_zones (block/blk-zoned.c:2354)
sd_zbc_revalidate_zones (drivers/scsi/sd_zbc.c:566)
sd_revalidate_disk (drivers/scsi/sd.c:3898)
sd_probe (drivers/scsi/sd.c:4101)
Cap the descriptor count with min3() over the remaining requested zones,
the device-reported count, and max_in_buf derived from buflen. This
matches nvme_ns_report_zones() and preserves iteration over reports that
require multiple commands. Use shared constants for the REPORT ZONES
header and zone descriptor sizes.
[mkp: define constants]
Fixes: d41003513e61 ("block: rework zone reporting")
Cc: stable@vger.kernel.org
Reported-by: co+4a4f9998e2b4b490@bugs.sh
Signed-off-by: Boyan Liu <yymhvert@gmail.com>
Link: https://patch.msgid.link/20261028061651.110435-1-yymhvert@gmail.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/scsi/sd_zbc.c | 9 +++++++--
include/scsi/scsi_proto.h | 3 +++
2 files changed, 10 insertions(+), 2 deletions(-)
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -222,7 +222,7 @@ int sd_zbc_report_zones(struct gendisk *
{
struct scsi_disk *sdkp = scsi_disk(disk);
sector_t lba = sectors_to_logical(sdkp->device, sector);
- unsigned int nr, i;
+ unsigned int nr, i, max_in_buf;
unsigned char *buf;
u64 zone_length, start_lba;
size_t offset, buflen = 0;
@@ -241,13 +241,18 @@ int sd_zbc_report_zones(struct gendisk *
if (!buf)
return -ENOMEM;
+ max_in_buf = (buflen - ZBC_REPORT_ZONES_HEADER_SIZE) /
+ ZBC_ZONE_DESCRIPTOR_SIZE;
+
while (zone_idx < nr_zones && lba < sdkp->capacity) {
ret = sd_zbc_do_report_zones(sdkp, buf, buflen, lba, true);
if (ret)
goto out;
offset = 0;
- nr = min(nr_zones, get_unaligned_be32(&buf[0]) / 64);
+ nr = min3(nr_zones - zone_idx,
+ get_unaligned_be32(&buf[0]) / ZBC_ZONE_DESCRIPTOR_SIZE,
+ max_in_buf);
if (!nr)
break;
--- a/include/scsi/scsi_proto.h
+++ b/include/scsi/scsi_proto.h
@@ -422,6 +422,9 @@ enum zbc_zone_reporting_options {
#define ZBC_REPORT_ZONE_PARTIAL 0x80
+#define ZBC_REPORT_ZONES_HEADER_SIZE 64
+#define ZBC_ZONE_DESCRIPTOR_SIZE 64
+
/* Zone types of REPORT ZONES zone descriptors */
enum zbc_zone_type {
ZBC_ZONE_TYPE_CONV = 0x1,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 587/742] parisc: Fix register corruption in 32-bit dynamic ftrace
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (577 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 586/742] scsi: sd_zbc: Cap zone report count by buffer size Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 588/742] parisc: irq: Trace hardirq state in do_cpu_irq_mask() Greg Kroah-Hartman
` (147 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Karl Mehltretter, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <kmehltretter@gmail.com>
commit e9c14351f84f2ddf4aae2914979c0378bc14460a upstream.
The 32-bit dynamic ftrace trampoline allocates a 64-byte frame.
ftrace_caller() saves %r26 at offset 20, which overlaps the third
argument's spill slot for ftrace_function_trampoline().
In the failing build, GCC spills org_sp_gr3 into that slot, overwriting
saved %r26 with the original stack pointer. Tracing preempt_count_add()
then passes that pointer as val and corrupts the preempt count.
Allocate two frames on 32-bit, as 64-bit already does, and update the
generated trampoline instruction to match.
Fixes: 6ca6366220ed ("parisc: add dynamic ftrace")
Cc: stable@vger.kernel.org
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/parisc/kernel/entry.S | 4 ----
arch/parisc/kernel/ftrace.c | 2 +-
2 files changed, 1 insertion(+), 5 deletions(-)
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -1949,11 +1949,7 @@ ENDPROC_CFI(mcount)
#ifdef CONFIG_DYNAMIC_FTRACE
-#ifdef CONFIG_64BIT
#define FTRACE_FRAME_SIZE (2*FRAME_SIZE)
-#else
-#define FTRACE_FRAME_SIZE FRAME_SIZE
-#endif
ENTRY_CFI(ftrace_caller, caller,frame=FTRACE_FRAME_SIZE,CALLS,SAVE_RP,SAVE_SP)
ftrace_caller:
.global ftrace_caller
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -146,7 +146,7 @@ int ftrace_make_call(struct dyn_ftrace *
#else
u32 ftrace_trampoline[] = {
(u32)addr,
- 0x6fc10080, /* stw,ma r1,40(sp) */
+ 0x6fc10100, /* stw,ma r1,80(sp) */
0x48213fd1, /* ldw -18(r1),r1 */
0xe820c002, /* bv,n r0(r1) */
0xe83f1fdf, /* b,l,n .-c,r1 */
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 588/742] parisc: irq: Trace hardirq state in do_cpu_irq_mask()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (578 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 587/742] parisc: Fix register corruption in 32-bit dynamic ftrace Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 589/742] objtool/rust: add more `noreturn` Rust functions for Rust 1.101.0 Greg Kroah-Hartman
` (146 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Karl Mehltretter, Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <kmehltretter@gmail.com>
commit a739c9192173c0437ed3c76f87f5a39532ef9fe1 upstream.
intr_extint calls do_cpu_irq_mask() with PSW[I] already clear. Since
commit 044d0d6de9f5 ("lockdep: Only trace IRQ edges"), its
local_irq_disable() then skips trace_hardirqs_off(), and lockdep
assertions fail in the timer tick:
WARNING: kernel/rcu/tree.c:2739 at rcu_sched_clock_irq+0x618/0x1f84
The return to a context with PSW[I] set has not been annotated since
TRACE_IRQFLAGS_SUPPORT was enabled. Annotate both transitions.
Fixes: 366dd4ea9d5f ("parisc: Fix ftrace function tracer")
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Cc: stable@vger.kernel.org # v5.9+
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/parisc/kernel/irq.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/arch/parisc/kernel/irq.c
+++ b/arch/parisc/kernel/irq.c
@@ -497,7 +497,7 @@ asmlinkage void do_cpu_irq_mask(struct p
#endif
old_regs = set_irq_regs(regs);
- local_irq_disable();
+ trace_hardirqs_off();
irq_enter_rcu();
eirr_val = mfctl(23) & cpu_eiem & per_cpu(local_ack_eiem, cpu);
@@ -535,6 +535,8 @@ asmlinkage void do_cpu_irq_mask(struct p
out:
irq_exit_rcu();
set_irq_regs(old_regs);
+ if (!irqs_disabled_flags(regs->gr[0]))
+ trace_hardirqs_on();
return;
set_out:
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 589/742] objtool/rust: add more `noreturn` Rust functions for Rust 1.101.0
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (579 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 588/742] parisc: irq: Trace hardirq state in do_cpu_irq_mask() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 590/742] ocfs2/dlmfs: keep the superblock alive during lock work Greg Kroah-Hartman
` (145 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Josh Poimboeuf, Peter Zijlstra,
Gary Guo, Miguel Ojeda
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miguel Ojeda <ojeda@kernel.org>
commit 1846c049cfe325abe0be8d1ea50eda16aa02d1a8 upstream.
Starting with Rust 1.101.0 (expected 2026-12-24), `objtool` may report:
rust/kernel.o: warning: objtool: _R..._6kernel3pci2ioINtB7_6DeviceNtNtB9_6device5BoundE8cfg_size()
falls through to next function _R..._6kernel3oppNtB5_3OPP18from_raw_opp_owned()
(and others) due to calls to the `noreturn` symbol:
core::panicking::unreachable_default_msg
Rust now outlines the constant messages of the panicking macros [1],
thus `unreachable!()` (i.e. without arguments) calls that new function
instead of `core::panicking::panic`, which is already in the list.
The same change introduced the equivalent `noreturn` functions for
`panic!()`, `todo!()` and `unimplemented!()`, which lead to the same
warning when those are used:
core::panicking::panic_default_msg
core::panicking::todo_default_msg
core::panicking::unimplemented_default_msg
Thus add the mangled ones to the list so that `objtool` knows they are
actually `noreturn`.
See commit 56d680dd23c3 ("objtool/rust: list `noreturn` Rust functions")
for more details.
Cc: stable@vger.kernel.org # 6.12.x (Rust is pinned in older LTSs)
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://github.com/rust-lang/rust/pull/163766 [1]
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20261114001708.80599-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
tools/objtool/check.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -206,9 +206,13 @@ static bool is_rust_noreturn(const struc
str_ends_with(func->name, "_4core9panicking9panic_fmt") ||
str_ends_with(func->name, "_4core9panicking14panic_explicit") ||
str_ends_with(func->name, "_4core9panicking14panic_nounwind") ||
+ str_ends_with(func->name, "_4core9panicking16todo_default_msg") ||
+ str_ends_with(func->name, "_4core9panicking17panic_default_msg") ||
str_ends_with(func->name, "_4core9panicking18panic_bounds_check") ||
str_ends_with(func->name, "_4core9panicking18panic_nounwind_fmt") ||
str_ends_with(func->name, "_4core9panicking19assert_failed_inner") ||
+ str_ends_with(func->name, "_4core9panicking23unreachable_default_msg") ||
+ str_ends_with(func->name, "_4core9panicking25unimplemented_default_msg") ||
str_ends_with(func->name, "_4core9panicking30panic_null_pointer_dereference") ||
str_ends_with(func->name, "_4core9panicking32panic_null_reference_constructed") ||
str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference") ||
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 590/742] ocfs2/dlmfs: keep the superblock alive during lock work
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (580 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 589/742] objtool/rust: add more `noreturn` Rust functions for Rust 1.101.0 Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 591/742] ocfs2: advance locking_state through the live cursor Greg Kroah-Hartman
` (144 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Cen Zhang, Andrew Morton, Joseph Qi,
Mark Fasheh, Joel Becker, Heming Zhao, Jia-Ju Bai, jjzuming
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <zzzccc427@gmail.com>
commit e9e66aa5ef1a76ec92fe41c5eb16fda7a39db279 upstream.
Queued dlmfs lock work holds an inode reference, but no active reference
to its superblock. The workqueue is drained on module exit rather than on
each dlmfs unmount, and an inode reference does not stop superblock
shutdown: generic_shutdown_super() reports the busy inode and goes on.
DLM callback / worker Unmount
--------------------- -------
queue lock work; igrab(inode)
worker delayed
drop last active superblock ref
kill_anon_super()
report the busy inode
free the superblock
finish lock work
iput(inode)
access the inode's freed superblock
Flushing the workqueue from a dlmfs kill_sb would not be enough: a
blocking AST can queue new work for an inode that is still alive after the
flush and before eviction, and that work again holds only an inode
reference.
Take an active superblock reference before acquiring the queued inode
reference, with the atomic_inc_not_zero() on s_active that grab_super()
and the NFS and procfs superblock walkers use. Decline to queue if the
superblock is already shutting down; the inode is then being evicted and
user_dlm_destroy_lock() tears the lock down. The existing l_lock and
USER_LOCK_QUEUED flag serialize this with other queue attempts. Each
execution drops its inode reference before releasing the active superblock
reference, outside l_lock. If that releases the last active reference,
the unmount completes on the worker; it only waits for DLM replies and
never for this workqueue.
Only the relevant frames of the report are kept:
Oops: general protection fault, probably for non-canonical address 0xfbd59c0000000026: 0000 [#1] SMP KASAN NOPTI
KASAN: maybe wild-memory-access in range [0xdead000000000130-0xdead000000000137]
Workqueue: user_dlm user_dlm_unblock_lock
RIP: 0010:iput+0x246/0xc10
Call Trace:
<TASK>
user_dlm_unblock_lock+0x503/0xa50
process_one_work+0x9a8/0x1b40
worker_thread+0x65c/0xe40
</TASK>
Link: https://lore.kernel.org/pm-ocfs2-objects-candidate-0054-v6-c3887cceae3b039e591e@gmail.com
Fixes: 8df08c89c668 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem")
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Heming Zhao <heming.zhao@suse.com>
Cc: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: <jjzuming@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ocfs2/dlmfs/userdlm.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
---
fs/ocfs2/dlmfs/userdlm.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
--- a/fs/ocfs2/dlmfs/userdlm.c
+++ b/fs/ocfs2/dlmfs/userdlm.c
@@ -162,7 +162,13 @@ static void user_dlm_unblock_lock(struct
static void __user_dlm_queue_lockres(struct user_lock_res *lockres)
{
+ struct inode *inode = user_dlm_inode_from_user_lockres(lockres);
+
if (!(lockres->l_flags & USER_LOCK_QUEUED)) {
+ /* Pin the superblock through the worker's iput(). */
+ if (!atomic_inc_not_zero(&inode->i_sb->s_active))
+ return;
+
user_dlm_grab_inode_ref(lockres);
INIT_WORK(&lockres->l_work, user_dlm_unblock_lock);
@@ -275,9 +281,11 @@ static struct ocfs2_locking_protocol use
static inline void user_dlm_drop_inode_ref(struct user_lock_res *lockres)
{
- struct inode *inode;
- inode = user_dlm_inode_from_user_lockres(lockres);
+ struct inode *inode = user_dlm_inode_from_user_lockres(lockres);
+ struct super_block *sb = inode->i_sb;
+
iput(inode);
+ deactivate_super(sb);
}
static void user_dlm_unblock_lock(struct work_struct *work)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 591/742] ocfs2: advance locking_state through the live cursor
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (581 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 590/742] ocfs2/dlmfs: keep the superblock alive during lock work Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 592/742] ocfs2: fix kernel BUG in ocfs2_page_mkwrite() when write_end fails Greg Kroah-Hartman
` (143 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Cen Zhang, Andrew Morton, Joseph Qi,
Mark Fasheh, Joel Becker, Heming Zhao, Jia-Ju Bai, jjzuming
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <zzzccc427@gmail.com>
commit fffc86cbe3ebfd7fea3937f8698e4322b3137984 upstream.
locking_state copies each lock resource under ocfs2_dlm_tracking_lock so
its containing inode or quota object can be freed during the dump. The
copied l_debug_list pointers do not have that lifetime protection. Yet
ocfs2_dlm_seq_next() follows them to find the next record.
Remounting read-only can free a quota-info object while a debugfs read is
between the snapshot and the next iterator callback:
locking_state reader Quota suspension
-------------------- ----------------
snapshot current lock resource
copy l_debug_list.next
remove next resource from live list
free quota-info object
seq_next(): follow copied link
read freed lock resource
Advance through the live dummy cursor instead. List removal updates its
links under the tracking lock. Position it after the resource being
copied before releasing the lock, and never walk the snapshot's links.
Reuse the per-open snapshot for a nonzero seq_start() position, including
read continuation and buffer retries. Rewind the live cursor only when
seq_file starts at index zero; seq_lseek() traverses from there through
seq_next(). Clear the snapshot's l_ops marker at end of list so later
reads remain at EOF. This avoids replaying the list prefix under the
tracking lock on each read, without adding a new cursor or position field.
KASAN report as below:
BUG: KASAN: slab-use-after-free in ocfs2_dlm_next_res.isra.0+0x1b1/0x1d0
Read of size 8 at addr ffff888117ea9838 by task python3/489
CPU: 3 UID: 0 PID: 489 Comm: python3 Not tainted 7.3.0-rc4-next-20260921-pmb-bt-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
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? ocfs2_dlm_next_res.isra.0+0x1b1/0x1d0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20e/0x420
? ocfs2_dlm_next_res.isra.0+0x1b1/0x1d0
kasan_report+0xe0/0x110
? ocfs2_dlm_next_res.isra.0+0x1b1/0x1d0
ocfs2_dlm_next_res.isra.0+0x1b1/0x1d0
? __pfx_ocfs2_dlm_next_res.isra.0+0x10/0x10
? __pfx_do_raw_spin_lock+0x10/0x10
ocfs2_dlm_seq_next+0xb8/0x4c0
? srso_alias_return_thunk+0x5/0xfbef5
seq_read_iter+0x92f/0x1110
? srso_alias_return_thunk+0x5/0xfbef5
seq_read+0x362/0x5a0
? __pfx_seq_read+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? selinux_file_permission+0x11d/0x540
full_proxy_read+0x11f/0x180
? __pfx_full_proxy_read+0x10/0x10
vfs_read+0x1a0/0xc20
? srso_alias_return_thunk+0x5/0xfbef5
? kmem_cache_free+0x242/0x580
? __pfx_vfs_read+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? putname+0x93/0xe0
? srso_alias_return_thunk+0x5/0xfbef5
? do_sys_openat2+0x12a/0x1b0
? __pfx_do_sys_openat2+0x10/0x10
ksys_read+0x111/0x200
? __pfx_ksys_read+0x10/0x10
? irqentry_exit+0xbe/0x820
? srso_alias_return_thunk+0x5/0xfbef5
? trace_hardirqs_on_prepare+0x11d/0x150
do_syscall_64+0x114/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f0266dbb687
Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
RSP: 002b:00007ffccf76fc40 EFLAGS: 00000202 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007f0266d27780 RCX: 00007f0266dbb687
RDX: 0000000000000001 RSI: 00007f0266a53200 RDI: 0000000000000004
RBP: 00007f0266d27700 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000001
R13: 00007f0266a53200 R14: 0000000000000004 R15: 00007f0266b651e0
</TASK>
Allocated by task 547:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x28d/0x610
ocfs2_local_read_info+0x181/0x1580
dquot_load_quota_sb+0x68b/0x1000
dquot_load_quota_inode+0x227/0x3e0
ocfs2_enable_quotas+0x27c/0x520
ocfs2_fill_super+0x21f9/0x38f0
get_tree_bdev_flags+0x35d/0x5f0
vfs_get_tree+0x93/0x320
fc_mount+0x1d/0x200
path_mount+0x592/0x1e00
__x64_sys_mount+0x24b/0x2d0
do_syscall_64+0x114/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 577:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x308/0x580
ocfs2_local_free_info+0x47b/0x800
dquot_disable+0x5d9/0x17a0
ocfs2_susp_quotas.isra.0+0x22c/0x2b0
ocfs2_reconfigure+0x284/0xd00
reconfigure_super+0x3ca/0xa70
path_mount+0x16ae/0x1e00
__x64_sys_mount+0x24b/0x2d0
do_syscall_64+0x114/0x620
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff888117ea9800
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 56 bytes inside of
freed 1024-byte region [ffff888117ea9800, ffff888117ea9c00)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x117ea8
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x200000000000040(head|node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000040 ffff888100042dc0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000
head: 0200000000000040 ffff888100042dc0 dead000000000100 dead000000000122
head: 0000000000000000 0000000000100010 00000000f5000000 0000000000000000
head: 0200000000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888117ea9700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888117ea9780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888117ea9800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888117ea9880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888117ea9900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Link: https://lore.kernel.org/pm-ocfs2-objects-candidate-0053-v7-ec41d4bbd38bb4d795a8@gmail.com
Fixes: ccd979bdbce9 ("[PATCH] OCFS2: The Second Oracle Cluster Filesystem")
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Heming Zhao <heming.zhao@suse.com>
Cc: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: <jjzuming@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ocfs2/dlmglue.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
---
fs/ocfs2/dlmglue.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -3094,9 +3094,17 @@ static void *ocfs2_dlm_seq_start(struct
{
struct ocfs2_dlm_seq_priv *priv = m->private;
struct ocfs2_lock_res *iter;
+ struct ocfs2_lock_res *dummy = &priv->p_iter_res;
+
+ /* Continue or retry the snapshot left by ->next(). */
+ if (*pos)
+ return priv->p_tmp_res.l_ops ? &priv->p_tmp_res : NULL;
+ /* Reads from zero and seek traversal start at the list head. */
spin_lock(&ocfs2_dlm_tracking_lock);
- iter = ocfs2_dlm_next_res(&priv->p_iter_res, priv);
+ list_move(&dummy->l_debug_list,
+ &priv->p_dlm_debug->d_lockres_tracking);
+ iter = ocfs2_dlm_next_res(dummy, priv);
if (iter) {
/* Since lockres' have the lifetime of their container
* (which can be inodes, ocfs2_supers, etc) we want to
@@ -3105,8 +3113,11 @@ static void *ocfs2_dlm_seq_start(struct
* trust any pointers on the copy returned, but that's
* ok as the information we want isn't typically held
* in them. */
+ list_move(&dummy->l_debug_list, &iter->l_debug_list);
priv->p_tmp_res = *iter;
iter = &priv->p_tmp_res;
+ } else {
+ priv->p_tmp_res.l_ops = NULL;
}
spin_unlock(&ocfs2_dlm_tracking_lock);
@@ -3120,17 +3131,19 @@ static void ocfs2_dlm_seq_stop(struct se
static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos)
{
struct ocfs2_dlm_seq_priv *priv = m->private;
- struct ocfs2_lock_res *iter = v;
+ struct ocfs2_lock_res *iter;
struct ocfs2_lock_res *dummy = &priv->p_iter_res;
(*pos)++;
spin_lock(&ocfs2_dlm_tracking_lock);
- iter = ocfs2_dlm_next_res(iter, priv);
+ iter = ocfs2_dlm_next_res(dummy, priv);
list_del_init(&dummy->l_debug_list);
if (iter) {
list_add(&dummy->l_debug_list, &iter->l_debug_list);
priv->p_tmp_res = *iter;
iter = &priv->p_tmp_res;
+ } else {
+ priv->p_tmp_res.l_ops = NULL;
}
spin_unlock(&ocfs2_dlm_tracking_lock);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 592/742] ocfs2: fix kernel BUG in ocfs2_page_mkwrite() when write_end fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (582 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 591/742] ocfs2: advance locking_state through the live cursor Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 593/742] ocfs2: serialize inode journal access with shutdown Greg Kroah-Hartman
` (142 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zhiyuan Zhang, Andrew Morton,
syzbot+42984127d45ad96219de, Joseph Qi, Heming Zhao, Mark Fasheh,
Joel Becker, yangwenfang
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiyuan Zhang <zhiyuanzhang912@gmail.com>
commit 5158f371faceb185235ba42882e67a840cfd7f48 upstream.
syzbot reported a kernel BUG in the ocfs2 write fault path:
(syz.0.17,5578,0):ocfs2_write_end_nolock:1945 ERROR: status = -30
kernel BUG at fs/ocfs2/mmap.c:106!
Call Trace:
do_page_mkwrite+0x147/0x310 mm/memory.c:3879
do_shared_fault mm/memory.c:6145 [inline]
handle_mm_fault+0x1a53/0x3750 mm/memory.c:6943
__ocfs2_page_mkwrite() calls ocfs2_write_begin_nolock() and then
ocfs2_write_end_nolock(), and uses BUG_ON() to assert that the latter
returns the full length. But ocfs2_write_end_nolock() can fail: since
commit 7f27ec978b0e ("ocfs2: call ocfs2_journal_access_di() before
ocfs2_journal_dirty() in ocfs2_write_end_nolock()") it gets journal
access to the inode buffer again, because the handle may have been
restarted since ocfs2_write_begin_nolock(). That fails with -EROFS or
-EIO once the journal has been aborted or jbd2 has seen write errors
on the device. The syzbot reproducer gets there by shrinking the
backing loop device to zero with LOOP_SET_STATUS while writing to a
shared file mapping.
Handle the failure instead of crashing. ocfs2_write_end_nolock()
leaves the mmap folio locked, because ocfs2_unlock_folios() skips it
when w_target_locked is set so that it can be returned with
VM_FAULT_LOCKED, and do_page_mkwrite() does not unlock it either when
->page_mkwrite() returns an error. So unlock it and fail the fault;
the faulting task gets SIGBUS, like for the other errors in this
function.
For an mmap write ocfs2_write_end_nolock() returns either len or a
negative errno: inline data has already been converted to extents by
ocfs2_write_begin_nolock(), and copied is equal to len.
The BUG matters for local mounts, where the filesystem is expected to
go read-only and keep running after a journal abort. On clustered
mounts ocfs2_abort() panics the node anyway as soon as it notices the
aborted journal.
Link: https://lore.kernel.org/20261111023444.22688-1-zhiyuanzhang912@gmail.com
Fixes: 7f27ec978b0e ("ocfs2: call ocfs2_journal_access_di() before ocfs2_journal_dirty() in ocfs2_write_end_nolock()")
Signed-off-by: Zhiyuan Zhang <zhiyuanzhang912@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: <syzbot+42984127d45ad96219de@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=42984127d45ad96219de
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Heming Zhao <heming.zhao@suse.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: yangwenfang <vicky.yangwenfang@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ocfs2/mmap.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
---
fs/ocfs2/mmap.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -103,7 +103,17 @@ static vm_fault_t __ocfs2_page_mkwrite(s
goto out;
}
err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
- BUG_ON(err != len);
+ if (err != len) {
+ /*
+ * ocfs2_write_end_nolock() keeps the mmap folio locked so
+ * that it can be returned to the VM with VM_FAULT_LOCKED.
+ * On failure nobody else will unlock it, so do it here.
+ */
+ folio_unlock(locked_folio);
+ mlog_errno(err);
+ ret = vmf_error(err);
+ goto out;
+ }
ret = VM_FAULT_LOCKED;
out:
return ret;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 593/742] ocfs2: serialize inode journal access with shutdown
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (583 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 592/742] ocfs2: fix kernel BUG in ocfs2_page_mkwrite() when write_end fails Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 594/742] sctp: do not free a new asoc peeled off while sendmsg slept Greg Kroah-Hartman
` (141 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Cen Zhang, Andrew Morton, Joseph Qi,
Mark Fasheh, Joel Becker, Heming Zhao, Jia-Ju Bai, jjzuming
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <zzzccc427@gmail.com>
commit f277230d002d03ed98b814b735f9d3d01b42020a upstream.
The downconvert thread can run inode cleanup until ocfs2_dlm_shutdown()
stops it, but unmount shuts down the journal earlier. A final dentry
post-unlock put can therefore enter ocfs2_clear_inode() while the journal
is being destroyed.
ocfs2_ci_fully_checkpointed() loads osb->journal before taking
trans_inc_lock. Journal shutdown neither takes that lock for removal
nor waits for the downconvert thread before freeing the journal:
Downconvert thread Unmount
------------------ -------
dentry post-unlock; final iput()
ocfs2_checkpoint_inode()
load osb->journal
ocfs2_journal_shutdown()
free journal; clear pointer
read the transaction ID
The checkpoint wait queue is embedded in that journal, and the final
jbd2_journal_release_jbd_inode() also needs its JBD2 journal to remain
alive for the whole call. Protecting only the pointer load would leave
those longer uses unprotected.
Read and clear osb->journal under trans_inc_lock when checking checkpoint
progress. Treat a removed journal as checkpointed. Move checkpoint
waiters to the existing mount-owned checkpoint_event and wake it after
checkpoint progress and journal removal, so the queue outlives the
journal. The commit thread also waits there and rechecks its condition
when woken.
Serialize the final JBD2 inode release against JBD2 destruction and the
journal free with a mount-owned rw_semaphore. Take the write side only
after stopping the commit thread, and drop it before the journal inode's
final iput(), whose cleanup can take the read side. Inode cleanup holds
the read side only around the JBD2 release, outside checkpoint waits and
DLM lock teardown.
KASAN report as below:
Oops: general protection fault, probably for non-canonical address 0xdffffc000000000e: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000070-0x0000000000000077]
CPU: 0 UID: 0 PID: 587 Comm: ocfs2dc-33CAF04 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
RIP: 0010:ocfs2_clear_inode+0x8ae/0x1630
Code: fc ff df 48 c1 ea 03 80 3c 02 00 0f 85 27 0c 00 00 49 8d 7d 70 48 8b 43 c8 48 ba 00 00 00 00 00 fc ff df 48 89 f9 48 c1 e9 03 <80> 3c 11 00 0f 85 f0 0b 00 00 49 3b 45 70 0f 88 62 03 00 00 e8 49
RSP: 0018:ffff888118d3f878 EFLAGS: 00010212
RAX: 0000000000000001 RBX: ffff88811a5edc60 RCX: 000000000000000e
RDX: dffffc0000000000 RSI: 0000000000000001 RDI: 0000000000000070
RBP: ffff888116134000 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff8965765f R11: 0000000000000001 R12: ffff88811a5ed400
R13: 0000000000000000 R14: ffff88811a5edbf8 R15: ffff88811a5ed408
FS: 0000000000000000(0000) GS:ffff8881fd4dc000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ff35b66f2c0 CR3: 00000001092ae005 CR4: 0000000000770ef0
PKRU: 55555554
Call Trace:
<TASK>
? __pfx_ocfs2_clear_inode+0x10/0x10
? __pfx_ocfs2_inode_is_valid_to_delete+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __lock_acquire+0x5a3/0x2140
ocfs2_evict_inode+0x1ed/0x11e0
? inode_wait_for_writeback+0x14c/0x330
? __pfx_ocfs2_evict_inode+0x10/0x10
? lock_acquire+0x190/0x300
? srso_alias_return_thunk+0x5/0xfbef5
? find_held_lock+0x2b/0x80
? evict+0x347/0x9f0
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x290
? _raw_spin_unlock+0x23/0x40
? __pfx_ocfs2_evict_inode+0x10/0x10
evict+0x38b/0x9f0
? __pfx_evict+0x10/0x10
? lock_acquire+0x190/0x300
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x290
? __pfx_inode_just_drop+0x10/0x10
iput+0x680/0xb80
ocfs2_dentry_lock_put+0xc2/0x110
? __pfx_ocfs2_dentry_post_unlock+0x10/0x10
ocfs2_process_blocked_lock+0x1fb/0x420
? __pfx_ocfs2_process_blocked_lock+0x10/0x10
? __pfx_pmbd_probe_hit_cookie+0x10/0x10
? lock_release+0xc8/0x290
? srso_alias_return_thunk+0x5/0xfbef5
? lockdep_hardirqs_on_prepare+0xeb/0x1a0
? srso_alias_return_thunk+0x5/0xfbef5
ocfs2_downconvert_thread+0x32b/0x780
? do_raw_spin_lock+0x130/0x270
? __pfx_ocfs2_downconvert_thread+0x10/0x10
? __kthread_parkme+0xc1/0x220
? srso_alias_return_thunk+0x5/0xfbef5
? lock_release+0xc8/0x290
? __pfx_autoremove_wake_function+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? __kthread_parkme+0x177/0x220
? __pfx_ocfs2_downconvert_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 ]---
Link: https://lore.kernel.org/pm-ocfs2-objects-candidate-0004-v8-dbcb8f80b8df476084d6@gmail.com
Fixes: da5e7c87827e ("ocfs2: cleanup journal init and shutdown")
Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Heming Zhao <heming.zhao@suse.com>
Cc: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: <jjzuming@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ocfs2/inode.c | 17 +++++++++--------
fs/ocfs2/journal.c | 30 ++++++++++++++++++++++--------
fs/ocfs2/journal.h | 17 +++++++++--------
fs/ocfs2/ocfs2.h | 1 +
fs/ocfs2/super.c | 1 +
5 files changed, 42 insertions(+), 24 deletions(-)
---
fs/ocfs2/inode.c | 17 +++++++++--------
fs/ocfs2/journal.c | 30 ++++++++++++++++++++++--------
fs/ocfs2/journal.h | 17 +++++++++--------
fs/ocfs2/ocfs2.h | 1 +
fs/ocfs2/super.c | 1 +
5 files changed, 42 insertions(+), 24 deletions(-)
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -1318,15 +1318,16 @@ static void ocfs2_clear_inode(struct ino
oi->ip_blkno = 0ULL;
/*
- * ip_jinode is used to track txns against this inode. We ensure that
- * the journal is flushed before journal shutdown. Thus it is safe to
- * have inodes get cleaned up after journal shutdown.
+ * ip_jinode is used to track txns against this inode. The journal is
+ * flushed before it is shut down, so an inode cleaned up after that
+ * has nothing left to release. Hold the shutdown lock so a journal
+ * found here stays allocated until the release has finished.
*/
- if (!osb->journal)
- return;
-
- jbd2_journal_release_jbd_inode(osb->journal->j_journal,
- &oi->ip_jinode);
+ down_read(&osb->journal_shutdown_sem);
+ if (osb->journal)
+ jbd2_journal_release_jbd_inode(osb->journal->j_journal,
+ &oi->ip_jinode);
+ up_read(&osb->journal_shutdown_sem);
}
void ocfs2_evict_inode(struct inode *inode)
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -352,7 +352,7 @@ static int ocfs2_commit_cache(struct ocf
trace_ocfs2_commit_cache_end(journal->j_trans_id, flushed);
ocfs2_wake_downconvert_thread(osb);
- wake_up(&journal->j_checkpointed);
+ wake_up(&osb->checkpoint_event);
finally:
return status;
}
@@ -900,7 +900,6 @@ int ocfs2_journal_alloc(struct ocfs2_sup
atomic_set(&journal->j_num_trans, 0);
init_rwsem(&journal->j_trans_barrier);
- init_waitqueue_head(&journal->j_checkpointed);
spin_lock_init(&journal->j_lock);
journal->j_trans_id = 1UL;
INIT_LIST_HEAD(&journal->j_la_cleanups);
@@ -1072,12 +1071,14 @@ void ocfs2_journal_shutdown(struct ocfs2
journal = osb->journal;
if (!journal)
- goto done;
+ return;
inode = journal->j_inode;
- if (journal->j_state != OCFS2_JOURNAL_LOADED)
- goto done;
+ if (journal->j_state != OCFS2_JOURNAL_LOADED) {
+ down_write(&osb->journal_shutdown_sem);
+ goto free;
+ }
/* need to inc inode use count - jbd2_journal_destroy will iput. */
if (!igrab(inode))
@@ -1113,6 +1114,12 @@ void ocfs2_journal_shutdown(struct ocfs2
mlog_errno(status);
}
+ /*
+ * Exclude the final JBD2 inode cleanup in ocfs2_clear_inode() while
+ * the journal is destroyed and freed.
+ */
+ down_write(&osb->journal_shutdown_sem);
+
/* Shutdown the kernel journal system */
if (!jbd2_journal_destroy(journal->j_journal) && !status) {
/*
@@ -1135,10 +1142,17 @@ void ocfs2_journal_shutdown(struct ocfs2
journal->j_state = OCFS2_JOURNAL_FREE;
-done:
- iput(inode);
- kfree(journal);
+free:
+ /* Serialize the removal with ocfs2_ci_fully_checkpointed(). */
+ spin_lock(&trans_inc_lock);
osb->journal = NULL;
+ spin_unlock(&trans_inc_lock);
+ wake_up(&osb->checkpoint_event);
+ kfree(journal);
+ up_write(&osb->journal_shutdown_sem);
+
+ /* The journal inode's own cleanup takes the read side. */
+ iput(inode);
}
static void ocfs2_clear_journal_error(struct super_block *sb,
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -54,7 +54,6 @@ struct ocfs2_journal {
spinlock_t j_lock;
unsigned long j_trans_id;
struct rw_semaphore j_trans_barrier;
- wait_queue_head_t j_checkpointed;
/* both fields protected by j_lock*/
struct list_head j_la_cleanups;
@@ -91,11 +90,15 @@ static inline void ocfs2_set_ci_lock_tra
static inline int ocfs2_ci_fully_checkpointed(struct ocfs2_caching_info *ci)
{
int ret;
- struct ocfs2_journal *journal =
- OCFS2_SB(ocfs2_metadata_cache_get_super(ci))->journal;
+ struct ocfs2_super *osb =
+ OCFS2_SB(ocfs2_metadata_cache_get_super(ci));
+ struct ocfs2_journal *journal;
spin_lock(&trans_inc_lock);
- ret = time_after(journal->j_trans_id, ci->ci_last_trans);
+ journal = osb->journal;
+ /* A NULL journal has already completed checkpointing. */
+ ret = !journal ||
+ time_after(journal->j_trans_id, ci->ci_last_trans);
spin_unlock(&trans_inc_lock);
return ret;
}
@@ -196,9 +199,6 @@ static inline void ocfs2_checkpoint_inod
if (ocfs2_mount_local(osb))
return;
- if (!osb->journal)
- return;
-
if (!ocfs2_ci_fully_checkpointed(INODE_CACHE(inode))) {
/* WARNING: This only kicks off a single
* checkpoint. If someone races you and adds more
@@ -208,7 +208,8 @@ static inline void ocfs2_checkpoint_inod
* OK. */
ocfs2_start_checkpoint(osb);
- wait_event(osb->journal->j_checkpointed,
+ /* The wait queue must outlive journal shutdown. */
+ wait_event(osb->checkpoint_event,
ocfs2_ci_fully_checkpointed(INODE_CACHE(inode)));
}
}
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -388,6 +388,7 @@ struct ocfs2_super
enum ocfs2_recovery_state recovery_state;
wait_queue_head_t checkpoint_event;
struct ocfs2_journal *journal;
+ struct rw_semaphore journal_shutdown_sem;
unsigned long osb_commit_interval;
/* Journal triggers for checksum */
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -2048,6 +2048,7 @@ static int ocfs2_initialize_super(struct
}
init_waitqueue_head(&osb->checkpoint_event);
+ init_rwsem(&osb->journal_shutdown_sem);
osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 594/742] sctp: do not free a new asoc peeled off while sendmsg slept
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (584 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 593/742] ocfs2: serialize inode journal access with shutdown Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 595/742] sctp: use skb_set_transport_header_careful() in sctp_v6_err() Greg Kroah-Hartman
` (140 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Yves Bieri, Xin Long, Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yves Bieri <yves.bieri@theori.io>
commit f2540da93a113d3f0a70fd0961e00eb849ce8342 upstream.
When sctp_sendmsg() creates a new association and sending on it fails
with anything but -ESRCH, it frees the association. The send can
sleep in sctp_wait_for_sndbuf(), which releases the socket lock, and
meanwhile another thread can peel the new association off to a new
socket. The wait then returns -EPIPE, and sctp_sendmsg() frees an
association that now belongs to the peeled-off socket, without holding
that socket's lock.
If the peeled-off socket frees the association first, e.g. on close(),
sctp_sendmsg() frees it a second time. Otherwise a syscall running
concurrently on the peeled-off socket can use it after sctp_sendmsg()
freed it. Both are reachable by an unprivileged user. The double free
on net with KASAN:
BUG: KASAN: double-free in sctp_tsnmap_free+0x5c/0x80
sctp_association_free+0x1eb/0x750
sctp_sendmsg+0x15ff/0x2020
Freed by task 836:
sctp_association_free+0x1eb/0x750
sctp_primitive_ABORT+0x85/0xe0
sctp_close+0x22a/0x8d0
Commit dfcb9f4f99f1 ("sctp: deny peeloff operation on asocs with threads
sleeping on it") fixed this double free by denying the peeloff.
Commit cea0cc80a677 ("sctp: use the right sk after waking up from
wait_buf sleep") replaced that check, and commit a0ff660058b8 ("sctp:
return error if the asoc has been peeled off in sctp_wait_for_sndbuf")
reverted it to return -EPIPE, without restoring the check.
Fix this by holding a reference on the new association while sending
on it, and by freeing it on error only if this socket still owns it.
asoc->base.sk only changes in sctp_sock_migrate(), which runs with this
socket locked, so the ownership check is stable. The reference keeps
the check safe if the new owner frees the association meanwhile.
Userspace still gets -EPIPE, and the association stays with the socket
it was peeled off to.
This was found by Xint Code, an AI code review agent, and reproduced as
an unprivileged user on net with KASAN (trace above), without modifying
the kernel or using error injection. With this patch the sender gets
-EPIPE and the association keeps working on the peeled-off socket.
Without a peeloff, a failed send that created the association (EAGAIN,
EINTR) still frees it, and a peer ABORT while the sender sleeps still
frees it exactly once. The SCTP selftest sctp_vrf.sh passes. The
reproducer is available on request.
Fixes: a0ff660058b8 ("sctp: return error if the asoc has been peeled off in sctp_wait_for_sndbuf")
Cc: stable@vger.kernel.org
Signed-off-by: Yves Bieri <yves.bieri@theori.io>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20261112172149.27355-1-yves.bieri@theori.io
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/sctp/socket.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2063,6 +2063,11 @@ static int sctp_sendmsg(struct sock *sk,
asoc = transport->asoc;
new = true;
+ /* sctp_sendmsg_to_asoc() may release the socket lock,
+ * and the new asoc can be peeled off meanwhile. Hold
+ * it, and free it on error only if sk still owns it.
+ */
+ sctp_association_hold(asoc);
}
if (!sctp_style(sk, TCP) && !(sflags & SCTP_ADDR_OVER))
@@ -2084,8 +2089,11 @@ static int sctp_sendmsg(struct sock *sk,
/* Send msg to the asoc */
err = sctp_sendmsg_to_asoc(asoc, msg, msg_len, transport, sinfo);
- if (err < 0 && err != -ESRCH && new)
- sctp_association_free(asoc);
+ if (new) {
+ if (err < 0 && err != -ESRCH && asoc->base.sk == sk)
+ sctp_association_free(asoc);
+ sctp_association_put(asoc);
+ }
out_unlock:
release_sock(sk);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 595/742] sctp: use skb_set_transport_header_careful() in sctp_v6_err()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (585 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 594/742] sctp: do not free a new asoc peeled off while sendmsg slept Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 596/742] selftests/damon/sysfs_memcg_path_leak: define ksft_skip Greg Kroah-Hartman
` (139 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Justin Iurman,
Paolo Abeni
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <edumazet@kernel.org>
commit 13391f1a8c584e7c1addaea3fd47105d92cc724c upstream.
skb->transport_header is a 16-bit offset from skb->head, and U16_MAX is
reserved as the "not set" value. skb_set_transport_header() silently
truncates an offset that does not fit.
sctp_v6_err() stores @offset, computed by icmpv6_notify() from the
extension headers of the packet embedded in an ICMPv6 error. Should
the value be truncated, sctp_err_lookup() would read the SCTP header
at the wrong place.
Since commit 3744b0964d52 ("ipv6: Implement limits on extension header
parsing") a single chain is bounded to IP6_MAX_EXT_HDRS_CNT headers
(24576 bytes), so this needs a large skb->data - skb->head on top of it,
for instance after several nested decapsulations, each of them possibly
pulling its own extension header chain, since @offset is relative to
the IPv6 header embedded in the ICMPv6 error. No reproducer was written,
this is hardening.
Use skb_set_transport_header_careful() and ignore the ICMPv6 error if
the offset can not be stored. Do this before changing the network
header, so that nothing has to be restored on failure.
Fixes: 1a37e412a022 ("net: Use 16bits for *_headers fields of struct skbuff")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261113124625.4010206-5-edumazet@kernel.org
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/sctp/ipv6.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -170,8 +170,11 @@ static int sctp_v6_err(struct sk_buff *s
/* Fix up skb to look at the embedded net header. */
saveip = skb->network_header;
savesctp = skb->transport_header;
+ if (unlikely(!skb_set_transport_header_careful(skb, offset))) {
+ __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev), ICMP6_MIB_INERRORS);
+ return -EINVAL;
+ }
skb_reset_network_header(skb);
- skb_set_transport_header(skb, offset);
sk = sctp_err_lookup(net, AF_INET6, skb, sctp_hdr(skb), &asoc, &transport);
/* Put back, the original pointers. */
skb->network_header = saveip;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 596/742] selftests/damon/sysfs_memcg_path_leak: define ksft_skip
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (586 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 595/742] sctp: use skb_set_transport_header_careful() in sctp_v6_err() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 597/742] selftests/landlock: Test that layering does not break refer Greg Kroah-Hartman
` (138 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, SJ Park, Andrew Morton, Aveline Noir,
Shuah Khan, Wang Xiaolei
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: SJ Park <sj@kernel.org>
commit c8c47f4072bdcff783cedd5a8565242a212af058 upstream.
sysfs_memcg_path_leak test uses $ksft_skip without defining it. As a
result, the test is marked as passed while it was skipped, like below.
$ ./sysfs_memcg_path_leak.sh
Run as root
$ echo $?
0
Users who run the test could therefore wrongly believe the test was run
and passed while it was skipped.
Define the value at the beginning of the test. After this patch, the
exit code reflects the skip.
$ ./sysfs_memcg_path_leak.sh
Run as root
$ echo $?
4
Link: https://lore.kernel.org/20261102144627.88843-4-sj@kernel.org
Fixes: dfa3cf0bc018 ("selftets/damon: add a test for memcg_path leak")
Signed-off-by: SJ Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Closes: https://sashiko.dev/#/bug/linux-a0456336-0608-4fec-ac22-0ee61d1d6a91
Reviewed-by: Aveline Noir <jm5905938@gmail.com>
Tested-by: Aveline Noir <jm5905938@gmail.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Wang Xiaolei <xiaoleiwangxiaolei@gmail.com>
Cc: <stable@vger.kernel.org> # 6.17.x
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
tools/testing/selftests/damon/sysfs_memcg_path_leak.sh | 3 +++
1 file changed, 3 insertions(+)
--- a/tools/testing/selftests/damon/sysfs_memcg_path_leak.sh
+++ b/tools/testing/selftests/damon/sysfs_memcg_path_leak.sh
@@ -1,6 +1,9 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+
if [ $EUID -ne 0 ]
then
echo "Run as root"
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 597/742] selftests/landlock: Test that layering does not break refer
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (587 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 596/742] selftests/damon/sysfs_memcg_path_leak: define ksft_skip Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 598/742] selinux: check MAP_SHARED_VALIDATE mappings as shared Greg Kroah-Hartman
` (137 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Günther Noack,
Mickaël Salaün
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Günther Noack <gnoack3000@gmail.com>
commit 047e27306d268d6972f8242b69f50e5814b09282 upstream.
Regression test to exercise that layered Landlock domains do not
accidentally deny the LANDLOCK_ACCESS_FS_REFER access right. This
used to be the case when layering a non-filesystem ruleset with a
filesystem-enforcing ruleset. In that case, REFER operations that
would have been allowed for the individual rulesets would get denied
when layering the same rulesets.
Link: https://github.com/landlock-lsm/linux/issues/67
Link: https://github.com/landlock-lsm/go-landlock/issues/66
Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect")
Cc: stable@vger.kernel.org
Signed-off-by: Günther Noack <gnoack3000@gmail.com>
Link: https://patch.msgid.link/20261113-b4-landlock-refer-nonfs-layer-v3-3-02d7e42bcdfd@gmail.com
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
tools/testing/selftests/landlock/fs_test.c | 54 +++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -2620,6 +2620,60 @@ TEST_F_FORK(layout1, refer_denied_by_def
}
/*
+ * Regression test for layered domains: The two enforced Landlock layers both do
+ * not restrict the tested "refer" operations on their own, so they should also
+ * not restrict them when they are layered, regardless of the layer order.
+ */
+static void test_layering_does_not_break_refer(
+ struct __test_metadata *const _metadata,
+ const struct landlock_ruleset_attr *const non_fs_attr,
+ const bool non_fs_first)
+{
+ ASSERT_EQ(0, unlink(file1_s1d2));
+
+ if (non_fs_first)
+ drop_access_rights(_metadata, non_fs_attr);
+
+ enforce_fs(_metadata, LANDLOCK_ACCESS_FS_REFER, layer_dir_s1d1_refer);
+
+ if (!non_fs_first)
+ drop_access_rights(_metadata, non_fs_attr);
+
+ EXPECT_EQ(0, test_rename(file1_s1d1, file1_s1d2));
+ EXPECT_EQ(0, test_rename(file1_s1d2, file1_s1d1));
+ EXPECT_EQ(0, test_exchange(file2_s1d1, file2_s1d2));
+ EXPECT_EQ(0, test_exchange(file2_s1d2, file2_s1d1));
+}
+
+static const struct landlock_ruleset_attr net_attr = {
+ .handled_access_net = LANDLOCK_ACCESS_NET_BIND_TCP,
+};
+
+static const struct landlock_ruleset_attr scoped_attr = {
+ .scoped = LANDLOCK_SCOPE_SIGNAL,
+};
+
+TEST_F_FORK(layout1, layering_fs_then_net_does_not_break_refer)
+{
+ test_layering_does_not_break_refer(_metadata, &net_attr, false);
+}
+
+TEST_F_FORK(layout1, layering_net_then_fs_does_not_break_refer)
+{
+ test_layering_does_not_break_refer(_metadata, &net_attr, true);
+}
+
+TEST_F_FORK(layout1, layering_fs_then_scoped_does_not_break_refer)
+{
+ test_layering_does_not_break_refer(_metadata, &scoped_attr, false);
+}
+
+TEST_F_FORK(layout1, layering_scoped_then_fs_does_not_break_refer)
+{
+ test_layering_does_not_break_refer(_metadata, &scoped_attr, true);
+}
+
+/*
* Tests walking through a denied root mount.
*/
TEST_F_FORK(layout1, refer_mount_root_deny)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 598/742] selinux: check MAP_SHARED_VALIDATE mappings as shared
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (588 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 597/742] selftests/landlock: Test that layering does not break refer Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 599/742] spi: Fix runtime PM imbalance on pump transfer message error Greg Kroah-Hartman
` (136 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Stephen Smalley, Paul Moore
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Smalley <stephen.smalley.work@gmail.com>
commit beb0ae6bcd7505e2e61babe5d98a8dd3b3f03c7f upstream.
selinux_mmap_file() only recognizes MAP_SHARED as a shared mapping,
but MAP_SHARED_VALIDATE is also a shared mapping type. The mmap flags
reach this hook before the mm code processes the mapping type.
Consequently, a writable MAP_SHARED_VALIDATE mapping was failing to
check the file write permission at mmap time, and a writable
executable file mapping was wrongly checking process execmem
permission as if it were private.
Cc: stable@vger.kernel.org
Link: https://github.com/SELinuxProject/selinux-kernel/issues/78
Fixes: 1c9725974074 ("mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap flags")
Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/selinux/hooks.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4173,8 +4173,11 @@ static int selinux_mmap_file(struct file
unsigned long reqprot __always_unused,
unsigned long prot, unsigned long flags)
{
+ const unsigned long map_type = (flags & MAP_TYPE);
+
return selinux_mmap_file_common(file, prot,
- (flags & MAP_TYPE) == MAP_SHARED,
+ (map_type == MAP_SHARED ||
+ map_type == MAP_SHARED_VALIDATE),
false);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 599/742] spi: Fix runtime PM imbalance on pump transfer message error
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (589 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 598/742] selinux: check MAP_SHARED_VALIDATE mappings as shared Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 600/742] tcp: Fix the SO_REUSEPORT bind cache admitting a conflicting socket Greg Kroah-Hartman
` (135 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sebastian Reichel, Alexander Shiyan,
Mark Brown
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <sebastian.reichel@collabora.com>
commit bb5caf7a2e0b2dae8e8905d32fc376703eabcfc4 upstream.
The current SPI message pumping code may drop the runtime PM twice when
an SPI message cannot be sent:
spi_master spi2: noqueue transfer failed
rockchip-spi feb20000.spi: Runtime PM usage count underflow!
Fix the problem by always keeping the runtime PM count increased when
exiting __spi_pump_transfer_message(), as the caller handles decreasing
it.
Note, that the function already keeps the RPM usage counter increased
for the error paths following after the prepare_transfer_hardware step.
Cc: stable@vger.kernel.org
Fixes: bef4a48f4ef7 ("spi: Fix null dereference on suspend")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Tested-by: Alexander Shiyan <eagle.alexander923@gmail.com>
Link: https://patch.msgid.link/20261110-spi-runtime-pm-fix-v1-1-8601ebb2f6a8@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/spi/spi.c | 4 ----
1 file changed, 4 deletions(-)
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1942,7 +1942,6 @@ static int __spi_pump_transfer_message(s
if (!was_busy && ctlr->auto_runtime_pm) {
ret = pm_runtime_get_sync(ctlr->dev.parent);
if (ret < 0) {
- pm_runtime_put_noidle(ctlr->dev.parent);
dev_err(&ctlr->dev, "Failed to power device: %d\n",
ret);
@@ -1963,9 +1962,6 @@ static int __spi_pump_transfer_message(s
"failed to prepare transfer hardware: %d\n",
ret);
- if (ctlr->auto_runtime_pm)
- pm_runtime_put(ctlr->dev.parent);
-
msg->status = ret;
spi_finalize_current_message(ctlr);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 600/742] tcp: Fix the SO_REUSEPORT bind cache admitting a conflicting socket
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (590 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 599/742] spi: Fix runtime PM imbalance on pump transfer message error Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 601/742] thermal: int340x: processor_thermal: Fix Nova Lake-S PCI device ID Greg Kroah-Hartman
` (134 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Juan Agustin Niccolini,
Kuniyuki Iwashima, Eric Dumazet, Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juan Agustin Niccolini <juanagusnicco@gmail.com>
commit f675070191f202010b010160b509a543dd232ae6 upstream.
When the port is in the FASTREUSEPORT_STRICT state, inet_csk_get_port()
skips the bind conflict check if sk_reuseport_match() finds the new
socket's address covered by the socket cached in tb->fast_*.
This is only safe if both sockets match on everything
inet_bind_conflict() reads. The cache misses some of it:
- It does not record sk_bound_dev_if or sk_reuse.
- It records the family and IPV6_V6ONLY but never compares them with
the new socket, so a cached v6only [::] (or 0.0.0.0) socket covers
a dual-stack [::] socket.
As a result, an unprivileged user can bind and listen on a port that
another user is listening on, for example a dual-stack [::] socket on
top of a 0.0.0.0 listener:
victim: bind(0.0.0.0:P), listen()
attacker: SO_REUSEPORT + IPV6_V6ONLY, bind([::]:P) /* fills cache */
attacker: SO_REUSEPORT, bind([::]:P), listen() /* should fail */
Only take the fast path when the new socket matches the cached one in
family, IPV6_V6ONLY, bound device and SO_REUSEADDR. Identical
SO_REUSEPORT listeners, the workload this cache was added for, still
skip the scan (binding 16384 of them: 9.80 ms before, 9.86 ms after,
5874 ms with the full check every time).
Fixes: 637bc8bbe6c0 ("inet: reset tb->fastreuseport when adding a reuseport sk")
Cc: stable@vger.kernel.org
Signed-off-by: Juan Agustin Niccolini <juanagusnicco@gmail.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/20261111174704.24312-2-juanagusnicco@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/net/inet_hashtables.h | 2 ++
net/ipv4/inet_connection_sock.c | 15 ++++++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -87,6 +87,8 @@ struct inet_bind_bucket {
__be32 fast_rcv_saddr;
unsigned short fast_sk_family;
bool fast_ipv6_only;
+ unsigned char fast_sk_reuse;
+ int fast_bound_dev_if;
struct hlist_node node;
struct hlist_head bhash2;
struct rcu_head rcu;
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -420,13 +420,18 @@ static inline int sk_reuseport_match(str
return 0;
if (!uid_eq(tb->fastuid, sk_uid(sk)))
return 0;
- /* We only need to check the rcv_saddr if this tb was once marked
+ /* We only need to check the fast_* fields if this tb was once marked
* without fastreuseport and then was reset, as we can only know that
- * the fast_*rcv_saddr doesn't have any conflicts with the socks on the
- * owners list.
+ * the socket they describe doesn't have any conflicts with the socks
+ * on the owners list.
*/
if (tb->fastreuseport == FASTREUSEPORT_ANY)
return 1;
+ if (tb->fast_sk_family != sk->sk_family ||
+ tb->fast_ipv6_only != ipv6_only_sock(sk) ||
+ tb->fast_bound_dev_if != sk->sk_bound_dev_if ||
+ tb->fast_sk_reuse != sk->sk_reuse)
+ return 0;
#if IS_ENABLED(CONFIG_IPV6)
if (tb->fast_sk_family == AF_INET6)
return ipv6_rcv_saddr_equal(&tb->fast_v6_rcv_saddr,
@@ -455,6 +460,8 @@ void inet_csk_update_fastreuse(const str
tb->fast_rcv_saddr = sk->sk_rcv_saddr;
tb->fast_ipv6_only = ipv6_only_sock(sk);
tb->fast_sk_family = sk->sk_family;
+ tb->fast_sk_reuse = sk->sk_reuse;
+ tb->fast_bound_dev_if = sk->sk_bound_dev_if;
#if IS_ENABLED(CONFIG_IPV6)
tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
#endif
@@ -482,6 +489,8 @@ void inet_csk_update_fastreuse(const str
tb->fast_rcv_saddr = sk->sk_rcv_saddr;
tb->fast_ipv6_only = ipv6_only_sock(sk);
tb->fast_sk_family = sk->sk_family;
+ tb->fast_sk_reuse = sk->sk_reuse;
+ tb->fast_bound_dev_if = sk->sk_bound_dev_if;
#if IS_ENABLED(CONFIG_IPV6)
tb->fast_v6_rcv_saddr = sk->sk_v6_rcv_saddr;
#endif
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 601/742] thermal: int340x: processor_thermal: Fix Nova Lake-S PCI device ID
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (591 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 600/742] tcp: Fix the SO_REUSEPORT bind cache admitting a conflicting socket Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 602/742] ublk: dispatch the next fetch after a batch failure Greg Kroah-Hartman
` (133 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sankara Tankala, Srinivas Pandruvada,
Rafael J. Wysocki
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sankara Tankala <sankara.narayana@intel.com>
commit 22139b5a46353184f43d120b569b01447843d363 upstream.
Nova Lake-S uses the same processor thermal PCI device ID as Nova
Lake-H, 0xD703. The 0xAD03 ID added for Nova Lake-S is the Arrow
Lake-S ID (PCI_DEVICE_ID_INTEL_ARL_S_THERMAL).
The ARL-S entry comes first in the PCI ID table, so the NVL-S entry
never matched. However, proc_thermal_rfim_add() matches on the device
ID alone, so Arrow Lake-S, which has DLVR, wrongly gets the Nova Lake
DLVR register map.
Replace the separate NVL_H and NVL_S IDs with a single NVL ID, 0xD703,
and drop the 0xAD03 entries.
Fixes: af1b80b94126 ("thermal: int340x: processor_thermal: Add Nova Lake processor thermal device")
Fixes: dbd911a07f14 ("thermal: intel: int340x: Add DLVR support for Nova Lake")
Cc: stable@vger.kernel.org
Signed-off-by: Sankara Tankala <sankara.narayana@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://patch.msgid.link/20261113154001.2081-1-sankara.narayana@intel.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/thermal/intel/int340x_thermal/processor_thermal_device.h | 3 +--
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c | 7 +------
drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c | 3 +--
3 files changed, 3 insertions(+), 10 deletions(-)
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.h
@@ -27,8 +27,7 @@
#define PCI_DEVICE_ID_INTEL_JSL_THERMAL 0x4E03
#define PCI_DEVICE_ID_INTEL_LNLM_THERMAL 0x641D
#define PCI_DEVICE_ID_INTEL_MTLP_THERMAL 0x7D03
-#define PCI_DEVICE_ID_INTEL_NVL_H_THERMAL 0xD703
-#define PCI_DEVICE_ID_INTEL_NVL_S_THERMAL 0xAD03
+#define PCI_DEVICE_ID_INTEL_NVL_THERMAL 0xD703
#define PCI_DEVICE_ID_INTEL_RPL_THERMAL 0xA71D
#define PCI_DEVICE_ID_INTEL_SKL_THERMAL 0x1903
#define PCI_DEVICE_ID_INTEL_TGL_THERMAL 0x9A03
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
@@ -501,12 +501,7 @@ static const struct pci_device_id proc_t
PROC_THERMAL_FEATURE_DVFS | PROC_THERMAL_FEATURE_WT_HINT |
PROC_THERMAL_FEATURE_POWER_FLOOR | PROC_THERMAL_FEATURE_PTC |
PROC_THERMAL_FEATURE_SOC_POWER_SLIDER) },
- { PCI_DEVICE_DATA(INTEL, NVL_H_THERMAL, PROC_THERMAL_FEATURE_RAPL |
- PROC_THERMAL_FEATURE_DLVR | PROC_THERMAL_FEATURE_DVFS |
- PROC_THERMAL_FEATURE_MSI_SUPPORT | PROC_THERMAL_FEATURE_WT_HINT |
- PROC_THERMAL_FEATURE_POWER_FLOOR | PROC_THERMAL_FEATURE_PTC |
- PROC_THERMAL_FEATURE_SOC_POWER_SLIDER) },
- { PCI_DEVICE_DATA(INTEL, NVL_S_THERMAL, PROC_THERMAL_FEATURE_RAPL |
+ { PCI_DEVICE_DATA(INTEL, NVL_THERMAL, PROC_THERMAL_FEATURE_RAPL |
PROC_THERMAL_FEATURE_DLVR | PROC_THERMAL_FEATURE_DVFS |
PROC_THERMAL_FEATURE_MSI_SUPPORT | PROC_THERMAL_FEATURE_WT_HINT |
PROC_THERMAL_FEATURE_POWER_FLOOR | PROC_THERMAL_FEATURE_PTC |
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c
@@ -472,8 +472,7 @@ int proc_thermal_rfim_add(struct pci_dev
dlvr_mmio_regs_table = lnl_dlvr_mmio_regs;
dlvr_mapping = lnl_dlvr_mapping;
break;
- case PCI_DEVICE_ID_INTEL_NVL_H_THERMAL:
- case PCI_DEVICE_ID_INTEL_NVL_S_THERMAL:
+ case PCI_DEVICE_ID_INTEL_NVL_THERMAL:
dlvr_mmio_regs_table = nvl_dlvr_mmio_regs;
ddr_data_rate_reg = &nvl_ddr_data_rate_reg;
break;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 602/742] ublk: dispatch the next fetch after a batch failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (592 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 601/742] thermal: int340x: processor_thermal: Fix Nova Lake-S PCI device ID Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 603/742] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap() Greg Kroah-Hartman
` (132 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Ming Lei, Jens Axboe
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit a6f37fb3f5747bb7cca5cd6630dfeea4435022a1 upstream.
When a batch fetch fails, for example because its provided-buffer group
is empty, ublk_batch_dispatch() removes the failed fetch and returns.
Pending I/O tags stay in evts_fifo even if another fetch with usable
buffers is already queued. With no new I/O or fetch submission to select
it, that fetch and the outstanding block requests cannot make progress.
Claim the next queued fetch under evts_lock before completing and freeing
the failed one, then schedule its dispatch in the proper task context.
Marking it active before dropping the lock also prevents cancellation
from taking it before its task work is queued.
Fixes: a4d883755399 ("ublk: add UBLK_U_IO_FETCH_IO_CMDS for batch I/O processing")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Link: https://patch.msgid.link/20261115003352168cE_tyVxSyZV124AM31htL@zte.com.cn
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/block/ublk_drv.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -835,23 +835,27 @@ static void __ublk_release_fcmd(struct u
WRITE_ONCE(ubq->active_fcmd, NULL);
}
-/*
- * Nothing can move on, so clear ->active_fcmd, and the caller should stop
- * dispatching
- */
-static void ublk_batch_deinit_fetch_buf(struct ublk_queue *ubq,
- const struct ublk_batch_io_data *data,
- struct ublk_batch_fetch_cmd *fcmd,
- int res)
+static struct ublk_batch_fetch_cmd *__ublk_acquire_fcmd(struct ublk_queue *ubq);
+
+/* Remove the failed fetch and claim the next one before dropping its reference. */
+static struct ublk_batch_fetch_cmd *
+ublk_batch_deinit_fetch_buf(struct ublk_queue *ubq,
+ const struct ublk_batch_io_data *data,
+ struct ublk_batch_fetch_cmd *fcmd,
+ int res)
{
+ struct ublk_batch_fetch_cmd *next_fcmd;
+
spin_lock(&ubq->evts_lock);
list_del_init(&fcmd->node);
WARN_ON_ONCE(fcmd != ubq->active_fcmd);
__ublk_release_fcmd(ubq);
+ next_fcmd = __ublk_acquire_fcmd(ubq);
spin_unlock(&ubq->evts_lock);
io_uring_cmd_done(fcmd->cmd, res, data->issue_flags);
ublk_batch_free_fcmd(fcmd);
+ return next_fcmd;
}
static int ublk_batch_fetch_post_cqe(struct ublk_batch_fetch_cmd *fcmd,
@@ -2040,7 +2044,10 @@ again:
}
if (ret < 0) {
- ublk_batch_deinit_fetch_buf(ubq, data, fcmd, ret);
+ new_fcmd = ublk_batch_deinit_fetch_buf(ubq, data, fcmd, ret);
+ if (new_fcmd)
+ io_uring_cmd_complete_in_task(new_fcmd->cmd,
+ ublk_batch_tw_cb);
return;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 603/742] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (593 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 602/742] ublk: dispatch the next fetch after a batch failure Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 604/742] userfaultfd: clear uffd state in child PTEs if uffd is released during fork Greg Kroah-Hartman
` (131 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Eric Dumazet, Stefano Brivio,
Justin Iurman, Paolo Abeni
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <edumazet@kernel.org>
commit 02f578b736f1524ed73ef879fb1cf1ba4a875aa4 upstream.
skb->transport_header is a 16-bit offset from skb->head, and U16_MAX is
reserved as the "not set" value. skb_set_transport_header() silently
truncates an offset that does not fit.
__udp6_lib_err_encap() stores @offset, computed by icmpv6_notify() from
the extension headers of the packet embedded in an ICMPv6 error. Should
the value be truncated, the tunnel encap_err_lookup() and err_handler()
callbacks would read the UDP header at the wrong place.
Since commit 3744b0964d52 ("ipv6: Implement limits on extension header
parsing") a single chain is bounded to IP6_MAX_EXT_HDRS_CNT headers
(24576 bytes), so this needs a large skb->data - skb->head on top of it,
for instance after several nested decapsulations, each of them possibly
pulling its own extension header chain, since @offset is relative to
the IPv6 header embedded in the ICMPv6 error. No reproducer was written,
this is hardening.
Use skb_set_transport_header_careful() and return an error if the
offset can not be stored, in which case udpv6_err() ignores the
ICMPv6 error. Do this before changing the network header, so that
nothing has to be restored on failure.
Fixes: a36e185e8c85 ("udp: Handle ICMP errors for tunnels with same destination port on both endpoints")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Link: https://patch.msgid.link/20261113124625.4010206-6-edumazet@kernel.org
Reviewed-by: Justin Iurman <justin.iurman@gmail.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/ipv6/udp.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -651,12 +651,13 @@ static struct sock *__udp6_lib_err_encap
network_offset = skb_network_offset(skb);
transport_offset = skb_transport_offset(skb);
+ /* Transport header needs to point to the UDP header */
+ if (unlikely(!skb_set_transport_header_careful(skb, offset)))
+ return ERR_PTR(-EINVAL);
+
/* Network header needs to point to the outer IPv6 header inside ICMP */
skb_reset_network_header(skb);
- /* Transport header needs to point to the UDP header */
- skb_set_transport_header(skb, offset);
-
if (sk) {
up = udp_sk(sk);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 604/742] userfaultfd: clear uffd state in child PTEs if uffd is released during fork
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (594 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 603/742] udp: use skb_set_transport_header_careful() in __udp6_lib_err_encap() Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 605/742] vgacon: Fall back to the dummy console if mapping VGA memory fails Greg Kroah-Hartman
` (130 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Mike Rapoport (Microsoft),
Andrew Morton, Jose A. Perez de Azpillaga, Tal Zussman, Peter Xu
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Rapoport (Microsoft) <rppt@kernel.org>
commit 111894c595a078d8481db34f3355e8531990668e upstream.
With UFFD_FEATURE_EVENT_FORK the userfaultfd context is duplicated for the
child process, the child VMAs are registered with the new context, and
uffd protection state from the parent PTEs is copied into the child.
If the parent's userfaultfd is released before the fork event is read,
userfaultfd_release_new() resets the VMA flags but keeps uffd state in the
child PTEs.
This leaves the child's VMAs in an inconsistent state: they are not
registered with userfaultfd but their mappings carry uffd protection
state.
If the child registers the range with userfaultfd again, the stale state
turns into protection the child never asked for.
When a write fault makes such a PTE writable without copying the page, the
uffd bit remains set and page_table_check_pte_flags() warns about it.
Split resolving of the uffd PTE state out of userfaultfd_clear_vma() and
call it from userfaultfd_release_new() before resetting the VMA.
Link: https://lore.kernel.org/20261031-uffd-prot-bits-fork-event-v2-1-c448e57df417@kernel.org
Fixes: f369b07c8614 ("mm/uffd: reset write protection when unregister with wp-mode")
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Tested-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Tal Zussman <tz2294@columbia.edu>
Tested-by: Tal Zussman <tz2294@columbia.edu>
Cc: Peter Xu <peterx@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/userfaultfd.c | 47 ++++++++++++++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 17 deletions(-)
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -2239,6 +2239,32 @@ static void userfaultfd_reset_ctx(struct
userfaultfd_set_ctx(vma, NULL, 0);
}
+/*
+ * Clear uffd state from a WP or RWP range: the uffd bit, WP markers and
+ * RWP PAGE_NONE entries. Call this before dropping the registration, as it
+ * needs the VMA flags to know what to resolve.
+ */
+static void userfaultfd_clear_ptes(struct vm_area_struct *vma,
+ unsigned long start, unsigned long end)
+{
+ unsigned int mm_cp_flags = 0;
+ struct mmu_gather tlb;
+
+ if (!userfaultfd_protected(vma))
+ return;
+
+ if (userfaultfd_wp(vma))
+ mm_cp_flags |= MM_CP_UFFD_WP_RESOLVE;
+ if (userfaultfd_rwp(vma))
+ mm_cp_flags |= MM_CP_UFFD_RWP_RESOLVE;
+ if (vma_wants_manual_pte_write_upgrade(vma))
+ mm_cp_flags |= MM_CP_TRY_CHANGE_WRITABLE;
+
+ tlb_gather_mmu(&tlb, vma->vm_mm);
+ change_protection(&tlb, vma, start, end, mm_cp_flags);
+ tlb_finish_mmu(&tlb);
+}
+
static struct vm_area_struct *userfaultfd_clear_vma(struct vma_iterator *vmi,
struct vm_area_struct *prev,
struct vm_area_struct *vma,
@@ -2258,22 +2284,7 @@ static struct vm_area_struct *userfaultf
if (start == vma->vm_start && end == vma->vm_end)
give_up_on_oom = true;
- /* Clear the uffd bit and/or restore protnone PTEs */
- if (userfaultfd_protected(vma)) {
- unsigned int mm_cp_flags = 0;
- struct mmu_gather tlb;
-
- if (userfaultfd_wp(vma))
- mm_cp_flags |= MM_CP_UFFD_WP_RESOLVE;
- if (userfaultfd_rwp(vma))
- mm_cp_flags |= MM_CP_UFFD_RWP_RESOLVE;
- if (vma_wants_manual_pte_write_upgrade(vma))
- mm_cp_flags |= MM_CP_TRY_CHANGE_WRITABLE;
-
- tlb_gather_mmu(&tlb, vma->vm_mm);
- change_protection(&tlb, vma, start, end, mm_cp_flags);
- tlb_finish_mmu(&tlb);
- }
+ userfaultfd_clear_ptes(vma, start, end);
ret = vma_modify_flags_uffd(vmi, prev, vma, start, end,
&new_vma_flags, NULL_VM_UFFD_CTX,
@@ -2382,8 +2393,10 @@ static void userfaultfd_release_new(stru
/* the various vma->vm_userfaultfd_ctx still points to it */
mmap_write_lock(mm);
for_each_vma(vmi, vma) {
- if (vma->vm_userfaultfd_ctx.ctx == ctx)
+ if (vma->vm_userfaultfd_ctx.ctx == ctx) {
+ userfaultfd_clear_ptes(vma, vma->vm_start, vma->vm_end);
userfaultfd_reset_ctx(vma);
+ }
}
mmap_write_unlock(mm);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 605/742] vgacon: Fall back to the dummy console if mapping VGA memory fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (595 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 604/742] userfaultfd: clear uffd state in child PTEs if uffd is released during fork Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 606/742] vhost: split out-of-order used ring batches at every wrap Greg Kroah-Hartman
` (129 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Matt Turner, Magnus Lindholm,
Helge Deller
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Turner <mattst88@gmail.com>
commit e3512c7628621f7048a9615d21fd7cf63173c518 upstream.
On Alpha, setup_arch() registers vgacon whenever CONFIG_VGA_CONSOLE is
enabled. On Marvel (EV7) systems whose SRM console is serial, no VGA
hose is set, so marvel_ioremap() finds no hose for 0xb8000 and returns
NULL. vgacon_startup() then probes video memory through that NULL
pointer and oopses in console_init():
Unable to handle kernel paging request at virtual address 0000000000000000
pc is at vgacon_startup+0x174/0x910
VGA_MAP_MEM() is ioremap() on Alpha and powerpc and can fail. Treat
failure like a failed probe and fall back to the dummy console. If a
VGA card is present, locate_and_init_vga() still switches to vgacon
once PCI is up.
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Magnus Lindholm <linmag7@gmail.com>
Tested-by: Magnus Lindholm <linmag7@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/video/console/vgacon.c | 2 ++
1 file changed, 2 insertions(+)
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -324,6 +324,8 @@ static const char *vgacon_startup(void)
}
vga_vram_base = VGA_MAP_MEM(vga_vram_base, vga_vram_size);
+ if (!vga_vram_base)
+ goto no_vga;
vga_vram_end = vga_vram_base + vga_vram_size;
/*
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 606/742] vhost: split out-of-order used ring batches at every wrap
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (596 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 605/742] vgacon: Fall back to the dummy console if mapping VGA memory fails Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 607/742] virtiofs: fix use-after-free of fs->tag on device removal Greg Kroah-Hartman
` (128 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Seohyeon Maeng, minki, Jason Wang,
Michael S. Tsirkin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael S. Tsirkin <mst@redhat.com>
commit 5570a998b884c988dbe105430d7e2d8e9411e37e upstream.
When a completion batch larger than the remaining space in the used
ring is added without VIRTIO_F_IN_ORDER, vhost_add_used_n_ooo() splits
it at the ring boundary only once. vhost-net can batch up to
VHOST_NET_BATCH TX completions, so with a queue smaller than half the
batch the tail of the second chunk runs past the end of the used ring
and into whatever follows it in the vhost owner's address space: with
a 32 entry queue, last_used_idx % 32 == 3 and a 64 entry batch, three
used entries are written past the ring.
To fix, keep splitting the remaining batch at each wrap until it is
exhausted.
Cc: stable@vger.kernel.org
Reported-by: Seohyeon Maeng <bioloidgp@gmail.com>
Cc: minki@morningstarsec.dev
Fixes: 2b3b35eb989 ("vhost_net: batch used ring update in rx")
Fixes: 4afb52c2af44 ("vhost_net: batch update used ring for datacopy TX")
Cc: Jason Wang <jasowangio@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/vhost/vhost.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -3137,18 +3137,21 @@ static int vhost_add_used_n_ooo(struct v
struct vring_used_elem *heads,
unsigned count)
{
- int start, n, r;
+ unsigned int n;
+ int r;
- start = vq->last_used_idx & (vq->num - 1);
- n = vq->num - start;
- if (n < count) {
+ do {
+ unsigned int start = vq->last_used_idx & (vq->num - 1);
+
+ n = min(vq->num - start, count);
r = __vhost_add_used_n(vq, heads, n);
if (r < 0)
return r;
heads += n;
count -= n;
- }
- return __vhost_add_used_n(vq, heads, count);
+ } while (count);
+
+ return 0;
}
static int vhost_add_used_n_in_order(struct vhost_virtqueue *vq,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 607/742] virtiofs: fix use-after-free of fs->tag on device removal
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (597 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 606/742] vhost: split out-of-order used ring batches at every wrap Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 608/742] watchdog: npcm: fix sleeping clock call in restart handler Greg Kroah-Hartman
` (127 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Miklos Szeredi
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <mszeredi@redhat.com>
commit 6df984631391616dafd9b989a3505d93ca4fd235 upstream.
The virtio_fs object is refcounted via its kobject, so a mount can keep it
alive well beyond the lifetime of the virtio device binding. The tag
string, however, was allocated with devm_kmalloc() and is therefore freed
by devres_release_all() as soon as the device is unbound, i.e. right after
virtio_fs_remove() returns (see device_unbind_cleanup() in
drivers/base/dd.c).
virtio_fs_get_tree() looks up the instance, takes a kobject reference and
then drops virtio_fs_mutex before doing the sleepable part of the mount
(allocations, fuse_conn_init(), sget_fc()). A concurrent device removal
can complete in that window:
CPU 0 (mount) CPU 1 (remove)
------------- --------------
virtio_fs_get_tree()
virtio_fs_find_instance()
// reference taken, mutex dropped
virtio_fs_remove()
list_del_init(&fs->list);
// driver core unbinds device
// devres frees fs->tag
virtio_fs_fill_super()
mutex_lock(&virtio_fs_mutex);
if (list_empty(&fs->list))
pr_info(... fs->tag); <-- use-after-free
The virtio_fs object itself is still valid here, only its tag has been
freed behind its back.
Fix the lifetime mismatch at the source: allocate the tag with kmalloc()
and free it from virtio_fs_ktype_release(), so that it lives exactly as
long as the object embedding it. All probe error paths already drop the
final kobject reference, so they are covered. Merely dropping the tag
from the error message would paper over this instance while leaving a
devres pointer embedded in an object that routinely outlives its device.
The other readers of fs->tag are unaffected: tag_show() is fenced off by
the kobject_del() in virtio_fs_remove(), the automatic KOBJ_REMOVE uevent
is emitted from __kobject_del() while the device is still bound, and both
virtio_fs_add_instance() and virtio_fs_find_instance() only walk instances
still on virtio_fs_instances.
Fixes: a62a8ef9d97d ("virtio-fs: add virtiofs filesystem")
Cc: <stable@vger.kernel.org>
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-0328b3a1-043b-468e-8425-6a613d91b5ef
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/fuse/virtio_fs.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -193,6 +193,7 @@ static void virtio_fs_ktype_release(stru
{
struct virtio_fs *vfs = container_of(kobj, struct virtio_fs, kobj);
+ kfree(vfs->tag);
kfree(vfs->mq_map);
kfree(vfs->vqs);
kfree(vfs);
@@ -489,7 +490,11 @@ static void virtio_fs_free_devs(struct v
}
}
-/* Read filesystem name from virtio config into fs->tag (must kfree()). */
+/*
+ * Read filesystem name from virtio config into fs->tag. Freed by
+ * virtio_fs_ktype_release() so that it stays valid for as long as the
+ * virtio_fs object itself, which may outlive the virtio device.
+ */
static int virtio_fs_read_tag(struct virtio_device *vdev, struct virtio_fs *fs)
{
char tag_buf[sizeof_field(struct virtio_fs_config, tag)];
@@ -505,7 +510,7 @@ static int virtio_fs_read_tag(struct vir
end = &tag_buf[sizeof(tag_buf)];
len = end - tag_buf;
- fs->tag = devm_kmalloc(&vdev->dev, len + 1, GFP_KERNEL);
+ fs->tag = kmalloc(len + 1, GFP_KERNEL);
if (!fs->tag)
return -ENOMEM;
memcpy(fs->tag, tag_buf, len);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 608/742] watchdog: npcm: fix sleeping clock call in restart handler
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (598 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 607/742] virtiofs: fix use-after-free of fs->tag on device removal Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 609/742] watchdog: stm32_iwdg: serialize accesses to EWCR register Greg Kroah-Hartman
` (126 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zhao Feng, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Feng <zhaofeng2@cmss.chinamobile.com>
commit 4e83ea5b22193fd0db8bcee5682935f1d528705e upstream.
The watchdog .restart callback runs in atomic context: it is invoked
from the restart handler chain via atomic_notifier_call_chain(), under
an RCU read-side critical section, on every reboot or restart. Since
commit af084fdccfaf ("watchdog: npcm: Enable clock if provided"),
npcm_wdt_restart() calls clk_prepare_enable(), and clk_prepare()
takes a mutex unconditionally, so kernels built with
CONFIG_DEBUG_ATOMIC_SLEEP=y report
BUG: sleeping function called from invalid context
on every reboot. Worse, a panic-time restart can block on
prepare_lock and never issue the reset at all.
Get the clock with devm_clk_get_optional_prepared() at probe time and
keep it prepared for the lifetime of the driver, so the restart
handler only needs clk_enable(), which is safe in atomic context.
With the clock permanently prepared, npcm_wdt_start() and
npcm_wdt_stop() are simplified to clk_enable()/clk_disable() as well.
Fixes: af084fdccfaf ("watchdog: npcm: Enable clock if provided")
Cc: stable@vger.kernel.org
Signed-off-by: Zhao Feng <zhaofeng2@cmss.chinamobile.com>
Link: https://patch.msgid.link/20261111083236.248-1-zhaofeng2@cmss.chinamobile.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/watchdog/npcm_wdt.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
--- a/drivers/watchdog/npcm_wdt.c
+++ b/drivers/watchdog/npcm_wdt.c
@@ -180,7 +180,7 @@ static int npcm_wdt_start(struct watchdo
{
struct npcm_wdt *wdt = to_npcm_wdt(wdd);
- clk_prepare_enable(wdt->clk);
+ clk_enable(wdt->clk);
__npcm_wdt_start(wdd);
@@ -193,7 +193,7 @@ static int npcm_wdt_stop(struct watchdog
writel(0, wdt->reg);
- clk_disable_unprepare(wdt->clk);
+ clk_disable(wdt->clk);
return 0;
}
@@ -242,8 +242,12 @@ static int npcm_wdt_restart(struct watch
{
struct npcm_wdt *wdt = to_npcm_wdt(wdd);
- /* For reset, we start the WDT clock and leave it running. */
- clk_prepare_enable(wdt->clk);
+ /*
+ * For reset, we start the WDT clock and leave it running.
+ * The clock was prepared at probe time; only clk_enable() is
+ * safe in this atomic (restart notifier) context.
+ */
+ clk_enable(wdt->clk);
writel(NPCM_WTR | NPCM_WTRE | NPCM_WTE, wdt->reg);
udelay(1000);
@@ -417,7 +421,12 @@ static int npcm_wdt_probe(struct platfor
start = res->start;
- wdt->clk = devm_clk_get_optional(&pdev->dev, NULL);
+ /*
+ * Keep the clock prepared for the lifetime of the driver:
+ * npcm_wdt_restart() runs in atomic context and may only call
+ * clk_enable().
+ */
+ wdt->clk = devm_clk_get_optional_prepared(&pdev->dev, NULL);
if (IS_ERR(wdt->clk))
return PTR_ERR(wdt->clk);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 609/742] watchdog: stm32_iwdg: serialize accesses to EWCR register
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (599 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 608/742] watchdog: npcm: fix sleeping clock call in restart handler Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 610/742] watchdog: stm32_iwdg: set driver data before requesting interrupt Greg Kroah-Hartman
` (125 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Antonio Borneo, Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antonio Borneo <antonio.borneo@foss.st.com>
commit abbf55699ff6a8830b864aa1fab9f24edc9e72a6 upstream.
On STM32MP1xx platforms, EWCR contains both the pretimeout
interrupt configuration and a write-only bit used to acknowledge
the interrupt.
On SMP systems, the read-modify-write operation in the pretimeout
IRQ handler can race with writes that update the pretimeout
configuration.
Protect these accesses with a spinlock to prevent concurrent
updates.
Don't use the helpers reg_read()/reg_write() in the critical
sections as they rely on relaxed memory access, which are not
ordered against locking.
Fixes: 3ab1663af6c1 ("watchdog: stm32_iwdg: Add pretimeout support")
Cc: stable@vger.kernel.org
Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
Link: https://patch.msgid.link/20261116132416.1184447-3-antonio.borneo@foss.st.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/watchdog/stm32_iwdg.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
--- a/drivers/watchdog/stm32_iwdg.c
+++ b/drivers/watchdog/stm32_iwdg.c
@@ -19,6 +19,7 @@
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_wakeirq.h>
+#include <linux/spinlock.h>
#include <linux/watchdog.h>
#define DEFAULT_TIMEOUT 10
@@ -82,6 +83,7 @@ struct stm32_iwdg {
struct clk *clk_lsi;
struct clk *clk_pclk;
unsigned int rate;
+ spinlock_t lock; /* serialize IWDG_EWCR register access */
};
static inline u32 reg_read(void __iomem *base, u32 reg)
@@ -98,6 +100,7 @@ static int stm32_iwdg_start(struct watch
{
struct stm32_iwdg *wdt = watchdog_get_drvdata(wdd);
u32 tout, ptot, presc, iwdg_rlr, iwdg_ewcr, iwdg_pr, iwdg_sr;
+ unsigned long flags;
int ret;
dev_dbg(wdd->parent, "%s\n", __func__);
@@ -124,8 +127,11 @@ static int stm32_iwdg_start(struct watch
/* set prescaler & reload registers */
reg_write(wdt->regs, IWDG_PR, iwdg_pr);
reg_write(wdt->regs, IWDG_RLR, iwdg_rlr);
- if (wdt->data->has_early_wakeup)
- reg_write(wdt->regs, IWDG_EWCR, iwdg_ewcr | EWCR_EWIE);
+ if (wdt->data->has_early_wakeup) {
+ spin_lock_irqsave(&wdt->lock, flags);
+ writel(iwdg_ewcr | EWCR_EWIE, wdt->regs + IWDG_EWCR);
+ spin_unlock_irqrestore(&wdt->lock, flags);
+ }
reg_write(wdt->regs, IWDG_KR, KR_KEY_ENABLE);
/* wait for the registers to be updated (max 100ms) */
@@ -185,11 +191,16 @@ static irqreturn_t stm32_iwdg_isr(int ir
{
struct watchdog_device *wdd = wdog_arg;
struct stm32_iwdg *wdt = watchdog_get_drvdata(wdd);
+ unsigned long flags;
u32 reg;
- reg = reg_read(wdt->regs, IWDG_EWCR);
+ spin_lock_irqsave(&wdt->lock, flags);
+
+ reg = readl(wdt->regs + IWDG_EWCR);
reg |= EWCR_EWIC;
- reg_write(wdt->regs, IWDG_EWCR, reg);
+ writel(reg, wdt->regs + IWDG_EWCR);
+
+ spin_unlock_irqrestore(&wdt->lock, flags);
watchdog_notify_pretimeout(wdd);
@@ -323,6 +334,8 @@ static int stm32_iwdg_probe(struct platf
if (!wdt)
return -ENOMEM;
+ spin_lock_init(&wdt->lock);
+
wdt->data = of_device_get_match_data(&pdev->dev);
if (!wdt->data)
return -ENODEV;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 610/742] watchdog: stm32_iwdg: set driver data before requesting interrupt
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (600 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 609/742] watchdog: stm32_iwdg: serialize accesses to EWCR register Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 611/742] x86/apic/msi: Fix MSI interrupt affinity configuration Greg Kroah-Hartman
` (124 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sashiko, Antonio Borneo,
Guenter Roeck
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antonio Borneo <antonio.borneo@foss.st.com>
commit 25c38ab9e6b69cfdc13aeff19470f7d0893b1702 upstream.
The interrupt handler accesses the driver data, which is currently
set after devm_request_irq() returns.
If the watchdog was started by the bootloader and a pretimeout
interrupt is pending, the handler can run before the driver data
is set, resulting in a NULL pointer dereference.
Move the IRQ request after setting the driver data to ensure it
is available when the interrupt handler runs.
Fixes: 3ab1663af6c1 ("watchdog: stm32_iwdg: Add pretimeout support")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20261106163429.618392-1-antonio.borneo%40foss.st.com?part=3
Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
Link: https://patch.msgid.link/20261116132416.1184447-2-antonio.borneo@foss.st.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/watchdog/stm32_iwdg.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/drivers/watchdog/stm32_iwdg.c
+++ b/drivers/watchdog/stm32_iwdg.c
@@ -359,15 +359,15 @@ static int stm32_iwdg_probe(struct platf
wdd->max_hw_heartbeat_ms = ((RLR_MAX + 1) * wdt->data->max_prescaler *
1000) / wdt->rate;
+ watchdog_set_drvdata(wdd, wdt);
+ watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT);
+ watchdog_init_timeout(wdd, 0, dev);
+
/* Initialize IRQ, this might override wdd->info, hence it is here. */
ret = stm32_iwdg_irq_init(pdev, wdt);
if (ret)
return ret;
- watchdog_set_drvdata(wdd, wdt);
- watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT);
- watchdog_init_timeout(wdd, 0, dev);
-
/*
* In case of CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED is set
* (Means U-Boot/bootloaders leaves the watchdog running)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 611/742] x86/apic/msi: Fix MSI interrupt affinity configuration
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (601 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 610/742] watchdog: stm32_iwdg: set driver data before requesting interrupt Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 612/742] x86/Kconfig: Enable ROX also when STRICT_KERNEL_RWX is present Greg Kroah-Hartman
` (123 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Weitao Wang, Borislav Petkov (AMD),
Koichiro Den, Thomas Gleixner
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: WeitaoWang-oc <WeitaoWang-oc@zhaoxin.com>
commit 068d82afd070beb8ea32c8ee64d685af7d3f36e2 upstream.
The two step update sequence in msi_set_affinity() is required for MSI
interrupts which cannot be migrated atomically, i.e. devices which do not
provide MSI masking.
The MSI message update writes address and data registers separately, so such
a device can raise an interrupt in between, which results in a message built
from half updated state: a stray interrupt on a stale vector and a possibly
lost device interrupt.
The update sequence is selected by a per interrupt quirk flag, which is set
for interrupts which cannot use reservation mode. Reservation mode is only
enabled for maskable interrupts, i.e. devices which provide MSI-X or
mask support, so the quirk flag is the inverse of the reservation mode
bit.
The removal of the quirk flag replaced the flag check with a reservation mode
check, but dropped the negation of the removed condition:
- if (!irqd_msi_nomask_quirk(irqd) || ...)
+ if (!irqd_can_reserve(irqd) || ...)
As the quirk flag is the inverse of the reservation mode bit, the replacement
inverted the condition and selects the wrong update path for every interrupt:
non-maskable interrupts take the direct update path again, which reopens the
race, while maskable interrupts needlessly go through the two step update.
Restore the original condition so that the direct update path is selected when
reservation mode is enabled, which also matches the comment above the check:
direct update is possible when the MSI is maskable, which is the case when the
reservation mode bit is set.
[ bp: Massage commit message. ]
Fixes: b56ebe7c896d ("x86/apic/msi: Fix misconfigured non-maskable MSI quirk")
Signed-off-by: Weitao Wang <WeitaoWang-oc@zhaoxin.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Koichiro Den <den@valinux.co.jp>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org # v6.1+
Link: https://patch.msgid.link/20261016181016.3850-1-WeitaoWang-oc@zhaoxin.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/x86/kernel/apic/msi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/arch/x86/kernel/apic/msi.c
+++ b/arch/x86/kernel/apic/msi.c
@@ -62,7 +62,7 @@ msi_set_affinity(struct irq_data *irqd,
* - The interrupt is not yet started up
* - The new destination CPU is the same as the old destination CPU
*/
- if (!irqd_can_reserve(irqd) ||
+ if (irqd_can_reserve(irqd) ||
cfg->vector == old_cfg.vector ||
old_cfg.vector == MANAGED_IRQ_SHUTDOWN_VECTOR ||
!irqd_is_started(irqd) ||
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 612/742] x86/Kconfig: Enable ROX also when STRICT_KERNEL_RWX is present
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (602 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 611/742] x86/apic/msi: Fix MSI interrupt affinity configuration Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 613/742] x86/mce: Do not treat cache hierarchy errors as memory errors Greg Kroah-Hartman
` (122 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Mike Rapoport (Microsoft),
Richard Weinberger, Borislav Petkov (AMD), Peter Zijlstra (Intel),
Vinny Horgan
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <richard@nod.at>
commit ae3398a7da224e1cb14a04ce8e9da66fc2948121 upstream.
Running a kernel with CONFIG_MODULES=n causes the W+X page detection
to trigger:
x86/mm: Found insecure W+X mapping at address 0xffffffffc033a000
The W+X pages come from __its_alloc() with type being EXECMEM_MODULE_TEXT.
Without ARCH_HAS_EXECMEM_ROX pgprot is PAGE_KERNEL instead of PAGE_KERNEL_ROX.
Fixes: 47410d839fcda ("x86/Kconfig: only enable ROX cache in execmem when STRICT_MODULE_RWX is set")
Suggested-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Tested-by: Vinny Horgan <vinnyhorgan@gmail.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260625090627.1501095-1-richard@nod.at
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/x86/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -85,7 +85,7 @@ config X86
select ARCH_HAS_DMA_OPS if GART_IOMMU || XEN
select ARCH_HAS_EARLY_DEBUG if KGDB
select ARCH_HAS_ELF_RANDOMIZE
- select ARCH_HAS_EXECMEM_ROX if X86_64 && STRICT_MODULE_RWX
+ select ARCH_HAS_EXECMEM_ROX if X86_64 && (STRICT_MODULE_RWX || STRICT_KERNEL_RWX)
select ARCH_HAS_FAST_MULTIPLIER
select ARCH_HAS_FORTIFY_SOURCE
select ARCH_HAS_GCOV_PROFILE_ALL
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 613/742] x86/mce: Do not treat cache hierarchy errors as memory errors
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (603 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 612/742] x86/Kconfig: Enable ROX also when STRICT_KERNEL_RWX is present Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 614/742] x86/resctrl: Add SNC support for Granite Rapids "D" CPU Greg Kroah-Hartman
` (121 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Adrian Schlegel,
Borislav Petkov (AMD), Qiuxu Zhuo, Tony Luck, Yazen Ghannam,
Sohil Mehta, stable
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Schlegel <me@adrianschlegel.com>
commit 29b74cf57f432d60da2b79c827f1379125409611 upstream.
On Intel and Zhaoxin, mce_is_memory_error() also returns true for cache
hierarchy errors. All callers expect it to report memory errors only.
The CEC uses it to count corrected DRAM errors. A corrected cache error only
names the cache line that was affected, not a faulty DRAM page. With a faulty
CPU core, the CEC therefore soft-offlines healthy pages. On an i9-9900K this
caused about 500 soft-offline attempts per hour.
Report only memory controller errors on Intel and Zhaoxin, as is already done
for AMD.
Fixes: fa92c5869426 ("x86, mce: Support memory error recovery for both UCNA and Deferred error in machine_check_poll")
Signed-off-by: Adrian Schlegel <me@adrianschlegel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Qiuxu Zhuo <qzhuo@nvidia.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
Cc: <stable@kernel.org>
Link: https://patch.msgid.link/20261012193305.38931-1-me@adrianschlegel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/x86/kernel/cpu/mce/core.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -540,21 +540,13 @@ bool mce_is_memory_error(struct mce *m)
case X86_VENDOR_INTEL:
case X86_VENDOR_ZHAOXIN:
/*
- * Intel SDM Volume 3B - 15.9.2 Compound Error Codes
+ * Intel SDM Volume 3B "Compound Error Codes".
*
- * Bit 7 of the MCACOD field of IA32_MCi_STATUS is used for
- * indicating a memory error. Bit 8 is used for indicating a
- * cache hierarchy error. The combination of bit 2 and bit 3
- * is used for indicating a `generic' cache hierarchy error
- * But we can't just blindly check the above bits, because if
- * bit 11 is set, then it is a bus/interconnect error - and
- * either way the above bits just gives more detail on what
- * bus/interconnect error happened. Note that bit 12 can be
- * ignored, as it's the "filter" bit.
+ * Memory controller errors have an MCACOD of 000F 0000 1MMM CCCC:
+ * bit 7 set, bits 8-11 and 13-15 clear. Bit 12 is the "filter"
+ * bit and is ignored.
*/
- return (m->status & 0xef80) == BIT(7) ||
- (m->status & 0xef00) == BIT(8) ||
- (m->status & 0xeffc) == 0xc;
+ return (m->status & 0xef80) == BIT(7);
default:
return false;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 614/742] x86/resctrl: Add SNC support for Granite Rapids "D" CPU
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (604 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 613/742] x86/mce: Do not treat cache hierarchy errors as memory errors Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:07 ` [PATCH 7.3 615/742] xarray: fix index jumping backwards in xas_find() Greg Kroah-Hartman
` (120 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Tony Luck, Borislav Petkov (AMD),
stable
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Luck <tony.luck@intel.com>
commit 0833bc1d4ad71144500f6ca8601672580624f24f upstream.
Sub-NUMA Cluster (SNC) mode divides available RMID counters between
NUMA nodes that share an instance of an L3 cache.
Granite Rapids "D" CPUs can enable SNC mode, so Linux must adjust
when SNC is enabled.
Update the table of SNC capable CPU models.
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Cc: <stable@kernel.org>
Link: https://patch.msgid.link/20261119184524.12846-1-tony.luck@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/x86/kernel/cpu/resctrl/monitor.c | 1 +
1 file changed, 1 insertion(+)
--- a/arch/x86/kernel/cpu/resctrl/monitor.c
+++ b/arch/x86/kernel/cpu/resctrl/monitor.c
@@ -381,6 +381,7 @@ static const struct x86_cpu_id snc_cpu_i
X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, 0),
X86_MATCH_VFM(INTEL_ATOM_CRESTMONT_X, 0),
X86_MATCH_VFM(INTEL_ATOM_DARKMONT_X, 0),
+ X86_MATCH_VFM(INTEL_GRANITERAPIDS_D, 0),
{}
};
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 615/742] xarray: fix index jumping backwards in xas_find()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (605 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 614/742] x86/resctrl: Add SNC support for Granite Rapids "D" CPU Greg Kroah-Hartman
@ 2026-12-04 10:07 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 616/742] xor: arm/arm64: Move NEON xor_gen() dispatch into the glue code Greg Kroah-Hartman
` (119 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:07 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, syzbot+b72767277f29b6407083,
Krystian Kaniewski, Andrew Morton, Jose Fernandez (Anthropic),
Matthew Wilcox (Oracle), Mike Rapoport
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krystian Kaniewski <krystianmkaniewski@gmail.com>
commit a4e667346a8d91e629a2ca9affc70dc28978f4a1 upstream.
A bug in the XArray iterator xas_find() causes the iterator's index
(xas->xa_index) to jump backwards when iterating over a multi-index entry
(like a THP) that resides in a non-leaf node and is concurrently split.
When iterating over a multi-index entry in a non-leaf node, xas_load()
sets xas->xa_offset to the base offset of the entry, but leaves
xas->xa_index at the requested index. When the caller subsequently wants
to advance to the next entry, xas_find() is called. xas_find() attempts
to synchronize xas->xa_offset with xas->xa_index before advancing.
However, the fixup logic was incorrectly restricted to leaf nodes
(!xas->xa_node->shift). Because the THP resides in a non-leaf node, the
fixup is skipped.
As a result, xas_find() simply increments xas->xa_offset and recalculates
xas->xa_index based on this new offset. This causes xas->xa_index to jump
backwards. If the THP was concurrently split, the entry at the new offset
is a node pointer, so xas_find() descends into it and returns the folio at
the backwards index. The caller (filemap_map_pages()) then calculates the
PTE pointer based on this backwards index, resulting in an invalid memory
access such as an out-of-bounds read or use-after-free on a page-table
page freed via tlb_remove_table_rcu().
A userspace access that faults in a file-backed mapping can trigger this
path. When the index moves backwards, filemap_map_pages() can calculate a
PTE outside the page locked for fault-around and dereference a freed
page-table page, resulting in a KASAN-detected use-after-free read.
To fix this, check if xas->xa_offset matches get_offset(xas->xa_index,
xas->xa_node). If it does not and the node is a non-leaf node, set
xas->xa_offset to get_offset(xas->xa_index, xas->xa_node) before
advancing. Also add test cases in test_xarray to verify xas_find()
behavior when iterating over and splitting multi-index entries.
Link: https://lore.kernel.org/20260904121301.200049-1-krystianmkaniewski@gmail.com
Fixes: b803b42823d0 ("xarray: Add XArray iterators")
Reported-by: syzbot+b72767277f29b6407083@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b72767277f29b6407083
Closes: https://syzkaller.appspot.com/ai_job?id=a01c56bd-74d0-411c-afb4-ee6f0cb6cb61
Signed-off-by: Krystian Kaniewski <krystianmkaniewski@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Tested-by: Jose Fernandez (Anthropic) <jose.fernandez@linux.dev>
Link: https://lore.kernel.org/20261104-jf-filemap-v2-pedro-reply-r2-74c87c6fbcf@linux.dev
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
lib/test_xarray.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/xarray.c | 8 +++---
2 files changed, 75 insertions(+), 3 deletions(-)
--- a/lib/test_xarray.c
+++ b/lib/test_xarray.c
@@ -1247,6 +1247,75 @@ static noinline void check_multi_find_3(
}
}
+static noinline void check_multi_find_4(struct xarray *xa)
+{
+#ifdef CONFIG_XARRAY_MULTI
+ unsigned int order = XA_CHUNK_SHIFT + 1;
+ unsigned long next = 1UL << order;
+ unsigned long start = next - 1;
+ XA_STATE(xas, xa, start);
+ XA_STATE_ORDER(split, xa, 0, 0);
+ void *entry;
+ unsigned long i;
+
+ /* Multi-index entry in two slots of a non-leaf node. */
+ xa_store_order(xa, 0, order, xa_mk_index(0), GFP_KERNEL);
+ XA_BUG_ON(xa, xa_store_index(xa, next, GFP_KERNEL) != NULL);
+
+ rcu_read_lock();
+ entry = xas_find(&xas, ULONG_MAX);
+ XA_BUG_ON(xa, entry != xa_mk_index(0));
+ XA_BUG_ON(xa, xas.xa_index != start);
+
+ entry = xas_find(&xas, ULONG_MAX);
+ XA_BUG_ON(xa, entry != xa_mk_index(next));
+ XA_BUG_ON(xa, xas.xa_index != next);
+
+ entry = xas_find(&xas, ULONG_MAX);
+ XA_BUG_ON(xa, entry != NULL);
+ rcu_read_unlock();
+
+ xa_erase_index(xa, next);
+ xa_erase_index(xa, 0);
+ XA_BUG_ON(xa, !xa_empty(xa));
+
+ /* Split the multi-index entry after a lookup begins inside it. */
+ xa_store_order(xa, 0, order, xa_mk_index(0), GFP_KERNEL);
+ XA_BUG_ON(xa, xa_store_index(xa, next, GFP_KERNEL) != NULL);
+
+ xas_set(&xas, start);
+ rcu_read_lock();
+ entry = xas_find(&xas, ULONG_MAX);
+ XA_BUG_ON(xa, entry != xa_mk_index(0));
+ XA_BUG_ON(xa, xas.xa_index != start);
+ rcu_read_unlock();
+
+ xas_split_alloc(&split, xa_mk_index(0), order, GFP_KERNEL);
+ if (xas_error(&split)) {
+ XA_BUG_ON(xa, true);
+ goto out;
+ }
+ xas_lock(&split);
+ xas_split(&split, xa_mk_index(0), order);
+ for (i = 0; i < next; i++)
+ __xa_store(xa, i, xa_mk_index(i), 0);
+ xas_unlock(&split);
+
+ rcu_read_lock();
+ entry = xas_find(&xas, ULONG_MAX);
+ XA_BUG_ON(xa, entry != xa_mk_index(next));
+ XA_BUG_ON(xa, xas.xa_index != next);
+
+ entry = xas_find(&xas, ULONG_MAX);
+ XA_BUG_ON(xa, entry != NULL);
+ rcu_read_unlock();
+
+out:
+ xa_destroy(xa);
+ XA_BUG_ON(xa, !xa_empty(xa));
+#endif
+}
+
static noinline void check_find_1(struct xarray *xa)
{
unsigned long i, j, k;
@@ -1370,6 +1439,7 @@ static noinline void check_find(struct x
check_multi_find_1(xa, i);
check_multi_find_2(xa);
check_multi_find_3(xa);
+ check_multi_find_4(xa);
}
/* See find_swap_entry() in mm/shmem.c */
--- a/lib/xarray.c
+++ b/lib/xarray.c
@@ -1409,9 +1409,11 @@ void *xas_find(struct xa_state *xas, uns
entry = xas_load(xas);
if (entry || xas_not_node(xas->xa_node))
return entry;
- } else if (!xas->xa_node->shift &&
- xas->xa_offset != (xas->xa_index & XA_CHUNK_MASK)) {
- xas->xa_offset = ((xas->xa_index - 1) & XA_CHUNK_MASK) + 1;
+ } else if (xas->xa_offset != get_offset(xas->xa_index, xas->xa_node)) {
+ if (!xas->xa_node->shift)
+ xas->xa_offset = ((xas->xa_index - 1) & XA_CHUNK_MASK) + 1;
+ else
+ xas->xa_offset = get_offset(xas->xa_index, xas->xa_node);
}
xas_next_offset(xas);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 616/742] xor: arm/arm64: Move NEON xor_gen() dispatch into the glue code
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (606 preceding siblings ...)
2026-12-04 10:07 ` [PATCH 7.3 615/742] xarray: fix index jumping backwards in xas_find() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 617/742] zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits() Greg Kroah-Hartman
` (118 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ard Biesheuvel, Nathan Chancellor,
Eric Biggers, Catalin Marinas
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <ardb@kernel.org>
commit 14e3460321430a3f9ed2260f3c6198bdeaba5792 upstream.
The NEON intrinsics code in xor-neon.c and arm64/xor-eor3.c includes xor_impl.h
for the definition of __DO_XOR_BLOCKS(), which pulls in <linux/types.h> via
<linux/init.h> and <linux/minmax.h>. This only works because
asm/neon-intrinsics.h overrides the compiler's predefined macros that
<stdint.h> uses to define the C99 types, so that they match the kernel's
definitions in <linux/types.h>.
So instead, follow the approach taken by LoongArch, and instantiate the
dispatch routines using DO_XOR_BLOCKS() in the glue code, which already
includes the kernel headers, and does not use NEON intrinsics itself. This
requires the NEON routines that handle a fixed number of sources to be exposed
to the glue code, which means that the arm64 glue code can use __xor_neon_2()
directly for the EOR3 flavor as well, and so the __xor_eor3_2() alias can be
dropped.
This makes the NEON intrinsics code independent of the kernel's own headers,
which will allow the macro overrides in asm/neon-intrinsics.h to be removed.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
lib/raid/xor/arm/xor-neon-glue.c | 3 +++
lib/raid/xor/arm/xor-neon.h | 16 ++++++++++++++--
lib/raid/xor/arm64/xor-eor3.c | 15 +++------------
lib/raid/xor/arm64/xor-neon-glue.c | 5 +++++
lib/raid/xor/arm64/xor-neon.h | 31 +++++++++++++++++++++++++++----
lib/raid/xor/xor-neon.c | 16 ++++------------
6 files changed, 56 insertions(+), 30 deletions(-)
--- a/lib/raid/xor/arm/xor-neon-glue.c
+++ b/lib/raid/xor/arm/xor-neon-glue.c
@@ -5,6 +5,9 @@
#include "xor_impl.h"
#include "xor_arch.h"
+DO_XOR_BLOCKS(neon_inner, __xor_neon_2, __xor_neon_3, __xor_neon_4,
+ __xor_neon_5);
+
static void xor_gen_neon(void *dest, void **srcs, unsigned int src_cnt,
unsigned int bytes)
{
--- a/lib/raid/xor/arm/xor-neon.h
+++ b/lib/raid/xor/arm/xor-neon.h
@@ -3,5 +3,17 @@
extern struct xor_block_template xor_block_arm4regs;
extern struct xor_block_template xor_block_neon;
-void xor_gen_neon_inner(void *dest, void **srcs, unsigned int src_cnt,
- unsigned int bytes);
+void __xor_neon_2(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2);
+void __xor_neon_3(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2,
+ const unsigned long * __restrict p3);
+void __xor_neon_4(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2,
+ const unsigned long * __restrict p3,
+ const unsigned long * __restrict p4);
+void __xor_neon_5(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2,
+ const unsigned long * __restrict p3,
+ const unsigned long * __restrict p4,
+ const unsigned long * __restrict p5);
--- a/lib/raid/xor/arm64/xor-eor3.c
+++ b/lib/raid/xor/arm64/xor-eor3.c
@@ -1,14 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-only
-#include <linux/cache.h>
#include <asm/neon-intrinsics.h>
-#include "xor_impl.h"
-#include "xor_arch.h"
#include "xor-neon.h"
-extern void __xor_eor3_2(unsigned long bytes, unsigned long * __restrict p1,
- const unsigned long * __restrict p2);
-
static inline uint64x2_t eor3(uint64x2_t p, uint64x2_t q, uint64x2_t r)
{
uint64x2_t res;
@@ -19,7 +13,7 @@ static inline uint64x2_t eor3(uint64x2_t
return res;
}
-static void __xor_eor3_3(unsigned long bytes, unsigned long * __restrict p1,
+void __xor_eor3_3(unsigned long bytes, unsigned long * __restrict p1,
const unsigned long * __restrict p2,
const unsigned long * __restrict p3)
{
@@ -53,7 +47,7 @@ static void __xor_eor3_3(unsigned long b
} while (--lines > 0);
}
-static void __xor_eor3_4(unsigned long bytes, unsigned long * __restrict p1,
+void __xor_eor3_4(unsigned long bytes, unsigned long * __restrict p1,
const unsigned long * __restrict p2,
const unsigned long * __restrict p3,
const unsigned long * __restrict p4)
@@ -96,7 +90,7 @@ static void __xor_eor3_4(unsigned long b
} while (--lines > 0);
}
-static void __xor_eor3_5(unsigned long bytes, unsigned long * __restrict p1,
+void __xor_eor3_5(unsigned long bytes, unsigned long * __restrict p1,
const unsigned long * __restrict p2,
const unsigned long * __restrict p3,
const unsigned long * __restrict p4,
@@ -141,6 +135,3 @@ static void __xor_eor3_5(unsigned long b
dp5 += 8;
} while (--lines > 0);
}
-
-__DO_XOR_BLOCKS(eor3_inner, __xor_eor3_2, __xor_eor3_3, __xor_eor3_4,
- __xor_eor3_5);
--- a/lib/raid/xor/arm64/xor-neon-glue.c
+++ b/lib/raid/xor/arm64/xor-neon-glue.c
@@ -9,6 +9,11 @@
#include "xor_arch.h"
#include "xor-neon.h"
+DO_XOR_BLOCKS(neon_inner, __xor_neon_2, __xor_neon_3, __xor_neon_4,
+ __xor_neon_5);
+DO_XOR_BLOCKS(eor3_inner, __xor_neon_2, __xor_eor3_3, __xor_eor3_4,
+ __xor_eor3_5);
+
#define XOR_TEMPLATE(_name) \
static void xor_gen_##_name(void *dest, void **srcs, unsigned int src_cnt, \
unsigned int bytes) \
--- a/lib/raid/xor/arm64/xor-neon.h
+++ b/lib/raid/xor/arm64/xor-neon.h
@@ -1,6 +1,29 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-void xor_gen_neon_inner(void *dest, void **srcs, unsigned int src_cnt,
- unsigned int bytes);
-void xor_gen_eor3_inner(void *dest, void **srcs, unsigned int src_cnt,
- unsigned int bytes);
+void __xor_neon_2(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2);
+void __xor_neon_3(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2,
+ const unsigned long * __restrict p3);
+void __xor_neon_4(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2,
+ const unsigned long * __restrict p3,
+ const unsigned long * __restrict p4);
+void __xor_neon_5(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2,
+ const unsigned long * __restrict p3,
+ const unsigned long * __restrict p4,
+ const unsigned long * __restrict p5);
+
+void __xor_eor3_3(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2,
+ const unsigned long * __restrict p3);
+void __xor_eor3_4(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2,
+ const unsigned long * __restrict p3,
+ const unsigned long * __restrict p4);
+void __xor_eor3_5(unsigned long bytes, unsigned long * __restrict p1,
+ const unsigned long * __restrict p2,
+ const unsigned long * __restrict p3,
+ const unsigned long * __restrict p4,
+ const unsigned long * __restrict p5);
--- a/lib/raid/xor/xor-neon.c
+++ b/lib/raid/xor/xor-neon.c
@@ -4,12 +4,11 @@
* Copyright (C) 2018,Tianjin KYLIN Information Technology Co., Ltd.
*/
-#include "xor_impl.h"
#include "xor-neon.h"
#include <asm/neon-intrinsics.h>
-static void __xor_neon_2(unsigned long bytes, unsigned long * __restrict p1,
+void __xor_neon_2(unsigned long bytes, unsigned long * __restrict p1,
const unsigned long * __restrict p2)
{
uint64_t *dp1 = (uint64_t *)p1;
@@ -36,7 +35,7 @@ static void __xor_neon_2(unsigned long b
} while (--lines > 0);
}
-static void __xor_neon_3(unsigned long bytes, unsigned long * __restrict p1,
+void __xor_neon_3(unsigned long bytes, unsigned long * __restrict p1,
const unsigned long * __restrict p2,
const unsigned long * __restrict p3)
{
@@ -72,7 +71,7 @@ static void __xor_neon_3(unsigned long b
} while (--lines > 0);
}
-static void __xor_neon_4(unsigned long bytes, unsigned long * __restrict p1,
+void __xor_neon_4(unsigned long bytes, unsigned long * __restrict p1,
const unsigned long * __restrict p2,
const unsigned long * __restrict p3,
const unsigned long * __restrict p4)
@@ -117,7 +116,7 @@ static void __xor_neon_4(unsigned long b
} while (--lines > 0);
}
-static void __xor_neon_5(unsigned long bytes, unsigned long * __restrict p1,
+void __xor_neon_5(unsigned long bytes, unsigned long * __restrict p1,
const unsigned long * __restrict p2,
const unsigned long * __restrict p3,
const unsigned long * __restrict p4,
@@ -170,10 +169,3 @@ static void __xor_neon_5(unsigned long b
dp5 += 8;
} while (--lines > 0);
}
-
-__DO_XOR_BLOCKS(neon_inner, __xor_neon_2, __xor_neon_3, __xor_neon_4,
- __xor_neon_5);
-
-#ifdef CONFIG_ARM64
-extern typeof(__xor_neon_2) __xor_eor3_2 __alias(__xor_neon_2);
-#endif
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 617/742] zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (607 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 616/742] xor: arm/arm64: Move NEON xor_gen() dispatch into the glue code Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 618/742] xfs: break layouts before swapping extents Greg Kroah-Hartman
` (117 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Ding Feng, Damien Le Moal
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ding Feng <dingf3ng@gmail.com>
commit fb5289b697c965581104bafdd875b969a1db3e79 upstream.
zonefs_write_check_limits() follows generic_write_check_limits() and
has the same problem: it stores rlimit(RLIMIT_FSIZE), an unsigned long,
in a loff_t, so a soft limit between 2^63 and RLIM_INFINITY is negative
and every write fails with -EFBIG and raises SIGXFSZ.
Keep the limit unsigned and apply it only when it is at most LLONG_MAX,
as the generic helper now does.
Fixes: ebfd68cd0c1e ("zonefs: Fix O_APPEND async write handling")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5-5 Frama-C
Signed-off-by: Ding Feng <dingf3ng@gmail.com>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/zonefs/file.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
--- a/fs/zonefs/file.c
+++ b/fs/zonefs/file.c
@@ -407,15 +407,16 @@ static loff_t zonefs_write_check_limits(
{
struct inode *inode = file_inode(file);
struct zonefs_zone *z = zonefs_inode_zone(inode);
- loff_t limit = rlimit(RLIMIT_FSIZE);
+ u64 limit = rlimit(RLIMIT_FSIZE);
loff_t max_size = z->z_capacity;
- if (limit != RLIM_INFINITY) {
- if (pos >= limit) {
+ /* No file position reaches a limit above LLONG_MAX. */
+ if (limit != RLIM_INFINITY && limit <= LLONG_MAX) {
+ if (pos >= (loff_t)limit) {
send_sig(SIGXFSZ, current, 0);
return -EFBIG;
}
- count = min(count, limit - pos);
+ count = min(count, (loff_t)limit - pos);
}
if (!(file->f_flags & O_LARGEFILE))
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 618/742] xfs: break layouts before swapping extents
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (608 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 617/742] zonefs: ignore RLIMIT_FSIZE above LLONG_MAX in zonefs_write_check_limits() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 619/742] xfs: fix f_bfree underflow in statfs() Greg Kroah-Hartman
` (116 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Daejun Park, Christoph Hellwig,
Carlos Maiolino
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daejun Park <daejun7.park@samsung.com>
commit 0d8026c7ac0c79a8ebe2942a3c3114c06aced734 upstream.
XFS_IOC_SWAPEXT does not break pNFS layouts. A client can keep writing
to blocks that the swap moved to the temporary file. xfs_fsr frees
those blocks when it closes that file. The writes then land in whatever
reuses them.
Lock with xfs_ilock2_io_mmap(), as the exchange-range ioctls do.
Fixes: 781355c6e5ae ("xfs: recall pNFS layouts on conflicting access")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/xfs/xfs_bmap_util.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1554,9 +1554,9 @@ xfs_swap_extents(
* page cache safely. Once we have done this we can take the ilocks and
* do the rest of the checks.
*/
- lock_two_nondirectories(VFS_I(ip), VFS_I(tip));
- filemap_invalidate_lock_two(VFS_I(ip)->i_mapping,
- VFS_I(tip)->i_mapping);
+ error = xfs_ilock2_io_mmap(ip, tip);
+ if (error)
+ return error;
/* Verify that both files have the same format */
if ((VFS_I(ip)->i_mode & S_IFMT) != (VFS_I(tip)->i_mode & S_IFMT)) {
@@ -1762,9 +1762,7 @@ out_unlock_ilock:
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_iunlock(tip, XFS_ILOCK_EXCL);
out_unlock:
- filemap_invalidate_unlock_two(VFS_I(ip)->i_mapping,
- VFS_I(tip)->i_mapping);
- unlock_two_nondirectories(VFS_I(ip), VFS_I(tip));
+ xfs_iunlock2_io_mmap(ip, tip);
return error;
out_trans_cancel:
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 619/742] xfs: fix f_bfree underflow in statfs()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (609 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 618/742] xfs: break layouts before swapping extents Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 620/742] xfs: keep successful near rt allocations Greg Kroah-Hartman
` (115 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Hengyu Liang, Christoph Hellwig,
Carlos Maiolino
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hengyu Liang <hengyul@cs.unc.edu>
commit f0b9e58eee233547e5d77e467ccee89d7a59dd63 upstream.
Commit dd324cb79e54 ("xfs: refactor xfs_fs_statfs") made
xfs_statfs_data() limit f_bfree with max(0LL, ...) instead of
max_t(int64_t, 0, ...).
However, the value is an unsigned difference, so max() never picks 0.
As of now, when the free block counter is below the count of
unavailable blocks, statfs() reports f_bfree and f_bavail close to 2^64
instead of 0, and df prints negative sizes.
A similar issue happened before and was fixed by commit 237aac4624aa
("xfs: ensure f_bfree returned by statfs() is non-negative"). Perhaps
the refactored code needs that fix as well.
The issue can be reproduced on a new 2 GiB filesystem mounted on /mnt:
for i in $(seq 3000); do head -c 65536 /dev/zero > /mnt/s$i; done
dd if=/dev/zero of=/mnt/big bs=1M
xfs_io -x -c 'resblks 100000000' /mnt
for i in $(seq 1 2 3000); do rm /mnt/s$i; done
sync
df -h /mnt
Before commit dd324cb79e54 ("xfs: refactor xfs_fs_statfs"), the result
is:
Filesystem Size Used Avail Use% Mounted on
/dev/vda 2.0G 2.0G 0 100% /mnt
After that commit, the result is:
Filesystem Size Used Avail Use% Mounted on
/dev/vda 2.0G -64Z -24K 100% /mnt
This patch will compare the difference as a signed value again.
Fixes: dd324cb79e54 ("xfs: refactor xfs_fs_statfs")
Cc: stable@vger.kernel.org # v6.14
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/xfs/xfs_super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -916,7 +916,7 @@ xfs_statfs_data(
xfs_sum_freecounter(mp, XC_FREE_BLOCKS);
/* make sure st->f_bfree does not underflow */
- st->f_bfree = max(0LL,
+ st->f_bfree = max_t(int64_t, 0,
fdblocks - xfs_freecounter_unavailable(mp, XC_FREE_BLOCKS));
/*
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 620/742] xfs: keep successful near rt allocations
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (610 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 619/742] xfs: fix f_bfree underflow in statfs() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 621/742] xfs: wait for direct I/O before swapping extents Greg Kroah-Hartman
` (114 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christian Andres Saide, Rik van Riel,
Christoph Hellwig, Carlos Maiolino, Carlos Maiolino
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rik van Riel <riel@surriel.com>
commit f9bfe5af596a5ef6fc745c30bda41f9a109ed16d upstream.
XFS realtime allocations first attempt to allocate space near where
other parts of a file already are. If that allocation succeeds, it
does not have to do a global search for free space.
Unfortunately, a code cleanup a while ago causes xfs_rtallocate_rtg
to unconditionally do the global search, even when the search for a
nearby extent has succeeded.
Fix it by running the global search only when the near search did
not find available space.
Found by noticing higher kernel CPU use and examining the profile.
Fixes: fd048a1bb391d ("xfs: rework the rtalloc fallback handling")
Cc: stable@vger.kernel.org # v6.12
Reported-by: Christian Andres Saide <csaide@meta.com>
Signed-off-by: Rik van Riel <riel@surriel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/xfs/xfs_rtalloc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1997,10 +1997,14 @@ xfs_rtallocate_rtg(
if (error == -ENOSPC) {
xfs_rtbuf_cache_relse(&args);
error = 0;
+ start = 0;
}
}
- if (!error) {
+ /*
+ * Global search, runs when the near search did not find space.
+ */
+ if (!error && !start) {
error = xfs_rtallocate_extent_size(&args, minlen, maxlen, &len,
prod, &rtx);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 621/742] xfs: wait for direct I/O before swapping extents
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (611 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 620/742] xfs: keep successful near rt allocations Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 622/742] net: bridge: fix skb leak of reinjected link-local frames Greg Kroah-Hartman
` (113 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Daejun Park, Christoph Hellwig,
Carlos Maiolino
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daejun Park <daejun7.park@samsung.com>
commit 844bc1167f1b2d19d9495a556599af24dc4468bd upstream.
An AIO direct write drops the iolock before its bios complete.
XFS_IOC_SWAPEXT does not wait for it. The write can land in blocks that
the swap moved to the temporary file. Once xfs_fsr frees them, the
write corrupts whatever reuses them.
Wait for direct I/O first, as exchange-range does.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/xfs/xfs_bmap_util.c | 1 +
1 file changed, 1 insertion(+)
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1257,6 +1257,7 @@ xfs_swap_extent_flush(
{
int error;
+ inode_dio_wait(VFS_I(ip));
error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
if (error)
return error;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 622/742] net: bridge: fix skb leak of reinjected link-local frames
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (612 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 621/742] xfs: wait for direct I/O before swapping extents Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 623/742] net: e1000: fix warning in iounmap on probe failure Greg Kroah-Hartman
` (112 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Daniel Wade, Xia Yan,
Nikolay Aleksandrov, Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wade <danjwade95@gmail.com>
commit 98382d41f92f048cf3cbb7af415f48a722b19ebc upstream.
br_handle_frame() passes the link-local frames it neither forwards nor
delivers (01:80:c2:00:00:02 to 0d and 0f, unless set in the group
forward mask) through NF_HOOK() at NF_BR_LOCAL_IN. Since commit
3b2e2904deb3 ("net: bridge: fix per-port af_packet sockets") the okfn
only learns the source and returns 1, which becomes RX_HANDLER_PASS.
That commit sent the nf_queue case to RX_HANDLER_CONSUMED, which is
right for the synchronous return, but the frame comes back: on
reinjection nf_reinject() calls the okfn and ignores its return value,
because every other okfn consumes the skb. This one no longer does, so
nothing frees the frame. NFQA_CFG_F_FAIL_OPEN leaks it the same way
with no verdict at all, when the queue or the listener's socket is full.
Each frame leaks an skb, and one sent from a local socket keeps that
socket charged, so neither it nor the network namespace holding it is
freed. Bridge, rule and queue need only CAP_NET_ADMIN in a netns, so
with user namespaces an unprivileged user can exhaust kernel memory.
nf_reinject() cannot free the skb on a 1 from the okfn, because other
okfns return NET_RX_DROP, which is 1, after freeing it.
Call nf_hook() instead of NF_HOOK() and do the learning and the
RX_HANDLER_PASS return in br_handle_frame() on 1, as the 0x00 and 0x0e
cases already do and as vrf_rcv_nfhook() does. The okfn then runs only
for a reinjected frame, which br_handle_frame() has already reported
consumed and cannot pass on the port, so it learns from the frame and
frees it. These frames were not delivered before this change either.
Also set *pskb before the new RX_HANDLER_PASS, as the other such
returns do; skb_share_check() may have replaced the skb, and the commit
above added that return without the assignment.
Discovered by an AI code review agent and reproduced on unmodified
mainline under KASAN: an unprivileged user in a new user and network
namespace bridged a veth, queued link-local frames to an NFQUEUE
listener that accepted every one, and leaked an skb per frame. With
this patch the reinjected frames are freed and nothing leaks.
Fixes: 3b2e2904deb3 ("net: bridge: fix per-port af_packet sockets")
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Wade <danjwade95@gmail.com>
Reviewed-by: Xia Yan <yanxia@cmss.chinamobile.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/20261115130211.7724-1-danjwade95@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/bridge/br_input.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -255,13 +255,18 @@ static void __br_handle_local_finish(str
br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, 0);
}
-/* note: already called with rcu_read_lock */
+/* okfn of the link-local NF_BR_LOCAL_IN hook in br_handle_frame(). It is
+ * only called when a queued frame is reinjected, after br_handle_frame()
+ * returned RX_HANDLER_CONSUMED for it, so the frame can no longer be
+ * passed up on the port and has to be freed here.
+ * note: already called with rcu_read_lock
+ */
static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
{
__br_handle_local_finish(skb);
+ kfree_skb(skb);
- /* return 1 to signal the okfn() was called so it's ok to use the skb */
- return 1;
+ return 0;
}
static int nf_hook_bridge_pre(struct sk_buff *skb, struct sk_buff **pskb)
@@ -422,11 +427,14 @@ static rx_handler_result_t br_handle_fra
/* The else clause should be hit when nf_hook():
* - returns < 0 (drop/error)
* - returns = 0 (stolen/nf_queue)
- * Thus return 1 from the okfn() to signal the skb is ok to pass
+ * On 1 the frame is passed on here. The okfn() only runs if a
+ * queued frame is reinjected later, and must consume it then.
*/
- if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN,
+ if (nf_hook(NFPROTO_BRIDGE, NF_BR_LOCAL_IN,
dev_net(skb->dev), NULL, skb, skb->dev, NULL,
br_handle_local_finish) == 1) {
+ *pskb = skb;
+ __br_handle_local_finish(skb);
return RX_HANDLER_PASS;
} else {
return RX_HANDLER_CONSUMED;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 623/742] net: e1000: fix warning in iounmap on probe failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (613 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 622/742] net: bridge: fix skb leak of reinjected link-local frames Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 631/742] net: stmmac: dwmac1000: stop hardware from dropping checksum-error packets Greg Kroah-Hartman
` (111 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, syzbot+ca1ef9e2e234b8d3599b,
Svyatoslav Nikolenko, Aleksandr Loktionov, Tony Nguyen,
Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Svyatoslav Nikolenko <nsvatoslav515@gmail.com>
commit cf704cc62ffaf9206f1cbc12c2a3baec316b0ac1 upstream.
In e1000_probe(), the error unwinding path at err_sw_init unconditionally
calls iounmap(hw->ce4100_gbe_mdio_base_virt). On non-CE4100 hardware,
hw->ce4100_gbe_mdio_base_virt remains NULL.
Passing NULL to iounmap() triggers a WARN_ON_ONCE on x86 architectures.
Furthermore, on CE4100 hardware, if probe fails before or during
MDIO mapping, ce4100_gbe_mdio_base_virt is also NULL.
Fix this by adding a NULL pointer check before calling iounmap() on
hw->ce4100_gbe_mdio_base_virt. iounmap(hw->hw_addr) remains unconditional
because every code path reaching err_sw_init occurs after hw->hw_addr has
been successfully mapped.
Reported-by: syzbot+ca1ef9e2e234b8d3599b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ca1ef9e2e234b8d3599b
Fixes: 13acde8fffc0 ("e1000: cleanup CE4100 MDIO registers access")
Cc: stable@vger.kernel.org
Signed-off-by: Svyatoslav Nikolenko <nsvatoslav515@gmail.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20261113005823.130021-4-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/intel/e1000/e1000_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -1227,7 +1227,8 @@ err_mdio_ioremap:
kfree(adapter->rx_ring);
err_dma:
err_sw_init:
- iounmap(hw->ce4100_gbe_mdio_base_virt);
+ if (hw->ce4100_gbe_mdio_base_virt)
+ iounmap(hw->ce4100_gbe_mdio_base_virt);
iounmap(hw->hw_addr);
err_ioremap:
disable_dev = !test_and_set_bit(__E1000_DISABLED, &adapter->flags);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 631/742] net: stmmac: dwmac1000: stop hardware from dropping checksum-error packets
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (614 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 623/742] net: e1000: fix warning in iounmap on probe failure Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 632/742] net: stmmac: honour Rx checksum errors in the AF_XDP zero-copy path Greg Kroah-Hartman
` (110 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christian Schmidbauer,
Maxime Chevallier, Paolo Abeni
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Schmidbauer <opensource@grische.xyz>
commit 2dd48c4615a67ebb1762c2b0d79801be1949fcfb upstream.
When the checksum offload engine (CoE) is enabled, the dwmac1000 MAC
silently drops any frame for which the engine detects a checksum error,
before the driver sees it.
This breaks VXLAN over IPv6 with zero UDP checksums, which RFC 6935 and
RFC 6936 allow for tunnels.
Set DMA_CONTROL_DT so that such frames are delivered instead of dropped,
as commit fe4042797651 ("net: stmmac: dwmac4: stop hardware from
dropping checksum-error packets") did for dwmac4. CoE remains enabled,
so the driver still sees the error status and marks the skb
CHECKSUM_NONE for the stack to verify.
Set the bit only with enhanced descriptors. The normal descriptor parser
does not report a checksum-only error to the stack, so cores that use
it keep dropping such frames in hardware anyway.
Tested on an Aruba AP-325 (ipq806x-gmac-dwmac) with Rx checksum offload
on.
Link: https://lore.kernel.org/all/20250625132117.1b3264e8@kernel.org/
Link: https://github.com/freifunk-gluon/gluon/issues/3783
Fixes: 47dd7a540b8a ("net: add support for STMicroelectronics Ethernet controllers.")
Cc: <stable@vger.kernel.org> # 6.6.x: ee0aace5f844: net: stmmac: Correctly handle Rx checksum offload errors
Cc: <stable@vger.kernel.org> # 6.6.x
Signed-off-by: Christian Schmidbauer <opensource@grische.xyz>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20261114133640.3285413-4-opensource@grische.xyz
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/stmicro/stmmac/dwmac1000.h | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h
@@ -162,7 +162,7 @@ enum rx_tx_priority_ratio {
/* DMA CRS Control and Status Register Mapping */
/* DMA operation mode defines (start/stop tx/rx are placed in common header)*/
-/* Disable Drop TCP/IP csum error */
+#define DMA_CONTROL_DT 0x04000000 /* Disable Drop of TCP/IP csum errors */
#define DMA_CONTROL_RSF 0x02000000 /* Receive Store and Forward */
#define DMA_CONTROL_DFF 0x01000000 /* Disaable flushing */
/* Threshold for Activating the FC */
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c
@@ -15,6 +15,7 @@
#include <linux/io.h>
#include "dwmac1000.h"
#include "dwmac_dma.h"
+#include "stmmac.h"
static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)
{
@@ -129,6 +130,13 @@ static void dwmac1000_dma_operation_mode
{
u32 csr6 = readl(ioaddr + DMA_CHAN_CONTROL(channel));
+ /* Deliver checksum-error frames only with enhanced
+ * descriptors, because the normal descriptor parser does not
+ * report a checksum-only error.
+ */
+ if (priv->plat->enh_desc)
+ csr6 |= DMA_CONTROL_DT;
+
if (mode == SF_DMA_MODE) {
pr_debug("GMAC: enable RX store and forward mode\n");
csr6 |= DMA_CONTROL_RSF | DMA_CONTROL_DFF;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 632/742] net: stmmac: honour Rx checksum errors in the AF_XDP zero-copy path
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (615 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 631/742] net: stmmac: dwmac1000: stop hardware from dropping checksum-error packets Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 633/742] net: stmmac: re-enable on-chip parity checkers for XGMAC ASP 0x2 Greg Kroah-Hartman
` (109 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christian Schmidbauer,
Maxime Chevallier, Paolo Abeni
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Schmidbauer <opensource@grische.xyz>
commit fcfc52fcf89a3076c3a9afbbc70c0fecd2b5fc8d upstream.
Commit ee0aace5f844 ("net: stmmac: Correctly handle Rx checksum offload
errors") taught stmmac_rx() to honour the csum_none status, but
stmmac_dispatch_skb_zc() still ignores it and sets CHECKSUM_UNNECESSARY
for every IP frame whenever the checksum offload engine (CoE) is
enabled.
Since commit fe4042797651 ("net: stmmac: dwmac4: stop hardware from
dropping checksum-error packets") dwmac4 delivers such frames instead of
dropping them, so this path receives them.
Mark the skb CHECKSUM_NONE when csum_none is set, as stmmac_rx() does.
Fixes: bba2556efad6 ("net: stmmac: Enable RX via AF_XDP zero-copy")
Cc: <stable@vger.kernel.org>
Signed-off-by: Christian Schmidbauer <opensource@grische.xyz>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20261114133640.3285413-2-opensource@grische.xyz
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -5482,7 +5482,7 @@ static struct sk_buff *stmmac_construct_
static void stmmac_dispatch_skb_zc(struct stmmac_priv *priv, u32 queue,
struct dma_desc *p, struct dma_desc *np,
- struct xdp_buff *xdp)
+ struct xdp_buff *xdp, int status)
{
struct stmmac_rxq_stats *rxq_stats = &priv->xstats.rxq_stats[queue];
struct stmmac_channel *ch = &priv->channel[queue];
@@ -5510,7 +5510,8 @@ static void stmmac_dispatch_skb_zc(struc
skb->protocol = eth_type_trans(skb, priv->dev);
- if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb))
+ if (unlikely(!coe) || !stmmac_has_ip_ethertype(skb) ||
+ (status & csum_none))
skb_checksum_none_assert(skb);
else
skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -5732,7 +5733,8 @@ read_again:
switch (res) {
case STMMAC_XDP_PASS:
- stmmac_dispatch_skb_zc(priv, queue, p, np, buf->xdp);
+ stmmac_dispatch_skb_zc(priv, queue, p, np, buf->xdp,
+ status);
xsk_buff_free(buf->xdp);
break;
case STMMAC_XDP_CONSUMED:
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 633/742] net: stmmac: re-enable on-chip parity checkers for XGMAC ASP 0x2
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (616 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 632/742] net: stmmac: honour Rx checksum errors in the AF_XDP zero-copy path Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 634/742] net: usb: smsc75xx: reject frames without a full header and FCS Greg Kroah-Hartman
` (108 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Zxyan Zhu, Maxime Chevallier,
Nicolai Buchwitz, Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zxyan Zhu <zxyan0222@gmail.com>
commit 9c9863f9b9f120b771a908849157791a32eadb02 upstream.
Commit 669a55560e4b ("net: stmmac: Check more MAC HW features for XGMAC
Core 3.20") made dwxgmac3_safety_feat_config() bail out early for
asp == 0x2, assuming that configuration has no parity protection.
Per the DWC_xgmac databook, the ASP field of MAC_HW_Feature3 selects:
0x1 (AS_EPPE): all automotive safety features, with ECC and parity
ports on the external application interface
0x2 (AS_NEPPE): all automotive safety features, without ECC or
parity ports on the external application interface
0x3 (AS_PPE): all automotive safety features, with parity ports
on the external application interface
The reset value of the field is defined as:
(DWCXG_ASP_ALL && DWCXG_ASP_PPE == 1) ? "3"
: (DWCXG_ASP_ALL && DWCXG_ASP_PPE == 0) ? "2"
: (DWCXG_ASP_ALL && DWCXG_ASP_PPE == 2) ? "1" : "0"
so ASP 0x2 implies DWCXG_ASP_ALL = 1, where the internal FSM state
parity and timeout (MAC_FSM_Control) and the on-chip data-path parity
(MTL_DPP_CONTROL) features exist; only the ports on the external
application interface are absent. The early return therefore skips
enabling safety checkers that are present in the hardware.
Drop 0x2 from the condition so the FSM and data-path parity checkers
are enabled again.
Also update the safety feature descriptions printed by
stmmac_dma_cap_show() to spell out that ASP 0x1/0x2/0x3 differ only
in the ECC or parity ports on the external application interface; the
previous wording, "All Safety Features without ECC or Parity",
suggests the on-chip checkers are absent from an ASP 0x2 device.
Keep the early return for ASP 0x4 (EASP), which selects only ECC
protection for external memory and has no on-chip parity features.
Tested on XGMAC 3.10 and 3.40 cores.
Fixes: 669a55560e4b ("net: stmmac: Check more MAC HW features for XGMAC Core 3.20")
Cc: stable@vger.kernel.org
Signed-off-by: Zxyan Zhu <zxyan0222@gmail.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Link: https://patch.msgid.link/20261114015554.2187341-1-zxyan0222@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 6 +++---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
--- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c
@@ -859,10 +859,10 @@ dwxgmac3_safety_feat_config(void __iomem
value |= XGMAC_TCEIE; /* TSO Memory Correctable Error */
writel(value, ioaddr + XGMAC_DMA_ECC_INT_ENABLE);
- /* 0x2: Without ECC or Parity Ports on External Application Interface
- * 0x4: Only ECC Protection for External Memory feature is selected
+ /* 0x4: Only ECC Protection for External Memory feature is
+ * selected, without any on-chip parity protection
*/
- if (asp == 0x2 || asp == 0x4)
+ if (asp == 0x4)
return 0;
/* 4. Enable Parity and Timeout for FSM */
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -6699,9 +6699,9 @@ static int stmmac_dma_cap_show(struct se
};
static const char * const dwxgmac_safety_feature_desc[] = {
"No",
- "All Safety Features with ECC and Parity",
- "All Safety Features without ECC or Parity",
- "All Safety Features with Parity Only",
+ "All Safety Features with ECC and Parity Ports on External Application Interface",
+ "All Safety Features without ECC or Parity Ports on External Application Interface",
+ "All Safety Features with Parity Ports on External Application Interface",
"ECC Only",
"UNDEFINED",
"UNDEFINED",
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 634/742] net: usb: smsc75xx: reject frames without a full header and FCS
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (617 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 633/742] net: stmmac: re-enable on-chip parity checkers for XGMAC ASP 0x2 Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 635/742] nvme-auth: use the parsed offset for the DH-CHAP key Greg Kroah-Hartman
` (107 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Joas Antonio dos Santos, Andrew Lunn,
Jakub Kicinski
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <joasantonio108@gmail.com>
commit 1b02f90976d4bdf8c67d19dadf31b4bba05eb66f upstream.
smsc75xx_rx_fixup() takes the frame length from the RX command word
supplied by the device and strips the FCS by using "size - 4" for the
allocation, skb_put() and memcpy() of each frame that is not the last
one in the URB. The length is only checked against an upper bound and
against skb->len, so a device can report a length field of 2..5, which
gives a size of 0..3 after RXW_PADDING is subtracted.
size is a u32, so "size - 4" then wraps to 0xfffffffc..0xffffffff.
__netdev_alloc_skb() adds NET_SKB_PAD to the unsigned length, which
wraps back to a small value and the allocation succeeds. skb_put()
adds the length to the 32-bit skb->tail and skb->len, which also wrap,
so the skb_over_panic() check does not fire. The following memcpy()
then tries to copy almost 4 GiB from the URB buffer into that small
allocation and writes far beyond it.
A malicious or malfunctioning USB device can use this to corrupt
kernel memory or crash the machine.
A frame that holds an FCS but less than an Ethernet header is not
valid either. usbnet drops it when it is the last frame in the URB,
but the other frames go straight to usbnet_skb_return(), where
eth_type_trans() reads an Ethernet header that was never copied into
the new skb.
Reject frames that are too short to hold an Ethernet header and an
FCS, which covers both cases with one check.
The driver does not set FLAG_RX_ASSEMBLE, so usbnet already counts
rx_errors when smsc75xx_rx_fixup() returns 0. Also count
rx_length_errors for these frames, as usbnet does for the short frames
it drops itself.
Found by LLM-assisted source review.
Fixes: 1b3b2d9e772b ("net: usb: smsc75xx: stop lying about skb->truesize")
Cc: stable@vger.kernel.org
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20261112-smsc75xx-rx-fcs-v3-1-6ad0378d0384@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/usb/smsc75xx.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -2217,6 +2217,14 @@ static int smsc75xx_rx_fixup(struct usbn
return 0;
}
+ if (unlikely(size < ETH_HLEN + ETH_FCS_LEN)) {
+ netif_dbg(dev, rx_err, dev->net,
+ "size err rx_cmd_a=0x%08x\n",
+ rx_cmd_a);
+ dev->net->stats.rx_length_errors++;
+ return 0;
+ }
+
/* last frame in this batch */
if (skb->len == size) {
smsc75xx_rx_csum_offload(dev, skb, rx_cmd_a,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 635/742] nvme-auth: use the parsed offset for the DH-CHAP key
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (618 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 634/742] net: usb: smsc75xx: reject frames without a full header and FCS Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 636/742] nvme-loop: release the target request when SG setup fails Greg Kroah-Hartman
` (106 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Hannes Reinecke,
Christoph Hellwig, Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit f7141618d5d0b51bc2a64961bab738a0fe57e83f upstream.
nvme_auth_parse_key() accepts the DH-HMAC-CHAP key with
if (sscanf(secret, "DHHC-1:%hhd:%*s:", &key_hash) != 1)
return -EINVAL;
and then skips a hardcoded ten characters:
key = nvme_auth_extract_key(secret + 10, key_hash);
The ten characters assume that the hash identifier is exactly two
characters long. A string such as "DHHC-1:1:" still makes sscanf()
return 1, and secret + 10 then points one byte past the NUL terminator
of the buffer. nvme_auth_extract_key() starts with
strlen(secret), so it reads past the end of the allocation. The sysfs
dhchap_secret and dhchap_ctrl_secret stores only require seven
characters and a "DHHC-1:" prefix, so a short value reaches this code
(even though the nvme-fabrics option parser rejects secrets shorter than
eleven characters).
Use the %n conversion to obtain the real offset after the
"DHHC-1:<hash>:" prefix and reject a string where the prefix is not
complete. This accepts both one and two character hash identifiers and
never starts the key past the terminator.
Fixes: f50fff73d620 ("nvme: implement In-Band authentication")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/common/auth.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/drivers/nvme/common/auth.c
+++ b/drivers/nvme/common/auth.c
@@ -489,17 +489,19 @@ int nvme_auth_parse_key(const char *secr
{
struct nvme_dhchap_key *key;
u8 key_hash;
+ int offset = 0;
if (!secret) {
*ret_key = NULL;
return 0;
}
- if (sscanf(secret, "DHHC-1:%hhd:%*s:", &key_hash) != 1)
+ if (sscanf(secret, "DHHC-1:%hhd:%n", &key_hash, &offset) != 1 ||
+ !offset)
return -EINVAL;
/* Pass in the secret without the 'DHHC-1:XX:' prefix */
- key = nvme_auth_extract_key(secret + 10, key_hash);
+ key = nvme_auth_extract_key(secret + offset, key_hash);
if (IS_ERR(key)) {
*ret_key = NULL;
return PTR_ERR(key);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 636/742] nvme-loop: release the target request when SG setup fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (619 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 635/742] nvme-auth: use the parsed offset for the DH-CHAP key Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 637/742] nvme-tcp: require the R2T offset to match the data sent Greg Kroah-Hartman
` (105 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Shao Mingyin,
Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit f2937481c28033e10e8a29b8742a767e73c696df upstream.
nvme_loop_queue_rq() calls nvmet_req_init(), which takes a reference on
the submission queue percpu ref, pins the namespace and, for a
reservation-enabled namespace, takes a per-controller PR reference. If
sg_alloc_table_chained() then fails under memory pressure, the function
returns BLK_STS_RESOURCE without calling nvmet_req_uninit(). blk-mq
retries the same request and nvmet_req_init() overwrites req->ns and
req->pc_ref, leaking the queue, namespace and PR references taken by the
failed attempt each time this happens.
Release the request before returning BLK_STS_RESOURCE.
Fixes: 3a85a5de29ea ("nvme-loop: add a NVMe loopback host driver")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/target/loop.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -159,6 +159,7 @@ static blk_status_t nvme_loop_queue_rq(s
blk_rq_nr_phys_segments(req),
iod->sg_table.sgl, NVME_INLINE_SG_CNT)) {
nvme_cleanup_cmd(req);
+ nvmet_req_uninit(&iod->req);
return BLK_STS_RESOURCE;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 637/742] nvme-tcp: require the R2T offset to match the data sent
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (620 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 636/742] nvme-loop: release the target request when SG setup fails Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 638/742] nvme: avoid wrapping admin_timeout and io_timeout Greg Kroah-Hartman
` (104 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Shao Mingyin,
Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit 347d50d92e25d4b9c50c5f5c1d8b727b9c88d12c upstream.
nvme_tcp_handle_r2t() rejects offsets below data_sent but accepts
larger offsets. The send iterator still points at data_sent, so the
next H2CData PDU carries bytes from that position while advertising the
larger offset. A target that accepts the PDU can place the data at the
wrong position; the Linux target rejects it and fails the connection.
Require the R2T offset to equal data_sent, rejecting the invalid request
before transmitting data with a mismatched offset.
Fixes: 3f2304f8c6d6 ("nvme-tcp: add NVMe over TCP host driver")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/host/tcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -838,7 +838,7 @@ static int nvme_tcp_handle_r2t(struct nv
return -EPROTO;
}
- if (unlikely(r2t_offset < req->data_sent)) {
+ if (unlikely(r2t_offset != req->data_sent)) {
dev_err(queue->ctrl->ctrl.device,
"req %d unexpected r2t offset %u (expected %zu)\n",
rq->tag, r2t_offset, req->data_sent);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 638/742] nvme: avoid wrapping admin_timeout and io_timeout
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (621 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 637/742] nvme-tcp: require the R2T offset to match the data sent Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 639/742] nvme: reject invalid reconnect_delay sysfs values Greg Kroah-Hartman
` (103 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Yingjie Wang, Christoph Hellwig,
Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yingjie Wang <1075151112@qq.com>
commit 4a5aeebf1a00360bcc53c9e29fcd8d47aefa4c1d upstream.
NVME_ADMIN_TIMEOUT and NVME_IO_TIMEOUT multiply the admin_timeout and
io_timeout module parameters by HZ in unsigned int arithmetic, and
nvme_fw_act_work() does the same through secs_to_jiffies(). The parameters
accept any unsigned int, so values above UINT_MAX / HZ wrap. With HZ=1000,
io_timeout=4294968 becomes 704 jiffies, and a controller created afterwards
times out I/O after 0.7 seconds instead of about 49.7 days. On 32-bit
systems, results above MAX_JIFFY_OFFSET are also unsafe relative delays and
can be treated as already expired.
These large values are used in practice. AWS documents
nvme_core.io_timeout=4294967295 for EBS volumes and says Amazon Linux uses
it by default. With HZ=1000, the current code happens to wrap this setting
to 4294966296 jiffies, which still behaves as a long timeout on 64-bit
systems.
Add nvme_timeout_to_jiffies(), which caps the seconds value so that the
result fits the u32 timeout fields and stays within MAX_JIFFY_OFFSET for
32-bit timers, and use it for both macros and for the firmware
activation wait. On 64-bit kernels every timeout that did not wrap is
unchanged. Larger values saturate instead of being rejected so that the
documented setting keeps a long timeout.
Fixes: 8ae4e4477d8f ("nvme: update timeout module parameter type")
Cc: stable@vger.kernel.org
Signed-off-by: Yingjie Wang <1075151112@qq.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/host/core.c | 2 +-
drivers/nvme/host/nvme.h | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4893,7 +4893,7 @@ static void nvme_fw_act_work(struct work
if (ctrl->mtfa)
fw_act_timeout = jiffies + msecs_to_jiffies(ctrl->mtfa * 100);
else
- fw_act_timeout = jiffies + secs_to_jiffies(admin_timeout);
+ fw_act_timeout = jiffies + NVME_ADMIN_TIMEOUT;
nvme_quiesce_io_queues(ctrl);
while (nvme_ctrl_pp_status(ctrl)) {
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -22,11 +22,20 @@
extern const struct pr_ops nvme_pr_ops;
+/* Seconds to jiffies, capped for the u32 timeouts and timer delays */
+static inline unsigned int nvme_timeout_to_jiffies(unsigned int timeout)
+{
+ unsigned long max_secs;
+
+ max_secs = min_t(unsigned long, UINT_MAX, MAX_JIFFY_OFFSET) / HZ;
+ return min_t(unsigned long, timeout, max_secs) * HZ;
+}
+
extern unsigned int nvme_io_timeout;
-#define NVME_IO_TIMEOUT (nvme_io_timeout * HZ)
+#define NVME_IO_TIMEOUT nvme_timeout_to_jiffies(nvme_io_timeout)
extern unsigned int admin_timeout;
-#define NVME_ADMIN_TIMEOUT (admin_timeout * HZ)
+#define NVME_ADMIN_TIMEOUT nvme_timeout_to_jiffies(admin_timeout)
#define NVME_DEFAULT_KATO 5
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 639/742] nvme: reject invalid reconnect_delay sysfs values
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (622 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 638/742] nvme: avoid wrapping admin_timeout and io_timeout Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 640/742] nvme: stop asynchronous event work before ANA teardown Greg Kroah-Hartman
` (102 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit f92fe8dea19c743eb9e4d998ae0384344dd40091 upstream.
nvme_ctrl_reconnect_delay_store() stores whatever kstrtou32() accepted
into opts->reconnect_delay without validating it. The nvme-fabrics
option parser refuses reconnect_delay values that are zero or negative,
and the rest of the driver relies on that: nvme_ctrl_loss_tmo_store()
computes
opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo,
opts->reconnect_delay);
Writing 0 to reconnect_delay and then a positive value to ctrl_loss_tmo
therefore divides by zero in the kernel. In addition, a value larger
than INT_MAX is truncated to a negative int in the assignment and
silently bypasses the checks done by the fabrics parser.
Reject zero and values that do not fit into the signed int field.
Fixes: 764075fdcb2f ("nvme: expose reconnect_delay and ctrl_loss_tmo via sysfs")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/host/sysfs.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -630,6 +630,9 @@ static ssize_t nvme_ctrl_reconnect_delay
if (err)
return err;
+ if (!v || v > INT_MAX)
+ return -EINVAL;
+
ctrl->opts->reconnect_delay = v;
return count;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 640/742] nvme: stop asynchronous event work before ANA teardown
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (623 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 639/742] nvme: reject invalid reconnect_delay sysfs values Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 641/742] nvmet-fc: reject duplicate queue IDs on Create Connection Greg Kroah-Hartman
` (101 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Yaohan Li, Christoph Hellwig,
Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yaohan Li <shunsheng1218@gmail.com>
commit 9b657c565984f28976b1e471e3ce2f81cc269238 upstream.
NVMe ANA work has several producers, including ANA AER completion,
namespace scanning and failover processing.
An AER completion can queue ana_work for an ANA notice and can
separately queue async_event_work, which sends the AEN uevent and
submits the next asynchronous event request. These work items access
controller-owned state during asynchronous processing.
This issue was investigated and the fix was developed with AI
assistance (ZCode/GLM-4).
Fixes: 0d0b660f214dc ("nvme: add ANA support")
Cc: stable@vger.kernel.org
Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/host/core.c | 9 +++++++++
drivers/nvme/host/multipath.c | 7 +++++++
2 files changed, 16 insertions(+)
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -5185,6 +5185,15 @@ EXPORT_SYMBOL_GPL(nvme_start_ctrl);
void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
{
nvme_stop_keep_alive(ctrl);
+
+ /*
+ * An AER completion can queue async_event_work; drain it before the
+ * controller's final release. Note that ana_work has additional
+ * producers (namespace scanning via nvme_scan_work, and the failover
+ * path in nvme_failover_req), which is why nvme_mpath_uninit()
+ * separately cancels ana_work after this point.
+ */
+ cancel_work_sync(&ctrl->async_event_work);
nvme_hwmon_exit(ctrl);
nvme_fault_inject_fini(&ctrl->fault_inject);
dev_pm_qos_hide_latency_tolerance(ctrl->device);
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -1491,6 +1491,13 @@ out_uninit:
void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
{
+ /*
+ * ANA work can be queued by nvme_handle_aen_notice, nvme_scan_work,
+ * and nvme_failover_req. Drain remaining work before releasing the ANA
+ * resources.
+ */
+ cancel_work_sync(&ctrl->ana_work);
+
kvfree(ctrl->ana_log_buf);
ctrl->ana_log_buf = NULL;
ctrl->ana_log_size = 0;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 641/742] nvmet-fc: reject duplicate queue IDs on Create Connection
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (624 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 640/742] nvme: stop asynchronous event work before ANA teardown Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 642/742] nvmet-fcloop: free the LS request when delivery fails Greg Kroah-Hartman
` (100 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Shao Mingyin,
Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit 153eac284ebf68be74993643e9b2fe2f9b2b1d88 upstream.
nvmet_fc_alloc_target_queue() stores the new queue with
WARN_ON(assoc->queues[qid]);
assoc->queues[qid] = queue;
The queue ID comes straight from the Create Connection LS and is only
checked against NVMET_NR_QUEUES. A remote initiator can send a second
Create Connection for a queue ID that already exists, or send queue ID 0
which was already created as the admin queue by Create Association. The
WARN fires and the old pointer is overwritten: the old queue's base
reference is never put, so its workqueue, nvmet_sq and nvmet_cq are
never released. For the admin queue this also leaves the controller
reference unreachable from nvmet_fc_delete_target_assoc(), so the
controller and its subsystem reference leak permanently.
Publish the queue with cmpxchg() and destroy the newly created queue if
the slot is already taken, returning the normal queue allocation error
to the initiator. This keeps the existing error path and makes both
duplicate and admin queue IDs fail cleanly.
Fixes: c53432030d86 ("nvme-fabrics: Add target support for FC transport")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/target/fc.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -818,8 +818,17 @@ nvmet_fc_alloc_target_queue(struct nvmet
if (ret)
goto out_fail_iodlist;
- WARN_ON(assoc->queues[qid]);
- assoc->queues[qid] = queue;
+ /*
+ * Publish the queue only if the slot is still free. A Create
+ * Connection may arrive twice for the same queue ID, or with the
+ * admin queue ID that was created by Create Association; replacing
+ * the old pointer would leak that queue and its controller
+ * reference forever.
+ */
+ if (cmpxchg(&assoc->queues[qid], NULL, queue)) {
+ nvmet_sq_destroy(&queue->nvme_sq);
+ goto out_fail_iodlist;
+ }
return queue;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 642/742] nvmet-fcloop: free the LS request when delivery fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (625 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 641/742] nvmet-fc: reject duplicate queue IDs on Create Connection Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 643/742] nvmet-tcp: only wait for in-capsule data for inline SGLs Greg Kroah-Hartman
` (99 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Shao Mingyin,
Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit 8c1f99419b6cc51892e259497c8e10a5d079621a upstream.
fcloop_h2t_ls_req() allocates a fcloop_lsreq from lsreq_cache and hands
it to nvmet_fc_rcv_ls_req(). That function only takes ownership on
success and returns an error without invoking any completion callback
when the target port is shutting down, the LS payload is too large, or
the target has no free LS request slot. The error is returned as-is, so
the fcloop_lsreq is leaked; every failed LS during a target port
teardown or an LS slot exhaustion loses one slab object.
The target-to-host direction already frees the request when
nvme_fc_rcv_ls_req() fails. Do the same here.
Fixes: 772042dd38ee ("nvmet-fcloop: allocate/free fcloop_lsreq directly")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/target/fcloop.c | 2 ++
1 file changed, 2 insertions(+)
--- a/drivers/nvme/target/fcloop.c
+++ b/drivers/nvme/target/fcloop.c
@@ -379,6 +379,8 @@ fcloop_h2t_ls_req(struct nvme_fc_local_p
ret = nvmet_fc_rcv_ls_req(rport->targetport, rport,
&tls_req->ls_rsp,
lsreq->rqstaddr, lsreq->rqstlen);
+ if (ret)
+ kmem_cache_free(lsreq_cache, tls_req);
return ret;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 643/742] nvmet-tcp: only wait for in-capsule data for inline SGLs
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (626 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 642/742] nvmet-fcloop: free the LS request when delivery fails Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 644/742] nvmet: handle short reads and writes in the file backend Greg Kroah-Hartman
` (98 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit 9dac3b1aa2a99e126a5504b7f5bc781c8b2771e0 upstream.
nvmet-tcp decides whether to wait for in-capsule data using only the
write direction and SGL length. A write using a transport SGL can fit
within inline_data_size without carrying any in-capsule data. The
response path then withholds its R2T, leaving the command stuck.
If request initialization fails, the same length-only test both
withholds the error response and attempts to drain inline data that
will never arrive. This can also consume the following PDU as data
or a digest.
Require an offset data-block SGL in both checks. Share a helper that
only uses command and port fields, as the completion callback can run
before nvmet_req_init() has finished.
Fixes: bdaf13279192 ("nvmet-tcp: fix a segmentation fault during io parsing error")
Fixes: 872d26a391da ("nvmet-tcp: add NVMe over TCP target driver")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/target/tcp.c | 42 +++++++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 13 deletions(-)
--- a/drivers/nvme/target/tcp.c
+++ b/drivers/nvme/target/tcp.c
@@ -270,6 +270,30 @@ static inline bool nvmet_tcp_has_inline_
!cmd->rbytes_done;
}
+/*
+ * Check whether the SGL of @cmd carries in-capsule data that the host
+ * will send right after the command PDU. Only the offset form of the
+ * data block descriptor is in-capsule; a regular transport SGL is
+ * fetched through an R2T instead.
+ */
+static inline bool nvmet_tcp_sgl_is_inline(struct nvmet_tcp_cmd *cmd)
+{
+ struct nvme_sgl_desc *sgl = &cmd->req.cmd->common.dptr.sgl;
+ u32 len = le32_to_cpu(sgl->length);
+
+ if (sgl->type != ((NVME_SGL_FMT_DATA_DESC << 4) |
+ NVME_SGL_FMT_OFFSET))
+ return false;
+
+ if (!nvme_is_write(cmd->req.cmd))
+ return false;
+
+ if (!len)
+ return false;
+
+ return len <= cmd->req.port->inline_data_size;
+}
+
static inline struct nvmet_tcp_cmd *
nvmet_tcp_get_cmd(struct nvmet_tcp_queue *queue)
{
@@ -626,25 +650,19 @@ static void nvmet_tcp_queue_response(str
struct nvmet_tcp_queue *queue = cmd->queue;
enum nvmet_tcp_recv_state queue_state;
struct nvmet_tcp_cmd *queue_cmd;
- struct nvme_sgl_desc *sgl;
- u32 len;
/* Pairs with store_release in nvmet_prepare_receive_pdu() */
queue_state = smp_load_acquire(&queue->rcv_state);
queue_cmd = READ_ONCE(queue->cmd);
if (unlikely(cmd == queue_cmd)) {
- sgl = &cmd->req.cmd->common.dptr.sgl;
- len = le32_to_cpu(sgl->length);
-
/*
- * Wait for inline data before processing the response.
- * Avoid using helpers, this might happen before
- * nvmet_req_init is completed.
+ * Wait for in-capsule data before processing the response.
+ * This can happen before nvmet_req_init() has completed, so
+ * only look at the SGL descriptor itself.
*/
if (queue_state == NVMET_TCP_RECV_PDU &&
- len && len <= cmd->req.port->inline_data_size &&
- nvme_is_write(cmd->req.cmd))
+ nvmet_tcp_sgl_is_inline(cmd))
return;
}
@@ -982,7 +1000,6 @@ static int nvmet_tcp_handle_icreq(struct
static int nvmet_tcp_handle_req_failure(struct nvmet_tcp_queue *queue,
struct nvmet_tcp_cmd *cmd, struct nvmet_req *req)
{
- size_t data_len = le32_to_cpu(req->cmd->common.dptr.sgl.length);
int ret;
/*
@@ -992,8 +1009,7 @@ static int nvmet_tcp_handle_req_failure(
* otherwise we will need to prepare a buffer and receive the
* stale data before continuing forward.
*/
- if (!nvme_is_write(cmd->req.cmd) || !data_len ||
- data_len > cmd->req.port->inline_data_size) {
+ if (!nvmet_tcp_sgl_is_inline(cmd)) {
nvmet_prepare_receive_pdu(queue);
return 0;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 644/742] nvmet: handle short reads and writes in the file backend
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (627 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 643/742] nvmet-tcp: only wait for in-capsule data for inline SGLs Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 645/742] nvmet: roll back queue bindings on connection failure Greg Kroah-Hartman
` (97 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Shao Mingyin,
Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit 1738de07a79b9abdcffe03571c442033b80e7fed upstream.
When the file backend falls back to its bvec mempool, large requests
are submitted in synchronous chunks. A short completion advances the
file position by the full chunk length and is eventually overwritten
with the total request length. The target reports success for an
incomplete write or returns unread buffer contents as valid data.
The common completion path has another short-I/O case: a zero-byte
return, such as a read at EOF after the backing file is truncated, is
passed to errno_to_nvme_status() and becomes success.
Stop at any incomplete chunk and convert nonnegative short completions
to -EIO in both paths. Preserve negative errors and full completions.
Fixes: d5eff33ee6f8 ("nvmet: add simple file backed ns support")
Fixes: c6aa3542e010 ("nvmet: add error log support for file backend")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/target/io-cmd-file.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -113,7 +113,7 @@ static void nvmet_file_io_done(struct ki
}
if (unlikely(ret != req->transfer_len))
- status = errno_to_nvme_status(req, ret);
+ status = errno_to_nvme_status(req, ret < 0 ? ret : -EIO);
nvmet_req_complete(req, status);
}
@@ -150,8 +150,11 @@ static bool nvmet_file_execute_io(struct
if (unlikely(is_sync) &&
(nr_bvec - 1 == 0 || bv_cnt == NVMET_MAX_MPOOL_BVEC)) {
ret = nvmet_file_submit_bvec(req, pos, bv_cnt, len, 0);
- if (ret < 0)
+ if (ret != len) {
+ if (ret >= 0)
+ ret = -EIO;
goto complete;
+ }
pos += len;
bv_cnt = 0;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 645/742] nvmet: roll back queue bindings on connection failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (628 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 644/742] nvmet: handle short reads and writes in the file backend Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 646/742] nvmet: use GFP_KERNEL for PR allocations Greg Kroah-Hartman
` (96 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Christoph Hellwig, Shao Mingyin,
Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit 3f82752e089283eb8204b9d2ebd8246077031173 upstream.
nvmet_install_queue() publishes the SQ controller pointer before
claiming the CQ. If the CQ is already connected, it leaves the SQ
pointer and the controller reference taken for it behind on failure.
An install_queue() callback failure also leaves the CQ bound after
clearing the SQ pointer. The reference taken in nvmet_install_queue()
is in addition to the one the caller already holds: the caller's put
releases the reference acquired before the call, while this one belongs
to the CQ binding. It is not released on this path, so the controller
stays alive and a Connect retry on the same queue keeps finding the
stale binding.
Clear the tentative SQ binding and release the extra reference on a CQ
conflict. On a transport installation failure, destroy the CQ binding
as well, so its controller table entry and reference are released.
Link: https://lore.kernel.org/all/20261106015842.3534898-6-kanie@linux.alibaba.com/
Fixes: bb78836b3a7c ("nvmet: fabrics: add CQ init and destroy")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/target/fabrics-cmd.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/nvme/target/fabrics-cmd.c
+++ b/drivers/nvme/target/fabrics-cmd.c
@@ -216,6 +216,8 @@ static u16 nvmet_install_queue(struct nv
if (old) {
pr_warn("queue already connected!\n");
req->error_loc = offsetof(struct nvmf_connect_command, opcode);
+ req->sq->ctrl = NULL;
+ nvmet_ctrl_put(ctrl);
return NVME_SC_CONNECT_CTRL_BUSY | NVME_STATUS_DNR;
}
@@ -242,6 +244,7 @@ static u16 nvmet_install_queue(struct nv
err:
req->sq->ctrl = NULL;
+ nvmet_cq_destroy(req->cq);
return ret;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 646/742] nvmet: use GFP_KERNEL for PR allocations
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (629 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 645/742] nvmet: roll back queue bindings on connection failure Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 647/742] nvmet: use overflow-safe range checks in the file backend Greg Kroah-Hartman
` (95 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Hannes Reinecke, Christoph Hellwig,
Nilay Shroff, Guixin Liu, Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guixin Liu <kanie@linux.alibaba.com>
commit 976311c5594a7a26047891f087ad59a804e02baa upstream.
nvmet_pr_update_reg_attr() and nvmet_pr_alloc_and_insert_pc_ref()
allocate with GFP_ATOMIC, but both run in sleepable context: the PR
command handlers execute from the transport workqueues and take the
pr_sem semaphore, and the pc_ref allocation is reached from the
connect and configfs paths. The latter function even passes
GFP_KERNEL to the percpu_ref_init() in the same scope, so the
GFP_ATOMIC only raises the failure rate for no reason.
Switch both allocations to GFP_KERNEL.
Fixes: 5a47c2080a73 ("nvmet: support reservation feature")
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/target/pr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/drivers/nvme/target/pr.c
+++ b/drivers/nvme/target/pr.c
@@ -335,7 +335,7 @@ static u16 nvmet_pr_update_reg_attr(stru
return NVME_SC_SUCCESS;
}
- new = kmalloc_obj(*new, GFP_ATOMIC);
+ new = kmalloc_obj(*new, GFP_KERNEL);
if (!new)
return NVME_SC_INTERNAL;
@@ -1040,7 +1040,7 @@ static int nvmet_pr_alloc_and_insert_pc_
struct nvmet_pr_per_ctrl_ref *pc_ref;
int ret;
- pc_ref = kmalloc_obj(*pc_ref, GFP_ATOMIC);
+ pc_ref = kmalloc_obj(*pc_ref, GFP_KERNEL);
if (!pc_ref)
return -ENOMEM;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 647/742] nvmet: use overflow-safe range checks in the file backend
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (630 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 646/742] nvmet: use GFP_KERNEL for PR allocations Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 648/742] nvmet: zero the entire Get Log Page transfer buffer Greg Kroah-Hartman
` (94 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Christoph Hellwig,
Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit bcd5316e708d418f03707c183571549ad878cfff upstream.
The file backend shifts a host-supplied SLBA to form a byte offset
before checking it against the namespace size. The shift can discard
high bits: with a 4 KiB block size, SLBA 2^52 + 1 becomes offset 4096.
The range check then accepts a command aimed outside the namespace and
the backend accesses data at the wrapped offset.
Reject overflowing LBA-to-byte conversions and check the transfer
length against the remaining namespace size without adding it to the
offset. Apply the checks to reads, writes, discard and write zeroes.
Fixes: 9c891c139894 ("nvmet: check fileio lba range access boundaries")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/target/io-cmd-file.c | 40 +++++++++++++++++++++++++++-----------
1 file changed, 29 insertions(+), 11 deletions(-)
--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -117,6 +117,19 @@ static void nvmet_file_io_done(struct ki
nvmet_req_complete(req, status);
}
+static bool nvmet_file_check_lba_range(struct nvmet_req *req, u64 slba,
+ u64 len, loff_t *pos)
+{
+ u64 pos64;
+
+ if (check_shl_overflow(slba, req->ns->blksize_shift, &pos64) ||
+ pos64 > req->ns->size || len > req->ns->size - pos64)
+ return false;
+
+ *pos = pos64;
+ return true;
+}
+
static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags)
{
ssize_t nr_bvec = req->sg_cnt;
@@ -131,8 +144,9 @@ static bool nvmet_file_execute_io(struct
if (req->f.mpool_alloc && nr_bvec > NVMET_MAX_MPOOL_BVEC)
is_sync = true;
- pos = le64_to_cpu(req->cmd->rw.slba) << req->ns->blksize_shift;
- if (unlikely(pos + req->transfer_len > req->ns->size)) {
+ if (unlikely(!nvmet_file_check_lba_range(req,
+ le64_to_cpu(req->cmd->rw.slba),
+ req->transfer_len, &pos))) {
ret = -ENOSPC;
goto complete;
}
@@ -282,19 +296,22 @@ static void nvmet_file_execute_discard(s
int i;
for (i = 0; i <= le32_to_cpu(req->cmd->dsm.nr); i++) {
+ u64 len64;
+
status = nvmet_copy_from_sgl(req, i * sizeof(range), &range,
sizeof(range));
if (status)
break;
- offset = le64_to_cpu(range.slba) << req->ns->blksize_shift;
- len = le32_to_cpu(range.nlb);
- len <<= req->ns->blksize_shift;
- if (offset + len > req->ns->size) {
+ if (check_shl_overflow((u64)le32_to_cpu(range.nlb),
+ req->ns->blksize_shift, &len64) ||
+ !nvmet_file_check_lba_range(req, le64_to_cpu(range.slba),
+ len64, &offset)) {
req->error_slba = le64_to_cpu(range.slba);
status = errno_to_nvme_status(req, -ENOSPC);
break;
}
+ len = len64;
ret = vfs_fallocate(req->ns->file, mode, offset, len);
if (ret && ret != -EOPNOTSUPP) {
@@ -339,16 +356,17 @@ static void nvmet_file_write_zeroes_work
int mode = FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE;
loff_t offset;
loff_t len;
+ u64 len64;
int ret;
- offset = le64_to_cpu(write_zeroes->slba) << req->ns->blksize_shift;
- len = (((sector_t)le16_to_cpu(write_zeroes->length) + 1) <<
- req->ns->blksize_shift);
-
- if (unlikely(offset + len > req->ns->size)) {
+ if (check_shl_overflow((u64)le16_to_cpu(write_zeroes->length) + 1,
+ req->ns->blksize_shift, &len64) ||
+ !nvmet_file_check_lba_range(req, le64_to_cpu(write_zeroes->slba),
+ len64, &offset)) {
nvmet_req_complete(req, errno_to_nvme_status(req, -ENOSPC));
return;
}
+ len = len64;
ret = vfs_fallocate(req->ns->file, mode, offset, len);
nvmet_req_complete(req, ret < 0 ? errno_to_nvme_status(req, ret) : 0);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 648/742] nvmet: zero the entire Get Log Page transfer buffer
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (631 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 647/742] nvmet: use overflow-safe range checks in the file backend Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 649/742] nvmet: zns: return the namespace lookup error for Identify Greg Kroah-Hartman
` (93 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit ad606ae5635b68e324005aaa06421be752619dab upstream.
Several fixed-size Get Log Page handlers copy only the log structure
and leave the rest of the host buffer untouched. The transport buffers
are not zeroed, so a host requesting more bytes than the structure
receives stale kernel memory.
Zero the entire transfer length before filling the buffer in the
Supported Log Pages, Commands Supported and Effects, Supported
Features, Endurance Group, Rotational Media Information and Reservation
handlers. For the Error log, also clamp the ring walk to the requested
length and propagate copy failures instead of completing with success.
The Rotational Media Information handler now accepts a buffer larger
than its fixed structure.
Fixes: 11ad507784ed ("nvmet: add error log page cmd handler")
Fixes: 83acb24e6de7 ("nvmet: implement supported log pages")
Fixes: 0866bf0c3778 ("nvmet: add commands supported and effects log page")
Fixes: e973c91727d4 ("nvmet: implement supported features log")
Fixes: 266b652c65b4 ("nvmet: implement endurance groups")
Fixes: 5fd075cdaf36 ("nvmet: implement rotational media information log")
Fixes: 5a47c2080a73 ("nvmet: support reservation feature")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/target/admin-cmd.c | 51 +++++++++++++++++++++++++++++++---------
drivers/nvme/target/pr.c | 6 ++++
2 files changed, 46 insertions(+), 11 deletions(-)
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -176,16 +176,35 @@ static void nvmet_execute_get_log_page_e
{
struct nvmet_ctrl *ctrl = req->sq->ctrl;
unsigned long flags;
- off_t offset = 0;
+ u32 offset = 0;
+ u32 len;
u64 slot;
u64 i;
+ u16 status = 0;
+
+ status = nvmet_zero_sgl(req, 0, req->transfer_len);
+ if (status) {
+ nvmet_req_complete(req, status);
+ return;
+ }
+
+ len = min_t(u32, req->transfer_len,
+ NVMET_ERROR_LOG_SLOTS * sizeof(struct nvme_error_slot));
spin_lock_irqsave(&ctrl->error_lock, flags);
+
+ /*
+ * The NVMe base specification requires the most recent error to be
+ * the first log entry, so walk the ring backwards from the slot of
+ * the last error and stop at the end of the requested buffer.
+ */
slot = ctrl->err_counter % NVMET_ERROR_LOG_SLOTS;
- for (i = 0; i < NVMET_ERROR_LOG_SLOTS; i++) {
- if (nvmet_copy_to_sgl(req, offset, &ctrl->slots[slot],
- sizeof(struct nvme_error_slot)))
+ for (i = 0; i < NVMET_ERROR_LOG_SLOTS &&
+ offset + sizeof(struct nvme_error_slot) <= len; i++) {
+ status = nvmet_copy_to_sgl(req, offset, &ctrl->slots[slot],
+ sizeof(struct nvme_error_slot));
+ if (status)
break;
if (slot == 0)
@@ -195,7 +214,7 @@ static void nvmet_execute_get_log_page_e
offset += sizeof(struct nvme_error_slot);
}
spin_unlock_irqrestore(&ctrl->error_lock, flags);
- nvmet_req_complete(req, 0);
+ nvmet_req_complete(req, status);
}
static void nvmet_execute_get_supported_log_pages(struct nvmet_req *req)
@@ -221,7 +240,9 @@ static void nvmet_execute_get_supported_
logs->lids[NVME_LOG_RMI] = cpu_to_le32(NVME_LIDS_LSUPP);
logs->lids[NVME_LOG_RESERVATION] = cpu_to_le32(NVME_LIDS_LSUPP);
- status = nvmet_copy_to_sgl(req, 0, logs, sizeof(*logs));
+ status = nvmet_zero_sgl(req, 0, req->transfer_len);
+ if (!status)
+ status = nvmet_copy_to_sgl(req, 0, logs, sizeof(*logs));
kfree(logs);
out:
nvmet_req_complete(req, status);
@@ -303,7 +324,7 @@ static void nvmet_execute_get_log_page_r
goto out;
}
- if (req->transfer_len != sizeof(*log)) {
+ if (req->transfer_len < sizeof(*log)) {
status = NVME_SC_SGL_INVALID_DATA | NVME_STATUS_DNR;
goto out;
}
@@ -321,7 +342,9 @@ static void nvmet_execute_get_log_page_r
else
log->numa = cpu_to_le16(1);
- status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
+ status = nvmet_zero_sgl(req, 0, req->transfer_len);
+ if (!status)
+ status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
kfree(log);
out:
nvmet_req_complete(req, status);
@@ -436,7 +459,9 @@ static void nvmet_execute_get_log_cmd_ef
goto free;
}
- status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
+ status = nvmet_zero_sgl(req, 0, req->transfer_len);
+ if (!status)
+ status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
free:
kfree(log);
out:
@@ -527,7 +552,9 @@ static void nvmet_execute_get_log_page_e
put_unaligned_le64(host_writes, &log->hwc[0]);
put_unaligned_le64(data_units_written, &log->duw[0]);
copy:
- status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
+ status = nvmet_zero_sgl(req, 0, req->transfer_len);
+ if (!status)
+ status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log));
kfree(log);
out:
nvmet_req_complete(req, status);
@@ -610,7 +637,9 @@ static void nvmet_execute_get_log_page_f
features->fis[NVME_FEAT_RESV_MASK] =
cpu_to_le32(NVME_FIS_FSUPP | NVME_FIS_NSCPE);
- status = nvmet_copy_to_sgl(req, 0, features, sizeof(*features));
+ status = nvmet_zero_sgl(req, 0, req->transfer_len);
+ if (!status)
+ status = nvmet_copy_to_sgl(req, 0, features, sizeof(*features));
kfree(features);
out:
nvmet_req_complete(req, status);
--- a/drivers/nvme/target/pr.c
+++ b/drivers/nvme/target/pr.c
@@ -99,6 +99,12 @@ void nvmet_execute_get_log_page_resv(str
u64 cur_count;
u64 next_count;
+ status = nvmet_zero_sgl(req, 0, req->transfer_len);
+ if (status) {
+ nvmet_req_complete(req, status);
+ return;
+ }
+
mutex_lock(&log_mgr->lock);
if (!kfifo_get(&log_mgr->log_queue, &log))
goto out;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 649/742] nvmet: zns: return the namespace lookup error for Identify
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (632 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 648/742] nvmet: zero the entire Get Log Page transfer buffer Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 650/742] scsi: target: core: Parse APTPL res_type and res_scope as hex Greg Kroah-Hartman
` (92 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Shao Mingyin, Keith Busch
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit 687f3014afcd5826fa3d8f40b445f647b5a379b6 upstream.
nvmet_execute_identify_ns_zns() jumps to done when nvmet_req_find_ns()
fails, and that label overwrites status with a successful copy of the
zeroed identify data. An Identify with CNS 05h and CSI 02h for a
missing NSID therefore completes with SUCCESS and zeroed data instead
of Invalid Namespace.
Return the lookup error instead.
Fixes: aaf2e048af27 ("nvmet: add ZBD over ZNS backend support")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvme/target/zns.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/drivers/nvme/target/zns.c
+++ b/drivers/nvme/target/zns.c
@@ -108,7 +108,7 @@ void nvmet_execute_identify_ns_zns(struc
status = nvmet_req_find_ns(req);
if (status)
- goto done;
+ goto out;
if (nvmet_ns_revalidate(req->ns)) {
mutex_lock(&req->ns->subsys->lock);
@@ -140,7 +140,6 @@ void nvmet_execute_identify_ns_zns(struc
mar--;
id_zns->mar = cpu_to_le32(mar);
-done:
status = nvmet_copy_to_sgl(req, 0, id_zns, sizeof(*id_zns));
out:
kfree(id_zns);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 650/742] scsi: target: core: Parse APTPL res_type and res_scope as hex
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (633 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 649/742] nvmet: zns: return the namespace lookup error for Identify Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 651/742] scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition() Greg Kroah-Hartman
` (91 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Ciro Iriarte,
Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ciro Iriarte <ciro.iriarte+software@gmail.com>
commit 08f08a6d49efc422258edba802faa4fc7677309e upstream.
core_scsi3_update_aptpl_buf() saves the reservation holder's type and scope
to the APTPL metadata file as zero-padded hex ("res_type=%02x",
"res_scope=%02x"), but target_pr_res_aptpl_metadata_store() reads them back
with "%d" tokens and match_int(), which parse with base 0. A leading zero
selects octal, so match_token() parses only the "0" of "res_type=08", the
trailing "8" makes the token not match, and the field is ignored as
unknown. An Exclusive Access - All Registrants holder (type 0x8) is left
with type 0 and the write fails with -EINVAL and
Illegal PR type: 0x00 for reservation holder
Userspace that restores APTPL state by writing the saved records back to
pr/res_aptpl_metadata (rtslib-fb does this when it recreates a storage
object) therefore loses every type 8 reservation across a target restart,
and with rtslib the storage object creation fails. The other valid types
(1, 3, 5, 6, 7) and scope 0 only work because their octal and decimal
values coincide.
Keep the on-disk format and parse both fields as hex. The valid type and
scope values have the same hex and decimal representation, so records
written in decimal by hand keep working.
Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6")
Cc: stable@vger.kernel.org
Signed-off-by: Ciro Iriarte <ciro.iriarte+software@gmail.com>
Link: https://patch.msgid.link/ea903e6c-09b5-4a11-80e8-6e1387f39ef5@gmail.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/target/target_core_configfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2126,8 +2126,8 @@ static match_table_t tokens = {
{Opt_initiator_sid, "initiator_sid=%s"},
{Opt_sa_res_key, "sa_res_key=%s"},
{Opt_res_holder, "res_holder=%d"},
- {Opt_res_type, "res_type=%d"},
- {Opt_res_scope, "res_scope=%d"},
+ {Opt_res_type, "res_type=%x"},
+ {Opt_res_scope, "res_scope=%x"},
{Opt_res_all_tg_pt, "res_all_tg_pt=%d"},
{Opt_mapped_lun, "mapped_lun=%u"},
{Opt_target_fabric, "target_fabric=%s"},
@@ -2229,13 +2229,13 @@ static ssize_t target_pr_res_aptpl_metad
res_holder = arg;
break;
case Opt_res_type:
- ret = match_int(args, &arg);
+ ret = match_hex(args, &arg);
if (ret)
goto out;
type = (u8)arg;
break;
case Opt_res_scope:
- ret = match_int(args, &arg);
+ ret = match_hex(args, &arg);
if (ret)
goto out;
break;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 651/742] scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (634 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 650/742] scsi: target: core: Parse APTPL res_type and res_scope as hex Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 652/742] scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store() Greg Kroah-Hartman
` (90 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Shao Mingyin,
Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit c0bb6614132c64205a3c40c32dc1494c1bfeffe1 upstream.
core_alua_do_port_transition() assumes that the device has an ALUA LU group
member and that the member is associated with an LU group. Neither is
guaranteed: internal-use HBAs never allocate dev_alua_lu_gp_mem, and the
association with an LU group is dropped when "NULL" is written to the
device's alua_lu_gp attribute.
The configfs path can reach the second case. After clearing the LU group
association, writing the implicit ALUA access state of a target port group
calls core_alua_do_port_transition(), which dereferences the NULL lu_gp in
atomic_inc(&lu_gp->lu_gp_ref_cnt).
Return -ENODEV when the device has no LU group association instead.
Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261026195133237y2UxJLoV1FK6aD1zrFbIU@zte.com.cn
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/target/target_core_alua.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -1081,8 +1081,15 @@ int core_alua_do_port_transition(
return -EINVAL;
local_lu_gp_mem = l_dev->dev_alua_lu_gp_mem;
+ if (!local_lu_gp_mem)
+ return -ENODEV;
+
spin_lock(&local_lu_gp_mem->lu_gp_mem_lock);
lu_gp = local_lu_gp_mem->lu_gp;
+ if (!lu_gp) {
+ spin_unlock(&local_lu_gp_mem->lu_gp_mem_lock);
+ return -ENODEV;
+ }
atomic_inc(&lu_gp->lu_gp_ref_cnt);
spin_unlock(&local_lu_gp_mem->lu_gp_mem_lock);
/*
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 652/742] scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (635 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 651/742] scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 653/742] scsi: target: iscsi: Check for existing sessions only after authentication Greg Kroah-Hartman
` (89 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Shao Mingyin,
Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit fe5988e8708e1d42cb844bd9ac8f0a51388061fc upstream.
Writing "NULL" to the alua_lu_gp attribute clears the ALUA LU group
association of a device. The attribute can be written again after the
association has already been cleared. In that case lu_gp_mem->lu_gp and
lu_gp_new are both NULL, but the code still calls
__core_alua_attach_lu_gp_mem(), which dereferences the NULL lu_gp pointer:
BUG: kernel NULL pointer dereference, address: 0000000000000000
...
__core_alua_attach_lu_gp_mem
target_dev_alua_lu_gp_store
Clearing an already cleared association is a no-op, so return early when
there is no association left to clear.
Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261026194955694FnXGoQ352dstLk5HPBqCG@zte.com.cn
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/target/target_core_configfs.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2547,6 +2547,14 @@ static ssize_t target_dev_alua_lu_gp_sto
spin_lock(&lu_gp_mem->lu_gp_mem_lock);
lu_gp = lu_gp_mem->lu_gp;
+ if (!lu_gp && !lu_gp_new) {
+ /*
+ * The LU group association has already been cleared, so
+ * there is nothing left to do.
+ */
+ spin_unlock(&lu_gp_mem->lu_gp_mem_lock);
+ return count;
+ }
if (lu_gp) {
/*
* Clearing an existing lu_gp association, and replacing
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 653/742] scsi: target: iscsi: Check for existing sessions only after authentication
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (636 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 652/742] scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 654/742] scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails Greg Kroah-Hartman
` (88 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Praneeth Balasubramanian,
Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Praneeth Balasubramanian <praneeth@ucsb.edu>
commit 48d3b732e5ad3fffe74e033d9a3cf47ebaa314b0 upstream.
In the operational-negotiation path (CSG=1), iscsi_target_handle_csg_one()
calls iscsi_target_check_for_existing_instances() before
iscsi_conn_authenticated(). An initiator can therefore send a first Login
PDU with CSG=1, TSIH=0 and no CHAP exchange, carrying the InitiatorName and
ISID of an existing session. The target reinstates that session, which
tears down the legitimate initiator's connection. Only afterwards does it
reject the login with AUTH_FAILED.
iscsi_check_for_session_reinstatement() matches on ISID, InitiatorName and
SessionType only. The InitiatorName is not secret, and open-iscsi ISIDs are
a fixed OUI followed by a small session counter. A remote peer with no
credentials can thus repeatedly disconnect a CHAP-authenticated session and
keep its I/O failing.
The comment above iscsi_target_check_for_existing_instances() already
states the intended invariant:
NOTE: We check for existing sessions or connections AFTER the initiator
has been successfully authenticated in order to protect against faked
ISID/TSIH combinations.
The security-negotiation path (CSG=0) honours this, calling the check only
once authentication completes. Move the CSG=1 call below the authentication
check so both paths behave the same. When authentication is not required,
iscsi_conn_authenticated() returns true and behaviour is unchanged.
Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")
Cc: stable@vger.kernel.org
Signed-off-by: Praneeth Balasubramanian <praneeth@ucsb.edu>
Link: https://patch.msgid.link/20261029205456.1211532-1-praneethb2002@gmail.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/target/iscsi/iscsi_target_nego.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/target/iscsi/iscsi_target_nego.c
+++ b/drivers/target/iscsi/iscsi_target_nego.c
@@ -982,9 +982,6 @@ static int iscsi_target_handle_csg_one(s
if (iscsi_target_check_first_request(conn, login) < 0)
return -1;
- if (iscsi_target_check_for_existing_instances(conn, login) < 0)
- return -1;
-
ret = iscsi_encode_text_output(
PHASE_OPERATIONAL|PHASE_DECLARATIVE,
SENDER_TARGET,
@@ -1008,6 +1005,9 @@ static int iscsi_target_handle_csg_one(s
return -1;
}
+ if (iscsi_target_check_for_existing_instances(conn, login) < 0)
+ return -1;
+
if (!iscsi_check_negotiated_keys(conn->param_list))
if ((login_req->flags & ISCSI_FLAG_LOGIN_NEXT_STAGE3) &&
(login_req->flags & ISCSI_FLAG_LOGIN_TRANSIT))
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 654/742] scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (637 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 653/742] scsi: target: iscsi: Check for existing sessions only after authentication Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 655/742] scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper Greg Kroah-Hartman
` (87 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stanley Jhu, Bart Van Assche,
Peter Wang, Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <stanleyjhu@google.com>
commit 2b8541edf7c43f0294c45d2e687bbc1288292f4e upstream.
ufs_bsg_request() resumes the UFS device W-LUN with ufshcd_rpm_get_sync()
and ignores its return value:
1. The W-LUN is runtime suspended.
2. User space submits a BSG request.
3. ufs_bsg_request() calls ufshcd_rpm_get_sync().
4. The W-LUN runtime resume fails and the W-LUN stays suspended.
5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
6. ufs_bsg_request() dispatches the BSG command while the W-LUN is
still suspended.
Use ufshcd_rpm_resume_and_get() and jump to out_complete on error so the
BSG job is completed via bsg_job_done() with the failure code without
dropping an unacquired runtime PM reference.
Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper"
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/20261029040003.2100003-5-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/ufs/core/ufs_bsg.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/drivers/ufs/core/ufs_bsg.c
+++ b/drivers/ufs/core/ufs_bsg.c
@@ -150,7 +150,9 @@ static int ufs_bsg_request(struct bsg_jo
goto out_complete;
}
- ufshcd_rpm_get_sync(hba);
+ ret = ufshcd_rpm_resume_and_get(hba);
+ if (ret)
+ goto out_complete;
msgcode = bsg_request->msgcode;
switch (msgcode) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 655/742] scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (638 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 654/742] scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 656/742] scsi: ufs: core: Keep clock-gating hold on failed W-LUN runtime resume Greg Kroah-Hartman
` (86 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stanley Jhu, Bart Van Assche,
Peter Wang, Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <stanleyjhu@google.com>
commit cbab12e5b4a7f49d5add4301de275351269cd431 upstream.
ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() resume the
UFS device W-LUN with ufshcd_rpm_get_sync() and ignore its return value.
For clkscale_enable:
1. The W-LUN is runtime suspended and clock scaling is disabled.
2. User space writes 1 to clkscale_enable.
3. ufshcd_clkscale_enable_store() calls ufshcd_rpm_get_sync().
4. The W-LUN runtime resume fails and the W-LUN stays suspended.
5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
6. ufshcd_clkscale_enable_store() enables clock scaling and resumes
devfreq while the W-LUN is still suspended.
For auto_hibern8:
1. The W-LUN starts a runtime suspend.
2. User space writes a new value to auto_hibern8.
3. ufshcd_auto_hibern8_update() sees that the W-LUN is not yet
suspended and calls ufshcd_rpm_get_sync().
4. ufshcd_rpm_get_sync() waits for the runtime suspend to finish and
then runs the W-LUN runtime resume.
5. The W-LUN runtime resume fails and the W-LUN stays suspended.
6. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
7. ufshcd_auto_hibern8_update() writes REG_AUTO_HIBERNATE_IDLE_TIMER
while the W-LUN is still suspended.
Add ufshcd_rpm_resume_and_get() wrapping pm_runtime_resume_and_get() so
failed resumes drop the usage reference automatically, and return early in
ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() when it
fails.
Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Cc: stable@vger.kernel.org
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/20261029040003.2100003-3-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/ufs/core/ufshcd-priv.h | 5 +++++
drivers/ufs/core/ufshcd.c | 7 +++++--
2 files changed, 10 insertions(+), 2 deletions(-)
--- a/drivers/ufs/core/ufshcd-priv.h
+++ b/drivers/ufs/core/ufshcd-priv.h
@@ -388,6 +388,11 @@ static inline int ufshcd_rpm_get_sync(st
return pm_runtime_get_sync(&hba->ufs_device_wlun->sdev_gendev);
}
+static inline int ufshcd_rpm_resume_and_get(struct ufs_hba *hba)
+{
+ return pm_runtime_resume_and_get(&hba->ufs_device_wlun->sdev_gendev);
+}
+
static inline int ufshcd_rpm_get_if_active(struct ufs_hba *hba)
{
return pm_runtime_get_if_active(&hba->ufs_device_wlun->sdev_gendev);
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -1840,7 +1840,9 @@ static ssize_t ufshcd_clkscale_enable_st
if (value == hba->clk_scaling.is_enabled)
goto out;
- ufshcd_rpm_get_sync(hba);
+ err = ufshcd_rpm_resume_and_get(hba);
+ if (err)
+ goto out;
ufshcd_hold(hba);
hba->clk_scaling.is_enabled = value;
@@ -4751,7 +4753,8 @@ void ufshcd_auto_hibern8_update(struct u
WRITE_ONCE(hba->ahit, ahit);
if (!pm_runtime_suspended(&hba->ufs_device_wlun->sdev_gendev)) {
- ufshcd_rpm_get_sync(hba);
+ if (ufshcd_rpm_resume_and_get(hba))
+ return;
ufshcd_hold(hba);
/*
* Serialize with the host driver's AHIT control. Skip the
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 656/742] scsi: ufs: core: Keep clock-gating hold on failed W-LUN runtime resume
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (639 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 655/742] scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 657/742] scsi: ufs: core: Restore jiffies conversion of device management timeouts Greg Kroah-Hartman
` (85 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stanley Jhu, Brian Norris,
Peter Wang, Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <stanleyjhu@google.com>
commit 6da1bc55c060bec3163b0e6077f3ac9641f8100c upstream.
1. __ufshcd_wl_suspend() takes one ufshcd_hold() reference and sets
hba->clk_gating.is_suspended while the UFS device W-LUN enters
RPM_SUSPENDED.
2. Since commit eef1d74bf88f ("PM: runtime: Only set runtime_error on
suspend callback failures"), a failed runtime resume (for example
START STOP UNIT completing with an error) leaves the W-LUN in
RPM_SUSPENDED with power.runtime_error == 0, while
__ufshcd_wl_resume() already clears hba->clk_gating.is_suspended and
calls ufshcd_release().
3. The next W-LUN runtime resume runs __ufshcd_wl_resume() again without
an intervening suspend and calls ufshcd_release() a second time,
dropping a reference it does not own and underflowing
hba->clk_gating.active_reqs on UFSHCD_CAP_CLK_GATING hosts.
Keep hba->clk_gating.is_suspended and the suspend hold across a failed
W-LUN runtime resume, so the hold stays paired with the W-LUN
RPM_SUSPENDED state and the next successful resume releases it.
Fixes: eef1d74bf88f ("PM: runtime: Only set runtime_error on suspend callback failures")
Cc: stable@vger.kernel.org # v7.3+
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/20261029040002.2100002-1-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/ufs/core/ufshcd.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10608,8 +10608,14 @@ vendor_suspend:
out:
if (ret)
ufshcd_update_evt_hist(hba, UFS_EVT_WL_RES_ERR, (u32)ret);
- hba->clk_gating.is_suspended = false;
- ufshcd_release(hba);
+ /*
+ * A failed runtime resume leaves the W-LUN RPM_SUSPENDED, so keep
+ * is_suspended and the suspend hold for the next resume.
+ */
+ if (!ret || pm_op != UFS_RUNTIME_PM) {
+ hba->clk_gating.is_suspended = false;
+ ufshcd_release(hba);
+ }
hba->pm_op_in_progress = false;
return ret;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 657/742] scsi: ufs: core: Restore jiffies conversion of device management timeouts
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (640 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 656/742] scsi: ufs: core: Keep clock-gating hold on failed W-LUN runtime resume Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 658/742] scsi: ufs: hwmon, debugfs: Propagate runtime PM resume errors Greg Kroah-Hartman
` (84 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stanley Jhu, Bart Van Assche,
Peter Wang, Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <stanleyjhu@google.com>
commit ebf5cab0dd223a36a09742a91be4fea97e46c816 upstream.
Before commit 08b12cda6c44 ("scsi: ufs: core: Switch to
scsi_get_internal_cmd()"), ufshcd_wait_for_dev_cmd() converted the
millisecond timeout with msecs_to_jiffies() before waiting for the
command. That commit moved the timeout to the block layer and assigns the
millisecond value to rq->timeout as is, but rq->timeout is in jiffies. A
1500 ms query timeout (QUERY_REQ_TIMEOUT_DEFAULT) becomes 6 s with
CONFIG_HZ=250 and 15 s with CONFIG_HZ=100, and NOP_OUT_TIMEOUT and
ADVANCED_RPMB_REQ_TIMEOUT grow the same way.
Restore the conversion with msecs_to_jiffies().
Fixes: 08b12cda6c44 ("scsi: ufs: core: Switch to scsi_get_internal_cmd()")
Cc: stable@vger.kernel.org # v6.19+
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/20261029040003.2100003-2-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/ufs/core/ufshcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -3363,7 +3363,7 @@ static int ufshcd_issue_dev_cmd(struct u
struct request *rq = scsi_cmd_to_rq(cmd);
blk_status_t sts;
- rq->timeout = timeout;
+ rq->timeout = msecs_to_jiffies(timeout);
sts = blk_execute_rq(rq, true);
if (sts != BLK_STS_OK)
return blk_status_to_errno(sts);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 658/742] scsi: ufs: hwmon, debugfs: Propagate runtime PM resume errors
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (641 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 657/742] scsi: ufs: core: Restore jiffies conversion of device management timeouts Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 659/742] scsi: ufs: sysfs: " Greg Kroah-Hartman
` (83 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stanley Jhu, Bart Van Assche,
Peter Wang, Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <stanleyjhu@google.com>
commit 9eb89611d95914e47cec62826e4000396df0f953 upstream.
ufs_hwmon_read(), ufs_hwmon_write(), and ufs_debugfs_get_user_access()
resume the UFS device W-LUN with ufshcd_rpm_get_sync() and ignore its
return value. For example, for a hwmon temperature read:
1. The W-LUN is runtime suspended.
2. User space reads temp1_input of the UFS hwmon device.
3. ufs_hwmon_read() calls ufshcd_rpm_get_sync().
4. The W-LUN runtime resume fails and the W-LUN stays suspended.
5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
6. ufs_hwmon_read() sends an attribute query UPIU while the W-LUN is
still suspended.
ufs_hwmon_write() and the debugfs writers that use
ufs_debugfs_get_user_access() (exception_event_mask and tx_eq_ctrl) follow
the same sequence.
Convert all three call sites to ufshcd_rpm_resume_and_get() and release
hba->host_sem before returning the error, ahead of __acquire(ufs_debugfs)
in ufs_debugfs_get_user_access().
Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")
Fixes: e88e2d32200a ("scsi: ufs: core: Probe for temperature notification support")
Fixes: adbabdcf0db0 ("scsi: ufs: core: Add support to retrain TX Equalization via debugfs")
Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper"
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/20261029040003.2100003-6-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/ufs/core/ufs-debugfs.c | 8 +++++++-
drivers/ufs/core/ufs-hwmon.c | 12 ++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
--- a/drivers/ufs/core/ufs-debugfs.c
+++ b/drivers/ufs/core/ufs-debugfs.c
@@ -70,12 +70,18 @@ token_context_lock(ufs_debugfs);
static int ufs_debugfs_get_user_access(struct ufs_hba *hba)
__cond_acquires(0, ufs_debugfs)
{
+ int err;
+
down(&hba->host_sem);
if (!ufshcd_is_user_access_allowed(hba)) {
up(&hba->host_sem);
return -EBUSY;
}
- ufshcd_rpm_get_sync(hba);
+ err = ufshcd_rpm_resume_and_get(hba);
+ if (err) {
+ up(&hba->host_sem);
+ return err;
+ }
__acquire(ufs_debugfs);
return 0;
}
--- a/drivers/ufs/core/ufs-hwmon.c
+++ b/drivers/ufs/core/ufs-hwmon.c
@@ -61,7 +61,11 @@ static int ufs_hwmon_read(struct device
return -EBUSY;
}
- ufshcd_rpm_get_sync(hba);
+ err = ufshcd_rpm_resume_and_get(hba);
+ if (err) {
+ up(&hba->host_sem);
+ return err;
+ }
switch (attr) {
case hwmon_temp_enable:
@@ -113,7 +117,11 @@ static int ufs_hwmon_write(struct device
return -EBUSY;
}
- ufshcd_rpm_get_sync(hba);
+ err = ufshcd_rpm_resume_and_get(hba);
+ if (err) {
+ up(&hba->host_sem);
+ return err;
+ }
if (val == 1)
err = ufshcd_update_ee_usr_mask(hba, MASK_EE_URGENT_TEMP, 0);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 659/742] scsi: ufs: sysfs: Propagate runtime PM resume errors
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (642 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 658/742] scsi: ufs: hwmon, debugfs: Propagate runtime PM resume errors Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 660/742] smb: client: convert path_consumed to mount charset units Greg Kroah-Hartman
` (82 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Stanley Jhu, Bart Van Assche,
Peter Wang, Martin K. Petersen (Oracle)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <stanleyjhu@google.com>
commit 93891d1c486efcef2267c32e6e73ca2fd243704e upstream.
All 14 ufshcd_rpm_get_sync() callers in ufs-sysfs.c resume the UFS device
W-LUN and ignore the return value. For example, for a UFS descriptor read:
1. The W-LUN is runtime suspended.
2. User space reads a UFS descriptor attribute in sysfs.
3. ufs_sysfs_read_desc_param() calls ufshcd_rpm_get_sync().
4. The W-LUN runtime resume fails and the W-LUN stays suspended.
5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored.
6. ufs_sysfs_read_desc_param() sends a query UPIU while the W-LUN is
still suspended.
The other sysfs callers follow the same sequence. They send other query
UPIUs, or read a host register in ufshcd_read_hci_reg().
Switch all 14 sysfs callers to ufshcd_rpm_resume_and_get() and return the
error after releasing any held buffer and hba->host_sem.
Fixes: aef80fd1da32 ("scsi: ufs: sysfs: Resume the proper SCSI device")
Fixes: b9d104465a6c ("scsi: ufs: Prepare to add HCI capabilities sysfs")
Fixes: 600edc6620a4 ("scsi: ufs: sysfs: Make max_number_of_rtt read-write")
Fixes: 6c4148ce7cc1 ("scsi: ufs: wb: Add explicit flush sysfs attribute")
Fixes: 500d4b742e0c ("scsi: ufs: core: Add WB buffer resize support")
Fixes: ae7795a8c258 ("scsi: ufs: core: Add HID support")
Fixes: 1fd2e77b8897 ("scsi: ufs: core: Add device level exception support")
Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper"
Signed-off-by: Stanley Jhu <stanleyjhu@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Link: https://patch.msgid.link/20261029040003.2100003-4-stanleyjhu@google.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/ufs/core/ufs-sysfs.c | 67 ++++++++++++++++++++++++++++++++++---------
1 file changed, 53 insertions(+), 14 deletions(-)
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -250,13 +250,19 @@ EXPORT_SYMBOL_GPL(ufshcd_us_to_ahit);
static int ufshcd_read_hci_reg(struct ufs_hba *hba, u32 *val, unsigned int reg)
{
+ int ret;
+
down(&hba->host_sem);
if (!ufshcd_is_user_access_allowed(hba)) {
up(&hba->host_sem);
return -EBUSY;
}
- ufshcd_rpm_get_sync(hba);
+ ret = ufshcd_rpm_resume_and_get(hba);
+ if (ret) {
+ up(&hba->host_sem);
+ return ret;
+ }
ufshcd_hold(hba);
*val = ufshcd_readl(hba, reg);
ufshcd_release(hba);
@@ -350,7 +356,9 @@ static ssize_t wb_on_store(struct device
goto out;
}
- ufshcd_rpm_get_sync(hba);
+ res = ufshcd_rpm_resume_and_get(hba);
+ if (res)
+ goto out;
res = ufshcd_wb_toggle(hba, wb_enable);
ufshcd_rpm_put_sync(hba);
out:
@@ -421,7 +429,9 @@ static ssize_t enable_wb_buf_flush_store
goto out;
}
- ufshcd_rpm_get_sync(hba);
+ res = ufshcd_rpm_resume_and_get(hba);
+ if (res)
+ goto out;
res = ufshcd_wb_toggle_buf_flush(hba, enable_wb_buf_flush);
ufshcd_rpm_put_sync(hba);
@@ -490,7 +500,9 @@ static ssize_t wb_resize_enable_store(st
goto out;
}
- ufshcd_rpm_get_sync(hba);
+ res = ufshcd_rpm_resume_and_get(hba);
+ if (res)
+ goto out;
res = ufshcd_wb_set_resize_en(hba, mode);
ufshcd_rpm_put_sync(hba);
@@ -598,7 +610,9 @@ static ssize_t device_lvl_exception_id_s
if (hba->dev_info.wspecversion < 0x410)
return -EOPNOTSUPP;
- ufshcd_rpm_get_sync(hba);
+ err = ufshcd_rpm_resume_and_get(hba);
+ if (err)
+ return err;
err = ufshcd_query_attr_qword(hba, UPIU_QUERY_OPCODE_READ_ATTR,
QUERY_ATTR_IDN_DEV_LVL_EXCEPTION_ID,
0, 0, &exception_id);
@@ -1101,7 +1115,9 @@ static ssize_t ufs_sysfs_read_desc_param
goto out;
}
- ufshcd_rpm_get_sync(hba);
+ ret = ufshcd_rpm_resume_and_get(hba);
+ if (ret)
+ goto out;
ret = ufshcd_read_desc_param(hba, desc_id, desc_index,
param_offset, desc_buf, param_size);
ufshcd_rpm_put_sync(hba);
@@ -1482,7 +1498,12 @@ static ssize_t _name##_show(struct devic
up(&hba->host_sem); \
return -ENOMEM; \
} \
- ufshcd_rpm_get_sync(hba); \
+ ret = ufshcd_rpm_resume_and_get(hba); \
+ if (ret) { \
+ kfree(desc_buf); \
+ up(&hba->host_sem); \
+ return ret; \
+ } \
ret = ufshcd_query_descriptor_retry(hba, \
UPIU_QUERY_OPCODE_READ_DESC, QUERY_DESC_IDN_DEVICE, \
0, 0, desc_buf, &desc_len); \
@@ -1548,7 +1569,9 @@ static ssize_t _name##_show(struct devic
} \
if (ufshcd_is_wb_flags(QUERY_FLAG_IDN##_uname)) \
index = ufshcd_wb_get_query_index(hba); \
- ufshcd_rpm_get_sync(hba); \
+ ret = ufshcd_rpm_resume_and_get(hba); \
+ if (ret) \
+ goto out; \
ret = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG, \
QUERY_FLAG_IDN##_uname, index, &flag); \
ufshcd_rpm_put_sync(hba); \
@@ -1608,7 +1631,9 @@ static ssize_t max_number_of_rtt_show(st
return -EBUSY;
}
- ufshcd_rpm_get_sync(hba);
+ ret = ufshcd_rpm_resume_and_get(hba);
+ if (ret)
+ goto out;
ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
QUERY_ATTR_IDN_MAX_NUM_OF_RTT, 0, 0, &rtt);
ufshcd_rpm_put_sync(hba);
@@ -1648,7 +1673,9 @@ static ssize_t max_number_of_rtt_store(s
goto out;
}
- ufshcd_rpm_get_sync(hba);
+ ret = ufshcd_rpm_resume_and_get(hba);
+ if (ret)
+ goto out;
memflags = memalloc_noio_save();
shost_for_each_device(sdev, hba->host)
@@ -1700,7 +1727,11 @@ static int wb_read_resize_attrs(struct u
}
index = ufshcd_wb_get_query_index(hba);
- ufshcd_rpm_get_sync(hba);
+ ret = ufshcd_rpm_resume_and_get(hba);
+ if (ret) {
+ up(&hba->host_sem);
+ return ret;
+ }
ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
idn, index, 0, attr_val);
ufshcd_rpm_put_sync(hba);
@@ -1760,7 +1791,9 @@ static ssize_t _name##_show(struct devic
} \
if (ufshcd_is_wb_attrs(QUERY_ATTR_IDN##_uname)) \
index = ufshcd_wb_get_query_index(hba); \
- ufshcd_rpm_get_sync(hba); \
+ ret = ufshcd_rpm_resume_and_get(hba); \
+ if (ret) \
+ goto out; \
if (ufshcd_is_qword_attr(QUERY_ATTR_IDN##_uname)) \
ret = ufshcd_query_attr_qword(hba, \
UPIU_QUERY_OPCODE_READ_ATTR, \
@@ -1848,7 +1881,11 @@ static int hid_query_attr(struct ufs_hba
return -EBUSY;
}
- ufshcd_rpm_get_sync(hba);
+ ret = ufshcd_rpm_resume_and_get(hba);
+ if (ret) {
+ up(&hba->host_sem);
+ return ret;
+ }
ret = ufshcd_query_attr(hba, opcode, idn, 0, 0, attr_val);
ufshcd_rpm_put_sync(hba);
@@ -2121,7 +2158,9 @@ static ssize_t dyn_cap_needed_attribute_
goto out;
}
- ufshcd_rpm_get_sync(hba);
+ ret = ufshcd_rpm_resume_and_get(hba);
+ if (ret)
+ goto out;
ret = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
QUERY_ATTR_IDN_DYN_CAP_NEEDED, lun, 0, &value);
ufshcd_rpm_put_sync(hba);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 660/742] smb: client: convert path_consumed to mount charset units
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (643 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 659/742] scsi: ufs: sysfs: " Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 661/742] smb: client: do not let the server grow a write subrequest Greg Kroah-Hartman
` (81 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Fredric Cover, Paulo Alcantara
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fredric Cover <fredric.cover.lkernel@gmail.com>
commit 3a191eec3627acd558640cf4092e9e337aa15291 upstream.
path_consumed in a DFS referral counts bytes of the canonical path,
which is in the DFS cache charset (utf8). dfs_parse_target_referral()
applies it as an offset into full_path, which is in the mount charset.
When the mount charset is not utf8, each non-ASCII character in the
consumed part that encodes longer in utf8 than in the mount charset
makes the offset too large, so leading characters of the prefix path
are dropped. For example, with iocharset=iso8859-1, mounting
//srv/dfs/café é/sub yields the prefix "ub" instead of "sub" and the
mount fails with -ENOENT. (A single accented character only worked
because the offset happened to land after the delimiter.)
Translate the count in parse_dfs_target(), where both strings are
available, by matching path components: count the delimiters in the
consumed part of the canonical path and find the same position in the
mount charset path. Delimiters are ASCII in both and are not affected
by remapping. If the consumed bytes are identical in both strings,
which is the case for utf8 mounts and ASCII-only prefixes using the
default backslash delimiter, the value is used unchanged.
This assumes the server reports PathConsumed on a component boundary;
a translated value that ends mid-component is rounded up to the next
boundary.
Tested against Samba on a KASAN kernel: with iocharset=iso8859-1, links
with 0 to 3 accented characters followed by a tail, a two-level tail,
an accented tail, a link in a subdirectory, and mapposix with an
accented name; iso8859-15 and cp932 mounts; and iocharset=utf8
controls. Not tested against Windows servers, with posixpaths, or with
reserved characters under mapchars/mapposix.
Signed-off-by: Fredric Cover <fredric.cover.lkernel@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/smb/client/dfs.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 74 insertions(+), 3 deletions(-)
--- a/fs/smb/client/dfs.c
+++ b/fs/smb/client/dfs.c
@@ -85,16 +85,87 @@ static void set_root_smb_session(struct
ctx->dfs_root_ses = ses;
}
+static bool dfs_is_delim(wchar_t c)
+{
+ return c == '/' || c == '\\';
+}
+
+/*
+ * @consumed counts bytes of the canonical (cache charset) path @cpath.
+ * Return the matching byte offset in @fpath, which holds the same path in
+ * the mount charset. Offsets are matched by path component, since the
+ * delimiters are ASCII in every charset and survive remapping.
+ */
+static int dfs_consumed_to_local(const struct nls_table *nls,
+ const char *cpath, const char *fpath,
+ int consumed)
+{
+ size_t clen = strlen(cpath), flen = strlen(fpath), off = 0;
+ int ndelims = 0, seen = 0, i;
+ bool ends_on_delim;
+
+ if (consumed < 0)
+ return -EINVAL;
+
+ /* Identical bytes in both strings: units already agree */
+ if ((size_t)consumed <= min(clen, flen) &&
+ !memcmp(cpath, fpath, consumed))
+ return consumed;
+
+ if ((size_t)consumed > clen)
+ consumed = clen;
+
+ for (i = 0; i < consumed; i++)
+ if (dfs_is_delim(cpath[i]))
+ ndelims++;
+ ends_on_delim = consumed && dfs_is_delim(cpath[consumed - 1]);
+
+ while (off < flen) {
+ wchar_t uni;
+ int len;
+
+ len = nls->char2uni((const unsigned char *)fpath + off,
+ flen - off, &uni);
+ if (len <= 0) {
+ uni = (unsigned char)fpath[off];
+ len = 1;
+ }
+ if (dfs_is_delim(uni)) {
+ /* check if start of next component */
+ if (!ends_on_delim && seen == ndelims)
+ break;
+ seen++;
+ if (ends_on_delim && seen == ndelims) {
+ /* just past the last consumed delimiter */
+ off += len;
+ break;
+ }
+ }
+ off += len;
+ }
+ return off;
+}
+
static inline int parse_dfs_target(struct smb3_fs_context *ctx,
struct dfs_ref_walk *rw,
struct dfs_info3_param *tgt)
{
- int rc;
const char *fpath = ref_walk_fpath(rw) + 1;
+ const char *cpath = ref_walk_path(rw) + 1;
+ int rc;
rc = ref_walk_get_tgt(rw, tgt);
- if (!rc)
- rc = dfs_parse_target_referral(fpath, tgt, ctx);
+ if (!rc) {
+ struct dfs_info3_param local = *tgt;
+ int off;
+
+ off = dfs_consumed_to_local(rw->mnt_ctx->cifs_sb->local_nls,
+ cpath, fpath, tgt->path_consumed);
+ if (off < 0)
+ return off;
+ local.path_consumed = off;
+ rc = dfs_parse_target_referral(fpath, &local, ctx);
+ }
return rc;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 661/742] smb: client: do not let the server grow a write subrequest
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (644 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 660/742] smb: client: convert path_consumed to mount charset units Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 662/742] smb: client: dont use read data that failed signature verification Greg Kroah-Hartman
` (80 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, ozgun kultekin, Namjae Jeon,
Paulo Alcantara
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: ozgun kultekin <ozgunkultekin@gmail.com>
commit f834c81f108f8bdb0e3aa8375a536fb6dda56c70 upstream.
smb2_writev_callback() takes the byte count from the SMB2 WRITE
response, masks it with 0xFFFF if it is larger than the request (for
old OS/2 servers), and then copies it into wdata->subreq.len. A server
can return a count that is still larger than the request after the
mask, for example 0x8002 for a 5-byte write or 0xFFFF for a 4 KiB
write, and the subrequest then covers data that was never sent.
netfs uses the subrequest length to decide how far the write collector
may advance. With a grown subrequest the collector moves collected_to
past the data that was issued: netfs_writeback_unlock_folios() walks
folio_queue slots that were never filled, and
rolling_buffer_delete_spent() frees folio_queue segments that later
in-flight subrequests still use. This is a use-after-free that a
malicious or broken server triggers from an ordinary write:
BUG: KASAN: slab-use-after-free in netfs_limit_iter+0xed4/0x1040
Read of size 1 at addr ff11000010561511 by task kworker/u8:4/63
Workqueue: events_unbound netfs_write_collection_worker
netfs_limit_iter+0xed4/0x1040
netfs_retry_writes+0x1410/0x1e90
netfs_write_collection+0x2647/0x3880
netfs_write_collection_worker+0x1cd/0x3e0
Allocated by task 141:
netfs_folioq_alloc+0x39a/0x470
rolling_buffer_init+0x29/0xc0
netfs_create_write_req+0x12f/0x840
Freed by task 42:
rolling_buffer_delete_spent+0xb1/0x220
netfs_write_collection+0x1f62/0x3880
Never change the subrequest length from the response. If the count is
still larger than the request after the mask, fail the write with -EIO
and record it with a new write_overlarge trace point, like the read
path does with read_overlarge. A short count still returns -ENOSPC as
before.
The folio_queue form of the use-after-free exists since
commit cd0277ed0c18 ("netfs: Use new folio_queue data type and
iterator instead of xarray iter").
Fixes: 3ee1a1fc3981 ("cifs: Cut over to using netfslib")
Cc: stable@vger.kernel.org
Signed-off-by: ozgun kultekin <ozgunkultekin@gmail.com>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/smb/client/smb2pdu.c | 17 +++++++++++++----
fs/smb/client/trace.h | 1 +
2 files changed, 14 insertions(+), 4 deletions(-)
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -5162,14 +5162,23 @@ smb2_writev_callback(struct TCP_Server_I
if (written > wdata->subreq.len)
written &= 0xFFFF;
+ /*
+ * The server must not report more bytes than were sent. netfs
+ * uses the subrequest length to work out which folios this
+ * write has finished with, so it must not be changed here.
+ */
+ if (written > wdata->subreq.len) {
+ result = smb_EIO2(smb_eio_trace_write_overlarge,
+ written, wdata->subreq.len);
+ break;
+ }
+
cifs_stats_bytes_written(tcon, written);
- if (written < wdata->subreq.len) {
+ if (written < wdata->subreq.len)
result = -ENOSPC;
- } else if (written > 0) {
- wdata->subreq.len = written;
+ else if (written > 0)
__set_bit(NETFS_SREQ_MADE_PROGRESS, &wdata->subreq.flags);
- }
break;
case MID_REQUEST_SUBMITTED:
trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_req_submitted);
--- a/fs/smb/client/trace.h
+++ b/fs/smb/client/trace.h
@@ -153,6 +153,7 @@
EM(smb_eio_trace_user_iter, "user_iter") \
EM(smb_eio_trace_write_bad_buf_type, "write_bad_buf_type") \
EM(smb_eio_trace_write_mid_state_unknown, "write_mid_state_unknown") \
+ EM(smb_eio_trace_write_overlarge, "write_overlarge") \
EM(smb_eio_trace_write_rsp_malformed, "write_rsp_malformed") \
E_(smb_eio_trace_write_too_far, "write_too_far")
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 662/742] smb: client: dont use read data that failed signature verification
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (645 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 661/742] smb: client: do not let the server grow a write subrequest Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 663/742] smb: client: fail SMB2 responses with a bad signature Greg Kroah-Hartman
` (79 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kaixuan Li, Suyuan Wang,
Paulo Alcantara
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suyuan Wang <stevewong@hust.edu.cn>
commit a1a0ef3ba8e802060bfc2b0ebf131a2cf98c3b71 upstream.
When smb2_readv_callback() finds a bad signature, it sets the error in
rdata->result but leaves rdata->got_bytes alone. Further down, a short
read that reaches the remote EOF clears the error again:
size_t trans = rdata->subreq.transferred + rdata->got_bytes;
if (trans < rdata->subreq.len &&
rdata->subreq.start + trans >= netfs_read_remote_i_size(inode)) {
rdata->result = 0;
and got_bytes is then added to subreq.transferred. So the last part of a
file, or all of a small one, is returned even though its signature is
wrong.
Clearing got_bytes is not enough on its own. If the read starts at or
past the cached remote size, for example because the file has grown on
the server since the size was last fetched, the check above still
matches and the error turns into EOF, or into a zero-filled tail when
NETFS_SREQ_CLEAR_TAIL is set.
Clear got_bytes when the signature check fails, as the retry path in the
same function already does, and only treat a short read as hitting the
remote EOF when the read itself succeeded. That is what commit
1da29f2c39b6 ("netfs, cifs: Fix handling of short DIO read") describes:
"clear the error if a short read occurred without error and the read-to
file position is now at the remote inode size".
Found with a static analysis tool and checked by hand.
Fixes: 1da29f2c39b6 ("netfs, cifs: Fix handling of short DIO read")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/smb/client/smb2pdu.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -4800,6 +4800,8 @@ smb2_readv_callback(struct TCP_Server_In
rc);
rdata->subreq.error = rc;
rdata->result = rc;
+ /* the data can't be trusted, don't count it */
+ rdata->got_bytes = 0;
if (is_replayable_error(rc)) {
trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_retry_needed);
@@ -4879,9 +4881,8 @@ do_retry:
__set_bit(NETFS_SREQ_CLEAR_TAIL, &rdata->subreq.flags);
} else {
size_t trans = rdata->subreq.transferred + rdata->got_bytes;
- if (trans < rdata->subreq.len &&
+ if (!rdata->result && trans < rdata->subreq.len &&
rdata->subreq.start + trans >= netfs_read_remote_i_size(inode)) {
- rdata->result = 0;
if (rdata->subreq.start + trans >= i_size_read(inode))
__set_bit(NETFS_SREQ_HIT_EOF, &rdata->subreq.flags);
else
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 663/742] smb: client: fail SMB2 responses with a bad signature
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (646 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 662/742] smb: client: dont use read data that failed signature verification Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 664/742] smb: client: fix busy dentry and inode on unmount from late oplock break Greg Kroah-Hartman
` (78 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Daniel Birtwhistle, Kaixuan Li,
Suyuan Wang, Paulo Alcantara
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suyuan Wang <stevewong@hust.edu.cn>
commit 2a5bd7a2bbb787483cd69ecf099e2b591e3633b2 upstream.
smb2_check_receive() checks the response signature when signing is on,
but a failed check is only logged:
rc = smb2_verify_signature(&rqst, server);
if (rc)
cifs_server_dbg(VFS, "SMB signature verification returned ...",
rc);
...
return map_smb2_to_linux_error(mid->resp_buf, log_error);
The status from the response is returned as usual, and the caller goes
on to use a response whose signature is wrong. This is the path for
synchronous and compound requests and for smb2_writev_callback(). On a
signed but unencrypted connection, anyone who can modify the traffic
can change e.g. a directory listing or file attributes, and the client
accepts it.
Return the verification error instead. That alone is not enough for
compound_send_recv(), which still hands the response buffer to the
caller after check_receive() fails. smb2_compound_op() then maps the
status from that buffer again and copies the payload out, and other
callers look at the buffer on error too, e.g. smb2_open_file() parses
a symlink target out of a STATUS_STOPPED_ON_SYMLINK response. So also
mark the mid MID_RESPONSE_MALFORMED, and have compound_send_recv() handle
it like a mid in a bad state: mark the earlier mids cancelled, so that a
CREATE which did succeed gets its handle closed, and don't pass any
response on.
Unlike the SMB1 fix in commit dc96f01d54cc ("smb: client: terminate
session upon failed client required signing"), don't reconnect: this
runs in the thread that sent the request, and only cifsd should call
cifs_reconnect(). And fail the request whichever side required signing,
since a response with a bad signature can't be trusted either way.
Found with a static analysis tool and checked by hand.
Reported-by: Daniel Birtwhistle <daniel.birtwhistle@gehealthcare.com>
Closes: https://lore.kernel.org/linux-cifs/SN4PR22MB28883DAF57E0B4D4BFB1C22AEEC42@SN4PR22MB2888.namprd22.prod.outlook.com/
Fixes: 3c1bf7e48e9e ("CIFS: Enable signing in SMB2")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/smb/client/smb2transport.c | 7 +++++--
fs/smb/client/transport.c | 5 +++++
2 files changed, 10 insertions(+), 2 deletions(-)
--- a/fs/smb/client/smb2transport.c
+++ b/fs/smb/client/smb2transport.c
@@ -712,9 +712,12 @@ smb2_check_receive(struct mid_q_entry *m
int rc;
rc = smb2_verify_signature(&rqst, server);
- if (rc)
+ if (rc) {
cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
- rc);
+ rc);
+ mid->mid_state = MID_RESPONSE_MALFORMED;
+ return rc;
+ }
}
return map_smb2_to_linux_error(mid->resp_buf, log_error);
--- a/fs/smb/client/transport.c
+++ b/fs/smb/client/transport.c
@@ -1082,6 +1082,11 @@ compound_send_recv(const unsigned int xi
rc = server->ops->check_receive(mid[i], server,
flags & CIFS_LOG_ERROR);
+ if (mid[i]->mid_state != MID_RESPONSE_READY) {
+ cifs_mark_compound_mids_cancelled(mid, i);
+ num_processed = 0;
+ goto out;
+ }
num_processed = i + 1;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 664/742] smb: client: fix busy dentry and inode on unmount from late oplock break
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (647 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 663/742] smb: client: fail SMB2 responses with a bad signature Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 665/742] smb: client: fix busy dentry on unmount from persistent handle reopen Greg Kroah-Hartman
` (77 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Adam Kim, Siddharth Chintamaneni,
Paulo Alcantara
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siddharth Chintamaneni <sidchintamaneni@gmail.com>
commit a10ec8dba77799a0460a4b3dfcac040ac452a325 upstream.
During unmount, cifs_kill_sb() flushes cifsoplockd_wq and deferredclose_wq
before waiting on cifs_sb->outstanding_rreq for in-flight netfs I/O
requests to finish their cleanup_work in cifs_free_request().
While cifs_kill_sb() is waiting on outstanding_rreq, any cifsFileInfo
referenced by an in-flight request (req->cfile) still has cfile->count >= 1
and remains on tcon->openFileList. If the SMB server sends a lease or
oplock break for that file during this window, the demultiplex thread
(cifsd) finds cfile on tcon->openFileList and calls
cifs_queue_oplock_break(cfile), which takes a new reference on cfile and
queues cfile->oplock_break onto cifsoplockd_wq after cifsoplockd_wq was
already flushed:
Thread 1 (umount) Thread 2 (cifsd) Thread 3 (workers)
----------------- ---------------- ------------------
cifs_kill_sb()
flush(cifsoplockd_wq)
flush(deferredclose_wq)
wait(outstanding_rreq)
[blocks: rreq == 1]
SMB2 Lease Break
finds cfile on list
cifs_queue_oplock_break()
queue(cifsoplockd_wq)
cifsFileInfo_get(cfile)
[cfile->count: 1 -> 2]
cifs_oplock_break()
ihold(inode)
cifs_free_request()
cifsFileInfo_put()
[cfile->count: 2 -> 1]
dec(outstanding_rreq)
[wakes: rreq == 0]
flush(serverclose_wq)
flush(fileinfo_put_wq)
kill_anon_super(sb)
-> generic_shutdown_super()
BUG: Dentry still in use (1)
VFS: Busy inodes after unmount!
Furthermore, cifs_oplock_break() itself holds the inode via ihold() after
dropping cfile and may initiate writeback via filemap_fdatawrite(),
spawning new netfs I/O requests.
Fix this by counting queued oplock breaks in cifs_sb->outstanding_rreq
from when cifs_queue_oplock_break() queues the work until
cifs_oplock_break() finishes, so wait_var_event() in cifs_kill_sb() waits
for both in-flight I/O requests and any late oplock breaks to complete.
Fixes: 340cea84f691 ("cifs: open files should not hold ref on superblock")
Cc: stable@vger.kernel.org
Reported-by: Adam Kim <adamkim@microsoft.com>
Signed-off-by: Siddharth Chintamaneni <sidchintamaneni@gmail.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/smb/client/cifsfs.c | 10 +++++-----
fs/smb/client/file.c | 2 ++
fs/smb/client/misc.c | 6 +++++-
3 files changed, 12 insertions(+), 6 deletions(-)
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -380,11 +380,11 @@ static void cifs_kill_sb(struct super_bl
flush_workqueue(deferredclose_wq);
/*
- * Wait for all in-flight netfs I/O requests to finish their
- * cleanup_work so that any cifsFileInfo final puts they queue
- * to fileinfo_put_wq/serverclose_wq have been queued, then
- * drain the workqueue so the cfile dentry refs are dropped to
- * avoid the busy dentry warning.
+ * Wait for all in-flight netfs I/O requests and oplock breaks
+ * to finish so that any cifsFileInfo final puts they queue to
+ * fileinfo_put_wq/serverclose_wq have been queued, then drain
+ * the workqueue so the cfile dentry refs are dropped to avoid
+ * the busy dentry warning.
*/
wait_var_event(&cifs_sb->outstanding_rreq,
!atomic_read(&cifs_sb->outstanding_rreq));
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -3848,6 +3848,8 @@ oplock_break_ack:
out:
cifs_done_oplock_break(cinode);
iput(inode);
+ if (atomic_dec_and_test(&cifs_sb->outstanding_rreq))
+ wake_up_var(&cifs_sb->outstanding_rreq);
}
#ifdef CONFIG_SWAP
--- a/fs/smb/client/misc.c
+++ b/fs/smb/client/misc.c
@@ -373,6 +373,8 @@ void cifs_put_writer(struct cifsInodeInf
*/
void cifs_queue_oplock_break(struct cifsFileInfo *cfile)
{
+ struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry);
+
/*
* Bump the handle refcount now while we hold the
* open_file_lock to enforce the validity of it for the oplock
@@ -381,8 +383,10 @@ void cifs_queue_oplock_break(struct cifs
*
* Only take a reference if the work is actually queued.
*/
- if (queue_work(cifsoplockd_wq, &cfile->oplock_break))
+ if (queue_work(cifsoplockd_wq, &cfile->oplock_break)) {
cifsFileInfo_get(cfile);
+ atomic_inc(&cifs_sb->outstanding_rreq);
+ }
}
void cifs_done_oplock_break(struct cifsInodeInfo *cinode)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 665/742] smb: client: fix busy dentry on unmount from persistent handle reopen
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (648 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 664/742] smb: client: fix busy dentry and inode on unmount from late oplock break Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 666/742] smb: client: fix negative timestamps being read from smb Greg Kroah-Hartman
` (76 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Adam Kim, Siddharth Chintamaneni,
Paulo Alcantara
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siddharth Chintamaneni <sidchintamaneni@gmail.com>
commit 340ca61e9d31c31403013dc9190550d615844828 upstream.
During unmount, cifs_kill_sb() waits on cifs_sb->outstanding_rreq for
in-flight netfs I/O requests and oplock breaks to complete before
flushing serverclose_wq and fileinfo_put_wq.
While cifs_kill_sb() is waiting on outstanding_rreq, any cifsFileInfo
referenced by an in-flight request (req->cfile) remains on
tcon->openFileList. On a mount using persistent handles, if a reconnect
runs on cifsiod_wq during this window, smb2_reconnect_server() calls
cifs_reopen_persistent_handles(), which walks tcon->openFileList and
takes a new reference on open_file via cifsFileInfo_get() to reopen the
handle over the network:
Thread 1 (umount) Thread 2 (cifsiod_wq) Thread 3 (workers)
----------------- --------------------- ------------------
cifs_kill_sb()
wait(outstanding_rreq)
[blocks: rreq == 1]
smb2_reconnect_server()
cifs_reopen_persistent_handles()
finds open_file on list
cifsFileInfo_get(open_file)
[cfile->count: 1 -> 2]
cifs_reopen_file()
cifs_free_request()
cifsFileInfo_put()
[cfile->count: 2 -> 1]
dec(outstanding_rreq)
[wakes: rreq == 0]
flush(serverclose_wq)
flush(fileinfo_put_wq)
kill_anon_super(sb)
-> generic_shutdown_super()
BUG: Dentry still in use (1)
VFS: Busy inodes after unmount!
Fix this by incrementing cifs_sb->outstanding_rreq when
cifs_reopen_persistent_handles() takes a reference on open_file and
decrementing it after cifsFileInfo_put(open_file), so wait_var_event()
in cifs_kill_sb() waits for any in-progress persistent handle reopen to
finish and queue its final put before draining fileinfo_put_wq.
Fixes: 340cea84f691 ("cifs: open files should not hold ref on superblock")
Cc: stable@vger.kernel.org
Reported-by: Adam Kim <adamkim@microsoft.com>
Signed-off-by: Siddharth Chintamaneni <sidchintamaneni@gmail.com>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/smb/client/file.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -1876,6 +1876,7 @@ void
cifs_reopen_persistent_handles(struct cifs_tcon *tcon)
{
struct cifsFileInfo *open_file, *tmp;
+ struct cifs_sb_info *cifs_sb;
LIST_HEAD(tmp_list);
if (!tcon->use_persistent || !tcon->need_reopen_files)
@@ -1890,17 +1891,22 @@ cifs_reopen_persistent_handles(struct ci
list_for_each_entry(open_file, &tcon->openFileList, tlist) {
if (!open_file->invalidHandle)
continue;
+ cifs_sb = CIFS_SB(open_file->dentry);
cifsFileInfo_get(open_file);
+ atomic_inc(&cifs_sb->outstanding_rreq);
list_add_tail(&open_file->rlist, &tmp_list);
}
spin_unlock(&tcon->open_file_lock);
list_for_each_entry_safe(open_file, tmp, &tmp_list, rlist) {
+ cifs_sb = CIFS_SB(open_file->dentry);
/* do not flush */
if (cifs_reopen_file(open_file, false, 0))
tcon->need_reopen_files = true;
list_del_init(&open_file->rlist);
cifsFileInfo_put(open_file);
+ if (atomic_dec_and_test(&cifs_sb->outstanding_rreq))
+ wake_up_var(&cifs_sb->outstanding_rreq);
}
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 666/742] smb: client: fix negative timestamps being read from smb
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (649 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 665/742] smb: client: fix busy dentry on unmount from persistent handle reopen Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 667/742] smb: client: fix times assignments in cifs_posix_to_fattr() Greg Kroah-Hartman
` (75 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, koraynilay, Namjae Jeon,
Paulo Alcantara
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: koraynilay <koray.fra@gmail.com>
commit 6a75ce0866bb1efe67947fc5536a476381d7a9d9 upstream.
When reading a timestamp before epoch 0, cifs converts it from NT format
to Unix format without normalizing it, leading to the nanoseconds field
to be used as a negative number, which leads to a garbled stat command
output.
This bug also violates a struct timespec64 invariant, as documented in
the set_normalized_timespec64() kernel-doc:
[...]
* Note: The tv_nsec part is always in the range of 0 <= tv_nsec <
* NSEC_PER_SEC.
* For negative values only the tv_sec field is negative !
*/
Reproducer, with /tmp as the local filesystem folder exported as [test]
in ksmbd.conf and /mnt as the smb folder mounted with mount -t cifs:
mount -t cifs //127.0.0.1/test /mnt -o username=user,password=pass
touch -d "1969-07-20 20:17:40.123456789" /tmp/test.txt
stat -c "Server local (/tmp): %y" /tmp/test.txt
stat -c "CIFS client (/mnt): %y" /mnt/test.txt --cached=never
smbclient //127.0.0.1/test -U user%pass -c "allinfo test.txt"
which prints (stat output is garbled because of negative value):
Server local (/tmp): 1969-07-20 20:17:40.123456789 +0000
CIFS client (/mnt): 1969-07-20 20:17:41.()*+,--00 +0000
altname: TESTT~K6.TXT
[...]
access_time: Sun Jul 20 20:17:40 1969 UTC
write_time: Sun Jul 20 20:17:40 1969 UTC
[...]
Fix this by using set_normalized_timespec64() in cifs_NTtimeToUnix().
Fixes: 2ae83bf93882 ("[CIFS] Fix setting time before epoch (negative time values)")
Cc: stable@vger.kernel.org
Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.3
Signed-off-by: koraynilay <koray.fra@gmail.com>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/smb/client/netmisc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/fs/smb/client/netmisc.c
+++ b/fs/smb/client/netmisc.c
@@ -133,8 +133,7 @@ cifs_NTtimeToUnix(__le64 ntutc)
if (t < 0) {
abs_t = -t;
ts.tv_nsec = (time64_t)(do_div(abs_t, 10000000) * 100);
- ts.tv_nsec = -ts.tv_nsec;
- ts.tv_sec = -abs_t;
+ set_normalized_timespec64(&ts, -abs_t, -ts.tv_nsec);
} else {
abs_t = t;
ts.tv_nsec = (time64_t)do_div(abs_t, 10000000) * 100;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 667/742] smb: client: fix times assignments in cifs_posix_to_fattr()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (650 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 666/742] smb: client: fix negative timestamps being read from smb Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 668/742] tracing/osnoise: Dont start a kthread in timerlat user-space mode Greg Kroah-Hartman
` (74 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, koraynilay, Namjae Jeon,
Paulo Alcantara
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: koraynilay <koray.fra@gmail.com>
commit 8b456f136a76a29fee8d36934740cb7f7fb5c837 upstream.
Currently cifs_posix_to_fattr() wrongly sets SMB's CreationTime to
fattr->cf_ctime.
Fix this by setting fattr->cf_createtime to SMB's CreationTime and
fattr->cf_ctime to SMB's ChangeTime, matching the behaviour of
__dir_info_to_fattr().
This patch also fixes a few related issues reported by sashiko on
another patch (see Sashiko Link tag).
Reproducers for these bugs, with /tmp as the local filesystem folder
exported as [test] in ksmbd.conf and /mnt as the smb folder mounted with
mount -t cifs:
mount -t cifs //127.0.0.1/test /mnt -o username=ciao,password=c,posix
Issue 1: ctime clobbered by CreationTime during readdir
mkdir -p /mnt/dir
touch /mnt/dir/file
sleep 4
chmod 644 /mnt/dir/file
stat -c "ctime and btime before readdir: %Z %W" /mnt/dir/file
ls -lc /mnt/dir > /dev/null
stat -c "ctime and btime after readdir: %Z %W" /mnt/dir/file
stat -c "ctime and btime on disk: %Z %W" /tmp/dir/file
output before the fix, notice how ctime is the same as btime after the
readdir, while it's 4 seconds ahead (because of the sleep 4) before the
readdir (on disk timestamps are not touched):
ctime and btime before readdir: 1794842068 1794842064
ctime and btime after readdir: 1794842064 1794842064
ctime and btime on disk: 1794842068 1794842064
output after the fix:
ctime and btime before readdir: 1794842908 1794842904
ctime and btime after readdir: 1794842908 1794842904
ctime and btime on disk: 1794842908 1794842904
Issue 2: btime and ptime wiped out by readdir
[ no reproducer as it only happens after the linked patch series is
applied, since it needs cifs_i->createtime = fattr->cf_createtime in
cifs_fattr_to_inode() ]
Issue 3: in-memory inode aliasing (flock bypass on hardlink via readdir)
mkdir -p /mnt/dir1 /mnt/dir2
echo "test" > /mnt/dir1/h1
ln /mnt/dir1/h1 /mnt/dir2/h2
exec 3< /mnt/dir1/h1
flock -x -n 3 # get exclusive lock
ls /mnt/dir2 > /dev/null
exec 4< /mnt/dir2/h2
flock -x -n 4
if [ $? -eq 0 ];then
echo "acquired: duplicate in-memory inode"
else
echo "blocked: same inode"
fi
output before the fix:
acquired: duplicate in-memory inode
output after the fix:
blocked: same inode
Fixes: 3d519bd1269f ("cifs: plumb smb2 POSIX dir enumeration")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20261115180343.576773-1-koray.fra%40gmail.com?part=10
Link: https://lore.kernel.org/all/20261115180343.576773-11-koray.fra@gmail.com/
Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.7
Signed-off-by: koraynilay <koray.fra@gmail.com>
Reviewed-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/smb/client/readdir.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/fs/smb/client/readdir.c
+++ b/fs/smb/client/readdir.c
@@ -253,9 +253,10 @@ cifs_posix_to_fattr(struct cifs_fattr *f
fattr->cf_bytes = le64_to_cpu(info->AllocationSize);
fattr->cf_eof = le64_to_cpu(info->EndOfFile);
+ fattr->cf_createtime = le64_to_cpu(info->CreationTime);
fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
fattr->cf_mtime = cifs_NTtimeToUnix(info->LastWriteTime);
- fattr->cf_ctime = cifs_NTtimeToUnix(info->CreationTime);
+ fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
fattr->cf_nlink = le32_to_cpu(info->HardLinks);
fattr->cf_cifsattrs = le32_to_cpu(info->DosAttributes);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 668/742] tracing/osnoise: Dont start a kthread in timerlat user-space mode
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (651 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 667/742] smb: client: fix times assignments in cifs_posix_to_fattr() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 669/742] tracing/user_events: Dont free an event that a dynamic event still references Greg Kroah-Hartman
` (73 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Chaosheng Qu, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaosheng Qu <chaosheng.qu.linux@gmail.com>
commit 5f855410554564ca05903979e6dab96e754d8773 upstream.
In timerlat user-space mode (NO_OSNOISE_WORKLOAD) the workload is a user
task reading timerlat_fd, so there is no per-CPU kernel thread to run.
start_kthread() only checks for that in the osnoise branch:
if (timerlat_enabled()) {
snprintf(comm, 24, "timerlat/%d", cpu);
main = timerlat_main;
} else {
/* if no workload, just return */
if (!test_bit(OSN_WORKLOAD, &osnoise_options)) {
...
return 0;
}
...
}
start_per_cpu_kthreads() guards against this mode itself, but
osnoise_hotplug_workfn() calls start_kthread() directly. Bringing a CPU
online in user-space mode therefore starts a timerlat/N thread and sets
its bit in kthread_cpumask while OSN_WORKLOAD is clear.
stop_kthread() uses that bit to decide what the recorded task is:
if (cpumask_test_and_clear_cpu(cpu, &kthread_cpumask) &&
!WARN_ON(!test_bit(OSN_WORKLOAD, &osnoise_options))) {
kthread_stop(kthread);
} else if (!WARN_ON(test_bit(OSN_WORKLOAD, &osnoise_options))) {
kill_pid(kthread->thread_pid, SIGKILL, 1);
put_task_struct(kthread);
}
The bit is set but OSN_WORKLOAD is not, so the first WARN_ON() fires and
the && short-circuits into the user-task branch. A running kernel thread
is SIGKILLed and its task_struct is put without ever being stopped, so it
keeps executing until it is freed underneath itself.
Any write to osnoise/options reaches this: osnoise_options_write() stops
the per-CPU threads before applying the new value, so stop_kthread()
still sees OSN_WORKLOAD clear. Re-writing the value that is already set
triggers it just as well as changing it.
echo NO_OSNOISE_WORKLOAD > osnoise/options
echo timerlat > current_tracer
echo 0 > /sys/devices/system/cpu/cpu1/online
echo 1 > /sys/devices/system/cpu/cpu1/online
echo NO_OSNOISE_WORKLOAD > osnoise/options
The offline/online pair is required, otherwise no kthread is recorded and
no bit is set. Running this on 7.3-rc7 with KASAN gives a WARNING in
stop_kthread() followed by a slab-use-after-free in update_se(); leaving
out the hotplug step produces neither.
Keep the check in start_kthread(), where the related hotplug bug was
fixed in 0bb0a5c12ecf, instead of adding another copy to the callback.
Cc: stable@vger.kernel.org
Fixes: e88ed227f639 ("tracing/timerlat: Add user-space interface")
Link: https://patch.msgid.link/20261014081034.12702-1-chaosheng.qu.linux@gmail.com
Signed-off-by: Chaosheng Qu <chaosheng.qu.linux@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_osnoise.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/kernel/trace/trace_osnoise.c
+++ b/kernel/trace/trace_osnoise.c
@@ -2038,6 +2038,14 @@ static int start_kthread(unsigned int cp
return 0;
if (timerlat_enabled()) {
+ /*
+ * In timerlat user-space mode the workload is the user task
+ * reading timerlat_fd, so there is no kernel thread to start.
+ * One started here would set its kthread_cpumask bit, which
+ * stop_kthread() reads as "osnoise workload kthread".
+ */
+ if (!test_bit(OSN_WORKLOAD, &osnoise_options))
+ return 0;
snprintf(comm, 24, "timerlat/%d", cpu);
main = timerlat_main;
} else {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 669/742] tracing/user_events: Dont free an event that a dynamic event still references
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (652 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 668/742] tracing/osnoise: Dont start a kthread in timerlat user-space mode Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 670/742] tracing/filters: Check for missing operand after operator in parse_pred() Greg Kroah-Hartman
` (72 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, David Carlier, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <devnexen@gmail.com>
commit 0fbdc293697a5d72dc985e533eef5155a1b264cc upstream.
An eprobe takes a reference on the call of the event it attaches to,
and kprobe, uprobe, fprobe and synth events all refuse to go away while
trace_event_dyn_busy() says such a reference exists. user_events never
checks it, so a user event can be freed under an eprobe:
echo 'u:test u32 a' >> dynamic_events
echo 'e:ep user_events/test a=$a' >> dynamic_events
echo '-:user_events/test u32 a' >> dynamic_events
echo '-:eprobes/ep' >> dynamic_events
The last write drops the reference on the freed call.
If the last fd of a non-persistent event closes while such a reference
is held, the delayed destroy now fails. Mark the event persistent then,
so it can still be deleted once the reference is gone instead of being
leaked.
Return -EBUSY from destroy_user_event() in that case.
Fixes: 7f5a08c79df3 ("user_events: Add minimal support for trace_event into ftrace")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261031212453.16116-1-devnexen@gmail.com
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events_user.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -256,6 +256,11 @@ static void delayed_destroy_user_event(s
* attempt to delete it later.
*/
pr_warn("user_events: Unable to delete event\n");
+ /*
+ * Keep it as persistent so it can be still deleted
+ * since nobody own this event
+ */
+ user->reg_flags |= USER_EVENT_REG_PERSIST;
refcount_set(&user->refcnt, 1);
}
out:
@@ -1506,6 +1511,10 @@ static int destroy_user_event(struct use
lockdep_assert_held(&event_mutex);
+ /* If there is a reference to a dynamic event */
+ if (trace_event_dyn_busy(&user->call))
+ return -EBUSY;
+
/*
* Detach the fields before removing the call. Removing the event
* frees the field list memory (trace_destroy_fields() is run on
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 670/742] tracing/filters: Check for missing operand after operator in parse_pred()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (653 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 669/742] tracing/user_events: Dont free an event that a dynamic event still references Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 671/742] tracing/filters: Fix false success return in process_system_preds() Greg Kroah-Hartman
` (71 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
commit 42647658bdd8434a90c1b63391081396f36820ba upstream.
In parse_pred(), after matching the operator and skipping whitespace,
the filter string may terminate (str[i] == '\0') if the operand is
missing (e.g. "ip ==" or "common_pid ==").
For function events, the loop 'for (i++; str[i]; i++)' unconditionally
increments 'i' past the NUL terminator, causing an out-of-bounds read.
For other event types, allocating a predicate only to fail later during
value parsing is wasteful.
Check if 'str[i]' is NUL immediately after skipping whitespace after
the operator, and report FILT_ERR_INVALID_FILTER.
Cc: stable@vger.kernel.org
Fixes: 80765597bc58 ("tracing: Rewrite filter logic to be simpler and faster")
Link: https://patch.msgid.link/179323789181.740114.16161070743864669086.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events_filter.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1712,6 +1712,11 @@ static int parse_pred(const char *str, v
while (isspace(str[i]))
i++;
+ if (!str[i]) {
+ parse_error(pe, FILT_ERR_INVALID_FILTER, pos + i);
+ goto err_free;
+ }
+
s = i;
pred = kzalloc_obj(*pred);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 671/742] tracing/filters: Fix false success return in process_system_preds()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (654 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 670/742] tracing/filters: Check for missing operand after operator in parse_pred() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 672/742] tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings Greg Kroah-Hartman
` (70 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Steven Rostedt,
Masami Hiramatsu (Google)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
commit 5d4eeee1697e63cc0010cf34910a72c0f4776e42 upstream.
In process_system_preds(), "fail" was initialized to true to indicate
whether any event in the subsystem successfully applied the filter.
However, "fail = false;" was placed at the end of the event loop outside
the error check, unconditionally clearing "fail" on every iteration even
when process_preds() returned an error.
As a result, if every event in the subsystem fails to match the filter
(e.g., an invalid field), process_system_preds() returns 0 (success)
instead of -EINVAL. Consequently, create_system_filter() considers the
operation successful and silently resets the subsystem filter display to
the default global filter message instead of reporting the parse error.
Fix this by clearing "fail" only when at least one event filter succeeds.
Consolidate the cleanup logic in fail and fail_mem by using ret
initialized to -ENOMEM, setting ret to -EINVAL in fail, and falling
through to fail_mem, freeing any replaced filters via delay_free_filter()
if !list_empty(&filter_list->list).
Cc: stable@vger.kernel.org
Fixes: 80765597bc58 ("tracing: Rewrite filter logic to be simpler and faster")
Link: https://patch.msgid.link/179324101176.752804.17624386967710135045.stgit@devnote2
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events_filter.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -2270,6 +2270,7 @@ static int process_system_preds(struct t
struct event_filter *filter = NULL;
struct filter_head *filter_list;
bool fail = true;
+ int ret = -ENOMEM;
int err;
filter_list = kmalloc_obj(*filter_list);
@@ -2296,9 +2297,10 @@ static int process_system_preds(struct t
filter_disable(file);
parse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0);
append_filter_err(tr, pe, filter);
- } else
+ } else {
event_set_filtered_flag(file);
-
+ fail = false;
+ }
filter_item = kzalloc_obj(*filter_item);
if (!filter_item)
@@ -2312,8 +2314,6 @@ static int process_system_preds(struct t
filter_item->filter = event_filter(file);
event_set_filter(file, filter);
filter = NULL;
-
- fail = false;
}
if (fail)
@@ -2328,19 +2328,18 @@ static int process_system_preds(struct t
return 0;
fail:
/* No call succeeded */
- free_filter_list(filter_list);
parse_error(pe, FILT_ERR_BAD_SUBSYS_FILTER, 0);
- return -EINVAL;
+ ret = -EINVAL;
fail_mem:
__free_filter(filter);
- /* If any call succeeded, we still need to sync */
- if (!fail)
+ /* If any filter was replaced, we still need to sync */
+ if (!list_empty(&filter_list->list))
delay_free_filter(filter_list);
else
free_filter_list(filter_list);
- return -ENOMEM;
+ return ret;
}
static int create_filter_start(char *filter_string, bool set_str,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 672/742] tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (655 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 671/742] tracing/filters: Fix false success return in process_system_preds() Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 673/742] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison Greg Kroah-Hartman
` (69 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
commit b82178ad9e282e20c3f3636bde5c52143ed5b933 upstream.
regex_match_end() calculates string length as "len - 1", assuming @len
is the string length including trailing '\0'. For dynamic strings
(filter_pred_strloc) and pointer strings (filter_pchar), this assumption
holds and allows O(1) constant-time suffix matching.
However, for fixed-size string fields (FILTER_STATIC_STRING) and "comm"
(FILTER_COMM), the callers pass the buffer capacity rather than the
actual string length (field->size for filter_pred_string, and
TASK_COMM_LEN for filter_pred_comm). Because these buffers hold
null-terminated strings (e.g. prev_comm in sched_switch holding "bash"
in a 16-byte buffer), regex_match_end() tests against the tail of the
buffer capacity (typically trailing '\0' padding at offset 13) rather
than the actual string end. Consequently, suffix matching like
comm ~ "*sh" or prev_comm ~ "*sh" fails for all strings shorter than
the buffer capacity.
Furthermore, for trace events like ftrace/print (trace_marker), the
"buf" field is defined with size 0, denoting an unbounded NUL-terminated
string. regex_match_end() and regex_match_end_str() return 0 when len
is 0, causing suffix matching to fail on ftrace/print events as well.
To fix this without penalizing dynamic and pointer strings with an
unnecessary scan on every event:
- Introduce regex_match_end_str() using strnlen(str, len) for fixed-size
buffers (FILTER_COMM and FILTER_STATIC_STRING with field->size > 0).
- Introduce regex_match_end_dynstr() using strlen(str) for unbounded
strings (FILTER_STATIC_STRING with field->size == 0).
Assign these match callbacks in parse_pred() when MATCH_END_ONLY is
requested.
Cc: stable@vger.kernel.org
Fixes: a3291c14ecf0 ("tracing/filters: Fix MATCH_END_ONLY filter matching")
Fixes: 10f20e9f9da9 ("tracing: Have zero size length in filter logic be full string")
Link: https://patch.msgid.link/179323785497.740114.7643531772387726730.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events_filter.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1064,6 +1064,30 @@ static int regex_match_end(char *str, st
return 0;
}
+static int regex_match_end_str(char *str, struct regex *r, int len)
+{
+ int slen;
+
+ if (len < r->len)
+ return 0;
+
+ slen = strnlen(str, len);
+ if (slen >= r->len &&
+ memcmp(str + slen - r->len, r->pattern, r->len) == 0)
+ return 1;
+ return 0;
+}
+
+static int regex_match_end_dynstr(char *str, struct regex *r, int len)
+{
+ int slen = strlen(str);
+
+ if (slen >= r->len &&
+ memcmp(str + slen - r->len, r->pattern, r->len) == 0)
+ return 1;
+ return 0;
+}
+
static int regex_match_glob(char *str, struct regex *r, int len)
{
return glob_match_len(r->pattern, str, len) ? 1 : 0;
@@ -2006,10 +2030,18 @@ static int parse_pred(const char *str, v
if (field->filter_type == FILTER_COMM) {
pred->fn_num = FILTER_PRED_FN_COMM;
+ if (pred->regex->match == regex_match_end)
+ pred->regex->match = regex_match_end_str;
} else if (field->filter_type == FILTER_STATIC_STRING) {
pred->fn_num = FILTER_PRED_FN_STRING;
pred->regex->field_len = field->size;
+ if (pred->regex->match == regex_match_end) {
+ if (!field->size)
+ pred->regex->match = regex_match_end_dynstr;
+ else
+ pred->regex->match = regex_match_end_str;
+ }
} else if (field->filter_type == FILTER_DYN_STRING) {
pred->fn_num = FILTER_PRED_FN_STRLOC;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 673/742] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (656 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 672/742] tracing/filters: Fix MATCH_END_ONLY regex matching for fixed-size strings Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 674/742] tracing/filters: Treat zero-length dynamic strings as empty Greg Kroah-Hartman
` (68 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Masami Hiramatsu (Google),
Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
commit 87e0a196153e983a4d95903e7422b7d766cd37cf upstream.
In filter_pred_##size##_cpumask(), if the event's scalar CPU value is
out of range (cpu >= nr_cpu_ids), it unconditionally returns 0.
However, if the predicate operation is OP_NE (e.g., field != CPUS{0,1}),
an out-of-range CPU cannot match any valid CPU in the user-provided
cpumask and the condition is satisfied. Returning 0 produces a false
negative.
Return "pred->op == OP_NE" instead of 0 when cpu >= nr_cpu_ids.
Cc: stable@vger.kernel.org
Fixes: 3cbec9d7b93d ("tracing/filters: Enable filtering a scalar field by a cpumask")
Link: https://patch.msgid.link/179323787340.740114.14434420599496956193.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events_filter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -756,7 +756,7 @@ static int filter_pred_##size##_cpumask(
unsigned int cpu = *addr; \
\
if (cpu >= nr_cpu_ids) \
- return 0; \
+ return pred->op == OP_NE; \
\
return do_filter_scalar_cpumask(pred->op, cpu, pred->mask); \
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 674/742] tracing/filters: Treat zero-length dynamic strings as empty
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (657 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 673/742] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:08 ` [PATCH 7.3 675/742] tracing: Add notrace to event functions that hook to ftrace Greg Kroah-Hartman
` (67 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kyle Zeng, Masami Hiramatsu (Google),
Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <kylebot@openai.com>
commit 97adb02064c6e3f378523b35563848cedbc23ec7 upstream.
The regex callbacks use a length of zero for NUL-terminated strings of
unknown size, such as the trailing buffer in a trace_marker record.
However, filter_pred_strloc() and filter_pred_strrelloc() pass the length
from a data locator directly to those callbacks. A zero-length locator
has no data and need not point at a NUL byte.
In particular, syscall entry events can contain an empty captured array
or a failed user-string copy. Matching such a field with an equality,
prefix, or substring filter can read beyond the record. The per-CPU perf
trace buffer is reused, so an unprivileged counting syscall event can
disclose bytes left by a previous kernel tracepoint even when raw
sampling is denied and exclude_kernel prevents counting that tracepoint.
Handle both locator formats through a common helper. For a zero-length
field, pass an empty string and its actual size to the regex callback.
This gives all matching modes the empty-string semantics without reading
the locator's target. Keep nonzero fields and the legacy trace_marker
unknown-length convention unchanged.
Fixes: 10f20e9f9da9 ("tracing: Have zero size length in filter logic be full string")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261006225642.58778-1-kylebot@openai.com
Assisted-by: Codex:gpt-6-astra
Signed-off-by: Kyle Zeng <kylebot@openai.com>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events_filter.c | 38 +++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -889,6 +889,25 @@ static int filter_pred_pchar_user(struct
return filter_pchar(pred, str);
}
+static __always_inline int filter_dyn_string(struct filter_pred *pred,
+ char *str, int len)
+{
+ int cmp;
+
+ /*
+ * The regex callbacks use zero for an unknown-length, NUL-terminated
+ * string. A zero-length data_loc or rel_loc field has no bytes at all.
+ * Match an empty string instead of reading past the end of the field.
+ */
+ if (!len) {
+ str = "";
+ len = 1;
+ }
+
+ cmp = pred->regex->match(str, pred->regex, len);
+ return cmp ^ pred->not;
+}
+
/*
* Filter predicate for dynamic sized arrays of characters.
* These are implemented through a list of strings at the end
@@ -905,13 +924,8 @@ static int filter_pred_strloc(struct fil
int str_loc = str_item & 0xffff;
int str_len = str_item >> 16;
char *addr = (char *)(event + str_loc);
- int cmp, match;
-
- cmp = pred->regex->match(addr, pred->regex, str_len);
- match = cmp ^ pred->not;
-
- return match;
+ return filter_dyn_string(pred, addr, str_len);
}
/*
@@ -928,13 +942,8 @@ static int filter_pred_strrelloc(struct
int str_loc = str_item & 0xffff;
int str_len = str_item >> 16;
char *addr = (char *)(&item[1]) + str_loc;
- int cmp, match;
-
- cmp = pred->regex->match(addr, pred->regex, str_len);
-
- match = cmp ^ pred->not;
- return match;
+ return filter_dyn_string(pred, addr, str_len);
}
/* Filter predicate for CPUs. */
@@ -1019,7 +1028,8 @@ static int filter_pred_function(struct f
*
* @str: the string to be searched
* @r: the regex structure containing the pattern string
- * @len: the length of the string to be searched (including '\0')
+ * @len: the length of the string to be searched (including '\0'), or zero
+ * for a NUL-terminated string of unknown length
*
* Note:
* - @str might not be NULL-terminated if it's of type DYN_STRING
@@ -1028,7 +1038,7 @@ static int filter_pred_function(struct f
static int regex_match_full(char *str, struct regex *r, int len)
{
- /* len of zero means str is dynamic and ends with '\0' */
+ /* Zero is reserved for a NUL-terminated string of unknown length. */
if (!len)
return strcmp(str, r->pattern) == 0;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 675/742] tracing: Add notrace to event functions that hook to ftrace
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (658 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 674/742] tracing/filters: Treat zero-length dynamic strings as empty Greg Kroah-Hartman
@ 2026-12-04 10:08 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 676/742] tracing: Avoid undefined shifts for zero histogram map size Greg Kroah-Hartman
` (66 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:08 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <rostedt@goodmis.org>
commit 39bc1fdbce1e5f435f8d02d57a9415735690bb1f upstream.
A few functions in trace_events.c are used to hook to the ftrace function
hooks. Before CONFIG_FUNCTION_SELF_TRACING was added, these functions were not
marked for tracing because the entire directory was set to "notrace". But
now that certain files can be traced by ftrace when the
CONFIG_FUNCTION_SELF_TRACING config is set, individual functions that use ftrace
must be annotated with "notrace" otherwise they can trigger a triple fault
when called.
Annotate the trace_events.c functions that are attached to ftrace with
"notrace.
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261119124319.3a8bfe50@gandalf.local.home
Fixes: f93a7d0caccd6 ("ftrace: Allow tracing of some of the tracing code")
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -4279,7 +4279,7 @@ static void update_event_probe(struct ev
set_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &data->file->flags);
}
-static void
+static void notrace
event_enable_probe(unsigned long ip, unsigned long parent_ip,
struct trace_array *tr, struct ftrace_probe_ops *ops,
void *data)
@@ -4296,7 +4296,7 @@ event_enable_probe(unsigned long ip, uns
update_event_probe(edata);
}
-static void
+static void notrace
event_enable_count_probe(unsigned long ip, unsigned long parent_ip,
struct trace_array *tr, struct ftrace_probe_ops *ops,
void *data)
@@ -5167,7 +5167,7 @@ static DEFINE_PER_CPU(atomic_t, ftrace_t
static struct trace_event_file event_trace_file __initdata;
-static void __init
+static void notrace __init
function_test_events_call(unsigned long ip, unsigned long parent_ip,
struct ftrace_ops *op, struct ftrace_regs *regs)
{
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 676/742] tracing: Avoid undefined shifts for zero histogram map size
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (659 preceding siblings ...)
2026-12-04 10:08 ` [PATCH 7.3 675/742] tracing: Add notrace to event functions that hook to ftrace Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 677/742] tracing: Do not allow user events to add a system name Greg Kroah-Hartman
` (65 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Jaewon Jung, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaewon Jung <jaewon8868@gmail.com>
commit cae7fb0d853eff05c70b08ef9e7ecb18867f8945 upstream.
Reject size=0 before calling roundup_pow_of_two().
include/linux/log2.h documents roundup_pow_of_two() as:
- the result is undefined when n == 0
With CONFIG_UBSAN_SHIFT=y, a size=0 histogram trigger reports:
UBSAN: shift-out-of-bounds in include/linux/log2.h
shift exponent 64 is too large for 64-bit type 'long unsigned int'
Tested on x86_64 QEMU: size=0 is rejected without UBSAN warnings,
and the histogram modifier and parser tests pass.
Fixes: 7ef224d1d0e3 ("tracing: Add 'hist' event trigger command")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261028074610.2212374-1-jaewon8868@gmail.com
Signed-off-by: Jaewon Jung <jaewon8868@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events_hist.c | 5 +++++
1 file changed, 5 insertions(+)
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -1430,6 +1430,11 @@ static int parse_map_size(char *str)
if (ret)
goto out;
+ if (!size) {
+ ret = -EINVAL;
+ goto out;
+ }
+
map_bits = ilog2(roundup_pow_of_two(size));
if (map_bits < TRACING_MAP_BITS_MIN ||
map_bits > TRACING_MAP_BITS_MAX)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 677/742] tracing: Do not allow user events to add a system name
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (660 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 676/742] tracing: Avoid undefined shifts for zero histogram map size Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 678/742] tracing: Drop the synthetic event ref when clearing hist triggers Greg Kroah-Hartman
` (64 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Beau Belgrave, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <rostedt@goodmis.org>
commit 761a77e09577bc7e5fdaff1d11bbff3486a87bf9 upstream.
User events currently do not support the addition of a system name, but
the parsing does not check to see if one is specified.
A kprobe can add its own system name with the following command:
~# echo 'p:mysystem/kprobe_event schedule a=%ax' >> dynamic_events
~# ls events/mysystem
enable filter kprobe_event
But if one tries to do the same with user events:
~# echo 'u:user_events/test u32 a' >> dynamic_events
~# ls events/user_events
ls: reading directory 'events/user_events/': Invalid argument
enable filter
It corrupts the file system as the event added had a '/' in the name.
Until user events support specifying system names, just return -EINVAL to
prevent the corrupted file system from happening:
~# echo 'u:user_events/test u32 a' >> dynamic_events
-bash: echo: write error: Invalid argument
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261118122520.4a689710@gandalf.local.home
Acked-by: Beau Belgrave <beaub@linux.microsoft.com>
Fixes: 7f5a08c79df35 ("user_events: Add minimal support for trace_event into ftrace")
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events_user.c | 3 +++
1 file changed, 3 insertions(+)
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -1040,6 +1040,9 @@ static int user_event_parse_cmd(struct u
if (flags)
*flags++ = '\0';
+ if (strstr(name, "/") != NULL)
+ return -EINVAL;
+
return user_event_parse(group, name, args, flags, newuser, reg_flags);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 678/742] tracing: Drop the synthetic event ref when clearing hist triggers
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (661 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 677/742] tracing: Do not allow user events to add a system name Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 679/742] tracing: Free tracer resources on instance creation failure Greg Kroah-Hartman
` (63 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, David Carlier, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <devnexen@gmail.com>
commit 2b3bed9617bb71c9b1893d9f54ef8df59a239224 upstream.
clear_event_triggers() frees a hist trigger on a synthetic event without
dropping the se->ref taken by event_hist_trigger_parse(). Removing an
instance with such a trigger leaves the synthetic event busy forever.
Cc: stable@vger.kernel.org
Fixes: 4b147936fa50 ("tracing: Add support for 'synthetic' events")
Link: https://patch.msgid.link/20261022205405.1228742-1-devnexen@gmail.com
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace.h | 2 ++
kernel/trace/trace_events_hist.c | 20 +++++++++++++-------
kernel/trace/trace_events_trigger.c | 2 ++
3 files changed, 17 insertions(+), 7 deletions(-)
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1911,9 +1911,11 @@ extern const struct file_operations even
#ifdef CONFIG_HIST_TRIGGERS
extern int register_trigger_hist_cmd(void);
extern int register_trigger_hist_enable_disable_cmds(void);
+extern void hist_put_synth_event(struct trace_event_file *file);
#else
static inline int register_trigger_hist_cmd(void) { return 0; }
static inline int register_trigger_hist_enable_disable_cmds(void) { return 0; }
+static inline void hist_put_synth_event(struct trace_event_file *file) { }
#endif
extern int register_trigger_cmds(void);
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -6768,6 +6768,17 @@ static bool hist_trigger_check_refs(stru
return false;
}
+void hist_put_synth_event(struct trace_event_file *file)
+{
+ struct synth_event *se;
+
+ lockdep_assert_held(&event_mutex);
+
+ se = find_synth_event_call(file->event_call);
+ if (se)
+ se->ref--;
+}
+
static void hist_unregister_trigger(char *glob,
struct event_trigger_data *data,
struct trace_event_file *file)
@@ -6823,7 +6834,6 @@ static void hist_unreg_all(struct trace_
{
struct event_trigger_data *test, *n;
struct hist_trigger_data *hist_data;
- struct synth_event *se;
lockdep_assert_held(&event_mutex);
@@ -6836,9 +6846,7 @@ static void hist_unreg_all(struct trace_
list_del_rcu(&test->list);
trace_event_trigger_enable_disable(file, 0);
- se = find_synth_event_call(file->event_call);
- if (se)
- se->ref--;
+ hist_put_synth_event(file);
update_cond_flag(file);
if (hist_data->enable_timestamps)
@@ -6953,9 +6961,7 @@ static int event_hist_trigger_parse(stru
}
event_trigger_unregister(cmd_ops, file, glob+1, trigger_data);
- se = find_synth_event_call(file->event_call);
- if (se)
- se->ref--;
+ hist_put_synth_event(file);
ret = 0;
goto out_free;
}
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -643,6 +643,8 @@ clear_event_triggers(struct trace_array
list_for_each_entry_safe(data, n, &file->triggers, list) {
trace_event_trigger_enable_disable(file, 0);
list_del_rcu(&data->list);
+ if (data->cmd_ops->trigger_type == ETT_EVENT_HIST)
+ hist_put_synth_event(file);
if (data->cmd_ops->free)
data->cmd_ops->free(data);
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 679/742] tracing: Free tracer resources on instance creation failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (662 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 678/742] tracing: Drop the synthetic event ref when clearing hist triggers Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 680/742] tracing: Ignore .function on the function trace event Greg Kroah-Hartman
` (62 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Baek Kyu, Kim, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baek Kyu, Kim <pocj8ur4in@gmail.com>
commit a20691808762d48ae38191cf856878e4c901b553 upstream.
Creating a tracefs instance can allocate private tracer nodes, copied
flags and option arrays before trace_array_create_dir() returns. If a
later allocation fails, trace_array_create_systems() frees the trace_array
without releasing those private allocations. The failed instance is never
registered, so normal removal cannot reclaim them.
Free the tracer nodes and option arrays when trace_array_create_dir()
fails, then continue through the existing trace_array cleanup. Share the
option array cleanup with normal instance removal. Earlier failures still
use out_free_tr because the tracer list is not yet initialized there.
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261029173127.387835-1-pocj8ur4in@gmail.com
Fixes: 428add559b69 ("tracing: Have tracer option be instance specific")
Signed-off-by: Baek Kyu, Kim <pocj8ur4in@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1456,6 +1456,13 @@ static void free_tracers(struct trace_ar
}
}
+static void free_tracer_options(struct trace_array *tr)
+{
+ for (int i = 0; i < tr->nr_topts; i++)
+ kfree(tr->topts[i].topts);
+ kfree(tr->topts);
+}
+
/**
* register_tracer - register a tracer with the ftrace system.
* @type: the plugin for the tracer
@@ -8764,7 +8771,7 @@ trace_array_create_systems(const char *n
if (trace_instance_dir) {
ret = trace_array_create_dir(tr);
if (ret)
- goto out_free_tr;
+ goto out_free_tracers;
} else
__trace_early_add_events(tr);
@@ -8774,6 +8781,9 @@ trace_array_create_systems(const char *n
return tr;
+ out_free_tracers:
+ free_tracers(tr);
+ free_tracer_options(tr);
out_free_tr:
ftrace_free_ftrace_ops(tr);
free_trace_buffers(tr);
@@ -8927,10 +8937,7 @@ static int __remove_instance(struct trac
if (tr->flags & TRACE_ARRAY_FL_VMALLOC)
vfree((void *)tr->range_addr_start);
- for (i = 0; i < tr->nr_topts; i++) {
- kfree(tr->topts[i].topts);
- }
- kfree(tr->topts);
+ free_tracer_options(tr);
free_cpumask_var(tr->pipe_cpumask);
free_cpumask_var(tr->tracing_cpumask);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 680/742] tracing: Ignore .function on the function trace event
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (663 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 679/742] tracing: Free tracer resources on instance creation failure Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 681/742] tracing: Take trace_access_lock() in tracing_buffers_ioctl() Greg Kroah-Hartman
` (61 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Steven Rostedt, David Carlier
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Carlier <devnexen@gmail.com>
commit 56ce4ed6316cae9536ea891d6686b92f1d930c00 upstream.
For the function event, parse_pred() handles the .function suffix
before the ftrace_event_is_function() case, so "ip.function == schedule"
builds a predicate with no regex. Setting it through perf then
dereferences the NULL pred->regex in ftrace_function_set_filter_pred().
The "ip" field of that event already takes a function name, so ignore
the suffix there and let the function event case handle it.
Cc: stable@vger.kernel.org
Fixes: cfb58e278c6a ("tracing/filters: Dynamically allocate filter_pred.regex")
Link: https://patch.msgid.link/20261119080139.131834-1-devnexen@gmail.com
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events_filter.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1722,7 +1722,9 @@ static int parse_pred(const char *str, v
/* See if the field is a kernel function name */
if ((len = str_has_prefix(str + i, ".function"))) {
- function = true;
+ /* Ignore if event is already a function */
+ if (!ftrace_event_is_function(call))
+ function = true;
i += len;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 681/742] tracing: Take trace_access_lock() in tracing_buffers_ioctl()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (664 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 680/742] tracing: Ignore .function on the function trace event Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 682/742] tracing: Validate user addresses in faultable buffer copies Greg Kroah-Hartman
` (60 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kyuwon Cho, Vincent Donnefort,
Masami Hiramatsu (Google), Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <vdonnefort@google.com>
commit 2891516d90b4dc9d41aa55fde08882e40c7c0336 upstream.
tracing_buffers_ioctl() calls ring_buffer_map_get_reader() without
trace_access_lock, breaking concurrent readers. Take trace_access_lock()
around ring_buffer_map_get_reader(), matching the other consuming
readers.
Cc: stable@vger.kernel.org
Fixes: cf9f0f7c4c5b ("tracing: Allow user-space mapping of the ring-buffer")
Reported-by: Kyuwon Cho <kyuwoncho18@gmail.com>
Closes: https://lore.kernel.org/all/179485165154.2547186.6129837870360499372@gmail.com/
Link: https://patch.msgid.link/20261117082932.3441173-1-vdonnefort@google.com
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7414,8 +7414,12 @@ static long tracing_buffers_ioctl(struct
return err;
}
- return ring_buffer_map_get_reader(iter->array_buffer->buffer,
- iter->cpu_file);
+ trace_access_lock(iter->cpu_file);
+ err = ring_buffer_map_get_reader(iter->array_buffer->buffer,
+ iter->cpu_file);
+ trace_access_unlock(iter->cpu_file);
+
+ return err;
} else if (cmd) {
return -ENOTTY;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 682/742] tracing: Validate user addresses in faultable buffer copies
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (665 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 681/742] tracing: Take trace_access_lock() in tracing_buffers_ioctl() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 683/742] vdso/math64: Use OPTIMIZER_HIDE_VAR() in __iter_div_u64_rem() Greg Kroah-Hartman
` (59 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Kyle Zeng, Steven Rostedt
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <kylebot@openai.com>
commit c62206dfe9c80490de8cc2d211fb28eea4958240 upstream.
trace_user_fault_read() uses __copy_from_user() when no custom copy
function is supplied. That primitive assumes the source address has
already been validated, but the helper only checks the destination
buffer size. A caller that passes an unchecked kernel address can
therefore cause mapped kernel memory to be copied into the tracing
buffer. The original syscall-array tracing implementation exposed this
path to syscall arguments before the syscall validated them.
Use copy_from_user() for the default copy as documented. Non-user
addresses then fail the copy and follow the existing NULL-return path.
Successful user copies, buffer bounds, and preemption and migration
retry rules are unchanged.
Cc: stable@vger.kernel.org
Fixes: 64cf7d058a005 ("tracing: Have trace_marker use per-cpu data to read user space")
Link: https://patch.msgid.link/20261110054411.75788-1-kylebot@openai.com
Signed-off-by: Kyle Zeng <kylebot@openai.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6299,7 +6299,7 @@ char *trace_user_fault_read(struct trace
if (copy_func) {
ret = copy_func(buffer, ptr, size, data);
} else {
- ret = __copy_from_user(buffer, ptr, size);
+ ret = copy_from_user(buffer, ptr, size);
}
preempt_disable_notrace();
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 683/742] vdso/math64: Use OPTIMIZER_HIDE_VAR() in __iter_div_u64_rem()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (666 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 682/742] tracing: Validate user addresses in faultable buffer copies Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 684/742] ipv6: Remove FIB6_EXCEPTION_BUCKET_FLUSHED Greg Kroah-Hartman
` (58 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, kernel test robot, Zhan Xusheng,
Thomas Gleixner, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhan Xusheng <zhanxusheng1024@gmail.com>
[ Upstream commit c1b910b270fee8930865410455f71e273f4c602c ]
__iter_div_u64_rem() open-codes an empty asm() to keep the compiler from
turning the subtraction loop into a modulo operation. That is what
OPTIMIZER_HIDE_VAR() is for, so use it and reflow the comment.
The macro lives in linux/compiler.h, which this header did not include.
vdso/math64.h is reached from linux/math64.h, whose includes are
linux/types.h, linux/math.h, asm/div64.h and vdso/math64.h; none of them
guarantees linux/compiler.h. x86 happens to get it through
asm/div64.h -> linux/log2.h, m68k's asm/div64.h only pulls in
asm-generic/div64.h and linux/types.h, so the macro is undeclared there
and the build fails with -Werror=implicit-function-declaration.
Include linux/compiler.h so the header no longer depends on its includer.
This is a no-op for the vDSO, where lib/vdso/gettimeofday.c already gets
it through linux/build_bug.h, and vdso/unaligned.h sets the same
precedent by including linux/compiler_types.h.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20261002153104.1347978-2-zhanxusheng@xiaomi.com
Closes: https://lore.kernel.org/oe-kbuild-all/202609300626.zwNjKaO6-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202609301300.uAawkHuh-lkp@intel.com/
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/vdso/math64.h | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/include/vdso/math64.h b/include/vdso/math64.h
index 2ef4905585c59..6f1e311cfdbd1 100644
--- a/include/vdso/math64.h
+++ b/include/vdso/math64.h
@@ -2,15 +2,18 @@
#ifndef __VDSO_MATH64_H
#define __VDSO_MATH64_H
-static __always_inline u32
-__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
+#include <linux/compiler.h>
+
+static __always_inline u32 __iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
{
u32 ret = 0;
while (dividend >= divisor) {
- /* The following asm() prevents the compiler from
- optimising this loop into a modulo operation. */
- asm("" : "+rm"(dividend));
+ /*
+ * Prevent the compiler from optimising this loop into a
+ * modulo operation.
+ */
+ OPTIMIZER_HIDE_VAR(dividend);
dividend -= divisor;
ret++;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 684/742] ipv6: Remove FIB6_EXCEPTION_BUCKET_FLUSHED.
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (667 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 683/742] vdso/math64: Use OPTIMIZER_HIDE_VAR() in __iter_div_u64_rem() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 685/742] ipv6: Flush exception route while replacing nexthop Greg Kroah-Hartman
` (57 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kuniyuki Iwashima, Ido Schimmel,
Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <kuniyu@google.com>
[ Upstream commit c66d93e68728cfb5f40b40d0f24129d7768faf43 ]
The FIB6_EXCEPTION_BUCKET_FLUSHED logic has been dead since added.
Commit 0346ec2f080b ("ipv6: Prevent rt6_insert_exception() for
dying fib6_info.") restored the original race protection in
rt6_insert_exception() by reusing fib6_info.fib6_destroying.
The flag now prevents two races for per-cpu and exception routes.
Let's remove FIB6_EXCEPTION_BUCKET_FLUSHED and set fib6_destroying
in fib6_purge_rt().
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260926033355.3295550-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ipv6/ip6_fib.c | 14 +++++++-------
net/ipv6/route.c | 45 ---------------------------------------------
2 files changed, 7 insertions(+), 52 deletions(-)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 2e1d8ab25f778..e1d49897d6ab0 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1053,12 +1053,6 @@ static int fib6_nh_drop_pcpu_from(struct fib6_nh *nh, void *_arg)
static void fib6_drop_pcpu_from(struct fib6_info *f6i)
{
- /* Make sure rt6_make_pcpu_route() wont add other percpu routes
- * while we are cleaning them here.
- */
- f6i->fib6_destroying = 1;
- mb(); /* paired with the cmpxchg() in rt6_make_pcpu_route() */
-
if (f6i->nh) {
rcu_read_lock();
nexthop_for_each_fib6_nh(f6i->nh, fib6_nh_drop_pcpu_from, f6i);
@@ -1076,7 +1070,13 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
{
struct fib6_table *table = rt->fib6_table;
- /* Flush all cached dst in exception table */
+ /* Make sure rt6_make_pcpu_route() / rt6_insert_exception()
+ * will not add other percpu / exception routes after cleaning
+ * them up in __fib6_drop_pcpu_from() / rt6_flush_exceptions().
+ */
+ rt->fib6_destroying = 1;
+ mb(); /* paired with the cmpxchg() in rt6_make_pcpu_route() */
+
fib6_drop_pcpu_from(rt);
rt6_flush_exceptions(rt);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 745782f80af42..6aa3479a07244 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1700,13 +1700,6 @@ static unsigned int fib6_mtu(const struct fib6_result *res)
return mtu - lwtunnel_headroom(nh->fib_nh_lws, mtu);
}
-#define FIB6_EXCEPTION_BUCKET_FLUSHED 0x1UL
-
-/* used when the flushed bit is not relevant, only access to the bucket
- * (ie., all bucket users except rt6_insert_exception);
- *
- * called under rcu lock; sometimes called with rt6_exception_lock held
- */
static
struct rt6_exception_bucket *fib6_nh_get_excptn_bucket(const struct fib6_nh *nh,
spinlock_t *lock)
@@ -1719,40 +1712,9 @@ struct rt6_exception_bucket *fib6_nh_get_excptn_bucket(const struct fib6_nh *nh,
else
bucket = rcu_dereference(nh->rt6i_exception_bucket);
- /* remove bucket flushed bit if set */
- if (bucket) {
- unsigned long p = (unsigned long)bucket;
-
- p &= ~FIB6_EXCEPTION_BUCKET_FLUSHED;
- bucket = (struct rt6_exception_bucket *)p;
- }
-
return bucket;
}
-static bool fib6_nh_excptn_bucket_flushed(struct rt6_exception_bucket *bucket)
-{
- unsigned long p = (unsigned long)bucket;
-
- return !!(p & FIB6_EXCEPTION_BUCKET_FLUSHED);
-}
-
-/* called with rt6_exception_lock held */
-static void fib6_nh_excptn_bucket_set_flushed(struct fib6_nh *nh,
- spinlock_t *lock)
-{
- struct rt6_exception_bucket *bucket;
- unsigned long p;
-
- bucket = rcu_dereference_protected(nh->rt6i_exception_bucket,
- lockdep_is_held(lock));
-
- p = (unsigned long)bucket;
- p |= FIB6_EXCEPTION_BUCKET_FLUSHED;
- bucket = (struct rt6_exception_bucket *)p;
- rcu_assign_pointer(nh->rt6i_exception_bucket, bucket);
-}
-
static int rt6_insert_exception(struct rt6_info *nrt,
const struct fib6_result *res)
{
@@ -1782,9 +1744,6 @@ static int rt6_insert_exception(struct rt6_info *nrt,
goto out;
}
rcu_assign_pointer(nh->rt6i_exception_bucket, bucket);
- } else if (fib6_nh_excptn_bucket_flushed(bucket)) {
- err = -EINVAL;
- goto out;
}
#ifdef CONFIG_IPV6_SUBTREES
@@ -1855,10 +1814,6 @@ static void fib6_nh_flush_exceptions(struct fib6_nh *nh, struct fib6_info *from)
if (!bucket)
goto out;
- /* Prevent rt6_insert_exception() to recreate the bucket list */
- if (!from)
- fib6_nh_excptn_bucket_set_flushed(nh, &rt6_exception_lock);
-
for (i = 0; i < FIB6_EXCEPTION_BUCKET_SIZE; i++) {
hlist_for_each_entry_safe(rt6_ex, tmp, &bucket->chain, hlist) {
if (!from ||
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 685/742] ipv6: Flush exception route while replacing nexthop.
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (668 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 684/742] ipv6: Remove FIB6_EXCEPTION_BUCKET_FLUSHED Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 686/742] wifi: rtw89: modify active scan rule for 6GHz band Greg Kroah-Hartman
` (56 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jason Zhang, Kuniyuki Iwashima,
Ido Schimmel, Paolo Abeni, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <kuniyu@google.com>
[ Upstream commit 9401b428b5d4dfe1fd5752973fd02b4e9cd05536 ]
The following creates a cyclic reference between IPv6 route
and nexthop:
1. create a nexthop A
2. create a nexthop group w/ A
3. create an IPv6 route with the nexthop group
4. create an exception route w/ A
5. replace A with a new nexthop B in the nexthop group
6. remove the IPv6 route
7. replace B with A in the nexthop group
8. remove the nexthop group
Then, removing a device tied to the route gets stuck and
triggers the splat below. [0]
At 5., fib6_nh_release_dsts() is called, but it does not
flush exception routes, so the nexthop A continues to grab
the IPv6 route reference.
nh_A->rt6i_exception_bucket[] -> rt6_ex->rt6i->from
At 6., fib6_purge_rt() calls rt6_flush_exceptions(), but it
only purges exceptions tied to nexthop B. Also, the route is
unlinked from the nexthop group by list_del_init(&rt->nh_list).
-> f6i->nh -> nhg->nh_entries[]
At 8., __remove_nexthop_fib() cannot find the IPv6 route, and
remove_nexthop_group() calls list_del_init(&nhge->nh_list) to
unlink the group from the nexthop A's nhe->grp_list.
nhg->nh_entries[] -> nh_A -> ... -> f6i
Here, the nexthop A is reachable from net->nexthop.devhash[],
but remove_nexthop_from_groups() cannot find the nexthop group,
leaking the whole chain.
Let's call fib6_nh_flush_exceptions() in fib6_nh_release_dsts().
[0]:
unregister_netdevice: waiting for gre6 to become free. Usage count = 4
ref_tracker: netdev@000000009652f190 has 1/3 users at
dst_alloc+0x14b/0x490
ip6_rt_cache_alloc+0x27b/0x670
__ip6_rt_update_pmtu+0x572/0x850
ip6_tnl_xmit+0x8c5/0x1b70
__gre6_xmit+0x7af/0xaa0
ip6gre_tunnel_xmit+0x685/0xdc0
dev_hard_start_xmit+0x204/0x5a0
__dev_queue_xmit+0xe8a/0x2550
ip6_finish_output+0x232/0x570
ip6_output+0x226/0x3b0
ip6_send_skb+0x133/0x250
rawv6_push_pending_frames+0x503/0x6f0
rawv6_sendmsg+0xdf0/0x1310
sock_sendmsg_nosec+0xde/0x130
__sys_sendto+0x27f/0x320
__x64_sys_sendto+0xd9/0xf0
Fixes: 7bf4796dd099 ("nexthops: add support for replace")
Reported-by: Jason Zhang <jdz@google.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20261101064418.2055158-2-kuniyu@google.com
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/ipv6/route.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 6aa3479a07244..308e1a48cd362 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3721,9 +3721,10 @@ void fib6_nh_release(struct fib6_nh *fib6_nh)
{
struct rt6_exception_bucket *bucket;
+ fib6_nh_release_dsts(fib6_nh);
+
rcu_read_lock();
- fib6_nh_flush_exceptions(fib6_nh, NULL);
bucket = fib6_nh_get_excptn_bucket(fib6_nh, NULL);
if (bucket) {
rcu_assign_pointer(fib6_nh->rt6i_exception_bucket, NULL);
@@ -3732,7 +3733,6 @@ void fib6_nh_release(struct fib6_nh *fib6_nh)
rcu_read_unlock();
- fib6_nh_release_dsts(fib6_nh);
free_percpu(fib6_nh->rt6i_pcpu);
fib_nh_common_release(&fib6_nh->nh_common);
@@ -3742,6 +3742,8 @@ void fib6_nh_release_dsts(struct fib6_nh *fib6_nh)
{
int cpu;
+ fib6_nh_flush_exceptions(fib6_nh, NULL);
+
if (!fib6_nh->rt6i_pcpu)
return;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 686/742] wifi: rtw89: modify active scan rule for 6GHz band
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (669 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 685/742] ipv6: Flush exception route while replacing nexthop Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 687/742] vhost/net: Fix receive queue test in busy poll Greg Kroah-Hartman
` (55 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Po-Hao Huang, Ping-Ke Shih,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Po-Hao Huang <phhuang@realtek.com>
[ Upstream commit 0788bad5d012b164e5eabf5da206dea4fa67db1c ]
Remove the cancellation of active scan with specific SSID when receiving
beacons/probe responses of that SSID. Per IEEE Std 802.11ax 26.17.2.3.3,
only active scan of direct BSSID should be cancelled. Previously the
cancellation causes hidden AP under same ESS couldn't be found.
Signed-off-by: Po-Hao Huang <phhuang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260909070004.35353-5-pkshih@realtek.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/wireless/realtek/rtw89/core.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 397ebbfcac09a..4ec628920228a 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -2571,7 +2571,6 @@ static void rtw89_core_cancel_6ghz_probe_tx(struct rtw89_dev *rtwdev,
struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
struct list_head *pkt_list = rtwdev->scan_info.pkt_list;
struct rtw89_pktofld_info *info;
- const u8 *ies = mgmt->u.beacon.variable, *ssid_ie;
bool queue_work = false;
if (rx_status->band != NL80211_BAND_6GHZ)
@@ -2582,21 +2581,10 @@ static void rtw89_core_cancel_6ghz_probe_tx(struct rtw89_dev *rtwdev,
return;
}
- ssid_ie = cfg80211_find_ie(WLAN_EID_SSID, ies, skb->len);
-
list_for_each_entry(info, &pkt_list[NL80211_BAND_6GHZ], list) {
if (ether_addr_equal(info->bssid, mgmt->bssid)) {
info->cancel = true;
queue_work = true;
- continue;
- }
-
- if (!ssid_ie || ssid_ie[1] != info->ssid_len || info->ssid_len == 0)
- continue;
-
- if (memcmp(&ssid_ie[2], info->ssid, info->ssid_len) == 0) {
- info->cancel = true;
- queue_work = true;
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 687/742] vhost/net: Fix receive queue test in busy poll
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (670 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 686/742] wifi: rtw89: modify active scan rule for 6GHz band Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 688/742] vhost: Run TIF_NOTIFY_RESUME work in the vhost_task loop Greg Kroah-Hartman
` (54 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Xu Rao, Eugenio Pérez,
Willem de Bruijn
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Rao <raoxu@uniontech.com>
commit cdf84b850584574fc81bd80990d3bf1cf81b6a00 upstream.
sock_has_rx_data() returns a positive value when receive data is
available. For sockets without a peek_len() callback, however, its
fallback returns skb_queue_empty(), which has the opposite meaning.
An AF_PACKET SOCK_RAW socket is accepted by get_raw_socket() as a
vhost-net backend, and its socket operations do not provide peek_len().
With busy polling enabled for this backend, an empty receive queue is
treated as ready and a nonempty queue as not ready. This can make
vhost_net_busy_poll() stop polling prematurely or fail to stop for
queued receive data, and invert its receive-side scheduling decision.
TUN and TAP backends provide peek_len() and are unaffected.
Negate skb_queue_empty() so the fallback matches the callback and the
readiness checks in vhost_net_busy_poll().
The issue was found during AI-assisted code review. The helper's
incorrect result was confirmed on x86_64 running 6.6.0-amd64-desktop
using a temporary diagnostic module containing the original and fixed
helpers. An AF_PACKET SOCK_RAW socket, without PACKET_RX_RING, was
bound to loopback in a private network namespace. Across three cycles
of sending and receiving a 60-byte frame, the original helper returned
1 for an empty queue and 0 for a queued frame. The fixed helper returned
0 and 1 respectively, matching socket readability in all nine checks.
This tests helper copies on real sockets, not the running vhost-net
busy-poll path; the vhost-net module was not replaced.
The patched drivers/vhost/net.o was also build-tested on the net tree
with x86_64 GCC 12.3 and W=1 under allmodconfig and allyesconfig.
No end-to-end vhost tests or kernel selftests were run.
Fixes: 1576d9860599 ("tun: switch to use skb array for tx")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Rao <raoxu@uniontech.com>
Acked-by: Eugenio Pérez <eperezma@redhat.com>
Link: https://patch.msgid.link/1B3A1B72438119BC+20261120033824.681219-1-raoxu@uniontech.com
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/vhost/net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -538,7 +538,7 @@ static int sock_has_rx_data(struct socke
if (sock->ops->peek_len)
return sock->ops->peek_len(sock);
- return skb_queue_empty(&sock->sk->sk_receive_queue);
+ return !skb_queue_empty(&sock->sk->sk_receive_queue);
}
static void vhost_net_busy_poll_try_queue(struct vhost_net *net,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 688/742] vhost: Run TIF_NOTIFY_RESUME work in the vhost_task loop
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (671 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 687/742] vhost/net: Fix receive queue test in busy poll Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 689/742] Revert "vhost: split out-of-order used ring batches at every wrap" Greg Kroah-Hartman
` (53 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Shakeel Butt, Aamir Ahmed,
Bradley Morgan, Michael S. Tsirkin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aamir Ahmed <elb12345@hotmail.co.uk>
commit f20d30ff369de1f995546d11888d2b70b089afa4 upstream.
Since commit e1fad12dcb66 ("sched/fair: Switch to task based throttle
model"), a throttled task is only dequeued when TWA_RESUME task_work
runs on its way back to user mode.
vhost workers never return to user mode, and vhost_task_fn() only runs
task_work via get_signal() when a signal is pending. A busy vhost worker
therefore ignores its cgroup's cpu.max, while its runtime is still
charged to the group, throttling the group's other tasks (typically the
VM's vCPUs) harder.
This also fixes memory.high and block cgroup throttling for vhost
workers, which are handled in resume_user_mode_work() as well.
Run pending notify-resume work at the top of the worker loop, as io-wq
does in io_run_task_work(). Commit 12013e3d4695 ("KVM: powerpc: Use
generic xfer to guest work function") fixed the same problem for KVM.
Fixes: e1fad12dcb66 ("sched/fair: Switch to task based throttle model")
Cc: stable@vger.kernel.org # 6.18+
Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
Tested-by: Shakeel Butt <shakeel.butt@linux.dev>
Assisted-by: LLM
Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk>
Reviewed-by: Bradley Morgan <brads@mainlining.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <AS8P251MB0001F1EACBED6E7A2AFA8A96C8692@AS8P251MB0001.EURP251.PROD.OUTLOOK.COM>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/vhost_task.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/kernel/vhost_task.c
+++ b/kernel/vhost_task.c
@@ -6,6 +6,7 @@
#include <linux/completion.h>
#include <linux/sched/task.h>
#include <linux/sched/vhost_task.h>
+#include <linux/resume_user_mode.h>
#include <linux/sched/signal.h>
enum vhost_task_flags {
@@ -31,6 +32,14 @@ static int vhost_task_fn(void *data)
for (;;) {
bool did_work;
+ /*
+ * We never return to user mode, so TWA_RESUME task_work and
+ * memory.high/blkcg throttling would otherwise never run. Run
+ * them here, where no locks are held, like io-wq workers do.
+ */
+ if (test_thread_flag(TIF_NOTIFY_RESUME))
+ resume_user_mode_work(NULL);
+
if (signal_pending(current)) {
struct ksignal ksig;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 689/742] Revert "vhost: split out-of-order used ring batches at every wrap"
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (672 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 688/742] vhost: Run TIF_NOTIFY_RESUME work in the vhost_task loop Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 690/742] vhost: reject used ring batches larger than the ring Greg Kroah-Hartman
` (52 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Michael S. Tsirkin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael S. Tsirkin <mst@redhat.com>
commit 9842e945a0991c81993ce50926cc5a277ec1e5ba upstream.
This reverts commit 5570a998b884c988dbe105430d7e2d8e9411e37e.
Commit 5570a998b884 ("vhost: split out-of-order used ring batches at
every wrap") addressed completion batches larger than the ring on the
out-of-order path, but did not cover all paths (such as the in-order
dirty-log replay loop).
Revert it; a follow-up patch will address all paths in a more consistent
manner.
Cc: stable@vger.kernel.org
Fixes: 5570a998b884 ("vhost: split out-of-order used ring batches at every wrap")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/vhost/vhost.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -3137,21 +3137,18 @@ static int vhost_add_used_n_ooo(struct v
struct vring_used_elem *heads,
unsigned count)
{
- unsigned int n;
- int r;
+ int start, n, r;
- do {
- unsigned int start = vq->last_used_idx & (vq->num - 1);
-
- n = min(vq->num - start, count);
+ start = vq->last_used_idx & (vq->num - 1);
+ n = vq->num - start;
+ if (n < count) {
r = __vhost_add_used_n(vq, heads, n);
if (r < 0)
return r;
heads += n;
count -= n;
- } while (count);
-
- return 0;
+ }
+ return __vhost_add_used_n(vq, heads, count);
}
static int vhost_add_used_n_in_order(struct vhost_virtqueue *vq,
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 690/742] vhost: reject used ring batches larger than the ring
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (673 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 689/742] Revert "vhost: split out-of-order used ring batches at every wrap" Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 691/742] i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period Greg Kroah-Hartman
` (51 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Seohyeon Maeng, minki, YanXin Li,
Jason Wang, Eugenio Pérez, Michael S. Tsirkin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael S. Tsirkin <mst@redhat.com>
commit 700737df3b825a1b9d0724acfc62b177f1e723df upstream.
A compliant driver never has more than vq->num buffers in flight at
once, so a batch accumulated before used->idx advances never exceeds
vq->num.
Reject used count > vq->num in
vhost_add_used_n()/vhost_add_used_n_in_order().
Cc: stable@vger.kernel.org
Reported-by: Seohyeon Maeng <bioloidgp@gmail.com>
Reported-by: minki@morningstarsec.dev
Reported-by: YanXin Li <fadouse@pm.me>
Fixes: e2b3b35eb989 ("vhost_net: batch used ring update in rx")
Fixes: 4afb52c2af44 ("vhost_net: batch update used ring for datacopy TX")
Fixes: bfcde6b64769 ("vhost: fix dirty logging for in-order used ring entries")
Cc: Jason Wang <jasowangio@gmail.com>
Cc: Eugenio Pérez <eperezma@redhat.com>
Message-ID: <66327153423e98bd10778bac1f29c26ba633e02a.1796163071.git.mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/vhost/vhost.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -3158,6 +3158,7 @@ static int vhost_add_used_n_in_order(str
{
vring_used_elem_t __user *used;
u16 old, new = vq->last_used_idx;
+ unsigned int total = 0;
int start, i;
if (!nheads)
@@ -3166,6 +3167,12 @@ static int vhost_add_used_n_in_order(str
start = vq->last_used_idx & (vq->num - 1);
for (i = 0; i < count; i++) {
+ total += nheads[i];
+ if (unlikely(total > vq->num)) {
+ vq_err(vq, "Added %u > %u used heads\n",
+ total, vq->num);
+ return -EINVAL;
+ }
if (vhost_put_used(vq, &heads[i], start, 1)) {
vq_err(vq, "Failed to write used");
return -EFAULT;
@@ -3222,6 +3229,11 @@ int vhost_add_used_n(struct vhost_virtqu
bool in_order = vhost_has_feature(vq, VIRTIO_F_IN_ORDER);
int r;
+ if (unlikely(count > vq->num)) {
+ vq_err(vq, "Added %u > %u used entries\n", count, vq->num);
+ return -EINVAL;
+ }
+
if (!in_order || !nheads)
r = vhost_add_used_n_ooo(vq, heads, count);
else
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 691/742] i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (674 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 690/742] vhost: reject used ring batches larger than the ring Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 692/742] usb: gadget: f_uac1_legacy: fix double close of the ALSA devices Greg Kroah-Hartman
` (50 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Dave Airlie
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Airlie <airlied@redhat.com>
commit 4cd3c5bdf16789fc8c8736ed1a1a645b8cecb3b6 upstream.
There is a race in the vma lookup and the vma freeing that can race
object close against object execbuffer vma lookups.
execbuffer2 and close on two threads can be raced, so the radix tree
lookup and tryget in eb_lookup_vma can be raced against a freed vma.
The rcu protection in the eb lookup doesn't help because we don't
use rcu around the free path.
This patch adds rcu protection around the vma destruction path.
We could also probably use SLAB_TYPESAFE_BY_RCU but there may be
other submarined vma races in other code that this might not fix,
so let's just force the rcu on free.
Cc: stable@vger.kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/i915/i915_vma.c | 2 +-
drivers/gpu/drm/i915/i915_vma_types.h | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -67,7 +67,7 @@ static struct i915_vma *i915_vma_alloc(v
static void i915_vma_free(struct i915_vma *vma)
{
- return kmem_cache_free(slab_vmas, vma);
+ kfree_rcu(vma, rcu);
}
#if IS_ENABLED(CONFIG_DRM_I915_ERRLOG_GEM) && IS_ENABLED(CONFIG_DRM_DEBUG_MM)
--- a/drivers/gpu/drm/i915/i915_vma_types.h
+++ b/drivers/gpu/drm/i915/i915_vma_types.h
@@ -248,6 +248,9 @@ struct i915_vma {
struct list_head closed_link;
+ /** rcu head for kfree_rcu */
+ struct rcu_head rcu;
+
/** The async vma resource. Protected by the vm_mutex */
struct i915_vma_resource *resource;
};
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 692/742] usb: gadget: f_uac1_legacy: fix double close of the ALSA devices
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (675 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 691/742] i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 693/742] ALSA: firewire-lib: Abort the FCP transaction on a bus reset Greg Kroah-Hartman
` (49 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, stable, syzbot+df868600fe111c5ff79f,
Vasileios Almpanis
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vasileios Almpanis <vasilisalmpanis@gmail.com>
commit ba4bbac98e65c6998cac4ea2b63baf2159d00a8c upstream.
f_audio_bind() records that the ALSA files are open in the function
instance flag opts->bound, but keeps the file pointers in the
per-function gaudio card. Its error path calls gaudio_cleanup(), which
closes the files without clearing the filp pointers or opts->bound.
A failed bind does not destroy the usb_function, configfs_composite_bind()
puts it back on cfg->func_list, so the next write to UDC binds the same
f_audio, skips gaudio_setup() because opts->bound is still set, and on
failure closes the files a second time. Dropping the config symlink after
a failed bind closes them again via f_audio_free().
BUG: KASAN: slab-use-after-free in filp_flush+0x31/0x190 fs/open.c:1464
Read of size 8 at addr ffff888045f01990 by task syz-executor659/5617
Call Trace:
filp_close+0x1d/0x40 fs/open.c:1484
gaudio_close_snd_dev drivers/usb/gadget/function/u_uac1_legacy.c:263 [inline]
gaudio_cleanup+0x54/0xf0 drivers/usb/gadget/function/u_uac1_legacy.c:305
f_audio_bind+0x4a0/0x630 drivers/usb/gadget/function/f_uac1_legacy.c:792
usb_add_function+0x290/0x930 drivers/usb/gadget/composite.c:333
configfs_composite_bind+0xde0/0x1410 drivers/usb/gadget/configfs.c:1802
gadget_bind_driver+0x2ca/0x9e0 drivers/usb/gadget/udc/core.c:1662
gadget_dev_desc_UDC_store+0x1c9/0x2f0 drivers/usb/gadget/configfs.c:300
Clear filp, substream and card in gaudio_close_snd_dev() so cleanup is
idempotent, and close the devices on the bind error path only if that
bind opened them, resetting opts->bound as well.
Fixes: f3a3406b3f56 ("usb: gadget: f_uac1: convert to new function interface with backward compatibility")
Cc: stable <stable@kernel.org>
Reported-by: syzbot+df868600fe111c5ff79f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=df868600fe111c5ff79f
Signed-off-by: Vasileios Almpanis <vasilisalmpanis@gmail.com>
Link: https://patch.msgid.link/20260731-alsa-v1-1-95eb93ba32ec@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/gadget/function/f_uac1_legacy.c | 8 +++++++-
drivers/usb/gadget/function/u_uac1_legacy.c | 17 ++++++++++++++---
2 files changed, 21 insertions(+), 4 deletions(-)
--- a/drivers/usb/gadget/function/f_uac1_legacy.c
+++ b/drivers/usb/gadget/function/f_uac1_legacy.c
@@ -732,6 +732,7 @@ f_audio_bind(struct usb_configuration *c
int status;
struct usb_ep *ep = NULL;
struct f_uac1_legacy_opts *audio_opts;
+ bool bound_here = false;
audio_opts = container_of(f->fi, struct f_uac1_legacy_opts, func_inst);
audio->card.gadget = c->cdev->gadget;
@@ -741,6 +742,7 @@ f_audio_bind(struct usb_configuration *c
if (status < 0)
return status;
audio_opts->bound = true;
+ bound_here = true;
}
us = usb_gstrings_attach(cdev, uac1_strings, ARRAY_SIZE(strings_uac1));
if (IS_ERR(us))
@@ -789,7 +791,11 @@ f_audio_bind(struct usb_configuration *c
return 0;
fail:
- gaudio_cleanup(&audio->card);
+ /* Only tear down the ALSA devices if this bind opened them; the */
+ if (bound_here) {
+ gaudio_cleanup(&audio->card);
+ audio_opts->bound = false;
+ }
return status;
}
--- a/drivers/usb/gadget/function/u_uac1_legacy.c
+++ b/drivers/usb/gadget/function/u_uac1_legacy.c
@@ -259,18 +259,29 @@ static int gaudio_close_snd_dev(struct g
/* Close control device */
snd = &gau->control;
- if (snd->filp)
+ if (snd->filp) {
filp_close(snd->filp, NULL);
+ snd->filp = NULL;
+ snd->card = NULL;
+ }
/* Close PCM playback device and setup substream */
snd = &gau->playback;
- if (snd->filp)
+ if (snd->filp) {
filp_close(snd->filp, NULL);
+ snd->filp = NULL;
+ snd->substream = NULL;
+ snd->card = NULL;
+ }
/* Close PCM capture device and setup substream */
snd = &gau->capture;
- if (snd->filp)
+ if (snd->filp) {
filp_close(snd->filp, NULL);
+ snd->filp = NULL;
+ snd->substream = NULL;
+ snd->card = NULL;
+ }
return 0;
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 693/742] ALSA: firewire-lib: Abort the FCP transaction on a bus reset
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (676 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 692/742] usb: gadget: f_uac1_legacy: fix double close of the ALSA devices Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 694/742] ALSA: hda/realtek: Fix regression on another Lenovo Legion 16IRX9H model Greg Kroah-Hartman
` (48 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Takashi Sakamoto, Kaixuan Li,
Suyuan Wang, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suyuan Wang <stevewong@hust.edu.cn>
commit 5e8802bf480da76634a8ac929c29af7b7acde615 upstream.
When fcp_bus_reset() marks a transaction as STATE_BUS_RESET,
fcp_avc_transaction() sleeps and resends the command, but leaves the
state as it is. The response to the resent command is then ignored, and
the next wait returns at once, so the loop keeps resending the command
without a retry limit until sending fails.
The AV/C Digital Interface Command Set General Specification 4.2 says
that a target which detects a bus reset discards any AV/C transaction
in progress without returning a response. So instead of resending, end
the transaction on a bus reset and return -EAGAIN, so that the caller
can start the sequence again. ERROR_DELAY_MS and <linux/delay.h> have no
users left after this, so drop them.
Found with a static analysis tool and checked by hand.
Suggested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Fixes: 31ef9134eb52 ("ALSA: add LaCie FireWire Speakers/Griffin FireWave Surround driver")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20261122-firewire-busreset-v2-1-e104d785c8a1@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/firewire/fcp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
--- a/sound/firewire/fcp.c
+++ b/sound/firewire/fcp.c
@@ -14,7 +14,6 @@
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/wait.h>
-#include <linux/delay.h>
#include "fcp.h"
#include "lib.h"
#include "amdtp-stream.h"
@@ -22,7 +21,6 @@
#define CTS_AVC 0x00
#define ERROR_RETRIES 3
-#define ERROR_DELAY_MS 5
#define FCP_TIMEOUT_MS 125
int avc_general_set_sig_fmt(struct fw_unit *unit, unsigned int rate,
@@ -272,7 +270,8 @@ deferred:
ret = t.response_size;
break;
} else if (t.state == STATE_BUS_RESET) {
- msleep(ERROR_DELAY_MS);
+ ret = -EAGAIN;
+ break;
} else if (++tries >= ERROR_RETRIES) {
dev_err(&t.unit->device, "FCP command timed out\n");
ret = -EIO;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 694/742] ALSA: hda/realtek: Fix regression on another Lenovo Legion 16IRX9H model
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (677 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 693/742] ALSA: firewire-lib: Abort the FCP transaction on a bus reset Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 695/742] ALSA: fireworks: Abort the transaction on a bus reset Greg Kroah-Hartman
` (47 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Edward Bentall, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <tiwai@suse.de>
commit 1e04af2e3e17d62bc6d82ee890a3218341cae9d1 upstream.
There is yet another Lenovo Legion 16IRX9H model with the codec SSID
17aa:38cb that suffers from the same regression as stated in the
commit 0b4d69e8d2b5 ("ALSA: hda/realtek: Fix regression on Lenovo
Legion 16IRX9H").
Cover this device in the same way, too.
Fixes: f2293e7b2ddd ("ALSA: hda/realtek: Enable all four speaker amps on Lenovo ThinkBook X G2 IAH")
Cc: <stable@vger.kernel.org>
Reported-by: Edward Bentall <bentallea@gmail.com>
Closes: https://lore.kernel.org/CACw1+JLf_0i+GvJ4POkFUrPo_AWNHp9X2aCxyQVFRcdrKbKVxQ@mail.gmail.com
Link: https://patch.msgid.link/20261124125606.570355-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/hda/codecs/realtek/alc269.c | 1 +
1 file changed, 1 insertion(+)
--- a/sound/hda/codecs/realtek/alc269.c
+++ b/sound/hda/codecs/realtek/alc269.c
@@ -8345,6 +8345,7 @@ static const struct hda_quirk alc269_fix
SND_PCI_QUIRK(0x17aa, 0x3834, "Lenovo IdeaPad Slim 9i 14ITL5", ALC287_FIXUP_YOGA7_14ITL_SPEAKERS),
SND_PCI_QUIRK(0x17aa, 0x383d, "Legion Y9000X 2019", ALC285_FIXUP_LEGION_Y9000X_SPEAKERS),
/* Legion 16IRX9H shares PCI SSID 17aa:3842 with Thinkpad X G2 below */
+ HDA_CODEC_QUIRK(0x17aa, 0x38cb, "Lenovo Legion 16IRX9H", ALC287_FIXUP_TAS2781_I2C),
HDA_CODEC_QUIRK(0x17aa, 0x38cd, "Lenovo Legion 16IRX9H", ALC287_FIXUP_TAS2781_I2C),
SND_PCI_QUIRK(0x17aa, 0x3842, "ThinkBook X G2 IAH", ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_4_THINKPAD),
SND_PCI_QUIRK(0x17aa, 0x3843, "Lenovo Yoga 9i / Yoga Book 9i", ALC287_FIXUP_LENOVO_YOGA_BOOK_9I),
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 695/742] ALSA: fireworks: Abort the transaction on a bus reset
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (678 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 694/742] ALSA: hda/realtek: Fix regression on another Lenovo Legion 16IRX9H model Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 696/742] ALSA: oss: Fix deadlock at unregistering (again) Greg Kroah-Hartman
` (46 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Takashi Sakamoto, Kaixuan Li,
Suyuan Wang, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suyuan Wang <stevewong@hust.edu.cn>
commit 890eff85e8a01012e1d3b6c54cba787416331381 upstream.
When snd_efw_transaction_bus_reset() marks a transaction as
STATE_BUS_RESET, snd_efw_transaction_run() sleeps and resends the
command, but leaves the state as it is. The response to the resent
command is then ignored, and the next wait returns at once, so the loop
keeps resending the command without a retry limit until sending fails.
Fireworks devices also accept AV/C commands, and the AV/C general
specification says that a bus reset discards any transaction in
progress. Do the same as for FCP: end the transaction on a bus reset and
return -EAGAIN. ERROR_DELAY_MS has no users left, so drop it.
Found with a static analysis tool and checked by hand.
Suggested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Fixes: bde8a8f23bbe ("ALSA: fireworks: Add transaction and some commands")
Cc: stable@vger.kernel.org
Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20261122-firewire-busreset-v2-2-e104d785c8a1@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/firewire/fireworks/fireworks_transaction.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/sound/firewire/fireworks/fireworks_transaction.c
+++ b/sound/firewire/fireworks/fireworks_transaction.c
@@ -34,7 +34,6 @@
#define MEMORY_SPACE_EFW_RESPONSE 0xecc080000000ULL
#define ERROR_RETRIES 3
-#define ERROR_DELAY_MS 5
#define EFC_TIMEOUT_MS 125
static DEFINE_SPINLOCK(instances_lock);
@@ -99,7 +98,8 @@ int snd_efw_transaction_run(struct fw_un
ret = t.size;
break;
} else if (t.state == STATE_BUS_RESET) {
- msleep(ERROR_DELAY_MS);
+ ret = -EAGAIN;
+ break;
} else if (++tries >= ERROR_RETRIES) {
dev_err(&t.unit->device, "EFW transaction timed out\n");
ret = -EIO;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 696/742] ALSA: oss: Fix deadlock at unregistering (again)
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (679 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 695/742] ALSA: fireworks: Abort the transaction on a bus reset Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 697/742] ALSA: usb-audio: Dont queue playback URBs after stop Greg Kroah-Hartman
` (45 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <tiwai@suse.de>
commit dda2d9cd1fcd9ea1e4a93657e7386fde37d7e2ba upstream.
The recent code refactoring using guard() re-introduced a potential
deadlock at unregistering OSS device that had been fixed onceby the
commit 97d917879d7f ("ALSA: oss: Fix potential deadlock at
unregistration"). The unregister_sound_special() call must be done
outside the sound_oss_mutex.
Fix the regression by changing guard() with scoped_guard() to limit
the range.
Fixes: 742ecf3ce1ac ("ALSA: core: Use guard() for locking")
Cc: <stable@vger.kernel.org>
Link: https://patch.msgid.link/20261125135453.2088984-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/core/sound_oss.c | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -153,24 +153,25 @@ int snd_unregister_oss_device(int type,
return 0;
if (minor < 0)
return minor;
- guard(mutex)(&sound_oss_mutex);
- mptr = snd_oss_minors[minor];
- if (mptr == NULL)
- return -ENOENT;
- switch (SNDRV_MINOR_OSS_DEVICE(minor)) {
- case SNDRV_MINOR_OSS_PCM:
- track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_AUDIO);
- break;
- case SNDRV_MINOR_OSS_MIDI:
- track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI);
- break;
- case SNDRV_MINOR_OSS_MIDI1:
- track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1);
- break;
+ scoped_guard(mutex, &sound_oss_mutex) {
+ mptr = snd_oss_minors[minor];
+ if (mptr == NULL)
+ return -ENOENT;
+ switch (SNDRV_MINOR_OSS_DEVICE(minor)) {
+ case SNDRV_MINOR_OSS_PCM:
+ track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_AUDIO);
+ break;
+ case SNDRV_MINOR_OSS_MIDI:
+ track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI);
+ break;
+ case SNDRV_MINOR_OSS_MIDI1:
+ track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1);
+ break;
+ }
+ if (track2 >= 0)
+ snd_oss_minors[track2] = NULL;
+ snd_oss_minors[minor] = NULL;
}
- if (track2 >= 0)
- snd_oss_minors[track2] = NULL;
- snd_oss_minors[minor] = NULL;
/* call unregister_sound_special() outside sound_oss_mutex;
* otherwise may deadlock, as it can trigger the release of a card
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 697/742] ALSA: usb-audio: Dont queue playback URBs after stop
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (680 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 696/742] ALSA: oss: Fix deadlock at unregistering (again) Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 698/742] ALSA: timer: Protect the slave instance flags with the timer lock Greg Kroah-Hartman
` (44 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Miloslav Brada, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <tiwai@suse.de>
commit 5a6fcabe156e91c6ef2435a74f2d16e6dd39f7c7 upstream.
Although we've tried to address the corrupted ready_list for the
playback URBs due to the concurrent start/stop of streams, there seems
still a slight race: namely, in snd_complete_urb(), the driver checks
the EP check via ep_state_running() and process
push_back_to_ready_list() only when the EP isn't stopped. But since
the EP state change can still happen between the EP state check and
push_back_to_ready_list(), push_back_to_ready_list() may queue the
URBs unexpectedly even after the EP gets stopped. This may result in
a list corruption when the stream is restarted.
The addition to the list itself is properly protected by a lock, so as
a stop-gap, just add the EP state check again before actually adding
to the list.
In a long-term, we should reorganize the code to cover the EP state
changes more consistently, but this should suffice for the particular
race, at least.
Reported-by: Miloslav Brada <email@miloslavbrada.cz>
Closes: https://lore.kernel.org/awZs88beIhMcOchv@genesis.transkript.cz
Cc: <stable@vger.kernel.org>
Link: https://patch.msgid.link/20261125141057.2094719-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/usb/endpoint.c | 3 +++
1 file changed, 3 insertions(+)
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -449,6 +449,9 @@ static void push_back_to_ready_list(stru
struct snd_urb_ctx *ctx)
{
guard(spinlock_irqsave)(&ep->lock);
+ /* don't re-queue after stop_urbs() flushed the list */
+ if (!ep_state_running(ep))
+ return;
/* ctx may still be linked: a stale completion racing a stop/restart. */
if (list_empty(&ctx->ready_list))
list_add_tail(&ctx->ready_list, &ep->ready_playback_urbs);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 698/742] ALSA: timer: Protect the slave instance flags with the timer lock
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (681 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 697/742] ALSA: usb-audio: Dont queue playback URBs after stop Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 699/742] ALSA: pcm: oss: Refine slave hw_params after setting format Greg Kroah-Hartman
` (43 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Rongen Wang, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rongen Wang <security@nitrohex.com>
commit 8e324d767bdc5ab38b0e1e921e786ff9ea514188 upstream.
snd_timer_start_slave() and snd_timer_stop_slave() set and clear
SNDRV_TIMER_IFLG_RUNNING in timeri->flags while holding only
timeri_lock. For a slave that is linked to a master, the interrupt
path updates the same word under timer->lock:
snd_timer_process_callbacks() sets SNDRV_TIMER_IFLG_CALLBACK before it
calls the instance callback and clears it afterwards. Both sides do a
plain read-modify-write, so when they overlap one of the two updates is
lost.
If the set of SNDRV_TIMER_IFLG_CALLBACK is lost,
snd_timer_close_locked() does not wait for the callback that is still
running, the owner frees the instance, and the interrupt path clears
the flag in the freed object:
BUG: KASAN: slab-use-after-free in snd_timer_process_callbacks+0x269/0x2b0
Read of size 4 at addr ffff888007e5cc10 by task poc/90
snd_timer_process_callbacks+0x269/0x2b0
snd_timer_interrupt+0x7b8/0x1100
snd_utimer_ioctl+0x7c/0xb0
Freed by task 91:
kfree+0x127/0x3b0
__snd_timer_user_ioctl.isra.0+0xe93/0x28f0
If the clear is lost instead, the flag stays set: the instance gets no
further callbacks, and closing it spins in the drain loop of
snd_timer_close_locked() with register_mutex held, which blocks every
other open and close of an ALSA timer.
Take timer->lock around the whole flag update of a linked slave, as
snd_timer_start1() and snd_timer_stop1() do for master instances. The
callers hold timeri_lock, so timeri->timer is stable, and the lock
order is the one these functions already use. A slave that is not
linked to a master cannot be reached from any timer and needs no
additional protection.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Rongen Wang <security@nitrohex.com>
Link: https://patch.msgid.link/20261126-alsa-timer-slave-flags-v2-1-8e07a536fea3@nitrohex.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/core/timer.c | 50 +++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 43 insertions(+), 7 deletions(-)
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -657,9 +657,12 @@ static int snd_timer_start1(struct snd_t
return result;
}
-/* start/continue a slave timer */
-static int snd_timer_start_slave(struct snd_timer_instance *timeri,
- bool start)
+/*
+ * start/continue a slave timer;
+ * called with timer->lock held when the slave is linked to a master
+ */
+static int __snd_timer_start_slave(struct snd_timer_instance *timeri,
+ bool start)
{
if (timeri->flags & SNDRV_TIMER_IFLG_DEAD)
return -EINVAL;
@@ -667,7 +670,6 @@ static int snd_timer_start_slave(struct
return -EBUSY;
timeri->flags |= SNDRV_TIMER_IFLG_RUNNING;
if (timeri->master && timeri->timer) {
- guard(spinlock)(&timeri->timer->lock);
list_add_tail(&timeri->active_list,
&timeri->master->slave_active_head);
snd_timer_notify1(timeri, start ? SNDRV_TIMER_EVENT_START :
@@ -676,6 +678,27 @@ static int snd_timer_start_slave(struct
return 1; /* delayed start */
}
+/*
+ * start/continue a slave timer
+ *
+ * The flags of a slave linked to a master are updated also from the timer
+ * interrupt (SNDRV_TIMER_IFLG_CALLBACK in snd_timer_process_callbacks())
+ * under timer->lock. Change them only under the same lock, otherwise one
+ * of the two read-modify-write updates may get lost. The caller holds
+ * timeri_lock, hence timeri->timer can't change here; an unlinked slave is
+ * not reachable from any timer and needs no further protection.
+ */
+static int snd_timer_start_slave(struct snd_timer_instance *timeri,
+ bool start)
+{
+ struct snd_timer *timer = timeri->timer;
+
+ if (!timer)
+ return __snd_timer_start_slave(timeri, start);
+ guard(spinlock)(&timer->lock);
+ return __snd_timer_start_slave(timeri, start);
+}
+
/* stop/pause a master timer */
static int snd_timer_stop1(struct snd_timer_instance *timeri, bool stop)
{
@@ -718,15 +741,17 @@ static int snd_timer_stop1(struct snd_ti
return 0;
}
-/* stop/pause a slave timer */
-static int snd_timer_stop_slave(struct snd_timer_instance *timeri, bool stop)
+/*
+ * stop/pause a slave timer;
+ * called with timer->lock held when the slave is linked to a master
+ */
+static int __snd_timer_stop_slave(struct snd_timer_instance *timeri, bool stop)
{
bool running;
running = timeri->flags & SNDRV_TIMER_IFLG_RUNNING;
timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
if (timeri->timer) {
- guard(spinlock)(&timeri->timer->lock);
list_del_init(&timeri->ack_list);
list_del_init(&timeri->active_list);
if (running)
@@ -736,6 +761,17 @@ static int snd_timer_stop_slave(struct s
return running ? 0 : -EBUSY;
}
+/* stop/pause a slave timer; see snd_timer_start_slave() for the locking */
+static int snd_timer_stop_slave(struct snd_timer_instance *timeri, bool stop)
+{
+ struct snd_timer *timer = timeri->timer;
+
+ if (!timer)
+ return __snd_timer_stop_slave(timeri, stop);
+ guard(spinlock)(&timer->lock);
+ return __snd_timer_stop_slave(timeri, stop);
+}
+
/*
* start the timer instance
*/
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 699/742] ALSA: pcm: oss: Refine slave hw_params after setting format
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (682 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 698/742] ALSA: timer: Protect the slave instance flags with the timer lock Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 700/742] ALSA: hda/tas2781-spi: Set tas_hda->dev in probe Greg Kroah-Hartman
` (42 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Hengyu Liang, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hengyu Liang <hengyul@cs.unc.edu>
commit ddea524e437eae0d5581482a90565b4c1e6d4b24 upstream.
Commit 93d7d38fa61d ("ALSA: aloop: add DSD formats") added DSD_U8 to
the formats of snd-aloop. Before that, its narrowest format had 16 bits.
However, snd_pcm_oss_change_params_locked() sets the slave format with
_snd_pcm_hw_param_set(), which does not refine the parameters, while
the access, rate and channels before it are set with refining helpers.
snd_pcm_oss_period_size() then reads a buffer size maximum that is
still computed for the narrowest format, now DSD_U8, so the OSS period
doubles. With the default U8 client format, the doubled period no
longer fits in the format plugin, and snd_pcm_plugin_alloc() returns
-ENOMEM. As of now, an OSS program that asks snd-aloop for 8 channels
at 192 kHz gets ENOMEM from SNDCTL_DSP_SPEED and from every later
ioctl on the same file.
The issue can be reproduced with this program, where card 1 is
snd-aloop:
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
int main(void)
{
int fd = open("/dev/dsp1", O_WRONLY | O_NONBLOCK);
int ch = 8, rate = 192000, blk = 0;
ioctl(fd, SNDCTL_DSP_CHANNELS, &ch);
if (ioctl(fd, SNDCTL_DSP_SPEED, &rate) < 0)
perror("SNDCTL_DSP_SPEED");
if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &blk) < 0)
perror("SNDCTL_DSP_GETBLKSIZE");
printf("block size %d\n", blk);
return 0;
}
Before that commit, it prints "block size 65536". After that commit,
the result is:
SNDCTL_DSP_SPEED: Cannot allocate memory
SNDCTL_DSP_GETBLKSIZE: Cannot allocate memory
block size 0
This patch will set the format with snd_pcm_hw_param_set(), which
refines the parameters, as is done for the channels just before.
Fixes: 93d7d38fa61d ("ALSA: aloop: add DSD formats")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
Link: https://patch.msgid.link/20261125181005.3683575-1-hengyul@cs.unc.edu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/core/oss/pcm_oss.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -921,7 +921,8 @@ static int snd_pcm_oss_change_params_loc
goto failure;
}
format_found:
- err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0);
+ err = snd_pcm_hw_param_set(substream, sparams,
+ SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0);
if (err < 0)
goto failure;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 700/742] ALSA: hda/tas2781-spi: Set tas_hda->dev in probe
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (683 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 699/742] ALSA: pcm: oss: Refine slave hw_params after setting format Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 701/742] ALSA: hda/realtek: Fix headset mic on ASUS Zenbook S 13 UX5304MA Greg Kroah-Hartman
` (41 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Carmel Okun, Akhil Arul,
Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akhil Arul <akhilarul324@gmail.com>
commit d1458f8c2282975f2bd7467cd3c3cf4c0c58c1ca upstream.
tas2781_hda_remove() is shared by the I2C and SPI drivers and uses
tas_hda->dev for component_del() and for the runtime PM calls. The I2C
probe sets that field, the SPI probe does not, so for SPI it stays NULL
from the devm_kzalloc(). Unbinding the device through sysfs then warns
in component_del() and crashes on the NULL device in pm_runtime_get_sync():
WARNING: drivers/base/component.c:839 at component_del+0x149/0x170
Call Trace:
tas2781_hda_remove+0x16/0x60 [snd_hda_scodec_tas2781]
device_release_driver_internal+0x19e/0x200
unbind_store+0xa4/0xb0
Oops: general protection fault, kernel NULL pointer dereference 0x1d1
RIP: 0010:__pm_runtime_resume+0x1a/0x90
tas2781_hda_remove+0x23/0x60 [snd_hda_scodec_tas2781]
The same path runs from the driver remove callback and from the
component_add() failure path in tas2781_hda_spi_probe().
Before the common library was introduced, the SPI driver had its own
remove function that used tas_priv->dev. Set tas_hda->dev in
tas2781_hda_spi_probe(), as the I2C driver does.
Tested the probe/unbind path with KASAN and lockdep enabled: without this
change, unbinding the device gives the warning and oops above; with it,
unbind, bind and unbind again complete without any splat.
Fixes: 28a09d9e42c5 ("ALSA: hda/tas2781: Create an independent lib to save the shared parts for both SPI and I2C driver")
Reported-by: Carmel Okun <Carmel@aperio.ai>
Closes: https://lore.kernel.org/linux-sound/AS2PR02MB10038DB2CE8CAE659D35B9F1AC8792@AS2PR02MB10038.eurprd02.prod.outlook.com/
Cc: stable@vger.kernel.org
Signed-off-by: Akhil Arul <akhilarul324@gmail.com>
Link: https://patch.msgid.link/20261120125729.135171-1-akhilarul324@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/hda/codecs/side-codecs/tas2781_hda_spi.c | 1 +
1 file changed, 1 insertion(+)
--- a/sound/hda/codecs/side-codecs/tas2781_hda_spi.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda_spi.c
@@ -781,6 +781,7 @@ static int tas2781_hda_spi_probe(struct
if (!hda_priv)
return -ENOMEM;
+ tas_hda->dev = &spi->dev;
tas_hda->hda_priv = hda_priv;
spi->max_speed_hz = TAS2781_SPI_MAX_FREQ;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 701/742] ALSA: hda/realtek: Fix headset mic on ASUS Zenbook S 13 UX5304MA
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (684 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 700/742] ALSA: hda/tas2781-spi: Set tas_hda->dev in probe Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 702/742] ALSA: hda/realtek: Enable mute LEDs on HP Envy x360 15-ew0xxx Greg Kroah-Hartman
` (40 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Oleg Antonyan, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Antonyan <oleg.b.antonyan@gmail.com>
commit 896ec6bbe7dd2f29aff1a12eb318a6828be1edd8 upstream.
The ASUS Zenbook S 13 UX5304MA (1043:1c33) uses an ALC294 codec with
CS35L41 amplifiers over SPI. Its BIOS leaves pin 0x19 unconfigured, so
the headset mic on the combo jack does not work.
Use ALC294_FIXUP_ASUS_SPI_HEADSET_MIC like the UX3405MA and UX3402VA.
It configures the headset mic pin and chains to
ALC245_FIXUP_CS35L41_SPI_2 to keep the speakers working.
Tested on a UX5304MA: headset mic, internal mic and speakers work.
Fixes: 61cbc08fdb04 ("ALSA: hda/realtek: Add quirks for ASUS 2024 Zenbooks")
Cc: stable@vger.kernel.org
Signed-off-by: Oleg Antonyan <oleg.b.antonyan@gmail.com>
Link: https://patch.msgid.link/20261122-ux5304ma-headset-mic-v1-1-80589ae749a8@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/hda/codecs/realtek/alc269.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/sound/hda/codecs/realtek/alc269.c
+++ b/sound/hda/codecs/realtek/alc269.c
@@ -8026,7 +8026,7 @@ static const struct hda_quirk alc269_fix
SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
SND_PCI_QUIRK(0x1043, 0x1c03, "ASUS UM3406HA", ALC294_FIXUP_ASUS_I2C_HEADSET_MIC),
SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
- SND_PCI_QUIRK(0x1043, 0x1c33, "ASUS UX5304MA", ALC245_FIXUP_CS35L41_SPI_2),
+ SND_PCI_QUIRK(0x1043, 0x1c33, "ASUS UX5304MA", ALC294_FIXUP_ASUS_SPI_HEADSET_MIC),
SND_PCI_QUIRK(0x1043, 0x1c43, "ASUS UX8406MA", ALC245_FIXUP_CS35L41_SPI_2),
SND_PCI_QUIRK(0x1043, 0x1c62, "ASUS GU603", ALC289_FIXUP_ASUS_GA401),
SND_PCI_QUIRK(0x1043, 0x1c63, "ASUS GU605M", ALC285_FIXUP_ASUS_GU605_SPI_SPEAKER2_TO_DAC1),
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 702/742] ALSA: hda/realtek: Enable mute LEDs on HP Envy x360 15-ew0xxx
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (685 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 701/742] ALSA: hda/realtek: Fix headset mic on ASUS Zenbook S 13 UX5304MA Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 703/742] ALSA: hda/realtek: Add quirk for HP Spectre x360 2-in-1 Laptop 16-f2xxx Greg Kroah-Hartman
` (39 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Parmjot Singh, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parmjot Singh <parmjotsinghrobot@gmail.com>
commit 2c2f36d275fefdea7e1dfc251b4fee246298dedc upstream.
The HP ENVY x360 2-in-1 Laptop 15-ew0xxx (103c:8a2a) has speaker and
mic mute LEDs that are left unconfigured by the existing two-amplifier
quirk. On its ALC245 codec the speaker LED uses coefficient 0x0b bits
3:2 and the mic LED uses active-low GPIO 2.
Select the existing combined CS35L41 I2C and x360 mute LED fixup for
this board. On an equivalent Arch Linux 7.2.14 backport, both physical
LEDs responded, both native ALSA LED triggers followed the onboard
mixer switches, and both CS35L41 amps loaded their protection firmware.
Codex helped trace the ALSA LED controls, prepare the change and
write the commit message. The LEDs were verified on the laptop.
Fixes: aa8e3ef4fe53 ("ALSA: hda/realtek: Add quirks for various HP ENVY models")
Cc: stable@vger.kernel.org
Signed-off-by: Parmjot Singh <parmjotsinghrobot@gmail.com>
Link: https://patch.msgid.link/20261122061908.130239-1-parmjotsinghrobot@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/hda/codecs/realtek/alc269.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/sound/hda/codecs/realtek/alc269.c
+++ b/sound/hda/codecs/realtek/alc269.c
@@ -7689,7 +7689,8 @@ static const struct hda_quirk alc269_fix
SND_PCI_QUIRK(0x103c, 0x8a26, "HP Victus 16-d1xxx (MB 8A26)", ALC245_FIXUP_HP_MUTE_LED_COEFBIT),
SND_PCI_QUIRK(0x103c, 0x8a28, "HP Envy 13", ALC287_FIXUP_CS35L41_I2C_2),
SND_PCI_QUIRK(0x103c, 0x8a29, "HP Envy 15", ALC287_FIXUP_CS35L41_I2C_2),
- SND_PCI_QUIRK(0x103c, 0x8a2a, "HP Envy 15", ALC287_FIXUP_CS35L41_I2C_2),
+ SND_PCI_QUIRK(0x103c, 0x8a2a, "HP ENVY x360 2-in-1 Laptop 15-ew0xxx",
+ ALC287_FIXUP_CS35L41_I2C_2_HP_MUTE_LEDS),
SND_PCI_QUIRK(0x103c, 0x8a2b, "HP Envy 15", ALC287_FIXUP_CS35L41_I2C_2),
SND_PCI_QUIRK(0x103c, 0x8a2c, "HP Envy 16", ALC287_FIXUP_CS35L41_I2C_2),
SND_PCI_QUIRK(0x103c, 0x8a2d, "HP Envy 16", ALC287_FIXUP_CS35L41_I2C_2),
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 703/742] ALSA: hda/realtek: Add quirk for HP Spectre x360 2-in-1 Laptop 16-f2xxx
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (686 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 702/742] ALSA: hda/realtek: Enable mute LEDs on HP Envy x360 15-ew0xxx Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 704/742] ALSA: hda/realtek: Fix duplicate LEDs on HP Spectre x360 16-f2xxx Greg Kroah-Hartman
` (38 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Abhiraj Dutta, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhiraj Dutta <abhirajdutta7@gmail.com>
commit e30ec632e1f0e1fb92b3f0d727f5bc0c00ada6eb upstream.
The HP Spectre x360 16-f2xxx (SSID 103c:891e) has the same speaker
problem as the 14-eu0xxx and 16-aa0xxx: the BIOS marks the treble
speaker pin 0x14 as unconnected, so only the bass speakers on 0x17
play. The mute and mic-mute LEDs don't work either.
Use the existing EU0XXX pin fixup and chain ALC245_FIXUP_HP_X360_MUTE_LEDS.
The mute LED is on COEF 0x0b bits 2-3 and the mic-mute LED on GPIO2
(active low), which is what that fixup already handles. Unlike the
16-aa0xxx, the bass speaker amp works without toggling GPIO0, so the
EU0XXX variant is enough.
Under SOF the PCI SSID on this machine reads as 103c:0000, so the entry
is matched against the codec SSID.
Tested on a 16-f2xxx: all four speakers play and both LEDs follow the
mute state.
Cc: stable@vger.kernel.org
Signed-off-by: Abhiraj Dutta <abhirajdutta7@gmail.com>
Link: https://patch.msgid.link/20261122-hp-spectre-16-f2-quirk-v1-1-2011ef8986fb@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/hda/codecs/realtek/alc269.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/sound/hda/codecs/realtek/alc269.c
+++ b/sound/hda/codecs/realtek/alc269.c
@@ -4401,6 +4401,7 @@ enum {
ALC256_FIXUP_HEADPHONE_AMP_VOL,
ALC245_FIXUP_HP_SPECTRE_X360_EU0XXX,
ALC245_FIXUP_HP_SPECTRE_X360_16_AA0XXX,
+ ALC245_FIXUP_HP_SPECTRE_X360_16_F2XXX,
ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A,
ALC285_FIXUP_ASUS_GA403U,
ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC,
@@ -7025,6 +7026,12 @@ static const struct hda_fixup alc269_fix
.type = HDA_FIXUP_FUNC,
.v.func = alc245_fixup_hp_spectre_x360_16_aa0xxx,
},
+ [ALC245_FIXUP_HP_SPECTRE_X360_16_F2XXX] = {
+ .type = HDA_FIXUP_FUNC,
+ .v.func = alc245_fixup_hp_spectre_x360_eu0xxx,
+ .chained = true,
+ .chain_id = ALC245_FIXUP_HP_X360_MUTE_LEDS
+ },
[ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A] = {
.type = HDA_FIXUP_FUNC,
.v.func = alc245_fixup_hp_zbook_firefly_g12a,
@@ -7648,6 +7655,7 @@ static const struct hda_quirk alc269_fix
SND_PCI_QUIRK(0x103c, 0x8902, "HP OMEN 16", ALC285_FIXUP_HP_MUTE_LED),
SND_PCI_QUIRK(0x103c, 0x890e, "HP 255 G8 Notebook PC", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
SND_PCI_QUIRK(0x103c, 0x8919, "HP Pavilion Aero Laptop 13-be0xxx", ALC287_FIXUP_HP_GPIO_LED),
+ SND_PCI_QUIRK(0x103c, 0x891e, "HP Spectre x360 2-in-1 Laptop 16-f2xxx", ALC245_FIXUP_HP_SPECTRE_X360_16_F2XXX),
SND_PCI_QUIRK(0x103c, 0x896d, "HP ZBook Firefly 16 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
SND_PCI_QUIRK(0x103c, 0x896e, "HP EliteBook x360 830 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
SND_PCI_QUIRK(0x103c, 0x8971, "HP EliteBook 830 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 704/742] ALSA: hda/realtek: Fix duplicate LEDs on HP Spectre x360 16-f2xxx
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (687 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 703/742] ALSA: hda/realtek: Add quirk for HP Spectre x360 2-in-1 Laptop 16-f2xxx Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 705/742] KEYS: Fix asym key overflow in keyctl_pkey_verify() Greg Kroah-Hartman
` (37 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Abhiraj Dutta, Takashi Iwai
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abhiraj Dutta <abhirajdutta7@gmail.com>
commit 0ad50746fc640b68c24454500a513c4fd6293d75 upstream.
The EU0XXX fixup already sets up the mute and mic-mute LEDs, so chaining
ALC245_FIXUP_HP_X360_MUTE_LEDS after it registers both LEDs twice
(hda::mute_1 and hda::micmute_1 appear). Use the EU0XXX fixup directly.
The original commit message also got the SSID wrong: under SOF the PCI
SSID is 103c:891e, not 103c:0000.
Fixes: e30ec632e1f0 ("ALSA: hda/realtek: Add quirk for HP Spectre x360 2-in-1 Laptop 16-f2xxx")
Cc: stable@vger.kernel.org
Signed-off-by: Abhiraj Dutta <abhirajdutta7@gmail.com>
Link: https://patch.msgid.link/20261123-hp-spectre-16-f2-led-fix-v1-1-a2a333dceeb5@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/hda/codecs/realtek/alc269.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
--- a/sound/hda/codecs/realtek/alc269.c
+++ b/sound/hda/codecs/realtek/alc269.c
@@ -4401,7 +4401,6 @@ enum {
ALC256_FIXUP_HEADPHONE_AMP_VOL,
ALC245_FIXUP_HP_SPECTRE_X360_EU0XXX,
ALC245_FIXUP_HP_SPECTRE_X360_16_AA0XXX,
- ALC245_FIXUP_HP_SPECTRE_X360_16_F2XXX,
ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A,
ALC285_FIXUP_ASUS_GA403U,
ALC285_FIXUP_ASUS_GA403U_HEADSET_MIC,
@@ -7026,12 +7025,6 @@ static const struct hda_fixup alc269_fix
.type = HDA_FIXUP_FUNC,
.v.func = alc245_fixup_hp_spectre_x360_16_aa0xxx,
},
- [ALC245_FIXUP_HP_SPECTRE_X360_16_F2XXX] = {
- .type = HDA_FIXUP_FUNC,
- .v.func = alc245_fixup_hp_spectre_x360_eu0xxx,
- .chained = true,
- .chain_id = ALC245_FIXUP_HP_X360_MUTE_LEDS
- },
[ALC245_FIXUP_HP_ZBOOK_FIREFLY_G12A] = {
.type = HDA_FIXUP_FUNC,
.v.func = alc245_fixup_hp_zbook_firefly_g12a,
@@ -7655,7 +7648,7 @@ static const struct hda_quirk alc269_fix
SND_PCI_QUIRK(0x103c, 0x8902, "HP OMEN 16", ALC285_FIXUP_HP_MUTE_LED),
SND_PCI_QUIRK(0x103c, 0x890e, "HP 255 G8 Notebook PC", ALC236_FIXUP_HP_MUTE_LED_COEFBIT2),
SND_PCI_QUIRK(0x103c, 0x8919, "HP Pavilion Aero Laptop 13-be0xxx", ALC287_FIXUP_HP_GPIO_LED),
- SND_PCI_QUIRK(0x103c, 0x891e, "HP Spectre x360 2-in-1 Laptop 16-f2xxx", ALC245_FIXUP_HP_SPECTRE_X360_16_F2XXX),
+ SND_PCI_QUIRK(0x103c, 0x891e, "HP Spectre x360 2-in-1 Laptop 16-f2xxx", ALC245_FIXUP_HP_SPECTRE_X360_EU0XXX),
SND_PCI_QUIRK(0x103c, 0x896d, "HP ZBook Firefly 16 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
SND_PCI_QUIRK(0x103c, 0x896e, "HP EliteBook x360 830 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
SND_PCI_QUIRK(0x103c, 0x8971, "HP EliteBook 830 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 705/742] KEYS: Fix asym key overflow in keyctl_pkey_verify()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (688 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 704/742] ALSA: hda/realtek: Fix duplicate LEDs on HP Spectre x360 16-f2xxx Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 706/742] KEYS: Fix crash on big_key read Greg Kroah-Hartman
` (36 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Jarkko Sakkinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <jarkko@kernel.org>
commit 94cd215923495a0e1031b86dc7d246ef3c33cc73 upstream.
While verifying a variable-length signature shorter than info.max_sig_size,
memdup_user() reads past the end of the caller's _in2 and passes trailing
bytes to ->asym_verify_signature().
Set params->in2_len to uparams.in2_len in the KEYCTL_PKEY_VERIFY case.
Cc: stable@vger.kernel.org # v7.2+
Closes: https://sashiko.dev/#/bug/linux-dd9ad2ca-a846-4d0d-89d6-aa262ffd40f1
Fixes: cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/keys/keyctl_pkey.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/security/keys/keyctl_pkey.c
+++ b/security/keys/keyctl_pkey.c
@@ -175,7 +175,7 @@ static int keyctl_pkey_params_get_2(cons
goto out_up_key_sem;
}
- params->out_len = info.max_sig_size;
+ params->in2_len = uparams.in2_len;
break;
default:
ret = -EOPNOTSUPP;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 706/742] KEYS: Fix crash on big_key read
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (689 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 705/742] KEYS: Fix asym key overflow in keyctl_pkey_verify() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 707/742] KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s() Greg Kroah-Hartman
` (35 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Henry Martin, Jarkko Sakkinen,
Guicai Ma
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <bsdhenrymartin@gmail.com>
commit 1bcff832c48d83c5132662bec83bda37f566d8a2 upstream.
big_key_update() reserves quota with the raw payload length and then
destroys the old payload before instantiating the new one. For a payload
of N < 16 bytes that reserve releases 16-N bytes, so the reserve of 16
done by generic_key_instantiate() charges them again and can fail with
-EDQUOT once the payload is already destroyed. big_key_destroy() keeps
payload->length but clears path and data, so the key stays positive with
a stale length that KEYCTL_READ and KEYCTL_REVOKE then follow:
kernel BUG at fs/open.c:1145!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
RIP: 0010:dentry_open+0x7b/0x90
big_key_read+0x141/0x280
Instantiate the new payload first and destroy the old one only on success;
a positive key's reservation is already 16 bytes, so it cannot fail.
This issue was discovered by Tencent CodeBuddy Security.
Cc: stable@vger.kernel.org
Fixes: b6f61c314649 ("keys: Implement update for the big_key type")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Guicai Ma <maguicai@kylinos.cn>
Tested-by: Guicai Ma <maguicai@kylinos.cn>
Link: https://lore.kernel.org/r/20261124025759.39344-1-bsdhenrymartin@gmail.com
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/keys/big_key.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
--- a/security/keys/big_key.c
+++ b/security/keys/big_key.c
@@ -193,16 +193,24 @@ void big_key_destroy(struct key *key)
*/
int big_key_update(struct key *key, struct key_preparsed_payload *prep)
{
+ struct big_key_payload old = { };
+ bool positive = key_is_positive(key);
int ret;
- ret = key_payload_reserve(key, prep->datalen);
+ if (positive)
+ old = *to_big_key_payload(key->payload);
+
+ ret = generic_key_instantiate(key, prep);
if (ret < 0)
return ret;
- if (key_is_positive(key))
- big_key_destroy(key);
+ if (positive) {
+ if (old.length > BIG_KEY_FILE_THRESHOLD)
+ path_put(&old.path);
+ kfree_sensitive(old.data);
+ }
- return generic_key_instantiate(key, prep);
+ return 0;
}
/*
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 707/742] KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (690 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 706/742] KEYS: Fix crash on big_key read Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 708/742] KEYS: serialise key instantiation against keyctl_chown_key() Greg Kroah-Hartman
` (34 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Guicai Ma, Jarkko Sakkinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guicai Ma <maguicai@kylinos.cn>
commit 484dc27f031229b374446cf038fa9c7a84d0f725 upstream.
Commit cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
changed keyctl_pkey_params_get_2() to set params->out_len to the maximum
output size of the operation instead of uparams.out_len, so that the
kernel buffer allocated in keyctl_pkey_e_d_s() is large enough.
Because uparams.out_len is no longer kept, keyctl_pkey_e_d_s() copies
ret bytes to _out without checking whether the result fits in the
caller's buffer. If a smaller out_len was passed, copy_to_user() writes
past the end of _out instead of failing with -EOVERFLOW.
uparams.out_len cannot simply be required to be at least the maximum
output size in keyctl_pkey_params_get_2(), since KEYCTL_PKEY_DECRYPT
with enc=pkcs1 can return a plaintext shorter than max_dec_size into a
matching smaller buffer.
Pass uparams.out_len back to keyctl_pkey_e_d_s() and return -EOVERFLOW
before copy_to_user() if ret exceeds it.
Cc: stable@vger.kernel.org # v7.2+
Fixes: cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
Signed-off-by: Guicai Ma <maguicai@kylinos.cn>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/keys/keyctl_pkey.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
--- a/security/keys/keyctl_pkey.c
+++ b/security/keys/keyctl_pkey.c
@@ -113,7 +113,8 @@ static int keyctl_pkey_params_get(key_se
static int keyctl_pkey_params_get_2(const struct keyctl_pkey_params __user *_params,
const char __user *_info,
int op,
- struct kernel_pkey_params *params)
+ struct kernel_pkey_params *params,
+ u32 *user_out_len)
{
struct keyctl_pkey_params uparams;
struct kernel_pkey_query info;
@@ -183,6 +184,8 @@ static int keyctl_pkey_params_get_2(cons
}
params->in_len = uparams.in_len;
+ if (user_out_len)
+ *user_out_len = uparams.out_len;
switch (op) {
case KEYCTL_PKEY_VERIFY:
@@ -264,10 +267,12 @@ long keyctl_pkey_e_d_s(int op,
void __user *_out)
{
struct kernel_pkey_params params;
+ u32 user_out_len;
void *in, *out;
long ret;
- ret = keyctl_pkey_params_get_2(_params, _info, op, ¶ms);
+ ret = keyctl_pkey_params_get_2(_params, _info, op, ¶ms,
+ &user_out_len);
if (ret < 0)
goto error_params;
@@ -310,6 +315,10 @@ out_up_key_sem:
if (ret < 0)
goto error_out;
+ if (ret > user_out_len) {
+ ret = -EOVERFLOW;
+ goto error_out;
+ }
if (copy_to_user(_out, out, ret) != 0)
ret = -EFAULT;
@@ -349,7 +358,7 @@ long keyctl_pkey_verify(const struct key
long ret;
ret = keyctl_pkey_params_get_2(_params, _info, KEYCTL_PKEY_VERIFY,
- ¶ms);
+ ¶ms, NULL);
if (ret < 0)
goto out_free_params;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 708/742] KEYS: serialise key instantiation against keyctl_chown_key()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (691 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 707/742] KEYS: Fix userspace buffer overflow in keyctl_pkey_e_d_s() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 709/742] KEYS: trusted: TEE: Synchronize session lifetime Greg Kroah-Hartman
` (33 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sinan Turunc, Jarkko Sakkinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sinan Turunc <enscrpt@pm.me>
commit 899af9ffd2671351e5402d572934dd59b5e91ae5 upstream.
keyctl_chown_key() looks up the target key by calling lookup_user_key()
with the KEY_LOOKUP_PARTIAL flag. That flag lets a caller with
CAP_SYS_ADMIN change the UID of an uninstantiated key during construction.
When the UID changes, keyctl_chown_key() replaces key->user under key->sem
and drops the old reference with key_user_put().
__key_instantiate_and_link() and key_reject_and_link() hold
key_construction_mutex during instantiation, but neither function takes
key->sem. Both functions increment key->user->nikeys, and
__key_instantiate_and_link() also calls key->type->instantiate() without
holding key->sem. When a key is in quota and its size changes,
key_payload_reserve() reads key->user seven times without key->sem. Those
reads include spin_lock_irqsave(&key->user->lock, flags) at the start and
spin_unlock_irqrestore(&key->user->lock, flags) at the end.
If keyctl_chown_key() swaps key->user between those two calls,
key_payload_reserve() unlocks the new owner's spinlock and leaves the old
spinlock held. By source inspection, key_user_put() can also kfree() the
old struct key_user while instantiation still dereferences it. That struct
key_user use-after-free was found by reading the code and did not trigger
during our KASAN runs.
=====================================
WARNING: bad unlock balance detected!
7.4.0-rc2-g23c62304dde2 #3 Not tainted
-------------------------------------
request-key/163 is trying to release lock (&candidate->lock) at:
[<ffffffff82698fff>] key_payload_reserve+0x29f/0x370
but there are no more locks to release!
other info that might help us debug this:
locks held by request-key/163: 2, on CPU#3:
#0: ffffffff871c10a0 (key_construction_mutex){+.+.}-{4:4}, at: __key_instantiate_and_link+0x38/0x370
#1: ffff88800de4a8b8 (&candidate->lock){..-.}-{3:3}, at: key_payload_reserve+0x160/0x370
Call Trace:
lock_release+0x286/0x2e0
_raw_spin_unlock_irqrestore+0x1a/0x50
key_payload_reserve+0x29f/0x370
generic_key_instantiate+0x42/0x230
__key_instantiate_and_link+0xd7/0x370
key_instantiate_and_link+0x40d/0x4b0
keyctl_instantiate_key_common+0x2d2/0x450
keyctl_instantiate_key+0x167/0x180
__do_sys_keyctl+0x391/0x550
Take key->sem for write with down_write_nested(&key->sem, 2) inside
key_construction_mutex in __key_instantiate_and_link() and
key_reject_and_link().
Fixes: 5801649d8b83 ("[PATCH] keys: let keyctl_chown() change a key's owner")
Cc: stable@vger.kernel.org
Signed-off-by: Sinan Turunc <enscrpt@pm.me>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lore.kernel.org/r/20261121111246.3478-1-enscrpt@pm.me
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/keys/key.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -441,6 +441,7 @@ static int __key_instantiate_and_link(st
ret = -EBUSY;
mutex_lock(&key_construction_mutex);
+ down_write_nested(&key->sem, 2);
/* can't instantiate twice */
if (key->state == KEY_IS_UNINSTANTIATED) {
@@ -473,6 +474,7 @@ static int __key_instantiate_and_link(st
}
}
+ up_write(&key->sem);
mutex_unlock(&key_construction_mutex);
/* wake up anyone waiting for a key to be constructed */
@@ -609,6 +611,7 @@ int key_reject_and_link(struct key *key,
}
mutex_lock(&key_construction_mutex);
+ down_write_nested(&key->sem, 2);
/* can't instantiate twice */
if (key->state == KEY_IS_UNINSTANTIATED) {
@@ -632,6 +635,7 @@ int key_reject_and_link(struct key *key,
key_invalidate(authkey);
}
+ up_write(&key->sem);
mutex_unlock(&key_construction_mutex);
if (keyring && link_ret == 0)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 709/742] KEYS: trusted: TEE: Synchronize session lifetime
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (692 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 708/742] KEYS: serialise key instantiation against keyctl_chown_key() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 710/742] KEYS: trusted: Update static calls before init Greg Kroah-Hartman
` (32 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Sumit Garg, Jarkko Sakkinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <jarkko@kernel.org>
commit b8d381d5ed7980db0bcdccdb61bb65f10f08f907 upstream.
The parent TEE device can remove the client device while live instances
keep trusted.ko loaded.
Guard session context state with a mutex, publish pvt_data.dev before
registering key_type_trusted and sanitize pvt_data on probe failure and
removal.
When an active TEE has not been bound, reject seal, unseal and get_random
with -ENODEV.
Cc: stable@vger.kernel.org # v5.15+
Fixes: 0a95ebc91305 ("KEYS: trusted: Introduce TEE based Trusted Keys")
Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/keys/trusted-keys/trusted_tee.c | 86 +++++++++++++++++++++++--------
1 file changed, 65 insertions(+), 21 deletions(-)
--- a/security/keys/trusted-keys/trusted_tee.c
+++ b/security/keys/trusted-keys/trusted_tee.c
@@ -9,6 +9,7 @@
#include <linux/err.h>
#include <linux/key-type.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/tee_drv.h>
@@ -56,6 +57,8 @@ struct trusted_key_tee_private {
};
static struct trusted_key_tee_private pvt_data;
+/* Do not hold this mutex across key type registration or unregistration. */
+static DEFINE_MUTEX(trusted_key_tee_mutex);
/*
* Have the TEE seal(encrypt) the symmetric key
@@ -67,6 +70,12 @@ static int trusted_tee_seal(struct trust
struct tee_param param[4];
struct tee_shm *reg_shm = NULL;
+ mutex_lock(&trusted_key_tee_mutex);
+ if (!pvt_data.ctx) {
+ ret = -ENODEV;
+ goto out_unlock;
+ }
+
memset(&inv_arg, 0, sizeof(inv_arg));
memset(¶m, 0, sizeof(param));
@@ -74,7 +83,8 @@ static int trusted_tee_seal(struct trust
sizeof(p->key) + sizeof(p->blob));
if (IS_ERR(reg_shm)) {
dev_err(pvt_data.dev, "shm register failed\n");
- return PTR_ERR(reg_shm);
+ ret = PTR_ERR(reg_shm);
+ goto out_unlock;
}
inv_arg.func = TA_CMD_SEAL;
@@ -100,7 +110,8 @@ static int trusted_tee_seal(struct trust
}
tee_shm_free(reg_shm);
-
+out_unlock:
+ mutex_unlock(&trusted_key_tee_mutex);
return ret;
}
@@ -114,6 +125,12 @@ static int trusted_tee_unseal(struct tru
struct tee_param param[4];
struct tee_shm *reg_shm = NULL;
+ mutex_lock(&trusted_key_tee_mutex);
+ if (!pvt_data.ctx) {
+ ret = -ENODEV;
+ goto out_unlock;
+ }
+
memset(&inv_arg, 0, sizeof(inv_arg));
memset(¶m, 0, sizeof(param));
@@ -121,7 +138,8 @@ static int trusted_tee_unseal(struct tru
sizeof(p->key) + sizeof(p->blob));
if (IS_ERR(reg_shm)) {
dev_err(pvt_data.dev, "shm register failed\n");
- return PTR_ERR(reg_shm);
+ ret = PTR_ERR(reg_shm);
+ goto out_unlock;
}
inv_arg.func = TA_CMD_UNSEAL;
@@ -147,7 +165,8 @@ static int trusted_tee_unseal(struct tru
}
tee_shm_free(reg_shm);
-
+out_unlock:
+ mutex_unlock(&trusted_key_tee_mutex);
return ret;
}
@@ -161,13 +180,20 @@ static int trusted_tee_get_random(unsign
struct tee_param param[4];
struct tee_shm *reg_shm = NULL;
+ mutex_lock(&trusted_key_tee_mutex);
+ if (!pvt_data.ctx) {
+ ret = -ENODEV;
+ goto out_unlock;
+ }
+
memset(&inv_arg, 0, sizeof(inv_arg));
memset(¶m, 0, sizeof(param));
reg_shm = tee_shm_register_kernel_buf(pvt_data.ctx, key, key_len);
if (IS_ERR(reg_shm)) {
dev_err(pvt_data.dev, "key shm register failed\n");
- return PTR_ERR(reg_shm);
+ ret = PTR_ERR(reg_shm);
+ goto out_unlock;
}
inv_arg.func = TA_CMD_GET_RANDOM;
@@ -189,7 +215,8 @@ static int trusted_tee_get_random(unsign
}
tee_shm_free(reg_shm);
-
+out_unlock:
+ mutex_unlock(&trusted_key_tee_mutex);
return ret;
}
@@ -205,50 +232,67 @@ static int optee_ctx_match(struct tee_io
static int trusted_key_probe(struct tee_client_device *rng_device)
{
struct device *dev = &rng_device->dev;
+ struct tee_context *ctx;
int ret;
struct tee_ioctl_open_session_arg sess_arg;
+ mutex_lock(&trusted_key_tee_mutex);
+ if (pvt_data.ctx) {
+ ret = -EBUSY;
+ goto out_unlock;
+ }
+
memset(&sess_arg, 0, sizeof(sess_arg));
- pvt_data.ctx = tee_client_open_context(NULL, optee_ctx_match, NULL,
- NULL);
- if (IS_ERR(pvt_data.ctx))
- return -ENODEV;
+ ctx = tee_client_open_context(NULL, optee_ctx_match, NULL, NULL);
+ if (IS_ERR(ctx)) {
+ ret = -ENODEV;
+ goto out_unlock;
+ }
memcpy(sess_arg.uuid, rng_device->id.uuid.b, TEE_IOCTL_UUID_LEN);
sess_arg.clnt_login = TEE_IOCTL_LOGIN_REE_KERNEL;
sess_arg.num_params = 0;
- ret = tee_client_open_session(pvt_data.ctx, &sess_arg, NULL);
+ ret = tee_client_open_session(ctx, &sess_arg, NULL);
if ((ret < 0) || (sess_arg.ret != 0)) {
dev_err(dev, "tee_client_open_session failed, err: %x\n",
sess_arg.ret);
ret = -EINVAL;
goto out_ctx;
}
+ pvt_data.ctx = ctx;
pvt_data.session_id = sess_arg.session;
-
- ret = register_key_type(&key_type_trusted);
- if (ret < 0)
- goto out_sess;
-
pvt_data.dev = dev;
+ mutex_unlock(&trusted_key_tee_mutex);
- return 0;
+ ret = register_key_type(&key_type_trusted);
+ if (!ret)
+ return 0;
-out_sess:
- tee_client_close_session(pvt_data.ctx, pvt_data.session_id);
+ mutex_lock(&trusted_key_tee_mutex);
+ tee_client_close_session(ctx, pvt_data.session_id);
out_ctx:
- tee_client_close_context(pvt_data.ctx);
-
+ tee_client_close_context(ctx);
+ pvt_data.ctx = NULL;
+ pvt_data.dev = NULL;
+ pvt_data.session_id = 0;
+out_unlock:
+ mutex_unlock(&trusted_key_tee_mutex);
return ret;
}
static void trusted_key_remove(struct tee_client_device *dev)
{
unregister_key_type(&key_type_trusted);
+
+ mutex_lock(&trusted_key_tee_mutex);
tee_client_close_session(pvt_data.ctx, pvt_data.session_id);
tee_client_close_context(pvt_data.ctx);
+ pvt_data.ctx = NULL;
+ pvt_data.dev = NULL;
+ pvt_data.session_id = 0;
+ mutex_unlock(&trusted_key_tee_mutex);
}
static const struct tee_client_device_id trusted_key_id_table[] = {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 710/742] KEYS: trusted: Update static calls before init
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (693 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 709/742] KEYS: trusted: TEE: Synchronize session lifetime Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 711/742] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s() Greg Kroah-Hartman
` (31 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Jarkko Sakkinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <jarkko@kernel.org>
commit f8b462c497549e9991299156ed0e019eae8524f1 upstream.
Given that the static calls are updated only after ->init() returns, an
added trusted key can race with the callback initializations. This can
ultimately lead into null dereference as static_call() is used unchecked.
Address the bug by updating the static calls before invoking ->init(), and
roll back on failure.
Cc: stable@vger.kernel.org # v5.15+
Fixes: 31de287345f4 ("KEYS: trusted: Rollback init_trusted() consistently")
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/keys/trusted-keys/trusted_core.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
--- a/security/keys/trusted-keys/trusted_core.c
+++ b/security/keys/trusted-keys/trusted_core.c
@@ -373,14 +373,19 @@ static int __init init_trusted(void)
if (!get_random)
get_random = kernel_get_random;
+ static_call_update(trusted_key_seal, trusted_key_sources[i].ops->seal);
+ static_call_update(trusted_key_unseal, trusted_key_sources[i].ops->unseal);
+ static_call_update(trusted_key_get_random, get_random);
+ migratable = trusted_key_sources[i].ops->migratable;
+
ret = trusted_key_sources[i].ops->init();
if (!ret) {
- static_call_update(trusted_key_seal, trusted_key_sources[i].ops->seal);
- static_call_update(trusted_key_unseal, trusted_key_sources[i].ops->unseal);
- static_call_update(trusted_key_get_random, get_random);
-
trusted_key_exit = trusted_key_sources[i].ops->exit;
- migratable = trusted_key_sources[i].ops->migratable;
+ } else {
+ static_call_update(trusted_key_seal, NULL);
+ static_call_update(trusted_key_unseal, NULL);
+ static_call_update(trusted_key_get_random, NULL);
+ migratable = 0;
}
if (!ret || ret != -ENODEV)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 711/742] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (694 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 710/742] KEYS: trusted: Update static calls before init Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 712/742] ext4: fix OOB memmove in ext4_xattr_set_entry Greg Kroah-Hartman
` (30 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Guicai Ma, Jarkko Sakkinen
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guicai Ma <maguicai@kylinos.cn>
commit f779bd424bf27e17cee57c94f068328be29f3662 upstream.
keyctl_pkey_e_d_s() frees the temporary 'in' and 'out' buffers with
kfree(). For encrypt, decrypt and sign operations these buffers hold
plaintext or other sensitive data.
Free them with kfree_sensitive() instead.
Closes: https://sashiko.dev/#/bug/linux-4199b169-0b8d-4055-9a71-6b5b79e38eb3
Fixes: 00d60fd3b932 ("KEYS: Provide keyctls to drive the new key type ops for asymmetric keys [ver #2]")
Cc: stable@vger.kernel.org
Signed-off-by: Guicai Ma <maguicai@kylinos.cn>
Link: https://lore.kernel.org/r/20261124052849.940005-1-maguicai@kylinos.cn
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/keys/keyctl_pkey.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/security/keys/keyctl_pkey.c
+++ b/security/keys/keyctl_pkey.c
@@ -323,9 +323,9 @@ out_up_key_sem:
ret = -EFAULT;
error_out:
- kfree(out);
+ kfree_sensitive(out);
error_in:
- kfree(in);
+ kfree_sensitive(in);
error_params:
keyctl_pkey_params_free(¶ms);
return ret;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 712/742] ext4: fix OOB memmove in ext4_xattr_set_entry
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (695 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 711/742] KEYS: Use kfree_sensitive() in keyctl_pkey_e_d_s() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 713/742] xfrm: interface: drop non-IP packets before pskb_inet_may_pull() Greg Kroah-Hartman
` (29 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Zhao Gongyi, Theodore Tso
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Gongyi <zhaogongyi@bytedance.com>
commit e290c77088e6f829f7d1d88c915f2a2fb22241e6 upstream.
A corrupted filesystem can leave an inode marked as having inline data
while the system.data xattr is missing. ext4_destroy_inline_data_nolock()
then asks ext4_xattr_set_entry() to remove an entry even though
ext4_xattr_ibody_find() left the search state at the insertion position.
In the syzkaller reproducer, the old xattr value offset is smaller than
min_offs. ext4_xattr_set_entry() then computes val - first_val for
memmove(), the length wraps to a huge size_t, and memmove() can run out of
the xattr buffer. This results in an out-of-bounds memmove and a kernel
page fault.
A crafted corrupted ext4 image can trigger this while inline data is being
converted out of the inode. Treat the inconsistent inline/xattr state as
filesystem corruption before updating the xattr entry.
The issue was found by syzkaller and reproduced with the generated C
reproducer. The crash signature is:
BUG: unable to handle page fault for address: ffff8880074cf000
RIP: 0010:memmove+0x28/0x1b0
Call Trace:
ext4_xattr_set_entry+0xe2f/0x1e90 fs/ext4/xattr.c:1761
ext4_xattr_ibody_set+0x3d6/0x5d0 fs/ext4/xattr.c:2268
ext4_destroy_inline_data_nolock+0x288/0x5b0 fs/ext4/inline.c:467
ext4_convert_inline_data_nolock+0x178/0xe80 fs/ext4/inline.c:1222
ext4_convert_inline_data+0x52a/0x610 fs/ext4/inline.c:2083
ext4_fallocate+0x1a0/0x3ba0 fs/ext4/extents.c:4752
Reject the missing system.data xattr before destroying inline data, and
validate the old value offset before ext4_xattr_set_entry() reaches the
memmove().
The crash was reproduced on unpatched 7.3.0-rc3 and 6.6.122 kernels. With
this fix applied to both versions, the same syzkaller C reproducer ran for
120 seconds without triggering KASAN, Oops, a memmove fault, or panic.
Fixes: 67cf5b09a46f ("ext4: add the basic function for inline data support")
Cc: stable@vger.kernel.org # v3.8+
Signed-off-by: Zhao Gongyi <zhaogongyi@bytedance.com>
Link: https://patch.msgid.link/20260918101249.43643-1-zhaogongyi@bytedance.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/ext4/inline.c | 6 ++++++
fs/ext4/xattr.c | 12 ++++++++++++
2 files changed, 18 insertions(+)
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -461,6 +461,12 @@ static int ext4_destroy_inline_data_nolo
error = ext4_xattr_ibody_find(inode, &i, &is);
if (error)
goto out;
+ if (is.s.not_found) {
+ EXT4_ERROR_INODE(inode,
+ "corrupted inline data without system.data xattr");
+ error = -EFSCORRUPTED;
+ goto out;
+ }
BUFFER_TRACE(is.iloc.bh, "get_write_access");
error = ext4_journal_get_write_access(handle, inode->i_sb, is.iloc.bh,
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1712,6 +1712,18 @@ static int ext4_xattr_set_entry(struct e
}
}
+ if (!s->not_found && here->e_value_size && !here->e_value_inum) {
+ size_t offs = le16_to_cpu(here->e_value_offs);
+
+ if (offs < min_offs) {
+ EXT4_ERROR_INODE(inode,
+ "corrupted xattr: value offset %zu < min_offs %zu",
+ offs, min_offs);
+ ret = -EFSCORRUPTED;
+ goto out;
+ }
+ }
+
/*
* Getting access to old and new ea inodes is subject to failures.
* Finish that work before doing any modifications to the xattr data.
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 713/742] xfrm: interface: drop non-IP packets before pskb_inet_may_pull()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (696 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 712/742] ext4: fix OOB memmove in ext4_xattr_set_entry Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 714/742] userfaultfd: clear the inherited uffd bit in move_swap_pte() Greg Kroah-Hartman
` (28 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, syzbot+d29af9ef5c96a3f5e96c,
Shuai Liu, Steffen Klassert, Paolo Abeni
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuai Liu <847807867@qq.com>
commit e509726660dd06ce107437aecf7c106c9d3fc1e7 upstream.
AF_XDP sockets bound to an xfrm interface submit skbs with
skb->protocol unset (0) and skb->network_header still 0 from the
__alloc_skb() zero-initialization; skb_reserve() only moves data
NET_SKB_PAD bytes into the headroom.
Since commit 86de3a1118a16 ("xfrm: interface: validate the IP header
on xmit"), xfrmi_xmit() calls pskb_inet_may_pull() unconditionally.
For such a skb, pskb_inet_may_pull_reason() selects nhlen = 0 for the
unknown protocol and pskb_may_pull_reason() receives
len = skb_network_offset(skb) = network_header - data = -64, which as
unsigned int exceeds INT_MAX and trips the
DEBUG_NET_WARN_ON_ONCE(len > INT_MAX) in pskb_may_pull_reason():
WARNING: ./include/linux/skbuff.h:2856 at pskb_may_pull_reason [inline]
WARNING: ./include/linux/skbuff.h:3286 at pskb_network_may_pull_reason [inline]
WARNING: ./include/net/ip_tunnels.h:483 at pskb_inet_may_pull_reason [inline]
WARNING: ./include/net/ip_tunnels.h:488 at pskb_inet_may_pull [inline]
WARNING: ./include/net/ip_tunnels.h:488 at xfrmi_xmit+0x1844/0x1eb0
net/xfrm/xfrm_interface_core.c:534
RIP: 0010:pskb_may_pull_reason include/linux/skbuff.h:2856 [inline]
Call Trace:
__dev_direct_xmit+0x4b6/0x730 net/core/dev.c:5164
__xsk_generic_xmit net/xdp/xsk.c:1288 [inline]
xsk_generic_xmit+0x27d8/0x47a0 net/xdp/xsk.c:1344
xsk_poll+0x326/0x670 net/xdp/xsk.c:1472
The packet is dropped by the pull returning PKT_TOO_SMALL and hitting
the default case afterwards anyway, so the only visible effect is the
warning; reject unknown protocols before the pull to restore the
pre-86de3a1118a16 behavior of dropping them silently via the switch
default.
Reported-by: syzbot+d29af9ef5c96a3f5e96c@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=d29af9ef5c96a3f5e96c
Fixes: 86de3a1118a16 ("xfrm: interface: validate the IP header on xmit")
Cc: stable@vger.kernel.org
Signed-off-by: Shuai Liu <847807867@qq.com>
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Link: https://patch.msgid.link/tencent_46F20906773869221623F9FA26275C133107@qq.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/xfrm/xfrm_interface_core.c | 8 ++++++++
1 file changed, 8 insertions(+)
--- a/net/xfrm/xfrm_interface_core.c
+++ b/net/xfrm/xfrm_interface_core.c
@@ -531,6 +531,14 @@ static netdev_tx_t xfrmi_xmit(struct sk_
memset(&fl, 0, sizeof(fl));
+ switch (skb->protocol) {
+ case htons(ETH_P_IPV6):
+ case htons(ETH_P_IP):
+ break;
+ default:
+ goto tx_err;
+ }
+
if (!pskb_inet_may_pull(skb))
goto tx_err;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 714/742] userfaultfd: clear the inherited uffd bit in move_swap_pte()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (697 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 713/742] xfrm: interface: drop non-IP packets before pskb_inet_may_pull() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 715/742] accel/rocket: put IOMMU domain on BO creation failure Greg Kroah-Hartman
` (27 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Donggeun Yoo, Andrew Morton,
David Hildenbrand (Arm), Mike Rapoport (Microsoft), Peter Xu,
Suren Baghdasaryan, Andrea Arcangeli, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Michal Hocko, Shuah Khan,
Kiryl Shutsemau
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
commit 50abb4245e1ecdd679aef504543bdbc055dc9247 upstream.
UFFDIO_MOVE on a swapped-out page installs the source PTE at the
destination unchanged, so a uffd bit set on a write-protected or
RWP-protected source lands in a destination VMA that was never
registered for either. Nothing clears it there, and userspace sees:
- /proc/<pid>/pagemap reports the page as uffd-tracked (bit 57), both
while it is swapped out and after it is faulted back in.
- MADV_COLLAPSE fails with EINVAL on a range containing it, because the
collapse scan bails on a swap entry with the uffd bit set.
- With CONFIG_PAGE_TABLE_CHECK, faulting the page in warns.
do_swap_page() carries the bit into the present PTE and, since the
destination isn't WP-registered, also makes it writable:
WARNING: mm/page_table_check.c:202 at __page_table_check_ptes_set+0x185/0x1e0
Call Trace:
set_ptes+0x67/0xc0
do_swap_page+0x990/0xfe0
__handle_mm_fault+0x7d0/0xeb0
handle_mm_fault+0x9c/0x250
do_user_addr_fault+0x207/0x650
exc_page_fault+0x65/0x150
asm_exc_page_fault+0x26/0x30
Reaching it takes UFFDIO_MOVE out of a WP- or RWP-protected area into
one that isn't, on a page that is swapped out at the time. It hasn't
been seen in practice.
A resident page doesn't carry the bit, because move_present_ptes() builds
the destination PTE from dst_vma->vm_page_prot. Clear it on the moved
swap entry as well, then re-arm it if the destination is RWP-registered.
The WP case has been there since v6.8, where UFFDIO_MOVE was added.
Link: https://lore.kernel.org/20261003103030.63380-1-donggeunyoo.kernel@gmail.com
Link: https://lore.kernel.org/20261003103030.63380-2-donggeunyoo.kernel@gmail.com
Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Assisted-by: LLM
Cc: Peter Xu <peterx@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/userfaultfd.c | 1 +
1 file changed, 1 insertion(+)
---
mm/userfaultfd.c | 1 +
1 file changed, 1 insertion(+)
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -1425,6 +1425,7 @@ static int move_swap_pte(struct mm_struc
orig_src_pte = ptep_get_and_clear(mm, src_addr, src_pte);
if (pgtable_supports_soft_dirty())
orig_src_pte = pte_swp_mksoft_dirty(orig_src_pte);
+ orig_src_pte = pte_swp_clear_uffd(orig_src_pte);
/* Re-arm RWP on the moved swap entry if dst_vma is RWP-registered. */
if (userfaultfd_rwp(dst_vma))
orig_src_pte = pte_swp_mkuffd(orig_src_pte);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 715/742] accel/rocket: put IOMMU domain on BO creation failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (698 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 714/742] userfaultfd: clear the inherited uffd bit in move_swap_pte() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 716/742] accel/rocket: Fix drm_mm UAF on close vs in-flight job Greg Kroah-Hartman
` (26 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Guangshuo Li, Tomeu Vizoso,
Gyeyoung Baek, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <lgs201920130244@gmail.com>
commit 90035d3f26e011e16fcf9c5071571f0d956b5219 upstream.
rocket_ioctl_create_bo() takes an IOMMU domain reference for each newly
created BO.
The normal GEM object release path drops that reference from
rocket_gem_bo_free(). However, the BO creation error paths free the
object with drm_gem_shmem_object_free(), which bypasses the driver's GEM
.free callback. Those paths therefore release the shmem object without
dropping the IOMMU domain reference.
Drop the domain reference explicitly on the BO creation error path before
freeing the shmem object.
Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Reviewed-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Signed-off-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Link: https://patch.msgid.link/20260708114354.753817-1-lgs201920130244@gmail.com
Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/accel/rocket/rocket_gem.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/accel/rocket/rocket_gem.c b/drivers/accel/rocket/rocket_gem.c
index d981c6a93ff12..79135351b8e38 100644
--- a/drivers/accel/rocket/rocket_gem.c
+++ b/drivers/accel/rocket/rocket_gem.c
@@ -127,6 +127,8 @@ int rocket_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *
mutex_unlock(&rocket_priv->mm_lock);
err:
+ rocket_iommu_domain_put(rkt_obj->domain);
+ rkt_obj->domain = NULL;
drm_gem_shmem_object_free(gem_obj);
return ret;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 716/742] accel/rocket: Fix drm_mm UAF on close vs in-flight job
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (699 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 715/742] accel/rocket: put IOMMU domain on BO creation failure Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 717/742] x86/rust: use `-Zindirect-branch-cs-prefix` for RETPOLINE builds Greg Kroah-Hartman
` (25 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Gyeyoung Baek, Tomeu Vizoso,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gyeyoung Baek <gye976@gmail.com>
commit c3fe8795ecd844d0bf76102217bec01cce01b715 upstream.
The drm_mm and its mutex live in rocket_file_priv, which
rocket_postclose() frees on fd close. But a BO held by an
in-flight job is only freed after close, from the drm_sched
free_job worker, and its destructor then accesses the already
freed drm_mm and mutex.
BUG: KASAN: slab-use-after-free in __mutex_trylock_common+0x90/0x1e8
Workqueue: <NPU>.npu drm_sched_free_job_work [gpu_sched]
Call trace:
__mutex_lock
rocket_gem_bo_free
rocket_job_cleanup
rocket_job_free
drm_sched_free_job_work [gpu_sched]
Move drm_mm and the mutex out of rocket_file_priv into the
kref-managed rocket_iommu_domain (renamed to rocket_vm). Their
lifetime now matches the vm's: as long as a BO or job references
the vm, the address-space state stays alive.
Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
Cc: stable@vger.kernel.org
Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
Reviewed-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
[tomeu: Rebased on the BO creation error path fix]
[tomeu: Fixes points at the commit that added the drm_mm to rocket_file_priv]
Signed-off-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Link: https://patch.msgid.link/20261101073700.1261966-1-gye976@gmail.com
Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/accel/rocket/rocket_drv.c | 74 +++++++++++++++----------------
drivers/accel/rocket/rocket_drv.h | 13 +++---
drivers/accel/rocket/rocket_gem.c | 35 ++++++++-------
drivers/accel/rocket/rocket_gem.h | 4 +-
drivers/accel/rocket/rocket_job.c | 6 +--
drivers/accel/rocket/rocket_job.h | 2 +-
6 files changed, 66 insertions(+), 68 deletions(-)
diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c
index 538e0950035ca..a27d587ac5179 100644
--- a/drivers/accel/rocket/rocket_drv.c
+++ b/drivers/accel/rocket/rocket_drv.c
@@ -26,46 +26,54 @@ static struct platform_device *drm_dev;
static struct rocket_device *rdev;
static void
-rocket_iommu_domain_destroy(struct kref *kref)
+rocket_vm_destroy(struct kref *kref)
{
- struct rocket_iommu_domain *domain = container_of(kref, struct rocket_iommu_domain, kref);
+ struct rocket_vm *vm = container_of(kref, struct rocket_vm, kref);
- iommu_domain_free(domain->domain);
- domain->domain = NULL;
- kfree(domain);
+ drm_mm_takedown(&vm->mm);
+ mutex_destroy(&vm->lock);
+ iommu_domain_free(vm->domain);
+ vm->domain = NULL;
+ kfree(vm);
}
-static struct rocket_iommu_domain*
-rocket_iommu_domain_create(struct device *dev)
+static struct rocket_vm *
+rocket_vm_create(struct device *dev)
{
- struct rocket_iommu_domain *domain = kmalloc_obj(*domain);
+ struct rocket_vm *vm = kmalloc_obj(*vm);
+ u64 start, end;
void *err;
- if (!domain)
+ if (!vm)
return ERR_PTR(-ENOMEM);
- domain->domain = iommu_paging_domain_alloc(dev);
- if (IS_ERR(domain->domain)) {
- err = ERR_CAST(domain->domain);
- kfree(domain);
+ vm->domain = iommu_paging_domain_alloc(dev);
+ if (IS_ERR(vm->domain)) {
+ err = ERR_CAST(vm->domain);
+ kfree(vm);
return err;
}
- kref_init(&domain->kref);
- return domain;
+ start = vm->domain->geometry.aperture_start;
+ end = vm->domain->geometry.aperture_end;
+ drm_mm_init(&vm->mm, start, end - start + 1);
+ mutex_init(&vm->lock);
+ kref_init(&vm->kref);
+
+ return vm;
}
-struct rocket_iommu_domain *
-rocket_iommu_domain_get(struct rocket_file_priv *rocket_priv)
+struct rocket_vm *
+rocket_vm_get(struct rocket_file_priv *rocket_priv)
{
- kref_get(&rocket_priv->domain->kref);
- return rocket_priv->domain;
+ kref_get(&rocket_priv->vm->kref);
+ return rocket_priv->vm;
}
void
-rocket_iommu_domain_put(struct rocket_iommu_domain *domain)
+rocket_vm_put(struct rocket_vm *vm)
{
- kref_put(&domain->kref, rocket_iommu_domain_destroy);
+ kref_put(&vm->kref, rocket_vm_destroy);
}
static int
@@ -73,7 +81,6 @@ rocket_open(struct drm_device *dev, struct drm_file *file)
{
struct rocket_device *rdev = to_rocket_device(dev);
struct rocket_file_priv *rocket_priv;
- u64 start, end;
int ret;
if (!try_module_get(THIS_MODULE))
@@ -86,29 +93,22 @@ rocket_open(struct drm_device *dev, struct drm_file *file)
}
rocket_priv->rdev = rdev;
- rocket_priv->domain = rocket_iommu_domain_create(rdev->cores[0].dev);
- if (IS_ERR(rocket_priv->domain)) {
- ret = PTR_ERR(rocket_priv->domain);
+ rocket_priv->vm = rocket_vm_create(rdev->cores[0].dev);
+ if (IS_ERR(rocket_priv->vm)) {
+ ret = PTR_ERR(rocket_priv->vm);
goto err_free;
}
file->driver_priv = rocket_priv;
- start = rocket_priv->domain->domain->geometry.aperture_start;
- end = rocket_priv->domain->domain->geometry.aperture_end;
- drm_mm_init(&rocket_priv->mm, start, end - start + 1);
- mutex_init(&rocket_priv->mm_lock);
-
ret = rocket_job_open(rocket_priv);
if (ret)
- goto err_mm_takedown;
+ goto err_vm_put;
return 0;
-err_mm_takedown:
- mutex_destroy(&rocket_priv->mm_lock);
- drm_mm_takedown(&rocket_priv->mm);
- rocket_iommu_domain_put(rocket_priv->domain);
+err_vm_put:
+ rocket_vm_put(rocket_priv->vm);
err_free:
kfree(rocket_priv);
err_put_mod:
@@ -122,9 +122,7 @@ rocket_postclose(struct drm_device *dev, struct drm_file *file)
struct rocket_file_priv *rocket_priv = file->driver_priv;
rocket_job_close(rocket_priv);
- mutex_destroy(&rocket_priv->mm_lock);
- drm_mm_takedown(&rocket_priv->mm);
- rocket_iommu_domain_put(rocket_priv->domain);
+ rocket_vm_put(rocket_priv->vm);
kfree(rocket_priv);
module_put(THIS_MODULE);
}
diff --git a/drivers/accel/rocket/rocket_drv.h b/drivers/accel/rocket/rocket_drv.h
index 2c673bb99ccc1..2754f46f17498 100644
--- a/drivers/accel/rocket/rocket_drv.h
+++ b/drivers/accel/rocket/rocket_drv.h
@@ -11,22 +11,23 @@
extern const struct dev_pm_ops rocket_pm_ops;
-struct rocket_iommu_domain {
+struct rocket_vm {
struct iommu_domain *domain;
+ struct drm_mm mm;
+ /* protects @mm */
+ struct mutex lock;
struct kref kref;
};
struct rocket_file_priv {
struct rocket_device *rdev;
- struct rocket_iommu_domain *domain;
- struct drm_mm mm;
- struct mutex mm_lock;
+ struct rocket_vm *vm;
struct drm_sched_entity sched_entity;
};
-struct rocket_iommu_domain *rocket_iommu_domain_get(struct rocket_file_priv *rocket_priv);
-void rocket_iommu_domain_put(struct rocket_iommu_domain *domain);
+struct rocket_vm *rocket_vm_get(struct rocket_file_priv *rocket_priv);
+void rocket_vm_put(struct rocket_vm *vm);
#endif
diff --git a/drivers/accel/rocket/rocket_gem.c b/drivers/accel/rocket/rocket_gem.c
index 79135351b8e38..8f802df3e0f14 100644
--- a/drivers/accel/rocket/rocket_gem.c
+++ b/drivers/accel/rocket/rocket_gem.c
@@ -14,20 +14,20 @@
static void rocket_gem_bo_free(struct drm_gem_object *obj)
{
struct rocket_gem_object *bo = to_rocket_bo(obj);
- struct rocket_file_priv *rocket_priv = bo->driver_priv;
+ struct rocket_vm *vm = bo->vm;
size_t unmapped;
drm_WARN_ON(obj->dev, refcount_read(&bo->base.pages_use_count) > 1);
- unmapped = iommu_unmap(bo->domain->domain, bo->mm.start, bo->size);
+ unmapped = iommu_unmap(vm->domain, bo->mm.start, bo->size);
drm_WARN_ON(obj->dev, unmapped != bo->size);
- mutex_lock(&rocket_priv->mm_lock);
+ mutex_lock(&vm->lock);
drm_mm_remove_node(&bo->mm);
- mutex_unlock(&rocket_priv->mm_lock);
+ mutex_unlock(&vm->lock);
- rocket_iommu_domain_put(bo->domain);
- bo->domain = NULL;
+ rocket_vm_put(vm);
+ bo->vm = NULL;
drm_gem_shmem_free(&bo->base);
}
@@ -64,6 +64,7 @@ int rocket_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *
struct drm_gem_shmem_object *shmem_obj;
struct rocket_gem_object *rkt_obj;
struct drm_gem_object *gem_obj;
+ struct rocket_vm *vm;
struct sg_table *sgt;
int ret;
@@ -74,8 +75,8 @@ int rocket_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *
gem_obj = &shmem_obj->base;
rkt_obj = to_rocket_bo(gem_obj);
- rkt_obj->driver_priv = rocket_priv;
- rkt_obj->domain = rocket_iommu_domain_get(rocket_priv);
+ vm = rocket_vm_get(rocket_priv);
+ rkt_obj->vm = vm;
rkt_obj->size = args->size;
rkt_obj->offset = 0;
@@ -85,15 +86,15 @@ int rocket_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *
goto err;
}
- mutex_lock(&rocket_priv->mm_lock);
- ret = drm_mm_insert_node_generic(&rocket_priv->mm, &rkt_obj->mm,
+ mutex_lock(&vm->lock);
+ ret = drm_mm_insert_node_generic(&vm->mm, &rkt_obj->mm,
rkt_obj->size, PAGE_SIZE,
0, 0);
- mutex_unlock(&rocket_priv->mm_lock);
+ mutex_unlock(&vm->lock);
if (ret)
goto err;
- ret = iommu_map_sgtable(rocket_priv->domain->domain,
+ ret = iommu_map_sgtable(vm->domain,
rkt_obj->mm.start,
shmem_obj->sgt,
IOMMU_READ | IOMMU_WRITE);
@@ -118,17 +119,17 @@ int rocket_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *
return 0;
err_unmap:
- iommu_unmap(rocket_priv->domain->domain,
+ iommu_unmap(vm->domain,
rkt_obj->mm.start, rkt_obj->size);
err_remove_node:
- mutex_lock(&rocket_priv->mm_lock);
+ mutex_lock(&vm->lock);
drm_mm_remove_node(&rkt_obj->mm);
- mutex_unlock(&rocket_priv->mm_lock);
+ mutex_unlock(&vm->lock);
err:
- rocket_iommu_domain_put(rkt_obj->domain);
- rkt_obj->domain = NULL;
+ rocket_vm_put(rkt_obj->vm);
+ rkt_obj->vm = NULL;
drm_gem_shmem_object_free(gem_obj);
return ret;
diff --git a/drivers/accel/rocket/rocket_gem.h b/drivers/accel/rocket/rocket_gem.h
index 2404303345094..e1fbbd8cf7190 100644
--- a/drivers/accel/rocket/rocket_gem.h
+++ b/drivers/accel/rocket/rocket_gem.h
@@ -9,9 +9,7 @@
struct rocket_gem_object {
struct drm_gem_shmem_object base;
- struct rocket_file_priv *driver_priv;
-
- struct rocket_iommu_domain *domain;
+ struct rocket_vm *vm;
struct drm_mm_node mm;
size_t size;
u32 offset;
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index 088e41e404338..278128b817a13 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -240,7 +240,7 @@ static void rocket_job_cleanup(struct kref *ref)
refcount);
unsigned int i;
- rocket_iommu_domain_put(job->domain);
+ rocket_vm_put(job->vm);
dma_fence_put(job->done_fence);
dma_fence_put(job->inference_done_fence);
@@ -321,7 +321,7 @@ static struct dma_fence *rocket_job_run(struct drm_sched_job *sched_job)
if (ret < 0)
goto err_put_fences;
- ret = iommu_attach_group(job->domain->domain, core->iommu_group);
+ ret = iommu_attach_group(job->vm->domain, core->iommu_group);
if (ret < 0)
goto err_put_pm;
@@ -562,7 +562,7 @@ static int rocket_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
kref_init(&rjob->refcount);
rjob->rdev = rdev;
- rjob->domain = rocket_iommu_domain_get(file_priv);
+ rjob->vm = rocket_vm_get(file_priv);
ret = drm_sched_job_init(&rjob->base,
&file_priv->sched_entity,
diff --git a/drivers/accel/rocket/rocket_job.h b/drivers/accel/rocket/rocket_job.h
index 4ae00feec3b93..9373c3d0273b4 100644
--- a/drivers/accel/rocket/rocket_job.h
+++ b/drivers/accel/rocket/rocket_job.h
@@ -36,7 +36,7 @@ struct rocket_job {
/* Fence to be signaled by IRQ handler when the job is complete. */
struct dma_fence *done_fence;
- struct rocket_iommu_domain *domain;
+ struct rocket_vm *vm;
struct kref refcount;
};
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 717/742] x86/rust: use `-Zindirect-branch-cs-prefix` for RETPOLINE builds
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (700 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 716/742] accel/rocket: Fix drm_mm UAF on close vs in-flight job Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 718/742] nvme-tcp: use an aligned buffer for the TLS record type Greg Kroah-Hartman
` (24 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kent Overstreet, Borislav Petkov,
Miguel Ojeda, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miguel Ojeda <ojeda@kernel.org>
commit 1eaa31fa41125db78a50abef7f0a35aa22af40d0 upstream.
The C compiler is asked to add a `cs` prefix to the `call` and `jmp`
instructions that go through the indirect thunks for the `r8`-`r15`
registers, which makes them 6 bytes long instead of 5. That gives
`patch_retpoline()` enough room to inline them, e.g. as `lfence; call
*%r11` for `spectre_v2=retpoline,lfence`.
However, Rust code does not get the prefix, e.g. for a
`CONFIG_MITIGATION_RETPOLINE=y` build:
$ objdump -dr rust/kernel.o
...
e2b: e8 00 00 00 00 call e30 <...>
e2c: R_X86_64_PLT32 __x86_indirect_thunk_r11-0x4
Moreover, since commit 4a1e02b15ac1 ("x86,retpoline: Optimize
patch_retpoline()"), `emit_indirect()` assumes there is enough room
for the inlined sequence -- e.g. with `spectre_v2=retpoline,lfence`,
the kernel warns and dies while patching a site inside `core`:
WARNING: arch/x86/kernel/alternative.c:736 at apply_retpolines+0x2ee/0x400, CPU#0: swapper/0/0
...
Call Trace:
<TASK>
? _RNvMs6_NtNtCshS2CUL9MEDn_4core3fmt8buildersNtB5_9DebugList21finish_non_exhaustive+0x5b/0xd0
...
alternative_instructions+0x1d/0x60
arch_cpu_finalize_init+0x5a/0xb0
start_kernel+0x1f4/0x280
Similarly, paranoid FineIBT rewrites each kCFI call site into a fixed
20-byte sequence, i.e. the 14 bytes of the kCFI check plus a 6-byte
call. For a 5-byte call, that overwrites the first byte of the next
instruction, corrupting Rust code:
SMP alternatives: Using paranoid FineIBT CFI
...
Oops: double fault: 0000 [#1]
...
RIP: 0010:_RNvNtCsdVypMZsLRAh_4core3fmt5write+0x1e9/0x210
Code: ... b8 68 81 16 9f 41 3b 43 f5 2e 4d 8d 5b f0 75 fd 41 ff e3 <cc> c0 eb 02 b0 01 ...
...
Kernel panic - not syncing: Fatal exception in interrupt
Non-paranoid FineIBT is not affected, since it only rewrites the kCFI
check and leaves the call itself to `apply_retpolines()`.
We added support for `-Zindirect-branch-cs-prefix` [1][2] in Rust 1.91.0
[3]. Thus pass it for `RETPOLINE` builds when possible, which makes all
sites indeed get the prefix:
e3c: 2e e8 00 00 00 00 cs call e42 <...>
e3e: R_X86_64_PLT32 __x86_indirect_thunk_r11-0x4
The kernel above boots fine with `spectre_v2=retpoline,lfence`, inlining
the Rust sites as well.
For older Rust compilers, set the LLVM module flag instead, which
has the same code-generation effect. This means that every Rust version
that the kernel supports gets the prefix, that the kernel boots fine with
`spectre_v2=retpoline,lfence`, and that paranoid FineIBT no longer
corrupts.
In addition, add it to our target modifier workaround for `rustdoc`.
Cc: stable@vger.kernel.org # 6.18.y+
Link: https://github.com/rust-lang/rust/issues/116852 [1]
Link: https://github.com/rust-lang/compiler-team/issues/899 [2]
Link: https://github.com/rust-lang/rust/pull/140740 [3]
Reported-by: Kent Overstreet <kent.overstreet@linux.dev>
Acked-by: Borislav Petkov <bp@alien8.de>
Link: https://patch.msgid.link/20261018175457.87803-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/Makefile | 1 +
rust/Makefile | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 8af6b80cffdd8..01c848855f992 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -21,6 +21,7 @@ RETPOLINE_CFLAGS := -mretpoline-external-thunk
RETPOLINE_VDSO_CFLAGS := -mretpoline
endif
RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix)
+RETPOLINE_RUSTFLAGS += $(if $(call rustc-min-version,109100),-Zindirect-branch-cs-prefix,-Zllvm_module_flag=indirect_branch_cs_prefix:u32:1:override)
ifdef CONFIG_MITIGATION_RETHUNK
RETHUNK_CFLAGS := -mfunction-return=thunk-extern
diff --git a/rust/Makefile b/rust/Makefile
index 3879411d7bb97..0d055a3352c54 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -167,7 +167,7 @@ pin_init-flags := \
rustdoc_modifiers_workaround := $(if $(call rustc-min-version,108800),-Cunsafe-allow-abi-mismatch=fixed-x18)
# Similarly, for doctests (https://github.com/rust-lang/rust/issues/146465).
-doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer)
+doctests_modifiers_workaround := $(rustdoc_modifiers_workaround)$(if $(call rustc-min-version,109100),$(comma)sanitizer$(comma)indirect-branch-cs-prefix)
quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
cmd_rustdoc = \
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 718/742] nvme-tcp: use an aligned buffer for the TLS record type
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (701 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 717/742] x86/rust: use `-Zindirect-branch-cs-prefix` for RETPOLINE builds Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 719/742] nvme-tcp: move the TLS record read loop into a helper Greg Kroah-Hartman
` (23 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Martin Belanger, Hannes Reinecke,
Keith Busch, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Belanger <martin.belanger@dell.com>
commit 1193566c35ead643e954ff8356bb54b1cd78378a upstream.
The buffers that receive the TLS record type are char arrays.
put_cmsg() and tls_get_record_type() access them as struct cmsghdr,
which needs a stricter alignment than a char array has.
Use a union with struct cmsghdr, sized with CMSG_SPACE(), as
svc_tcp_recv_cmsg() and xs_tls_read_record() in sunrpc do.
Fixes: 2837966ab2a8 ("nvme-tcp: control message handling for recvmsg()")
Cc: stable@vger.kernel.org
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
[ Martin: resolved a context conflict next to nvme_tcp_cpu_queues ]
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/nvme/host/tcp.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 2f30c16ec802e..0d80c12d9fe8f 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -76,6 +76,12 @@ MODULE_PARM_DESC(tls_handshake_timeout,
/* TLS records read while waiting for the ICResp, the ICResp included */
#define NVME_TCP_ICRESP_MAX_RECORDS 8
+/* control message buffer for the TLS record type */
+union nvme_tcp_tls_cmsg {
+ struct cmsghdr cmsg;
+ u8 buf[CMSG_SPACE(sizeof(u8))];
+};
+
static atomic_t nvme_tcp_cpu_queues[NR_CPUS];
enum nvme_tcp_send_state {
@@ -1646,11 +1652,11 @@ static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
.iov_base = buf,
.iov_len = sizeof(buf),
};
- char cbuf[CMSG_LEN(sizeof(char))] = {};
+ union nvme_tcp_tls_cmsg u = {};
/* kTLS fails a control record read without a cmsg buffer */
struct msghdr drain = {
- .msg_control = cbuf,
- .msg_controllen = sizeof(cbuf),
+ .msg_control = &u,
+ .msg_controllen = sizeof(u),
};
ret = kernel_recvmsg(queue->sock, &drain, &iov, 1, sizeof(buf),
@@ -1675,7 +1681,7 @@ static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue,
struct nvme_tcp_icresp_pdu *icresp)
{
- char cbuf[CMSG_LEN(sizeof(char))];
+ union nvme_tcp_tls_cmsg u;
struct msghdr msg;
struct kvec iov;
u8 ctype;
@@ -1683,12 +1689,12 @@ static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue,
for (i = 0; i < NVME_TCP_ICRESP_MAX_RECORDS; i++) {
memset(&msg, 0, sizeof(msg));
- memset(cbuf, 0, sizeof(cbuf));
+ memset(&u, 0, sizeof(u));
iov.iov_base = icresp;
iov.iov_len = sizeof(*icresp);
if (nvme_tcp_queue_tls(queue)) {
- msg.msg_control = cbuf;
- msg.msg_controllen = sizeof(cbuf);
+ msg.msg_control = &u;
+ msg.msg_controllen = sizeof(u);
}
msg.msg_flags = MSG_WAITALL;
ret = kernel_recvmsg(queue->sock, &msg, &iov, 1,
@@ -1696,8 +1702,7 @@ static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue,
if (ret <= 0 || !nvme_tcp_queue_tls(queue))
return ret;
- ctype = tls_get_record_type(queue->sock->sk,
- (struct cmsghdr *)cbuf);
+ ctype = tls_get_record_type(queue->sock->sk, &u.cmsg);
if (ctype == TLS_RECORD_TYPE_DATA)
return ret;
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 719/742] nvme-tcp: move the TLS record read loop into a helper
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (702 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 718/742] nvme-tcp: use an aligned buffer for the TLS record type Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 720/742] nvme-tcp: consume TLS records without application data Greg Kroah-Hartman
` (22 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Martin Belanger, Hannes Reinecke,
Keith Busch, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Belanger <martin.belanger@dell.com>
commit 76afef5e29221e68f9a19df767f94b092c31e974 upstream.
Move the read loop out of nvme_tcp_skip_tls_record() into a new
helper, nvme_tcp_drain_tls_record(). The next patch uses the helper
to read TLS records that arrive on a live queue.
No functional change.
Cc: stable@vger.kernel.org
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/nvme/host/tcp.c | 60 ++++++++++++++++++++++++++---------------
1 file changed, 38 insertions(+), 22 deletions(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 0d80c12d9fe8f..ea64d243d058b 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1622,31 +1622,16 @@ static int nvme_tcp_recv_tls_alert(struct nvme_tcp_queue *queue,
}
/*
- * Discard a TLS record that arrived in place of the ICResp. A peer may send
- * a NewSessionTicket as soon as the handshake completes.
+ * Read the rest of a TLS record whose first part was read into @msg.
*
- * Returns 0 when the record was discarded and the ICResp can be read, or a
- * negative errno if the connection cannot continue.
+ * Returns the bytes read, or a negative errno.
*/
-static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
- struct msghdr *msg, u8 ctype, int len)
+static int nvme_tcp_drain_tls_record(struct nvme_tcp_queue *queue,
+ struct msghdr *msg, int flags)
{
u8 buf[NVME_TCP_TLS_REC_CHUNK];
- int ret;
+ int ret, drained = 0;
- switch (ctype) {
- case TLS_RECORD_TYPE_HANDSHAKE:
- break;
- case TLS_RECORD_TYPE_ALERT:
- ret = nvme_tcp_recv_tls_alert(queue, msg, len);
- return ret ? : -ENOTCONN;
- default:
- pr_err("queue %d: unhandled TLS record %u\n",
- nvme_tcp_queue_id(queue), ctype);
- return -ENOTCONN;
- }
-
- /* the ICResp is in a later record, drain this one first */
while (!(msg->msg_flags & MSG_EOR)) {
struct kvec iov = {
.iov_base = buf,
@@ -1660,16 +1645,47 @@ static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
};
ret = kernel_recvmsg(queue->sock, &drain, &iov, 1, sizeof(buf),
- 0);
+ flags);
if (ret <= 0) {
pr_warn("queue %d: failed to drain TLS record: %d\n",
nvme_tcp_queue_id(queue), ret);
return ret ? : -ECONNRESET;
}
+ drained += ret;
msg->msg_flags = drain.msg_flags;
}
- return 0;
+ return drained;
+}
+
+/*
+ * Discard a TLS record that arrived in place of the ICResp. A peer may send
+ * a NewSessionTicket as soon as the handshake completes.
+ *
+ * Returns 0 when the record was discarded and the ICResp can be read, or a
+ * negative errno if the connection cannot continue.
+ */
+static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
+ struct msghdr *msg, u8 ctype, int len)
+{
+ int ret;
+
+ switch (ctype) {
+ case TLS_RECORD_TYPE_HANDSHAKE:
+ break;
+ case TLS_RECORD_TYPE_ALERT:
+ ret = nvme_tcp_recv_tls_alert(queue, msg, len);
+ return ret ? : -ENOTCONN;
+ default:
+ pr_err("queue %d: unhandled TLS record %u\n",
+ nvme_tcp_queue_id(queue), ctype);
+ return -ENOTCONN;
+ }
+
+ /* the ICResp is in a later record, drain this one first */
+ ret = nvme_tcp_drain_tls_record(queue, msg, 0);
+
+ return ret < 0 ? ret : 0;
}
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 720/742] nvme-tcp: consume TLS records without application data
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (703 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 719/742] nvme-tcp: move the TLS record read loop into a helper Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 721/742] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets Greg Kroah-Hartman
` (21 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Martin Belanger, Hannes Reinecke,
Keith Busch, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Belanger <martin.belanger@dell.com>
commit 687e743e4089b2a854982b321cb2d681ae5d6136 upstream.
A peer may send a TLS record without application data at any time
after the handshake: a NewSessionTicket, a KeyUpdate or an alert.
tls_sw_read_sock() cannot pass such a record to nvme_tcp_recv_skb().
It returns -EINVAL and leaves the record at the head of the receive
queue. nvme_tcp_try_recv() then starts error recovery, and the
controller reconnects.
TLS 1.3 allows a server to send a NewSessionTicket at any time after
the handshake (RFC 8446, section 4.6.1). Alerts can also arrive at any
time.
On -EINVAL, read the record with recvmsg(), which reports the record
type. Discard handshake messages other than KeyUpdate. Log alerts, and
fail the queue on a fatal alert. Fail the queue on a KeyUpdate, which
nvme-tcp cannot answer, and on any other record type. recvmsg() takes
the socket lock, so release it around the read.
Handle these records in one helper, also for the records that arrive
ahead of the ICResp. A warning alert ahead of the ICResp no longer fails
the connection.
On a poll queue, nvme_tcp_poll() and nvme_tcp_io_work() can both see
the record while the socket lock is released. A queue flag makes sure
that only one of them reads it.
svc_tcp_recvfrom() in sunrpc handles -EINVAL from read_sock() the same
way.
Fixes: be8e82caa685 ("nvme-tcp: enable TLS handshake upcall")
Cc: stable@vger.kernel.org
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/nvme/host/tcp.c | 113 ++++++++++++++++++++++++++++++++++------
1 file changed, 97 insertions(+), 16 deletions(-)
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index ea64d243d058b..1baddb78d2541 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -121,6 +121,7 @@ enum nvme_tcp_queue_flags {
NVME_TCP_Q_LIVE = 1,
NVME_TCP_Q_POLLING = 2,
NVME_TCP_Q_IO_CPU_SET = 3,
+ NVME_TCP_Q_TLS_RECORD = 4,
};
#define NVME_TCP_OPT_NR_QUEUES(opts) ((opts)->nr_io_queues + \
@@ -1441,6 +1442,8 @@ static int nvme_tcp_try_send(struct nvme_tcp_queue *queue)
return ret;
}
+static int nvme_tcp_recv_tls_record(struct nvme_tcp_queue *queue);
+
static int nvme_tcp_try_recv(struct nvme_tcp_queue *queue)
{
struct socket *sock = queue->sock;
@@ -1453,10 +1456,31 @@ static int nvme_tcp_try_recv(struct nvme_tcp_queue *queue)
lock_sock(sk);
queue->nr_cqe = 0;
consumed = sock->ops->read_sock(sk, &rd_desc, nvme_tcp_recv_skb);
+ /*
+ * kTLS cannot pass a TLS record without application data to
+ * nvme_tcp_recv_skb(). It returns -EINVAL and leaves the record at
+ * the head of the receive queue. recvmsg() takes the socket lock,
+ * so read the record without it.
+ */
+ if (unlikely(consumed == -EINVAL && nvme_tcp_queue_tls(queue) &&
+ queue->rd_enabled)) {
+ /*
+ * On a poll queue, nvme_tcp_poll() and nvme_tcp_io_work() can
+ * both get here for the same record. Only one of them reads it.
+ */
+ if (test_and_set_bit(NVME_TCP_Q_TLS_RECORD, &queue->flags)) {
+ consumed = 0;
+ } else {
+ release_sock(sk);
+ consumed = nvme_tcp_recv_tls_record(queue);
+ lock_sock(sk);
+ clear_bit(NVME_TCP_Q_TLS_RECORD, &queue->flags);
+ }
+ }
/*
* nvme_tcp_recv_skb() handles its own errors, so a queue that is
- * still enabled failed inside read_sock(). Handle it before
- * release_sock() processes the backlog.
+ * still enabled failed inside read_sock() or while reading a TLS
+ * record. Handle it before release_sock() processes the backlog.
*/
if (unlikely(consumed < 0 && consumed != -EAGAIN &&
queue->rd_enabled)) {
@@ -1659,33 +1683,88 @@ static int nvme_tcp_drain_tls_record(struct nvme_tcp_queue *queue,
}
/*
- * Discard a TLS record that arrived in place of the ICResp. A peer may send
- * a NewSessionTicket as soon as the handshake completes.
+ * Consume a TLS record without application data. The first @len bytes of
+ * the record were read into @msg and @data.
*
- * Returns 0 when the record was discarded and the ICResp can be read, or a
- * negative errno if the connection cannot continue.
+ * A KeyUpdate needs new keys that nothing here can supply. Other handshake
+ * messages, such as a NewSessionTicket, are discarded.
+ *
+ * Returns the bytes read after the first @len, or a negative errno if the
+ * connection cannot continue.
*/
-static int nvme_tcp_skip_tls_record(struct nvme_tcp_queue *queue,
- struct msghdr *msg, u8 ctype, int len)
+static int nvme_tcp_consume_tls_record(struct nvme_tcp_queue *queue,
+ struct msghdr *msg, u8 ctype,
+ const u8 *data, int len, int flags)
{
int ret;
switch (ctype) {
case TLS_RECORD_TYPE_HANDSHAKE:
+ if (data[0] == TLS_HANDSHAKE_KEYUPDATE) {
+ dev_err(queue->ctrl->ctrl.device,
+ "queue %d: TLS KeyUpdate is not supported\n",
+ nvme_tcp_queue_id(queue));
+ return -EKEYEXPIRED;
+ }
break;
case TLS_RECORD_TYPE_ALERT:
ret = nvme_tcp_recv_tls_alert(queue, msg, len);
- return ret ? : -ENOTCONN;
+ if (ret)
+ return ret;
+ break;
default:
- pr_err("queue %d: unhandled TLS record %u\n",
- nvme_tcp_queue_id(queue), ctype);
- return -ENOTCONN;
+ dev_err(queue->ctrl->ctrl.device,
+ "queue %d: unexpected TLS record %u\n",
+ nvme_tcp_queue_id(queue), ctype);
+ return -EPROTO;
}
- /* the ICResp is in a later record, drain this one first */
- ret = nvme_tcp_drain_tls_record(queue, msg, 0);
+ return nvme_tcp_drain_tls_record(queue, msg, flags);
+}
+
+/*
+ * Read the TLS record that read_sock() could not pass to
+ * nvme_tcp_recv_skb(). The caller must not hold the socket lock.
+ *
+ * Returns the bytes consumed, or a negative errno if the connection cannot
+ * continue.
+ */
+static int nvme_tcp_recv_tls_record(struct nvme_tcp_queue *queue)
+{
+ u8 buf[NVME_TCP_TLS_REC_CHUNK];
+ union nvme_tcp_tls_cmsg u = {};
+ struct kvec iov = {
+ .iov_base = buf,
+ .iov_len = sizeof(buf),
+ };
+ struct msghdr msg = {
+ .msg_control = &u,
+ .msg_controllen = sizeof(u),
+ };
+ int len, ret;
+ u8 ctype;
+
+ len = kernel_recvmsg(queue->sock, &msg, &iov, 1, sizeof(buf),
+ MSG_DONTWAIT);
+ if (len <= 0)
+ goto fail;
+
+ ctype = tls_get_record_type(queue->sock->sk, &u.cmsg);
+ ret = nvme_tcp_consume_tls_record(queue, &msg, ctype, buf, len,
+ MSG_DONTWAIT);
+ if (ret < 0) {
+ len = ret;
+ goto fail;
+ }
+
+ return len + ret;
+
+fail:
+ /* read_sock() left a whole record, so none of it can be missing */
+ if (len == -EAGAIN)
+ return -EPROTO;
- return ret < 0 ? ret : 0;
+ return len ? : -ECONNRESET;
}
/*
@@ -1722,7 +1801,9 @@ static int nvme_tcp_recv_icresp(struct nvme_tcp_queue *queue,
if (ctype == TLS_RECORD_TYPE_DATA)
return ret;
- ret = nvme_tcp_skip_tls_record(queue, &msg, ctype, ret);
+ /* the ICResp is in a later record */
+ ret = nvme_tcp_consume_tls_record(queue, &msg, ctype,
+ (const u8 *)icresp, ret, 0);
if (ret < 0)
return ret;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 721/742] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (704 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 720/742] nvme-tcp: consume TLS records without application data Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 722/742] gpiolib: clear debounce period before the "requested" flag Greg Kroah-Hartman
` (20 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Harry Wentland, Cooper Morgan,
Wayne Lin, Alex Deucher, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cooper Morgan <ext-github@cwooper.dev>
commit 76850a457474a629dc0ceffaafb3aed78ff5f469 upstream.
The v1 and v2 FreeSync infopackets carry the minimum and maximum
refresh rate in one byte each, and build_vrr_infopacket_data_v1() casts
the rate in Hz to unsigned char. On a sink whose range goes above
255 Hz the value wraps: a 320 Hz mode is advertised as a 64 Hz maximum.
Sinks that treat the field as authoritative misbehave once the wrapped
value lands inside their range. An MSI MAG 271QPX32 (48-320 Hz) over
native DP looks like a ~720p image upscaled to the full screen at 320 Hz
and runs its self-test pattern at 305-315 Hz, while 300 Hz (wrapping to
44 Hz, below its minimum) is fine. Capping the EDID range at 255 Hz, so
the packet says 255, gives a correct picture at 320 Hz.
Saturate the fields at 255 Hz instead of wrapping.
Capping v1 at 255 as a fallback was suggested by oystersuki in the linked
issue.
Fixes: 98e6436d3af5 ("drm/amd/display: Refactor FreeSync module")
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/5988
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Cooper Morgan <ext-github@cwooper.dev>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 8f91c13d9a14085216725f60b55546fce5c2dd19)
Cc: stable@vger.kernel.org
(cherry picked from commit 76850a457474a629dc0ceffaafb3aed78ff5f469)
[ Cooper: Dropped the KUnit test hunks, since 7.3.y's
amdgpu_dm_freesync_test.c predates the tests they extend. The
freesync.c change is unchanged. ]
Signed-off-by: Cooper Morgan <ext-github@cwooper.dev>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../gpu/drm/amd/display/modules/freesync/freesync.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index f154a619b5339..21165855cb927 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -571,6 +571,12 @@ static bool vrr_settings_require_update(struct core_freesync *core_freesync,
return false;
}
+/* v1/v2 packets hold each rate in one byte; saturate instead of wrapping. */
+static unsigned char vrr_refresh_hz_u8(unsigned int refresh_in_uhz)
+{
+ return min((refresh_in_uhz + 500000) / 1000000, 255U);
+}
+
static void build_vrr_infopacket_data_v1(const struct mod_vrr_params *vrr,
struct dc_info_packet *infopacket,
bool freesync_on_desktop)
@@ -614,15 +620,15 @@ static void build_vrr_infopacket_data_v1(const struct mod_vrr_params *vrr,
/* PB7 = FreeSync Minimum refresh rate (Hz) */
if (vrr->state == VRR_STATE_ACTIVE_VARIABLE ||
vrr->state == VRR_STATE_ACTIVE_FIXED) {
- infopacket->sb[7] = (unsigned char)((vrr->min_refresh_in_uhz + 500000) / 1000000);
+ infopacket->sb[7] = vrr_refresh_hz_u8(vrr->min_refresh_in_uhz);
} else {
- infopacket->sb[7] = (unsigned char)((vrr->max_refresh_in_uhz + 500000) / 1000000);
+ infopacket->sb[7] = vrr_refresh_hz_u8(vrr->max_refresh_in_uhz);
}
/* PB8 = FreeSync Maximum refresh rate (Hz)
* Note: We should never go above the field rate of the mode timing set.
*/
- infopacket->sb[8] = (unsigned char)((vrr->max_refresh_in_uhz + 500000) / 1000000);
+ infopacket->sb[8] = vrr_refresh_hz_u8(vrr->max_refresh_in_uhz);
}
static void build_vrr_infopacket_data_v3(const struct mod_vrr_params *vrr,
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 722/742] gpiolib: clear debounce period before the "requested" flag
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (705 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 721/742] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 723/742] gpiolib: dont overwrite the entire flags field in gpiod_free_commit() Greg Kroah-Hartman
` (19 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kent Gibson, Bartosz Golaszewski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
[ Upstream commit 8509d643ffb7be508568c696c9fe45eb1f84c33c ]
The debounce_period_us field is protected by the GPIOD_FLAG_REQUESTED
flag, so it should be cleared before the flag, else it could potentially
race with a new request.
Suggested-by: Kent Gibson <warthog618@gmail.com>
Closes: https://lore.kernel.org/all/20261105042905.GB8436@rigel/
Fixes: 81625f362497 ("gpio: cdev: go back to storing debounce period in the GPIO descriptor")
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-3-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpiolib.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index fbd07bdb013af..c69fabe1d689c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2690,6 +2690,10 @@ void gpiod_free_commit(struct gpio_desc *desc)
if (guard.gc->free)
guard.gc->free(guard.gc, gpiod_hwgpio(desc));
+#ifdef CONFIG_GPIO_CDEV
+ WRITE_ONCE(desc->debounce_period_us, 0);
+#endif
+
clear_bit(GPIOD_FLAG_ACTIVE_LOW, &flags);
clear_bit(GPIOD_FLAG_REQUESTED, &flags);
clear_bit(GPIOD_FLAG_OPEN_DRAIN, &flags);
@@ -2707,9 +2711,6 @@ void gpiod_free_commit(struct gpio_desc *desc)
#endif
desc_set_label(desc, NULL);
WRITE_ONCE(desc->flags, flags);
-#ifdef CONFIG_GPIO_CDEV
- WRITE_ONCE(desc->debounce_period_us, 0);
-#endif
gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_RELEASED);
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 723/742] gpiolib: dont overwrite the entire flags field in gpiod_free_commit()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (706 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 722/742] gpiolib: clear debounce period before the "requested" flag Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 724/742] gpiolib: wait for pending label frees before cleaning up desc_srcu Greg Kroah-Hartman
` (18 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Kent Gibson, Bartosz Golaszewski,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
[ Upstream commit 63d7aedf6add8a24415af4c010588f63fa7296ab ]
Use set_mask_bits() to clear all request-related flags in one go
instead of risking racing with concurrent users and overwriting any
changes they could have done between READ_ONCE() and WRITE_ONCE().
Cc: stable@vger.kernel.org
Fixes: 35b545332b80 ("gpio: remove gpio_lock")
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-4-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpiolib.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c69fabe1d689c..ef71c353e724e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2693,24 +2693,23 @@ void gpiod_free_commit(struct gpio_desc *desc)
#ifdef CONFIG_GPIO_CDEV
WRITE_ONCE(desc->debounce_period_us, 0);
#endif
-
- clear_bit(GPIOD_FLAG_ACTIVE_LOW, &flags);
- clear_bit(GPIOD_FLAG_REQUESTED, &flags);
- clear_bit(GPIOD_FLAG_OPEN_DRAIN, &flags);
- clear_bit(GPIOD_FLAG_OPEN_SOURCE, &flags);
- clear_bit(GPIOD_FLAG_PULL_UP, &flags);
- clear_bit(GPIOD_FLAG_PULL_DOWN, &flags);
- clear_bit(GPIOD_FLAG_BIAS_DISABLE, &flags);
- clear_bit(GPIOD_FLAG_EDGE_RISING, &flags);
- clear_bit(GPIOD_FLAG_EDGE_FALLING, &flags);
- clear_bit(GPIOD_FLAG_EVENT_CLOCK_REALTIME, &flags);
- clear_bit(GPIOD_FLAG_EVENT_CLOCK_HTE, &flags);
- clear_bit(GPIOD_FLAG_IS_HOGGED, &flags);
#ifdef CONFIG_OF_DYNAMIC
WRITE_ONCE(desc->hog, NULL);
#endif
desc_set_label(desc, NULL);
- WRITE_ONCE(desc->flags, flags);
+ set_mask_bits(&desc->flags,
+ BIT(GPIOD_FLAG_ACTIVE_LOW) |
+ BIT(GPIOD_FLAG_REQUESTED) |
+ BIT(GPIOD_FLAG_OPEN_DRAIN) |
+ BIT(GPIOD_FLAG_OPEN_SOURCE) |
+ BIT(GPIOD_FLAG_PULL_UP) |
+ BIT(GPIOD_FLAG_PULL_DOWN) |
+ BIT(GPIOD_FLAG_BIAS_DISABLE) |
+ BIT(GPIOD_FLAG_EDGE_RISING) |
+ BIT(GPIOD_FLAG_EDGE_FALLING) |
+ BIT(GPIOD_FLAG_EVENT_CLOCK_REALTIME) |
+ BIT(GPIOD_FLAG_EVENT_CLOCK_HTE) |
+ BIT(GPIOD_FLAG_IS_HOGGED), 0);
gpiod_line_state_notify(desc, GPIO_V2_LINE_CHANGED_RELEASED);
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 724/742] gpiolib: wait for pending label frees before cleaning up desc_srcu
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (707 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 723/742] gpiolib: dont overwrite the entire flags field in gpiod_free_commit() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 725/742] gpiolib: free the label of lines released after their chip was removed Greg Kroah-Hartman
` (17 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Paul E. McKenney, Andy Shevchenko,
Yi Lai, Adrian Ambrozewicz, Bartosz Golaszewski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Ambrozewicz <aambrozewicz@nvidia.com>
[ Upstream commit c901e8fddd3a23353bb12c9d93b9a5fc482ac8f5 ]
desc_set_label() frees the old label with call_srcu() on
gdev->desc_srcu, and gpiodev_release() calls synchronize_srcu() before
cleanup_srcu_struct(). synchronize_srcu() waits for a grace period, not
for queued callbacks. Once the srcu_struct uses per-CPU callback lists,
a label freed by gpiochip_free_hogs() can still be pending, and
cleanup_srcu_struct() warns:
WARNING: kernel/rcu/srcutree.c:706 at cleanup_srcu_struct+0x239/0x330, CPU#0: init/1
Call Trace:
gpiodev_release
device_release
kobject_put
devres_release_all
device_release_driver_internal
platform_device_unregister
gpio_sim_device_deactivate
Use srcu_barrier(), which waits for them.
Reproduced with a hogged gpio-sim line, setting the chip live and back
on a 4-CPU guest with srcutree.convert_to_big=1: it warns within 60
cycles; with this change, 1000 cycles pass.
Fixes: a86d27693066 ("gpiolib: fix the speed of descriptor label setting with SRCU")
Cc: stable@vger.kernel.org
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Yi Lai <yi1.lai@intel.com>
Signed-off-by: Adrian Ambrozewicz <aambrozewicz@nvidia.com>
Link: https://patch.msgid.link/20261124-gpiolib-chip-removal-v8-1-aambrozewicz@nvidia.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpiolib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index ef71c353e724e..4b0e7d066497b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -898,7 +898,7 @@ static void gpiodev_release(struct device *dev)
struct gpio_device *gdev = to_gpio_device(dev);
/* Call pending kfree()s for descriptor labels. */
- synchronize_srcu(&gdev->desc_srcu);
+ srcu_barrier(&gdev->desc_srcu);
cleanup_srcu_struct(&gdev->desc_srcu);
if (gdev->line_state_wq)
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 725/742] gpiolib: free the label of lines released after their chip was removed
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (708 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 724/742] gpiolib: wait for pending label frees before cleaning up desc_srcu Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 726/742] fuse: preserve ENOTCONN after failed initialization and disconnect Greg Kroah-Hartman
` (16 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Andy Shevchenko, Adrian Ambrozewicz,
Bartosz Golaszewski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Ambrozewicz <aambrozewicz@nvidia.com>
[ Upstream commit 4bc5e234e10866ebaad01ce11ed08f64333dcac0 ]
gpiod_free_commit() drops the consumer label only while the chip is
still there. A line that user space keeps requested across
gpiochip_remove() is released when gdev->chip is already NULL, and its
label leaks:
unreferenced object (size 32):
comm "gpio-hold"
backtrace (crc 7ff222d9):
desc_set_label
gpiod_request_commit
gpiod_request
linereq_create
gpio_ioctl
Clear the label before the chip check. The ->free() callback, the flags
update and the line state notification need the chip and stay under it.
Reproduced with gpio-sim: request a line, set the chip's "live"
attribute to 0, then close the request. kmemleak reports up to 30 such
objects after 30 cycles; with this change, none after 100.
Fixes: 35b545332b80 ("gpio: remove gpio_lock")
Cc: stable@vger.kernel.org
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Adrian Ambrozewicz <aambrozewicz@nvidia.com>
Link: https://patch.msgid.link/20261124-gpiolib-chip-removal-v8-2-aambrozewicz@nvidia.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpio/gpiolib.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 4b0e7d066497b..67d68806310ee 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2686,7 +2686,12 @@ void gpiod_free_commit(struct gpio_desc *desc)
flags = READ_ONCE(desc->flags);
- if (guard.gc && test_bit(GPIOD_FLAG_REQUESTED, &flags)) {
+ if (guard.gc && !test_bit(GPIOD_FLAG_REQUESTED, &flags))
+ return;
+
+ desc_set_label(desc, NULL);
+
+ if (guard.gc) {
if (guard.gc->free)
guard.gc->free(guard.gc, gpiod_hwgpio(desc));
@@ -2696,7 +2701,6 @@ void gpiod_free_commit(struct gpio_desc *desc)
#ifdef CONFIG_OF_DYNAMIC
WRITE_ONCE(desc->hog, NULL);
#endif
- desc_set_label(desc, NULL);
set_mask_bits(&desc->flags,
BIT(GPIOD_FLAG_ACTIVE_LOW) |
BIT(GPIOD_FLAG_REQUESTED) |
--
2.53.0
^ permalink raw reply related [flat|nested] 728+ messages in thread* [PATCH 7.3 726/742] fuse: preserve ENOTCONN after failed initialization and disconnect
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (709 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 725/742] gpiolib: free the label of lines released after their chip was removed Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 727/742] drm/amd/display: Seed boot clocks to avoid lowering pre-OS display clocks Greg Kroah-Hartman
` (15 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Hengyu Liang, Miklos Szeredi,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hengyu Liang <hengyul@cs.unc.edu>
[ Upstream commit 2eb2329f9ce7f29f227656cc2686fe6f1879d11c ]
Commit 794e811d1443 ("fuse: split out filesystem part of request
sending") moved the INIT failure check into fuse_req_prep(), before
the channel checks whether it is still connected.
If a daemon closes /dev/fuse before replying to INIT, aborting the
channel completes INIT with an error. stat() and open() on the mount
then return ECONNREFUSED instead of the previous ENOTCONN. The same
change occurs when INIT is rejected before the daemon closes the fd.
Record INIT failure in the channel before publishing initialized, and
check it in fuse_get_req() after waiting for initialization and checking
for disconnection. This preserves ECONNREFUSED for failed INIT while
the device remains open, and restores ENOTCONN after disconnection.
Set the failure flag only while the channel is connected, since abort
also marks it initialized to wake waiters after a successful INIT.
Fixes: 794e811d1443 ("fuse: split out filesystem part of request sending")
Cc: stable@vger.kernel.org
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
[ sashal: adapted the context for the non-const struct mnt_idmap *idmap parameter type in fs/fuse/req.c when removing fuse_req_prep(); the rest matches upstream. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/fuse/dev.c | 8 ++++++++
fs/fuse/fuse_dev_i.h | 3 +++
fs/fuse/req.c | 14 +++-----------
3 files changed, 14 insertions(+), 11 deletions(-)
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -80,6 +80,10 @@ void fuse_chan_set_initialized(struct fu
fuse_uring_conn_init(fch);
}
+ /* An aborted channel is also marked initialized to wake waiters. */
+ if (!param && fch->connected)
+ fch->conn_refused = true;
+
/* Pairs with smp_load_acquire() readers of fch->initialized */
smp_store_release(&fch->initialized, 1);
wake_up_all(&fch->blocked_waitq);
@@ -130,6 +134,10 @@ static struct fuse_req *fuse_get_req(str
if (!fch->connected)
goto out;
+ err = -ECONNREFUSED;
+ if (fch->conn_refused)
+ goto out;
+
req = fuse_request_alloc(fch, GFP_KERNEL);
err = -ENOMEM;
if (!req) {
--- a/fs/fuse/fuse_dev_i.h
+++ b/fs/fuse/fuse_dev_i.h
@@ -245,6 +245,9 @@ struct fuse_chan {
/** Is interrupt not implemented by fs? */
bool no_interrupt;
+ /** @conn_refused: INIT failed while the channel was still connected. */
+ bool conn_refused;
+
/* Use io_uring for communication */
unsigned int io_uring;
--- a/fs/fuse/req.c
+++ b/fs/fuse/req.c
@@ -48,19 +48,11 @@ static int fuse_fill_creds(struct fuse_m
return 0;
}
-static int fuse_req_prep(struct fuse_mount *fm, struct fuse_args *args, struct mnt_idmap *idmap)
-{
- if (!args->force && fm->fc->conn_error)
- return -ECONNREFUSED;
-
- return fuse_fill_creds(fm, args, idmap);
-}
-
ssize_t __fuse_simple_request(struct mnt_idmap *idmap, struct fuse_mount *fm,
struct fuse_args *args)
{
struct fuse_conn *fc = fm->fc;
- int err = fuse_req_prep(fm, args, idmap);
+ int err = fuse_fill_creds(fm, args, idmap);
if (err)
return err;
@@ -75,7 +67,7 @@ int fuse_simple_background(struct fuse_m
WARN_ON(args->force && !args->nocreds);
- err = fuse_req_prep(fm, args, &invalid_mnt_idmap);
+ err = fuse_fill_creds(fm, args, &invalid_mnt_idmap);
if (err)
return err;
@@ -90,7 +82,7 @@ int fuse_simple_notify_reply(struct fuse
WARN_ON(args->force && !args->nocreds);
- err = fuse_req_prep(fm, args, &invalid_mnt_idmap);
+ err = fuse_fill_creds(fm, args, &invalid_mnt_idmap);
if (err)
return err;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 727/742] drm/amd/display: Seed boot clocks to avoid lowering pre-OS display clocks
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (710 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 726/742] fuse: preserve ENOTCONN after failed initialization and disconnect Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 728/742] drm/vc4: Rebuild the V3D interrupt mask on every power transition Greg Kroah-Hartman
` (14 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Nicholas Kazlauskas, Charlene Liu,
Mario Limonciello, Alex Deucher, ChiaHsuan Chung, Jing Zhou,
Wayne Lin, Dan Wheeler, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jing Zhou <Jing.Zhou@amd.com>
[ Upstream commit eaf4ff850d97eb608482fa3497f1b89b2e628781 ]
[WHY]
USB4 DPIA HPD can arrive early in boot, before the first stream commit.
Its link detection runs prepare_phy_clocks(), which goes through
clk_mgr_exit_optimized_pwr_state() and clk_mgr_optimize_pwr_state()
and calls update_clocks(dc->current_state).
At that point both dc->current_state->bw_ctx.bw.dcn.clk and
clk_mgr->clks are still zero, because init_clocks() memsets them. On the
safe_to_lower path, dcn42_update_clocks() clamps the requested DPPCLK to
the 100MHz floor and programs it. This drops DPPCLK below what the
GOP-lit eDP pipe needs, and the panel flashes white.
[HOW]
1. In dcn42_init_clocks() and dcn42b_init_clocks(), seed clk_mgr->clks
dispclk/dppclk from the boot snapshot(10kHz units, x10).
2. Add a DC core helper, sync_current_state_clocks_from_clk_mgr().
After every hwss.init_hw() call (legacy_hardware_init, D0 entry in
dc_set_power_state, and dc_reinitialize_hardware), it copies
clk_mgr->clks into dc->current_state->bw_ctx.bw.dcn.clk for DCN.
A later update_clocks() before the first commit then sees the real
pre-OS clocks and does not lower them. Raising clocks is still
allowed and does not cause a flash.
Cc: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Cc: Charlene Liu <charlene.liu@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: ChiaHsuan Chung <chiahsuan.chung@amd.com>
Signed-off-by: Jing Zhou <Jing.Zhou@amd.com>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 2f289740a04f08a5ce4b5e3c69af6e32ab4a540e)
Cc: stable@vger.kernel.org
[ sashal: Renamed legacy_hardware_init() to dc_hardware_init() in the dc.c hunk context and function header, since this tree already uses the new name. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn42/dcn42_clk_mgr.c | 3 +
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn42b/dcn42b_clk_mgr.c | 4 ++
drivers/gpu/drm/amd/display/dc/core/dc.c | 16 +++++++++-
3 files changed, 22 insertions(+), 1 deletion(-)
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn42/dcn42_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn42/dcn42_clk_mgr.c
@@ -632,6 +632,9 @@ void dcn42_init_clocks(struct clk_mgr *c
DC_LOG_SMU("dp_dto_source_clock %d, dprefclk %d\n", clk_mgr_base->dp_dto_source_clock_in_khz, clk_mgr_base->dprefclk_khz);
dcn42_dump_clk_registers(&clk_mgr_base->boot_snapshot, clk_mgr);
+ /* Snapshot is in 10kHz units; seed clks so update_clocks() does not lower the pre-OS clocks */
+ clk_mgr_base->clks.dispclk_khz = clk_mgr_base->boot_snapshot.dispclk * 10;
+ clk_mgr_base->clks.dppclk_khz = clk_mgr_base->boot_snapshot.dppclk * 10;
clk_mgr_base->clks.ref_dtbclk_khz = clk_mgr_base->boot_snapshot.dtbclk * 10;
clk_mgr_base->clks.dtbclk_en = clk_mgr_base->boot_snapshot.dtbclk > 59000;
}
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn42b/dcn42b_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn42b/dcn42b_clk_mgr.c
@@ -240,6 +240,10 @@ void dcn42b_init_clocks(struct clk_mgr *
DC_LOG_SMU("dp_dto_source_clock %d, dprefclk %d\n", clk_mgr_base->dp_dto_source_clock_in_khz, clk_mgr_base->dprefclk_khz);
dcn42b_dump_clk_registers(&clk_mgr_base->boot_snapshot, clk_mgr);
+
+ /* Snapshot is in 10kHz units; seed clks so update_clocks() does not lower the pre-OS clocks */
+ clk_mgr_base->clks.dispclk_khz = clk_mgr_base->boot_snapshot.dispclk * 10;
+ clk_mgr_base->clks.dppclk_khz = clk_mgr_base->boot_snapshot.dppclk * 10;
}
static struct clk_bw_params dcn42b_bw_params = {
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1640,12 +1640,25 @@ static void detect_edp_presence(struct d
}
}
+static void sync_current_state_clocks_from_clk_mgr(struct dc *dc)
+{
+ if (!dc->current_state || !dc->clk_mgr)
+ return;
+
+ if (!(dc->ctx->dce_version == DCN_VERSION_4_2 || dc->ctx->dce_version == DCN_VERSION_4_2B))
+ return;
+
+ dc->current_state->bw_ctx.bw.dcn.clk = dc->clk_mgr->clks;
+}
+
void dc_hardware_init(struct dc *dc)
{
detect_edp_presence(dc);
- if (dc->ctx->dce_environment != DCE_ENV_VIRTUAL_HW)
+ if (dc->ctx->dce_environment != DCE_ENV_VIRTUAL_HW) {
dc->hwss.init_hw(dc);
+ sync_current_state_clocks_from_clk_mgr(dc);
+ }
dc_dmub_srv_notify_fw_dc_power_state(dc->ctx->dmub_srv, DC_ACPI_CM_POWER_STATE_D0);
}
@@ -6521,6 +6534,7 @@ void dc_set_power_state(struct dc *dc, e
dc_dmub_srv_notify_fw_dc_power_state(dc->ctx->dmub_srv, power_state);
dc->hwss.init_hw(dc);
+ sync_current_state_clocks_from_clk_mgr(dc);
if (dc->hwss.init_sys_ctx != NULL &&
dc->vm_pa_config.valid) {
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 728/742] drm/vc4: Rebuild the V3D interrupt mask on every power transition
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (711 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 727/742] drm/amd/display: Seed boot clocks to avoid lowering pre-OS display clocks Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 729/742] drm/xe: Include error-injection.h for ALLOW_ERROR_INJECTION() Greg Kroah-Hartman
` (13 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Iago Toral Quiroga, Maíra Canal,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <mcanal@igalia.com>
[ Upstream commit 83dd19480c105c8bf96c93fb18b2ea554b44445d ]
The out-of-memory interrupt is armed once, by bin_bo_alloc(), when the
binner BO is allocated. vc4_irq_disable() masks it on the way down,
vc4_irq_enable() brings back only the render bits, and bin_bo_alloc() does
not run again for a binner BO that is still referenced. An overflow after
an autosuspend therefore raises nothing and the binner stalls, until the
hangcheck resets the GPU and arms the interrupt again.
Therefore, derive the out-of-memory bit in vc4_irq_enable() from whether a
binner BO exists, which is the condition bin_bo_alloc() was standing in
for.
While here, clear the complement of the wanted mask while enabling.
V3D_INTENA and V3D_INTDIS are set/clear registers and the driver only ever
set bits, so a source left enabled will stay enabled and can reach
vc4_irq(), which returns IRQ_NONE for anything outside the three bits it
handles.
Cc: stable@vger.kernel.org
Fixes: 35c8b4b2c0fe ("drm/vc4: Allocate binner bo when starting to use the V3D")
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Link: https://patch.msgid.link/20261111-vc4-irq-cleanup-v2-2-aa757bb742f2@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>
[ sashal: Adjusted context for a differently worded comment above the V3D_INTENA write in vc4_irq_reset(); the resulting code is identical to upstream. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/vc4/vc4_irq.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
--- a/drivers/gpu/drm/vc4/vc4_irq.c
+++ b/drivers/gpu/drm/vc4/vc4_irq.c
@@ -53,10 +53,6 @@
#include "vc4_regs.h"
#include "vc4_trace.h"
-#define V3D_DRIVER_IRQS (V3D_INT_OUTOMEM | \
- V3D_INT_FLDONE | \
- V3D_INT_FRDONE)
-
static void
vc4_overflow_mem_work(struct work_struct *work)
{
@@ -249,6 +245,7 @@ void
vc4_irq_enable(struct drm_device *dev)
{
struct vc4_dev *vc4 = to_vc4_dev(dev);
+ u32 mask = V3D_INT_FLDONE | V3D_INT_FRDONE;
if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
return;
@@ -256,10 +253,18 @@ vc4_irq_enable(struct drm_device *dev)
if (!vc4->v3d)
return;
- /* Enable the render done interrupts. The out-of-memory interrupt is
- * enabled as soon as we have a binner BO allocated.
+ /* Arming the OOM interrupt before there is a binner BO would raise an
+ * interrupt nothing can clear.
*/
- V3D_WRITE(V3D_INTENA, V3D_INT_FLDONE | V3D_INT_FRDONE);
+ if (vc4->bin_bo)
+ mask |= V3D_INT_OUTOMEM;
+
+ /* Clear any pending interrupts someone might have left around for us. */
+ V3D_WRITE(V3D_INTCTL, mask);
+
+ /* Enable our set of interrupts, masking out any others. */
+ V3D_WRITE(V3D_INTDIS, ~mask);
+ V3D_WRITE(V3D_INTENA, mask);
}
void
@@ -274,14 +279,14 @@ vc4_irq_disable(struct drm_device *dev)
return;
/* Disable sending interrupts for our driver's IRQs. */
- V3D_WRITE(V3D_INTDIS, V3D_DRIVER_IRQS);
-
- /* Clear any pending interrupts we might have left. */
- V3D_WRITE(V3D_INTCTL, V3D_DRIVER_IRQS);
+ V3D_WRITE(V3D_INTDIS, ~0);
/* Finish any interrupt handler still in flight. */
disable_irq(vc4->irq);
+ /* Clear any pending interrupts we might have left. */
+ V3D_WRITE(V3D_INTCTL, ~0);
+
cancel_work_sync(&vc4->overflow_mem_work);
}
@@ -324,16 +329,12 @@ void vc4_irq_reset(struct drm_device *de
if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
return;
- /* Acknowledge any stale IRQs. */
- V3D_WRITE(V3D_INTCTL, V3D_DRIVER_IRQS);
-
- /*
- * Turn all our interrupts on. Binner out of memory is the
- * only one we expect to trigger at this point, since we've
- * just come from poweron and haven't supplied any overflow
- * memory yet.
+ /* bin_bo_alloc() may arm OUTOMEM between the bin_bo check and the
+ * INTDIS write in vc4_irq_enable(), which would then mask it again.
*/
- V3D_WRITE(V3D_INTENA, V3D_DRIVER_IRQS);
+ scoped_guard(mutex, &vc4->bin_bo_lock) {
+ vc4_irq_enable(dev);
+ }
spin_lock_irqsave(&vc4->job_lock, irqflags);
vc4_cancel_bin_job(dev);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 729/742] drm/xe: Include error-injection.h for ALLOW_ERROR_INJECTION()
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (712 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 728/742] drm/vc4: Rebuild the V3D interrupt mask on every power transition Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 730/742] drm/xe: Unwrap sync fences before adding them as job dependencies Greg Kroah-Hartman
` (12 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Francois Dugast, Petr Pavlu,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Pavlu <petr.pavlu@suse.com>
[ Upstream commit 291a8fe5d999c3937b9403c70badf847ec336b3a ]
Several drivers/gpu/drm/xe/*.c files use ALLOW_ERROR_INJECTION(), which is
defined in asm-generic/error-injection.h. They currently rely on this
header being included indirectly through linux/module.h ->
linux/error-injection.h.
Add the missing includes in preparation for removing the
linux/error-injection.h include from linux/module.h.
Remove also the linux/fault-injection.h include, which commit 91b2c42c214f
("drm/xe: Use fault injection infrastructure to find issues at probe time")
mistakenly used to provide the definition of ALLOW_ERROR_INJECTION().
Reviewed-by: Francois Dugast <francois.dugast@intel.com>
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Stable-dep-of: e2cdad51ec53 ("drm/xe: Unwrap sync fences before adding them as job dependencies")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/xe/xe_device.c | 2 +-
drivers/gpu/drm/xe/xe_exec_queue.c | 1 +
drivers/gpu/drm/xe/xe_ggtt.c | 2 +-
drivers/gpu/drm/xe/xe_guc.c | 1 +
drivers/gpu/drm/xe/xe_guc_ads.c | 2 +-
drivers/gpu/drm/xe/xe_guc_ct.c | 2 +-
drivers/gpu/drm/xe/xe_guc_log.c | 2 +-
drivers/gpu/drm/xe/xe_guc_relay.c | 2 +-
drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c | 1 +
drivers/gpu/drm/xe/xe_hw_engine_group.c | 2 ++
drivers/gpu/drm/xe/xe_mmio.c | 1 +
drivers/gpu/drm/xe/xe_oa.c | 1 +
drivers/gpu/drm/xe/xe_pm.c | 2 +-
drivers/gpu/drm/xe/xe_pt.c | 2 ++
drivers/gpu/drm/xe/xe_pxp.c | 2 ++
drivers/gpu/drm/xe/xe_sriov.c | 2 +-
drivers/gpu/drm/xe/xe_sync.c | 1 +
drivers/gpu/drm/xe/xe_tile.c | 2 +-
drivers/gpu/drm/xe/xe_tuning.c | 2 ++
drivers/gpu/drm/xe/xe_uc_fw.c | 2 +-
drivers/gpu/drm/xe/xe_vm.c | 1 +
drivers/gpu/drm/xe/xe_wa.c | 2 +-
drivers/gpu/drm/xe/xe_wopcm.c | 2 +-
23 files changed, 27 insertions(+), 12 deletions(-)
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -7,7 +7,7 @@
#include <linux/aperture.h>
#include <linux/delay.h>
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <linux/units.h>
#include <drm/drm_client.h>
--- a/drivers/gpu/drm/xe/xe_exec_queue.c
+++ b/drivers/gpu/drm/xe/xe_exec_queue.c
@@ -5,6 +5,7 @@
#include "xe_exec_queue.h"
+#include <linux/error-injection.h>
#include <linux/nospec.h>
#include <drm/drm_device.h>
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -6,7 +6,7 @@
#include "xe_ggtt.h"
#include <kunit/visibility.h>
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/sizes.h>
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -5,6 +5,7 @@
#include "xe_guc.h"
+#include <linux/error-injection.h>
#include <linux/iopoll.h>
#include <drm/drm_managed.h>
--- a/drivers/gpu/drm/xe/xe_guc_ads.c
+++ b/drivers/gpu/drm/xe/xe_guc_ads.c
@@ -5,7 +5,7 @@
#include "xe_guc_ads.h"
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <drm/drm_managed.h>
--- a/drivers/gpu/drm/xe/xe_guc_ct.c
+++ b/drivers/gpu/drm/xe/xe_guc_ct.c
@@ -8,7 +8,7 @@
#include <linux/bitfield.h>
#include <linux/circ_buf.h>
#include <linux/delay.h>
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <kunit/static_stub.h>
--- a/drivers/gpu/drm/xe/xe_guc_log.c
+++ b/drivers/gpu/drm/xe/xe_guc_log.c
@@ -5,7 +5,7 @@
#include "xe_guc_log.h"
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <linux/utsname.h>
#include <drm/drm_managed.h>
--- a/drivers/gpu/drm/xe/xe_guc_relay.c
+++ b/drivers/gpu/drm/xe/xe_guc_relay.c
@@ -5,7 +5,7 @@
#include <linux/bitfield.h>
#include <linux/delay.h>
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <drm/drm_managed.h>
--- a/drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c
+++ b/drivers/gpu/drm/xe/xe_hw_engine_class_sysfs.c
@@ -4,6 +4,7 @@
*/
#include <drm/drm_managed.h>
+#include <linux/error-injection.h>
#include <linux/kobject.h>
#include <linux/sysfs.h>
--- a/drivers/gpu/drm/xe/xe_hw_engine_group.c
+++ b/drivers/gpu/drm/xe/xe_hw_engine_group.c
@@ -3,6 +3,8 @@
* Copyright © 2024 Intel Corporation
*/
+#include <linux/error-injection.h>
+
#include <drm/drm_managed.h>
#include "xe_assert.h"
--- a/drivers/gpu/drm/xe/xe_mmio.c
+++ b/drivers/gpu/drm/xe/xe_mmio.c
@@ -6,6 +6,7 @@
#include "xe_mmio.h"
#include <linux/delay.h>
+#include <linux/error-injection.h>
#include <linux/io-64-nonatomic-lo-hi.h>
#include <linux/minmax.h>
#include <linux/pci.h>
--- a/drivers/gpu/drm/xe/xe_oa.c
+++ b/drivers/gpu/drm/xe/xe_oa.c
@@ -5,6 +5,7 @@
#include <linux/anon_inodes.h>
#include <linux/delay.h>
+#include <linux/error-injection.h>
#include <linux/nospec.h>
#include <linux/poll.h>
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -5,7 +5,7 @@
#include "xe_pm.h"
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <linux/pm_runtime.h>
#include <linux/suspend.h>
#include <linux/dmi.h>
--- a/drivers/gpu/drm/xe/xe_pt.c
+++ b/drivers/gpu/drm/xe/xe_pt.c
@@ -5,6 +5,8 @@
#include "xe_pt.h"
+#include <linux/error-injection.h>
+
#include "regs/xe_gtt_defs.h"
#include "xe_bo.h"
#include "xe_device.h"
--- a/drivers/gpu/drm/xe/xe_pxp.c
+++ b/drivers/gpu/drm/xe/xe_pxp.c
@@ -5,6 +5,8 @@
#include "xe_pxp.h"
+#include <linux/error-injection.h>
+
#include <drm/drm_managed.h>
#include <uapi/drm/xe_drm.h>
--- a/drivers/gpu/drm/xe/xe_sriov.c
+++ b/drivers/gpu/drm/xe/xe_sriov.c
@@ -3,7 +3,7 @@
* Copyright © 2023 Intel Corporation
*/
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <drm/drm_managed.h>
--- a/drivers/gpu/drm/xe/xe_sync.c
+++ b/drivers/gpu/drm/xe/xe_sync.c
@@ -6,6 +6,7 @@
#include "xe_sync.h"
#include <linux/dma-fence-array.h>
+#include <linux/error-injection.h>
#include <linux/kthread.h>
#include <linux/sched/mm.h>
#include <linux/uaccess.h>
--- a/drivers/gpu/drm/xe/xe_tile.c
+++ b/drivers/gpu/drm/xe/xe_tile.c
@@ -3,7 +3,7 @@
* Copyright © 2023 Intel Corporation
*/
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <drm/drm_managed.h>
#include <drm/drm_pagemap_util.h>
--- a/drivers/gpu/drm/xe/xe_tuning.c
+++ b/drivers/gpu/drm/xe/xe_tuning.c
@@ -5,6 +5,8 @@
#include "xe_tuning.h"
+#include <linux/error-injection.h>
+
#include <kunit/visibility.h>
#include <drm/drm_managed.h>
--- a/drivers/gpu/drm/xe/xe_uc_fw.c
+++ b/drivers/gpu/drm/xe/xe_uc_fw.c
@@ -4,7 +4,7 @@
*/
#include <linux/bitfield.h>
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <linux/firmware.h>
#include <drm/drm_managed.h>
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -6,6 +6,7 @@
#include "xe_vm.h"
#include <linux/dma-fence-array.h>
+#include <linux/error-injection.h>
#include <linux/nospec.h>
#include <drm/drm_drv.h>
--- a/drivers/gpu/drm/xe/xe_wa.c
+++ b/drivers/gpu/drm/xe/xe_wa.c
@@ -8,7 +8,7 @@
#include <drm/drm_managed.h>
#include <kunit/visibility.h>
#include <linux/compiler_types.h>
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include <generated/xe_device_wa_oob.h>
#include <generated/xe_wa_oob.h>
--- a/drivers/gpu/drm/xe/xe_wopcm.c
+++ b/drivers/gpu/drm/xe/xe_wopcm.c
@@ -5,7 +5,7 @@
#include "xe_wopcm.h"
-#include <linux/fault-inject.h>
+#include <linux/error-injection.h>
#include "regs/xe_guc_regs.h"
#include "xe_device.h"
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 730/742] drm/xe: Unwrap sync fences before adding them as job dependencies
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (713 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 729/742] drm/xe: Include error-injection.h for ALLOW_ERROR_INJECTION() Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 731/742] hwmon: (nct6775) Fix target temp and tolerance for NCT6106/6116/6126 Greg Kroah-Hartman
` (11 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Chen, Junjia, Matthew Brost,
Dave Airlie, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Chen, Junjia" <junjia.chen@intel.com>
[ Upstream commit e2cdad51ec53dd0f48e7f767cc1390dec69d54d4 ]
A timeline syncobj point is a dma_fence_chain node that carries its own
fence context, separate from the contexts of the fences it wraps.
xe_sync_entry_add_deps() passed that container straight to
drm_sched_job_add_dependency().
drm_sched_entity_add_dependency_cb() only drops a dependency when the
fence context is one of the entity's own (fence_context or
fence_context + 1). A chain node never matches, so a wait on a point
whose inner fence is the finished fence of an earlier job on the same
exec queue is treated like a cross-queue dependency: the job is held
until the previous job has completed on the GPU. Every job queued
behind it waits too, and the ring drains before the next batch of jobs
is released.
Unwrap the fence with dma_fence_unwrap_for_each() and add each
unsignaled underlying fence as a dependency, so drm_sched sees the real
fence contexts and ignores same-entity fences. Dependencies on other
exec queues still wait for completion. drm_sched_job_add_dependency()
keeps only the latest fence per context, so the dependency array does
not grow with the length of the chain.
Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Cc: stable@vger.kernel.org
Signed-off-by: Chen, Junjia <junjia.chen@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/intel-xe/20261028161358.1917359-1-junjia.chen@intel.com/
(cherry picked from commit 3b8860fe2581a8db796150728687ba1c6b78ddab)
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/xe/xe_sync.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
--- a/drivers/gpu/drm/xe/xe_sync.c
+++ b/drivers/gpu/drm/xe/xe_sync.c
@@ -6,6 +6,7 @@
#include "xe_sync.h"
#include <linux/dma-fence-array.h>
+#include <linux/dma-fence-unwrap.h>
#include <linux/error-injection.h>
#include <linux/kthread.h>
#include <linux/sched/mm.h>
@@ -234,11 +235,35 @@ ALLOW_ERROR_INJECTION(xe_sync_entry_pars
int xe_sync_entry_add_deps(struct xe_sync_entry *sync, struct xe_sched_job *job)
{
- if (sync->fence)
- return drm_sched_job_add_dependency(&job->drm,
- dma_fence_get(sync->fence));
+ struct dma_fence_unwrap iter;
+ struct dma_fence *fence;
+ int err = 0;
- return 0;
+ if (!sync->fence)
+ return 0;
+
+ /*
+ * Unwrap fence containers (e.g. dma_fence_chain from a timeline
+ * syncobj) so the scheduler sees the underlying fences. That lets it
+ * drop dependencies on jobs from the same entity and only wait for
+ * jobs on the same scheduler to be scheduled, rather than waiting for
+ * the container, which forces a full GPU completion wait and drains
+ * the queue.
+ */
+ dma_fence_unwrap_for_each(fence, &iter, sync->fence) {
+ /*
+ * There is no dma_fence_unwrap_stop() helper to drop the
+ * reference the iterator holds, so keep iterating without
+ * doing anything once an error has occurred.
+ */
+ if (err || dma_fence_is_signaled(fence))
+ continue;
+
+ err = drm_sched_job_add_dependency(&job->drm,
+ dma_fence_get(fence));
+ }
+
+ return err;
}
/**
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 731/742] hwmon: (nct6775) Fix target temp and tolerance for NCT6106/6116/6126
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (714 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 730/742] drm/xe: Unwrap sync fences before adding them as job dependencies Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 732/742] i40e: fix freeing of TX rings on RX allocation failure Greg Kroah-Hartman
` (10 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Sashiko, Anton Lundin, Guenter Roeck,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <linux@roeck-us.net>
[ Upstream commit 73d857b33cdfaf35f8d3f833b36745d91c18db13 ]
In nct6775_probe(), the nct6106, nct6116, and nct6126 chip cases leave
target_temp_mask, tolerance_mask, and speed_tolerance_limit
zero-initialized.
As a result, reading pwm*_target_temp from sysfs always returns 0,
writing to pwm*_target_temp, pwm*_temp_tolerance,
pwm*_crit_temp_tolerance, or fan*_tolerance clamps user-supplied values
to 0, and pwm_update_registers() fails to clear existing tolerance bits
in REG_FAN_MODE when updating fan control modes.
Initialize target_temp_mask to 0xff, tolerance_mask to 0x07, and
speed_tolerance_limit to 63 for NCT6106, NCT6116, and NCT6126, matching
the hardware register layout shared with NCT5525 and NCT6776+.
Fixes: 6c009501ff20 ("hwmon: (nct6775) Add support for NCT6102D/6106D")
Fixes: 29c7cb485b32 ("hwmon: (nct6775) Integrate new model nct6116")
Fixes: 437b3c2a4bdc ("hwmon: (nct6775) Add support for NCT6126D")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-76f191d0-4c79-4982-887e-e5c9a2ed7136
Cc: Anton Lundin <glance@ac2.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
[ sashal: Applied the three target_temp/tolerance assignments to the nct6106 and nct6116 cases only, dropping the nct6126 hunk because this tree has no nct6126 support. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/hwmon/nct6775-core.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -3534,6 +3534,9 @@ int nct6775_probe(struct device *dev, st
data->fan_from_reg = fan_from_reg13;
data->fan_from_reg_min = fan_from_reg13;
+ data->target_temp_mask = 0xff;
+ data->tolerance_mask = 0x07;
+ data->speed_tolerance_limit = 63;
data->temp_label = nct6776_temp_label;
data->temp_mask = NCT6776_TEMP_MASK;
@@ -3610,6 +3613,9 @@ int nct6775_probe(struct device *dev, st
data->fan_from_reg = fan_from_reg13;
data->fan_from_reg_min = fan_from_reg13;
+ data->target_temp_mask = 0xff;
+ data->tolerance_mask = 0x07;
+ data->speed_tolerance_limit = 63;
data->temp_label = nct6776_temp_label;
data->temp_mask = NCT6776_TEMP_MASK;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 732/742] i40e: fix freeing of TX rings on RX allocation failure
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (715 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 731/742] hwmon: (nct6775) Fix target temp and tolerance for NCT6106/6116/6126 Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 733/742] i40e: avoid resetting BQL state when freeing temporary Tx rings in set_ringparam Greg Kroah-Hartman
` (9 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Filip Balluch, Aleksandr Loktionov,
Alexander Nowlin, Tony Nguyen, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filip Balluch <fballuch@redhat.com>
[ Upstream commit 4957f668681a2e1e2dab4731d75a2c53c6017319 ]
When ethtool -G is used to change ring buffer sizes while the interface is
up, i40e_set_ringparam() allocates temporary TX and RX rings. If the RX
ring allocation fails, the error path at the free_tx label incorrectly
calls i40e_free_tx_resources(vsi->tx_rings[i]), freeing the live TX rings
instead of the temporary tx_rings[i].
Since the interface is still up, the next TX completion interrupt causes
i40e_clean_tx_irq() to dereference the freed ring descriptors, resulting in
a NULL pointer dereference in IRQ context and a kernel panic.
This can be reproduced on systems with Intel X710 NICs under memory
pressure, where the second port's DMA allocation fails after the first port
succeeds.
Fix by freeing the temporary tx_rings[i] in the error path instead of
the live vsi->tx_rings[i].
Fixes: 74608d17fe29 ("i40e: add support for XDP_TX action")
Signed-off-by: Filip Balluch <fballuch@redhat.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Alexander Nowlin <alexander.nowlin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20261113004602.129864-3-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: e3916fa03f4d ("i40e: avoid resetting BQL state when freeing temporary Tx rings in set_ringparam")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -2249,7 +2249,7 @@ free_tx:
if (tx_rings) {
for (i = 0; i < tx_alloc_queue_pairs; i++) {
if (i40e_active_tx_ring_index(vsi, i))
- i40e_free_tx_resources(vsi->tx_rings[i]);
+ i40e_free_tx_resources(&tx_rings[i]);
}
kfree(tx_rings);
tx_rings = NULL;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 733/742] i40e: avoid resetting BQL state when freeing temporary Tx rings in set_ringparam
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (716 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 732/742] i40e: fix freeing of TX rings on RX allocation failure Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 734/742] landlock: Wrap per-layer access masks in struct layer_config Greg Kroah-Hartman
` (8 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Aleksandr Loktionov,
Alexander Nowlin, Tony Nguyen, Jakub Kicinski, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
[ Upstream commit e3916fa03f4d300be91468a7b7a608d38b6b3277 ]
Temporary Tx rings built by i40e_set_ringparam() while resizing
descriptor counts are shallow struct copies of the live vsi->tx_rings[]
entries, so they retain the same ring->netdev and ring->queue_index as
the live ring they are staged to replace.
If an error path frees one of these clones with
i40e_free_tx_resources() before i40e_down() has run - either the
i40e_setup_tx_descriptors() failure unwind loop, or the free_tx: error
label - i40e_clean_tx_ring() will call netdev_tx_reset_queue() on
txring_txq(tx_ring), which resolves to the *same* netdev_queue as the
live ring because netdev/queue_index alias. That call resets the
queue's BQL/dql state (dql_reset(): num_queued = num_completed = 0)
while the live ring is still actively transmitting and completing
Tx on that same queue.
The next time the live ring reports completions for bytes that were
queued before the reset, dql_completed() can underflow its own
sanity check and hit:
BUG_ON(count > num_queued - dql->num_completed);
i.e. a guaranteed kernel panic, not just a warning, given a queue with
outstanding (queued but not yet completed) Tx traffic at the moment
the clone is freed.
Reproduced on real hardware by forcing i40e_setup_tx_descriptors() to
fail partway through building tx_rings[] while flooding real Tx
traffic on the affected queues:
kernel BUG at lib/dynamic_queue_limits.c:99!
RIP: 0010:dql_completed+0x285/0x2a0
Call Trace:
<IRQ>
i40e_napi_poll+0x74b/0x1700 [i40e]
__napi_poll+0x10a/0x200
net_rx_action+0x2f7/0x380
handle_softirqs+0xcc/0x270
Confirmed the same trigger no longer panics with this fix applied,
including repeated resize/traffic cycles.
Clear the clone ring netdev before freeing it in both error paths, so
i40e_clean_tx_ring()'s existing `if (!tx_ring->netdev) return;` guard
skips the netdev_tx_reset_queue() call for the clone. This mirrors the
same idiom i40e already uses for XDP Tx rings, which also have no
netdev_queue of their own (ring->netdev = NULL in i40e_vsi_setup_tx()).
Only the temporary, about-to-be-freed clone is touched; the live ring
in vsi->tx_rings[] keeps its netdev.
Fixes: 9f65e15b4f98 ("i40e: Move rings from pointer to array to array of pointers")
Cc: stable@vger.kernel.org
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Alexander Nowlin <alexander.nowlin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://patch.msgid.link/20261113004602.129864-4-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -2143,6 +2143,8 @@ static int i40e_set_ringparam(struct net
i--;
if (!i40e_active_tx_ring_index(vsi, i))
continue;
+ /* not live yet, skip its BQL reset on free */
+ tx_rings[i].netdev = NULL;
i40e_free_tx_resources(&tx_rings[i]);
}
kfree(tx_rings);
@@ -2248,8 +2250,11 @@ free_tx:
/* error cleanup if the Rx allocations failed after getting Tx */
if (tx_rings) {
for (i = 0; i < tx_alloc_queue_pairs; i++) {
- if (i40e_active_tx_ring_index(vsi, i))
+ if (i40e_active_tx_ring_index(vsi, i)) {
+ /* not live yet, skip its BQL reset on free */
+ tx_rings[i].netdev = NULL;
i40e_free_tx_resources(&tx_rings[i]);
+ }
}
kfree(tx_rings);
tx_rings = NULL;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 734/742] landlock: Wrap per-layer access masks in struct layer_config
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (717 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 733/742] i40e: avoid resetting BQL state when freeing temporary Tx rings in set_ringparam Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:09 ` [PATCH 7.3 735/742] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER Greg Kroah-Hartman
` (7 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Günther Noack, Tingmao Wang,
Mickaël Salaün, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <mic@digikod.net>
[ Upstream commit 68ba67106a3c7529672b7f2189916442a1ee09b5 ]
The domain layer FAM stores struct access_masks values directly, while a
ruleset stores the equivalent single mutable value. Per-category
permissions need additional per-layer data beyond the handled-access
bitfields.
Introduce struct layer_config as the common value type. Keeping the
handled bitfields in its .handled member leaves struct access_masks as a
lightweight parameter type for functions that only need those bitfields,
while the complete layer can be snapshotted with one assignment.
At this point struct layer_config only wraps the four-byte access_masks,
so it does not grow the per-domain allocation: the maximum 16-entry FAM
remains 64 bytes.
No functional change.
Cc: Günther Noack <gnoack@google.com>
Reviewed-by: Günther Noack <gnoack@google.com>
Reviewed-by: Tingmao Wang <m@maowtm.org>
Link: https://patch.msgid.link/20261014082718.1435842-3-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Stable-dep-of: 0ad8ea7fa7dc ("landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/trace/events/landlock.h | 6 +++---
security/landlock/access.h | 32 +++++++++++++++++++++++---------
security/landlock/cred.h | 2 +-
security/landlock/domain.c | 10 +++++-----
security/landlock/domain.h | 29 ++++++++++++++---------------
security/landlock/fs.c | 2 +-
security/landlock/net.c | 2 +-
security/landlock/ruleset.c | 6 +++---
security/landlock/ruleset.h | 5 ++---
security/landlock/syscalls.c | 4 ++--
10 files changed, 55 insertions(+), 43 deletions(-)
--- a/include/trace/events/landlock.h
+++ b/include/trace/events/landlock.h
@@ -353,9 +353,9 @@ TRACE_EVENT(landlock_create_ruleset,
TP_fast_assign(
__entry->ruleset_id = ruleset->id;
__entry->ruleset_version = ruleset->version;
- __entry->handled_fs = ruleset->handled_masks.fs;
- __entry->handled_net = ruleset->handled_masks.net;
- __entry->scoped = ruleset->handled_masks.scope;
+ __entry->handled_fs = ruleset->layer.handled.fs;
+ __entry->handled_net = ruleset->layer.handled.net;
+ __entry->scoped = ruleset->layer.handled.scope;
),
TP_printk("ruleset=%llx.%llu handled_fs=%s handled_net=%s scoped=%s",
--- a/security/landlock/access.h
+++ b/security/landlock/access.h
@@ -19,9 +19,9 @@
/*
* All access rights that are denied by default whether they are handled or not
- * by a ruleset/layer. This must be ORed with all domain->handled_masks[]
- * entries when we need to get the absolute handled access masks, see
- * landlock_upgrade_handled_access_masks().
+ * by a ruleset/layer. This must be ORed with the .handled field of all
+ * domain->layers[] entries when we need to get the absolute handled access
+ * masks, see landlock_upgrade_handled_layer_config().
*/
/* clang-format off */
#define _LANDLOCK_ACCESS_FS_INITIALLY_DENIED ( \
@@ -45,7 +45,7 @@ static_assert(BITS_PER_TYPE(access_mask_
/* Makes sure for_each_set_bit() and for_each_clear_bit() calls are OK. */
static_assert(sizeof(unsigned long) >= sizeof(access_mask_t));
-/* Ruleset access masks. */
+/* Access masks (bitfields only). */
struct access_masks {
access_mask_t fs : LANDLOCK_NUM_ACCESS_FS;
access_mask_t net : LANDLOCK_NUM_ACCESS_NET;
@@ -61,6 +61,20 @@ union access_masks_all {
static_assert(sizeof(typeof_member(union access_masks_all, masks)) ==
sizeof(typeof_member(union access_masks_all, all)));
+/**
+ * struct layer_config - Per-layer access configuration
+ *
+ * A ruleset stores one mutable layer and a domain stores a flexible array of
+ * immutable layers.
+ */
+struct layer_config {
+ /**
+ * @handled: Bitmask of access rights handled (i.e. restricted) by this
+ * layer.
+ */
+ struct access_masks handled;
+};
+
#define _LANDLOCK_LAYER_MASK_PADDING \
(BITS_PER_TYPE(access_mask_t) - LANDLOCK_NUM_ACCESS_MAX - \
IS_ENABLED(CONFIG_SECURITY_LANDLOCK_LOG))
@@ -131,17 +145,17 @@ static_assert(BITS_PER_TYPE(deny_masks_t
static_assert(HWEIGHT(LANDLOCK_MAX_NUM_LAYERS) == 1);
/* Upgrades with all initially denied by default access rights. */
-static inline struct access_masks
-landlock_upgrade_handled_access_masks(struct access_masks access_masks)
+static inline struct layer_config
+landlock_upgrade_handled_layer_config(struct layer_config layer_config)
{
/*
* All access rights that are denied by default whether they are
* explicitly handled or not.
*/
- if (access_masks.fs)
- access_masks.fs |= _LANDLOCK_ACCESS_FS_INITIALLY_DENIED;
+ if (layer_config.handled.fs)
+ layer_config.handled.fs |= _LANDLOCK_ACCESS_FS_INITIALLY_DENIED;
- return access_masks;
+ return layer_config;
}
/* Checks the subset relation between access masks. */
--- a/security/landlock/cred.h
+++ b/security/landlock/cred.h
@@ -138,7 +138,7 @@ landlock_get_applicable_subject(const st
for (layer_level = domain->num_layers - 1; layer_level >= 0;
layer_level--) {
union access_masks_all layer = {
- .masks = domain->handled_masks[layer_level],
+ .masks = domain->layers[layer_level].handled,
};
if (layer.all & masks_all.all) {
--- a/security/landlock/domain.c
+++ b/security/landlock/domain.c
@@ -50,7 +50,7 @@ static struct landlock_domain *create_do
struct landlock_domain *new_domain;
build_check_domain();
- new_domain = kzalloc_flex(*new_domain, handled_masks, num_layers,
+ new_domain = kzalloc_flex(*new_domain, layers, num_layers,
GFP_KERNEL_ACCOUNT);
if (!new_domain)
return ERR_PTR(-ENOMEM);
@@ -328,8 +328,8 @@ static int merge_ruleset(struct landlock
if (WARN_ON_ONCE(dst->num_layers < 1))
return -EINVAL;
- dst->handled_masks[dst->num_layers - 1] =
- landlock_upgrade_handled_access_masks(src->handled_masks);
+ dst->layers[dst->num_layers - 1] =
+ landlock_upgrade_handled_layer_config(src->layer);
/* Merges the @src inode tree. */
err = merge_tree(dst, src, LANDLOCK_KEY_INODE);
@@ -404,8 +404,8 @@ static int inherit_ruleset(struct landlo
/*
* Copies the parent layer stack and leaves a space for the new layer.
*/
- memcpy(child->handled_masks, parent->handled_masks,
- flex_array_size(parent, handled_masks, parent->num_layers));
+ memcpy(child->layers, parent->layers,
+ flex_array_size(parent, layers, parent->num_layers));
if (WARN_ON_ONCE(!parent->hierarchy))
return -EINVAL;
--- a/security/landlock/domain.h
+++ b/security/landlock/domain.h
@@ -217,7 +217,7 @@ struct landlock_domain {
* @work_free: Enables to free a domain within a lockless
* section. This is only used by landlock_put_domain_deferred()
* when @usage reaches zero. The fields @usage, @num_layers and
- * @handled_masks are then unused.
+ * @layers are then unused.
*/
struct work_struct work_free;
struct {
@@ -233,15 +233,14 @@ struct landlock_domain {
*/
u32 num_layers;
/**
- * @handled_masks: Contains the subset of filesystem and
- * network actions that are restricted by a domain. A
- * domain saves all layers of merged rulesets in a stack
- * (FAM), starting from the first layer to the last one.
- * These layers are used when merging rulesets, for user
- * space backward compatibility (i.e. future-proof), and
- * to properly handle merged rulesets without
- * overlapping access rights. These layers are set once
- * and never changed for the lifetime of the domain.
+ * @layers: Per-layer access configuration. A domain
+ * saves all layers of merged rulesets in a stack (FAM),
+ * starting from the first layer to the last one. These
+ * layers are used when merging rulesets, for user space
+ * backward compatibility (i.e. future-proof), and to
+ * properly handle merged rulesets without overlapping
+ * access rights. These layers are set once and never
+ * changed for the lifetime of the domain.
*
* Not annotated with __counted_by(num_layers): clang
* miscomputes the counter address for a FAM nested in
@@ -249,7 +248,7 @@ struct landlock_domain {
* FORTIFY:
* https://github.com/llvm/llvm-project/pull/228309
*/
- struct access_masks handled_masks[];
+ struct layer_config layers[];
};
};
};
@@ -259,7 +258,7 @@ landlock_get_fs_access_mask(const struct
const u16 layer_level)
{
/* Handles all initially denied by default access rights. */
- return domain->handled_masks[layer_level].fs |
+ return domain->layers[layer_level].handled.fs |
_LANDLOCK_ACCESS_FS_INITIALLY_DENIED;
}
@@ -267,14 +266,14 @@ static inline access_mask_t
landlock_get_net_access_mask(const struct landlock_domain *const domain,
const u16 layer_level)
{
- return domain->handled_masks[layer_level].net;
+ return domain->layers[layer_level].handled.net;
}
static inline access_mask_t
landlock_get_scope_mask(const struct landlock_domain *const domain,
const u16 layer_level)
{
- return domain->handled_masks[layer_level].scope;
+ return domain->layers[layer_level].handled.scope;
}
/**
@@ -293,7 +292,7 @@ landlock_union_access_masks(const struct
for (layer_level = 0; layer_level < domain->num_layers; layer_level++) {
union access_masks_all layer = {
- .masks = domain->handled_masks[layer_level],
+ .masks = domain->layers[layer_level].handled,
};
matches.all |= layer.all;
--- a/security/landlock/fs.c
+++ b/security/landlock/fs.c
@@ -342,7 +342,7 @@ int landlock_append_fs_rule(struct landl
/* Transforms relative access rights to absolute ones. */
access_rights |= LANDLOCK_MASK_ACCESS_FS &
- ~(ruleset->handled_masks.fs |
+ ~(ruleset->layer.handled.fs |
_LANDLOCK_ACCESS_FS_INITIALLY_DENIED);
id.key.object = get_inode_object(d_backing_inode(path->dentry));
if (IS_ERR(id.key.object))
--- a/security/landlock/net.c
+++ b/security/landlock/net.c
@@ -35,7 +35,7 @@ int landlock_append_net_rule(struct land
BUILD_BUG_ON(sizeof(port) > sizeof(id.key.data));
/* Transforms relative access rights to absolute ones. */
- access_rights |= LANDLOCK_MASK_ACCESS_NET & ~ruleset->handled_masks.net;
+ access_rights |= LANDLOCK_MASK_ACCESS_NET & ~ruleset->layer.handled.net;
mutex_lock(&ruleset->lock);
err = landlock_insert_rule(ruleset, id, access_rights, flags);
--- a/security/landlock/ruleset.c
+++ b/security/landlock/ruleset.c
@@ -64,20 +64,20 @@ landlock_create_ruleset(const access_mas
LANDLOCK_MASK_ACCESS_FS;
WARN_ON_ONCE(fs_access_mask != mask);
- new_ruleset->handled_masks.fs |= mask;
+ new_ruleset->layer.handled.fs |= mask;
}
if (net_access_mask) {
const access_mask_t mask = net_access_mask &
LANDLOCK_MASK_ACCESS_NET;
WARN_ON_ONCE(net_access_mask != mask);
- new_ruleset->handled_masks.net |= mask;
+ new_ruleset->layer.handled.net |= mask;
}
if (scope_mask) {
const access_mask_t mask = scope_mask & LANDLOCK_MASK_SCOPE;
WARN_ON_ONCE(scope_mask != mask);
- new_ruleset->handled_masks.scope |= mask;
+ new_ruleset->layer.handled.scope |= mask;
}
return new_ruleset;
}
--- a/security/landlock/ruleset.h
+++ b/security/landlock/ruleset.h
@@ -188,10 +188,9 @@ struct landlock_ruleset {
*/
struct access_masks quiet_masks;
/**
- * @handled_masks: Contains the subset of filesystem and network actions
- * that are handled by this ruleset.
+ * @layer: Access configuration for this ruleset's single mutable layer.
*/
- struct access_masks handled_masks;
+ struct layer_config layer;
};
struct landlock_ruleset *
--- a/security/landlock/syscalls.c
+++ b/security/landlock/syscalls.c
@@ -377,7 +377,7 @@ static int add_rule_path_beneath(struct
return -ENOMSG;
/* Checks that allowed_access matches the @ruleset constraints. */
- mask = ruleset->handled_masks.fs;
+ mask = ruleset->layer.handled.fs;
if ((path_beneath_attr.allowed_access | mask) != mask)
return -EINVAL;
@@ -418,7 +418,7 @@ static int add_rule_net_port(struct land
return -ENOMSG;
/* Checks that allowed_access matches the @ruleset constraints. */
- mask = ruleset->handled_masks.net;
+ mask = ruleset->layer.handled.net;
if ((net_port_attr.allowed_access | mask) != mask)
return -EINVAL;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 735/742] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (718 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 734/742] landlock: Wrap per-layer access masks in struct layer_config Greg Kroah-Hartman
@ 2026-12-04 10:09 ` Greg Kroah-Hartman
2026-12-04 10:10 ` [PATCH 7.3 736/742] ipvs: fix problems during connection deletion Greg Kroah-Hartman
` (6 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:09 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Dwi Siswanto, Günther Noack,
Mickaël Salaün, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Günther Noack <gnoack3000@gmail.com>
[ Upstream commit 0ad8ea7fa7dc0f0d0e45f7ed4933d5433dac4291 ]
In landlock_get_fs_access_mask(), only add the
LANDLOCK_ACCESS_FS_REFER right if any filesystem access rights are
handled at all. This prevents us from accidentally treating
non-filesystem layers as if they handled LANDLOCK_ACCESS_FS_REFER.
landlock_get_fs_access_mask() is used when initializing the layer
masks for doing access right checks, so this bug meant that we
unintentionally denied "refer" (e.g., link, rename) operations in
layered cases, where the same operation would have been accepted if
only either one of the two layers had been enforced. If the rulesets
individually allow an operation, the composition of these rulesets
should also allow it.
The bug only manifests as soon as one other layer handles filesystem
access rights. Otherwise, Landlock filesystem path walk is guarded by
an early exit for the case that no filesystem-enforcing layer exists.
Reported-by: Dwi Siswanto <me@dw1.io>
Closes: https://github.com/landlock-lsm/linux/issues/67
Closes: https://github.com/landlock-lsm/go-landlock/issues/66
Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect")
Cc: stable@vger.kernel.org
Signed-off-by: Günther Noack <gnoack3000@gmail.com>
Link: https://patch.msgid.link/20261113-b4-landlock-refer-nonfs-layer-v3-1-02d7e42bcdfd@gmail.com
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
security/landlock/domain.h | 13 ++++++++++---
security/landlock/errata/abi-4.h | 21 +++++++++++++++++++++
2 files changed, 31 insertions(+), 3 deletions(-)
--- a/security/landlock/domain.h
+++ b/security/landlock/domain.h
@@ -257,9 +257,16 @@ static inline access_mask_t
landlock_get_fs_access_mask(const struct landlock_domain *const domain,
const u16 layer_level)
{
- /* Handles all initially denied by default access rights. */
- return domain->layers[layer_level].handled.fs |
- _LANDLOCK_ACCESS_FS_INITIALLY_DENIED;
+ access_mask_t handled = domain->layers[layer_level].handled.fs;
+
+ /*
+ * Handles all initially denied by default access rights, but only for
+ * layers handling filesystem accesses.
+ */
+ if (handled)
+ handled |= _LANDLOCK_ACCESS_FS_INITIALLY_DENIED;
+
+ return handled;
}
static inline access_mask_t
--- a/security/landlock/errata/abi-4.h
+++ b/security/landlock/errata/abi-4.h
@@ -20,3 +20,24 @@
* that rely on these protocols while using Landlock network restrictions.
*/
LANDLOCK_ERRATUM(1)
+
+/**
+ * DOC: erratum_5
+ *
+ * Erratum 5: Denial of ``LANDLOCK_ACCESS_FS_REFER`` in layered domains
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * This fix addresses an issue where ``LANDLOCK_ACCESS_FS_REFER`` was implicitly
+ * handled in domain layers that handle no filesystem access rights.
+ *
+ * With this fix, a reparenting operation is allowed in a layered Landlock
+ * domain if and only if each layer, enforced on its own, would allow it.
+ *
+ * Impact:
+ *
+ * In kernels without this fix, if a domain combined a layer that handles
+ * filesystem access rights with a layer that doesn't, the resulting layered
+ * domain would deny all ``LANDLOCK_ACCESS_FS_REFER`` operations, even when the
+ * filesystem layer granted these operations with a rule.
+ */
+LANDLOCK_ERRATUM(5)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 736/742] ipvs: fix problems during connection deletion
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (719 preceding siblings ...)
2026-12-04 10:09 ` [PATCH 7.3 735/742] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER Greg Kroah-Hartman
@ 2026-12-04 10:10 ` Greg Kroah-Hartman
2026-12-04 10:10 ` [PATCH 7.3 737/742] ipvs: avoid stack overflow from recursive connection expiration Greg Kroah-Hartman
` (5 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:10 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Julian Anastasov, Pablo Neira Ayuso,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <ja@ssi.bg>
[ Upstream commit 5ae07c10854f7ac38da02e8313a59dfcfeb44a61 ]
Sashiko reports for problem when deleting connections.
If connection timer expires, its callback can not be
concurrently running but if connection is deleted
the callback can be running on another CPU even
after all references are released. Before now we
continued with the connection freeing, risking the
callback to access the deleted connection after it
is freed. As ip_vs_conn_del() runs under RCU lock
there is no risk for accessing a connection freed
by concurrent timer callback. As Sashiko warns, the
risk is present if normal connection expires and
tries to delete its cp->control chain with
ip_vs_conn_del_put() without holding a RCU read lock.
It is evident that as the pending timer and the
running timer callback do not hold reference for
the connection, there are races which is difficult
to avoid.
Change the connection refcounting as follows:
* the connection hashing does not take reference anymore
* new connection handoffs its reference to the timer
if started in __ip_vs_conn_put_timer(), to hold it
while it is pending.
* if user finds connection in hash table it gets reference
and can handoff this reference to the pending timer if
this timer is started in __ip_vs_conn_put_timer(),
otherwise puts its reference if the timer was already
pending which is the common case.
* the pending timer handoffs its reference to the
running timer callback implicitly. By this way, the
timer callback in the common case has the last reference.
In rare cases, while the timer callback is running and
before it changes refcnt from 1 to 0, other users can get
reference and to handoff it again to the pending timer
they arm. In this case, the expiration is deferred
for later time.
As result, cp->refcnt accounts all current connection
users and the pending and running timer.
Two paths can try to delete the connection: the
normal expiration path and ip_vs_conn_del() if it
successfully steals the connection reference from the
pending timer. refcount_dec_if_one() will tell us if
we were the last active user with no packets accessing
the connection and no pending/running timers.
Change ip_vs_conn_unlink() to directly unhash the
connection because when we are the last user the
connection's forwarding method can not change.
Use smp_acquire__after_ctrl_dep() after refcount_dec_if_one()
and before reading the connection fields.
ip_vs_conn_expire() does not need to call timer_delete()
anymore because the pending timer is already accounted
in refcnt.
Add explicit rcu_read_lock() while deleting the cp->control
chain to protect from concurrent timer callback for ct to
expire it before us and to cause use-after-free.
During such races, try to keep 0 in cp->timeout as it is
a request for deleting our cp->control chain immediately.
Make sure we do not send timeout 0 (seconds) in the
v1 sync message because the backup server will select some
large default value which is not desired for small timeouts.
Remove the smp_mb__before_atomic() call from __ip_vs_conn_put(),
it is from the atomic_dec() era, now refcount_dec() has
RELEASE semantics.
Link: https://sashiko.dev/#/patchset/cover.1789435989.git.zihanx%40nebusec.ai
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1790266803.git.zihanx%40nebusec.ai
Fixes: f9200a52eedf ("ipvs: avoid expiring many connections from timer")
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Stable-dep-of: d4e4cd04de2c ("ipvs: avoid stack overflow from recursive connection expiration")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/net/ip_vs.h | 1
net/netfilter/ipvs/ip_vs_conn.c | 99 +++++++++++++++++++++-------------------
net/netfilter/ipvs/ip_vs_sync.c | 2
3 files changed, 55 insertions(+), 47 deletions(-)
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -1687,7 +1687,6 @@ static inline bool __ip_vs_conn_get(stru
/* put back the conn without restarting its timer */
static inline void __ip_vs_conn_put(struct ip_vs_conn *cp)
{
- smp_mb__before_atomic();
refcount_dec(&cp->refcnt);
}
void ip_vs_conn_put(struct ip_vs_conn *cp);
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -293,7 +293,6 @@ static inline int ip_vs_conn_hash(struct
cp->flags |= IP_VS_CONN_F_HASHED;
WRITE_ONCE(cp->hn0.hash_key, hash_key);
WRITE_ONCE(cp->hn1.hash_key, hash_key2);
- refcount_inc(&cp->refcnt);
hlist_bl_add_head_rcu(&cp->hn0.node, head);
if (use2)
hlist_bl_add_head_rcu(&cp->hn1.node, head2);
@@ -319,11 +318,27 @@ static inline bool ip_vs_conn_unlink(str
struct hlist_bl_head *head, *head2;
u32 hash_key, hash_key2;
struct ip_vs_rht *t;
- bool ret = false;
bool use2;
+ /* No more users and no running/pending timer except us? */
+ if (!refcount_dec_if_one(&cp->refcnt))
+ return false;
+
+ /* The ONE_PACKET connection is special:
+ * - the flag is present only for normal connections, not for templates
+ * - its timer is never started
+ * - it is never hashed, so you can not find it and delete it
+ * - it is not synced
+ * - it has only one user
+ * - it is freed after use immediately
+ */
if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
- return refcount_dec_if_one(&cp->refcnt);
+ return true;
+
+ /* Add the needed ACQUIRE barrier between the above
+ * refcount_dec_if_one() call and the read of cp fields
+ */
+ smp_acquire__after_ctrl_dep();
rcu_read_lock();
local_bh_disable();
@@ -337,15 +352,11 @@ static inline bool ip_vs_conn_unlink(str
false /* new_hash2 */, &head, &head2);
if (cp->flags & IP_VS_CONN_F_HASHED) {
- /* Decrease refcnt and unlink conn only if we are last user */
- if (use2 == ip_vs_conn_use_hash2(cp) &&
- refcount_dec_if_one(&cp->refcnt)) {
- hlist_bl_del_rcu(&cp->hn0.node);
- if (use2)
- hlist_bl_del_rcu(&cp->hn1.node);
- cp->flags &= ~IP_VS_CONN_F_HASHED;
- ret = true;
- }
+ /* Unlink conn as we are the last user */
+ hlist_bl_del_rcu(&cp->hn0.node);
+ if (use2)
+ hlist_bl_del_rcu(&cp->hn1.node);
+ cp->flags &= ~IP_VS_CONN_F_HASHED;
}
conn_tab_unlock(head, head2);
@@ -353,7 +364,7 @@ static inline bool ip_vs_conn_unlink(str
local_bh_enable();
rcu_read_unlock();
- return ret;
+ return true;
}
@@ -623,9 +634,12 @@ static void __ip_vs_conn_put_timer(struc
{
unsigned long t = (cp->flags & IP_VS_CONN_F_ONE_PACKET) ?
0 : cp->timeout;
- mod_timer(&cp->timer, jiffies+t);
- __ip_vs_conn_put(cp);
+ /* Handoff our reference to the timer if it was just armed,
+ * put the reference if timer was already pending.
+ */
+ if (mod_timer(&cp->timer, jiffies + t))
+ __ip_vs_conn_put(cp);
}
void ip_vs_conn_put(struct ip_vs_conn *cp)
@@ -1324,9 +1338,18 @@ static void ip_vs_conn_rcu_free(struct r
kmem_cache_free(ip_vs_conn_cachep, cp);
}
-/* Try to delete connection while not holding reference */
+/* Try to delete connection while not holding reference.
+ * It can be called concurrently and always under RCU lock
+ * to protect from connection deletion from others.
+ * Used when we need to remove the connection immediately
+ * and without overloading the timer processing.
+ * OTOH, we use ip_vs_conn_expire_now() when we prefer to
+ * leave the current context (packet processing) and to
+ * remove the connection from timer.
+ */
static void ip_vs_conn_del(struct ip_vs_conn *cp)
{
+ /* Steal reference from the pending timer */
if (timer_delete(&cp->timer)) {
/* Drop cp->control chain too */
if (cp->control)
@@ -1335,20 +1358,11 @@ static void ip_vs_conn_del(struct ip_vs_
}
}
-/* Try to delete connection while holding reference */
-static void ip_vs_conn_del_put(struct ip_vs_conn *cp)
-{
- if (timer_delete(&cp->timer)) {
- /* Drop cp->control chain too */
- if (cp->control)
- cp->timeout = 0;
- __ip_vs_conn_put(cp);
- ip_vs_conn_expire(&cp->timer);
- } else {
- __ip_vs_conn_put(cp);
- }
-}
-
+/* Connection is removed in the following steps:
+ * - timer expires (with ref) or connection is deleted (with stolen ref)
+ * - there should be no more users except us (pending/running timer,
+ * n_control>0 or refcnt>1)
+ */
static void ip_vs_conn_expire(struct timer_list *t)
{
struct ip_vs_conn *cp = timer_container_of(cp, t, timer);
@@ -1364,23 +1378,18 @@ static void ip_vs_conn_expire(struct tim
if (likely(ip_vs_conn_unlink(cp))) {
struct ip_vs_conn *ct = cp->control;
- /* delete the timer if it is activated by other users */
- timer_delete(&cp->timer);
-
/* does anybody control me? */
if (ct) {
- bool has_ref = !cp->timeout && __ip_vs_conn_get(ct);
-
+ rcu_read_lock();
ip_vs_control_del(cp);
/* Drop CTL or non-assured TPL if not used anymore */
- if (has_ref && !atomic_read(&ct->n_control) &&
+ if (!cp->timeout && !atomic_read(&ct->n_control) &&
(!(ct->flags & IP_VS_CONN_F_TEMPLATE) ||
!(ct->state & IP_VS_CTPL_S_ASSURED))) {
IP_VS_DBG(4, "drop controlling connection\n");
- ip_vs_conn_del_put(ct);
- } else if (has_ref) {
- __ip_vs_conn_put(ct);
+ ip_vs_conn_del(ct);
}
+ rcu_read_unlock();
}
if ((cp->flags & IP_VS_CONN_F_NFCT) &&
@@ -1415,8 +1424,8 @@ static void ip_vs_conn_expire(struct tim
refcount_read(&cp->refcnt),
atomic_read(&cp->n_control));
- refcount_inc(&cp->refcnt);
- cp->timeout = 60*HZ;
+ if (cp->timeout || atomic_read(&cp->n_control))
+ cp->timeout = 60 * HZ;
if (ipvs->sync_state & IP_VS_STATE_MASTER)
ip_vs_sync_conn(ipvs, cp, sysctl_sync_threshold(ipvs));
@@ -1434,7 +1443,7 @@ static void ip_vs_conn_expire(struct tim
void ip_vs_conn_expire_now(struct ip_vs_conn *cp)
{
/* Using mod_timer_pending will ensure the timer is not
- * modified after the final timer_delete in ip_vs_conn_expire.
+ * started without giving it new reference.
*/
if (timer_pending(&cp->timer) &&
time_after(cp->timer.expires, jiffies))
@@ -1502,9 +1511,9 @@ ip_vs_conn_new(const struct ip_vs_conn_p
spin_lock_init(&cp->lock);
/*
- * Set the entry is referenced by the current thread before hashing
- * it in the table, so that other thread run ip_vs_random_dropentry
- * but cannot drop this entry.
+ * Set the entry as referenced by the current thread before starting
+ * the timer and giving it our reference to allow other threads to
+ * run ip_vs_random_dropentry() or any deletion method safely.
*/
refcount_set(&cp->refcnt, 1);
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -749,7 +749,7 @@ sloop:
s->v4.vport = cp->vport;
s->v4.dport = cp->dport;
s->v4.fwmark = htonl(cp->fwmark);
- s->v4.timeout = htonl(cp->timeout / HZ);
+ s->v4.timeout = htonl(max(1UL, cp->timeout / HZ));
m->nr_conns++;
#ifdef CONFIG_IP_VS_IPV6
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 737/742] ipvs: avoid stack overflow from recursive connection expiration
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (720 preceding siblings ...)
2026-12-04 10:10 ` [PATCH 7.3 736/742] ipvs: fix problems during connection deletion Greg Kroah-Hartman
@ 2026-12-04 10:10 ` Greg Kroah-Hartman
2026-12-04 10:10 ` [PATCH 7.3 738/742] riscv: convert pgtable_l4|l5_enabled to inline function Greg Kroah-Hartman
` (4 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:10 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Vega, Luxing Yin, Zihan Xi,
Julian Anastasov, Pablo Neira Ayuso, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zihan Xi <zihanx@nebusec.ai>
[ Upstream commit d4e4cd04de2c47ed05f837a26edd20c56be3f097 ]
When a controlled IPVS connection expires, its controller may be expired
synchronously if it has no remaining controlled connections. A chain of
controlled connections can then recurse through ip_vs_conn_expire() and
exhaust the kernel stack during namespace cleanup.
Continue expiration with the controller after the current connection has
been fully cleaned up instead of calling ip_vs_conn_del() recursively. Keep
the expiration walk under RCU, preserve the immediate-drop timeout for a
controller with its own controller, and switch to deletion mode before the
next iteration.
This keeps controlled-connection cleanup synchronous while using one stack
frame for the whole chain. The timer callback race during connection
deletion is handled by the preceding connection-deletion fix.
This patch depends on "ipvs: fix problems during connection deletion" to
protect the iterative controller cleanup from the timer callback race.
Fixes: f9200a52eedf ("ipvs: avoid expiring many connections from timer")
Cc: stable@vger.kernel.org
Reported-by: Vega <vega@nebusec.ai>
Co-developed-by: Luxing Yin <root@tr0jan.top>
Signed-off-by: Luxing Yin <root@tr0jan.top>
Signed-off-by: Zihan Xi <zihanx@nebusec.ai>
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/netfilter/ipvs/ip_vs_conn.c | 40 +++++++++++++++++++++++++++++-----------
1 file changed, 29 insertions(+), 11 deletions(-)
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -1338,9 +1338,23 @@ static void ip_vs_conn_rcu_free(struct r
kmem_cache_free(ip_vs_conn_cachep, cp);
}
-/* Try to delete connection while not holding reference.
+/* Try to steal the reference from the pending timer.
* It can be called concurrently and always under RCU lock
* to protect from connection deletion from others.
+ */
+static bool ip_vs_conn_del_reference(struct ip_vs_conn *cp)
+{
+ /* Steal reference from the pending timer */
+ if (!timer_delete(&cp->timer))
+ return false;
+
+ /* Drop cp->control chain too */
+ if (cp->control)
+ cp->timeout = 0;
+ return true;
+}
+
+/* Try to delete connection while not holding reference.
* Used when we need to remove the connection immediately
* and without overloading the timer processing.
* OTOH, we use ip_vs_conn_expire_now() when we prefer to
@@ -1349,13 +1363,8 @@ static void ip_vs_conn_rcu_free(struct r
*/
static void ip_vs_conn_del(struct ip_vs_conn *cp)
{
- /* Steal reference from the pending timer */
- if (timer_delete(&cp->timer)) {
- /* Drop cp->control chain too */
- if (cp->control)
- cp->timeout = 0;
+ if (ip_vs_conn_del_reference(cp))
ip_vs_conn_expire(&cp->timer);
- }
}
/* Connection is removed in the following steps:
@@ -1368,6 +1377,9 @@ static void ip_vs_conn_expire(struct tim
struct ip_vs_conn *cp = timer_container_of(cp, t, timer);
struct netns_ipvs *ipvs = cp->ipvs;
+ rcu_read_lock();
+
+repeat:
/*
* do I control anybody?
*/
@@ -1377,19 +1389,18 @@ static void ip_vs_conn_expire(struct tim
/* Unlink conn if not referenced anymore */
if (likely(ip_vs_conn_unlink(cp))) {
struct ip_vs_conn *ct = cp->control;
+ bool next = false;
/* does anybody control me? */
if (ct) {
- rcu_read_lock();
ip_vs_control_del(cp);
/* Drop CTL or non-assured TPL if not used anymore */
if (!cp->timeout && !atomic_read(&ct->n_control) &&
(!(ct->flags & IP_VS_CONN_F_TEMPLATE) ||
!(ct->state & IP_VS_CTPL_S_ASSURED))) {
IP_VS_DBG(4, "drop controlling connection\n");
- ip_vs_conn_del(ct);
+ next = ip_vs_conn_del_reference(ct);
}
- rcu_read_unlock();
}
if ((cp->flags & IP_VS_CONN_F_NFCT) &&
@@ -1416,7 +1427,11 @@ static void ip_vs_conn_expire(struct tim
else
call_rcu(&cp->rcu_head, ip_vs_conn_rcu_free);
atomic_dec(&ipvs->conn_count);
- return;
+ if (next) {
+ cp = ct;
+ goto repeat;
+ }
+ goto out;
}
expire_later:
@@ -1431,6 +1446,9 @@ static void ip_vs_conn_expire(struct tim
ip_vs_sync_conn(ipvs, cp, sysctl_sync_threshold(ipvs));
__ip_vs_conn_put_timer(cp);
+
+out:
+ rcu_read_unlock();
}
/* Modify timer, so that it expires as soon as possible.
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 738/742] riscv: convert pgtable_l4|l5_enabled to inline function
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (721 preceding siblings ...)
2026-12-04 10:10 ` [PATCH 7.3 737/742] ipvs: avoid stack overflow from recursive connection expiration Greg Kroah-Hartman
@ 2026-12-04 10:10 ` Greg Kroah-Hartman
2026-12-04 10:10 ` [PATCH 7.3 739/742] riscv/mm: fix hotplug page-table destructor handling Greg Kroah-Hartman
` (3 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:10 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Jisheng Zhang, Paul Walmsley,
Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jisheng Zhang <jszhang@kernel.org>
[ Upstream commit 79113093e9dc3330a05cfd9b9bca1294bc8d2fa8 ]
This is the preparation of optimizing pgtable_l4|l5_enabled(). No
functionality change.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
Link: https://patch.msgid.link/20261008150045.28905-3-jszhang@kernel.org
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Stable-dep-of: 352fca06aa69 ("riscv/mm: fix hotplug page-table destructor handling")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/riscv/include/asm/pgalloc.h | 14 +++----
arch/riscv/include/asm/pgtable-32.h | 4 +-
arch/riscv/include/asm/pgtable-64.h | 50 ++++++++++++++++------------
arch/riscv/include/asm/pgtable.h | 4 +-
arch/riscv/include/asm/vmalloc.h | 5 +-
arch/riscv/kernel/cpu.c | 4 +-
arch/riscv/mm/init.c | 64 ++++++++++++++++++------------------
arch/riscv/mm/kasan_init.c | 20 +++++------
arch/riscv/mm/pgtable.c | 4 +-
arch/riscv/mm/ptdump.c | 4 +-
10 files changed, 91 insertions(+), 82 deletions(-)
--- a/arch/riscv/include/asm/pgalloc.h
+++ b/arch/riscv/include/asm/pgalloc.h
@@ -41,7 +41,7 @@ static inline void pud_populate(struct m
static inline void p4d_populate(struct mm_struct *mm, p4d_t *p4d, pud_t *pud)
{
- if (pgtable_l4_enabled) {
+ if (pgtable_l4_enabled()) {
unsigned long pfn = virt_to_pfn(pud);
set_p4d(p4d, __p4d((pfn << _PAGE_PFN_SHIFT) | _PAGE_TABLE));
@@ -51,7 +51,7 @@ static inline void p4d_populate(struct m
static inline void p4d_populate_safe(struct mm_struct *mm, p4d_t *p4d,
pud_t *pud)
{
- if (pgtable_l4_enabled) {
+ if (pgtable_l4_enabled()) {
unsigned long pfn = virt_to_pfn(pud);
set_p4d_safe(p4d,
@@ -61,7 +61,7 @@ static inline void p4d_populate_safe(str
static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, p4d_t *p4d)
{
- if (pgtable_l5_enabled) {
+ if (pgtable_l5_enabled()) {
unsigned long pfn = virt_to_pfn(p4d);
set_pgd(pgd, __pgd((pfn << _PAGE_PFN_SHIFT) | _PAGE_TABLE));
@@ -71,7 +71,7 @@ static inline void pgd_populate(struct m
static inline void pgd_populate_safe(struct mm_struct *mm, pgd_t *pgd,
p4d_t *p4d)
{
- if (pgtable_l5_enabled) {
+ if (pgtable_l5_enabled()) {
unsigned long pfn = virt_to_pfn(p4d);
set_pgd_safe(pgd,
@@ -82,21 +82,21 @@ static inline void pgd_populate_safe(str
#define pud_free pud_free
static inline void pud_free(struct mm_struct *mm, pud_t *pud)
{
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
__pud_free(mm, pud);
}
static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud,
unsigned long addr)
{
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
tlb_remove_ptdesc(tlb, virt_to_ptdesc(pud));
}
static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d,
unsigned long addr)
{
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
tlb_remove_ptdesc(tlb, virt_to_ptdesc(p4d));
}
#endif /* __PAGETABLE_PMD_FOLDED */
--- a/arch/riscv/include/asm/pgtable-32.h
+++ b/arch/riscv/include/asm/pgtable-32.h
@@ -33,7 +33,7 @@
_PAGE_WRITE | _PAGE_EXEC | \
_PAGE_USER | _PAGE_GLOBAL))
-static const __maybe_unused int pgtable_l4_enabled;
-static const __maybe_unused int pgtable_l5_enabled;
+static inline bool pgtable_l4_enabled(void) { return false; }
+static inline bool pgtable_l5_enabled(void) { return false; }
#endif /* _ASM_RISCV_PGTABLE_32_H */
--- a/arch/riscv/include/asm/pgtable-64.h
+++ b/arch/riscv/include/asm/pgtable-64.h
@@ -10,14 +10,24 @@
#include <linux/const.h>
#include <asm/errata_list.h>
-extern bool pgtable_l4_enabled;
-extern bool pgtable_l5_enabled;
+extern bool _pgtable_l4_enabled;
+extern bool _pgtable_l5_enabled;
+
+static __always_inline bool pgtable_l5_enabled(void)
+{
+ return _pgtable_l5_enabled;
+}
+
+static __always_inline bool pgtable_l4_enabled(void)
+{
+ return _pgtable_l4_enabled;
+}
#define PGDIR_SHIFT_L3 30
#define PGDIR_SHIFT_L4 39
#define PGDIR_SHIFT_L5 48
-#define PGDIR_SHIFT (pgtable_l5_enabled ? PGDIR_SHIFT_L5 : \
- (pgtable_l4_enabled ? PGDIR_SHIFT_L4 : PGDIR_SHIFT_L3))
+#define PGDIR_SHIFT (pgtable_l5_enabled() ? PGDIR_SHIFT_L5 : \
+ (pgtable_l4_enabled() ? PGDIR_SHIFT_L4 : PGDIR_SHIFT_L3))
/* Size of region mapped by a page global directory */
#define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT)
#define PGDIR_MASK (~(PGDIR_SIZE - 1))
@@ -26,8 +36,8 @@ extern bool pgtable_l5_enabled;
#define P4D_SHIFT_L3 30
#define P4D_SHIFT_L4 39
#define P4D_SHIFT_L5 39
-#define P4D_SHIFT (pgtable_l5_enabled ? P4D_SHIFT_L5 : \
- (pgtable_l4_enabled ? P4D_SHIFT_L4 : P4D_SHIFT_L3))
+#define P4D_SHIFT (pgtable_l5_enabled() ? P4D_SHIFT_L5 : \
+ (pgtable_l4_enabled() ? P4D_SHIFT_L4 : P4D_SHIFT_L3))
#define P4D_SIZE (_AC(1, UL) << P4D_SHIFT)
#define P4D_MASK (~(P4D_SIZE - 1))
@@ -233,7 +243,7 @@ static inline struct page *pud_page(pud_
#define mm_p4d_folded mm_p4d_folded
static inline bool mm_p4d_folded(struct mm_struct *mm)
{
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
return false;
return true;
@@ -242,7 +252,7 @@ static inline bool mm_p4d_folded(struct
#define mm_pud_folded mm_pud_folded
static inline bool mm_pud_folded(struct mm_struct *mm)
{
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
return false;
return true;
@@ -275,7 +285,7 @@ static inline unsigned long _pmd_pfn(pmd
static inline void set_p4d(p4d_t *p4dp, p4d_t p4d)
{
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
WRITE_ONCE(*p4dp, p4d);
else
set_pud((pud_t *)p4dp, (pud_t){ p4d_val(p4d) });
@@ -283,7 +293,7 @@ static inline void set_p4d(p4d_t *p4dp,
static inline int p4d_none(p4d_t p4d)
{
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
return (p4d_val(p4d) == 0);
return 0;
@@ -291,7 +301,7 @@ static inline int p4d_none(p4d_t p4d)
static inline int p4d_present(p4d_t p4d)
{
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
return (p4d_val(p4d) & _PAGE_PRESENT);
return 1;
@@ -299,7 +309,7 @@ static inline int p4d_present(p4d_t p4d)
static inline int p4d_bad(p4d_t p4d)
{
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
return !p4d_present(p4d);
return 0;
@@ -307,7 +317,7 @@ static inline int p4d_bad(p4d_t p4d)
static inline void p4d_clear(p4d_t *p4d)
{
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
set_p4d(p4d, __p4d(0));
}
@@ -323,7 +333,7 @@ static inline unsigned long _p4d_pfn(p4d
static inline pud_t *p4d_pgtable(p4d_t p4d)
{
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
return (pud_t *)pfn_to_virt(__page_val_to_pfn(p4d_val(p4d)));
return (pud_t *)pud_pgtable((pud_t) { p4d_val(p4d) });
@@ -342,7 +352,7 @@ pud_t *pud_offset(p4d_t *p4d, unsigned l
static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
{
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
WRITE_ONCE(*pgdp, pgd);
else
set_p4d((p4d_t *)pgdp, (p4d_t){ pgd_val(pgd) });
@@ -350,7 +360,7 @@ static inline void set_pgd(pgd_t *pgdp,
static inline int pgd_none(pgd_t pgd)
{
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
return (pgd_val(pgd) == 0);
return 0;
@@ -358,7 +368,7 @@ static inline int pgd_none(pgd_t pgd)
static inline int pgd_present(pgd_t pgd)
{
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
return (pgd_val(pgd) & _PAGE_PRESENT);
return 1;
@@ -366,7 +376,7 @@ static inline int pgd_present(pgd_t pgd)
static inline int pgd_bad(pgd_t pgd)
{
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
return !pgd_present(pgd);
return 0;
@@ -374,13 +384,13 @@ static inline int pgd_bad(pgd_t pgd)
static inline void pgd_clear(pgd_t *pgd)
{
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
set_pgd(pgd, __pgd(0));
}
static inline p4d_t *pgd_pgtable(pgd_t pgd)
{
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
return (p4d_t *)pfn_to_virt(__page_val_to_pfn(pgd_val(pgd)));
return (p4d_t *)p4d_pgtable((p4d_t) { pgd_val(pgd) });
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -75,8 +75,8 @@
#define VA_BITS_SV48 48
#define VA_BITS_SV57 57
-#define VA_BITS (pgtable_l5_enabled ? \
- VA_BITS_SV57 : (pgtable_l4_enabled ? VA_BITS_SV48 : VA_BITS_SV39))
+#define VA_BITS (pgtable_l5_enabled() ? \
+ VA_BITS_SV57 : (pgtable_l4_enabled() ? VA_BITS_SV48 : VA_BITS_SV39))
#else
#define VA_BITS VA_BITS_SV32
#endif
--- a/arch/riscv/include/asm/vmalloc.h
+++ b/arch/riscv/include/asm/vmalloc.h
@@ -3,15 +3,14 @@
#define _ASM_RISCV_VMALLOC_H
#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
-
-extern bool pgtable_l4_enabled, pgtable_l5_enabled;
+#include <asm/pgtable.h>
#define IOREMAP_MAX_ORDER (PUD_SHIFT)
#define arch_vmap_pud_supported arch_vmap_pud_supported
static inline bool arch_vmap_pud_supported(pgprot_t prot)
{
- return pgtable_l4_enabled || pgtable_l5_enabled;
+ return pgtable_l4_enabled() || pgtable_l5_enabled();
}
#define arch_vmap_pmd_supported arch_vmap_pmd_supported
--- a/arch/riscv/kernel/cpu.c
+++ b/arch/riscv/kernel/cpu.c
@@ -292,9 +292,9 @@ static void print_mmu(struct seq_file *f
#if defined(CONFIG_32BIT)
sv_type = "sv32";
#elif defined(CONFIG_64BIT)
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
sv_type = "sv57";
- else if (pgtable_l4_enabled)
+ else if (pgtable_l4_enabled())
sv_type = "sv48";
else
sv_type = "sv39";
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -52,10 +52,10 @@ u64 satp_mode __ro_after_init = SATP_MOD
EXPORT_SYMBOL(satp_mode);
#ifdef CONFIG_64BIT
-bool pgtable_l4_enabled __ro_after_init = true;
-bool pgtable_l5_enabled __ro_after_init = true;
-EXPORT_SYMBOL(pgtable_l4_enabled);
-EXPORT_SYMBOL(pgtable_l5_enabled);
+bool _pgtable_l4_enabled __ro_after_init = true;
+bool _pgtable_l5_enabled __ro_after_init = true;
+EXPORT_SYMBOL(_pgtable_l4_enabled);
+EXPORT_SYMBOL(_pgtable_l5_enabled);
#endif
phys_addr_t phys_ram_base __ro_after_init;
@@ -652,23 +652,23 @@ static void __meminit create_p4d_mapping
}
#define pgd_next_t p4d_t
-#define alloc_pgd_next(__va) (pgtable_l5_enabled ? \
- pt_ops.alloc_p4d(__va) : (pgtable_l4_enabled ? \
+#define alloc_pgd_next(__va) (pgtable_l5_enabled() ? \
+ pt_ops.alloc_p4d(__va) : (pgtable_l4_enabled() ? \
pt_ops.alloc_pud(__va) : pt_ops.alloc_pmd(__va)))
-#define get_pgd_next_virt(__pa) (pgtable_l5_enabled ? \
- pt_ops.get_p4d_virt(__pa) : (pgd_next_t *)(pgtable_l4_enabled ? \
+#define get_pgd_next_virt(__pa) (pgtable_l5_enabled() ? \
+ pt_ops.get_p4d_virt(__pa) : (pgd_next_t *)(pgtable_l4_enabled() ? \
pt_ops.get_pud_virt(__pa) : (pud_t *)pt_ops.get_pmd_virt(__pa)))
#define create_pgd_next_mapping(__nextp, __va, __pa, __sz, __prot) \
- (pgtable_l5_enabled ? \
+ (pgtable_l5_enabled() ? \
create_p4d_mapping(__nextp, __va, __pa, __sz, __prot) : \
- (pgtable_l4_enabled ? \
+ (pgtable_l4_enabled() ? \
create_pud_mapping((pud_t *)__nextp, __va, __pa, __sz, __prot) : \
create_pmd_mapping((pmd_t *)__nextp, __va, __pa, __sz, __prot)))
-#define fixmap_pgd_next (pgtable_l5_enabled ? \
- (uintptr_t)fixmap_p4d : (pgtable_l4_enabled ? \
+#define fixmap_pgd_next (pgtable_l5_enabled() ? \
+ (uintptr_t)fixmap_p4d : (pgtable_l4_enabled() ? \
(uintptr_t)fixmap_pud : (uintptr_t)fixmap_pmd))
-#define trampoline_pgd_next (pgtable_l5_enabled ? \
- (uintptr_t)trampoline_p4d : (pgtable_l4_enabled ? \
+#define trampoline_pgd_next (pgtable_l5_enabled() ? \
+ (uintptr_t)trampoline_p4d : (pgtable_l4_enabled() ? \
(uintptr_t)trampoline_pud : (uintptr_t)trampoline_pmd))
#else
#define pgd_next_t pte_t
@@ -713,11 +713,11 @@ static uintptr_t __meminit best_map_size
if (debug_pagealloc_enabled())
return PAGE_SIZE;
- if (pgtable_l5_enabled &&
+ if (pgtable_l5_enabled() &&
!(pa & (P4D_SIZE - 1)) && !(va & (P4D_SIZE - 1)) && size >= P4D_SIZE)
return P4D_SIZE;
- if (pgtable_l4_enabled &&
+ if (pgtable_l4_enabled() &&
!(pa & (PUD_SIZE - 1)) && !(va & (PUD_SIZE - 1)) && size >= PUD_SIZE)
return PUD_SIZE;
@@ -769,14 +769,14 @@ u64 __pi_set_satp_mode_from_fdt(uintptr_
static void __init disable_pgtable_l5(void)
{
- pgtable_l5_enabled = false;
+ _pgtable_l5_enabled = false;
kernel_map.page_offset = PAGE_OFFSET_L4;
satp_mode = SATP_MODE_48;
}
static void __init disable_pgtable_l4(void)
{
- pgtable_l4_enabled = false;
+ _pgtable_l4_enabled = false;
kernel_map.page_offset = PAGE_OFFSET_L3;
satp_mode = SATP_MODE_39;
}
@@ -867,7 +867,7 @@ retry:
create_pgd_mapping(early_pg_dir,
set_satp_mode_pmd,
- pgtable_l5_enabled ?
+ pgtable_l5_enabled() ?
(uintptr_t)early_p4d : (uintptr_t)early_pud,
PGDIR_SIZE, PAGE_TABLE);
@@ -879,7 +879,7 @@ retry:
local_flush_tlb_all();
if (hw_satp != identity_satp) {
- if (pgtable_l5_enabled) {
+ if (pgtable_l5_enabled()) {
disable_pgtable_l5();
memset(early_pg_dir, 0, PAGE_SIZE);
goto retry;
@@ -1120,11 +1120,11 @@ asmlinkage void __init setup_vm(uintptr_
#ifndef __PAGETABLE_PMD_FOLDED
/* Setup fixmap P4D and PUD */
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
create_p4d_mapping(fixmap_p4d, FIXADDR_START,
(uintptr_t)fixmap_pud, P4D_SIZE, PAGE_TABLE);
/* Setup fixmap PUD and PMD */
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
create_pud_mapping(fixmap_pud, FIXADDR_START,
(uintptr_t)fixmap_pmd, PUD_SIZE, PAGE_TABLE);
create_pmd_mapping(fixmap_pmd, FIXADDR_START,
@@ -1132,10 +1132,10 @@ asmlinkage void __init setup_vm(uintptr_
/* Setup trampoline PGD and PMD */
create_pgd_mapping(trampoline_pg_dir, kernel_map.virt_addr,
trampoline_pgd_next, PGDIR_SIZE, PAGE_TABLE);
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
create_p4d_mapping(trampoline_p4d, kernel_map.virt_addr,
(uintptr_t)trampoline_pud, P4D_SIZE, PAGE_TABLE);
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
create_pud_mapping(trampoline_pud, kernel_map.virt_addr,
(uintptr_t)trampoline_pmd, PUD_SIZE, PAGE_TABLE);
create_pmd_mapping(trampoline_pmd, kernel_map.virt_addr,
@@ -1406,7 +1406,7 @@ static void __init preallocate_pgd_pages
if (!p4d)
goto failed;
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
continue;
lvl = "pud";
@@ -1414,7 +1414,7 @@ static void __init preallocate_pgd_pages
if (!pud)
goto failed;
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
continue;
lvl = "pmd";
@@ -1626,13 +1626,13 @@ static void __meminit remove_pud_mapping
for (; addr < end; addr = next) {
next = pud_addr_end(addr, end);
- pudp = pgtable_l4_enabled ? pud_base + pud_index(addr) : pud_base;
+ pudp = pgtable_l4_enabled() ? pud_base + pud_index(addr) : pud_base;
pud = pudp_get(pudp);
if (!pud_present(pud))
continue;
if (pud_leaf(pud)) {
- if (pgtable_l4_enabled) {
+ if (pgtable_l4_enabled()) {
pud_clear(pudp);
if (is_vmemmap)
free_vmemmap_storage(pud_page(pud), PUD_SIZE, altmap);
@@ -1643,7 +1643,7 @@ static void __meminit remove_pud_mapping
pmd_base = pmd_offset(pudp, 0);
remove_pmd_mapping(pmd_base, addr, next, is_vmemmap, altmap);
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
free_pmd_table(pmd_base, pudp, is_vmemmap);
}
}
@@ -1657,13 +1657,13 @@ static void __meminit remove_p4d_mapping
for (; addr < end; addr = next) {
next = p4d_addr_end(addr, end);
- p4dp = pgtable_l5_enabled ? p4d_base + p4d_index(addr) : p4d_base;
+ p4dp = pgtable_l5_enabled() ? p4d_base + p4d_index(addr) : p4d_base;
p4d = p4dp_get(p4dp);
if (!p4d_present(p4d))
continue;
if (p4d_leaf(p4d)) {
- if (pgtable_l5_enabled) {
+ if (pgtable_l5_enabled()) {
p4d_clear(p4dp);
if (is_vmemmap)
free_vmemmap_storage(p4d_page(p4d), P4D_SIZE, altmap);
@@ -1674,7 +1674,7 @@ static void __meminit remove_p4d_mapping
pud_base = pud_offset(p4dp, 0);
remove_pud_mapping(pud_base, addr, next, is_vmemmap, altmap);
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
free_pud_table(pud_base, p4dp);
}
}
--- a/arch/riscv/mm/kasan_init.c
+++ b/arch/riscv/mm/kasan_init.c
@@ -168,7 +168,7 @@ static void __init kasan_early_clear_pud
pud_t *pudp, *base_pud;
unsigned long next;
- if (!pgtable_l4_enabled) {
+ if (!pgtable_l4_enabled()) {
pudp = (pud_t *)p4dp;
} else {
base_pud = pt_ops.get_pud_virt(pfn_to_phys(_p4d_pfn(p4dp_get(p4dp))));
@@ -193,7 +193,7 @@ static void __init kasan_early_clear_p4d
p4d_t *p4dp, *base_p4d;
unsigned long next;
- if (!pgtable_l5_enabled) {
+ if (!pgtable_l5_enabled()) {
p4dp = (p4d_t *)pgdp;
} else {
base_p4d = pt_ops.get_p4d_virt(pfn_to_phys(_pgd_pfn(pgdp_get(pgdp))));
@@ -203,7 +203,7 @@ static void __init kasan_early_clear_p4d
do {
next = p4d_addr_end(vaddr, end);
- if (pgtable_l4_enabled && IS_ALIGNED(vaddr, P4D_SIZE) &&
+ if (pgtable_l4_enabled() && IS_ALIGNED(vaddr, P4D_SIZE) &&
(next - vaddr) >= P4D_SIZE) {
p4d_clear(p4dp);
continue;
@@ -221,7 +221,7 @@ static void __init kasan_early_clear_pgd
do {
next = pgd_addr_end(vaddr, end);
- if (pgtable_l5_enabled && IS_ALIGNED(vaddr, PGDIR_SIZE) &&
+ if (pgtable_l5_enabled() && IS_ALIGNED(vaddr, PGDIR_SIZE) &&
(next - vaddr) >= PGDIR_SIZE) {
pgd_clear(pgdp);
continue;
@@ -239,7 +239,7 @@ static void __init kasan_early_populate_
phys_addr_t phys_addr;
unsigned long next;
- if (!pgtable_l4_enabled) {
+ if (!pgtable_l4_enabled()) {
pudp = (pud_t *)p4dp;
} else {
base_pud = pt_ops.get_pud_virt(pfn_to_phys(_p4d_pfn(p4dp_get(p4dp))));
@@ -277,7 +277,7 @@ static void __init kasan_early_populate_
* Note that this test is then completely equivalent to
* p4dp = p4d_offset(pgdp, vaddr)
*/
- if (!pgtable_l5_enabled) {
+ if (!pgtable_l5_enabled()) {
p4dp = (p4d_t *)pgdp;
} else {
base_p4d = pt_ops.get_p4d_virt(pfn_to_phys(_pgd_pfn(pgdp_get(pgdp))));
@@ -336,7 +336,7 @@ asmlinkage void __init kasan_early_init(
(__pa((uintptr_t)kasan_early_shadow_pte)),
PAGE_TABLE));
- if (pgtable_l4_enabled) {
+ if (pgtable_l4_enabled()) {
for (i = 0; i < PTRS_PER_PUD; ++i)
set_pud(kasan_early_shadow_pud + i,
pfn_pud(PFN_DOWN
@@ -344,7 +344,7 @@ asmlinkage void __init kasan_early_init(
PAGE_TABLE));
}
- if (pgtable_l5_enabled) {
+ if (pgtable_l5_enabled()) {
for (i = 0; i < PTRS_PER_P4D; ++i)
set_p4d(kasan_early_shadow_p4d + i,
pfn_p4d(PFN_DOWN
@@ -461,7 +461,7 @@ static void __init create_tmp_mapping(vo
memcpy(tmp_pg_dir, swapper_pg_dir, sizeof(pgd_t) * PTRS_PER_PGD);
/* Copy the last p4d since it is shared with the kernel mapping. */
- if (pgtable_l5_enabled) {
+ if (pgtable_l5_enabled()) {
ptr = (p4d_t *)pgd_page_vaddr(pgdp_get(pgd_offset_k(KASAN_SHADOW_END)));
memcpy(tmp_p4d, ptr, sizeof(p4d_t) * PTRS_PER_P4D);
set_pgd(&tmp_pg_dir[pgd_index(KASAN_SHADOW_END)],
@@ -472,7 +472,7 @@ static void __init create_tmp_mapping(vo
}
/* Copy the last pud since it is shared with the kernel mapping. */
- if (pgtable_l4_enabled) {
+ if (pgtable_l4_enabled()) {
ptr = (pud_t *)p4d_page_vaddr(p4dp_get(base_p4d + p4d_index(KASAN_SHADOW_END)));
memcpy(tmp_pud, ptr, sizeof(pud_t) * PTRS_PER_PUD);
set_p4d(&base_p4d[p4d_index(KASAN_SHADOW_END)],
--- a/arch/riscv/mm/pgtable.c
+++ b/arch/riscv/mm/pgtable.c
@@ -41,7 +41,7 @@ EXPORT_SYMBOL_GPL(ptep_test_and_clear_yo
#ifdef CONFIG_64BIT
pud_t *pud_offset(p4d_t *p4d, unsigned long address)
{
- if (pgtable_l4_enabled)
+ if (pgtable_l4_enabled())
return p4d_pgtable(p4dp_get(p4d)) + pud_index(address);
return (pud_t *)p4d;
@@ -50,7 +50,7 @@ EXPORT_SYMBOL_GPL(pud_offset);
p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)
{
- if (pgtable_l5_enabled)
+ if (pgtable_l5_enabled())
return pgd_pgtable(pgdp_get(pgd)) + p4d_index(address);
return (p4d_t *)pgd;
--- a/arch/riscv/mm/ptdump.c
+++ b/arch/riscv/mm/ptdump.c
@@ -446,8 +446,8 @@ static int __init ptdump_init(void)
kernel_ptd_info.base_addr = KERN_VIRT_START;
- pg_level[1].name = pgtable_l5_enabled ? "P4D" : "PGD";
- pg_level[2].name = pgtable_l4_enabled ? "PUD" : "PGD";
+ pg_level[1].name = pgtable_l5_enabled() ? "P4D" : "PGD";
+ pg_level[2].name = pgtable_l4_enabled() ? "PUD" : "PGD";
for (i = 0; i < ARRAY_SIZE(pg_level); i++)
for (j = 0; j < ARRAY_SIZE(pte_bits); j++)
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 739/742] riscv/mm: fix hotplug page-table destructor handling
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (722 preceding siblings ...)
2026-12-04 10:10 ` [PATCH 7.3 738/742] riscv: convert pgtable_l4|l5_enabled to inline function Greg Kroah-Hartman
@ 2026-12-04 10:10 ` Greg Kroah-Hartman
2026-12-04 10:10 ` [PATCH 7.3 740/742] userfaultfd: validate the whole range before changing write protection Greg Kroah-Hartman
` (2 subsequent siblings)
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:10 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Muchun Song, Andrew Morton,
Björn Töpel, Kevin Brodsky, David Hildenbrand (Arm),
Oscar Salvador, Dave Hansen, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, Björn Töpel,
Catalin Marinas, Will Deacon, Mark Rutland, Alexander Gordeev,
Alistair Popple, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muchun Song <muchun.song@linux.dev>
[ Upstream commit 352fca06aa692848a9b95f43740b4939f495ca4b ]
RISC-V uses the same memory-hotplug teardown code for linear-map and
vmemmap page tables. Late linear-map allocations run page-table
constructors, while vmemmap and early allocations may not.
free_pte_table() unconditionally calls pagetable_dtor(), corrupting
NR_PAGETABLE accounting for constructor-free tables. free_pmd_table()
avoids that for vmemmap using is_vmemmap, but mapping type is not a
reliable proxy for constructor state. In particular, it becomes invalid
once runtime vmemmap tables use the normal pgalloc helpers.
Introduce free_pgtable_page() to select free_reserved_page() for reserved
pages and pagetable_free() otherwise. The latter runs the destructor only
when PageTable() is set, handling both constructor-backed and
constructor-free tables.
Link: https://lore.kernel.org/20261023063428.3658761-3-songmuchun@bytedance.com
Fixes: c75a74f4ba19 ("riscv: mm: Add memory hotplugging support")
Signed-off-by: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Björn Töpel <bjorn@kernel.org>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Björn Töpel <bjorn@rivosinc.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/riscv/mm/init.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -1485,10 +1485,17 @@ struct execmem_info __init *execmem_arch
#endif /* CONFIG_EXECMEM */
#ifdef CONFIG_MEMORY_HOTPLUG
+static void __meminit free_pgtable_page(struct page *page)
+{
+ if (PageReserved(page))
+ free_reserved_page(page);
+ else
+ pagetable_free(page_ptdesc(page));
+}
+
static void __meminit free_pte_table(pte_t *pte_start, pmd_t *pmd)
{
struct page *page = pmd_page(*pmd);
- struct ptdesc *ptdesc = page_ptdesc(page);
pte_t *pte;
int i;
@@ -1498,18 +1505,13 @@ static void __meminit free_pte_table(pte
return;
}
- pagetable_dtor(ptdesc);
- if (PageReserved(page))
- free_reserved_page(page);
- else
- pagetable_free(ptdesc);
+ free_pgtable_page(page);
pmd_clear(pmd);
}
-static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud, bool is_vmemmap)
+static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud)
{
struct page *page = pud_page(*pud);
- struct ptdesc *ptdesc = page_ptdesc(page);
pmd_t *pmd;
int i;
@@ -1519,12 +1521,7 @@ static void __meminit free_pmd_table(pmd
return;
}
- if (!is_vmemmap)
- pagetable_dtor(ptdesc);
- if (PageReserved(page))
- free_reserved_page(page);
- else
- pagetable_free(ptdesc);
+ free_pgtable_page(page);
pud_clear(pud);
}
@@ -1644,7 +1641,7 @@ static void __meminit remove_pud_mapping
remove_pmd_mapping(pmd_base, addr, next, is_vmemmap, altmap);
if (pgtable_l4_enabled())
- free_pmd_table(pmd_base, pudp, is_vmemmap);
+ free_pmd_table(pmd_base, pudp);
}
}
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 740/742] userfaultfd: validate the whole range before changing write protection
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (723 preceding siblings ...)
2026-12-04 10:10 ` [PATCH 7.3 739/742] riscv/mm: fix hotplug page-table destructor handling Greg Kroah-Hartman
@ 2026-12-04 10:10 ` Greg Kroah-Hartman
2026-12-04 10:10 ` [PATCH 7.3 741/742] drm/gud: fix potential divide error due to optimisation Greg Kroah-Hartman
2026-12-04 10:10 ` [PATCH 7.3 742/742] mm/shmem: dont drop a folio whose swap write failed Greg Kroah-Hartman
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:10 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Umang Pokhriyal, Andrew Morton,
Mike Rapoport (Microsoft), Peter Xu, David Hildenbrand,
Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
Suren Baghdasaryan, Michal Hocko, Sasha Levin
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Umang Pokhriyal <umangpokhriyall@gmail.com>
[ Upstream commit 28ae0385b638f095109d282b927ac1a51f75c530 ]
mwriteprotect_range() checks each VMA as it walks the range. When a later
VMA is not registered for write protection, or is a hugetlb VMA the range
is not aligned to, the call fails after the earlier VMAs were already
changed. When unprotecting, userfaultfd_writeprotect() then skips
wake_userfault(), so threads blocked on those pages are not woken although
the pages are writable again.
An unprivileged process can trigger this with a range that spans an
unregistered VMA. It hasn't been seen in practice; it was found while
reviewing the userfaultfd range ioctls with an LLM.
Validate the whole range first, as mrwprotect_range() already does.
Link: https://lore.kernel.org/20261104093457.152245-1-umangpokhriyall@gmail.com
Fixes: a1b92a3f1498 ("mm/userfaultfd: support WP on multiple VMAs")
Signed-off-by: Umang Pokhriyal <umangpokhriyall@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: <stable@vger.kernel.org>
[ sashal: Replaced vma_is_hugetlb() with is_vm_hugetlb_page() in the new validation loop of mwriteprotect_range(), since the former helper does not exist in this tree. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/userfaultfd.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -1136,21 +1136,26 @@ static int mwriteprotect_range(struct us
if (atomic_read(&ctx->mmap_changing))
goto out_unlock;
+ /*
+ * Validate every spanned VMA before changing any of them, so an
+ * invalid range is rejected without changing part of it.
+ */
err = -ENOENT;
for_each_vma_range(vmi, dst_vma, end) {
-
- if (!userfaultfd_wp(dst_vma)) {
- err = -ENOENT;
- break;
- }
+ if (!userfaultfd_wp(dst_vma))
+ goto out_unlock;
if (is_vm_hugetlb_page(dst_vma)) {
- err = -EINVAL;
page_mask = vma_kernel_pagesize(dst_vma) - 1;
- if ((start & page_mask) || (len & page_mask))
- break;
+ if ((start & page_mask) || (len & page_mask)) {
+ err = -EINVAL;
+ goto out_unlock;
+ }
}
+ }
+ vma_iter_set(&vmi, start);
+ for_each_vma_range(vmi, dst_vma, end) {
_start = max(dst_vma->vm_start, start);
_end = min(dst_vma->vm_end, end);
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 741/742] drm/gud: fix potential divide error due to optimisation
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (724 preceding siblings ...)
2026-12-04 10:10 ` [PATCH 7.3 740/742] userfaultfd: validate the whole range before changing write protection Greg Kroah-Hartman
@ 2026-12-04 10:10 ` Greg Kroah-Hartman
2026-12-04 10:10 ` [PATCH 7.3 742/742] mm/shmem: dont drop a folio whose swap write failed Greg Kroah-Hartman
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:10 UTC (permalink / raw)
To: stable; +Cc: Greg Kroah-Hartman, patches, Thomas Zimmermann, Ruben Wauters
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruben Wauters <ruben.wauters@linux.dev>
commit cbea6bdc930b2de974e77e6c3031f67796793625 upstream.
Compilers can potentially optmise the read of gdrm->stats_actual_length
to two separate reads. As flagged by sashiko, when the rect is flushed
the stats_actual_length can reset to zero. If this was to occur between
the two reads, the divide error can still be triggered (albeit rarely).
Fix this by adding a READ_ONCE around the gdrm->stats_actual_length
Fixes: 431c2dffd2b7 ("drm/gud: avoid divide error in gud_stats_debugfs")
Cc: <stable@vger.kernel.org>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patch.msgid.link/20261117141943.10540-1-ruben.wauters@linux.dev
Signed-off-by: Ruben Wauters <ruben.wauters@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpu/drm/gud/gud_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/gpu/drm/gud/gud_drv.c
+++ b/drivers/gpu/drm/gud/gud_drv.c
@@ -329,7 +329,7 @@ static int gud_stats_debugfs(struct seq_
seq_puts(m, "\n");
if (gdrm->compression) {
- u64 actual_length = gdrm->stats_actual_length;
+ u64 actual_length = READ_ONCE(gdrm->stats_actual_length);
u64 remainder;
u64 ratio, ratio_frac;
^ permalink raw reply [flat|nested] 728+ messages in thread* [PATCH 7.3 742/742] mm/shmem: dont drop a folio whose swap write failed
2026-12-04 9:57 [PATCH 7.3 000/742] 7.3.8-rc1 review Greg Kroah-Hartman
` (725 preceding siblings ...)
2026-12-04 10:10 ` [PATCH 7.3 741/742] drm/gud: fix potential divide error due to optimisation Greg Kroah-Hartman
@ 2026-12-04 10:10 ` Greg Kroah-Hartman
726 siblings, 0 replies; 728+ messages in thread
From: Greg Kroah-Hartman @ 2026-12-04 10:10 UTC (permalink / raw)
To: stable
Cc: Greg Kroah-Hartman, patches, Chris Mason, Mani Tofigh, Nhat Pham,
Baolin Wang, David Hildenbrand (Arm)
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mani Tofigh <mt4022@columbia.edu>
commit e3464357e282d164ce873bfb4e259996cea3a564 upstream.
shmem_swapin_folio() drops a large folio that does not fit the mapping
from the swap cache if the folio is neither dirty nor under writeback.
The folio can belong to another file and be under swap writeback, when
the swap entry was freed and reused before the swap cache lookup.
Swap write completion does not take the folio lock. On a failed write,
swap_write_end() marks the folio dirty and then ends writeback. Since
dirty is tested first, the folio can look clean and written:
CPU0 (swapin of file Y) CPU1 (swapout of file X)
----------------------- ------------------------
shmem_swapin_folio()
folio_test_dirty() == false
swap_write_end(), failed write
folio_mark_dirty()
folio_end_writeback()
folio_test_writeback() == false
swap_cache_del_folio()
/* X's data is lost */
The next swapin of X reads the slot whose write failed.
Test writeback first. Both flags are in folio->flags. If the
writeback test sees the write ended, the dirty test then sees the dirty
bit set before it.
With the fix, a folio whose swap write failed stays in the swap cache.
Fixes: fc2c19648d68 ("mm/shmem: fix swapin livelock on a mismatched large swap cache folio")
Suggested-by: Chris Mason <mason@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Mani Tofigh <mt4022@columbia.edu>
Reviewed-by: Nhat Pham <nphamcs@gmail.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Link: https://patch.msgid.link/20261123-shmem-swap-write-failed-v1-1-41a0115dfbf1@columbia.edu
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/shmem.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2457,10 +2457,12 @@ failed:
* A large folio that does not fit the mapping, e.g. because its swap
* entries were freed and reused, would be found again on every retry.
* Drop it from the swap cache so the retry can swap in a fitting one.
+ * A failed swap write sets dirty and then ends writeback without the
+ * folio lock, so test writeback before dirty.
*/
if (error == -EEXIST && folio && folio_test_large(folio) &&
- !folio_test_anon(folio) && !folio_test_dirty(folio) &&
- !folio_test_writeback(folio))
+ !folio_test_anon(folio) && !folio_test_writeback(folio) &&
+ !folio_test_dirty(folio))
swap_cache_del_folio(folio);
unlock:
if (folio)
^ permalink raw reply [flat|nested] 728+ messages in thread