Instrument smp_processor_id /wrt illicit usage
This is still in my local queue, don't recall anymore when we last discussed it and if there was some issue remaining.
Anyway, here is a rebased set to detect calls of smp_processor_id() from illicit contexts (non-root) on archs that bother about this. Only i386 is cared about so far, x86_64 and PowerPC should be treated similarly, other (future) SMP-arch would arm the check automatically. Yet another safety bag for porting I-pipe.
Jan
--- lib/smp_processor_id.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
lib/smp_processor_id.c +18 -2
@@ -10,11 +10,27 @@unsigned int debug_smp_processor_id (void ) {unsigned long preempt_count =preempt_count (); -int this_cpu =raw_smp_processor_id (); +int this_cpu =ipipe_processor_id ();cpumask_t this_mask; -if (!ipipe_root_domain_p) +#ifdef CONFIG_IPIPE +if (!ipipe_root_domain_p) { +#ifndef IPIPE_STACK_INVARIANT_CPUID +if (test_bit (IPIPE_NOSTACK_FLAG , &ipipe_current_domain-> + cpudata[this_cpu].status)) { +ipipe_trace_panic_freeze (); +printk (KERN_ERR "BUG: using smp_processor_id() over " +"non-Linux stack. I-pipe domain: %s\n" , + ipipe_current_domain->name); +print_symbol ("caller is %s\n" , + (long )__builtin_return_address (0 )); +dump_stack (); +ipipe_trace_panic_dump (); + } +#endif /* !IPIPE_STACK_INVARIANT_CPUID */ goto out; + } +#endif /* CONFIG_IPIPE */ if (likely (preempt_count)) goto out;
--- include/asm-i386/ipipe.h | 1 + 1 file changed, 1 insertion(+)
include/asm-i386/ipipe.h +1 -0
@@ -38,6 +38,7 @@#include <asm/ptrace.h> #define ipipe_processor_id () raw_smp_processor_id() +#define IPIPE_STACK_INVARIANT_CPUID #define prepare_arch_switch (next) \ do { \
Quoted 8 lines · Jan Kiszka
This is still in my local queue, don't recall anymore when we last discussed it and if there was some issue remaining.
Anyway, here is a rebased set to detect calls of
smp_processor_id()from illicit contexts (non-root) on archs that bother about this. Only i386 is cared about so far,x86_64and PowerPC should be treated similarly, other (future) SMP-arch would arm the check automatically. Yet another safety bag for porting I-pipe.
Last time, the ancestor of this patch badly broke my x86_84 setup, causing hell in the NMI path for instance. A number of fixes you sent lately have improved the situation since then for sure, so I will hold those patches until the pending 2.6.22 issues are fixed, but will merge in the end.
Quoted 2 lines
Jan
Signature · 1 line
Philippe.