1
0
Fork 0
remarkable-linux/kernel/irq
Thomas Gleixner 3d5960c8c6 genirq: Make sparse_irq_lock protect what it should protect
commit 12ac1d0f6c upstream.

for_each_active_irq() iterates the sparse irq allocation bitmap. The caller
must hold sparse_irq_lock. Several code pathes expect that an active bit in
the sparse bitmap also has a valid interrupt descriptor.

Unfortunately that's not true. The (de)allocation is a two step process,
which holds the sparse_irq_lock only across the queue/remove from the radix
tree and the set/clear in the allocation bitmap.

If a iteration locks sparse_irq_lock between the two steps, then it might
see an active bit but the corresponding irq descriptor is NULL. If that is
dereferenced unconditionally, then the kernel oopses. Of course, all
iterator sites could be audited and fixed, but....

There is no reason why the sparse_irq_lock needs to be dropped between the
two steps, in fact the code becomes simpler when the mutex is held across
both and the semantics become more straight forward, so future problems of
missing NULL pointer checks in the iteration are avoided and all existing
sites are fixed in one go.

Expand the lock held sections so both operations are covered and the bitmap
and the radixtree are in sync.

Fixes: a05a900a51 ("genirq: Make sparse_lock a mutex")
Reported-and-tested-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-05 09:43:58 +02:00
..
Kconfig genirq: Add GENERIC_IRQ_IPI Kconfig symbol 2016-02-25 10:56:55 +01:00
Makefile genirq: Add a helper to spread an affinity mask for MSI/MSI-X vectors 2016-07-04 12:25:14 +02:00
affinity.c genirq/affinity: Fix node generation from cpumask 2017-01-12 11:39:31 +01:00
autoprobe.c genirq: Handle pending irqs in irq_startup() 2012-02-15 11:56:59 +01:00
chip.c genirq: Restore trigger settings in irq_modify_status() 2017-08-24 17:12:20 -07:00
cpuhotplug.c genirq: Make the cpuhotplug migration code less noisy 2015-10-22 14:34:57 +02:00
debug.h irq: hide debug macros so they don't collide with others. 2012-04-23 12:30:03 -04:00
devres.c genirq: devres: Fix testing return value of request_any_context_irq() 2015-05-13 10:47:37 +02:00
dummychip.c Merge branch 'linus' into irq/core 2015-06-05 22:25:01 +02:00
generic-chip.c genirq/generic_chip: Verify irqs_per_chip <= 32 2016-09-02 20:20:59 +02:00
handle.c genirq: Add untracked irq handler 2016-06-18 10:00:55 +02:00
internals.h Merge branch 'irq/for-block' into irq/core 2016-07-04 12:26:05 +02:00
ipi.c genirq/ipi: Fixup checks against nr_cpu_ids 2017-08-24 17:12:21 -07:00
irqdesc.c genirq: Make sparse_irq_lock protect what it should protect 2017-10-05 09:43:58 +02:00
irqdomain.c irqdomain: Avoid activating interrupts more than once 2017-02-09 08:08:31 +01:00
manage.c genirq: Release resources in __setup_irq() error path 2017-06-24 07:11:17 +02:00
migration.c genirq: Remove bogus restriction in irq_move_mask_irq() 2015-06-20 19:05:14 +02:00
msi.c genirq/msi: Add cpumask allocation to alloc_msi_entry 2016-09-14 22:11:08 +02:00
pm.c Merge branches 'irq-urgent-for-linus' and 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-11-15 09:30:48 -08:00
proc.c Merge branch 'irq/for-block' into irq/core 2016-07-04 12:26:05 +02:00
resend.c genirq: Remove irq argument from irq flow handlers 2015-09-16 15:47:51 +02:00
settings.h genirq: Add flag to force mask in disable_irq[_nosync]() 2015-10-11 11:33:42 +02:00
spurious.c genirq: Use a common macro to go through the actions list 2016-02-15 00:07:34 +01:00