Skip to content

Commit

Permalink
genirq/debugfs: Add missing sanity checks to interrupt injection
Browse files Browse the repository at this point in the history
commit a740a423c36932695b01a3e920f697bc55b05fec upstream.

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 <[email protected]>
Acked-by: Marc Zyngier <[email protected]>
Cc: [email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
KAGA-KOKO authored and gregkh committed Apr 17, 2020
1 parent 6ecc37d commit 3f3700c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kernel/irq/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,15 @@ static ssize_t irq_debug_write(struct file *file, const char __user *user_buf,
chip_bus_lock(desc);
raw_spin_lock_irqsave(&desc->lock, flags);

if (irq_settings_is_level(desc) || desc->istate & IRQS_NMI) {
/* Can't do level nor NMIs, sorry */
/*
* Don't allow injection when the interrupt is:
* - Level or NMI type
* - not activated
* - replaying already
*/
if (irq_settings_is_level(desc) ||
!irqd_is_activated(&desc->irq_data) ||
(desc->istate & (IRQS_NMI | IRQS_REPLAY))) {
err = -EINVAL;
} else {
desc->istate |= IRQS_PENDING;
Expand Down

0 comments on commit 3f3700c

Please sign in to comment.