diff options
-rw-r--r-- | arch/x86/include/asm/uaccess.h | 13 | ||||
-rw-r--r-- | include/linux/preempt.h | 21 |
2 files changed, 24 insertions, 10 deletions
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index faf3687f1035..ea148313570f 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h | |||
@@ -68,6 +68,12 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un | |||
68 | __chk_range_not_ok((unsigned long __force)(addr), size, limit); \ | 68 | __chk_range_not_ok((unsigned long __force)(addr), size, limit); \ |
69 | }) | 69 | }) |
70 | 70 | ||
71 | #ifdef CONFIG_DEBUG_ATOMIC_SLEEP | ||
72 | # define WARN_ON_IN_IRQ() WARN_ON_ONCE(!in_task()) | ||
73 | #else | ||
74 | # define WARN_ON_IN_IRQ() | ||
75 | #endif | ||
76 | |||
71 | /** | 77 | /** |
72 | * access_ok: - Checks if a user space pointer is valid | 78 | * access_ok: - Checks if a user space pointer is valid |
73 | * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that | 79 | * @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that |
@@ -88,8 +94,11 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un | |||
88 | * checks that the pointer is in the user space range - after calling | 94 | * checks that the pointer is in the user space range - after calling |
89 | * this function, memory access functions may still return -EFAULT. | 95 | * this function, memory access functions may still return -EFAULT. |
90 | */ | 96 | */ |
91 | #define access_ok(type, addr, size) \ | 97 | #define access_ok(type, addr, size) \ |
92 | likely(!__range_not_ok(addr, size, user_addr_max())) | 98 | ({ \ |
99 | WARN_ON_IN_IRQ(); \ | ||
100 | likely(!__range_not_ok(addr, size, user_addr_max())); \ | ||
101 | }) | ||
93 | 102 | ||
94 | /* | 103 | /* |
95 | * These are the main single-value transfer routines. They automatically | 104 | * These are the main single-value transfer routines. They automatically |
diff --git a/include/linux/preempt.h b/include/linux/preempt.h index 75e4e30677f1..7eeceac52dea 100644 --- a/include/linux/preempt.h +++ b/include/linux/preempt.h | |||
@@ -65,19 +65,24 @@ | |||
65 | 65 | ||
66 | /* | 66 | /* |
67 | * Are we doing bottom half or hardware interrupt processing? | 67 | * Are we doing bottom half or hardware interrupt processing? |
68 | * Are we in a softirq context? Interrupt context? | 68 | * |
69 | * in_softirq - Are we currently processing softirq or have bh disabled? | 69 | * in_irq() - We're in (hard) IRQ context |
70 | * in_serving_softirq - Are we currently processing softirq? | 70 | * in_softirq() - We have BH disabled, or are processing softirqs |
71 | * in_interrupt() - We're in NMI,IRQ,SoftIRQ context or have BH disabled | ||
72 | * in_serving_softirq() - We're in softirq context | ||
73 | * in_nmi() - We're in NMI context | ||
74 | * in_task() - We're in task context | ||
75 | * | ||
76 | * Note: due to the BH disabled confusion: in_softirq(),in_interrupt() really | ||
77 | * should not be used in new code. | ||
71 | */ | 78 | */ |
72 | #define in_irq() (hardirq_count()) | 79 | #define in_irq() (hardirq_count()) |
73 | #define in_softirq() (softirq_count()) | 80 | #define in_softirq() (softirq_count()) |
74 | #define in_interrupt() (irq_count()) | 81 | #define in_interrupt() (irq_count()) |
75 | #define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET) | 82 | #define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET) |
76 | 83 | #define in_nmi() (preempt_count() & NMI_MASK) | |
77 | /* | 84 | #define in_task() (!(preempt_count() & \ |
78 | * Are we in NMI context? | 85 | (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET))) |
79 | */ | ||
80 | #define in_nmi() (preempt_count() & NMI_MASK) | ||
81 | 86 | ||
82 | /* | 87 | /* |
83 | * The preempt_count offset after preempt_disable(); | 88 | * The preempt_count offset after preempt_disable(); |