Skip to contentSkip to conversation

6.12.119-rc1 review

PATCH Applied Greg Kroah-Hartman 15 participants 1,795 messages Nov 18 – Nov 20 Page 14 of 14

Subsystems (3)
lore
Share & tools
lore
author maintainer
#1714 lore raw

PATCH 1684/1756 block: introduce init_wait_func()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Muchun Song <[email protected]>

[ Upstream commit 36d03cb3277e29beedb87b8efb1e4da02b26e0c0 ]

There is already a macro DEFINE_WAIT_FUNC() to declare a wait_queue_entry with a specified waking function. But there is not a counterpart for initializing one wait_queue_entry with a specified waking function. So introducing init_wait_func() for this, which also could be used in iocost and rq-qos. Using default_wake_function() in rq_qos_wait() to wake up waiters, which could remove ->task field from rq_qos_wait_data.

Stable-dep-of: 0150554a3f38 ("blk-iocost: publish hweights as one atomic value")

---
 block/blk-iocost.c   |  3 +--
 block/blk-rq-qos.c   | 14 +++++++-------
 include/linux/wait.h |  6 ++++--
 3 files changed, 12 insertions(+), 11 deletions(-)
block/blk-iocost.c +1 -2
index 2a4d246fd9922..9496666b65b6a 100644
@@ -2722,8 +2722,7 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
 	 * All waiters are on iocg->waitq and the wait states are
 	 * synchronized using waitq.lock.
 	 */
-	init_waitqueue_func_entry(&wait.wait, iocg_wake_fn);
-	wait.wait.private = current;
+	init_wait_func(&wait.wait, iocg_wake_fn);
 	wait.bio = bio;
 	wait.abs_cost = abs_cost;
 	wait.committed = false;	/* will be set true by waker */
block/blk-rq-qos.c +7 -7
index eb9618cd68adf..0b1245d368cd1 100644
@@ -196,7 +196,6 @@ bool rq_depth_scale_down(struct rq_depth *rqd, bool hard_throttle)
 
 struct rq_qos_wait_data {
 	struct wait_queue_entry wq;
-	struct task_struct *task;
 	struct rq_wait *rqw;
 	acquire_inflight_cb_t *cb;
 	void *private_data;
@@ -218,7 +217,12 @@ static int rq_qos_wake_function(struct wait_queue_entry *curr,
 		return -1;
 
 	data->got_token = true;
-	wake_up_process(data->task);
+	/*
+	 * autoremove_wake_function() removes the wait entry only when it
+	 * actually changed the task state. We want the wait always removed.
+	 * Remove explicitly and use default_wake_function().
+	 */
+	default_wake_function(curr, mode, wake_flags, key);
 	list_del_init_careful(&curr->entry);
 	return 1;
 }
@@ -244,11 +248,6 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
 		 cleanup_cb_t *cleanup_cb)
 {
 	struct rq_qos_wait_data data = {
-		.wq = {
-			.func	= rq_qos_wake_function,
-			.entry	= LIST_HEAD_INIT(data.wq.entry),
-		},
-		.task = current,
 		.rqw = rqw,
 		.cb = acquire_inflight_cb,
 		.private_data = private_data,
@@ -259,6 +258,7 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_data,
 	if (!has_sleeper && acquire_inflight_cb(rqw, private_data))
 		return;
 
+	init_wait_func(&data.wq, rq_qos_wake_function);
 	has_sleeper = !prepare_to_wait_exclusive(&rqw->wait, &data.wq,
 						 TASK_UNINTERRUPTIBLE);
 	do {
include/linux/wait.h +4 -2
index 2b322a9b88a2b..10e46d5c31784 100644
@@ -1207,14 +1207,16 @@ int autoremove_wake_function(struct wait_queue_entry *wq_entry, unsigned mode, i
 
 #define DEFINE_WAIT(name) DEFINE_WAIT_FUNC(name, autoremove_wake_function)
 
-#define init_wait(wait)								\
+#define init_wait_func(wait, function)						\
 	do {									\
 		(wait)->private = current;					\
-		(wait)->func = autoremove_wake_function;			\
+		(wait)->func = function;					\
 		INIT_LIST_HEAD(&(wait)->entry);					\
 		(wait)->flags = 0;						\
 	} while (0)
 
+#define init_wait(wait)	init_wait_func(wait, autoremove_wake_function)
+
 typedef int (*task_call_f)(struct task_struct *p, void *arg);
 extern int task_call_func(struct task_struct *p, task_call_f func, void *arg);
 
Signature · 1 line
2.53.0
author maintainer
#1715 lore raw

PATCH 1685/1756 block/blk-iocost: Split ioc_rqos_throttle()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Bart Van Assche <[email protected]>

[ Upstream commit 1ff85a387947890938c05cfe22041dfeef3098dd ]

Prepare for inlining iocg_lock() and iocg_unlock() by moving the code between these two calls into a new function. No functionality has been changed.

Stable-dep-of: 0150554a3f38 ("blk-iocost: publish hweights as one atomic value")

---
 block/blk-iocost.c | 163 ++++++++++++++++++++++++++-------------------
 1 file changed, 94 insertions(+), 69 deletions(-)
block/blk-iocost.c +94 -69
index 9496666b65b6a..0839885e0ba5a 100644
@@ -2609,6 +2609,88 @@ static u64 calc_size_vtime_cost(struct request *rq, struct ioc *ioc)
 	return cost;
 }
 
+enum over_budget_action {
+	action_retry,
+	action_commit,
+	action_wait,
+	action_return,
+};
+
+static enum over_budget_action
+iocg_handle_over_budget(struct rq_qos *rqos, struct ioc_gq *iocg,
+			struct bio *bio, struct ioc_now *now,
+			struct iocg_wait *wait, bool use_debt, bool ioc_locked,
+			u64 abs_cost, u64 cost)
+{
+	lockdep_assert_held(&iocg->waitq.lock);
+
+	/*
+	 * @iocg must stay activated for debt and waitq handling. Deactivation
+	 * is synchronized against both ioc->lock and waitq.lock and we won't
+	 * get deactivated as long as we're waiting or have debt, so we're good
+	 * if we're activated here. In the unlikely cases that we aren't, just
+	 * issue the IO.
+	 */
+	if (unlikely(list_empty(&iocg->active_list)))
+		return action_commit;
+
+	/*
+	 * We're over budget. If @bio has to be issued regardless, remember
+	 * the abs_cost instead of advancing vtime. iocg_kick_waitq() will pay
+	 * off the debt before waking more IOs.
+	 *
+	 * This way, the debt is continuously paid off each period with the
+	 * actual budget available to the cgroup. If we just wound vtime, we
+	 * would incorrectly use the current hw_inuse for the entire amount
+	 * which, for example, can lead to the cgroup staying blocked for a
+	 * long time even with substantially raised hw_inuse.
+	 *
+	 * An iocg with vdebt should stay online so that the timer can keep
+	 * deducting its vdebt and [de]activate use_delay mechanism
+	 * accordingly. We don't want to race against the timer trying to
+	 * clear them and leave @iocg inactive w/ dangling use_delay heavily
+	 * penalizing the cgroup and its descendants.
+	 */
+	if (use_debt) {
+		iocg_incur_debt(iocg, abs_cost, now);
+		if (iocg_kick_delay(iocg, now))
+			blkcg_schedule_throttle(rqos->disk,
+						(bio->bi_opf & REQ_SWAP) ==
+							REQ_SWAP);
+		return action_return;
+	}
+
+	/* guarantee that iocgs w/ waiters have maximum inuse */
+	if (!iocg->abs_vdebt && iocg->inuse != iocg->active) {
+		if (!ioc_locked)
+			return action_retry;
+		lockdep_assert_held(&iocg->ioc->lock);
+		propagate_weights(iocg, iocg->active, iocg->active, true, now);
+	}
+
+	/*
+	 * Append self to the waitq and schedule the wakeup timer if we're
+	 * the first waiter.  The timer duration is calculated based on the
+	 * current vrate.  vtime and hweight changes can make it too short
+	 * or too long.  Each wait entry records the absolute cost it's
+	 * waiting for to allow re-evaluation using a custom wait entry.
+	 *
+	 * If too short, the timer simply reschedules itself.  If too long,
+	 * the period timer will notice and trigger wakeups.
+	 *
+	 * All waiters are on iocg->waitq and the wait states are
+	 * synchronized using waitq.lock.
+	 */
+	init_wait_func(&wait->wait, iocg_wake_fn);
+	wait->bio = bio;
+	wait->abs_cost = abs_cost;
+	wait->committed = false; /* will be set true by waker */
+
+	__add_wait_queue_entry_tail(&iocg->waitq, &wait->wait);
+	iocg_kick_waitq(iocg, ioc_locked, now);
+	return action_wait;
+}
+
 static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
 {
 	struct blkcg_gq *blkg = bio->bi_blkg;
@@ -2618,6 +2700,7 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
 	struct iocg_wait wait;
 	u64 abs_cost, cost, vtime;
 	bool use_debt, ioc_locked;
+	enum over_budget_action action;
 	unsigned long flags;
 
 	/* bypass IOs if disabled, still initializing, or for root cgroup */
@@ -2658,80 +2741,22 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
 	ioc_locked = use_debt || READ_ONCE(iocg->abs_vdebt);
 retry_lock:
 	iocg_lock(iocg, ioc_locked, &flags);
-
-	/*
-	 * @iocg must stay activated for debt and waitq handling. Deactivation
-	 * is synchronized against both ioc->lock and waitq.lock and we won't
-	 * get deactivated as long as we're waiting or has debt, so we're good
-	 * if we're activated here. In the unlikely cases that we aren't, just
-	 * issue the IO.
-	 */
-	if (unlikely(list_empty(&iocg->active_list))) {
-		iocg_unlock(iocg, ioc_locked, &flags);
+	action = iocg_handle_over_budget(rqos, iocg, bio, &now, &wait, use_debt,
+					 ioc_locked, abs_cost, cost);
+	iocg_unlock(iocg, ioc_locked, &flags);
+	switch (action) {
+	case action_retry:
+		ioc_locked = true;
+		goto retry_lock;
+	case action_commit:
 		iocg_commit_bio(iocg, bio, abs_cost, cost);
 		return;
-	}
-
-	/*
-	 * We're over budget. If @bio has to be issued regardless, remember
-	 * the abs_cost instead of advancing vtime. iocg_kick_waitq() will pay
-	 * off the debt before waking more IOs.
-	 *
-	 * This way, the debt is continuously paid off each period with the
-	 * actual budget available to the cgroup. If we just wound vtime, we
-	 * would incorrectly use the current hw_inuse for the entire amount
-	 * which, for example, can lead to the cgroup staying blocked for a
-	 * long time even with substantially raised hw_inuse.
-	 *
-	 * An iocg with vdebt should stay online so that the timer can keep
-	 * deducting its vdebt and [de]activate use_delay mechanism
-	 * accordingly. We don't want to race against the timer trying to
-	 * clear them and leave @iocg inactive w/ dangling use_delay heavily
-	 * penalizing the cgroup and its descendants.
-	 */
-	if (use_debt) {
-		iocg_incur_debt(iocg, abs_cost, &now);
-		if (iocg_kick_delay(iocg, &now))
-			blkcg_schedule_throttle(rqos->disk,
-					(bio->bi_opf & REQ_SWAP) == REQ_SWAP);
-		iocg_unlock(iocg, ioc_locked, &flags);
+	case action_return:
 		return;
+	case action_wait:
+		break;
 	}
 
-	/* guarantee that iocgs w/ waiters have maximum inuse */
-	if (!iocg->abs_vdebt && iocg->inuse != iocg->active) {
-		if (!ioc_locked) {
-			iocg_unlock(iocg, false, &flags);
-			ioc_locked = true;
-			goto retry_lock;
-		}
-		propagate_weights(iocg, iocg->active, iocg->active, true,
-				  &now);
-	}
-
-	/*
-	 * Append self to the waitq and schedule the wakeup timer if we're
-	 * the first waiter.  The timer duration is calculated based on the
-	 * current vrate.  vtime and hweight changes can make it too short
-	 * or too long.  Each wait entry records the absolute cost it's
-	 * waiting for to allow re-evaluation using a custom wait entry.
-	 *
-	 * If too short, the timer simply reschedules itself.  If too long,
-	 * the period timer will notice and trigger wakeups.
-	 *
-	 * All waiters are on iocg->waitq and the wait states are
-	 * synchronized using waitq.lock.
-	 */
-	init_wait_func(&wait.wait, iocg_wake_fn);
-	wait.bio = bio;
-	wait.abs_cost = abs_cost;
-	wait.committed = false;	/* will be set true by waker */
-
-	__add_wait_queue_entry_tail(&iocg->waitq, &wait.wait);
-	iocg_kick_waitq(iocg, ioc_locked, &now);
-
-	iocg_unlock(iocg, ioc_locked, &flags);
-
 	while (true) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		if (wait.committed)
Signature · 1 line
2.53.0
author maintainer
#1716 lore raw

PATCH 1686/1756 block/blk-iocost: Inline iocg_lock() and iocg_unlock()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Bart Van Assche <[email protected]>

[ Upstream commit a255026594e9b7eea24c12d2bd4acae0c11eea94 ]

Both iocg_lock() and iocg_unlock() use conditional locking. Fold these functions into their callers such that unlocking becomes unconditional.

Stable-dep-of: 0150554a3f38 ("blk-iocost: publish hweights as one atomic value")

---
 block/blk-iocost.c | 53 +++++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 27 deletions(-)
block/blk-iocost.c +26 -27
index 0839885e0ba5a..a60d3dcee7c04 100644
@@ -727,26 +727,6 @@ static void iocg_commit_bio(struct ioc_gq *iocg, struct bio *bio,
 	put_cpu_ptr(gcs);
 }
 
-static void iocg_lock(struct ioc_gq *iocg, bool lock_ioc, unsigned long *flags)
-{
-	if (lock_ioc) {
-		spin_lock_irqsave(&iocg->ioc->lock, *flags);
-		spin_lock(&iocg->waitq.lock);
-	} else {
-		spin_lock_irqsave(&iocg->waitq.lock, *flags);
-	}
-}
-
-static void iocg_unlock(struct ioc_gq *iocg, bool unlock_ioc, unsigned long *flags)
-{
-	if (unlock_ioc) {
-		spin_unlock(&iocg->waitq.lock);
-		spin_unlock_irqrestore(&iocg->ioc->lock, *flags);
-	} else {
-		spin_unlock_irqrestore(&iocg->waitq.lock, *flags);
-	}
-}
-
 #define CREATE_TRACE_POINTS
 #include <trace/events/iocost.h>
 
@@ -1589,9 +1569,17 @@ static enum hrtimer_restart iocg_waitq_timer_fn(struct hrtimer *timer)
 
 	ioc_now(iocg->ioc, &now);
 
-	iocg_lock(iocg, pay_debt, &flags);
-	iocg_kick_waitq(iocg, pay_debt, &now);
-	iocg_unlock(iocg, pay_debt, &flags);
+	if (pay_debt) {
+		spin_lock_irqsave(&iocg->ioc->lock, flags);
+		spin_lock(&iocg->waitq.lock);
+		iocg_kick_waitq(iocg, pay_debt, &now);
+		spin_unlock(&iocg->waitq.lock);
+		spin_unlock_irqrestore(&iocg->ioc->lock, flags);
+	} else {
+		spin_lock_irqsave(&iocg->waitq.lock, flags);
+		iocg_kick_waitq(iocg, pay_debt, &now);
+		spin_unlock_irqrestore(&iocg->waitq.lock, flags);
+	}
 
 	return HRTIMER_NORESTART;
 }
@@ -2740,10 +2728,21 @@ static void ioc_rqos_throttle(struct rq_qos *rqos, struct bio *bio)
 	use_debt = bio_issue_as_root_blkg(bio) || fatal_signal_pending(current);
 	ioc_locked = use_debt || READ_ONCE(iocg->abs_vdebt);
 retry_lock:
-	iocg_lock(iocg, ioc_locked, &flags);
-	action = iocg_handle_over_budget(rqos, iocg, bio, &now, &wait, use_debt,
-					 ioc_locked, abs_cost, cost);
-	iocg_unlock(iocg, ioc_locked, &flags);
+	if (ioc_locked) {
+		spin_lock_irqsave(&iocg->ioc->lock, flags);
+		spin_lock(&iocg->waitq.lock);
+		action = iocg_handle_over_budget(rqos, iocg, bio, &now, &wait,
+						 use_debt, ioc_locked, abs_cost,
+						 cost);
+		spin_unlock(&iocg->waitq.lock);
+		spin_unlock_irqrestore(&iocg->ioc->lock, flags);
+	} else {
+		spin_lock_irqsave(&iocg->waitq.lock, flags);
+		action = iocg_handle_over_budget(rqos, iocg, bio, &now, &wait,
+						 use_debt, ioc_locked, abs_cost,
+						 cost);
+		spin_unlock_irqrestore(&iocg->waitq.lock, flags);
+	}
 	switch (action) {
 	case action_retry:
 		ioc_locked = true;
Signature · 1 line
2.53.0
author maintainer
#1717 lore raw

PATCH 1687/1756 blk-iocost: publish hweights as one atomic value

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kunhai Dai <[email protected]>

[ Upstream commit 0150554a3f38e1850d5964102eb89a720c5fe789 ]

current_hweight() publishes the cache generation and both weights with separate stores. Refreshers running on different CPUs can interleave their stores and leave a new generation paired with weights from an older calculation. The compiler can also reorder the generation store before the weight stores, so a reader that sees the new generation can accept stale weights.

A stale weight is not only a reporting artifact. It feeds the cost calculation and the donation logic, where an inconsistent combination can lead to a zero divisor in transfer_surpluses().

In addition, the slow path rereads iocg->hweight_active/inuse after publishing them, so the value it returns can be the one written by another refresher instead of the locally computed one.

Pack the generation and both weights into a single atomic64_t and publish them with one atomic write. Readers take one atomic snapshot and return the local values. Weights are in [1, WEIGHT_ONE]; storing each minus one preserves the full range in 16 bits and leaves 32 bits for the generation.

The two weight fields remain as the donation workspace used under ioc->lock. Tracepoints decode the packed cache without refreshing it and iocost_monitor.py is updated accordingly.

Developed with assistance from Claude Code (Anthropic): the assistant drafted the packed representation, the helpers and the tracepoint/monitor changes, and ran the checks listed below. The author reviewed the result and remains responsible for it.

---
 block/blk-iocost.c             | 109 +++++++++++++++++++++++++++------
 include/trace/events/iocost.h  |   7 ++-
 tools/cgroup/iocost_monitor.py |   7 ++-
 3 files changed, 99 insertions(+), 24 deletions(-)
block/blk-iocost.c +89 -20
index a60d3dcee7c04..c7097b5c39c3a 100644
@@ -173,6 +173,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/bitfield.h>
 #include <linux/module.h>
 #include <linux/timer.h>
 #include <linux/time64.h>
@@ -472,8 +473,8 @@ struct ioc_gq {
 	 *
 	 * When an idle cgroup becomes active its `active` goes from 0 to
 	 * `weight`.  `inuse` is the surplus adjusted active weight.
-	 * `active` and `inuse` are used to calculate `hweight_active` and
-	 * `hweight_inuse`.
+	 * `active` and `inuse` determine the hierarchical weights cached in
+	 * `hweight_cache`.
 	 *
 	 * `last_inuse` remembers `inuse` while an iocg is idle to persist
 	 * surplus adjustments.
@@ -520,7 +521,9 @@ struct ioc_gq {
 	u64				child_active_sum;
 	u64				child_inuse_sum;
 	u64				child_adjusted_sum;
-	int				hweight_gen;
+	/* Generation in bits 63:32; active - 1 and inuse - 1 in 31:16/15:0. */
+	atomic64_t			hweight_cache;
+	/* Donation workspace, protected by ioc->lock. */
 	u32				hweight_active;
 	u32				hweight_inuse;
 	u32				hweight_donating;
@@ -727,6 +730,54 @@ static void iocg_commit_bio(struct ioc_gq *iocg, struct bio *bio,
 	put_cpu_ptr(gcs);
 }
 
+/*
+ * The hierarchical weights are in [1, WEIGHT_ONE] and the generation is a
+ * 32-bit counter.  Pack generation and both weights into one 64-bit value so
+ * that a reader or a refresher always observes a complete snapshot:
+ *
+ *   bits 63:32  generation
+ *   bits 31:16  hweight_active - 1
+ *   bits 15:0   hweight_inuse - 1
+ */
+#define HWEIGHT_GEN_MASK	GENMASK_ULL(63, 32)
+#define HWEIGHT_ACTIVE_MASK	GENMASK_ULL(31, 16)
+#define HWEIGHT_INUSE_MASK	GENMASK_ULL(15, 0)
+
+static inline u64 hweight_cache_pack(u32 gen, u32 active, u32 inuse)
+{
+	return FIELD_PREP(HWEIGHT_GEN_MASK, gen) |
+	       FIELD_PREP(HWEIGHT_ACTIVE_MASK, active - 1) |
+	       FIELD_PREP(HWEIGHT_INUSE_MASK, inuse - 1);
+}
+
+static inline void hweight_cache_unpack(u64 cache, u32 *genp, u32 *activep,
+					u32 *inusep)
+{
+	if (genp)
+		*genp = FIELD_GET(HWEIGHT_GEN_MASK, cache);
+	if (activep)
+		*activep = FIELD_GET(HWEIGHT_ACTIVE_MASK, cache) + 1;
+	if (inusep)
+		*inusep = FIELD_GET(HWEIGHT_INUSE_MASK, cache) + 1;
+}
+
+/* Decode the published weights without refreshing the cache. */
+static inline void iocg_hweight_cache(struct ioc_gq *iocg, u32 *activep,
+				      u32 *inusep)
+{
+	hweight_cache_unpack(atomic64_read(&iocg->hweight_cache), NULL,
+			     activep, inusep);
+}
+
+/* Decode the cached inuse weight; only used by tracepoints. */
+static inline u32 iocg_hweight_cache_inuse(struct ioc_gq *iocg)
+{
+	u32 inuse;
+
+	iocg_hweight_cache(iocg, NULL, &inuse);
+	return inuse;
+}
+
 #define CREATE_TRACE_POINTS
 #include <trace/events/iocost.h>
 
@@ -1154,12 +1205,15 @@ static void current_hweight(struct ioc_gq *iocg, u32 *hw_activep, u32 *hw_inusep
 {
 	struct ioc *ioc = iocg->ioc;
 	int lvl;
-	u32 hwa, hwi;
-	int ioc_gen;
+	u32 hwa, hwi, ioc_gen, cache_gen;
+	u64 cache;
+
+	ioc_gen = (u32)atomic_read(&ioc->hweight_gen);
 
-	/* hot path - if uptodate, use cached */
-	ioc_gen = atomic_read(&ioc->hweight_gen);
-	if (ioc_gen == iocg->hweight_gen)
+	/* hot path - if uptodate, use the cached snapshot */
+	cache = atomic64_read(&iocg->hweight_cache);
+	hweight_cache_unpack(cache, &cache_gen, &hwa, &hwi);
+	if (cache_gen == ioc_gen)
 		goto out;
 
 	/*
@@ -1194,14 +1248,20 @@ static void current_hweight(struct ioc_gq *iocg, u32 *hw_activep, u32 *hw_inusep
 		hwi = div64_u64((u64)hwi * inuse, inuse_sum);
 	}
 
-	iocg->hweight_active = max_t(u32, hwa, 1);
-	iocg->hweight_inuse = max_t(u32, hwi, 1);
-	iocg->hweight_gen = ioc_gen;
+	hwa = max_t(u32, hwa, 1);
+	hwi = max_t(u32, hwi, 1);
+	/*
+	 * Publish the generation and both weights as one atomic snapshot.
+	 * A concurrent refresher may overwrite this with its own snapshot,
+	 * but the generation travels with the weights so the next reader
+	 * detects the mismatch and refreshes again.
+	 */
+	atomic64_set(&iocg->hweight_cache, hweight_cache_pack(ioc_gen, hwa, hwi));
 out:
 	if (hw_activep)
-		*hw_activep = iocg->hweight_active;
+		*hw_activep = hwa;
 	if (hw_inusep)
-		*hw_inusep = iocg->hweight_inuse;
+		*hw_inusep = hwi;
 }
 
 /*
@@ -1249,7 +1309,8 @@ static bool iocg_activate(struct ioc_gq *iocg, struct ioc_now *now)
 {
 	struct ioc *ioc = iocg->ioc;
 	u64 __maybe_unused last_period, cur_period;
-	u64 vtime, vtarget;
+	u64 vtime, vtarget, cache;
+	u32 active, inuse;
 	int i;
 
 	/*
@@ -1299,11 +1360,16 @@ static bool iocg_activate(struct ioc_gq *iocg, struct ioc_now *now)
 	vtime = vtarget;
 
 	/*
-	 * Activate, propagate weight and start period timer if not
-	 * running.  Reset hweight_gen to avoid accidental match from
-	 * wrapping.
+	 * Activate, propagate weight and start period timer if not running.
+	 * Invalidate the cached generation to avoid an accidental match from
+	 * wrapping.  Keep the last published weights so that the activation
+	 * tracepoint can report them; the next current_hweight() recomputes.
 	 */
-	iocg->hweight_gen = atomic_read(&ioc->hweight_gen) - 1;
+	cache = atomic64_read(&iocg->hweight_cache);
+	hweight_cache_unpack(cache, NULL, &active, &inuse);
+	atomic64_set(&iocg->hweight_cache,
+		     hweight_cache_pack((u32)(atomic_read(&ioc->hweight_gen) - 1),
+					active, inuse));
 	list_add(&iocg->active_list, &ioc->active_iocgs);
 
 	propagate_weights(iocg, iocg->weight,
@@ -2046,7 +2112,7 @@ static void transfer_surpluses(struct list_head *surpluses, struct ioc_now *now)
 
 		TRACE_IOCG_PATH(inuse_transfer, iocg, now,
 				iocg->inuse, inuse,
-				iocg->hweight_inuse,
+				iocg_hweight_cache_inuse(iocg),
 				iocg->hweight_after_donation);
 
 		__propagate_weights(iocg, iocg->active, inuse, true, now);
@@ -2361,7 +2427,7 @@ static void ioc_timer_fn(struct timer_list *timer)
 				 */
 				TRACE_IOCG_PATH(inuse_shortage, iocg, &now,
 						iocg->inuse, iocg->active,
-						iocg->hweight_inuse, new_hwi);
+						old_hwi, new_hwi);
 
 				__propagate_weights(iocg, iocg->active,
 						    iocg->active, true, &now);
@@ -3031,6 +3097,9 @@ static void ioc_pd_init(struct blkg_policy_data *pd)
 	INIT_LIST_HEAD(&iocg->active_list);
 	INIT_LIST_HEAD(&iocg->walk_list);
 	INIT_LIST_HEAD(&iocg->surplus_list);
+	atomic64_set(&iocg->hweight_cache,
+		     hweight_cache_pack((u32)(atomic_read(&ioc->hweight_gen) - 1),
+					WEIGHT_ONE, WEIGHT_ONE));
 	iocg->hweight_active = WEIGHT_ONE;
 	iocg->hweight_inuse = WEIGHT_ONE;
 
include/trace/events/iocost.h +5 -2
index e772b1bc60d60..eb711343ce4fc 100644
@@ -34,6 +34,9 @@ DECLARE_EVENT_CLASS(iocost_iocg_state,
 	),
 
 	TP_fast_assign(
+		u32 hwa, hwi;
+
+		iocg_hweight_cache(iocg, &hwa, &hwi);
 		__assign_str(devname);
 		__assign_str(cgroup);
 		__entry->now = now->now;
@@ -44,8 +47,8 @@ DECLARE_EVENT_CLASS(iocost_iocg_state,
 		__entry->vtime = vtime;
 		__entry->weight = iocg->weight;
 		__entry->inuse = iocg->inuse;
-		__entry->hweight_active = iocg->hweight_active;
-		__entry->hweight_inuse = iocg->hweight_inuse;
+		__entry->hweight_active = hwa;
+		__entry->hweight_inuse = hwi;
 	),
 
 	TP_printk("[%s:%s] now=%llu:%llu vrate=%llu "
tools/cgroup/iocost_monitor.py +5 -2
index 933c750b319b7..c6df7ac7ddf41 100644
@@ -149,8 +149,11 @@ class IocgStat:
         self.weight = iocg.weight.value_() / WEIGHT_ONE
         self.active = iocg.active.value_() / WEIGHT_ONE
         self.inuse = iocg.inuse.value_() / WEIGHT_ONE
-        self.hwa_pct = iocg.hweight_active.value_() * 100 / WEIGHT_ONE
-        self.hwi_pct = iocg.hweight_inuse.value_() * 100 / WEIGHT_ONE
+        hweight_cache = iocg.hweight_cache.counter.value_()
+        hwa = ((hweight_cache >> 16) & (WEIGHT_ONE - 1)) + 1
+        hwi = (hweight_cache & (WEIGHT_ONE - 1)) + 1
+        self.hwa_pct = hwa * 100 / WEIGHT_ONE
+        self.hwi_pct = hwi * 100 / WEIGHT_ONE
         self.address = iocg.value_()
 
         vdone = iocg.done_vtime.counter.value_()
Signature · 1 line
2.53.0
author maintainer
#1718 lore raw

PATCH 1688/1756 selftests: net: txtimestamp: fix out-of-bounds read in raw UDP checksum

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jamie Nguyen <[email protected]>

[ Upstream commit 8daacee78b3d2798fcf92398b6dff364eab64466 ]

With -r (SOCK_RAW, IPPROTO_UDP) the test writes only the UDP header and payload, and the kernel adds the IP header. get_udp_csum() still expects the IP source and destination addresses to directly precede the UDP header, and reads 2 * alen bytes before the start of the buffer: 8 bytes for IPv4, 32 bytes for IPv6.

ASan reports a heap-buffer-overflow for both -4 -r and -6 -r. Without ASan the read usually goes unnoticed, but it faults when the buffer is the first chunk in the heap. That happens on Ubuntu 26.04, where the kselftest runner wraps the test in uutils stdbuf, and txtimestamp.sh fails with SIGSEGV on every run.

Even without a crash, -r packets were sent with a checksum computed over unrelated heap memory, so their UDP checksum was invalid.

Build the pseudo-header from the destination address and checksum only the UDP header and payload. -R and -P already write daddr as both the source and destination address, so their checksums are unchanged. With -r the kernel selects the source address, which equals daddr for the loopback addresses used by txtimestamp.sh.

Fixes b52354aa068e ("selftests: expand txtimestamp with ipv6 dgram + raw and pf_packet")
---
 tools/testing/selftests/net/txtimestamp.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
tools/testing/selftests/net/txtimestamp.c +14 -9
index d626f22f95509..b68e05602047c 100644
@@ -417,19 +417,25 @@ static uint16_t get_ip_csum(const uint16_t *start, int num_words,
 	return ~sum;
 }
 
-static uint16_t get_udp_csum(const struct udphdr *udph, int alen)
+static uint16_t get_udp_csum(const struct udphdr *udph, bool is_ipv4)
 {
-	unsigned long pseudo_sum, csum_len;
-	const void *csum_start = udph;
+	const void *addr = is_ipv4 ? (void *)&daddr.sin_addr : &daddr6.sin6_addr;
+	int alen = is_ipv4 ? sizeof(struct in_addr) : sizeof(struct in6_addr);
+	uint16_t addr16[sizeof(struct in6_addr) / sizeof(uint16_t)];
+	unsigned long pseudo_sum;
+	int i;
 
 	pseudo_sum = htons(IPPROTO_UDP);
 	pseudo_sum += udph->len;
 
-	/* checksum ip(v6) addresses + udp header + payload */
-	csum_start -= alen * 2;
-	csum_len = ntohs(udph->len) + alen * 2;
+	/* pseudo-header source and destination: both are daddr */
+	memcpy(addr16, addr, alen);
+	for (i = 0; i < alen / 2; i++)
+		pseudo_sum += 2 * addr16[i];
 
-	return get_ip_csum(csum_start, csum_len >> 1, pseudo_sum);
+	/* checksum udp header + payload */
+	return get_ip_csum((const uint16_t *)udph, ntohs(udph->len) >> 1,
+			   pseudo_sum);
 }
 
 static int fill_header_ipv4(void *p)
@@ -478,8 +484,7 @@ static void fill_header_udp(void *p, bool is_ipv4)
 	udph->len    = ntohs(sizeof(*udph) + cfg_payload_len);
 	udph->check  = 0;
 
-	udph->check  = get_udp_csum(udph, is_ipv4 ? sizeof(struct in_addr) :
-						    sizeof(struct in6_addr));
+	udph->check  = get_udp_csum(udph, is_ipv4);
 }
 
 static void do_test(int family, unsigned int report_opt)
Signature · 1 line
2.53.0
author maintainer
#1719 lore raw

PATCH 1689/1756 apparmor: report a label allocation failure as -ENOMEM

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Maxime Bélair <[email protected]>

[ Upstream commit 07aee062c6ecaa7199be583c83a1c74ae9885f03 ]

aa_label_strn_parse() returns -ENOENT for every failure, so a caller cannot tell "no such profile" from "could not allocate a label".

Report an allocation failure as -ENOMEM.

Fixes f1bd904175e8 ("apparmor: add the base fns() for domain labels")
---
 security/apparmor/label.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
security/apparmor/label.c +10 -4
index 6508f13e9544f..a5fe6ce689692 100644
@@ -1947,12 +1947,18 @@ struct aa_label *aa_label_strn_parse(struct aa_label *base, const char *str,
 		goto out;
 	}
 
-	if (create)
+	if (create) {
 		label = aa_vec_find_or_create_label(vec, len, gfp);
-	else
+		if (!label) {
+			/* not absence: creating only fails on allocation */
+			label = ERR_PTR(-ENOMEM);
+			goto out;
+		}
+	} else {
 		label = vec_find(vec, len);
-	if (!label)
-		goto fail;
+		if (!label)
+			goto fail;
+	}
 
 out:
 	/* use adjusted len from after vec_unique, not original */
Signature · 1 line
2.53.0
author maintainer
#1720 lore raw

PATCH 1690/1756 apparmor: add support for 2^24 states to the dfa state machine.

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: John Johansen <[email protected]>

[ Upstream commit 9208c05f9fdfd927ea160b97dfef3c379049fff2 ]

Currently the dfa state machine is limited by its default, next, and check tables using u16. Allow loading of u32 tables, and if u16 tables are loaded map them to u32.

The number of states allowed does not increase to 2^32 because the base table uses the top 8 bits of its u32 for flags. Moving the flags into a separate table allowing a full 2^32 bit range wil be done in a separate patch.

Stable-dep-of: 449195a4bb7d ("apparmor: fix table_size() integer overflow on 32 bit")

---
 security/apparmor/apparmorfs.c    |  1 +
 security/apparmor/include/match.h |  8 ++-
 security/apparmor/match.c         | 99 ++++++++++++++++++++++++-------
 3 files changed, 83 insertions(+), 25 deletions(-)
security/apparmor/apparmorfs.c +1 -0
index eeed8047b12ff..eee116b42f27c 100644
@@ -2480,6 +2480,7 @@ static struct aa_sfs_entry aa_sfs_entry_policy[] = {
 	AA_SFS_FILE_U64("outofband",		MAX_OOB_SUPPORTED),
 	AA_SFS_FILE_U64("permstable32_version",	1),
 	AA_SFS_FILE_STRING("permstable32", PERMS32STR),
+	AA_SFS_FILE_U64("state32",	1),
 	AA_SFS_DIR("unconfined_restrictions",   aa_sfs_entry_unconfined),
 	{ }
 };
security/apparmor/include/match.h +5 -3
index 14c0401f97c1b..da03d1404335a 100644
@@ -87,10 +87,12 @@ struct table_header {
 	char td_data[];
 };
 
-#define DEFAULT_TABLE(DFA) ((u16 *)((DFA)->tables[YYTD_ID_DEF]->td_data))
+#define TABLE_DATAU16(TABLE) ((u16 *)((TABLE)->td_data))
+#define TABLE_DATAU32(TABLE) ((u32 *)((TABLE)->td_data))
+#define DEFAULT_TABLE(DFA) ((u32 *)((DFA)->tables[YYTD_ID_DEF]->td_data))
 #define BASE_TABLE(DFA) ((u32 *)((DFA)->tables[YYTD_ID_BASE]->td_data))
-#define NEXT_TABLE(DFA) ((u16 *)((DFA)->tables[YYTD_ID_NXT]->td_data))
-#define CHECK_TABLE(DFA) ((u16 *)((DFA)->tables[YYTD_ID_CHK]->td_data))
+#define NEXT_TABLE(DFA) ((u32 *)((DFA)->tables[YYTD_ID_NXT]->td_data))
+#define CHECK_TABLE(DFA) ((u32 *)((DFA)->tables[YYTD_ID_CHK]->td_data))
 #define EQUIV_TABLE(DFA) ((u8 *)((DFA)->tables[YYTD_ID_EC]->td_data))
 #define ACCEPT_TABLE(DFA) ((u32 *)((DFA)->tables[YYTD_ID_ACCEPT]->td_data))
 #define ACCEPT_TABLE2(DFA) ((u32 *)((DFA)->tables[YYTD_ID_ACCEPT2]->td_data))
security/apparmor/match.c +77 -22

167 lines not on this page · raw message

Signature · 1 line
2.53.0
author maintainer
#1721 lore raw

PATCH 1691/1756 apparmor: add additional flags to extended permission.

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: John Johansen <[email protected]>

[ Upstream commit 2e12c5f060176ede209673e4f63ea5d0e3c5814c ]

This is a step towards merging the file and policy state machines.

With the switch to extended permissions the state machine's ACCEPT2 table became unused freeing it up to store state specific flags. The first flags to be stored are FLAG_OWNER and FLAG other which paves the way towards merging the file and policydb perms into a single permission table.

Currently Lookups based on the objects ownership conditional will still need separate fns, this will be address in a following patch.

Stable-dep-of: 449195a4bb7d ("apparmor: fix table_size() integer overflow on 32 bit")

---
 security/apparmor/apparmorfs.c     |  5 +++--
 security/apparmor/domain.c         |  9 ++++++---
 security/apparmor/file.c           | 23 ++++++++++++++---------
 security/apparmor/include/file.h   |  5 +++--
 security/apparmor/include/policy.h |  7 ++++++-
 security/apparmor/policy_compat.c  |  6 +++---
 security/apparmor/policy_unpack.c  | 20 +++++++++++++++++++-
 7 files changed, 54 insertions(+), 21 deletions(-)
security/apparmor/apparmorfs.c +3 -2
index eee116b42f27c..ac1507391686b 100644
@@ -707,7 +707,8 @@ static void profile_query_cb(struct aa_profile *profile, struct aa_perms *perms,
 		if (state) {
 			struct path_cond cond = { };
 
-			tmp = *(aa_lookup_fperms(rules->file, state, &cond));
+			tmp = *(aa_lookup_condperms(current_fsuid(),
+						    rules->file, state, &cond));
 		}
 	} else if (rules->policy->dfa) {
 		if (!RULE_MEDIATES(rules, *match_str))
@@ -2478,7 +2479,7 @@ static struct aa_sfs_entry aa_sfs_entry_policy[] = {
 	AA_SFS_FILE_BOOLEAN("set_load",		1),
 	/* number of out of band transitions supported */
 	AA_SFS_FILE_U64("outofband",		MAX_OOB_SUPPORTED),
-	AA_SFS_FILE_U64("permstable32_version",	1),
+	AA_SFS_FILE_U64("permstable32_version",	3),
 	AA_SFS_FILE_STRING("permstable32", PERMS32STR),
 	AA_SFS_FILE_U64("state32",	1),
 	AA_SFS_DIR("unconfined_restrictions",   aa_sfs_entry_unconfined),
security/apparmor/domain.c +6 -3
index 8685c10e6754c..66bea805e7f39 100644
@@ -155,7 +155,8 @@ static int label_compound_match(struct aa_profile *profile,
 		if (!state)
 			goto fail;
 	}
-	*perms = *(aa_lookup_fperms(rules->file, state, &cond));
+	*perms = *(aa_lookup_condperms(current_fsuid(), rules->file, state,
+				       &cond));
 	aa_apply_modes_to_perms(profile, perms);
 	if ((perms->allow & request) != request)
 		return -EACCES;
@@ -210,7 +211,8 @@ static int label_components_match(struct aa_profile *profile,
 	return 0;
 
 next:
-	tmp = *(aa_lookup_fperms(rules->file, state, &cond));
+	tmp = *(aa_lookup_condperms(current_fsuid(), rules->file, state,
+				    &cond));
 	aa_apply_modes_to_perms(profile, &tmp);
 	aa_perms_accum(perms, &tmp);
 	label_for_each_cont(i, label, tp) {
@@ -219,7 +221,8 @@ static int label_components_match(struct aa_profile *profile,
 		state = match_component(profile, tp, stack, start);
 		if (!state)
 			goto fail;
-		tmp = *(aa_lookup_fperms(rules->file, state, &cond));
+		tmp = *(aa_lookup_condperms(current_fsuid(), rules->file, state,
+					    &cond));
 		aa_apply_modes_to_perms(profile, &tmp);
 		aa_perms_accum(perms, &tmp);
 	}
security/apparmor/file.c +14 -9
index 62bc46e037588..35bd22a778baf 100644
@@ -169,7 +169,8 @@ static int path_name(const char *op, const struct cred *subj_cred,
 struct aa_perms default_perms = {};
 /**
  * aa_lookup_fperms - convert dfa compressed perms to internal perms
- * @file_rules: the aa_policydb to lookup perms for  (NOT NULL)
+ * @subj_uid: uid to use for subject owner test
+ * @rules: the aa_policydb to lookup perms for  (NOT NULL)
  * @state: state in dfa
  * @cond:  conditions to consider  (NOT NULL)
  *
@@ -177,18 +178,21 @@ struct aa_perms default_perms = {};
  *
  * Returns: a pointer to a file permission set
  */
-struct aa_perms *aa_lookup_fperms(struct aa_policydb *file_rules,
-				 aa_state_t state, struct path_cond *cond)
+struct aa_perms *aa_lookup_condperms(kuid_t subj_uid, struct aa_policydb *rules,
+				     aa_state_t state, struct path_cond *cond)
 {
-	unsigned int index = ACCEPT_TABLE(file_rules->dfa)[state];
+	unsigned int index = ACCEPT_TABLE(rules->dfa)[state];
 
-	if (!(file_rules->perms))
+	if (!(rules->perms))
 		return &default_perms;
 
-	if (uid_eq(current_fsuid(), cond->uid))
-		return &(file_rules->perms[index]);
+	if ((ACCEPT_TABLE2(rules->dfa)[state] & ACCEPT_FLAG_OWNER)) {
+		if (uid_eq(subj_uid, cond->uid))
+			return &(rules->perms[index]);
+		return &(rules->perms[index + 1]);
+	}
 
-	return &(file_rules->perms[index + 1]);
+	return &(rules->perms[index]);
 }
 
 /**
@@ -207,7 +211,8 @@ aa_state_t aa_str_perms(struct aa_policydb *file_rules, aa_state_t start,
 {
 	aa_state_t state;
 	state = aa_dfa_match(file_rules->dfa, start, name);
-	*perms = *(aa_lookup_fperms(file_rules, state, cond));
+	*perms = *(aa_lookup_condperms(current_fsuid(), file_rules, state,
+				       cond));
 
 	return state;
 }
security/apparmor/include/file.h +3 -2
index 6e8f2aa66cd63..06d9899098a65 100644
@@ -77,8 +77,9 @@ int aa_audit_file(const struct cred *cred,
 		  const char *target, struct aa_label *tlabel, kuid_t ouid,
 		  const char *info, int error);
 
-struct aa_perms *aa_lookup_fperms(struct aa_policydb *file_rules,
-				  aa_state_t state, struct path_cond *cond);
+struct aa_perms *aa_lookup_condperms(kuid_t subj_uid,
+				     struct aa_policydb *file_rules,
+				     aa_state_t state, struct path_cond *cond);
 aa_state_t aa_str_perms(struct aa_policydb *file_rules, aa_state_t start,
 			const char *name, struct path_cond *cond,
 			struct aa_perms *perms);
security/apparmor/include/policy.h +6 -1
index 47199bead884b..552b885b64a60 100644
@@ -59,6 +59,11 @@ extern const char *const aa_profile_mode_names[];
 
 #define on_list_rcu(X) (!list_empty(X) && (X)->prev != LIST_POISON2)
 
+/* flags in the dfa accept2 table */
+enum dfa_accept_flags {
+	ACCEPT_FLAG_OWNER = 1,
+};
+
 /*
  * FIXME: currently need a clean way to replace and remove profiles as a
  * set.  It should be done at the namespace level.
@@ -124,6 +129,7 @@ static inline void aa_put_pdb(struct aa_policydb *pdb)
 		kref_put(&pdb->count, aa_pdb_free_kref);
 }
 
+/* lookup perm that doesn't have and object conditional */
 static inline struct aa_perms *aa_lookup_perms(struct aa_policydb *policy,
 					       aa_state_t state)
 {
@@ -135,7 +141,6 @@ static inline struct aa_perms *aa_lookup_perms(struct aa_policydb *policy,
 	return &(policy->perms[index]);
 }
 
-
 /* struct aa_data - generic data structure
  * key: name for retrieving this data
  * size: size of data in bytes
security/apparmor/policy_compat.c +3 -3
index 423227670e685..cfc2207e5a12e 100644
@@ -286,10 +286,10 @@ static void remap_dfa_accept(struct aa_dfa *dfa, unsigned int factor)
 
 	AA_BUG(!dfa);
 
-	for (state = 0; state < state_count; state++)
+	for (state = 0; state < state_count; state++) {
 		ACCEPT_TABLE(dfa)[state] = state * factor;
-	kvfree(dfa->tables[YYTD_ID_ACCEPT2]);
-	dfa->tables[YYTD_ID_ACCEPT2] = NULL;
+		ACCEPT_TABLE2(dfa)[state] = factor > 1 ? ACCEPT_FLAG_OWNER : 0;
+	}
 }
 
 /* TODO: merge different dfa mappings into single map_policy fn */
security/apparmor/policy_unpack.c +19 -1
index 0928c064ee9f9..ac03011501dc6 100644
@@ -731,6 +731,7 @@ static int unpack_pdb(struct aa_ext *e, struct aa_policydb **policy,
 	void *pos = e->pos;
 	int i, flags, error = -EPROTO;
 	ssize_t size;
+	u32 version = 0;
 
 	pdb = aa_alloc_pdb(GFP_KERNEL);
 	if (!pdb)
@@ -748,6 +749,9 @@ static int unpack_pdb(struct aa_ext *e, struct aa_policydb **policy,
 	if (pdb->perms) {
 		/* perms table present accept is index */
 		flags = TO_ACCEPT1_FLAG(YYTD_DATA32);
+		if (aa_unpack_u32(e, &version, "permsv") && version > 2)
+			/* accept2 used for dfa flags */
+			flags |= TO_ACCEPT2_FLAG(YYTD_DATA32);
 	} else {
 		/* packed perms in accept1 and accept2 */
 		flags = TO_ACCEPT1_FLAG(YYTD_DATA32) |
@@ -795,6 +799,20 @@ static int unpack_pdb(struct aa_ext *e, struct aa_policydb **policy,
 		}
 	}
 
+	if (pdb->perms && version <= 2) {
+		/* add dfa flags table missing in v2 */
+		u32 noents = pdb->dfa->tables[YYTD_ID_ACCEPT]->td_lolen;
+		u16 tdflags = pdb->dfa->tables[YYTD_ID_ACCEPT]->td_flags;
+		size_t tsize = table_size(noents, tdflags);
+
+		pdb->dfa->tables[YYTD_ID_ACCEPT2] = kvzalloc(tsize, GFP_KERNEL);
+		if (!pdb->dfa->tables[YYTD_ID_ACCEPT2]) {
+			*info = "failed to alloc dfa flags table";
+			goto out;
+		}
+		pdb->dfa->tables[YYTD_ID_ACCEPT2]->td_lolen = noents;
+		pdb->dfa->tables[YYTD_ID_ACCEPT2]->td_flags = tdflags;
+	}
 	/*
 	 * Unfortunately due to a bug in earlier userspaces, a
 	 * transition table may be present even when the dfa is
@@ -810,7 +828,7 @@ static int unpack_pdb(struct aa_ext *e, struct aa_policydb **policy,
 
 	/* TODO: move compat mapping here, requires dfa merging first */
 	/* TODO: move verify here, it has to be done after compat mappings */
-
+out:
 	*policy = pdb;
 	return 0;
 
Signature · 1 line
2.53.0
author maintainer
#1722 lore raw

PATCH 1692/1756 apparmor: fix table_size() integer overflow on 32 bit

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Maxime Bélair <[email protected]>

[ Upstream commit 449195a4bb7d9c456c02b871eec6905edb449bd2 ]

table_size() checks ALIGN(sizeof(struct table_header) + len * el_size, 8) in size_t, where @len is td_lolen, a u32 user-provided value from the policy blob. On 32 bit kernels both operations can overflow.

Triggering this bug allows to:
- overflow a 16 byte allocation with up to 4GiB of policy data
- store the table header at address ZERO_SIZE_PTR (kvzalloc(0))

However, this bug requires CAP_MAC_ADMIN, only affects 32 bit kernels, and the copy runs until the machine is destroyed, so it gives no controllable primitive and is therefore not a security issue.

Compute the size with the checked helpers and return 0 when the result is not representable, so the callers can reject the table. A valid table is never 0 bytes, the header alone is 12.

64 bit kernels cannot overflow (these structs are 32 bit), and are hence not affected.

Fixes e06f75a6a2b4 ("AppArmor: dfa match engine")
---
 security/apparmor/include/match.h | 11 ++++++++++-
 security/apparmor/match.c         |  6 +++++-
 security/apparmor/policy_unpack.c |  5 +++++
 3 files changed, 20 insertions(+), 2 deletions(-)
security/apparmor/include/match.h +10 -1
index da03d1404335a..1e511ed6b2630 100644
@@ -12,6 +12,7 @@
 #define __AA_MATCH_H
 
 #include <linux/kref.h>
+#include <linux/overflow.h>
 
 #define DFA_NOMATCH			0
 #define DFA_START			1
@@ -120,7 +121,15 @@ struct aa_dfa {
 
 static inline size_t table_size(size_t len, size_t el_size)
 {
-	return ALIGN(sizeof(struct table_header) + len * el_size, 8);
+	size_t size;
+
+	/* Need check_*_overflow for 32 bit machines */
+	if (check_mul_overflow(len, el_size, &size) ||
+	    check_add_overflow(size, sizeof(struct table_header), &size) ||
+	    size > SIZE_MAX - 7)
+		return 0;
+
+	return ALIGN(size, 8);
 }
 
 #define aa_state_t unsigned int
security/apparmor/match.c +5 -1
index b2a4bee4e3939..7c11a52d542af 100644
@@ -58,7 +58,7 @@ static struct table_header *unpack_table(char *blob, size_t bsize)
 	if (th.td_lolen == 0)
 		goto out;
 	tsize = table_size(th.td_lolen, th.td_flags);
-	if (bsize < tsize)
+	if (!tsize || bsize < tsize)
 		goto out;
 
 	table = kvzalloc(tsize, GFP_KERNEL);
@@ -281,6 +281,10 @@ static struct table_header *remap_data16_to_data32(struct table_header *old)
 	u32 i;
 
 	tsize = table_size(old->td_lolen, YYTD_DATA32);
+	if (!tsize) {
+		kvfree(old);
+		return NULL;
+	}
 	new = kvzalloc(tsize, GFP_KERNEL);
 	if (!new) {
 		kvfree(old);
security/apparmor/policy_unpack.c +5 -0
index ac03011501dc6..b00dcec5e6df3 100644
@@ -805,6 +805,11 @@ static int unpack_pdb(struct aa_ext *e, struct aa_policydb **policy,
 		u16 tdflags = pdb->dfa->tables[YYTD_ID_ACCEPT]->td_flags;
 		size_t tsize = table_size(noents, tdflags);
 
+		if (!tsize) {
+			*info = "invalid dfa flags table size";
+			error = -EPROTO;
+			goto fail;
+		}
 		pdb->dfa->tables[YYTD_ID_ACCEPT2] = kvzalloc(tsize, GFP_KERNEL);
 		if (!pdb->dfa->tables[YYTD_ID_ACCEPT2]) {
 			*info = "failed to alloc dfa flags table";
Signature · 1 line
2.53.0
author maintainer
#1723 lore raw

PATCH 1693/1756 apparmor: convert duplicated dfa transitions to match_char()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Maxime Bélair <[email protected]>

[ Upstream commit e667fc72f7f4a54674962c324048ca2cc58bc703 ]

For historical reasons several matchers duplicate the dfa character transition instead of using match_char().

This is because aa_dfa_match_until() and aa_dfa_matchn_until() were written on a branch that did not yet have match_char(), and copied code from aa_dfa_match(). leftmatch_fb() used the same pattern.

When match_char() added support for diff-encoded states, the change was never ported to these copies.

match_char() resolves a diff encoded state by using def[state] and retrying the same character, until it reaches a state with a valid transition. The copies instead do a simple state = def[state]; after the character is consumed, so on a diff encoded state one byte is dropped and the walk continues from the diff parent in the wrong state.

This makes an unnamed px/Px/cx/Cx transition resolve to no profile, and exec fails with

apparmor="DENIED" operation="exec" info="profile transition not found"

Convert the three copies to match_char(). For a dfa with no diff encoded state this is a no-op.

This bug is latent until the kernel advertises policy/diff-encode.

Fixes 21f606610502 ("apparmor: improve overlapping domain attachment resolution")
Fixes 031dcc8f4e84f ("apparmor: dfa add support for state differential encoding")
---
 security/apparmor/match.c | 52 ++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 33 deletions(-)
security/apparmor/match.c +19 -33
index 7c11a52d542af..ed98f173f7f35 100644
@@ -615,7 +615,7 @@ aa_state_t aa_dfa_match_until(struct aa_dfa *dfa, aa_state_t start,
 	u32 *next = NEXT_TABLE(dfa);
 	u32 *check = CHECK_TABLE(dfa);
 	u32 *accept = ACCEPT_TABLE(dfa);
-	aa_state_t state = start, pos;
+	aa_state_t state = start;
 
 	if (state == DFA_NOMATCH)
 		return DFA_NOMATCH;
@@ -626,22 +626,18 @@ aa_state_t aa_dfa_match_until(struct aa_dfa *dfa, aa_state_t start,
 		u8 *equiv = EQUIV_TABLE(dfa);
 		/* default is direct to next state */
 		while (*str) {
-			pos = base_idx(base[state]) + equiv[(u8) *str++];
-			if (check[pos] == state)
-				state = next[pos];
-			else
-				state = def[state];
+			u8 c = equiv[(u8) *str++];
+
+			match_char(state, def, base, next, check, c);
 			if (accept[state])
 				break;
 		}
 	} else {
 		/* default is direct to next state */
 		while (*str) {
-			pos = base_idx(base[state]) + (u8) *str++;
-			if (check[pos] == state)
-				state = next[pos];
-			else
-				state = def[state];
+			u8 c = (u8) *str++;
+
+			match_char(state, def, base, next, check, c);
 			if (accept[state])
 				break;
 		}
@@ -676,7 +672,7 @@ aa_state_t aa_dfa_matchn_until(struct aa_dfa *dfa, aa_state_t start,
 	u32 *next = NEXT_TABLE(dfa);
 	u32 *check = CHECK_TABLE(dfa);
 	u32 *accept = ACCEPT_TABLE(dfa);
-	aa_state_t state = start, pos;
+	aa_state_t state = start;
 
 	*retpos = NULL;
 	if (state == DFA_NOMATCH)
@@ -688,22 +684,18 @@ aa_state_t aa_dfa_matchn_until(struct aa_dfa *dfa, aa_state_t start,
 		u8 *equiv = EQUIV_TABLE(dfa);
 		/* default is direct to next state */
 		for (; n; n--) {
-			pos = base_idx(base[state]) + equiv[(u8) *str++];
-			if (check[pos] == state)
-				state = next[pos];
-			else
-				state = def[state];
+			u8 c = equiv[(u8) *str++];
+
+			match_char(state, def, base, next, check, c);
 			if (accept[state])
 				break;
 		}
 	} else {
 		/* default is direct to next state */
 		for (; n; n--) {
-			pos = base_idx(base[state]) + (u8) *str++;
-			if (check[pos] == state)
-				state = next[pos];
-			else
-				state = def[state];
+			u8 c = (u8) *str++;
+
+			match_char(state, def, base, next, check, c);
 			if (accept[state])
 				break;
 		}
@@ -752,7 +744,7 @@ static aa_state_t leftmatch_fb(struct aa_dfa *dfa, aa_state_t start,
 	u32 *base = BASE_TABLE(dfa);
 	u32 *next = NEXT_TABLE(dfa);
 	u32 *check = CHECK_TABLE(dfa);
-	aa_state_t state = start, pos;
+	aa_state_t state = start;
 
 	AA_BUG(!dfa);
 	AA_BUG(!str);
@@ -770,13 +762,10 @@ static aa_state_t leftmatch_fb(struct aa_dfa *dfa, aa_state_t start,
 		/* default is direct to next state */
 		while (*str) {
 			unsigned int adjust;
+			u8 c = equiv[(u8) *str++];
 
 			wb->history[wb->pos] = state;
-			pos = base_idx(base[state]) + equiv[(u8) *str++];
-			if (check[pos] == state)
-				state = next[pos];
-			else
-				state = def[state];
+			match_char(state, def, base, next, check, c);
 			if (is_loop(wb, state, &adjust)) {
 				state = aa_dfa_match(dfa, state, str);
 				*count -= adjust;
@@ -789,13 +778,10 @@ static aa_state_t leftmatch_fb(struct aa_dfa *dfa, aa_state_t start,
 		/* default is direct to next state */
 		while (*str) {
 			unsigned int adjust;
+			u8 c = (u8) *str++;
 
 			wb->history[wb->pos] = state;
-			pos = base_idx(base[state]) + (u8) *str++;
-			if (check[pos] == state)
-				state = next[pos];
-			else
-				state = def[state];
+			match_char(state, def, base, next, check, c);
 			if (is_loop(wb, state, &adjust)) {
 				state = aa_dfa_match(dfa, state, str);
 				*count -= adjust;
Signature · 1 line
2.53.0
author maintainer
#1724 lore raw

PATCH 1694/1756 apparmor: Fix namespace reference leak in __aa_find_or_create_ns()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Wentao Liang <[email protected]>

[ Upstream commit 8f1f7f664c1822af34c5465f9820b4e39146786b ]

When the namespace already exists, the reference taken by aa_get_ns() is overwritten with ERR_PTR(-EEXIST) without being released. The caller in apparmorfs.c clears ns on IS_ERR() and so cannot drop it either, leaking the reference on raced mkdir of an existing namespace.

Release the reference before returning -EEXIST.

Fixes 73688d1ed0b8 ("apparmor: refactor prepare_ns() and make usable from different views")
---
 security/apparmor/policy_ns.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
security/apparmor/policy_ns.c +4 -2
index 96f49a73d681a..a6c222a6778b9 100644
@@ -265,10 +265,12 @@ struct aa_ns *__aa_find_or_create_ns(struct aa_ns *parent, const char *name,
 	/* try and find the specified ns */
 	/* released by caller */
 	ns = aa_get_ns(__aa_find_ns(&parent->sub_ns, name));
-	if (!ns)
+	if (!ns) {
 		ns = __aa_create_ns(parent, name, dir);
-	else
+	} else {
+		aa_put_ns(ns);
 		ns = ERR_PTR(-EEXIST);
+	}
 
 	/* return ref */
 	return ns;
Signature · 1 line
2.53.0
author maintainer
#1725 lore raw

PATCH 1695/1756 apparmor: check connect permission for SCTP

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jérémy Jean <[email protected]>

[ Upstream commit 2f764c08bb191a8c8f4051926dba0d25d195f39b ]

SCTP can start an association through sendmsg() or CONNECTX. These paths call the SCTP-specific sctp_bind_connect hook instead of the normal socket connect hook, but AppArmor does not register it. As a result, a profile can deny connect and allow send or setopt, yet a task can still create an SCTP association.

Register the SCTP hook. Ask for connect permission when SENDMSG_CONNECT or CONNECTX creates an association.

Fixes 56974a6fcfef ("apparmor: add base infastructure for socket mediation")
Assisted-by LLM
---
 security/apparmor/lsm.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
security/apparmor/lsm.c +14 -0
index 89c79fd241bad..47d772d36627e 100644
@@ -15,6 +15,7 @@
 #include <linux/mount.h>
 #include <linux/namei.h>
 #include <linux/ptrace.h>
+#include <linux/sctp.h>
 #include <linux/ctype.h>
 #include <linux/sysctl.h>
 #include <linux/audit.h>
@@ -1164,6 +1165,18 @@ static int apparmor_socket_connect(struct socket *sock,
 			 aa_sk_perm(OP_CONNECT, AA_MAY_CONNECT, sock->sk));
 }
 
+static int apparmor_sctp_bind_connect(struct sock *sk, int optname,
+				      struct sockaddr *address, int addrlen)
+{
+	switch (optname) {
+	case SCTP_SOCKOPT_CONNECTX:
+	case SCTP_SENDMSG_CONNECT:
+		return aa_sk_perm(OP_CONNECT, AA_MAY_CONNECT, sk);
+	}
+
+	return 0;
+}
+
 static int apparmor_socket_listen(struct socket *sock, int backlog)
 {
 	AA_BUG(!sock);
@@ -1492,6 +1505,7 @@ static struct security_hook_list apparmor_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(socket_getsockopt, apparmor_socket_getsockopt),
 	LSM_HOOK_INIT(socket_setsockopt, apparmor_socket_setsockopt),
 	LSM_HOOK_INIT(socket_shutdown, apparmor_socket_shutdown),
+	LSM_HOOK_INIT(sctp_bind_connect, apparmor_sctp_bind_connect),
 #ifdef CONFIG_NETWORK_SECMARK
 	LSM_HOOK_INIT(socket_sock_rcv_skb, apparmor_socket_sock_rcv_skb),
 #endif
Signature · 1 line
2.53.0
author maintainer
#1726 lore raw

PATCH 1696/1756 eth: bnxt: free XDP frags when xdp_do_redirect() fails

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jakub Kicinski <[email protected]>

[ Upstream commit c10f3420d59859df107838aa97b49357616d9b47 ]

When xdp_do_redirect() fails bnxt_rx_xdp() recycles the head page but not the frags of a multi-buffer frame. Their agg ring slots have already been refilled, so the pages leak, and the page pool can't be destroyed until they are returned, which will never happen. Redirect to an AF_XDP socket in copy mode fails this way with -ENOMEM whenever the socket's fill ring runs out of buffers.
A socket bound without XDP_USE_SG also fails with -ENOSPC for every frame that doesn't fit in a single chunk.

All the other drop paths in this function free the frags.

Pointed out in LLM review of the first patch of the series. Tested on a BCM57504 at MTU 9000 by redirecting 60k 8000B ICMPv6 echo requests (a head and two agg buffers each) to lo, which can't transmit XDP frames. The page pools' inflight count stayed flat rather than growing by two pages per frame.

Fixes a7559bc8c17c ("bnxt: support transmit and free of aggregation buffers")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +1 -0
index fcdffdc3ffa8c..0512b61c2cf69 100644
@@ -306,6 +306,7 @@ bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons,
 
 		if (xdp_do_redirect(bp->dev, xdp, xdp_prog)) {
 			trace_xdp_exception(bp->dev, xdp_prog, act);
+			bnxt_xdp_buff_frags_free(rxr, xdp);
 			page_pool_recycle_direct(rxr->page_pool, page);
 			return true;
 		}
Signature · 1 line
2.53.0
author maintainer
#1727 lore raw

PATCH 1697/1756 eth: bnxt: hand XDP frags over to the copybreak skb

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jakub Kicinski <[email protected]>

[ Upstream commit 364b88b54fc260d22ee318bae862c2d7d8c31dc6 ]

With a multi-buffer XDP program attached, a packet only has agg buffers if it filled its head buffer, which in page mode holds most of a page. The program can still move the start of the packet forward with bpf_xdp_adjust_head() and leave at most rx_copybreak bytes in the head. bnxt_rx_pkt() then copies the head into a new skb, puts the head page back on the ring, and calls bnxt_xdp_build_skb() on the copy. bnxt_xdp_build_skb() only sets nr_frags and the skb's length accounting, because it expects an skb built around the head page, sharing its shinfo with the xdp_buff. The copy ends up with nr_frags set but no frag descriptors, and the stack later reads and releases whatever its frags array happens to contain. The real frags leak.

Copy the frag descriptors to the new skb in bnxt_copy_xdp(), so that bnxt_xdp_build_skb() finds the frags where it expects them. The frags now belong to the skb, and the head page goes back on the ring as before.

Pointed out in LLM review of the first patch of the series. Confirmed by reading the code, the unfixed kernel was not run with the reproducer below.
Tested on a BCM57504 at MTU 9000 with rx-copybreak raised to 1024 and a frags-capable XDP program moving the start of multi-buffer frames 3000B forward with bpf_xdp_adjust_head(), receiving 8000B ICMPv6 echo requests (a head and two agg buffers each). All 60k frames took the copybreak path with frags attached, the sampled skbs reached GRO with len=4998 data_len=4492 nr_frags=2, and were freed by the stack with the page pools' inflight count staying flat, no KASAN or DEBUG_PAGEALLOC splats.

Fixes 1dc4c557bfed ("bnxt: adding bnxt_xdp_build_skb to build skb from multibuffer xdp_buff")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +8 -0
index dc2bc7a2de0e3..f30777268a59a 100644
@@ -1378,6 +1378,14 @@ static struct sk_buff *bnxt_copy_xdp(struct bnxt_napi *bnapi,
 		__skb_pull(skb, metasize);
 	}
 
+	if (unlikely(xdp_buff_has_frags(xdp))) {
+		struct skb_shared_info *sinfo;
+
+		sinfo = xdp_get_shared_info_from_buff(xdp);
+		memcpy(skb_shinfo(skb)->frags, sinfo->frags,
+		       sinfo->nr_frags * sizeof(skb_frag_t));
+	}
+
 	return skb;
 }
 
Signature · 1 line
2.53.0
author maintainer
#1728 lore raw

PATCH 1698/1756 gro: do not GRO GSO packets with inconsistent payload

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kyle Zeng <[email protected]>

[ Upstream commit de788d8a7032475f900c16e9cc0c1417f4f719eb ]

tcp_gro_receive() excludes empty non-GSO packets with the unsigned len - 1 check, but its GSO branch only checks that gso_size matches the held packet's MSS. A trusted TCP GSO skb can reach GRO again with no payload after TC pedit increases its TCP data offset.

If the skb is fully linear, skb_gro_receive() then enters its fragment transfer path with nr_frags == 0. The do-while loop copies skb_frag_t entries backwards beyond both fragment arrays. An unprivileged process using its own user and network namespaces can trigger a KASAN slab-out-of-bounds write and panic through veth, pedit and GRE.

More generally, the payload of such a packet can be shrunk to any value, making it inconsistent with its gso_segs, and a GSO packet with gso_segs == 0 contributes no segment to the GRO packet.

Do not aggregate GSO packets with gso_segs == 0, and require the payload of GSO packets to be consistent with gso_segs and gso_size, the last segment being allowed to be short. This rejects the empty skb before either TCP merge helper, and covers both IPv4 and IPv6.

Fixes 5eddb24901ee ("gro: add support of (hw)gro packets to gro stack")
[edumazet: check payload against gso_segs, refuse gso_segs == 0]
---
 net/core/gro.c         |  5 +++--
 net/ipv4/tcp_offload.c | 12 +++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)
net/core/gro.c +3 -2
index 74b1ed66693f4..6a730b4593e1c 100644
@@ -516,9 +516,10 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
 	NAPI_GRO_CB(skb)->count = 1;
 	if (unlikely(skb_is_gso(skb))) {
 		NAPI_GRO_CB(skb)->count = skb_shinfo(skb)->gso_segs;
-		/* Only support TCP and non DODGY users. */
+		/* Only support TCP and non DODGY users, with a sane gso_segs. */
 		if (!skb_is_gso_tcp(skb) ||
-		    (skb_shinfo(skb)->gso_type & SKB_GSO_DODGY))
+		    (skb_shinfo(skb)->gso_type & SKB_GSO_DODGY) ||
+		    !NAPI_GRO_CB(skb)->count)
 			NAPI_GRO_CB(skb)->flush = 1;
 	}
 
net/ipv4/tcp_offload.c +9 -3
index 17f28f0ba9300..fbdeca5a0822a 100644
@@ -339,14 +339,20 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb,
 
 	mss = skb_shinfo(p)->gso_size;
 
-	/* If skb is a GRO packet, make sure its gso_size matches prior packet mss.
+	/* If skb is a GRO packet, make sure its gso_size matches prior packet
+	 * mss, and that its payload is consistent with its gso_segs
+	 * (the last segment can be short).
 	 * If it is a single frame, do not aggregate it if its length
 	 * is bigger than our mss.
 	 */
-	if (unlikely(skb_is_gso(skb)))
+	if (unlikely(skb_is_gso(skb))) {
+		unsigned int segs = NAPI_GRO_CB(skb)->count;
+
 		flush |= (mss != skb_shinfo(skb)->gso_size);
-	else
+		flush |= len <= (segs - 1) * mss || len > segs * mss;
+	} else {
 		flush |= (len - 1) >= mss;
+	}
 
 	flush |= (ntohl(th2->seq) + skb_gro_len(p)) ^ ntohl(th->seq);
 	flush |= skb_cmp_decrypted(p, skb);
Signature · 1 line
2.53.0
author maintainer
#1729 lore raw

PATCH 1699/1756 net: bgmac: fix TX DMA unmapping and slot cleanup

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Rosen Penev <[email protected]>

[ Upstream commit 4f45e97b3aac2282f2b436d97338c9c2c484d093 ]

When mapping a fragment fails, bgmac_dma_tx_add() unwinds with the wrong slots. It passes the failed fragment's slot->dma_addr, which holds the mapping error, to dma_unmap_single() for the head. The fragment loop indexes from ring->end instead of ring->end + 1, so it unmaps the head a second time as a page and leaves the last mapped fragment mapped. None of the affected slots get their dma_addr cleared either, which includes the head slot when mapping the head fails.

bgmac_dma_tx_ring_free() unmaps every slot with a non-zero dma_addr, so tearing down the ring unmaps these addresses again. It also frees the skbs of pending TX slots but leaves slot->skb and slot->dma_addr set. The slots survive a down/up cycle, and bgmac_dma_tx_add() only sets slot->skb on the last slot of a packet. If a slot with a stale pointer is later used for the head or a fragment of a scatter/gather packet, bgmac_dma_tx_free() frees the old skb a second time when that slot completes.

bgmac_dma_tx_ring_free() also picks dma_unmap_single() or dma_unmap_page() by looking at slot->skb, which is set on the last slot of a packet, while the head was mapped with dma_map_single() and the fragments with skb_frag_dma_map().

In the error path, unmap the head and each mapped fragment from their own slots, and clear dma_addr on every slot the failed packet touched. In bgmac_dma_tx_ring_free(), choose the unmap function by the SOF flag of the descriptor like bgmac_dma_tx_free() does, unmap every slot before freeing any skb, since a packet can wrap around the end of the ring with its skb on the last slot, and clear both fields.

This was found through code inspection by an LLM while hitting other bugs on an Asus RT-N16. It did not hit these ones specifically.

---
 drivers/net/ethernet/broadcom/bgmac.c | 47 +++++++++++++++++----------
 1 file changed, 30 insertions(+), 17 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +30 -17
index 258b3b5a1cdb7..ece93043c506e 100644
@@ -208,19 +208,24 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
 	return NETDEV_TX_OK;
 
 err_dma:
-	dma_unmap_single(dma_dev, slot->dma_addr, skb_headlen(skb),
-			 DMA_TO_DEVICE);
+	slot->dma_addr = 0;
 
 	while (i-- > 0) {
-		int index = (ring->end + i) % BGMAC_TX_RING_SLOTS;
-		struct bgmac_slot_info *slot = &ring->slots[index];
-		u32 ctl1 = le32_to_cpu(ring->cpu_base[index].ctl1);
-		int len = ctl1 & BGMAC_DESC_CTL1_LEN;
-
-		dma_unmap_page(dma_dev, slot->dma_addr, len, DMA_TO_DEVICE);
+		index = (ring->end + 1 + i) % BGMAC_TX_RING_SLOTS;
+		slot = &ring->slots[index];
+		dma_unmap_page(dma_dev, slot->dma_addr,
+			       skb_frag_size(&skb_shinfo(skb)->frags[i]),
+			       DMA_TO_DEVICE);
+		slot->dma_addr = 0;
 	}
 
+	slot = &ring->slots[ring->end % BGMAC_TX_RING_SLOTS];
+	dma_unmap_single(dma_dev, slot->dma_addr, skb_headlen(skb),
+			 DMA_TO_DEVICE);
+
 err_dma_head:
+	slot->dma_addr = 0;
+
 	netdev_err(bgmac->net_dev, "Mapping error of skb on ring 0x%X\n",
 		   ring->mmio_base);
 
@@ -535,17 +540,25 @@ static void bgmac_dma_tx_ring_free(struct bgmac *bgmac,
 		unsigned int len = ctl1 & BGMAC_DESC_CTL1_LEN;
 
 		slot = &ring->slots[i];
-		dev_kfree_skb(slot->skb);
 
-		if (!slot->dma_addr)
-			continue;
+		if (slot->dma_addr) {
+			if (le32_to_cpu(dma_desc[i].ctl0) & BGMAC_DESC_CTL0_SOF)
+				dma_unmap_single(dma_dev, slot->dma_addr,
+						 len, DMA_TO_DEVICE);
+			else
+				dma_unmap_page(dma_dev, slot->dma_addr,
+					       len, DMA_TO_DEVICE);
+			slot->dma_addr = 0;
+		}
+	}
 
-		if (slot->skb)
-			dma_unmap_single(dma_dev, slot->dma_addr,
-					 len, DMA_TO_DEVICE);
-		else
-			dma_unmap_page(dma_dev, slot->dma_addr,
-				       len, DMA_TO_DEVICE);
+	/* A packet can wrap around the end of the ring with its skb on the
+	 * last slot, so free the skbs only once every slot is unmapped.
+	 */
+	for (i = 0; i < BGMAC_TX_RING_SLOTS; i++) {
+		slot = &ring->slots[i];
+		dev_kfree_skb(slot->skb);
+		slot->skb = NULL;
 	}
 }
 
Signature · 1 line
2.53.0
author maintainer
#1730 lore raw

PATCH 1700/1756 tcp: avoid double destroy in tcp_abort() of an unaccepted child

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kyle Zeng <[email protected]>

[ Upstream commit dbd62ad55a4c898f5a4c9edb20c0c062afb799df ]

tcp_abort() checks for TCP_CLOSE while only owning the socket lock, then grabs the BH lock before calling tcp_done_with_error().

For a child still sitting in a listener accept queue (which can be reached via SOCK_DESTROY or bpf_sock_destroy()), inet_csk_listen_stop() can run in this window: it only holds the child BH lock, and calls inet_child_forget(), which disconnects, orphans and destroys the child.

tcp_abort() then calls tcp_done_with_error() -> tcp_done(), which sees SOCK_DEAD and calls inet_csk_destroy_sock() a second time, leading to a double sock_put() and a use-after-free.

Recheck TCP_CLOSE after acquiring the BH lock, unless we just closed a listener ourselves, in which case tcp_done_with_error() must still run to report the error.

Note that the WARN_ON(sock_owned_by_user(child)) in inet_csk_listen_stop() can still trigger in this window.

Fixes bac76cf89816 ("tcp: fix forever orphan socket caused by tcp_abort")
[edumazet: recheck TCP_CLOSE under the BH lock instead of moving the test, smaller diff]
---
 net/ipv4/tcp.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
net/ipv4/tcp.c +13 -1
index 5c2314e600ab0..ba4e7ffa18761 100644
@@ -4912,6 +4912,8 @@ EXPORT_SYMBOL_GPL(tcp_done);
 int tcp_abort(struct sock *sk, int err)
 {
 	int state = inet_sk_state_load(sk);
+	bool listener = false;
+	int ret = 0;
 
 	if (state == TCP_NEW_SYN_RECV) {
 		struct request_sock *req = inet_reqsk(sk);
@@ -4946,21 +4948,31 @@ int tcp_abort(struct sock *sk, int err)
 	if (sk->sk_state == TCP_LISTEN) {
 		tcp_set_state(sk, TCP_CLOSE);
 		inet_csk_listen_stop(sk);
+		listener = true;
 	}
 
 	/* Don't race with BH socket closes such as inet_csk_listen_stop. */
 	local_bh_disable();
 	bh_lock_sock(sk);
 
+	/* An unaccepted child might have been closed by
+	 * inet_csk_listen_stop() while we were not holding its BH lock.
+	 */
+	if (!listener && sk->sk_state == TCP_CLOSE) {
+		ret = -ENOENT;
+		goto out;
+	}
+
 	if (tcp_need_reset(sk->sk_state))
 		tcp_send_active_reset(sk, SK_RST_REASON_TCP_STATE);
 	tcp_done_with_error(sk, err);
 
+out:
 	bh_unlock_sock(sk);
 	local_bh_enable();
 	if (!has_current_bpf_ctx())
 		release_sock(sk);
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(tcp_abort);
 
Signature · 1 line
2.53.0
author maintainer
#1731 lore raw

PATCH 1701/1756 apparmor: fix check SCTP bind, and connect permission checks

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: John Johansen <[email protected]>

[ Upstream commit 7a82f9a06459ff1c37b5e97b204430442cc076e3 ]

SCTP mediation of bind is not being checked correctly because bind permission needs to be checked in the sctp_bind_connect() hook.

Require for bind permissions when CTP_SET_PEER_PRIMARY_ADDR, and SCTP_SOCKOPT_BINDX_ADD are asked for.

The peer initialized ASCONF cases (SCTP_PARAM_ADD_IP and SCTP_PARAM_SET_PRIMARY) are processed in softirq context and are not mediated atm. SCTP_PRIMATEY_ADDR, and SCTP_SET_PEER_PRIMARY_ADDR only select among address already in the association.

Fixes 56974a6fcfef ("apparmor: add base infastructure for socket mediation")
---
 security/apparmor/lsm.c | 5 +++++
 1 file changed, 5 insertions(+)
security/apparmor/lsm.c +5 -0
index 47d772d36627e..b9dd558e55e3a 100644
@@ -1169,6 +1169,11 @@ static int apparmor_sctp_bind_connect(struct sock *sk, int optname,
 				      struct sockaddr *address, int addrlen)
 {
 	switch (optname) {
+	/* Bind checks */
+	case SCTP_SET_PEER_PRIMARY_ADDR:
+	case SCTP_SOCKOPT_BINDX_ADD:
+		return aa_sk_perm(OP_BIND, AA_MAY_BIND, sk);
+	/* Connect checks */
 	case SCTP_SOCKOPT_CONNECTX:
 	case SCTP_SENDMSG_CONNECT:
 		return aa_sk_perm(OP_CONNECT, AA_MAY_CONNECT, sk);
Signature · 1 line
2.53.0
author maintainer
#1732 lore raw

PATCH 1702/1756 tcp: initialize mapped children before route lookup

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kyle Zeng <[email protected]>

[ Upstream commit b7ff0e7a9ae3df2f123807a7e670bc348b1e1b9d ]

IPv4 passive opens on a dual-stack listener go through tcp_v4_syn_recv_sock() with tcp_v6_mapped_child_init() as the optional initializer. The callback currently runs after the output route lookup. If that lookup fails, tcp_done() destroys a clone whose pinet6 and ipv6_fl_list still refer to the listener's state.

With the flowlabel list head in inet_sock, fl6_free_socklist() walks the clone's list and RCU-frees its nodes without unlinking them from the live listener. Subsequent flowlabel operations can use or free the nodes again. Commit 858d2a4f67ff ("tcp: fix potential race in tcp_v6_syn_recv_sock()") moved the initializer before ehash insertion, but did not cover this error path.

Invoke the existing initializer after the IPv4 fields it consumes have been set, but before route lookup can fail. It needs neither the destination nor sk_setup_caps(), and all later disposal paths remain covered.

Fixes 1c17f4373d4d ("ipv6: Move ipv6_fl_list from ipv6_pinfo to inet_sock.")
---
 net/ipv4/tcp_ipv4.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
net/ipv4/tcp_ipv4.c +6 -4
index c32ec598930b1..b42630611afc7 100644
@@ -1790,6 +1790,12 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
 	if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_reflect_tos))
 		newinet->tos = tcp_rsk(req)->syn_tos & ~INET_ECN_MASK;
 
+#if IS_ENABLED(CONFIG_IPV6)
+	/* Detach IPv6 state before a route lookup can fail. */
+	if (opt_child_init)
+		opt_child_init(newsk, sk);
+#endif
+
 	if (!dst) {
 		dst = inet_csk_route_child_sock(sk, newsk, req);
 		if (!dst)
@@ -1799,10 +1805,6 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
 	}
 	sk_setup_caps(newsk, dst);
 
-#if IS_ENABLED(CONFIG_IPV6)
-	if (opt_child_init)
-		opt_child_init(newsk, sk);
-#endif
 	tcp_ca_openreq_child(newsk, dst);
 
 	tcp_sync_mss(newsk, dst4_mtu(dst));
Signature · 1 line
2.53.0
author maintainer
#1733 lore raw

PATCH 1703/1756 net: add eth_type_trans_careful()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <[email protected]>

[ Upstream commit 2519a6fe7a8bba57a961eb804e43e7df35ac40fe ]

eth_type_trans() assumes ETH_HLEN bytes are present in skb->head. NIC drivers always provide this, and they should keep using the fast version.

Devices looping skbs from their transmit path back to their receive path get skbs built by the stack instead. Their link-layer header might have been popped by tc actions (act_vlan pop_eth, act_ife decode) or OVS actions (pop_eth + pop_mpls / pop_nsh), leaving fewer than ETH_HLEN bytes in the linear part. eth_type_trans() then hits the BUG() in __skb_pull().

Add eth_type_trans_careful(), which first pulls the Ethernet header, and returns a drop reason on failure, so that the few devices exposed to this can drop such packets.

Stable-dep-of: 093a28998374 ("loopback: use eth_type_trans_careful()")

---
 include/linux/etherdevice.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/linux/etherdevice.h +28 -0
index a3ae683affa58..1188bc2f41ac6 100644
@@ -38,6 +38,34 @@ int fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr);
 
 u32 eth_get_headlen(const struct net_device *dev, const void *data, u32 len);
 __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev);
+
+/**
+ * eth_type_trans_careful - eth_type_trans() for skbs coming from the stack
+ * @skb: buffer, possibly with less than ETH_HLEN bytes in its linear area
+ * @dev: receiving network device
+ *
+ * eth_type_trans() expects ETH_HLEN bytes in skb->head, which NIC drivers
+ * provide. Devices looping skbs from their transmit path back to the
+ * receive path (loopback, OVS internal ports) get skbs built by the stack,
+ * whose link-layer header might have been popped by tc or OVS actions.
+ *
+ * Sets skb->protocol on success.
+ *
+ * Return: SKB_NOT_DROPPED_YET on success, or a drop reason. In the latter
+ * case, the caller must free @skb.
+ */
+static inline enum skb_drop_reason
+eth_type_trans_careful(struct sk_buff *skb, struct net_device *dev)
+{
+	enum skb_drop_reason reason = pskb_may_pull_reason(skb, ETH_HLEN);
+
+	if (unlikely(reason))
+		return reason;
+
+	skb->protocol = eth_type_trans(skb, dev);
+	return SKB_NOT_DROPPED_YET;
+}
+
 extern const struct header_ops eth_header_ops;
 
 int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
Signature · 1 line
2.53.0
author maintainer
#1734 lore raw

PATCH 1704/1756 loopback: use eth_type_trans_careful()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <[email protected]>

[ Upstream commit 093a28998374f4007ffe67cc661f8192c1b062a9 ]

tc egress actions can leave an skb with fewer than ETH_HLEN bytes in its linear part. loopback_xmit() then crashes in eth_type_trans():

tc qdisc add dev lo clsact
tc filter add dev lo egress matchall action vlan pop_eth # AF_PACKET SOCK_RAW: eth / eth / 8192 bytes of payload

kernel BUG at include/linux/skbuff.h:2839!

  RIP: 0010:eth_type_trans (include/linux/etherdevice.h:635 net/ethernet/eth.c:163)
  Call Trace:
   loopback_xmit (drivers/net/loopback.c:87)
   dev_hard_start_xmit (include/linux/netdevice.h:5455 include/linux/netdevice.h:5464 net/core/dev.c:4057 net/core/dev.c:4073)
   __dev_queue_xmit (net/core/dev.c:5066)
   packet_sendmsg (net/packet/af_packet.c:3157 net/packet/af_packet.c:3189)

The same happens with "action ife decode" on lo egress.

Use eth_type_trans_careful(), and drop the packet if the Ethernet header can not be pulled.

---
 drivers/net/loopback.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/loopback.c +7 -1
index 63b236efb3b70..625ffc4149ce2 100644
@@ -69,6 +69,7 @@ EXPORT_SYMBOL(blackhole_netdev);
 static netdev_tx_t loopback_xmit(struct sk_buff *skb,
 				 struct net_device *dev)
 {
+	enum skb_drop_reason reason;
 	int len;
 
 	skb_tx_timestamp(skb);
@@ -83,7 +84,12 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
 	 */
 	skb_dst_force(skb);
 
-	skb->protocol = eth_type_trans(skb, dev);
+	reason = eth_type_trans_careful(skb, dev);
+	if (unlikely(reason)) {
+		dev_core_stats_tx_dropped_inc(dev);
+		kfree_skb_reason(skb, reason);
+		return NETDEV_TX_OK;
+	}
 
 	len = skb->len;
 	if (likely(__netif_rx(skb) == NET_RX_SUCCESS))
Signature · 1 line
2.53.0
author maintainer
#1735 lore raw

PATCH 1705/1756 selftests/bpf: cover short IPv4/IPv6 inputs with adjust_room

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Sun Jian <[email protected]>

[ Upstream commit f1cc94665df907a85589ddb5fe74d7768ff61533 ]

Add a selftest covering ETH_HLEN-sized IPv4/IPv6 EtherType inputs for bpf_prog_test_run_skb().

Reuse a single zero-initialized struct ethhdr eth_hlen and set eth_hlen.h_proto from the per-test h_proto field.

Also add a dedicated tc_adjust_room program and route the short IPv4/IPv6 cases to it, so the selftest actually exercises the bpf_skb_adjust_room() path from the report.

Stable-dep-of: 695e1408eb90 ("net: use eth_type_trans_careful() in __dev_forward_skb2()")

---
 .../selftests/bpf/prog_tests/empty_skb.c      | 40 +++++++++++++++++--
 tools/testing/selftests/bpf/progs/empty_skb.c |  7 ++++
 2 files changed, 44 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/empty_skb.c +37 -3
index 438583e1f2d12..c9fcb70cbafbc 100644
@@ -10,8 +10,8 @@ void test_empty_skb(void)
 	struct empty_skb *bpf_obj = NULL;
 	struct nstoken *tok = NULL;
 	struct bpf_program *prog;
+	struct ethhdr eth_hlen;
 	char eth_hlen_pp[15];
-	char eth_hlen[14];
 	int veth_ifindex;
 	int ipip_ifindex;
 	int err;
@@ -25,7 +25,9 @@ void test_empty_skb(void)
 		int err;
 		int ret;
 		int lwt_egress_ret; /* expected retval at lwt/egress */
+		__be16 h_proto;
 		bool success_on_tc;
+		bool adjust_room;
 	} tests[] = {
 		/* Empty packets are always rejected. */
 
@@ -46,6 +48,28 @@ void test_empty_skb(void)
 			.err = -EINVAL,
 		},
 
+		/* ETH_HLEN-sized packets with IPv4/IPv6 EtherType but
+		 * no L3 header are rejected.
+		 */
+		{
+			.msg = "veth short IPv4 ingress packet",
+			.data_in = &eth_hlen,
+			.data_size_in = sizeof(eth_hlen),
+			.ifindex = &veth_ifindex,
+			.err = -EINVAL,
+			.h_proto = htons(ETH_P_IP),
+			.adjust_room = true,
+		},
+		{
+			.msg = "veth short IPv6 ingress packet",
+			.data_in = &eth_hlen,
+			.data_size_in = sizeof(eth_hlen),
+			.ifindex = &veth_ifindex,
+			.err = -EINVAL,
+			.h_proto = htons(ETH_P_IPV6),
+			.adjust_room = true,
+		},
+
 		/* ETH_HLEN-sized packets:
 		 * - can not be redirected at LWT_XMIT
 		 * - can be redirected at TC to non-tunneling dest
@@ -54,7 +78,7 @@ void test_empty_skb(void)
 		{
 			/* __bpf_redirect_common */
 			.msg = "veth ETH_HLEN packet ingress",
-			.data_in = eth_hlen,
+			.data_in = &eth_hlen,
 			.data_size_in = sizeof(eth_hlen),
 			.ifindex = &veth_ifindex,
 			.ret = -ERANGE,
@@ -68,7 +92,7 @@ void test_empty_skb(void)
 			 * tc: skb->len=14 <= skb_network_offset=14
 			 */
 			.msg = "ipip ETH_HLEN packet ingress",
-			.data_in = eth_hlen,
+			.data_in = &eth_hlen,
 			.data_size_in = sizeof(eth_hlen),
 			.ifindex = &ipip_ifindex,
 			.ret = -ERANGE,
@@ -108,17 +132,27 @@ void test_empty_skb(void)
 	SYS(out, "ip addr add 192.168.1.1/16 dev ipip0");
 	ipip_ifindex = if_nametoindex("ipip0");
 
+	memset(eth_hlen_pp, 0, sizeof(eth_hlen_pp));
+	memset(&eth_hlen, 0, sizeof(eth_hlen));
+
 	bpf_obj = empty_skb__open_and_load();
 	if (!ASSERT_OK_PTR(bpf_obj, "open skeleton"))
 		goto out;
 
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
+		if (tests[i].data_in == &eth_hlen)
+			eth_hlen.h_proto = tests[i].h_proto;
+
 		bpf_object__for_each_program(prog, bpf_obj->obj) {
 			bool at_egress = strstr(bpf_program__name(prog), "egress") != NULL;
 			bool at_tc = !strncmp(bpf_program__section_name(prog), "tc", 2);
+			bool is_adjust_room = !strcmp(bpf_program__name(prog), "tc_adjust_room");
 			int expected_ret;
 			char buf[128];
 
+			if (tests[i].adjust_room != is_adjust_room)
+				continue;
+
 			expected_ret = at_egress && !at_tc ? tests[i].lwt_egress_ret : tests[i].ret;
 
 			tattr.data_in = tests[i].data_in;
tools/testing/selftests/bpf/progs/empty_skb.c +7 -0
index 4b0cd67532511..44326f5cc8bb4 100644
@@ -35,3 +35,10 @@ int tc_redirect_egress(struct __sk_buff *skb)
 	ret = bpf_clone_redirect(skb, ifindex, 0);
 	return 0;
 }
+
+SEC("tc")
+int tc_adjust_room(struct __sk_buff *skb)
+{
+	ret = bpf_skb_adjust_room(skb, 4, BPF_ADJ_ROOM_NET, 0);
+	return 0;
+}
Signature · 1 line
2.53.0
author maintainer
#1736 lore raw

PATCH 1706/1756 net: use eth_type_trans_careful() in __dev_forward_skb2()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <[email protected]>

[ Upstream commit 695e1408eb908ac7acf78069933201f92b95727c ]

A tc egress BPF program can push a tiny link-layer header with bpf_skb_change_head() on an skb whose head is almost empty, then redirect it to an Ethernet device ingress. __bpf_redirect_common() only checks mac_header < network_header, and __dev_forward_skb2() crashes in eth_type_trans():

tc filter add dev lo egress pref 1 matchall action vlan pop_eth continue tc filter add dev lo egress pref 2 bpf da obj prog.o
# prog: bpf_skb_change_head(skb, 1, 0);
# return bpf_redirect(veth1_ifindex, BPF_F_INGRESS);
# AF_PACKET SOCK_RAW on lo: eth / eth / 8192 bytes of payload

kernel BUG at include/linux/skbuff.h:2839!

  RIP: 0010:eth_type_trans (include/linux/etherdevice.h:635 net/ethernet/eth.c:163)
  Call Trace:
   __dev_forward_skb2 (net/core/dev.c:2507)
   dev_forward_skb_nomtu (net/core/dev.c:2546)
   __dev_queue_xmit (net/core/dev.c:4738 net/core/dev.c:4998)
   packet_sendmsg (net/packet/af_packet.c:3157 net/packet/af_packet.c:3189)

Use eth_type_trans_careful(), and drop the packet if the Ethernet header can not be pulled. This also covers other dev_forward_skb() users (veth, macvlan, ipvlan, netdevsim, l2tp_eth).

Update the empty_skb BPF selftest: at lwt_xmit, BPF_PROG_TEST_RUN strips the Ethernet header, so the "veth ETH_HLEN+1" packet is a 1-byte skb. Redirecting it to veth ingress used to read the Ethernet header past skb->tail and deliver a 1-byte frame; it is now dropped with NET_RX_DROP, as veth_xmit() already does at egress.

---
 net/core/dev.c                                | 18 +++++++++++++-----
 .../selftests/bpf/prog_tests/empty_skb.c      | 19 ++++++++++++-------
 2 files changed, 25 insertions(+), 12 deletions(-)
net/core/dev.c +13 -5
index 857d195bef231..b0e328fc8adf6 100644
@@ -2260,14 +2260,22 @@ EXPORT_SYMBOL_GPL(is_skb_forwardable);
 static int __dev_forward_skb2(struct net_device *dev, struct sk_buff *skb,
 			      bool check_mtu)
 {
-	int ret = ____dev_forward_skb(dev, skb, check_mtu);
+	enum skb_drop_reason reason;
+	int ret;
+
+	ret = ____dev_forward_skb(dev, skb, check_mtu);
+	if (unlikely(ret))
+		return ret;
 
-	if (likely(!ret)) {
-		skb->protocol = eth_type_trans(skb, dev);
-		skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
+	reason = eth_type_trans_careful(skb, dev);
+	if (unlikely(reason)) {
+		dev_core_stats_rx_dropped_inc(dev);
+		kfree_skb_reason(skb, reason);
+		return NET_RX_DROP;
 	}
+	skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
 
-	return ret;
+	return 0;
 }
 
 int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
tools/testing/selftests/bpf/prog_tests/empty_skb.c +12 -7
index c9fcb70cbafbc..a3938c16557b1 100644
@@ -24,7 +24,7 @@ void test_empty_skb(void)
 		int *ifindex;
 		int err;
 		int ret;
-		int lwt_egress_ret; /* expected retval at lwt/egress */
+		int lwt_ret; /* expected retval at lwt */
 		__be16 h_proto;
 		bool success_on_tc;
 		bool adjust_room;
@@ -82,7 +82,7 @@ void test_empty_skb(void)
 			.data_size_in = sizeof(eth_hlen),
 			.ifindex = &veth_ifindex,
 			.ret = -ERANGE,
-			.lwt_egress_ret = -ERANGE,
+			.lwt_ret = -ERANGE,
 			.success_on_tc = true,
 		},
 		{
@@ -96,17 +96,23 @@ void test_empty_skb(void)
 			.data_size_in = sizeof(eth_hlen),
 			.ifindex = &ipip_ifindex,
 			.ret = -ERANGE,
-			.lwt_egress_ret = -ERANGE,
+			.lwt_ret = -ERANGE,
 		},
 
-		/* ETH_HLEN+1-sized packet should be redirected. */
+		/* ETH_HLEN+1-sized packet should be redirected at TC.
+		 * At LWT, the Ethernet header is not part of the skb, and
+		 * a 1-byte packet is too short for an Ethernet device.
+		 */
 
 		{
 			.msg = "veth ETH_HLEN+1 packet ingress",
 			.data_in = eth_hlen_pp,
 			.data_size_in = sizeof(eth_hlen_pp),
 			.ifindex = &veth_ifindex,
-			.lwt_egress_ret = 1, /* veth_xmit NET_XMIT_DROP */
+			/* lwt: skb->len=1, dropped by veth_xmit() at egress
+			 * and by __dev_forward_skb2() at ingress.
+			 */
+			.lwt_ret = 1, /* NET_XMIT_DROP / NET_RX_DROP */
 		},
 		{
 			.msg = "ipip ETH_HLEN+1 packet ingress",
@@ -144,7 +150,6 @@ void test_empty_skb(void)
 			eth_hlen.h_proto = tests[i].h_proto;
 
 		bpf_object__for_each_program(prog, bpf_obj->obj) {
-			bool at_egress = strstr(bpf_program__name(prog), "egress") != NULL;
 			bool at_tc = !strncmp(bpf_program__section_name(prog), "tc", 2);
 			bool is_adjust_room = !strcmp(bpf_program__name(prog), "tc_adjust_room");
 			int expected_ret;
@@ -153,7 +158,7 @@ void test_empty_skb(void)
 			if (tests[i].adjust_room != is_adjust_room)
 				continue;
 
-			expected_ret = at_egress && !at_tc ? tests[i].lwt_egress_ret : tests[i].ret;
+			expected_ret = at_tc ? tests[i].ret : tests[i].lwt_ret;
 
 			tattr.data_in = tests[i].data_in;
 			tattr.data_size_in = tests[i].data_size_in;
Signature · 1 line
2.53.0
author maintainer
#1737 lore raw

PATCH 1707/1756 openvswitch: use eth_type_trans_careful() in internal_dev_recv()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <[email protected]>

[ Upstream commit b55e5a0159c8f53edefcb7848d95eb93db37bce1 ]

OVS actions like pop_eth followed by pop_mpls(ETH_P_TEB) or pop_nsh can expose an inner Ethernet header which is not in the linear part of the skb. Output to an internal port then crashes in eth_type_trans():

flow: in_port(0),eth(),eth_type(0x8847),mpls(lse=0x00010140)
actions: pop_eth,pop_mpls(0x6558),0
# AF_PACKET SOCK_RAW on dp0: eth / mpls / eth / 4096 bytes of payload

kernel BUG at include/linux/skbuff.h:2839!

  RIP: 0010:eth_type_trans (include/linux/etherdevice.h:635 net/ethernet/eth.c:163)
  Call Trace:
   internal_dev_recv (net/openvswitch/vport-internal_dev.c:202) openvswitch
   do_execute_actions (net/openvswitch/actions.c:1296) openvswitch
   ovs_execute_actions (net/openvswitch/actions.c:1606) openvswitch
   ovs_dp_process_packet (net/openvswitch/datapath.c:310) openvswitch
   ovs_vport_receive (net/openvswitch/vport.c:448) openvswitch
   internal_dev_xmit (net/openvswitch/vport-internal_dev.c:42) openvswitch
   dev_hard_start_xmit (include/linux/netdevice.h:5455 include/linux/netdevice.h:5464 net/core/dev.c:4057 net/core/dev.c:4073)
   __dev_queue_xmit (net/core/dev.c:5066)
   packet_sendmsg (net/packet/af_packet.c:3157 net/packet/af_packet.c:3189)

Use eth_type_trans_careful(), and drop the packet if the Ethernet header can not be pulled. This covers all OVS actions at the consumer, instead of fixing each producer.

Fixes b2d0f5d5dc53 ("openvswitch: enable NSH support")
Fixes f66b53fdbb22 ("openvswitch: New MPLS actions for layer 2 tunnelling")
---
 net/openvswitch/vport-internal_dev.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
net/openvswitch/vport-internal_dev.c +7 -1
index 7b05a423a9ab9..f01393351991e 100644
@@ -186,6 +186,7 @@ static void internal_dev_destroy(struct vport *vport)
 static int internal_dev_recv(struct sk_buff *skb)
 {
 	struct net_device *netdev = skb->dev;
+	enum skb_drop_reason reason;
 
 	if (unlikely(!(netdev->flags & IFF_UP))) {
 		kfree_skb(skb);
@@ -198,7 +199,12 @@ static int internal_dev_recv(struct sk_buff *skb)
 	secpath_reset(skb);
 
 	skb->pkt_type = PACKET_HOST;
-	skb->protocol = eth_type_trans(skb, netdev);
+	reason = eth_type_trans_careful(skb, netdev);
+	if (unlikely(reason)) {
+		dev_core_stats_rx_dropped_inc(netdev);
+		kfree_skb_reason(skb, reason);
+		return NETDEV_TX_OK;
+	}
 	skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
 	dev_sw_netstats_rx_add(netdev, skb->len);
 
Signature · 1 line
2.53.0
author maintainer
#1738 lore raw

PATCH 1708/1756 netlink: check sk_rcvbuf before charging the dump skb

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jhonata Poma-Hansen <[email protected]>

[ Upstream commit b45d37740cfb4bdfccef3fbd9fd970fd3224438f ]

Since commit ae8f160e7eb2 ("netlink: Fix wraparounds of sk->sk_rmem_alloc."), netlink_dump() charges the dump skb first and queues it only if sk_rmem_alloc is still below sk_rcvbuf. Commit a215b5723922 ("netlink: make sure we allow at least one dump skb") added an exception for an empty socket.

A dump that starts while something else is still charged to a socket with a small receive buffer fails with ENOBUFS and stays running. Every recvmsg() retries it, fails again and sets sk_err, so a reader that peeks before reading, as libnl does, gets ENOBUFS on the read after each peek, never consumes the message at the head of the queue and spins forever.

I hit this with "iw dev wlan0 scan" hanging at 100% CPU on an arm64 board with a 6.6 based kernel (iw 5.19 sets SO_RCVBUF to 8KiB). A kprobe trace showed the scan dump starting while the NEW_SCAN_RESULTS notification iw had just read was still charged to its socket, because iw had preempted the sender before netlink_broadcast() returned.

Check the limit before charging, as before ae8f160e7eb2, which also covers the empty socket. netlink_recvmsg() continues a dump only at or below half of sk_rcvbuf, so the skb is then always queued, and a dump goes over the limit by at most one skb. Refuse a skb that would take sk_rmem_alloc past INT_MAX, so the wraparound stays fixed.

Reproduced on net in a KVM guest with a userspace reproducer and the selftest in the next patch; both pass with this fix.

Fixes ae8f160e7eb2 ("netlink: Fix wraparounds of sk->sk_rmem_alloc.")
---
 net/netlink/af_netlink.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/netlink/af_netlink.c +5 -1
index fb84eaa63d0ac..8977798d42322 100644
@@ -2300,9 +2300,13 @@ static int netlink_dump(struct sock *sk, bool lock_taken)
 	if (!skb)
 		goto errout_skb;
 
+	/* Check the limit before charging the skb: netlink_recvmsg() continues
+	 * the dump at or below half of sk_rcvbuf, and the skb must be queued
+	 * then. Keep sk_rmem_alloc at or below INT_MAX.
+	 */
 	rcvbuf = READ_ONCE(sk->sk_rcvbuf);
 	rmem = atomic_add_return(skb->truesize, &sk->sk_rmem_alloc);
-	if (rmem != skb->truesize && rmem >= rcvbuf) {
+	if (rmem - skb->truesize >= rcvbuf || rmem > INT_MAX) {
 		atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
 		goto errout_skb;
 	}
Signature · 1 line
2.53.0
author maintainer
#1739 lore raw

PATCH 1709/1756 apparmor: advertise that sctp is being mediated

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: John Johansen <[email protected]>

[ Upstream commit 35b8ab3f36ac0fcd8fc910da0bed889b6c75c426 ]

Enable the test harness to detect that the kernel should be properly mediating sctp.

Fixes 7a82f9a06459f ("apparmor: fix check SCTP bind, and connect permission checks")
---
 security/apparmor/net.c | 1 +
 1 file changed, 1 insertion(+)
security/apparmor/net.c +1 -0
index 6e989184e4086..662a1b58d7d72 100644
@@ -22,6 +22,7 @@
 struct aa_sfs_entry aa_sfs_entry_network[] = {
 	AA_SFS_FILE_STRING("af_mask",	AA_SFS_AF_MASK),
 	AA_SFS_FILE_BOOLEAN("tcp-fast-open",		1),
+	AA_SFS_FILE_BOOLEAN("sctp",		1),
 	{ }
 };
 
Signature · 1 line
2.53.0
author maintainer
#1740 lore raw

PATCH 1710/1756 tun: drop batched packets while the device is down

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Xiao Liang <[email protected]>

[ Upstream commit 8f44631ba02afe9fff2f0a0fb66560ab19df87fd ]

tun_sendmsg() handles TUN_MSG_PTR batches from vhost-net by calling tun_xdp_one() instead of tun_get_user(). But this path does not check IFF_UP, allowing packets from a guest to be injected into the host receive path while the device is administratively down.

Check IFF_UP in tun_xdp_one() before running XDP or building an skb. Drop the packet when the device is down, matching tun_get_user().

Fixes 043d222f93ab ("tuntap: accept an array of XDP buffs through sendmsg()")
---
 drivers/net/tun.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/tun.c +6 -0
index 479108e87e3d8..461b02721aab9 100644
@@ -2483,6 +2483,12 @@ static int tun_xdp_one(struct tun_struct *tun,
 		return -EINVAL;
 	}
 
+	if (unlikely(!(READ_ONCE(tun->dev->flags) & IFF_UP))) {
+		put_page(virt_to_head_page(xdp->data));
+		dev_core_stats_rx_dropped_inc(tun->dev);
+		return -EIO;
+	}
+
 	xdp_prog = rcu_dereference(tun->xdp_prog);
 	if (xdp_prog) {
 		if (gso->gso_type) {
Signature · 1 line
2.53.0
author maintainer
#1741 lore raw

PATCH 1711/1756 watch_queue: keep info_id separate from rcu_head

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Zhiyu Zhang <[email protected]>

[ Upstream commit 53d72818f9e2aeb03a6053544ee6efa4eb2a3988 ]

struct watch overlays info_id with rcu_head. A notification poster reads info_id under rcu_read_lock(), but a concurrent final put can enqueue the watch with call_rcu(). Enqueueing the callback writes rcu_head before the grace period has elapsed, so it can corrupt info_id while the object remains legally visible to the reader.

__post_watch_notification() then merges that value into the notification info word without masking it. Pointer bits can corrupt WATCH_INFO_LENGTH and make post_one_notification() copy beyond the posting task's stack record.

Give info_id storage separate from rcu_head so RCU enqueueing cannot modify it. Place it after the kref, which uses existing tail padding on x86-64. Mask info_id with WATCH_INFO_ID at the point of use as an additional invariant check.

An unprivileged shell and keyctl reproducer was run for 30 seconds in QEMU. The vulnerable baseline produced malformed notification lengths, while this change completed with 288631 key notifications and no malformed record.

---
 include/linux/watch_queue.h | 6 ++----
 kernel/watch_queue.c        | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)
include/linux/watch_queue.h +2 -4
index 429c7b6afeada..b87e1babb5f03 100644
@@ -52,10 +52,7 @@ struct watch_queue {
  * Representation of a watch on an object.
  */
 struct watch {
-	union {
-		struct rcu_head	rcu;
-		u32		info_id;	/* ID to be OR'd in to info field */
-	};
+	struct rcu_head		rcu;
 	struct watch_queue __rcu *queue;	/* Queue to post events to */
 	struct hlist_node	queue_node;	/* Link in queue->watches */
 	struct watch_list __rcu	*watch_list;
@@ -64,6 +61,7 @@ struct watch {
 	void			*private;	/* Private data for the watched object */
 	u64			id;		/* Internal identifier */
 	struct kref		usage;		/* Object usage count */
+	u32			info_id;	/* ID to be OR'd in to info field */
 };
 
 /*
kernel/watch_queue.c +1 -1
index 8f809cc60c036..8914bd27d751c 100644
@@ -212,7 +212,7 @@ void __post_watch_notification(struct watch_list *wlist,
 		if (watch->id != id)
 			continue;
 		n->info &= ~WATCH_INFO_ID;
-		n->info |= watch->info_id;
+		n->info |= watch->info_id & WATCH_INFO_ID;
 
 		wqueue = rcu_dereference(watch->queue);
 		wf = rcu_dereference(wqueue->filter);
Signature · 1 line
2.53.0
author maintainer
#1742 lore raw

PATCH 1712/1756 splice: retry tee() instead of returning 0 when it races

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nickolai Zeldovich <[email protected]>

[ Upstream commit b2aa970a0a03c117306f48d75a4c3125a8cc9957 ]

tee() can return 0 while the input pipe still has writers, when another task reads the input pipe or fills the output pipe at the same time. tee(2) documents 0 as "no data was copied" because the input pipe has no writers, and loops built on it (the man page example breaks out on 0) stop early. In a test with one thread writing 1 byte at a time to the input pipe, one reading it and one draining the output pipe, about one tee() call in 150 returned 0.

do_tee() runs ipipe_prep() and opipe_prep() to wait for data and room, each under its own pipe lock, and only then takes both locks in link_pipe(). If the input pipe was emptied or the output pipe filled in between, link_pipe() finds nothing to do and returns 0. splice_pipe_to_pipe(), which was modelled on tee(), handles the same race by dropping both locks and going back to the prep steps ("A zero return value means EOF, so retry instead"), and returns -EAGAIN for SPLICE_F_NONBLOCK.

Do the same in link_pipe(): move the prep steps into it and retry when nothing was linked although the input pipe still has writers.

Tested under QEMU (x86_64) with the program in the notes: 154 of 22698 tee() calls returned 0 before the change, none of 34429 after it.

---
 fs/splice.c | 43 +++++++++++++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 12 deletions(-)
fs/splice.c +31 -12
index a8f4ec2b7de10..aaa4c89cb28f5 100644
@@ -1886,6 +1886,15 @@ static ssize_t link_pipe(struct pipe_inode_info *ipipe,
 	unsigned int i_mask, o_mask;
 	ssize_t ret = 0;
 
+retry:
+	ret = ipipe_prep(ipipe, flags);
+	if (ret)
+		return ret;
+
+	ret = opipe_prep(opipe, flags);
+	if (ret)
+		return ret;
+
 	/*
 	 * Potential ABBA deadlock, work around it by ordering lock
 	 * grabbing by pipe info address. Otherwise two different processes
@@ -1909,13 +1918,32 @@ static ssize_t link_pipe(struct pipe_inode_info *ipipe,
 		i_head = ipipe->head;
 		o_tail = opipe->tail;
 
+		if (pipe_empty(i_head, i_tail) && !ipipe->writers)
+			break;
+
 		/*
 		 * If we have iterated all input buffers or run out of
 		 * output room, break.
 		 */
 		if (pipe_empty(i_head, i_tail) ||
-		    pipe_full(o_head, o_tail, opipe->max_usage))
-			break;
+		    pipe_full(o_head, o_tail, opipe->max_usage)) {
+			if (ret)
+				break;
+
+			if (flags & SPLICE_F_NONBLOCK) {
+				ret = -EAGAIN;
+				break;
+			}
+
+			/*
+			 * We raced with another reader/writer and haven't
+			 * linked any buffers. A zero return value means EOF,
+			 * so retry instead.
+			 */
+			pipe_unlock(ipipe);
+			pipe_unlock(opipe);
+			goto retry;
+		}
 
 		ibuf = &ipipe->bufs[i_tail & i_mask];
 		obuf = &opipe->bufs[o_head & o_mask];
@@ -1986,16 +2014,7 @@ ssize_t do_tee(struct file *in, struct file *out, size_t len,
 		if ((in->f_flags | out->f_flags) & O_NONBLOCK)
 			flags |= SPLICE_F_NONBLOCK;
 
-		/*
-		 * Keep going, unless we encounter an error. The ipipe/opipe
-		 * ordering doesn't really matter.
-		 */
-		ret = ipipe_prep(ipipe, flags);
-		if (!ret) {
-			ret = opipe_prep(opipe, flags);
-			if (!ret)
-				ret = link_pipe(ipipe, opipe, len, flags);
-		}
+		ret = link_pipe(ipipe, opipe, len, flags);
 	}
 
 	if (ret > 0) {
Signature · 1 line
2.53.0
author maintainer
#1743 lore raw

PATCH 1713/1756 ucount: read the parent ucounts before dropping the rlimit count

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nickolai Zeldovich <[email protected]>

[ Upstream commit 38bf603d1ea5d5a65a9cb277df75327ffec01ff1 ]

do_dec_rlimit_put_ucounts() drops its share of iter->rlimit[type] and only then loads iter->ns->ucounts. If the decrement leaves the count non-zero, a concurrent caller can take it to zero and put the last reference, which frees the ucounts and possibly its user namespace with kfree_rcu(). An exiting task frees its pending signals without siglock or any RCU read-side section, so when it is preempted between the decrement and the load for a grace period it reads freed memory and then decrements a counter through the pointer it found there.

A pending signal holds no reference on its ucounts: the reference is taken by whoever moves the count from 0 to 1 and dropped by whoever moves it back to 0, so the caller's share of the count is all that keeps iter alive, and only until it is dropped.

Load the parent first; it stays pinned by the caller's share of its own count.

---
 kernel/ucount.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
kernel/ucount.c +5 -2
index b731d13e6b766..232705e8375c0 100644
@@ -294,9 +294,12 @@ static void do_dec_rlimit_put_ucounts(struct ucounts *ucounts,
 {
 	struct ucounts *iter, *next;
 	for (iter = ucounts; iter != last; iter = next) {
-		long dec = atomic_long_sub_return(1, &iter->rlimit[type]);
-		WARN_ON_ONCE(dec < 0);
+		long dec;
+
+		/* Our count pins @iter; once it is dropped @iter may be freed. */
 		next = iter->ns->ucounts;
+		dec = atomic_long_sub_return(1, &iter->rlimit[type]);
+		WARN_ON_ONCE(dec < 0);
 		if (dec == 0)
 			put_ucounts(iter);
 	}
Signature · 1 line
2.53.0
author maintainer
#1744 lore raw

PATCH 1714/1756 fs_pin: do not trust the pin after a spurious wakeup in pin_kill()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nickolai Zeldovich <[email protected]>

[ Upstream commit f3a6dae67c9ca3d913cbb42fe324c9b47c8d9e53 ]

A task waiting in pin_kill() for another task's ->kill() can take p->wait.lock after the pin has been freed, and can return with its on-stack wait entry still on p->wait. With BSD process accounting this is a use-after-free of the acct structure when umount() of the mount holding the accounting file races with acct(2).

pin_kill() takes a still-queued entry as proof that pin_remove() has not run, so p is alive. But autoremove_wake_function() dequeues only when try_to_wake_up() succeeds: if the waiter was already woken spuriously, pin_remove() leaves the entry queued, acct_pin_kill() frees the acct with kfree_rcu(), and the grace period can end while the waiter sits between schedule() and rcu_read_lock().

Dequeue the entry unconditionally in a private wake function; pin_remove() is the only waker and sets p->done first.

Reproduced under QEMU with KASAN and test-only delays: a slab-use-after-free in pin_kill() before the patch, no report after.

---
 fs/fs_pin.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
fs/fs_pin.c +14 -1
index 1a508f2167e0a..a4e5a5a7aca8d 100644
@@ -28,6 +28,19 @@ void pin_insert(struct fs_pin *pin, struct vfsmount *m)
 	spin_unlock(&pin_lock);
 }
 
+/*
+ * Unlike autoremove_wake_function(), dequeue even if the waiter was already
+ * running: pin_kill() trusts @p only while its entry is still queued.
+ */
+static int pin_kill_wake_function(struct wait_queue_entry *wait,
+				  unsigned int mode, int sync, void *key)
+{
+	int ret = default_wake_function(wait, mode, sync, key);
+
+	list_del_init_careful(&wait->entry);
+	return ret;
+}
+
 void pin_kill(struct fs_pin *p)
 {
 	wait_queue_entry_t wait;
@@ -36,7 +49,7 @@ void pin_kill(struct fs_pin *p)
 		rcu_read_unlock();
 		return;
 	}
-	init_wait(&wait);
+	init_wait_func(&wait, pin_kill_wake_function);
 	spin_lock_irq(&p->wait.lock);
 	if (likely(!p->done)) {
 		p->done = -1;
Signature · 1 line
2.53.0
author maintainer
#1745 lore raw

PATCH 1715/1756 Add error handling to minix filesystem for inode corruption detection

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jori Koolstra <[email protected]>

[ Upstream commit 21215ce7a95ae03891708028a8c805e5dc47395e ]

We would like to provide early and specific warnings of filesystem corruption without running into generic WARN_ONs and BUG_ONs. Towards this goal, ext4, e.g., has a EFSCORRUPTED errno and a standardized inode corruption message format. This patch adds this errno and message format to the minix filesystem.

Stable-dep-of: fc9577079df8 ("minix: reject rmdir of a directory with a corrupted link count")

---
 fs/minix/inode.c | 16 ++++++++++++++++
 fs/minix/minix.h |  9 +++++++++
 2 files changed, 25 insertions(+)
fs/minix/inode.c +16 -0
index 7084f41cefbcd..1bea63d71b806 100644
@@ -26,6 +26,22 @@ static int minix_write_inode(struct inode *inode,
 		struct writeback_control *wbc);
 static int minix_statfs(struct dentry *dentry, struct kstatfs *buf);
 
+void __minix_error_inode(struct inode *inode, const char *function,
+			 unsigned int line, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+
+	va_start(args, fmt);
+	vaf.fmt = fmt;
+	vaf.va = &args;
+	printk(KERN_CRIT "minix-fs error (device %s): %s:%d: "
+	       "inode #%lu: comm %s: %pV\n",
+	       inode->i_sb->s_id, function, line, inode->i_ino,
+	       current->comm, &vaf);
+	va_end(args);
+}
+
 static void minix_evict_inode(struct inode *inode)
 {
 	truncate_inode_pages_final(&inode->i_data);
fs/minix/minix.h +9 -0
index c81e48badae93..73e1087502253 100644
@@ -42,6 +42,9 @@ struct minix_sb_info {
 	unsigned short s_version;
 };
 
+void __minix_error_inode(struct inode *inode, const char *function,
+			 unsigned int line, const char *fmt, ...);
+
 struct inode *minix_iget(struct super_block *, unsigned long);
 struct minix_inode *minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **);
 struct minix2_inode *minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **);
@@ -168,4 +171,10 @@ static inline int minix_test_bit(int nr, const void *vaddr)
 
 #endif
 
+#define minix_error_inode(inode, fmt, ...)			\
+	__minix_error_inode((inode), __func__, __LINE__,	\
+			    (fmt), ##__VA_ARGS__)
+
+#define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
+
 #endif /* FS_MINIX_H */
Signature · 1 line
2.53.0
author maintainer
#1746 lore raw

PATCH 1716/1756 Fix a drop_nlink warning in minix_rmdir

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jori Koolstra <[email protected]>

[ Upstream commit d3e0e8661ceb4fe3aab85af3730dbf41240d561f ]

Syzbot found a drop_nlink warning that is triggered by an easy to detect nlink corruption of a directory. This patch adds a sanity check to minix_rmdir to prevent the warning and instead return EFSCORRUPTED to the caller.

The changes were tested using the syzbot reproducer as well as local testing.

Stable-dep-of: fc9577079df8 ("minix: reject rmdir of a directory with a corrupted link count")

---
 fs/minix/namei.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
fs/minix/namei.c +17 -8
index 5d9c1406fe272..35e3e5947be7a 100644
@@ -161,15 +161,24 @@ static int minix_unlink(struct inode * dir, struct dentry *dentry)
 static int minix_rmdir(struct inode * dir, struct dentry *dentry)
 {
 	struct inode * inode = d_inode(dentry);
-	int err = -ENOTEMPTY;
-
-	if (minix_empty_dir(inode)) {
-		err = minix_unlink(dir, dentry);
-		if (!err) {
-			inode_dec_link_count(dir);
-			inode_dec_link_count(inode);
-		}
+	int err = -EFSCORRUPTED;
+
+	if (dir->i_nlink <= 2) {
+		minix_error_inode(dir, "inode has corrupted nlink");
+		goto out;
+	}
+
+	err = -ENOTEMPTY;
+	if (!minix_empty_dir(inode))
+		goto out;
+
+	err = minix_unlink(dir, dentry);
+	if (!err) {
+		inode_dec_link_count(dir);
+		inode_dec_link_count(inode);
 	}
+
+out:
 	return err;
 }
 
Signature · 1 line
2.53.0
author maintainer
#1747 lore raw

PATCH 1717/1756 minix: reject rmdir of a directory with a corrupted link count

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nguyen Ngoc Thang <[email protected]>

[ Upstream commit fc9577079df8a44ccbf39d2f06634017d286e4f0 ]

minix_rmdir() calls minix_unlink(), which drops the victim's link count once, and then drops it a second time for the "." entry. An image where an empty directory has i_nlink < 2 makes the second drop hit drop_nlink() with i_nlink == 0:

  WARNING: fs/inode.c:408 at drop_nlink
   minix_rmdir+0xe9/0x150
   vfs_rmdir
   filename_rmdir
   __do_sys_unlinkat

The parent's link count is already validated; do the same for the directory being removed and fail with -EFSCORRUPTED.

---
 fs/minix/namei.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/minix/namei.c +4 -0
index 35e3e5947be7a..3e4102bb8fbf5 100644
@@ -167,6 +167,10 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)
 		minix_error_inode(dir, "inode has corrupted nlink");
 		goto out;
 	}
+	if (inode->i_nlink < 2) {
+		minix_error_inode(inode, "inode has corrupted nlink");
+		goto out;
+	}
 
 	err = -ENOTEMPTY;
 	if (!minix_empty_dir(inode))
Signature · 1 line
2.53.0
author maintainer
#1748 lore raw

PATCH 1718/1756 rtc: ds1685: arm the wake-up alarm at power-off only if an alarm is set

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Imre Kaloz <[email protected]>

[ Upstream commit c2373bcd50d9654b76eac585c7c98105665b3321 ]

ds1685_rtc_poweroff() always sets WIE. The wake-up alarm then compares the time-of-day and date alarm registers, which hold whatever was last written to them, and a match powers the machine straight back on.

Set WIE only when AIE is set in Control B, and clear it otherwise.

Fixes aaaf5fbf56f1 ("rtc: add driver for DS1685 family of real time clocks")
---
 drivers/rtc/rtc-ds1685.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/rtc/rtc-ds1685.c +12 -6
index 38e25f63597ab..93f463a8251e9 100644
@@ -1370,7 +1370,7 @@ module_platform_driver(ds1685_rtc_driver);
 void __noreturn
 ds1685_rtc_poweroff(struct platform_device *pdev)
 {
-	u8 ctrla, ctrl4a, ctrl4b;
+	u8 ctrla, ctrlb, ctrl4a, ctrl4b;
 	struct ds1685_priv *rtc;
 
 	/* Check for valid RTC data, else, spin forever. */
@@ -1397,6 +1397,8 @@ ds1685_rtc_poweroff(struct platform_device *pdev)
 		ctrla &= ~(RTC_CTRL_A_DV2);
 		rtc->write(rtc, RTC_CTRL_A, ctrla);
 
+		ctrlb = rtc->read(rtc, RTC_CTRL_B);
+
 		/*
 		 * Read Control 4A and check the status of the auxillary
 		 * battery.  This must be present and working (VRT2 = 1)
@@ -1411,13 +1413,17 @@ ds1685_rtc_poweroff(struct platform_device *pdev)
 
 			/*
 			 * The auxillary battery is present and working.
-			 * Enable extended functions (ABE=1), enable
-			 * wake-up (WIE=1), and enable kickstart (KSE=1)
-			 * in Control 4B.
+			 * Enable extended functions (ABE=1) and kickstart
+			 * (KSE=1) in Control 4B.  Enable wake-up (WIE=1) only
+			 * if an alarm is set, else stale alarm registers
+			 * can power the system back on.
 			 */
 			ctrl4b = rtc->read(rtc, RTC_EXT_CTRL_4B);
-			ctrl4b |= (RTC_CTRL_4B_ABE | RTC_CTRL_4B_WIE |
-				   RTC_CTRL_4B_KSE);
+			ctrl4b |= (RTC_CTRL_4B_ABE | RTC_CTRL_4B_KSE);
+			if (ctrlb & RTC_CTRL_B_AIE)
+				ctrl4b |= RTC_CTRL_4B_WIE;
+			else
+				ctrl4b &= ~(RTC_CTRL_4B_WIE);
 			rtc->write(rtc, RTC_EXT_CTRL_4B, ctrl4b);
 		}
 
Signature · 1 line
2.53.0
author maintainer
#1749 lore raw

PATCH 1719/1756 rtc: ds1685: do not sleep in the power-off handler

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Imre Kaloz <[email protected]>

[ Upstream commit 21a829af60a7f5c7456f1f0ff9b6b0eff0ceb738 ]

Power-off handlers run from an atomic notifier chain and must not sleep. Use mdelay() for the delay before setting PAB.

---
 drivers/rtc/rtc-ds1685.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ds1685.c +1 -1
index 93f463a8251e9..621825d3f147f 100644
@@ -1429,7 +1429,7 @@ ds1685_rtc_poweroff(struct platform_device *pdev)
 
 		/* Set PAB to 1 in Control 4A to power the system down. */
 		dev_warn(&pdev->dev, "Powerdown.\n");
-		msleep(20);
+		mdelay(20);
 		rtc->write(rtc, RTC_EXT_CTRL_4A,
 			   (ctrl4a | RTC_CTRL_4A_PAB));
 
Signature · 1 line
2.53.0
author maintainer
#1750 lore raw

PATCH 1720/1756 libbpf: fix cross-endian build with newer libbpf

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Dominique Martinet <[email protected]>

commit 087f3964f4b3 ("libbpf: Support layout section handling in BTF") added extra data to the BTF header.

This extra data is ignored in the native case, but when building with different endianness the bswap code in old libbpf would check for strict size equality, leading to build failures such as this when BTF data is generated with a newer version of libbpf (through pahole)
BTFIDS vmlinux.unstripped
libbpf: Can't load BTF with non-native endianness due to unsupported header length 32
FAILED: load BTF from vmlinux.unstripped: Operation not supported make[2]: *** [../scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255

Newer libbpf versions also properly ignore trailing data in the bswap case, but the patch is too intrusive to backport, so take the header length comparison fix from it instead.

Fixes 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness")
---
 tools/lib/bpf/btf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/btf.c +2 -2
index 9f14ab48eef3e..723eb64fc7932 100644
@@ -225,14 +225,14 @@ static int btf_parse_hdr(struct btf *btf)
 	struct btf_header *hdr = btf->hdr;
 	__u32 meta_left;
 
-	if (btf->raw_size < sizeof(struct btf_header)) {
+	if (btf->raw_size < offsetofend(struct btf_header, str_len)) {
 		pr_debug("BTF header not found\n");
 		return -EINVAL;
 	}
 
 	if (hdr->magic == bswap_16(BTF_MAGIC)) {
 		btf->swapped_endian = true;
-		if (bswap_32(hdr->hdr_len) != sizeof(struct btf_header)) {
+		if (bswap_32(hdr->hdr_len) < offsetofend(struct btf_header, str_len)) {
 			pr_warn("Can't load BTF with non-native endianness due to unsupported header length %u\n",
 				bswap_32(hdr->hdr_len));
 			return -ENOTSUP;
Signature · 1 line
2.53.0
author maintainer
#1751 lore raw

PATCH 1721/1756 RDMA/erdma: Use IRQ-safe XArray helpers for QP and CQ tables

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Cheng Xu <[email protected]>

[ Upstream commit 00baeade709fb66da647e8327e8398bb532e30f7 ]

Locked QP and CQ lookups from EQ interrupts can deadlock with create-path XArray updates. If an interrupt arrives while the create path holds the plain xa_lock, the lookup spins forever trying to acquire the same lock.

Use IRQ-safe XArray helpers for all QP and CQ create-path updates, including the GSI QP store and error paths. Initialize both arrays with XA_FLAGS_LOCK_IRQ so sleeping allocations preserve interrupt state.

[ The GSI QP create path is not present in 6.6.y, so omit that hunk. ]

Fixes 98df2aee1459 ("RDMA/erdma: Hold CQ references when processing EQ events")
Fixes a52eeff32024 ("RDMA/erdma: Hold QP references for AE and CM processing")
---
 drivers/infiniband/hw/erdma/erdma_main.c  |  4 ++--
 drivers/infiniband/hw/erdma/erdma_verbs.c | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/infiniband/hw/erdma/erdma_main.c +2 -2
index 37723054f0645..94b7f3c4bb9c7 100644
@@ -578,8 +578,8 @@ static int erdma_ib_device_add(struct pci_dev *pdev)
 	INIT_LIST_HEAD(&dev->cep_list);
 
 	spin_lock_init(&dev->lock);
-	xa_init_flags(&dev->qp_xa, XA_FLAGS_ALLOC1);
-	xa_init_flags(&dev->cq_xa, XA_FLAGS_ALLOC1);
+	xa_init_flags(&dev->qp_xa, XA_FLAGS_ALLOC1 | XA_FLAGS_LOCK_IRQ);
+	xa_init_flags(&dev->cq_xa, XA_FLAGS_ALLOC1 | XA_FLAGS_LOCK_IRQ);
 	dev->next_alloc_cqn = 1;
 	dev->next_alloc_qpn = 1;
 
drivers/infiniband/hw/erdma/erdma_verbs.c +8 -8
index 057efff532b4f..75880864eba48 100644
@@ -982,9 +982,9 @@ int erdma_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs,
 	kref_init(&qp->ref);
 	init_completion(&qp->safe_free);
 
-	ret = xa_alloc_cyclic(&dev->qp_xa, &qp->ibqp.qp_num, qp,
-			      XA_LIMIT(1, dev->attrs.max_qp - 1),
-			      &dev->next_alloc_qpn, GFP_KERNEL);
+	ret = xa_alloc_cyclic_irq(&dev->qp_xa, &qp->ibqp.qp_num, qp,
+				  XA_LIMIT(1, dev->attrs.max_qp - 1),
+				  &dev->next_alloc_qpn, GFP_KERNEL);
 	if (ret < 0) {
 		ret = -ENOMEM;
 		goto err_out;
@@ -1045,7 +1045,7 @@ int erdma_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs,
 	else
 		free_kernel_qp(qp);
 err_out_xa:
-	xa_erase(&dev->qp_xa, QP_ID(qp));
+	xa_erase_irq(&dev->qp_xa, QP_ID(qp));
 err_out:
 	return ret;
 }
@@ -1945,9 +1945,9 @@ int erdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 	refcount_set(&cq->refcount, 1);
 	init_completion(&cq->free);
 
-	ret = xa_alloc_cyclic(&dev->cq_xa, &cq->cqn, cq,
-			      XA_LIMIT(1, dev->attrs.max_cq - 1),
-			      &dev->next_alloc_cqn, GFP_KERNEL);
+	ret = xa_alloc_cyclic_irq(&dev->cq_xa, &cq->cqn, cq,
+				  XA_LIMIT(1, dev->attrs.max_cq - 1),
+				  &dev->next_alloc_cqn, GFP_KERNEL);
 	if (ret < 0)
 		return ret;
 
@@ -1995,7 +1995,7 @@ int erdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
 	}
 
 err_out_xa:
-	xa_erase(&dev->cq_xa, cq->cqn);
+	xa_erase_irq(&dev->cq_xa, cq->cqn);
 
 	return ret;
 }
Signature · 1 line
2.53.0
author maintainer
#1752 lore raw

PATCH 1722/1756 mm/damon/reclaim: use parameter context correctly

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: SeongJae Park <[email protected]>

[ Upstream commit fed48693bdfeca666f7536ba88a05e9a4e5523b6 ]

damon_reclaim_apply_parameters() allocates a new DAMON context, stages user-specified DAMON parameters on it, and commits to running DAMON context at once, using damon_commit_ctx(). The code is mistakenly over-writing the monitoring attributes and the reclaim scheme on the running context. It is not causing a real problem for monitoring attributes, but the scheme overwriting can remove scheme's internal status such as charged quota. Fix the wrong use of the parameter context.

Fixes 11ddcfc257a3 ("mm/damon/reclaim: use damon_commit_ctx()")
---
 mm/damon/reclaim.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/damon/reclaim.c +2 -2
index 9df096218beb7..254d84166131f 100644
@@ -190,7 +190,7 @@ static int damon_reclaim_apply_parameters(void)
 		goto out;
 	}
 
-	err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs);
+	err = damon_set_attrs(param_ctx, &damon_reclaim_mon_attrs);
 	if (err)
 		goto out;
 
@@ -198,7 +198,7 @@ static int damon_reclaim_apply_parameters(void)
 	scheme = damon_reclaim_new_scheme();
 	if (!scheme)
 		goto out;
-	damon_set_schemes(ctx, &scheme, 1);
+	damon_set_schemes(param_ctx, &scheme, 1);
 
 	if (quota_mem_pressure_us) {
 		goal = damos_new_quota_goal(DAMOS_QUOTA_SOME_MEM_PSI_US,
Signature · 1 line
2.53.0
author maintainer
#1753 lore raw

PATCH 1723/1756 mm: fix OOM killer inaccuracy on large many-core systems

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Mathieu Desnoyers <[email protected]>

[ Upstream commit 5898aa8f9a0b42fe1f65c7364010ab15ec5c38bf ]

Use the precise, albeit slower, precise RSS counter sums for the OOM killer task selection and console dumps. The approximated value is too imprecise on large many-core systems.

The following rss tracking issues were noted by Sweet Tea Dorminy [1], which lead to picking wrong tasks as OOM kill target:

Recently, several internal services had an RSS usage regression as part of a kernel upgrade. Previously, they were on a pre-6.2 kernel and were able to read RSS statistics in a backup watchdog process to monitor and decide if they'd overrun their memory budget. Now, however, a representative service with five threads, expected to use about a hundred MB of memory, on a 250-cpu machine had memory usage tens of megabytes different from the expected amount -- this constituted a significant percentage of inaccuracy, causing the watchdog to act.

This was a result of commit f1a7941243c1 ("mm: convert mm's rss stats into percpu_counter") [1]. Previously, the memory error was bounded by 64*nr_threads pages, a very livable megabyte. Now, however, as a result of scheduler decisions moving the threads around the CPUs, the memory error could be as large as a gigabyte.

This is a really tremendous inaccuracy for any few-threaded program on a large machine and impedes monitoring significantly. These stat counters are also used to make OOM killing decisions, so this additional inaccuracy could make a big difference in OOM situations -- either resulting in the wrong process being killed, or in less memory being returned from an OOM-kill than expected.

Here is a (possibly incomplete) list of the prior approaches that were used or proposed, along with their downside:

1) Per-thread rss tracking: large error on many-thread processes.

2) Per-CPU counters: up to 12% slower for short-lived processes and 9% increased system time in make test workloads [1]. Moreover, the inaccuracy increases with O(n^2) with the number of CPUs.

3) Per-NUMA-node counters: requires atomics on fast-path (overhead), error is high with systems that have lots of NUMA nodes (32 times the number of NUMA nodes).

commit 82241a83cd15 ("mm: fix the inaccurate memory statistics issue for users") introduced get_mm_counter_sum() for precise proc memory status queries for some proc files.

The simple fix proposed here is to do the precise per-cpu counters sum every time a counter value needs to be read. This applies to the OOM killer task selection, oom task console dumps (printk).

This change increases the latency introduced when the OOM killer executes in favor of doing a more precise OOM target task selection. Effectively, the OOM killer iterates on all tasks, for all relevant page types, for which the precise sum iterates on all possible CPUs.

As a reference, here is the execution time of the OOM killer before/after the change:

AMD EPYC 9654 96-Core (2 sockets)
Within a KVM, configured with 256 logical cpus.

                                  |  before  |  after   |
----------------------------------|----------|----------|
nr_processes=40                   |  0.3 ms  |   0.5 ms |
nr_processes=10000                |  3.0 ms  |  80.0 ms |
Fixes f1a7941243c1 ("mm: convert mm's rss stats into percpu_counter")
Cc "Paul E. McKenney" <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
Cc Dennis Zhou <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc Martin Liu <[email protected]>
Cc David Rientjes <[email protected]>
Cc Shakeel Butt <[email protected]>
Cc SeongJae Park <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Sweet Tea Dorminy <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc "Liam R . Howlett" <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Suren Baghdasaryan <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Wei Yang <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Miaohe Lin <[email protected]>
Cc Al Viro <[email protected]>
Cc Yu Zhao <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Mateusz Guzik <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Aboorva Devarajan <[email protected]>
[ Backported without changes ]
---
 include/linux/mm.h |  7 +++++++
 mm/oom_kill.c      | 22 +++++++++++-----------
 2 files changed, 18 insertions(+), 11 deletions(-)
include/linux/mm.h +7 -0
index 81e973784d3be..a6348b25aee22 100644
@@ -2731,6 +2731,13 @@ static inline unsigned long get_mm_rss(struct mm_struct *mm)
 		get_mm_counter(mm, MM_SHMEMPAGES);
 }
 
+static inline unsigned long get_mm_rss_sum(struct mm_struct *mm)
+{
+	return get_mm_counter_sum(mm, MM_FILEPAGES) +
+		get_mm_counter_sum(mm, MM_ANONPAGES) +
+		get_mm_counter_sum(mm, MM_SHMEMPAGES);
+}
+
 static inline unsigned long get_mm_hiwater_rss(struct mm_struct *mm)
 {
 	return max(mm->hiwater_rss, get_mm_rss(mm));
mm/oom_kill.c +11 -11
index 8aa712afd8ae1..53ab72f747fdf 100644
@@ -229,7 +229,7 @@ long oom_badness(struct task_struct *p, unsigned long totalpages)
 	 * The baseline for the badness score is the proportion of RAM that each
 	 * task's rss, pagetable and swap space use.
 	 */
-	points = get_mm_rss(p->mm) + get_mm_counter(p->mm, MM_SWAPENTS) +
+	points = get_mm_rss_sum(p->mm) + get_mm_counter_sum(p->mm, MM_SWAPENTS) +
 		mm_pgtables_bytes(p->mm) / PAGE_SIZE;
 	task_unlock(p);
 
@@ -403,10 +403,10 @@ static int dump_task(struct task_struct *p, void *arg)
 
 	pr_info("[%7d] %5d %5d %8lu %8lu %8lu %8lu %9lu %8ld %8lu         %5hd %s\n",
 		task->pid, from_kuid(&init_user_ns, task_uid(task)),
-		task->tgid, task->mm->total_vm, get_mm_rss(task->mm),
-		get_mm_counter(task->mm, MM_ANONPAGES), get_mm_counter(task->mm, MM_FILEPAGES),
-		get_mm_counter(task->mm, MM_SHMEMPAGES), mm_pgtables_bytes(task->mm),
-		get_mm_counter(task->mm, MM_SWAPENTS),
+		task->tgid, task->mm->total_vm, get_mm_rss_sum(task->mm),
+		get_mm_counter_sum(task->mm, MM_ANONPAGES), get_mm_counter_sum(task->mm, MM_FILEPAGES),
+		get_mm_counter_sum(task->mm, MM_SHMEMPAGES), mm_pgtables_bytes(task->mm),
+		get_mm_counter_sum(task->mm, MM_SWAPENTS),
 		task->signal->oom_score_adj, task->comm);
 	task_unlock(task);
 
@@ -598,9 +598,9 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)
 
 	pr_info("oom_reaper: reaped process %d (%s), now anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
 			task_pid_nr(tsk), tsk->comm,
-			K(get_mm_counter(mm, MM_ANONPAGES)),
-			K(get_mm_counter(mm, MM_FILEPAGES)),
-			K(get_mm_counter(mm, MM_SHMEMPAGES)));
+			K(get_mm_counter_sum(mm, MM_ANONPAGES)),
+			K(get_mm_counter_sum(mm, MM_FILEPAGES)),
+			K(get_mm_counter_sum(mm, MM_SHMEMPAGES)));
 out_finish:
 	trace_finish_task_reaping(tsk->pid);
 out_unlock:
@@ -954,9 +954,9 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)
 	mark_oom_victim(victim);
 	pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID:%u pgtables:%lukB oom_score_adj:%hd\n",
 		message, task_pid_nr(victim), victim->comm, K(mm->total_vm),
-		K(get_mm_counter(mm, MM_ANONPAGES)),
-		K(get_mm_counter(mm, MM_FILEPAGES)),
-		K(get_mm_counter(mm, MM_SHMEMPAGES)),
+		K(get_mm_counter_sum(mm, MM_ANONPAGES)),
+		K(get_mm_counter_sum(mm, MM_FILEPAGES)),
+		K(get_mm_counter_sum(mm, MM_SHMEMPAGES)),
 		from_kuid(&init_user_ns, task_uid(victim)),
 		mm_pgtables_bytes(mm) >> 10, victim->signal->oom_score_adj);
 	task_unlock(victim);
Signature · 1 line
2.53.0
author maintainer
#1754 lore raw

PATCH 1724/1756 vdpa_sim: disable page faults around vringh_need_notify_iotlb()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Linus Torvalds <[email protected]>

[ Upstream commit 05fb07c40e0013ba5ae373c6ea1bcc622eaea7f0 ]

When vdpa_sim runs with use_va (the default), its rings live in user memory, and vringh reads the ring's flags and event index with __get_user() through the user address. The net and block simulators call vringh_need_notify_iotlb() with bottom halves disabled, so those reads happen in atomic context.

That only works today because __get_user() has no might_fault() check: a fault is not handled in atomic context and simply comes back as -EFAULT. Make that explicit with pagefault_disable() around the call, so vringh can use the normal user accessors without complaint. Only the notification check needs this: the rest of the ring processing runs in the same kthread without bottom halves disabled, and can fault normally.

---
 drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 9 ++++++++-
 drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 9 ++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/vdpa/vdpa_sim/vdpa_sim_blk.c +8 -1
index 770a40a20be9d..0d5922ba05bcb 100644
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
+#include <linux/uaccess.h>
 #include <linux/blkdev.h>
 #include <linux/vringh.h>
 #include <linux/vdpa.h>
@@ -343,11 +344,17 @@ static void vdpasim_blk_work(struct vdpasim *vdpasim)
 			continue;
 
 		while (vdpasim_blk_handle_req(vdpasim, vq)) {
+			bool notify;
+
 			/* Make sure used is visible before rasing the interrupt. */
 			smp_wmb();
 
 			local_bh_disable();
-			if (vringh_need_notify_iotlb(&vq->vring) > 0)
+			/* The ring may be in user memory, and we can't take faults here */
+			pagefault_disable();
+			notify = vringh_need_notify_iotlb(&vq->vring) > 0;
+			pagefault_enable();
+			if (notify)
 				vringh_notify(&vq->vring);
 			local_bh_enable();
 
drivers/vdpa/vdpa_sim/vdpa_sim_net.c +8 -1
index b596d4a532d01..2271dd26da127 100644
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
+#include <linux/uaccess.h>
 #include <linux/etherdevice.h>
 #include <linux/vringh.h>
 #include <linux/vdpa.h>
@@ -68,6 +69,8 @@ static struct vdpasim_net *sim_to_net(struct vdpasim *vdpasim)
 
 static void vdpasim_net_complete(struct vdpasim_virtqueue *vq, size_t len)
 {
+	bool notify;
+
 	/* Make sure data is wrote before advancing index */
 	smp_wmb();
 
@@ -77,7 +80,11 @@ static void vdpasim_net_complete(struct vdpasim_virtqueue *vq, size_t len)
 	smp_wmb();
 
 	local_bh_disable();
-	if (vringh_need_notify_iotlb(&vq->vring) > 0)
+	/* The ring may be in user memory, and we can't take faults here */
+	pagefault_disable();
+	notify = vringh_need_notify_iotlb(&vq->vring) > 0;
+	pagefault_enable();
+	if (notify)
 		vringh_notify(&vq->vring);
 	local_bh_enable();
 }
Signature · 1 line
2.53.0
author maintainer
#1755 lore raw

PATCH 1725/1756 PCI/sysfs: Decouple acpi_index from the optional device name element

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Krzysztof Wilczyński <[email protected]>

[ Upstream commit 337bdf853101a0ee66eadf668f0fef21f8276b52 ]

The "_DSM for Naming a PCI or PCI Express Device Under Operating Systems" (PCI Firmware r3.3, sec 4.6.7) returns a package of two elements:

1) Instance number (mandatory Integer)
2) String name (optional String, null string if not populated)

These are exposed as sysfs 'acpi_index' and 'label'. Previously, if the name was malformed, reads of 'acpi_index' failed unnecessarily.

Validate each element only for the attribute that exports it. So "acpi_index" now depends on the instance number alone, and "label" reads fail with -EIO when the name element is neither a string nor a buffer. The package elements pointer is read only after the object type has been checked.

On platforms with a valid instance number and a malformed name element the "acpi_index" attribute starts returning data. Because udev derives the onboard interface name from "acpi_index", an interface on such a platform may be renamed once, on the first boot after this change. That is the attribute assuming the value the firmware always provided.

---
 drivers/pci/pci-label.c | 53 +++++++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 20 deletions(-)
drivers/pci/pci-label.c +33 -20
index f81248a11a18e..08c461f1142d7 100644
@@ -157,7 +157,7 @@ static int dsm_get_label(struct device *dev, char *buf,
 {
 	acpi_handle handle = ACPI_HANDLE(dev);
 	union acpi_object *obj, *tmp;
-	int len = 0;
+	int len;
 
 	if (!handle)
 		return -ENODEV;
@@ -167,30 +167,43 @@ static int dsm_get_label(struct device *dev, char *buf,
 	if (!obj)
 		return -EIO;
 
+	if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count != 2) {
+		len = -EIO;
+		goto out;
+	}
+
 	tmp = obj->package.elements;
-	if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 2 &&
-	    tmp[0].type == ACPI_TYPE_INTEGER &&
-	    (tmp[1].type == ACPI_TYPE_STRING ||
-	     tmp[1].type == ACPI_TYPE_BUFFER)) {
-		/*
-		 * The second string element is optional even when
-		 * this _DSM is implemented; when not implemented,
-		 * this entry must return a null string.
-		 */
-		if (attr == ACPI_ATTR_INDEX_SHOW) {
-			len = sysfs_emit(buf, "%llu\n", tmp->integer.value);
-		} else if (attr == ACPI_ATTR_LABEL_SHOW) {
-			if (tmp[1].type == ACPI_TYPE_STRING)
-				len = sysfs_emit(buf, "%s\n",
-						 tmp[1].string.pointer);
-			else if (tmp[1].type == ACPI_TYPE_BUFFER)
-				len = dsm_label_utf16s_to_utf8s(tmp + 1, buf);
-		}
+	if (tmp[0].type != ACPI_TYPE_INTEGER) {
+		len = -EIO;
+		goto out;
 	}
 
+	if (attr == ACPI_ATTR_INDEX_SHOW) {
+		len = sysfs_emit(buf, "%llu\n", tmp[0].integer.value);
+		goto out;
+	}
+
+	/*
+	 * Per PCI Firmware r3.3, sec 4.6.7, the device name is optional
+	 * even when this _DSM is implemented. When not implemented, this
+	 * entry must return a NULL string.
+	 */
+	switch (tmp[1].type) {
+	case ACPI_TYPE_STRING:
+		len = sysfs_emit(buf, "%s\n", tmp[1].string.pointer);
+		break;
+	case ACPI_TYPE_BUFFER:
+		len = dsm_label_utf16s_to_utf8s(&tmp[1], buf);
+		break;
+	default:
+		len = -EIO;
+		break;
+	}
+
+out:
 	ACPI_FREE(obj);
 
-	return len > 0 ? len : -EIO;
+	return len;
 }
 
 static ssize_t label_show(struct device *dev, struct device_attribute *attr,
Signature · 1 line
2.53.0
author maintainer
#1756 lore raw

PATCH 1726/1756 scsi: core: Fix additional sense code definition

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Damien Le Moal <[email protected]>

commit 3b7ccba37858dd3d7d3780eb42ab943152e5b7ec upstream.

The ASC() macro used to define an additional sense code with no additional sense code qualifier conflicts with the ASC macro definition of the file arch/sparc/include/asm/ns87303.h, leading to compilation errors. Avoid this conflict by renaming the macro as SCSI_ASC() and the ASC_DEF() macro to SCSI_ASC_DEF() to be consistent.

---
 include/scsi/scsi_sense.h |  236 +++++++++++++++++++++++-----------------------
 1 file changed, 118 insertions(+), 118 deletions(-)
include/scsi/scsi_sense.h +118 -118
@@ -30,10 +30,10 @@ enum scsi_sense_key {
 	COMPLETED		= 0x0f,
 };
 
-#define ASC_DEF(name)	ASC_##name
-#define ASC(name, code)					\
-	ASC_DEF(name)	= (code),			\
-	name		= ((code) << 8) | 0x00
+#define SCSI_ASC_DEF(name)	ASC_##name
+#define SCSI_ASC(name, code)				\
+	SCSI_ASC_DEF(name)	= (code),		\
+	name			= ((code) << 8) | 0x00
 
 /*
  * SCSI additional sense codes and sense codes qualifiers.
@@ -49,7 +49,7 @@ enum scsi_sense_key {
  * are prefixed with "SSC_" (e.g. WARNING and WRITE_ERROR).
  */
 enum scsi_sense_code {
-	ASC(NO_ADDITIONAL_SENSE_INFORMATION,			0x00),
+	SCSI_ASC(NO_ADDITIONAL_SENSE_INFORMATION,		0x00),
 	FILEMARK_DETECTED					= 0x0001,
 	END_OF_PARTITION_MEDIUM_DETECTED			= 0x0002,
 	SETMARK_DETECTED					= 0x0003,
@@ -77,15 +77,15 @@ enum scsi_sense_code {
 	DEFERRED_MICROCODE_IS_PENDING				= 0x0022,
 	OVERLAPPING_ATOMIC_COMMAND_IN_PROGRESS			= 0x0023,
 
-	ASC(NO_INDEX_SECTOR_SIGNAL,				0x01),
+	SCSI_ASC(NO_INDEX_SECTOR_SIGNAL,			0x01),
 
-	ASC(NO_SEEK_COMPLETE,					0x02),
+	SCSI_ASC(NO_SEEK_COMPLETE,				0x02),
 
-	ASC(PERIPHERAL_DEVICE_WRITE_FAULT,			0x03),
+	SCSI_ASC(PERIPHERAL_DEVICE_WRITE_FAULT,			0x03),
 	NO_WRITE_CURRENT					= 0x0301,
 	EXCESSIVE_WRITE_ERRORS					= 0x0302,
 
-	ASC(LU_NOT_READY,					0x04),
+	SCSI_ASC(LU_NOT_READY,					0x04),
 	LU_IS_IN_PROCESS_OF_BECOMING_READY			= 0x0401,
 	LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED		= 0x0402,
 	LU_NOT_READY_MANUAL_INTERVENTION_REQUIRED		= 0x0403,
@@ -123,28 +123,28 @@ enum scsi_sense_code {
 	DEPOPULATION_IN_PROGRESS				= 0x0424,
 	DEPOPULATION_RESTORATION_IN_PROGRESS			= 0x0425,
 
-	ASC(LU_DOES_NOT_RESPOND_TO_SELECTION,			0x05),
+	SCSI_ASC(LU_DOES_NOT_RESPOND_TO_SELECTION,		0x05),
 
-	ASC(NO_REFERENCE_POSITION_FOUND,			0x06),
+	SCSI_ASC(NO_REFERENCE_POSITION_FOUND,			0x06),
 
-	ASC(MULTIPLE_PERIPHERAL_DEVICES_SELECTED,		0x07),
+	SCSI_ASC(MULTIPLE_PERIPHERAL_DEVICES_SELECTED,		0x07),
 
-	ASC(LU_COMMUNICATION_FAILURE,				0x08),
+	SCSI_ASC(LU_COMMUNICATION_FAILURE,			0x08),
 	LU_COMMUNICATION_TIMEOUT				= 0x0801,
 	LU_COMMUNICATION_PARITY_ERROR				= 0x0802,
 	LU_COMMUNICATION_CRC_ERROR				= 0x0803,
 	UNREACHABLE_COPY_TARGET					= 0x0804,
 
-	ASC(TRACK_FOLLOWING_ERROR,				0x09),
+	SCSI_ASC(TRACK_FOLLOWING_ERROR,				0x09),
 	TRACKING_SERVO_FAILURE					= 0x0901,
 	FOCUS_SERVO_FAILURE					= 0x0902,
 	SPINDLE_SERVO_FAILURE					= 0x0903,
 	HEAD_SELECT_FAULT					= 0x0904,
 	VIBRATION_INDUCED_TRACKING_ERROR			= 0x0905,
 
-	ASC(ERROR_LOG_OVERFLOW,					0x0A),
+	SCSI_ASC(ERROR_LOG_OVERFLOW,				0x0A),
 
-	ASC(SSC_WARNING,					0x0B),
+	SCSI_ASC(SSC_WARNING,					0x0B),
 	WARNING_SPECIFIED_TEMPERATURE_EXCEEDED			= 0x0B01,
 	WARNING_ENCLOSURE_DEGRADED				= 0x0B02,
 	WARNING_BACKGROUND_SELFTEST_FAILED			= 0x0B03,
@@ -167,7 +167,7 @@ enum scsi_sense_code {
 	WARNING_PHYSICAL_ELEMENT_STATUS_CHANGE			= 0x0B14,
 
 	/* Defined as "WRITE ERROR" in T10. */
-	ASC(SSC_WRITE_ERROR,					0x0C),
+	SCSI_ASC(SSC_WRITE_ERROR,				0x0C),
 	WRITE_ERROR_RECOVERED_WITH_AUTO_REALLOCATION		= 0x0C01,
 	WRITE_ERROR_AUTO_REALLOCATION_FAILED			= 0x0C02,
 	WRITE_ERROR_RECOMMEND_REASSIGNMENT			= 0x0C03,
@@ -187,26 +187,26 @@ enum scsi_sense_code {
 	WRITE_ERROR_RECOVERY_SCAN_NEEDED			= 0x0C11,
 	WRITE_ERROR_INSUFFICIENT_ZONE_RESOURCES			= 0x0C12,
 
-	ASC(ERROR_DETECTED_BY_THIRD_PARTY_TEMPORARY_INITIATOR,	0x0D),
+	SCSI_ASC(ERROR_DETECTED_BY_THIRD_PARTY_TEMPORARY_INITIATOR, 0x0D),
 	THIRD_PARTY_DEVICE_FAILURE				= 0x0D01,
 	COPY_TARGET_DEVICE_NOT_REACHABLE			= 0x0D02,
 	INCORRECT_COPY_TARGET_DEVICE_TYPE			= 0x0D03,
 	COPY_TARGET_DEVICE_DATA_UNDERRUN			= 0x0D04,
 	COPY_TARGET_DEVICE_DATA_OVERRUN				= 0x0D05,
 
-	ASC(INVALID_INFORMATION_UNIT,				0x0E),
+	SCSI_ASC(INVALID_INFORMATION_UNIT,			0x0E),
 	INFORMATION_UNIT_TOO_SHORT				= 0x0E01,
 	INFORMATION_UNIT_TOO_LONG				= 0x0E02,
 	INVALID_FIELD_IN_COMMAND_INFORMATION_UNIT		= 0x0E03,
 
-	ASC(ID_CRC_OR_ECC_ERROR,				0x10),
+	SCSI_ASC(ID_CRC_OR_ECC_ERROR,				0x10),
 	LOGICAL_BLOCK_GUARD_CHECK_FAILED			= 0x1001,
 	LOGICAL_BLOCK_APPLICATION_TAG_CHECK_FAILED		= 0x1002,
 	LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED		= 0x1003,
 	LOGICAL_BLOCK_PROTECTION_ERROR_ON_RECOVER_BUFFERED_DATA	= 0x1004,
 	LOGICAL_BLOCK_PROTECTION_METHOD_ERROR			= 0x1005,
 
-	ASC(UNRECOVERED_READ_ERROR,				0x11),
+	SCSI_ASC(UNRECOVERED_READ_ERROR,			0x11),
 	READ_RETRIES_EXHAUSTED					= 0x1101,
 	ERROR_TOO_LONG_TO_CORRECT				= 0x1102,
 	MULTIPLE_READ_ERRORS					= 0x1103,
@@ -229,11 +229,11 @@ enum scsi_sense_code {
 	READ_ERROR_LBA_MARKED_BAD_BY_APPLICATION_CLIENT		= 0x1114,
 	WRITE_AFTER_SANITIZE_REQUIRED				= 0x1115,
 
-	ASC(ADDRESS_MARK_NOT_FOUND_FOR_ID_FIELD,		0x12),
+	SCSI_ASC(ADDRESS_MARK_NOT_FOUND_FOR_ID_FIELD,		0x12),
 
-	ASC(ADDRESS_MARK_NOT_FOUND_FOR_DATA_FIELD,		0x13),
+	SCSI_ASC(ADDRESS_MARK_NOT_FOUND_FOR_DATA_FIELD,		0x13),
 
-	ASC(RECORDED_ENTITY_NOT_FOUND,				0x14),
+	SCSI_ASC(RECORDED_ENTITY_NOT_FOUND,			0x14),
 	RECORD_NOT_FOUND					= 0x1401,
 	FILEMARK_OR_SETMARK_NOT_FOUND				= 0x1402,
 	END_OF_DATA_NOT_FOUND					= 0x1403,
@@ -242,17 +242,17 @@ enum scsi_sense_code {
 	RECORD_NOT_FOUND_DATA_AUTO_REALLOCATED			= 0x1406,
 	LOCATE_OPERATION_FAILURE				= 0x1407,
 
-	ASC(RANDOM_POSITIONING_ERROR,				0x15),
+	SCSI_ASC(RANDOM_POSITIONING_ERROR,			0x15),
 	MECHANICAL_POSITIONING_ERROR				= 0x1501,
 	POSITIONING_ERROR_DETECTED_BY_READ_OF_MEDIUM		= 0x1502,
 
-	ASC(DATA_SYNCHRONIZATION_MARK_ERROR,			0x16),
+	SCSI_ASC(DATA_SYNCHRONIZATION_MARK_ERROR,		0x16),
 	DATA_SYNC_ERROR_DATA_REWRITTEN				= 0x1601,
 	DATA_SYNC_ERROR_RECOMMEND_REWRITE			= 0x1602,
 	DATA_SYNC_ERROR_DATA_AUTO_REALLOCATED			= 0x1603,
 	DATA_SYNC_ERROR_RECOMMEND_REASSIGNMENT			= 0x1604,
 
-	ASC(RECOVERED_DATA_WITH_NO_ERROR_CORRECTION_APPLIED,	0x17),
+	SCSI_ASC(RECOVERED_DATA_WITH_NO_ERROR_CORRECTION_APPLIED, 0x17),
 	RECOVERED_DATA_WITH_RETRIES				= 0x1701,
 	RECOVERED_DATA_WITH_POSITIVE_HEAD_OFFSET		= 0x1702,
 	RECOVERED_DATA_WITH_NEGATIVE_HEAD_OFFSET		= 0x1703,
@@ -263,7 +263,7 @@ enum scsi_sense_code {
 	RECOVERED_DATA_WITHOUT_ECC_RECOMMEND_REWRITE		= 0x1708,
 	RECOVERED_DATA_WITHOUT_ECC_DATA_REWRITTEN		= 0x1709,
 
-	ASC(RECOVERED_DATA_WITH_ERROR_CORRECTION_APPLIED,	0x18),
+	SCSI_ASC(RECOVERED_DATA_WITH_ERROR_CORRECTION_APPLIED,	0x18),
 	RECOVERED_DATA_WITH_ERROR_CORRECTION_RETRIES_APPLIED	= 0x1801,
 	RECOVERED_DATA_DATA_AUTO_REALLOCATED			= 0x1802,
 	RECOVERED_DATA_WITH_CIRC				= 0x1803,
@@ -273,27 +273,27 @@ enum scsi_sense_code {
 	RECOVERED_DATA_WITH_ECC_DATA_REWRITTEN			= 0x1807,
 	RECOVERED_DATA_WITH_LINKING				= 0x1808,
 
-	ASC(DEFECT_LIST_ERROR,					0x19),
+	SCSI_ASC(DEFECT_LIST_ERROR,				0x19),
 	DEFECT_LIST_NOT_AVAILABLE				= 0x1901,
 	DEFECT_LIST_ERROR_IN_PRIMARY_LIST			= 0x1902,
 	DEFECT_LIST_ERROR_IN_GROWN_LIST				= 0x1903,
 
-	ASC(PARAMETER_LIST_LENGTH_ERROR,			0x1A),
+	SCSI_ASC(PARAMETER_LIST_LENGTH_ERROR,			0x1A),
 
-	ASC(SYNCHRONOUS_DATA_TRANSFER_ERROR,			0x1B),
+	SCSI_ASC(SYNCHRONOUS_DATA_TRANSFER_ERROR,		0x1B),
 
-	ASC(DEFECT_LIST_NOT_FOUND,				0x1C),
+	SCSI_ASC(DEFECT_LIST_NOT_FOUND,				0x1C),
 	PRIMARY_DEFECT_LIST_NOT_FOUND				= 0x1C01,
 	GROWN_DEFECT_LIST_NOT_FOUND				= 0x1C02,
 
-	ASC(MISCOMPARE_DURING_VERIFY_OPERATION,			0x1D),
+	SCSI_ASC(MISCOMPARE_DURING_VERIFY_OPERATION,		0x1D),
 	MISCOMPARE_VERIFY_OF_UNMAPPED_LBA			= 0x1D01,
 
-	ASC(RECOVERED_ID_WITH_ECC_CORRECTION,			0x1E),
+	SCSI_ASC(RECOVERED_ID_WITH_ECC_CORRECTION,		0x1E),
 
-	ASC(PARTIAL_DEFECT_LIST_TRANSFER,			0x1F),
+	SCSI_ASC(PARTIAL_DEFECT_LIST_TRANSFER,			0x1F),
 
-	ASC(INVALID_COMMAND_OP_CODE,				0x20),
+	SCSI_ASC(INVALID_COMMAND_OP_CODE,			0x20),
 	ACCESS_DENIED_INITIATOR_PENDING_ENROLLED		= 0x2001,
 	ACCESS_DENIED_NO_ACCESS_RIGHTS				= 0x2002,
 	ACCESS_DENIED_INVALID_MGMT_ID_KEY			= 0x2003,
@@ -309,7 +309,7 @@ enum scsi_sense_code {
 	NOT_A_SUBSIDIARY_LOGICAL_UNIT				= 0x200E,
 	NOT_A_CONGLOMERATE_LOGICAL_UNIT				= 0x200F,
 
-	ASC(LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE,			0x21),
+	SCSI_ASC(LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE,		0x21),
 	INVALID_ELEMENT_ADDRESS					= 0x2101,
 	INVALID_ADDRESS_FOR_WRITE				= 0x2102,
 	INVALID_WRITE_CROSSING_LAYER_JUMP			= 0x2103,
@@ -320,9 +320,9 @@ enum scsi_sense_code {
 	MISALIGNED_WRITE_COMMAND				= 0x2108,
 	ATTEMPT_TO_ACCESS_GAP_ZONE				= 0x2109,
 
-	ASC(ILLEGAL_FUNCTION,					0x22),
+	SCSI_ASC(ILLEGAL_FUNCTION,				0x22),
 
-	ASC(INVALID_TOKEN_OP,					0x23),
+	SCSI_ASC(INVALID_TOKEN_OP,				0x23),
 	INVALID_TOKEN_OP_UNSUPPORTED_TOKEN_TYPE			= 0x2301,
 	INVALID_TOKEN_OP_REMOTE_TOKEN_USAGE_NOT_SUPPORTED	= 0x2302,
 	INVALID_TOKEN_OP_REMOTE_ROD_TOKEN_CREATION_NOT_SUPPORTED = 0x2303,
@@ -334,7 +334,7 @@ enum scsi_sense_code {
 	INVALID_TOKEN_OP_TOKEN_DELETED				= 0x2309,
 	INVALID_TOKEN_OP_INVALID_TOKEN_LENGTH			= 0x230A,
 
-	ASC(INVALID_FIELD_IN_CDB,				0x24),
+	SCSI_ASC(INVALID_FIELD_IN_CDB,				0x24),
 	CDB_DECRYPTION_ERROR					= 0x2401,
 	SECURITY_AUDIT_VALUE_FROZEN				= 0x2404,
 	SECURITY_WORKING_KEY_FROZEN				= 0x2405,
@@ -343,9 +343,9 @@ enum scsi_sense_code {
 	INVALID_XCDB						= 0x2408,
 	INVALID_FAST_FORMAT					= 0x2409,
 
-	ASC(LU_NOT_SUPPORTED,					0x25),
+	SCSI_ASC(LU_NOT_SUPPORTED,				0x25),
 
-	ASC(INVALID_FIELD_IN_PARAMETER_LIST,			0x26),
+	SCSI_ASC(INVALID_FIELD_IN_PARAMETER_LIST,		0x26),
 	PARAMETER_NOT_SUPPORTED					= 0x2601,
 	PARAMETER_VALUE_INVALID					= 0x2602,
 	THRESHOLD_PARAMETERS_NOT_SUPPORTED			= 0x2603,
@@ -369,7 +369,7 @@ enum scsi_sense_code {
 	COPY_SOURCE_OR_COPY_DESTINATION_NOT_AUTHORIZED		= 0x2615,
 	FAST_COPY_NOT_POSSIBLE					= 0x2616,
 
-	ASC(WRITE_PROTECTED,					0x27),
+	SCSI_ASC(WRITE_PROTECTED,				0x27),
 	HW_WRITE_PROTECTED					= 0x2701,
 	LU_SOFTWARE_WRITE_PROTECTED				= 0x2702,
 	ASSOCIATED_WRITE_PROTECT				= 0x2703,
@@ -379,12 +379,12 @@ enum scsi_sense_code {
 	SPACE_ALLOCATION_FAILED_WRITE_PROTECT			= 0x2707,
 	ZONE_IS_READ_ONLY					= 0x2708,
 
-	ASC(NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED,	0x28),
+	SCSI_ASC(NOT_READY_TO_READY_CHANGE_MEDIUM_MAY_HAVE_CHANGED, 0x28),
 	IMPORT_OR_EXPORT_ELEMENT_ACCESSED			= 0x2801,
 	FORMAT_LAYER_MAY_HAVE_CHANGED				= 0x2802,
 	IMPORT_EXPORT_ELEMENT_ACCESSED_MEDIUM_CHANGED		= 0x2803,
 
-	ASC(POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED,	0x29),
+	SCSI_ASC(POWER_ON_RESET_OR_BUS_DEVICE_RESET_OCCURRED,	0x29),
 	POWER_ON_OCCURRED					= 0x2901,
 	SCSI_BUS_RESET_OCCURRED					= 0x2902,
 	BUS_DEVICE_RESET_FUNCTION_OCCURRED			= 0x2903,
@@ -393,7 +393,7 @@ enum scsi_sense_code {
 	TRANSCEIVER_MODE_CHANGED_TO_LVD				= 0x2906,
 	I_T_NEXUS_LOSS_OCCURRED					= 0x2907,
 
-	ASC(PARAMETERS_CHANGED,					0x2A),
+	SCSI_ASC(PARAMETERS_CHANGED,				0x2A),
 	MODE_PARAMETERS_CHANGED					= 0x2A01,
 	LOG_PARAMETERS_CHANGED					= 0x2A02,
 	RESERVATIONS_PREEMPTED					= 0x2A03,
@@ -415,9 +415,9 @@ enum scsi_sense_code {
 	MEDIUM_REMOVAL_PREVENTION_PREEMPTED			= 0x2A15,
 	ZONE_RESET_WRITE_POINTER_RECOMMENDED			= 0x2A16,
 
-	ASC(COPY_CANNOT_EXECUTE_SINCE_HOST_CANNOT_DISCONNECT,	0x2B),
+	SCSI_ASC(COPY_CANNOT_EXECUTE_SINCE_HOST_CANNOT_DISCONNECT, 0x2B),
 
-	ASC(COMMAND_SEQUENCE_ERROR,				0x2C),
+	SCSI_ASC(COMMAND_SEQUENCE_ERROR,			0x2C),
 	TOO_MANY_WINDOWS_SPECIFIED				= 0x2C01,
 	INVALID_COMBINATION_OF_WINDOWS_SPECIFIED		= 0x2C02,
 	CURRENT_PROGRAM_AREA_IS_NOT_EMPTY			= 0x2C03,
@@ -438,19 +438,19 @@ enum scsi_sense_code {
 	ZONE_IS_INACTIVE					= 0x2C12,
 	WELL_KNOWN_LU_ACCESS_REQUIRED				= 0x2C13,
 
-	ASC(OVERWRITE_ERROR_ON_UPDATE_IN_PLACE,			0x2D),
+	SCSI_ASC(OVERWRITE_ERROR_ON_UPDATE_IN_PLACE,		0x2D),
 
-	ASC(INSUFFICIENT_TIME_FOR_OPERATION,			0x2E),
+	SCSI_ASC(INSUFFICIENT_TIME_FOR_OPERATION,		0x2E),
 	COMMAND_TIMEOUT_BEFORE_PROCESSING			= 0x2E01,
 	COMMAND_TIMEOUT_DURING_PROCESSING			= 0x2E02,
 	COMMAND_TIMEOUT_DURING_PROCESSING_DUE_TO_ERROR_RECOVERY	= 0x2E03,
 
-	ASC(COMMANDS_CLEARED_BY_ANOTHER_INITIATOR,		0x2F),
+	SCSI_ASC(COMMANDS_CLEARED_BY_ANOTHER_INITIATOR,		0x2F),
 	COMMANDS_CLEARED_BY_POWER_LOSS_NOTIFICATION		= 0x2F01,
 	COMMANDS_CLEARED_BY_DEVICE_SERVER			= 0x2F02,
 	SOME_COMMANDS_CLEARED_BY_QUEUING_LAYER_EVENT		= 0x2F03,
 
-	ASC(INCOMPATIBLE_MEDIUM_INSTALLED,			0x30),
+	SCSI_ASC(INCOMPATIBLE_MEDIUM_INSTALLED,			0x30),
 	CANNOT_READ_MEDIUM_UNKNOWN_FORMAT			= 0x3001,
 	CANNOT_READ_MEDIUM_INCOMPATIBLE_FORMAT			= 0x3002,
 	CLEANING_CARTRIDGE_INSTALLED				= 0x3003,
@@ -468,32 +468,32 @@ enum scsi_sense_code {
 	INCOMPATIBLE_VOLUME_QUALIFIER				= 0x3012,
 	CLEANING_VOLUME_EXPIRED					= 0x3013,
 
-	ASC(MEDIUM_FORMAT_CORRUPTED,				0x31),
+	SCSI_ASC(MEDIUM_FORMAT_CORRUPTED,			0x31),
 	FORMAT_COMMAND_FAILED					= 0x3101,
 	ZONED_FORMATTING_FAILED_DUE_TO_SPARE_LINKING		= 0x3102,
 	SANITIZE_COMMAND_FAILED					= 0x3103,
 	DEPOPULATION_FAILED					= 0x3104,
 	DEPOPULATION_RESTORATION_FAILED				= 0x3105,
 
-	ASC(NO_DEFECT_SPARE_LOCATION_AVAILABLE,			0x32),
+	SCSI_ASC(NO_DEFECT_SPARE_LOCATION_AVAILABLE,		0x32),
 	DEFECT_LIST_UPDATE_FAILURE				= 0x3201,
 
-	ASC(TAPE_LENGTH_ERROR,					0x33),
+	SCSI_ASC(TAPE_LENGTH_ERROR,				0x33),
 
-	ASC(ENCLOSURE_FAILURE,					0x34),
+	SCSI_ASC(ENCLOSURE_FAILURE,				0x34),
 
-	ASC(ENCLOSURE_SERVICES_FAILURE,				0x35),
+	SCSI_ASC(ENCLOSURE_SERVICES_FAILURE,			0x35),
 	UNSUPPORTED_ENCLOSURE_FUNCTION				= 0x3501,
 	ENCLOSURE_SERVICES_UNAVAILABLE				= 0x3502,
 	ENCLOSURE_SERVICES_TRANSFER_FAILURE			= 0x3503,
 	ENCLOSURE_SERVICES_TRANSFER_REFUSED			= 0x3504,
 	ENCLOSURE_SERVICES_CHECKSUM_ERROR			= 0x3505,
 
-	ASC(RIBBON_INK_OR_TONER_FAILURE,			0x36),
+	SCSI_ASC(RIBBON_INK_OR_TONER_FAILURE,			0x36),
 
-	ASC(ROUNDED_PARAMETER,					0x37),
+	SCSI_ASC(ROUNDED_PARAMETER,				0x37),
 
-	ASC(EVENT_STATUS_NOTIFICATION,				0x38),
+	SCSI_ASC(EVENT_STATUS_NOTIFICATION,			0x38),
 	ESN_POWER_MANAGEMENT_CLASS_EVENT			= 0x3802,
 	ESN_MEDIA_CLASS_EVENT					= 0x3804,
 	ESN_DEVICE_BUSY_CLASS_EVENT				= 0x3806,
@@ -501,15 +501,15 @@ enum scsi_sense_code {
 	DEPOPULATION_INTERRUPTED				= 0x3808,
 	DEPOPULATION_RESTORATION_INTERRUPTED			= 0x3809,
 
-	ASC(SAVING_PARAMETERS_NOT_SUPPORTED,			0x39),
+	SCSI_ASC(SAVING_PARAMETERS_NOT_SUPPORTED,		0x39),
 
-	ASC(MEDIUM_NOT_PRESENT,					0x3A),
+	SCSI_ASC(MEDIUM_NOT_PRESENT,				0x3A),
 	MEDIUM_NOT_PRESENT_TRAY_CLOSED				= 0x3A01,
 	MEDIUM_NOT_PRESENT_TRAY_OPEN				= 0x3A02,
 	MEDIUM_NOT_PRESENT_LOADABLE				= 0x3A03,
 	MEDIUM_NOT_PRESENT_MEDIUM_AUXILIARY_MEMORY_ACCESSIBLE	= 0x3A04,
 
-	ASC(SEQUENTIAL_POSITIONING_ERROR,			0x3B),
+	SCSI_ASC(SEQUENTIAL_POSITIONING_ERROR,			0x3B),
 	TAPE_POSITION_ERROR_AT_BEGINNING_OF_MEDIUM		= 0x3B01,
 	TAPE_POSITION_ERROR_AT_END_OF_MEDIUM			= 0x3B02,
 	TAPE_OR_ELECTRONIC_VERTICAL_FORMS_UNIT_NOT_READY	= 0x3B03,
@@ -539,15 +539,15 @@ enum scsi_sense_code {
 	TOO_MANY_LOGICAL_OBJECTS_ON_PARTITION_TO_SUPPORT_OP	= 0x3B1C,
 	ELEMENT_STATIC_INFORMATION_CHANGED			= 0x3B20,
 
-	ASC(INVALID_BITS_IN_IDENTIFY_MESSAGE,			0x3D),
+	SCSI_ASC(INVALID_BITS_IN_IDENTIFY_MESSAGE,		0x3D),
 
-	ASC(LU_HAS_NOT_SELF_CONFIGURED_YET,			0x3E),
+	SCSI_ASC(LU_HAS_NOT_SELF_CONFIGURED_YET,		0x3E),
 	LU_FAILURE						= 0x3E01,
 	TIMEOUT_ON_LOGICAL_UNIT					= 0x3E02,
 	LU_FAILED_SELF_TEST					= 0x3E03,
 	LU_UNABLE_TO_UPDATE_SELFTEST_LOG			= 0x3E04,
 
-	ASC(TARGET_OPERATING_CONDITIONS_HAVE_CHANGED,		0x3F),
+	SCSI_ASC(TARGET_OPERATING_CONDITIONS_HAVE_CHANGED,	0x3F),
 	MICROCODE_HAS_BEEN_CHANGED				= 0x3F01,
 	CHANGED_OPERATING_DEFINITION				= 0x3F02,
 	INQUIRY_DATA_HAS_CHANGED				= 0x3F03,
@@ -575,24 +575,24 @@ enum scsi_sense_code {
 	BIND_REDIRECTED						= 0x3F19,
 	SUBSIDIARY_BINDING_CHANGED				= 0x3F1A,
 
-	ASC(RAM_FAILURE,					0x40),
+	SCSI_ASC(RAM_FAILURE,					0x40),
 	/* DIAGNOSTIC_FAILURE_ON_COMPONENT_NN			= 0x40NN */
 
-	ASC(DATA_PATH_FAILURE,					0x41),
+	SCSI_ASC(DATA_PATH_FAILURE,				0x41),
 
-	ASC(POWER_ON_OR_SELFTEST_FAILURE,			0x42),
+	SCSI_ASC(POWER_ON_OR_SELFTEST_FAILURE,			0x42),
 
-	ASC(MESSAGE_ERROR,					0x43),
+	SCSI_ASC(MESSAGE_ERROR,					0x43),
 
-	ASC(INTERNAL_TARGET_FAILURE,				0x44),
+	SCSI_ASC(INTERNAL_TARGET_FAILURE,			0x44),
 	PERSISTENT_RESERVATION_INFORMATION_LOST			= 0x4401,
 	ATA_DEVICE_FAILED_SET_FEATURES				= 0x4471,
 
-	ASC(SELECT_OR_RESELECT_FAILURE,				0x45),
+	SCSI_ASC(SELECT_OR_RESELECT_FAILURE,			0x45),
 
-	ASC(UNSUCCESSFUL_SOFT_RESET,				0x46),
+	SCSI_ASC(UNSUCCESSFUL_SOFT_RESET,			0x46),
 
-	ASC(SCSI_PARITY_ERROR,					0x47),
+	SCSI_ASC(SCSI_PARITY_ERROR,				0x47),
 	DATA_PHASE_CRC_ERROR_DETECTED				= 0x4701,
 	SCSI_PARITY_ERROR_DETECTED_DURING_ST_DATA_PHASE		= 0x4702,
 	INFORMATION_UNIT_iuCRC_ERROR_DETECTED			= 0x4703,
@@ -601,13 +601,13 @@ enum scsi_sense_code {
 	PHY_TEST_FUNCTION_IN_PROGRESS				= 0x4706,
 	SOME_COMMANDS_CLEARED_BY_ISCSI_PROTOCOL_EVENT		= 0x477F,
 
-	ASC(INITIATOR_DETECTED_ERROR_MESSAGE_RECEIVED,		0x48),
+	SCSI_ASC(INITIATOR_DETECTED_ERROR_MESSAGE_RECEIVED,	0x48),
 
-	ASC(INVALID_MESSAGE_ERROR,				0x49),
+	SCSI_ASC(INVALID_MESSAGE_ERROR,				0x49),
 
-	ASC(COMMAND_PHASE_ERROR,				0x4A),
+	SCSI_ASC(COMMAND_PHASE_ERROR,				0x4A),
 
-	ASC(DATA_PHASE_ERROR,					0x4B),
+	SCSI_ASC(DATA_PHASE_ERROR,				0x4B),
 	INVALID_TARGET_PORT_TRANSFER_TAG_RECEIVED		= 0x4B01,
 	TOO_MUCH_WRITE_DATA					= 0x4B02,
 	ACK_NAK_TIMEOUT						= 0x4B03,
@@ -630,22 +630,22 @@ enum scsi_sense_code {
 	PCIE_ACS_VIOLATION					= 0x4B14,
 	PCIE_TLP_PREFIX_BLOCKED					= 0x4B15,
 
-	ASC(LU_FAILED_SELF_CONFIGURATION,			0x4C),
+	SCSI_ASC(LU_FAILED_SELF_CONFIGURATION,			0x4C),
 
-	ASC(TAGGED_OVERLAPPED_COMMANDS,				0x4D),
+	SCSI_ASC(TAGGED_OVERLAPPED_COMMANDS,			0x4D),
 
-	ASC(OVERLAPPED_COMMANDS_ATTEMPTED,			0x4E),
+	SCSI_ASC(OVERLAPPED_COMMANDS_ATTEMPTED,			0x4E),
 
-	ASC(WRITE_APPEND_ERROR,					0x50),
+	SCSI_ASC(WRITE_APPEND_ERROR,				0x50),
 	WRITE_APPEND_POSITION_ERROR				= 0x5001,
 	POSITION_ERROR_RELATED_TO_TIMING			= 0x5002,
 
-	ASC(ERASE_FAILURE,					0x51),
+	SCSI_ASC(ERASE_FAILURE,					0x51),
 	ERASE_FAILURE_INCOMPLETE_ERASE_OP_DETECTED		= 0x5101,
 
-	ASC(CARTRIDGE_FAULT,					0x52),
+	SCSI_ASC(CARTRIDGE_FAULT,				0x52),
 
-	ASC(MEDIA_LOAD_OR_EJECT_FAILED,				0x53),
+	SCSI_ASC(MEDIA_LOAD_OR_EJECT_FAILED,			0x53),
 	UNLOAD_TAPE_FAILURE					= 0x5301,
 	MEDIUM_REMOVAL_PREVENTED				= 0x5302,
 	MEDIUM_REMOVAL_PREVENTED_BY_DATA_TRANSFER_ELEMENT	= 0x5303,
@@ -660,9 +660,9 @@ enum scsi_sense_code {
 	DATA_TRANSFER_DEVICE_ERR_EJECT_FAILED			= 0x530C,
 	DATA_TRANSFER_DEVICE_ERR_LIBRARY_COMMUNICATION_FAILED	= 0x530D,
 
-	ASC(SCSI_TO_HOST_SYSTEM_INTERFACE_FAILURE,		0x54),
+	SCSI_ASC(SCSI_TO_HOST_SYSTEM_INTERFACE_FAILURE,		0x54),
 
-	ASC(SYSTEM_RESOURCE_FAILURE,				0x55),
+	SCSI_ASC(SYSTEM_RESOURCE_FAILURE,			0x55),
 	SYSTEM_BUFFER_FULL					= 0x5501,
 	INSUFFICIENT_RESERVATION_RESOURCES			= 0x5502,
 	INSUFFICIENT_RESOURCES					= 0x5503,
@@ -681,27 +681,27 @@ enum scsi_sense_code {
 	MAXIMUM_NUMBER_OF_STREAMS_OPEN				= 0x5510,
 	INSUFFICIENT_RESOURCES_TO_BIND				= 0x5511,
 
-	ASC(UNABLE_TO_RECOVER_TABLE_OF_CONTENTS,		0x57),
+	SCSI_ASC(UNABLE_TO_RECOVER_TABLE_OF_CONTENTS,		0x57),
 
-	ASC(GENERATION_DOES_NOT_EXIST,				0x58),
+	SCSI_ASC(GENERATION_DOES_NOT_EXIST,			0x58),
 
-	ASC(UPDATED_BLOCK_READ,					0x59),
+	SCSI_ASC(UPDATED_BLOCK_READ,				0x59),
 
-	ASC(OPERATOR_REQUEST_OR_STATE_CHANGE_INPUT,		0x5A),
+	SCSI_ASC(OPERATOR_REQUEST_OR_STATE_CHANGE_INPUT,	0x5A),
 	OPERATOR_MEDIUM_REMOVAL_REQUEST				= 0x5A01,
 	OPERATOR_SELECTED_WRITE_PROTECT				= 0x5A02,
 	OPERATOR_SELECTED_WRITE_PERMIT				= 0x5A03,
 
-	ASC(LOG_EXCEPTION,					0x5B),
+	SCSI_ASC(LOG_EXCEPTION,					0x5B),
 	THRESHOLD_CONDITION_MET					= 0x5B01,
 	LOG_COUNTER_AT_MAXIMUM					= 0x5B02,
 	LOG_LIST_CODES_EXHAUSTED				= 0x5B03,
 
-	ASC(RPL_STATUS_CHANGE,					0x5C),
+	SCSI_ASC(RPL_STATUS_CHANGE,				0x5C),
 	SPINDLES_SYNCHRONIZED					= 0x5C01,
 	SPINDLES_NOT_SYNCHRONIZED				= 0x5C02,
 
-	ASC(FAILURE_PREDICTION_THRESHOLD_EXCEEDED,		0x5D),
+	SCSI_ASC(FAILURE_PREDICTION_THRESHOLD_EXCEEDED,		0x5D),
 	MEDIA_FAILURE_PREDICTION_THRESHOLD_EXCEEDED		= 0x5D01,
 	LU_FAILURE_PREDICTION_THRESHOLD_EXCEEDED		= 0x5D02,
 	SPARE_AREA_EXHAUSTION_PREDICTION_THRESHOLD_EXCEEDED	= 0x5D03,
@@ -787,7 +787,7 @@ enum scsi_sense_code {
 	MEDIA_IMPENDING_FAILURE_ENDURANCE_LIMIT_MET		= 0x5D73,
 	FAILURE_PREDICTION_THRESHOLD_EXCEEDED_FALSE		= 0x5DFF,
 
-	ASC(LOW_POWER_CONDITION_ON,				0x5E),
+	SCSI_ASC(LOW_POWER_CONDITION_ON,			0x5E),
 	IDLE_CONDITION_ACTIVATED_BY_TIMER			= 0x5E01,
 	STANDBY_CONDITION_ACTIVATED_BY_TIMER			= 0x5E02,
 	IDLE_CONDITION_ACTIVATED_BY_COMMAND			= 0x5E03,
@@ -804,28 +804,28 @@ enum scsi_sense_code {
 	POWER_STATE_CHANGE_TO_SLEEP				= 0x5E45,
 	POWER_STATE_CHANGE_TO_DEVICE_CONTROL			= 0x5E47,
 
-	ASC(LAMP_FAILURE,					0x60),
+	SCSI_ASC(LAMP_FAILURE,					0x60),
 
-	ASC(VIDEO_ACQUISITION_ERROR,				0x61),
+	SCSI_ASC(VIDEO_ACQUISITION_ERROR,			0x61),
 	UNABLE_TO_ACQUIRE_VIDEO					= 0x6101,
 	OUT_OF_FOCUS						= 0x6102,
 
-	ASC(SCAN_HEAD_POSITIONING_ERROR,			0x62),
+	SCSI_ASC(SCAN_HEAD_POSITIONING_ERROR,			0x62),
 
-	ASC(END_OF_USER_AREA_ENCOUNTERED_ON_THIS_TRACK,		0x63),
+	SCSI_ASC(END_OF_USER_AREA_ENCOUNTERED_ON_THIS_TRACK,	0x63),
 	PACKET_DOES_NOT_FIT_IN_AVAILABLE_SPACE			= 0x6301,
 
-	ASC(ILLEGAL_MODE_FOR_THIS_TRACK,			0x64),
+	SCSI_ASC(ILLEGAL_MODE_FOR_THIS_TRACK,			0x64),
 	INVALID_PACKET_SIZE					= 0x6401,
 
-	ASC(VOLTAGE_FAULT,					0x65),
+	SCSI_ASC(VOLTAGE_FAULT,					0x65),
 
-	ASC(AUTOMATIC_DOCUMENT_FEEDER_COVER_UP,			0x66),
+	SCSI_ASC(AUTOMATIC_DOCUMENT_FEEDER_COVER_UP,		0x66),
 	AUTOMATIC_DOCUMENT_FEEDER_LIFT_UP			= 0x6601,
 	DOCUMENT_JAM_IN_AUTOMATIC_DOCUMENT_FEEDER		= 0x6602,
 	DOCUMENT_MISS_FEED_AUTOMATIC_IN_DOCUMENT_FEEDER		= 0x6603,
 
-	ASC(CONFIG_FAILURE,					0x67),
+	SCSI_ASC(CONFIG_FAILURE,				0x67),
 	CONFIG_OF_INCAPABLE_LOGICAL_UNITS_FAILED		= 0x6701,
 	ADD_LU_FAILED						= 0x6702,
 	MODIFICATION_OF_LU_FAILED				= 0x6703,
@@ -841,26 +841,26 @@ enum scsi_sense_code {
 	EXPLICIT_BIND_NOT_ALLOWED				= 0x670D,
 	FEATURE_NOT_ENABLED					= 0x670E,
 
-	ASC(LU_NOT_CONFIGURED,					0x68),
+	SCSI_ASC(LU_NOT_CONFIGURED,				0x68),
 	SUBSIDIARY_LU_NOT_CONFIGURED				= 0x6801,
 
-	ASC(DATA_LOSS_ON_LOGICAL_UNIT,				0x69),
+	SCSI_ASC(DATA_LOSS_ON_LOGICAL_UNIT,			0x69),
 	MULTIPLE_LU_FAILURES					= 0x6901,
 	PARITY_DATA_MISMATCH					= 0x6902,
 
-	ASC(INFORMATIONAL_REFER_TO_LOG,				0x6A),
+	SCSI_ASC(INFORMATIONAL_REFER_TO_LOG,			0x6A),
 
-	ASC(STATE_CHANGE_HAS_OCCURRED,				0x6B),
+	SCSI_ASC(STATE_CHANGE_HAS_OCCURRED,			0x6B),
 	REDUNDANCY_LEVEL_GOT_BETTER				= 0x6B01,
 	REDUNDANCY_LEVEL_GOT_WORSE				= 0x6B02,
 
-	ASC(REBUILD_FAILURE_OCCURRED,				0x6C),
+	SCSI_ASC(REBUILD_FAILURE_OCCURRED,			0x6C),
 
-	ASC(RECALCULATE_FAILURE_OCCURRED,			0x6D),
+	SCSI_ASC(RECALCULATE_FAILURE_OCCURRED,			0x6D),
 
-	ASC(COMMAND_TO_LU_FAILED,				0x6E),
+	SCSI_ASC(COMMAND_TO_LU_FAILED,				0x6E),
 
-	ASC(COPY_PROTECTION_KEY_EXCHANGE_FAILURE_AUTHENTICATION_FAILURE, 0x6F),
+	SCSI_ASC(COPY_PROTECTION_KEY_EXCHANGE_FAILURE_AUTHENTICATION_FAILURE, 0x6F),
 	COPY_PROTECTION_KEY_EXCHANGE_FAILURE_KEY_NOT_PRESENT	= 0x6F01,
 	COPY_PROTECTION_KEY_EXCHANGE_FAILURE_KEY_NOT_ESTABLISHED = 0x6F02,
 	READ_OF_SCRAMBLED_SECTOR_WITHOUT_AUTHENTICATION		= 0x6F03,
@@ -872,11 +872,11 @@ enum scsi_sense_code {
 	INVALID_DRIVE_HOST_PAIRING_SERVER			= 0x6F09,
 	DRIVE_HOST_PAIRING_SUSPENDED				= 0x6F0A,
 
-	ASC(DECOMPRESSION_EXCEPTION_SHORT_ALGORITHM_ID,		0x70),
+	SCSI_ASC(DECOMPRESSION_EXCEPTION_SHORT_ALGORITHM_ID,	0x70),
 
-	ASC(DECOMPRESSION_EXCEPTION_LONG_ALGORITHM_ID,		0x71),
+	SCSI_ASC(DECOMPRESSION_EXCEPTION_LONG_ALGORITHM_ID,	0x71),
 
-	ASC(SESSION_FIXATION_ERROR,				0x72),
+	SCSI_ASC(SESSION_FIXATION_ERROR,			0x72),
 	SESSION_FIXATION_ERROR_WRITING_LEAD_IN			= 0x7201,
 	SESSION_FIXATION_ERROR_WRITING_LEAD_OUT			= 0x7202,
 	SESSION_FIXATION_ERROR_INCOMPLETE_TRACK_IN_SESSION	= 0x7203,
@@ -885,7 +885,7 @@ enum scsi_sense_code {
 	RMZ_EXTENSION_IS_NOT_ALLOWED				= 0x7206,
 	NO_MORE_TEST_ZONE_EXTENSIONS_ARE_ALLOWED		= 0x7207,
 
-	ASC(CD_CONTROL_ERROR,					0x73),
+	SCSI_ASC(CD_CONTROL_ERROR,				0x73),
 	POWER_CALIBRATION_AREA_ALMOST_FULL			= 0x7301,
 	POWER_CALIBRATION_AREA_IS_FULL				= 0x7302,
 	POWER_CALIBRATION_AREA_ERROR				= 0x7303,
@@ -896,7 +896,7 @@ enum scsi_sense_code {
 	CURRENT_POWER_CALIBRATION_AREA_IS_FULL			= 0x7311,
 	RDZ_IS_FULL						= 0x7317,
 
-	ASC(SECURITY_ERROR,					0x74),
+	SCSI_ASC(SECURITY_ERROR,				0x74),
 	UNABLE_TO_DECRYPT_DATA					= 0x7401,
 	UNENCRYPTED_DATA_ENCOUNTERED_WHILE_DECRYPTING		= 0x7402,
 	INCORRECT_DATA_ENCRYPTION_KEY				= 0x7403,
@@ -926,8 +926,8 @@ enum scsi_sense_code {
 	SECURITY_CONFLICT_IN_TRANSLATED_DEVICE			= 0x7479,
 };
 
-#undef ASC_DEF
-#undef ASC
+#undef SCSI_ASC_DEF
+#undef SCSI_ASC
 
 /*
  * Use this to build non-standard sense codes.
author maintainer
#1757 lore raw

PATCH 1727/1756 kernfs: avoid READ_ONCE() on a kgid_t in kernfs_new_node()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Shakeel Butt <[email protected]>

commit ef179363b04306dbc645c53207b9ad3516ebc75f upstream.

kernfs_new_node() reads the parent's gid with READ_ONCE(attrs->ia_gid). That gid is a kgid_t, which is a struct.

On SMP alpha, READ_ONCE() ends by casting the value it loaded back to the type of its argument. Here that is a cast from a struct to the same struct. GCC accepts that as an extension, but ISO C does not allow a cast to or from a struct type, so sparse warns:

fs/kernfs/dir.c:751:31: sparse: sparse: cast to non-scalar fs/kernfs/dir.c:751:31: sparse: sparse: cast from non-scalar

Read the gid_t inside the kgid_t instead, and wrap it back up with KGIDT_INIT(). This is still a single marked load of the same four bytes.

There is no functional change. With GCC 12 for alpha (the config from the report) and GCC 14 for x86-64 (with and without KCSAN), fs/kernfs/dir.o has the same object code before and after this change.

---
 fs/kernfs/dir.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/kernfs/dir.c +1 -1
@@ -697,7 +697,7 @@ struct kernfs_node *kernfs_new_node(stru
 		struct kernfs_iattrs *attrs = READ_ONCE(parent->iattr);
 
 		if (attrs)
-			gid = READ_ONCE(attrs->ia_gid);
+			gid = KGIDT_INIT(READ_ONCE(attrs->ia_gid.val));
 
 		if (flags & KERNFS_DIR)
 			mode |= S_ISGID;
author maintainer
#1758 lore raw

PATCH 1728/1756 nvmet-auth: reject incomplete DHCHAP messages

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jérémy Jean <[email protected]>

commit 29e027774324dbd5321a67bbd16840e8f7bcd189 upstream.

Commit c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads") only ensures that AUTH_SEND has auth_type and auth_id before nvmet_execute_auth_send() starts parsing the payload, but the DHCHAP path reads t_id before it verifies message lengths. A two-byte DHCHAP NEGOTIATE payload can therefore still trigger an OOB read that KASAN reports as:

  BUG: KASAN: slab-out-of-bounds in nvmet_execute_auth_send
  Read of size 2 at addr ffff8880030d8364

Require the payload to cover the minimum DHCHAP message length before parsing it.

Fixes c9359401036e ("nvmet-auth: reject undersized AUTH_SEND payloads")
---
 drivers/nvme/target/fabrics-cmd-auth.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fabrics-cmd-auth.c +1 -1
@@ -256,7 +256,7 @@ void nvmet_execute_auth_send(struct nvme
 		nvmet_check_transfer_len(req, tl);
 		return;
 	}
-	if (tl < offsetof(struct nvmf_auth_dhchap_success2_data, rsvd1)) {
+	if (tl < sizeof(struct nvmf_auth_dhchap_failure_data)) {
 		status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR;
 		req->error_loc =
 			offsetof(struct nvmf_auth_send_command, tl);
author maintainer
#1759 lore raw

PATCH 1729/1756 PM: runtime: Only queue an idle check for RPM-linked suppliers (part 2)

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Brian Norris <[email protected]>

commit bd56424ce808fb1f92a4dc5bdeedc45b85c5d6cd upstream.

Commit be5755f023e7 ("PM: runtime: Only queue an idle check for RPM-linked suppliers") was incomplete. There are two other cases where we perform idle checks on non-DL_FLAG_PM_RUNTIME suppliers -- in pm_runtime_set_suspended(), and in cases where we failed to resume suppliers.

Fixes be5755f023e7 ("PM: runtime: Only queue an idle check for RPM-linked suppliers")
Fixes 5244f5e2d801 ("PM: runtime: Defer suspending suppliers")
---
 drivers/base/power/runtime.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/base/power/runtime.c +3 -0
@@ -331,6 +331,9 @@ static void __rpm_put_suppliers(struct d
 
 	list_for_each_entry_rcu(link, &dev->links.suppliers, c_node,
 				device_links_read_lock_held()) {
+		if (!device_link_test(link, DL_FLAG_PM_RUNTIME))
+			continue;
+
 		pm_runtime_release_supplier(link);
 		if (try_to_suspend)
 			pm_request_idle(link->supplier);
author maintainer
#1760 lore raw

PATCH 1730/1756 fs/ntfs3: fix deadlock in ni_read_folio_cmpr

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Szymon Wilczek <[email protected]>

commit e37a75bb866c29da954b51d0dd7670406246d9ee upstream.

Syzbot reported a task hung in ni_readpage_cmpr (now ni_read_folio_cmpr). This is caused by a lock inversion deadlock involving the inode mutex (ni_lock) and page locks.

Scenario:
1. Task A enters ntfs_read_folio() for page X. It acquires ni_lock.
2. Task A calls ni_read_folio_cmpr(), which attempts to lock all pages in the compressed frame (including page Y).
3. Concurrently, Task B (e.g., via readahead) has locked page Y and calls ntfs_read_folio().
4. Task B waits for ni_lock (held by A).
5. Task A waits for page Y lock (held by B).
-> DEADLOCK.

The fix is to restructure locking: do not take ni_lock in ntfs_read_folio(). Instead, acquire ni_lock inside ni_read_folio_cmpr() ONLY AFTER all required page locks for the frame have been successfully acquired. This restores the correct lock ordering (Page Lock -> ni_lock) consistent with VFS.

Reported-by [email protected]
Fixes f35590ee26f5 ("fs/ntfs3: remove ntfs_bio_pages and use page cache for compressed I/O")
[[email protected]: ni_readpage_cmpr was renamed to ni_read_folio_cmpr]
---
 fs/ntfs3/frecord.c |    2 ++
 fs/ntfs3/inode.c   |    3 +--
 2 files changed, 3 insertions(+), 2 deletions(-)
fs/ntfs3/frecord.c +2 -0
@@ -2176,7 +2176,9 @@ int ni_read_folio_cmpr(struct ntfs_inode
 		pages[i] = pg;
 	}
 
+	ni_lock(ni);
 	err = ni_read_frame(ni, frame_vbo, pages, pages_per_frame, 0);
+	ni_unlock(ni);
 
 out1:
 	for (i = 0; i < pages_per_frame; i++) {
fs/ntfs3/inode.c +1 -2
@@ -756,9 +756,8 @@ static int ntfs_read_folio(struct file *
 	}
 
 	if (is_compressed(ni)) {
-		ni_lock(ni);
+		/* ni_lock is taken inside ni_read_folio_cmpr after page locks */
 		err = ni_read_folio_cmpr(ni, folio);
-		ni_unlock(ni);
 		return err;
 	}
 
author maintainer
#1761 lore raw

PATCH 1731/1756 net: lwtunnel: Drop skb metadata before LWT encapsulation

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Jakub Sitnicki <[email protected]>

commit c00320b0e355c4bf0ae4743a53b4180fea237546 upstream.

skb metadata is meant for passing information between XDP and TC. It lives in the skb headroom, immediately before skb->data. LWT programs cannot access the __sk_buff->data_meta pseudo-pointer to metadata.

However, LWT encapsulation prepends outer headers, moving skb->data back over the headroom where the metadata sits. On an RX-originated (forwarded) packet that still carries XDP metadata this goes wrong in two different ways, depending on the encap type:

1. Non-BPF LWT encaps (mpls, seg6, ioam6 ...) call skb_push()/skb_pull() and silently overwrite the metadata that sits in the headroom.

2) BPF LWT xmit calls bpf_skb_change_head(), which uses skb_data_move(). That helper expects metadata immediately before skb->data. But since the IP output path runs LWT xmit before neighbour output has built the outgoing L2 header, for forwarded packets skb->data points at the L3 header while skb_mac_header() still points at the old L2 header. skb_data_move() sees metadata ending at skb_mac_header(), not before skb->data, warns and clears metadata:

  WARNING: CPU: 21 PID: 454557 at include/linux/skbuff.h:4609 skb_data_move+0x47/0x90
  CPU: 21 UID: 0 PID: 454557 Comm: napi/iconduit-g Tainted: G           O        6.18.21 #1
  RIP: 0010:skb_data_move+0x47/0x90
  Call Trace:
   <IRQ>
   bpf_skb_change_head+0xe6/0x1a0
   bpf_prog_...+0x213/0x2e3
   run_lwt_bpf.isra.0+0x1d3/0x360
   bpf_xmit+0x46/0xe0
   lwtunnel_xmit+0xa1/0xf0
   ip_finish_output2+0x1e7/0x5e0
   ip_output+0x63/0x100
   __netif_receive_skb_one_core+0x85/0xa0
   process_backlog+0x9c/0x150
   __napi_poll+0x2b/0x190
   net_rx_action+0x40b/0x7f0
   handle_softirqs+0xd2/0x270
   do_softirq+0x3f/0x60
   </IRQ>

That is what happens, as for how to fix it - a received packet that carries metadata can reach an encap through any of the three LWT redirect modes:

LWTUNNEL_STATE_INPUT_REDIRECT
ip6_rcv_finish
dst_input
lwtunnel_input

LWTUNNEL_STATE_OUTPUT_REDIRECT
ip6_rcv_finish
dst_input
ip6_forward
ip6_forward_finish
dst_output
lwtunnel_output

LWTUNNEL_STATE_XMIT_REDIRECT
ip6_rcv_finish
dst_input
ip6_forward
ip6_forward_finish
dst_output
ip6_output
ip6_finish_output
ip6_finish_output2
lwtunnel_xmit

Every encap funnels through the three LWT dispatch helpers, so drop the metadata there, right before handing the skb to the encap op. This single chokepoint covers all encap types and all three redirect modes:

- lwtunnel_input(): seg6, rpl, ila, seg6_local
- lwtunnel_output(): ioam6
- lwtunnel_xmit(): mpls, LWT BPF xmit

Alternatively, we could clear the metadata right after TC ingress hook. That would require a compromise, however. Metadata would become inaccessible from TC egress (in setups where it actually reaches the hook it tact, that is without any L2 tunnels on path).

---
 net/core/lwtunnel.c |    6 ++++++
 1 file changed, 6 insertions(+)
net/core/lwtunnel.c +6 -0
@@ -358,6 +358,8 @@ int lwtunnel_output(struct net *net, str
 	rcu_read_lock();
 	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
 	if (likely(ops && ops->output)) {
+		/* Encap pushes outer headers over the metadata; drop it. */
+		skb_metadata_clear(skb);
 		dev_xmit_recursion_inc();
 		ret = ops->output(net, sk, skb);
 		dev_xmit_recursion_dec();
@@ -412,6 +414,8 @@ int lwtunnel_xmit(struct sk_buff *skb)
 	rcu_read_lock();
 	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
 	if (likely(ops && ops->xmit)) {
+		/* Encap pushes outer headers over the metadata; drop it. */
+		skb_metadata_clear(skb);
 		dev_xmit_recursion_inc();
 		ret = ops->xmit(skb);
 		dev_xmit_recursion_dec();
@@ -463,6 +467,8 @@ int lwtunnel_input(struct sk_buff *skb)
 	rcu_read_lock();
 	ops = rcu_dereference(lwtun_encaps[lwtstate->type]);
 	if (likely(ops && ops->input)) {
+		/* Encap pushes outer headers over the metadata; drop it. */
+		skb_metadata_clear(skb);
 		dev_xmit_recursion_inc();
 		ret = ops->input(skb);
 		dev_xmit_recursion_dec();
author maintainer
#1762 lore raw

PATCH 1732/1756 selftests/cgroup: set the test plan after the setup checks

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Hemanth Selam <[email protected]>

commit 0c893d170ff8efe7b4067552932d26e7defba307 upstream.

The cgroup tests announce their plan before checking whether cgroup v2 is available, so on a host without it they promise a number of results and then skip out after the first one:

	TAP version 13
	1..3
	ok 1 # SKIP cgroup v2 isn't mounted
	# Planned tests != run tests (3 != 1)
	# Totals: pass:0 fail:0 xfail:0 xpass:0 skip:1 error:0

ksft_exit_skip() can only emit a well formed "1..0 # SKIP" line while no plan has been printed, as the comment above it in kselftest.h points out.

Move ksft_set_plan() below the setup checks that can skip, so that a skipped run reports:

TAP version 13
1..0 # SKIP cgroup v2 isn't mounted

Several of the tests skip more than once while setting up, for a missing or unwritable controller as well, so the plan goes after the last of them. test_core joins its two setup paths at the post_v2_setup label and sets the plan there.

Reporting each planned test as skipped instead would keep the plan where it is, but the setup failures here mean the whole test cannot run rather than its individual cases being skipped, which is what "1..0 # SKIP" is for.

Fixes 1dc830ee4c15 ("selftests/cgroup: conform test to KTAP format output")
---
 tools/testing/selftests/cgroup/test_core.c       |    2 +-
 tools/testing/selftests/cgroup/test_cpu.c        |    2 +-
 tools/testing/selftests/cgroup/test_cpuset.c     |    2 +-
 tools/testing/selftests/cgroup/test_freezer.c    |    2 +-
 tools/testing/selftests/cgroup/test_kill.c       |    2 +-
 tools/testing/selftests/cgroup/test_kmem.c       |    2 +-
 tools/testing/selftests/cgroup/test_memcontrol.c |    2 +-
 tools/testing/selftests/cgroup/test_pids.c       |    2 +-
 tools/testing/selftests/cgroup/test_zswap.c      |    2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)
tools/testing/selftests/cgroup/test_core.c +1 -1
@@ -902,7 +902,6 @@ int main(int argc, char *argv[])
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), &nsdelegate)) {
 		if (setup_named_v1_root(root, sizeof(root), CG_NAMED_NAME))
 			ksft_exit_skip("cgroup v2 isn't mounted and could not setup named v1 hierarchy\n");
@@ -915,6 +914,7 @@ int main(int argc, char *argv[])
 			ksft_exit_skip("Failed to set memory controller\n");
 
 post_v2_setup:
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_cpu.c +1 -1
@@ -701,7 +701,6 @@ int main(int argc, char *argv[])
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -709,6 +708,7 @@ int main(int argc, char *argv[])
 		if (cg_write(root, "cgroup.subtree_control", "+cpu"))
 			ksft_exit_skip("Failed to set cpu controller\n");
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_cpuset.c +1 -1
@@ -250,7 +250,6 @@ int main(int argc, char *argv[])
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -258,6 +257,7 @@ int main(int argc, char *argv[])
 		if (cg_write(root, "cgroup.subtree_control", "+cpuset"))
 			ksft_exit_skip("Failed to set cpuset controller\n");
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_freezer.c +1 -1
@@ -828,9 +828,9 @@ int main(int argc, char *argv[])
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_kill.c +1 -1
@@ -277,9 +277,9 @@ int main(int argc, char *argv[])
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_kmem.c +1 -1
@@ -421,7 +421,6 @@ int main(int argc, char **argv)
 	int i;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -436,6 +435,7 @@ int main(int argc, char **argv)
 		if (cg_write(root, "cgroup.subtree_control", "+memory"))
 			ksft_exit_skip("Failed to set memory controller\n");
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_memcontrol.c +1 -1
@@ -1652,7 +1652,6 @@ int main(int argc, char **argv)
 	int i, proc_status;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -1677,6 +1676,7 @@ int main(int argc, char **argv)
 		ksft_exit_skip("Failed to query cgroup mount option\n");
 	has_localevents = proc_status;
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_pids.c +1 -1
@@ -145,7 +145,6 @@ int main(int argc, char **argv)
 	char root[PATH_MAX];
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -160,6 +159,7 @@ int main(int argc, char **argv)
 		if (cg_write(root, "cgroup.subtree_control", "+pids"))
 			ksft_exit_skip("Failed to set pids controller\n");
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (int i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
tools/testing/selftests/cgroup/test_zswap.c +1 -1
@@ -770,7 +770,6 @@ int main(int argc, char **argv)
 		page_size = BUF_SIZE;
 
 	ksft_print_header();
-	ksft_set_plan(ARRAY_SIZE(tests));
 	if (cg_find_unified_root(root, sizeof(root), NULL))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
 
@@ -787,6 +786,7 @@ int main(int argc, char **argv)
 		if (cg_write(root, "cgroup.subtree_control", "+memory"))
 			ksft_exit_skip("Failed to set memory controller\n");
 
+	ksft_set_plan(ARRAY_SIZE(tests));
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
author maintainer
#1763 lore raw

PATCH 1733/1756 irqchip/gic-v3-its: Fix over allocation in itt_alloc_pool()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Steven Price <[email protected]>

commit bc88d44bd7e45b992cf8c2c2ffbc7bb3e24db4a7 upstream.

itt_alloc_pool() calls its_alloc_pages_node() to allocate an individual page to add to the pool (for allocations <PAGE_SIZE). However the final argument of its_alloc_pages_node() is the page order not the number of pages. Currently it allocates two pages and leaks the second page. Fix it by passing 0 instead (1 << 0 = 1 page).

---
 drivers/irqchip/irq-gic-v3-its.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +1 -1
@@ -265,7 +265,7 @@ static void *itt_alloc_pool(int node, in
 		if (addr)
 			break;
 
-		page = its_alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 1);
+		page = its_alloc_pages_node(node, GFP_KERNEL | __GFP_ZERO, 0);
 		if (!page)
 			break;
 
author maintainer
#1764 lore raw

PATCH 1734/1756 phy: freescale: fsl-samsung-hdmi: Fix 64-by-32 division cocci warnings

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Adam Ford <[email protected]>

commit 739214dd1c209e34323814fb815fb17cccb9f95b upstream.

The Kernel test robot returns the following warning:
do_div() does a 64-by-32 division, please consider using div64_ul instead.

To prevent the 64-by-32 divsion, consolidate both the multiplication and the do_div into one line which explicitly uses u64 sizes.

Fixes 1951dbb41d1d ("phy: freescale: fsl-samsung-hdmi: Support dynamic integer")
---
 drivers/phy/freescale/phy-fsl-samsung-hdmi.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/phy/freescale/phy-fsl-samsung-hdmi.c +1 -2
@@ -483,8 +483,7 @@ static unsigned long fsl_samsung_hdmi_ph
 			 * Fvco = (M * f_ref) / P,
 			 * where f_ref is 24MHz.
 			 */
-			tmp = (u64)_m * 24 * MHZ;
-			do_div(tmp, _p);
+			tmp = div64_ul((u64)_m * 24 * MHZ, _p);
 			if (tmp < 750 * MHZ ||
 			    tmp > 3000 * MHZ)
 				continue;
author maintainer
#1765 lore raw

PATCH 1735/1756 soc: qcom: pmic_glink: Drop redundant pg assignment before taking lock

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Krzysztof Kozlowski <[email protected]>

commit 1ac98d6484c4a53e9b3ed1f59d03a2dd2d287b70 upstream.

Commit e9f826b0459f ("soc: qcom: pmic_glink: simplify locking with guard()") was on top of a fix [1] which was moving the 'pg = __pmic_glink' assignment into the critical section. Unfortunately the actual fix was not applied and instead rebased version of the next patch got in. The resulting code is in general correct, but now there is a duplicated assignment 'pg = __pmic_glink'.

[1] https://lore.kernel.org/all/[email protected]/

Fixes e9f826b0459f ("soc: qcom: pmic_glink: simplify locking with guard()")
---
 drivers/soc/qcom/pmic_glink.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/pmic_glink.c +1 -1
@@ -238,7 +238,7 @@ static void pmic_glink_pdr_callback(int
 
 static int pmic_glink_rpmsg_probe(struct rpmsg_device *rpdev)
 {
-	struct pmic_glink *pg = __pmic_glink;
+	struct pmic_glink *pg;
 
 	guard(mutex)(&__pmic_glink_lock);
 	pg = __pmic_glink;
author maintainer
#1766 lore raw

PATCH 1736/1756 libbpf: Fix accessing BTF.ext core_relo header

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Tony Ambardar <[email protected]>

commit 0a7c2a84359612e54328aa52030eb202093da6e2 upstream.

Update btf_ext_parse_info() to ensure the core_relo header is present before reading its fields. This avoids a potential buffer read overflow reported by the OSS Fuzz project.

---
 tools/lib/bpf/btf.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/btf.c +2 -2
@@ -3018,8 +3018,6 @@ static int btf_ext_parse_info(struct btf
 		.desc = "line_info",
 	};
 	struct btf_ext_sec_info_param core_relo = {
-		.off = btf_ext->hdr->core_relo_off,
-		.len = btf_ext->hdr->core_relo_len,
 		.min_rec_size = sizeof(struct bpf_core_relo),
 		.ext_info = &btf_ext->core_relo_info,
 		.desc = "core_relo",
@@ -3037,6 +3035,8 @@ static int btf_ext_parse_info(struct btf
 	if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, core_relo_len))
 		return 0; /* skip core relos parsing */
 
+	core_relo.off = btf_ext->hdr->core_relo_off;
+	core_relo.len = btf_ext->hdr->core_relo_len;
 	err = btf_ext_parse_sec_info(btf_ext, &core_relo, is_native);
 	if (err)
 		return err;
author maintainer
#1767 lore raw

PATCH 1737/1756 platform/x86/amd/pmc: fix leak in probe()

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Dan Carpenter <[email protected]>

commit 01db3d1ff43aeedeaf11c8bc9d09493ec00c8f4a upstream.

Call pci_dev_put(rdev) before returning.

Fixes 6ad1b2dc0f2a ("platform/x86/amd/pmc: Use managed APIs for mutex")
---
 drivers/platform/x86/amd/pmc/pmc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/amd/pmc/pmc.c +1 -1
@@ -919,7 +919,7 @@ static int amd_pmc_probe(struct platform
 
 	err = devm_mutex_init(dev->dev, &dev->lock);
 	if (err)
-		return err;
+		goto err_pci_dev_put;
 
 	/* Get num of IP blocks within the SoC */
 	amd_pmc_get_ip_info(dev);
author maintainer
#1768 lore raw

PATCH 1738/1756 perf tools: Fix compilation error on arm64

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Leo Yan <[email protected]>

commit d18c882f85745f3c622e74b93151514b745de2ca upstream.

Since the commit dc6d2bc2d893 ("perf sample: Make user_regs and intr_regs optional"), the building for Arm64 reports error:

arch/arm64/util/unwind-libdw.c: In function ‘libdw__arch_set_initial_registers’:
arch/arm64/util/unwind-libdw.c:11:32: error: initialization of ‘struct regs_dump *’ from incompatible pointer type ‘struct regs_dump **’ [-Werror=incompatible-pointer-types]
11 | struct regs_dump *user_regs = &ui->sample->user_regs;
| ^
cc1: all warnings being treated as errors
make[6]: *** [/home/niayan01/linux/tools/build/Makefile.build:85: arch/arm64/util/unwind-libdw.o] Error 1
make[5]: *** [/home/niayan01/linux/tools/build/Makefile.build:138: util] Error 2
arch/arm64/tests/dwarf-unwind.c: In function ‘test__arch_unwind_sample’:
arch/arm64/tests/dwarf-unwind.c:48:27: error: initialization of ‘struct regs_dump *’ from incompatible pointer type ‘struct regs_dump **’ [-Werror=incompatible-pointer-types]
48 | struct regs_dump *regs = &sample->user_regs;
| ^

To fix the issue, use the helper perf_sample__user_regs() to retrieve the user_regs.

Fixes dc6d2bc2d893 ("perf sample: Make user_regs and intr_regs optional")
---
 tools/perf/arch/arm64/tests/dwarf-unwind.c |    2 +-
 tools/perf/arch/arm64/util/unwind-libdw.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/arch/arm64/tests/dwarf-unwind.c +1 -1
@@ -46,7 +46,7 @@ static int sample_ustack(struct perf_sam
 int test__arch_unwind_sample(struct perf_sample *sample,
 		struct thread *thread)
 {
-	struct regs_dump *regs = &sample->user_regs;
+	struct regs_dump *regs = perf_sample__user_regs(sample);
 	u64 *buf;
 
 	buf = calloc(1, sizeof(u64) * PERF_REGS_MAX);
tools/perf/arch/arm64/util/unwind-libdw.c +1 -1
@@ -8,7 +8,7 @@
 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
 {
 	struct unwind_info *ui = arg;
-	struct regs_dump *user_regs = &ui->sample->user_regs;
+	struct regs_dump *user_regs = perf_sample__user_regs(ui->sample);
 	Dwarf_Word dwarf_regs[PERF_REG_ARM64_MAX], dwarf_pc;
 
 #define REG(r) ({						\
author maintainer
#1769 lore raw

PATCH 1739/1756 perf tools: Fix compile error on sample->user_regs

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Namhyung Kim <[email protected]>

commit 20600b8aab734877740d5292c0cdd5ccb6c7beb7 upstream.

It's recently changed to allocate dynamically but misses to update some arch-dependent codes to use perf_sample__user_regs().

Fixes dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional")
---
 tools/perf/arch/arm/tests/dwarf-unwind.c      |    2 +-
 tools/perf/arch/arm/util/unwind-libdw.c       |    2 +-
 tools/perf/arch/csky/util/unwind-libdw.c      |    2 +-
 tools/perf/arch/loongarch/util/unwind-libdw.c |    2 +-
 tools/perf/arch/powerpc/tests/dwarf-unwind.c  |    2 +-
 tools/perf/arch/powerpc/util/unwind-libdw.c   |    2 +-
 tools/perf/arch/riscv/util/unwind-libdw.c     |    2 +-
 tools/perf/arch/s390/util/unwind-libdw.c      |    2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)
tools/perf/arch/arm/tests/dwarf-unwind.c +1 -1
@@ -46,7 +46,7 @@ static int sample_ustack(struct perf_sam
 int test__arch_unwind_sample(struct perf_sample *sample,
 			     struct thread *thread)
 {
-	struct regs_dump *regs = &sample->user_regs;
+	struct regs_dump *regs = perf_sample__user_regs(sample);
 	u64 *buf;
 
 	buf = calloc(1, sizeof(u64) * PERF_REGS_MAX);
tools/perf/arch/arm/util/unwind-libdw.c +1 -1
@@ -8,7 +8,7 @@
 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
 {
 	struct unwind_info *ui = arg;
-	struct regs_dump *user_regs = &ui->sample->user_regs;
+	struct regs_dump *user_regs = perf_sample__user_regs(ui->sample);
 	Dwarf_Word dwarf_regs[PERF_REG_ARM_MAX];
 
 #define REG(r) ({						\
tools/perf/arch/csky/util/unwind-libdw.c +1 -1
@@ -10,7 +10,7 @@
 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
 {
 	struct unwind_info *ui = arg;
-	struct regs_dump *user_regs = &ui->sample->user_regs;
+	struct regs_dump *user_regs = perf_sample__user_regs(ui->sample);
 	Dwarf_Word dwarf_regs[PERF_REG_CSKY_MAX];
 
 #define REG(r) ({						\
tools/perf/arch/loongarch/util/unwind-libdw.c +1 -1
@@ -10,7 +10,7 @@
 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
 {
 	struct unwind_info *ui = arg;
-	struct regs_dump *user_regs = &ui->sample->user_regs;
+	struct regs_dump *user_regs = perf_sample__user_regs(ui->sample);
 	Dwarf_Word dwarf_regs[PERF_REG_LOONGARCH_MAX];
 
 #define REG(r) ({							\
tools/perf/arch/powerpc/tests/dwarf-unwind.c +1 -1
@@ -46,7 +46,7 @@ static int sample_ustack(struct perf_sam
 int test__arch_unwind_sample(struct perf_sample *sample,
 			     struct thread *thread)
 {
-	struct regs_dump *regs = &sample->user_regs;
+	struct regs_dump *regs = perf_sample__user_regs(sample);
 	u64 *buf;
 
 	buf = calloc(1, sizeof(u64) * PERF_REGS_MAX);
tools/perf/arch/powerpc/util/unwind-libdw.c +1 -1
@@ -16,7 +16,7 @@ static const int special_regs[3][2] = {
 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
 {
 	struct unwind_info *ui = arg;
-	struct regs_dump *user_regs = &ui->sample->user_regs;
+	struct regs_dump *user_regs = perf_sample__user_regs(ui->sample);
 	Dwarf_Word dwarf_regs[32], dwarf_nip;
 	size_t i;
 
tools/perf/arch/riscv/util/unwind-libdw.c +1 -1
@@ -10,7 +10,7 @@
 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
 {
 	struct unwind_info *ui = arg;
-	struct regs_dump *user_regs = &ui->sample->user_regs;
+	struct regs_dump *user_regs = perf_sample__user_regs(ui->sample);
 	Dwarf_Word dwarf_regs[32];
 
 #define REG(r) ({						\
tools/perf/arch/s390/util/unwind-libdw.c +1 -1
@@ -11,7 +11,7 @@
 bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
 {
 	struct unwind_info *ui = arg;
-	struct regs_dump *user_regs = &ui->sample->user_regs;
+	struct regs_dump *user_regs = perf_sample__user_regs(ui->sample);
 	Dwarf_Word dwarf_regs[ARRAY_SIZE(s390_dwarf_regs)];
 
 #define REG(r) ({						\
author maintainer
#1770 lore raw

PATCH 1740/1756 perf libunwind: Fixup conversion perf_sample->user_regs to a pointer

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Arnaldo Carvalho de Melo <[email protected]>

commit 4e82c88a90a99b50f6488defd0d3d85ddc47c068 upstream.

The dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional") misses the changes to a file, resulting in this problem:

  $ make LIBUNWIND=1 -C tools/perf O=/tmp/build/perf-tools-next install-bin
  <SNIP>
    CC      /tmp/build/perf-tools-next/util/unwind-libunwind-local.o
    CC      /tmp/build/perf-tools-next/util/unwind-libunwind.o
  <SNIP>
  util/unwind-libunwind-local.c: In function ‘access_mem’:
  util/unwind-libunwind-local.c:582:56: error: ‘ui->sample->user_regs’ is a pointer; did you mean to use ‘->’?
    582 |         if (__write || !stack || !ui->sample->user_regs.regs) {
        |                                                        ^
        |                                                        ->
  util/unwind-libunwind-local.c:587:38: error: passing argument 2 of ‘perf_reg_value’ from incompatible pointer type [-Wincompatible-pointer-types]
    587 |         ret = perf_reg_value(&start, &ui->sample->user_regs,
        |                                      ^~~~~~~~~~~~~~~~~~~~~~
        |                                      |
        |                                      struct regs_dump **
<SNIP>
  ⬢ [acme@toolbox perf-tools-next]$ git bisect bad
  dc6d2bc2d893a878e7b58578ff01b4738708deb4 is the first bad commit
  commit dc6d2bc2d893a878e7b58578ff01b4738708deb4 (HEAD)
  Author: Ian Rogers <[email protected]>
  Date:   Mon Jan 13 11:43:45 2025 -0800

perf sample: Make user_regs and intr_regs optional

Detected using:

make -C tools/perf build-test

Fixes dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional")
---
 tools/perf/util/unwind-libunwind-local.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tools/perf/util/unwind-libunwind-local.c +6 -6
@@ -579,12 +579,12 @@ static int access_mem(unw_addr_space_t _
 	int ret;
 
 	/* Don't support write, probably not needed. */
-	if (__write || !stack || !ui->sample->user_regs.regs) {
+	if (__write || !stack || !ui->sample->user_regs || !ui->sample->user_regs->regs) {
 		*valp = 0;
 		return 0;
 	}
 
-	ret = perf_reg_value(&start, &ui->sample->user_regs,
+	ret = perf_reg_value(&start, perf_sample__user_regs(ui->sample),
 			     perf_arch_reg_sp(arch));
 	if (ret)
 		return ret;
@@ -628,7 +628,7 @@ static int access_reg(unw_addr_space_t _
 		return 0;
 	}
 
-	if (!ui->sample->user_regs.regs) {
+	if (!ui->sample->user_regs || !ui->sample->user_regs->regs) {
 		*valp = 0;
 		return 0;
 	}
@@ -637,7 +637,7 @@ static int access_reg(unw_addr_space_t _
 	if (id < 0)
 		return -EINVAL;
 
-	ret = perf_reg_value(&val, &ui->sample->user_regs, id);
+	ret = perf_reg_value(&val, perf_sample__user_regs(ui->sample), id);
 	if (ret) {
 		if (!ui->best_effort)
 			pr_err("unwind: can't read reg %d\n", regnum);
@@ -741,7 +741,7 @@ static int get_entries(struct unwind_inf
 	unw_cursor_t c;
 	int ret, i = 0;
 
-	ret = perf_reg_value(&val, &ui->sample->user_regs,
+	ret = perf_reg_value(&val, perf_sample__user_regs(ui->sample),
 			     perf_arch_reg_ip(arch));
 	if (ret)
 		return ret;
@@ -808,7 +808,7 @@ static int _unwind__get_entries(unwind_e
 		.best_effort  = best_effort
 	};
 
-	if (!data->user_regs.regs)
+	if (!data->user_regs || !data->user_regs->regs)
 		return -EINVAL;
 
 	if (max_stack <= 0)
author maintainer
#1771 lore raw

PATCH 1741/1756 nvme-tcp: fix use-after-free of netns by kernel TCP socket.

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Kuniyuki Iwashima <[email protected]>

commit b013b817f32fb8c560b6970e1002e94f1c725923 upstream.

Commit 1be52169c348 ("nvme-tcp: fix selinux denied when calling sock_sendmsg") converted sock_create() in nvme_tcp_alloc_queue() to sock_create_kern().

sock_create_kern() creates a kernel socket, which does not hold a reference to netns. If the code does not manage the netns lifetime properly, use-after-free could happen.

Also, TCP kernel socket with sk_net_refcnt 0 has a socket leak
problem: it remains FIN_WAIT_1 if it misses FIN after close() because tcp_close() stops all timers.

To fix such problems, let's hold netns ref by sk_net_refcnt_upgrade().

We had the same issue in CIFS, SMC, etc, and applied the same solution, see commit ef7134c7fc48 ("smb: client: Fix use-after-free of network namespace.") and commit 9744d2bf1976 ("smc: Fix use-after-free in tcp_write_timer_handler().").

Fixes 1be52169c348 ("nvme-tcp: fix selinux denied when calling sock_sendmsg")
---
 drivers/nvme/host/tcp.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/nvme/host/tcp.c +2 -0
@@ -2048,6 +2048,8 @@ static int nvme_tcp_alloc_queue(struct n
 		ret = PTR_ERR(sock_file);
 		goto err_destroy_mutex;
 	}
+
+	sk_net_refcnt_upgrade(queue->sock->sk);
 	nvme_tcp_reclassify_socket(queue->sock);
 
 	/* Single syn retry */
author maintainer
#1772 lore raw

PATCH 1742/1756 arm64: dts: st: Adjust interrupt-controller for stm32mp23 SoCs

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Christian Bruel <[email protected]>

commit 3a1e1082097b8fa2e5d420de105f4cce804c38b2 upstream.

Use gic-400 compatible and remove address-cells = <1> for aarch64

Fixes e9b03ef21386e ("arm64: dts: st: introduce stm32mp23 SoCs family")
---
 arch/arm64/boot/dts/st/stm32mp231.dtsi |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/boot/dts/st/stm32mp231.dtsi +1 -2
@@ -1201,13 +1201,12 @@
 		};
 
 		intc: interrupt-controller@4ac10000 {
-			compatible = "arm,cortex-a7-gic";
+			compatible = "arm,gic-400";
 			reg = <0x4ac10000 0x1000>,
 			      <0x4ac20000 0x2000>,
 			      <0x4ac40000 0x2000>,
 			      <0x4ac60000 0x2000>;
 			#interrupt-cells = <3>;
-			#address-cells = <1>;
 			interrupt-controller;
 		};
 	};
author maintainer
#1773 lore raw

PATCH 1743/1756 arm64: dts: st: Use 128kB size for aliased GIC400 register access on stm32mp23 SoCs

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Christian Bruel <[email protected]>

commit 2ef5c66cba6171feab05e62e1b22df970b238544 upstream.

Adjust the size of 8kB GIC regions to 128kB so that each 4kB is mapped 16 times over a 64kB region.
The offset is then adjusted in the irq-gic driver.

see commit 12e14066f4835 ("irqchip/GIC: Add workaround for aliased GIC400")

---
 arch/arm64/boot/dts/st/stm32mp231.dtsi |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/st/stm32mp231.dtsi +3 -3
@@ -1203,9 +1203,9 @@
 		intc: interrupt-controller@4ac10000 {
 			compatible = "arm,gic-400";
 			reg = <0x4ac10000 0x1000>,
-			      <0x4ac20000 0x2000>,
-			      <0x4ac40000 0x2000>,
-			      <0x4ac60000 0x2000>;
+			      <0x4ac20000 0x20000>,
+			      <0x4ac40000 0x20000>,
+			      <0x4ac60000 0x20000>;
 			#interrupt-cells = <3>;
 			interrupt-controller;
 		};
author maintainer
#1774 lore raw

PATCH 1744/1756 apparmor: fix: accept2 being specifie even when permission table is presnt

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: John Johansen <[email protected]>

commit 4d9d1a08b796efd54f1e29b42bd95879109fe448 upstream.

The transition to the perms32 permission table dropped the need for the accept2 table as permissions. However accept2 can be used for flags and may be present even when the perms32 table is present. So instead of checking on version, check whether the table is present.

Fixes 2e12c5f06017 ("apparmor: add additional flags to extended permission.")
---
 security/apparmor/policy_unpack.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
security/apparmor/policy_unpack.c +2 -1
@@ -799,7 +799,8 @@ static int unpack_pdb(struct aa_ext *e,
 		}
 	}
 
-	if (pdb->perms && version <= 2) {
+	/* accept2 is in some cases being allocated, even with perms */
+	if (pdb->perms && !pdb->dfa->tables[YYTD_ID_ACCEPT2]) {
 		/* add dfa flags table missing in v2 */
 		u32 noents = pdb->dfa->tables[YYTD_ID_ACCEPT]->td_lolen;
 		u16 tdflags = pdb->dfa->tables[YYTD_ID_ACCEPT]->td_flags;
author maintainer
#1775 lore raw

PATCH 1745/1756 apparmor: mitigate parser generating large xtables

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: John Johansen <[email protected]>

commit aff426f35966e6e77ecfe065984344a7d834eaa9 upstream.

Some versions of the parser are generating an xtable transition per state in the state machine, even when the state machine isn't using the transition table.

The parser bug is triggered by
commit 2e12c5f06017 ("apparmor: add additional flags to extended permission.")

In addition to fixing this in userspace, mitigate this in the kernel as part of the policy verification checks by detecting this situation and adjusting to what is actually used, or if not used at all freeing it, so we are not wasting unneeded memory on policy.

Fixes 2e12c5f06017 ("apparmor: add additional flags to extended permission.")
---
 security/apparmor/include/lib.h   |    1 +
 security/apparmor/lib.c           |   23 +++++++++++++++++++++++
 security/apparmor/policy_unpack.c |   27 +++++++++++++++++++++------
 3 files changed, 45 insertions(+), 6 deletions(-)
security/apparmor/include/lib.h +1 -0
@@ -123,6 +123,7 @@ struct aa_str_table {
 };
 
 void aa_free_str_table(struct aa_str_table *table);
+bool aa_resize_str_table(struct aa_str_table *t, int newsize, gfp_t gfp);
 
 struct counted_str {
 	struct kref count;
security/apparmor/lib.c +23 -0
@@ -138,6 +138,29 @@ const char *aa_splitn_fqname(const char
 	return name;
 }
 
+bool aa_resize_str_table(struct aa_str_table *t, int newsize, gfp_t gfp)
+{
+	char **n;
+	int i;
+
+	if (t->size == newsize)
+		return true;
+	n = kcalloc(newsize, sizeof(*n), gfp);
+	if (!n)
+		return false;
+	for (i = 0; i < min(t->size, newsize); i++)
+		n[i] = t->table[i];
+	for (; i < t->size; i++)
+		kfree_sensitive(t->table[i]);
+	if (newsize > t->size)
+		memset(&n[t->size], 0, (newsize-t->size)*sizeof(*n));
+	kfree_sensitive(t->table);
+	t->table = n;
+	t->size = newsize;
+
+	return true;
+}
+
 /**
  * aa_info_message - log a none profile related status message
  * @str: message to log
security/apparmor/policy_unpack.c +21 -6
@@ -832,8 +832,12 @@ static int unpack_pdb(struct aa_ext *e,
 	if (!pdb->dfa && pdb->trans.table)
 		aa_free_str_table(&pdb->trans);
 
-	/* TODO: move compat mapping here, requires dfa merging first */
-	/* TODO: move verify here, it has to be done after compat mappings */
+	/* TODO:
+	 * - move compat mapping here, requires dfa merging first
+	 * - move verify here, it has to be done after compat mappings
+	 * - move free of unneeded trans table here, has to be done
+	 *   after perm mapping.
+	 */
 out:
 	*policy = pdb;
 	return 0;
@@ -1272,21 +1276,32 @@ static bool verify_perm(struct aa_perms
 static bool verify_perms(struct aa_policydb *pdb)
 {
 	int i;
+	int xidx, xmax = -1;
 
 	for (i = 0; i < pdb->size; i++) {
 		if (!verify_perm(&pdb->perms[i]))
 			return false;
 		/* verify indexes into str table */
-		if ((pdb->perms[i].xindex & AA_X_TYPE_MASK) == AA_X_TABLE &&
-		    (pdb->perms[i].xindex & AA_X_INDEX_MASK) >= pdb->trans.size)
-			return false;
+		if ((pdb->perms[i].xindex & AA_X_TYPE_MASK) == AA_X_TABLE) {
+			xidx = pdb->perms[i].xindex & AA_X_INDEX_MASK;
+			if (xidx >= pdb->trans.size)
+				return false;
+			if (xmax < xidx)
+				xmax = xidx;
+		}
 		if (pdb->perms[i].tag && pdb->perms[i].tag >= pdb->trans.size)
 			return false;
 		if (pdb->perms[i].label &&
 		    pdb->perms[i].label >= pdb->trans.size)
 			return false;
 	}
-
+	/* deal with incorrectly constructed string tables */
+	if (xmax == -1) {
+		aa_free_str_table(&pdb->trans);
+	} else if (pdb->trans.size > xmax + 1) {
+		if (!aa_resize_str_table(&pdb->trans, xmax + 1, GFP_KERNEL))
+			return false;
+	}
 	return true;
 }
 
author maintainer
#1776 lore raw

PATCH 1746/1756 selftests/bpf: include limits.h needed for PATH_MAX directly

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eduard Zingerman <[email protected]>

commit cd7312a78f36e981939abe1cd1f21d355e083dfe upstream.

Constant PATH_MAX is used in function unpriv_helpers.c:open_config(). This constant is provided by include file <limits.h>.
The dependency was added by commit [1], which does not include <limits.h> directly, relying instead on <limits.h> being included from zlib.h -> zconf.h.
As it turns out, this is not the case for all systems, e.g. on Fedora 41 zlib 1.3.1 is used, and there <limits.h> is not included from zconf.h. Hence, there is a compilation error on Fedora 41.

[1] commit fc2915bb8bfc ("selftests/bpf: More precise cpu_mitigations state detection")

Fixes fc2915bb8bfc ("selftests/bpf: More precise cpu_mitigations state detection")
---
 tools/testing/selftests/bpf/unpriv_helpers.c |    1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/unpriv_helpers.c +1 -0
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
 #include <errno.h>
+#include <limits.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
author maintainer
#1777 lore raw

PATCH 1747/1756 drm/amdgpu: Fix vbios build number parsing logic

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Lijo Lazar <[email protected]>

commit b29c22b8dafd951664a491bf629e615d81513197 upstream.

It's not necessary that the build string and atom header section has a difference of 32 bytes. Use the remaining bytes in the section as copy limit.

Fixes d6fa80266178 ("drm/amdgpu: Add vbios build number interface")
---
 drivers/gpu/drm/amd/amdgpu/atom.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/atom.c +4 -3
@@ -1526,7 +1526,7 @@ static void atom_get_vbios_build(struct
 {
 	unsigned char *atom_rom_hdr;
 	unsigned char *str;
-	uint16_t base;
+	uint16_t base, len;
 
 	base = CU16(ATOM_ROM_TABLE_PTR);
 	atom_rom_hdr = CSTR(base);
@@ -1545,8 +1545,9 @@ static void atom_get_vbios_build(struct
 	while (str < atom_rom_hdr && *str++)
 		;
 
-	if ((str + STRLEN_NORMAL) < atom_rom_hdr)
-		strscpy(ctx->build_num, str, STRLEN_NORMAL);
+	len = min(atom_rom_hdr - str, STRLEN_NORMAL);
+	if (len)
+		strscpy(ctx->build_num, str, len);
 }
 
 static inline void atom_print_vbios_info(struct atom_context *ctx)
author maintainer
#1778 lore raw

PATCH 1748/1756 smb: align durable reconnect v2 context to 8 byte boundary

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Bharath SM <[email protected]>

commit 05f5e355cf783b30bd6eb3dec17ed1a8b3cfa95c upstream.

Add a 4-byte Pad to create_durable_handle_reconnect_v2 so the DH2C create context is 8 byte aligned.
This avoids malformed CREATE contexts on reconnect. Recent change removed this Padding, adding it back.

Fixes 81a45de432c6 ("smb: move create_durable_handle_reconnect_v2 to common/smb2pdu.h")
---
 fs/smb/common/smb2pdu.h |    1 +
 1 file changed, 1 insertion(+)
fs/smb/common/smb2pdu.h +1 -0
@@ -1320,6 +1320,7 @@ struct create_durable_handle_reconnect_v
 	struct create_context_hdr ccontext;
 	__u8   Name[8];
 	struct durable_reconnect_context_v2 dcontext;
+	__u8 Pad[4];
 } __packed;
 
 /* See MS-SMB2 2.2.14.2.12 */
author maintainer
#1779 lore raw

PATCH 1749/1756 remoteproc: imx_dsp_rproc: Only reset carveout memory at RPROC_OFFLINE state

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Shengjiu Wang <[email protected]>

commit b490ddf27be28e64a39c08ae643d7b22561beaf6 upstream.

Do not reset memory at suspend and resume stage, because some memory is used to save the software state for resume, if it is cleared, the resume operation can fail.

Fixes c4c432dfb00f ("remoteproc: imx_dsp_rproc: Add support of recovery and coredump process")
---
 drivers/remoteproc/imx_dsp_rproc.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/remoteproc/imx_dsp_rproc.c +5 -3
@@ -935,9 +935,11 @@ static int imx_dsp_rproc_load(struct rpr
 	 * Clear buffers after pm rumtime for internal ocram is not
 	 * accessible if power and clock are not enabled.
 	 */
-	list_for_each_entry(carveout, &rproc->carveouts, node) {
-		if (carveout->va)
-			memset(carveout->va, 0, carveout->len);
+	if (rproc->state == RPROC_OFFLINE) {
+		list_for_each_entry(carveout, &rproc->carveouts, node) {
+			if (carveout->va)
+				memset(carveout->va, 0, carveout->len);
+		}
 	}
 
 	ret = imx_dsp_rproc_elf_load_segments(rproc, fw);
author maintainer
#1780 lore raw

PATCH 1750/1756 apparmor: fail policy unpack on accept2 allocation failure

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Zygmunt Krynicki <[email protected]>

commit 45cf568241048e560a81aa2053f06a62069f5640 upstream.

unpack_pdb() may need to allocate a missing ACCEPT2 table for older policy data. If that allocation failed, it set an error message but jumped to the success path, returning a policydb with the required table missing.

Return -ENOMEM through the normal failure path when the ACCEPT2 allocation fails. Remove the now-unused out label.

Fixes 2e12c5f06017 ("apparmor: add additional flags to extended permission.")
---
 security/apparmor/policy_unpack.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/apparmor/policy_unpack.c +2 -2
@@ -814,7 +814,8 @@ static int unpack_pdb(struct aa_ext *e,
 		pdb->dfa->tables[YYTD_ID_ACCEPT2] = kvzalloc(tsize, GFP_KERNEL);
 		if (!pdb->dfa->tables[YYTD_ID_ACCEPT2]) {
 			*info = "failed to alloc dfa flags table";
-			goto out;
+			error = -ENOMEM;
+			goto fail;
 		}
 		pdb->dfa->tables[YYTD_ID_ACCEPT2]->td_lolen = noents;
 		pdb->dfa->tables[YYTD_ID_ACCEPT2]->td_flags = tdflags;
@@ -838,7 +839,6 @@ static int unpack_pdb(struct aa_ext *e,
 	 * - move free of unneeded trans table here, has to be done
 	 *   after perm mapping.
 	 */
-out:
 	*policy = pdb;
 	return 0;
 
author maintainer
#1781 lore raw

PATCH 1751/1756 apparmor: fix NULL pointer dereference in unpack_pdb

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Georgia Garcia <[email protected]>

commit 7681ca43d2b1c776e62fe77e3167835fb1ab8319 upstream.

pdb->dfa could be NULL if unpack_dfa fails, causing a NULL pointer dereference.

Fixes 2e12c5f06017 ("apparmor: add additional flags to extended permission.")
---
 security/apparmor/policy_unpack.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/apparmor/policy_unpack.c +1 -1
@@ -800,7 +800,7 @@ static int unpack_pdb(struct aa_ext *e,
 	}
 
 	/* accept2 is in some cases being allocated, even with perms */
-	if (pdb->perms && !pdb->dfa->tables[YYTD_ID_ACCEPT2]) {
+	if (pdb->dfa && pdb->perms && !pdb->dfa->tables[YYTD_ID_ACCEPT2]) {
 		/* add dfa flags table missing in v2 */
 		u32 noents = pdb->dfa->tables[YYTD_ID_ACCEPT]->td_lolen;
 		u16 tdflags = pdb->dfa->tables[YYTD_ID_ACCEPT]->td_flags;
author maintainer
#1782 lore raw

PATCH 1752/1756 fs/ntfs3: reject FS_IOC_SETFSLABEL on readonly mounts

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Baolin Liu <[email protected]>

commit 5d3e03b70d05162ca49830efcd8b1cd2746a86a3 upstream.

FS_IOC_SETFSLABEL does not check for readonly mounts and can report success without persisting the label change.

Return -EROFS on readonly mounts.

Fixes 21dc07ac9c25 ("ntfs3: add FS_IOC_SETFSLABEL ioctl")
---
 fs/ntfs3/file.c |    3 +++
 1 file changed, 3 insertions(+)
fs/ntfs3/file.c +3 -0
@@ -65,6 +65,9 @@ static int ntfs_ioctl_set_volume_label(s
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
+	if (sb_rdonly(sbi->sb))
+		return -EROFS;
+
 	if (copy_from_user(user, buf, FSLABEL_MAX))
 		return -EFAULT;
 
author maintainer
#1783 lore raw

PATCH 1753/1756 ceph: fix leaked inode reference on writeback abort at umount

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Matthew Brown <[email protected]>

commit c25aee9c630fb86f98d79eccb75765067079b972 upstream.

ceph_dirty_folio() takes a wrbuffer claim on each newly dirtied folio: it bumps i_wrbuffer_ref (taking an ihold() on the 0->1 transition) and attaches the snap_context to folio->private. That claim is released only by ceph_put_wrbuffer_cap_refs(), which for a submitted write runs from writepages_finish().

In ceph_submit_write(), if ceph_inc_osd_stopping_blocker() fails -- which happens during umount -- the request is aborted before submission: the already-collected folios are only redirtied and unlocked, so writepages_finish() never runs and the claim is leaked. redirty_page_for_writepage() -> folio_redirty_for_writepage() -> filemap_dirty_folio() sets PG_dirty directly and does not go through ->dirty_folio, so ceph_dirty_folio() is not re-entered to rebalance it. Because every subsequent writeback also fails the osd_stopping_blocker, i_wrbuffer_ref never returns to 0, the ihold() is never dropped, and the inode cannot be evicted:

VFS: Busy inodes after unmount of ceph
kernel BUG at fs/super.c:650!

Release the orphaned claim in the abort path before redirtying, via ceph_undo_wrbuffer_claim(): detach the snap_context, drop the wrbuffer reference (letting i_wrbuffer_ref reach 0 and iput() the inode), and drop the snap_context reference -- i.e. do what writepages_finish() would have done for these never-submitted folios.

Only the locked_pages entries are undone; folios still in the fbatch were never dirty-cleared by this call (folio_clear_dirty_for_io() is the ownership-transfer point, and a successful move NULLs the fbatch slot), so they hold no claim this call owns.

Fixes fd7449d937e7 ("ceph: fix generic/421 test failure")
---
 fs/ceph/addr.c |   11 +++++++++++
 1 file changed, 11 insertions(+)
fs/ceph/addr.c +11 -0
@@ -1431,6 +1431,16 @@ void ceph_shift_unused_folios_left(struc
 	fbatch->nr = n;
 }
 
+static void ceph_undo_wrbuffer_claim(struct inode *inode, struct folio *folio)
+{
+	struct ceph_snap_context *snapc = folio_detach_private(folio);
+
+	if (!snapc)
+		return;
+	ceph_put_wrbuffer_cap_refs(ceph_inode(inode), 1, snapc);
+	ceph_put_snap_context(snapc);
+}
+
 static
 int ceph_submit_write(struct address_space *mapping,
 			struct writeback_control *wbc,
@@ -1488,6 +1498,7 @@ new_request:
 			    CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
 				fsc->write_congested = false;
 
+			ceph_undo_wrbuffer_claim(inode, page_folio(page));
 			redirty_page_for_writepage(wbc, page);
 			unlock_page(page);
 			put_page(page);
author maintainer
#1784 lore raw

PATCH 1754/1756 net: bcmgenet: stop Tx NAPI before disabling the queues

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Nicolai Buchwitz <[email protected]>

commit 7e87508b5c4d81210d0a736ed01962e52f5c4c56 upstream.

bcmgenet_netif_stop() and the Wake-on-LAN branch of bcmgenet_suspend() both disable the Tx queues first and stop Tx NAPI several steps later. A completion in flight calls netif_tx_wake_queue() in between, and nothing stops the queue again, so a transmit can reach the rings after they have been freed.

Close is safe because dev_deactivate_many() stops the qdisc first. bcmgenet_suspend() does not, so stop Tx NAPI before the queues on both paths.

KASAN on a Raspberry Pi CM4, driven from an MTU change because suspend freezes user space before the callback runs:

  BUG: KASAN: use-after-free in bcmgenet_xmit+0x17f8/0x2258
  Write of size 8 at addr ffffff8055844a68 by task ksoftirqd/0/14
   bcmgenet_xmit+0x17f8/0x2258
   dev_hard_start_xmit+0x13c/0x588
   sch_direct_xmit+0x108/0x340
   __dev_queue_xmit+0x1190/0x3848
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +4 -2
@@ -3351,6 +3351,8 @@ static void bcmgenet_netif_stop(struct n
 {
 	struct bcmgenet_priv *priv = netdev_priv(dev);
 
+	/* Stop completion polling before it can wake a stopped queue */
+	bcmgenet_disable_tx_napi(priv);
 	netif_tx_disable(dev);
 
 	/* Disable MAC receive */
@@ -3365,7 +3367,6 @@ static void bcmgenet_netif_stop(struct n
 	/* Disable MAC transmit. TX DMA disabled must be done before this */
 	umac_enable_set(priv, CMD_TX_EN, false);
 
-	bcmgenet_disable_tx_napi(priv);
 	bcmgenet_disable_rx_napi(priv);
 	bcmgenet_intr_disable(priv);
 
@@ -4297,6 +4298,8 @@ static int bcmgenet_suspend(struct devic
 	netif_device_detach(dev);
 
 	if (device_may_wakeup(d) && priv->wolopts) {
+		/* Stop completion polling before it can wake a stopped queue */
+		bcmgenet_disable_tx_napi(priv);
 		netif_tx_disable(dev);
 
 		/* Suspend non-wake Rx data flows */
@@ -4306,7 +4309,6 @@ static int bcmgenet_suspend(struct devic
 			netdev_warn(priv->dev,
 				    "Timed out while disabling TX DMA\n");
 
-		bcmgenet_disable_tx_napi(priv);
 		bcmgenet_disable_rx_napi(priv);
 		disable_irq(priv->irq1);
 		bcmgenet_tx_reclaim_all(dev);
author maintainer
#1785 lore raw

PATCH 1755/1756 net: bcmgenet: if UMAC was suspended in SW_RESET, restore it to SW_RESET

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Justin Chen <[email protected]>

commit 5857e5a196b069766a39ceb754736326a43bc6bc upstream.

When the revised suspend/resume sequence was introduced this led to an edge case where the TX is left disabled in the following sequence.

1. phy link is down, so UMAC is held in reset and then network interface is WoL enabled
2. Enter suspend, bcmgenet_wol_power_down_cfg() enables UMAC_RX since MAC is in SW_RESET
4. Enter resume, UMAC_RX is left enabled. Since we only enable UMAC_TX and UMAC_RX in SW_RESET. The UMAC_TX is never enabled again on link up.

The issue was hit in production and I verified the sequence keeps the TX disabled in my standalone test. I tested on an internal development board with bcm77122, but should be reproducible on any genet HW that supports power management.

---
 drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c |   11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c +11 -0
@@ -253,6 +253,17 @@ int bcmgenet_wol_power_up_cfg(struct bcm
 	reg = bcmgenet_umac_readl(priv, UMAC_CMD);
 	reg &= ~CMD_CRC_FWD;
 	bcmgenet_umac_writel(priv, reg, UMAC_CMD);
+
+	/*
+	 * Mirror wol_power_down_cfg(). If only UMAC_RX
+	 * is enabled, then we must place the UMAC back
+	 * into SW_RESET.
+	 */
+	reg = bcmgenet_umac_readl(priv, UMAC_CMD);
+	if ((reg & CMD_RX_EN) && !(reg & CMD_TX_EN)) {
+		reg |= CMD_SW_RESET;
+		bcmgenet_umac_writel(priv, reg, UMAC_CMD);
+	}
 	spin_unlock_bh(&priv->reg_lock);
 
 	/* Resume link status tracking */
author maintainer
#1786 lore raw

PATCH 1756/1756 apparmor: avoid potential double free when remapping DFA tables

In reply to Greg Kroah-Hartman

6.12-stable review patch. If anyone has any objections, please let me know.

------------------

From: Li RongQing <[email protected]>

commit 7ccd884a5e5386f4c7d98625113f4924f70286b4 upstream.

When unpacking a DFA, aa_dfa_unpack() stores a table in dfa->tables before attempting to remap a 16-bit table to 32-bit.

However, remap_data16_to_data32() frees the original table when allocation of the new table fails. This leaves the corresponding dfa->tables entry pointing to freed memory. If the unpacking then fails, dfa_free() attempts to free the same table again.

Only publish the table to dfa->tables after any required remapping has completed successfully, so that dfa->tables never contains a pointer to a table that has already been freed.

Fixes 9208c05f9fdf ("apparmor: add support for 2^24 states to the dfa state machine.")
---
 security/apparmor/match.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
security/apparmor/match.c +1 -2
@@ -401,7 +401,6 @@ struct aa_dfa *aa_dfa_unpack(void *blob,
 		/* check for duplicate table entry */
 		if (dfa->tables[table->td_id])
 			goto fail;
-		dfa->tables[table->td_id] = table;
 		data += table_size(table->td_lolen, table->td_flags);
 		size -= table_size(table->td_lolen, table->td_flags);
 
@@ -418,9 +417,9 @@ struct aa_dfa *aa_dfa_unpack(void *blob,
 				if (!table)
 					goto fail;
 			}
-			dfa->tables[table->td_id] = table;
 			break;
 		}
+		dfa->tables[table->td_id] = table;
 		table = NULL;
 	}
 	error = verify_table_headers(dfa->tables, flags);
Tested-by on the v1 series
#1787 lore raw
In reply to Greg Kroah-Hartman

Am 18.11.2026 um 15:35 schrieb Greg Kroah-Hartman:

Quoted 4 lines

This is the start of the stable review cycle for the 6.12.119 release. There are 1756 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Builds, boots and works on my 2-socket Ivy Bridge Xeon E5-2697v2 server. No dmesg oddities or regressions found.

Beste Grüße,
Peter Schneider

Signature · 8 lines
Climb the mountain not to plant your flag, but to embrace the challenge,
enjoy the air and behold the view. Climb it so you can see the world,
not so the world can see you.                    -- David McCullough Jr.

OpenPGP:  0xA3828BD796CCE11A8CADE8866E3A92C92C3FF244
Download: https://www.peters-netzplatz.de/download/pschneider1968_pub.asc
https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
#1788 lore raw
In reply to Greg Kroah-Hartman

Greg Kroah-Hartman wrote on Wed, Nov 18, 2026 at 03:35:27PM +0100:

Quoted 9 lines

Adam Ford <[email protected]>
phy: freescale: fsl-samsung-hdmi: Fix 64-by-32 division cocci warnings

Aristo Chen <[email protected]>
phy: freescale: fsl-samsung-hdmi: initialize default rate

Pei Xiao <[email protected]>
phy: freescale: fsl-samsung-hdmi: Use helper function devm_clk_get_enabled()

Quoted 8 lines

Adam Ford <[email protected]>
phy: freescale: fsl-samsung-hdmi: Support dynamic integer

Adam Ford <[email protected]>
phy: freescale: fsl-samsung-hdmi: Simplify REG21_PMS_S_MASK lookup

Adam Ford <[email protected]>
phy: freescale: fsl-samsung-hdmi: Replace register defines with macro

I'm getting a boot failure around one of these on i.MX8MP:

2026-11-19 09:01:29.454251 [    0.587255] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
2026-11-19 09:01:29.459125 [    0.596076] Mem abort info:
2026-11-19 09:01:29.460122 [    0.598879]   ESR = 0x0000000096000004
2026-11-19 09:01:29.465853 [    0.602641]   EC = 0x25: DABT (current EL), IL = 32 bits
2026-11-19 09:01:29.470643 [    0.607973]   SET = 0, FnV = 0
2026-11-19 09:01:29.471565 [    0.611036]   EA = 0, S1PTW = 0
2026-11-19 09:01:29.476941 [    0.614190]   FSC = 0x04: level 0 translation fault
2026-11-19 09:01:29.481849 [    0.619077] Data abort info:
2026-11-19 09:01:29.487329 [    0.621961]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
2026-11-19 09:01:29.492669 [    0.627455]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
2026-11-19 09:01:29.498347 [    0.632518]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
2026-11-19 09:01:29.504076 [    0.637842] [0000000000000000] user address but active_mm is swapper
2026-11-19 09:01:29.509800 [    0.644207] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
2026-11-19 09:01:29.510695 [    0.650479] Modules linked in:
2026-11-19 09:01:29.521321 [    0.653542] CPU: 2 UID: 0 PID: 12 Comm: kworker/u16:0 Not tainted 6.12.119-rc1-at0-g8f03b6a4b095 #43
2026-11-19 09:01:29.527214 [    0.662683] Hardware name: Atmark-Techno Armadillo-IoT Gateway G4 Board (DT)
2026-11-19 09:01:29.533048 [    0.669734] Workqueue: events_unbound deferred_probe_work_func
2026-11-19 09:01:29.542857 [    0.675584] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
2026-11-19 09:01:29.544070 [    0.682548] pc : phy_clk_recalc_rate+0x4/0xc
2026-11-19 09:01:29.549398 [    0.686828] lr : __clk_register+0x4f0/0x8e0
2026-11-19 09:01:29.554271 [    0.691021] sp : ffff8000800bb9e0
2026-11-19 09:01:29.560182 [    0.694336] x29: ffff8000800bb9e0 x28: ffffa1893c634720 x27: ffff6d82c32ac080
2026-11-19 09:01:29.566395 [    0.701486] x26: 0000000000000000 x25: ffff6d82c32ac080 x24: 0000000000000001
2026-11-19 09:01:29.576245 [    0.708635] x23: ffff8000800bba88 x22: ffff6d82c32a16a0 x21: 0000000000000000
2026-11-19 09:01:29.582449 [    0.715784] x20: ffff6d82c20f8100 x19: ffff6d82c32a3800 x18: 0000000000000fdf
2026-11-19 09:01:29.588353 [    0.722932] x17: 0000000000000cf0 x16: 00000000000003fa x15: ffff6d82c214af10
2026-11-19 09:01:29.594281 [    0.730081] x14: 000000000000014d x13: ffff6d82c214af00 x12: 0000000000000000
2026-11-19 09:01:29.604441 [    0.737232] x11: 00000000000000c0 x10: 0000000000000000 x9 : 0000000000000000
2026-11-19 09:01:29.610325 [    0.744381] x8 : 0101010101010101 x7 : 0000000000000000 x6 : 8080808080808080
2026-11-19 09:01:29.616546 [    0.751528] x5 : ffff6d82c32ac080 x4 : 0000000000000000 x3 : ffff6d82c200a700
2026-11-19 09:01:29.622413 [    0.758677] x2 : ffffa1893b813740 x1 : 00000000016e3600 x0 : 0000000000000000
2026-11-19 09:01:29.627125 [    0.765829] Call trace:
2026-11-19 09:01:29.632409 [    0.768277]  phy_clk_recalc_rate+0x4/0xc
2026-11-19 09:01:29.633534 [    0.772208]  devm_clk_register+0x5c/0xbc
2026-11-19 09:01:29.638814 [    0.776137]  fsl_samsung_hdmi_phy_probe+0x1dc/0x310
2026-11-19 09:01:29.643768 [    0.781024]  platform_probe+0x68/0xdc
2026-11-19 09:01:29.644748 [    0.784693]  really_probe+0xbc/0x2bc
2026-11-19 09:01:29.650181 [    0.788278]  __driver_probe_device+0x80/0x14c
2026-11-19 09:01:29.655274 [    0.792643]  driver_probe_device+0x40/0x130
2026-11-19 09:01:29.660501 [    0.796831]  __device_attach_driver+0xb8/0x140
2026-11-19 09:01:29.665772 [    0.801282]  bus_for_each_drv+0x88/0xe8
2026-11-19 09:01:29.666809 [    0.805125]  __device_attach+0x9c/0x19c
2026-11-19 09:01:29.671945 [    0.808966]  device_initial_probe+0x54/0x74
2026-11-19 09:01:29.677003 [    0.813155]  __bus_probe_device+0x34/0xa0
2026-11-19 09:01:29.678308 [    0.817171]  bus_probe_device_deferred+0x2c/0x78
2026-11-19 09:01:29.683731 [    0.821795]  deferred_probe_work_func+0x7c/0xb4
2026-11-19 09:01:29.688826 [    0.826335]  process_one_work+0x164/0x2bc
2026-11-19 09:01:29.693854 [    0.830355]  worker_thread+0x180/0x2f4
2026-11-19 09:01:29.694736 [    0.834109]  kthread+0x110/0x114
2026-11-19 09:01:29.699938 [    0.837345]  ret_from_fork+0x10/0x20
2026-11-19 09:01:29.705576 [    0.840932] Code: d503201f d503201f d503201f f9400c00 (b9400000) 
2026-11-19 09:01:29.709069 [    0.847029] ---[ end trace 0000000000000000 ]---

I need to check further where the problem is exactly, will reply to this mail again in a couple of hours as I'm not sure I can recover the board remotely to check right now

Signature · 1 line
Dominique
#1789 lore raw

Dominique Martinet wrote on Thu, Nov 19, 2026 at 09:51:52AM +0900:

Quoted 74 lines

Greg Kroah-Hartman wrote on Wed, Nov 18, 2026 at 03:35:27PM +0100:

Quoted 9 lines

Adam Ford <[email protected]>
phy: freescale: fsl-samsung-hdmi: Fix 64-by-32 division cocci warnings

Aristo Chen <[email protected]>
phy: freescale: fsl-samsung-hdmi: initialize default rate

Pei Xiao <[email protected]>
phy: freescale: fsl-samsung-hdmi: Use helper function devm_clk_get_enabled()

Quoted 8 lines

Adam Ford <[email protected]>
phy: freescale: fsl-samsung-hdmi: Support dynamic integer

Adam Ford <[email protected]>
phy: freescale: fsl-samsung-hdmi: Simplify REG21_PMS_S_MASK lookup

Adam Ford <[email protected]>
phy: freescale: fsl-samsung-hdmi: Replace register defines with macro

I'm getting a boot failure around one of these on i.MX8MP:

2026-11-19 09:01:29.454251 [    0.587255] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
2026-11-19 09:01:29.459125 [    0.596076] Mem abort info:
2026-11-19 09:01:29.460122 [    0.598879]   ESR = 0x0000000096000004
2026-11-19 09:01:29.465853 [    0.602641]   EC = 0x25: DABT (current EL), IL = 32 bits
2026-11-19 09:01:29.470643 [    0.607973]   SET = 0, FnV = 0
2026-11-19 09:01:29.471565 [    0.611036]   EA = 0, S1PTW = 0
2026-11-19 09:01:29.476941 [    0.614190]   FSC = 0x04: level 0 translation fault
2026-11-19 09:01:29.481849 [    0.619077] Data abort info:
2026-11-19 09:01:29.487329 [    0.621961]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
2026-11-19 09:01:29.492669 [    0.627455]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
2026-11-19 09:01:29.498347 [    0.632518]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
2026-11-19 09:01:29.504076 [    0.637842] [0000000000000000] user address but active_mm is swapper
2026-11-19 09:01:29.509800 [    0.644207] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
2026-11-19 09:01:29.510695 [    0.650479] Modules linked in:
2026-11-19 09:01:29.521321 [    0.653542] CPU: 2 UID: 0 PID: 12 Comm: kworker/u16:0 Not tainted 6.12.119-rc1-at0-g8f03b6a4b095 #43
2026-11-19 09:01:29.527214 [    0.662683] Hardware name: Atmark-Techno Armadillo-IoT Gateway G4 Board (DT)
2026-11-19 09:01:29.533048 [    0.669734] Workqueue: events_unbound deferred_probe_work_func
2026-11-19 09:01:29.542857 [    0.675584] pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
2026-11-19 09:01:29.544070 [    0.682548] pc : phy_clk_recalc_rate+0x4/0xc
2026-11-19 09:01:29.549398 [    0.686828] lr : __clk_register+0x4f0/0x8e0
2026-11-19 09:01:29.554271 [    0.691021] sp : ffff8000800bb9e0
2026-11-19 09:01:29.560182 [    0.694336] x29: ffff8000800bb9e0 x28: ffffa1893c634720 x27: ffff6d82c32ac080
2026-11-19 09:01:29.566395 [    0.701486] x26: 0000000000000000 x25: ffff6d82c32ac080 x24: 0000000000000001
2026-11-19 09:01:29.576245 [    0.708635] x23: ffff8000800bba88 x22: ffff6d82c32a16a0 x21: 0000000000000000
2026-11-19 09:01:29.582449 [    0.715784] x20: ffff6d82c20f8100 x19: ffff6d82c32a3800 x18: 0000000000000fdf
2026-11-19 09:01:29.588353 [    0.722932] x17: 0000000000000cf0 x16: 00000000000003fa x15: ffff6d82c214af10
2026-11-19 09:01:29.594281 [    0.730081] x14: 000000000000014d x13: ffff6d82c214af00 x12: 0000000000000000
2026-11-19 09:01:29.604441 [    0.737232] x11: 00000000000000c0 x10: 0000000000000000 x9 : 0000000000000000
2026-11-19 09:01:29.610325 [    0.744381] x8 : 0101010101010101 x7 : 0000000000000000 x6 : 8080808080808080
2026-11-19 09:01:29.616546 [    0.751528] x5 : ffff6d82c32ac080 x4 : 0000000000000000 x3 : ffff6d82c200a700
2026-11-19 09:01:29.622413 [    0.758677] x2 : ffffa1893b813740 x1 : 00000000016e3600 x0 : 0000000000000000
2026-11-19 09:01:29.627125 [    0.765829] Call trace:
2026-11-19 09:01:29.632409 [    0.768277]  phy_clk_recalc_rate+0x4/0xc
2026-11-19 09:01:29.633534 [    0.772208]  devm_clk_register+0x5c/0xbc
2026-11-19 09:01:29.638814 [    0.776137]  fsl_samsung_hdmi_phy_probe+0x1dc/0x310
2026-11-19 09:01:29.643768 [    0.781024]  platform_probe+0x68/0xdc
2026-11-19 09:01:29.644748 [    0.784693]  really_probe+0xbc/0x2bc
2026-11-19 09:01:29.650181 [    0.788278]  __driver_probe_device+0x80/0x14c
2026-11-19 09:01:29.655274 [    0.792643]  driver_probe_device+0x40/0x130
2026-11-19 09:01:29.660501 [    0.796831]  __device_attach_driver+0xb8/0x140
2026-11-19 09:01:29.665772 [    0.801282]  bus_for_each_drv+0x88/0xe8
2026-11-19 09:01:29.666809 [    0.805125]  __device_attach+0x9c/0x19c
2026-11-19 09:01:29.671945 [    0.808966]  device_initial_probe+0x54/0x74
2026-11-19 09:01:29.677003 [    0.813155]  __bus_probe_device+0x34/0xa0
2026-11-19 09:01:29.678308 [    0.817171]  bus_probe_device_deferred+0x2c/0x78
2026-11-19 09:01:29.683731 [    0.821795]  deferred_probe_work_func+0x7c/0xb4
2026-11-19 09:01:29.688826 [    0.826335]  process_one_work+0x164/0x2bc
2026-11-19 09:01:29.693854 [    0.830355]  worker_thread+0x180/0x2f4
2026-11-19 09:01:29.694736 [    0.834109]  kthread+0x110/0x114
2026-11-19 09:01:29.699938 [    0.837345]  ret_from_fork+0x10/0x20
2026-11-19 09:01:29.705576 [    0.840932] Code: d503201f d503201f d503201f f9400c00 (b9400000) 
2026-11-19 09:01:29.709069 [    0.847029] ---[ end trace 0000000000000000 ]---
Quoted 3 lines

I need to check further where the problem is exactly, will reply to this mail again in a couple of hours as I'm not sure I can recover the board remotely to check right now

Ok, I boot after reverting commit a8210490583e ("phy: freescale:
fsl-samsung-hdmi: initialize default rate")

That commit removed the fallback if (!phy->cur_cfg), which probably works for master (didn't test), but doesn't work on 6.12 likely because it doesn't have commit 41db46233467 ("phy: freescale: fsl-samsung-hdmi:
Refactor finding PHY settings") - as far as I can see that commit ensures cur_cfg is always set early on.

Unfortunately it's not trivial to cherry-pick, picking these two in order results in a relatively minor conflict in the Refactor patch we want:
058ea4a06704 ("phy: freescale: fsl-samsung-hdmi: Use closest divider") 41db46233467 ("phy: freescale: fsl-samsung-hdmi: Refactor finding PHY settings")

And I've checked the oops no longer reproduce with these two, keeping a8210490583e ("phy: freescale: fsl-samsung-hdmi: initialize default rate") as is.

If it helps I can send the patches as I resolved, but it's probably easier to drop for this time?

Thanks,

Signature · 1 line
Dominique Martinet | Asmadeus
Tested-by on the v1 series
#1790 lore raw
In reply to Greg Kroah-Hartman

Greg Kroah-Hartman wrote on Wed, Nov 18, 2026 at 03:35:27PM +0100:

Quoted 5 lines

This is the start of the stable review cycle for the 6.12.119 release. There are 1756 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Quoted 8 lines

Responses should be made by Fri, 20 Nov 2026 14:55:44 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.119-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.12.y
and the diffstat can be found below.

after reverting commit a8210490583e ("phy: freescale: fsl-samsung-hdmi:
initialize default rate"),
(I only noticed Francesco/Vinod comment on the 7.3 tree to drop the patch now... FWIW I also checked fb output works on this phy, both with the patch reverted and the extra deps I suggested)

Tested 52008ba8d06c ("Linux 6.12.119-rc1") on:
- arm i.MX6ULL (Armadillo 640)
- arm64 i.MX8MP (Armadillo G4)
- arm64 i.MX8ULP (Armadillo IoT A9E)

No obvious regression in dmesg or basic tests:

Thanks,

Signature · 1 line
Dominique Martinet
Tested-by on the v1 series
#1791 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.12.119 release. There are 1756 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 20 Nov 2026 14:55:44 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 9 lines
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.119-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.12.y
and the diffstat can be found below.

thanks,

greg k-h

Compiled and booted on my test system. No dmesg regressions.

thanks,
-- Shuah

Tested-by on the v1 series
#1792 lore raw
In reply to Greg Kroah-Hartman
Quoted 5 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.12.119 release. There are 1756 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Quoted 9 lines

Responses should be made by Fri, 20 Nov 2026 14:55:44 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.119-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.12.y
and the diffstat can be found below.

Tested on AMD amd64 12-core and 4-core systems
and on Intel x86-64 4-core and x86 1-core systems

Tested-by on the v1 series
#1793 lore raw
In reply to Greg Kroah-Hartman
Quoted 4 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.12.119 release. There are 1756 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Built, booted, and tested on hardware for x86_64:

- Intel N100

No regressions found.

Thanks!
Sean

Tested-by on the v1 series
#1794 lore raw
In reply to Greg Kroah-Hartman
Quoted 9 lines · Greg Kroah-Hartman

This is the start of the stable review cycle for the 6.12.119 release. There are 1756 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.

Responses should be made by Fri, 20 Nov 2026 14:55:44 +0000. Anything received after that time might be too late.

The whole patch series can be found in one patch at:

Quoted 8 lines
	https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.119-rc1.gz

or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.12.y
and the diffstat can be found below.

thanks,

greg k-h

Built and booted successfully on RISC-V RV64 (HiFive Unmatched).