Skip to content

Commit a740a42

Browse files
committed
genirq/debugfs: Add missing sanity checks to interrupt injection
Interrupts cannot be injected when the interrupt is not activated and when a replay is already in progress. Fixes: 536e2e3 ("genirq/debugfs: Triggering of interrupts from userspace") Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Marc Zyngier <maz@kernel.org> Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20200306130623.500019114@linutronix.de
1 parent b513df6 commit a740a42

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎kernel/irq/debugfs.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,15 @@ static ssize_t irq_debug_write(struct file *file, const char __user *user_buf,
206206
chip_bus_lock(desc);
207207
raw_spin_lock_irqsave(&desc->lock, flags);
208208

209-
if (irq_settings_is_level(desc) || desc->istate & IRQS_NMI) {
210-
/* Can't do level nor NMIs, sorry */
209+
/*
210+
* Don't allow injection when the interrupt is:
211+
* - Level or NMI type
212+
* - not activated
213+
* - replaying already
214+
*/
215+
if (irq_settings_is_level(desc) ||
216+
!irqd_is_activated(&desc->irq_data) ||
217+
(desc->istate & (IRQS_NMI | IRQS_REPLAY))) {
211218
err = -EINVAL;
212219
} else {
213220
desc->istate |= IRQS_PENDING;

0 commit comments

Comments
 (0)