diff options
| author | Ingo Molnar <mingo@kernel.org> | 2026-10-13 08:55:39 +0200 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2026-10-13 08:55:39 +0200 |
| commit | c044eed292f5d821eef29de50563ec50d40034ea (patch) | |
| tree | 798a97fb4a7e8a367b86d25df45c0bc3657c1055 /include | |
| parent | e73e328d0f7bc5dc211dbb902d73d5a4f5eec1ba (diff) | |
| parent | 67e0eadd862616cb22145d6117b79b79c4ae48fe (diff) | |
| download | linux-next-c044eed292f5d821eef29de50563ec50d40034ea.tar.gz linux-next-c044eed292f5d821eef29de50563ec50d40034ea.zip | |
Merge branch into tip/master: 'locking/core'
# New commits in locking/core:
67e0eadd8626 ("irq: Add max local_interrupt_disable() nesting level kunit test case")
1259028ec8f2 ("irq: Explain better on NMI_MASK overflow condition")
9e174422f6f1 ("irq: Add {over,under}flow detection for local_interrupt_{enable,disable}")
5b5224220747 ("refcount: Use CONFIG_BUG_ON_DATA_CORRUPTION for UAF-related errors")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/hardirq.h | 2 | ||||
| -rw-r--r-- | include/linux/interrupt_rc.h | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h index 73b48dd9f135..2648c49cd8f6 100644 --- a/include/linux/hardirq.h +++ b/include/linux/hardirq.h @@ -108,7 +108,7 @@ DECLARE_PER_CPU(unsigned int, nmi_nesting); #define __preempt_count_nmi_enter() \ do { \ __preempt_count_add(HARDIRQ_OFFSET); \ - /* Maximum NMI nesting is 15. */ \ + /* NMI nesting is represented in 4 bits. */ \ BUG_ON(__this_cpu_read(nmi_nesting) >= 15); \ __this_cpu_inc(nmi_nesting); \ preempt_count_set(preempt_count() | NMI_MASK); \ diff --git a/include/linux/interrupt_rc.h b/include/linux/interrupt_rc.h index a9ed937a80e7..d385ab05a2b6 100644 --- a/include/linux/interrupt_rc.h +++ b/include/linux/interrupt_rc.h @@ -11,6 +11,7 @@ * make it easier to include without hitting circular header dependencies. */ +#include <linux/debug_locks.h> #include <linux/irqflags.h> #include <linux/preempt.h> #include <linux/processor.h> @@ -65,6 +66,13 @@ static inline void local_interrupt_disable(void) local_irq_save(flags); new_count = hardirq_disable_enter(); + /* Is hardirq disable count overflow soon? */ + if (IS_ENABLED(CONFIG_DEBUG_PREEMPT) && + DEBUG_LOCKS_WARN_ON(((new_count & HARDIRQ_DISABLE_MASK) + + (10 << HARDIRQ_DISABLE_SHIFT)) >= + HARDIRQ_DISABLE_MASK)) + return; + if ((new_count & HARDIRQ_DISABLE_MASK) == HARDIRQ_DISABLE_OFFSET) _local_interrupt_save_state(flags); } @@ -73,6 +81,11 @@ static inline void local_interrupt_enable(void) { int new_count; + /* Unpaired local_interrupt_enable()? Warn and abort. */ + if (IS_ENABLED(CONFIG_DEBUG_PREEMPT) && + DEBUG_LOCKS_WARN_ON((preempt_count() & HARDIRQ_DISABLE_MASK) == 0)) + return; + new_count = hardirq_disable_exit(); if ((new_count & HARDIRQ_DISABLE_MASK) == 0) |
