linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Joe Lawrence <joe.lawrence@stratus.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>, Peter Anvin <hpa@zytor.com>,
	Jiang Liu <jiang.liu@linux.intel.com>,
	Jeremiah Mahler <jmmahler@gmail.com>,
	andy.shevchenko@gmail.com, Guenter Roeck <linux@roeck-us.net>
Subject: Re: [patch 00/14] x86/irq: Plug various vector cleanup races
Date: Thu, 14 Jan 2016 11:33:26 +0100	[thread overview]
Message-ID: <20160114103326.GG8496@pd.tnic> (raw)
In-Reply-To: <alpine.DEB.2.11.1601140919420.3575@nanos>

On Thu, Jan 14, 2016 at 09:24:35AM +0100, Thomas Gleixner wrote:
> On Mon, 4 Jan 2016, Joe Lawrence wrote:
> > No issues running the same PCI device removal and stress tests against
> > the patchset.
> 
> Thanks for testing!
> 
> Though there is yet another long standing bug in that area. Fix below.
> 
> Thanks,
> 
> 	tglx
> 
> 8<--------------------
> 
> Subject: x86/irq: Call chip->irq_set_affinity in proper context
> From: Thomas Gleixner <tglx@linutronix.de>
> Date: Thu, 14 Jan 2016 08:43:38 +0100
> 
> setup_ioapic_dest() calls irqchip->irq_set_affinity() completely
> unprotected. That's wrong in several aspects:
> 
>  - it triggers a lockdep splat because vector lock is taken with interrupts
>    enabled.
> 
>  - it opens a race window where irq_set_affinity() can be interrupted and the
>    irq chip left in unconsistent state.
> 
> The proper calling convention is irq descriptor lock held and interrupts
> disabled.
> 
> Reported-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: stable@vger.kernel.org
> ---
>  arch/x86/kernel/apic/io_apic.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> --- a/arch/x86/kernel/apic/io_apic.c
> +++ b/arch/x86/kernel/apic/io_apic.c
> @@ -2521,6 +2521,7 @@ void __init setup_ioapic_dest(void)
>  {
>  	int pin, ioapic, irq, irq_entry;
>  	const struct cpumask *mask;
> +	struct irq_desc *desc;
>  	struct irq_data *idata;
>  	struct irq_chip *chip;
>  
> @@ -2536,7 +2537,9 @@ void __init setup_ioapic_dest(void)
>  		if (irq < 0 || !mp_init_irq_at_boot(ioapic, irq))
>  			continue;
>  
> -		idata = irq_get_irq_data(irq);
> +		desc = irq_to_desc(irq);
> +		raw_spin_lock_irq(d&desc->lock);

s/d//

> +		idata = irq_desc_get_irq_data(desc);
>  
>  		/*
>  		 * Honour affinities which have been set in early boot
> @@ -2550,6 +2553,7 @@ void __init setup_ioapic_dest(void)
>  		/* Might be lapic_chip for irq 0 */
>  		if (chip->irq_set_affinity)
>  			chip->irq_set_affinity(idata, mask, false);
> +		raw_spin_unlock_irq(d&desc->lock);

s/d//

With those micro-changes:

Tested-by: Borislav Petkov <bp@suse.de>

:-)

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

  reply	other threads:[~2016-01-14 10:33 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-31 16:30 [patch 00/14] x86/irq: Plug various vector cleanup races Thomas Gleixner
2015-12-31 16:30 ` [patch 01/14] x86/irq: Fix a race in x86_vector_free_irqs() Thomas Gleixner
2015-12-31 16:30 ` [patch 02/14] x86/irq: Validate that irq descriptor is still active Thomas Gleixner
2016-01-16 21:16   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 04/14] x86/irq: Reorganize the return path in assign_irq_vector Thomas Gleixner
2016-01-16 21:17   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 03/14] x86/irq: Do not use apic_chip_data.old_domain as temporary buffer Thomas Gleixner
2015-12-31 16:30 ` [patch 05/14] x86/irq: Reorganize the search in assign_irq_vector Thomas Gleixner
2016-01-16 21:17   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 06/14] x86/irq: Check vector allocation early Thomas Gleixner
2016-01-16 21:17   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 08/14] x86/irq: Get rid of code duplication Thomas Gleixner
2016-01-16 21:18   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 07/14] x86/irq: Copy vectormask instead of an AND operation Thomas Gleixner
2016-01-16 21:18   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 09/14] x86/irq: Remove offline cpus from vector cleanup Thomas Gleixner
2016-01-16 21:18   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 10/14] x86/irq: Clear move_in_progress before sending cleanup IPI Thomas Gleixner
2016-01-16 21:19   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 12/14] x86/irq: Remove outgoing CPU from vector cleanup mask Thomas Gleixner
2016-01-16 21:19   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 11/14] x86/irq: Remove the cpumask allocation from send_cleanup_vector() Thomas Gleixner
2016-01-16 21:19   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 13/14] x86/irq: Call irq_force_move_complete with irq descriptor Thomas Gleixner
2016-01-16 21:20   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2015-12-31 16:30 ` [patch 14/14] x86/irq: Plug vector cleanup race Thomas Gleixner
2016-01-16 21:20   ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2016-01-04 15:35 ` [patch 00/14] x86/irq: Plug various vector cleanup races Joe Lawrence
2016-01-14  8:24   ` Thomas Gleixner
2016-01-14 10:33     ` Borislav Petkov [this message]
2016-01-16 21:37       ` Joe Lawrence
2016-01-18 15:00         ` Joe Lawrence
2016-01-18 15:43           ` Borislav Petkov
2016-01-18 16:38             ` Joe Lawrence
2016-01-20  3:57           ` Joe Lawrence
2016-01-20  8:26             ` Borislav Petkov
2016-01-22 15:28               ` Joe Lawrence
2016-01-16 21:15     ` [tip:x86/urgent] x86/irq: Call chip-> irq_set_affinity in proper context tip-bot for Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160114103326.GG8496@pd.tnic \
    --to=bp@alien8.de \
    --cc=andy.shevchenko@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jiang.liu@linux.intel.com \
    --cc=jmmahler@gmail.com \
    --cc=joe.lawrence@stratus.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).