Skip to content

Commit

Permalink
xen: disable interrupts before saving in percpu
Browse files Browse the repository at this point in the history
Impact: Fix race condition

xen_mc_batch has a small preempt race where it takes the address of a
percpu variable immediately before disabling interrupts, thereby
leaving a small window in which we may migrate to another cpu and save
the flags in the wrong percpu variable.  Disable interrupts before
saving the old flags in a percpu.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
  • Loading branch information
Jeremy Fitzhardinge authored and H. Peter Anvin committed Feb 4, 2009
1 parent b1792e3 commit 06fc732
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion arch/x86/xen/multicalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ DECLARE_PER_CPU(unsigned long, xen_mc_irq_flags);
paired with xen_mc_issue() */
static inline void xen_mc_batch(void)
{
unsigned long flags;
/* need to disable interrupts until this entry is complete */
local_irq_save(__get_cpu_var(xen_mc_irq_flags));
local_irq_save(flags);
__get_cpu_var(xen_mc_irq_flags) = flags;
}

static inline struct multicall_space xen_mc_entry(size_t args)
Expand Down

0 comments on commit 06fc732

Please sign in to comment.