diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-29 13:51:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-29 13:51:32 -0500 |
commit | 33692f27597fcab536d7cbbcc8f52905133e4aa7 (patch) | |
tree | 1af26a47599661f9e1219536ac7e1714767b7fc7 | |
parent | c59c961ca511dc7ee2f4f7e9c224d16f5c76ca6e (diff) |
vm: add VM_FAULT_SIGSEGV handling support
The core VM already knows about VM_FAULT_SIGBUS, but cannot return a
"you should SIGSEGV" error, because the SIGSEGV case was generally
handled by the caller - usually the architecture fault handler.
That results in lots of duplication - all the architecture fault
handlers end up doing very similar "look up vma, check permissions, do
retries etc" - but it generally works. However, there are cases where
the VM actually wants to SIGSEGV, and applications _expect_ SIGSEGV.
In particular, when accessing the stack guard page, libsigsegv expects a
SIGSEGV. And it usually got one, because the stack growth is handled by
that duplicated architecture fault handler.
However, when the generic VM layer started propagating the error return
from the stack expansion in commit fee7e49d4514 ("mm: propagate error
from stack expansion even for guard page"), that now exposed the
existing VM_FAULT_SIGBUS result to user space. And user space really
expected SIGSEGV, not SIGBUS.
To fix that case, we need to add a VM_FAULT_SIGSEGV, and teach all those
duplicate architecture fault handlers about it. They all already have
the code to handle SIGSEGV, so it's about just tying that new return
value to the existing code, but it's all a bit annoying.
This is the mindless minimal patch to do this. A more extensive patch
would be to try to gather up the mostly shared fault handling logic into
one generic helper routine, and long-term we really should do that
cleanup.
Just from this patch, you can generally see that most architectures just
copied (directly or indirectly) the old x86 way of doing things, but in
the meantime that original x86 model has been improved to hold the VM
semaphore for shorter times etc and to handle VM_FAULT_RETRY and other
"newer" things, so it would be a good idea to bring all those
improvements to the generic case and teach other architectures about
them too.
Reported-and-tested-by: Takashi Iwai <tiwai@suse.de>
Tested-by: Jan Engelhardt <jengelh@inai.de>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> # "s390 still compiles and boots"
Cc: linux-arch@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/alpha/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/arc/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/avr32/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/cris/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/frv/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/ia64/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/m32r/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/m68k/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/metag/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/microblaze/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/mips/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/mn10300/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/nios2/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/openrisc/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/parisc/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/copro_fault.c | 2 | ||||
-rw-r--r-- | arch/powerpc/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/s390/mm/fault.c | 6 | ||||
-rw-r--r-- | arch/score/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/sh/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/sparc/mm/fault_32.c | 2 | ||||
-rw-r--r-- | arch/sparc/mm/fault_64.c | 2 | ||||
-rw-r--r-- | arch/tile/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/um/kernel/trap.c | 2 | ||||
-rw-r--r-- | arch/x86/mm/fault.c | 2 | ||||
-rw-r--r-- | arch/xtensa/mm/fault.c | 2 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/llite/vvp_io.c | 2 | ||||
-rw-r--r-- | include/linux/mm.h | 6 | ||||
-rw-r--r-- | mm/gup.c | 4 | ||||
-rw-r--r-- | mm/ksm.c | 2 |
30 files changed, 63 insertions, 7 deletions
diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c index 98838a05ba6d..9d0ac091a52a 100644 --- a/arch/alpha/mm/fault.c +++ b/arch/alpha/mm/fault.c | |||
@@ -156,6 +156,8 @@ retry: | |||
156 | if (unlikely(fault & VM_FAULT_ERROR)) { | 156 | if (unlikely(fault & VM_FAULT_ERROR)) { |
157 | if (fault & VM_FAULT_OOM) | 157 | if (fault & VM_FAULT_OOM) |
158 | goto out_of_memory; | 158 | goto out_of_memory; |
159 | else if (fault & VM_FAULT_SIGSEGV) | ||
160 | goto bad_area; | ||
159 | else if (fault & VM_FAULT_SIGBUS) | 161 | else if (fault & VM_FAULT_SIGBUS) |
160 | goto do_sigbus; | 162 | goto do_sigbus; |
161 | BUG(); | 163 | BUG(); |
diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c index 6f7e3a68803a..0f8df3b5b1b3 100644 --- a/arch/arc/mm/fault.c +++ b/arch/arc/mm/fault.c | |||
@@ -161,6 +161,8 @@ good_area: | |||
161 | 161 | ||
162 | if (fault & VM_FAULT_OOM) | 162 | if (fault & VM_FAULT_OOM) |
163 | goto out_of_memory; | 163 | goto out_of_memory; |
164 | else if (fault & VM_FAULT_SIGSEV) | ||
165 | goto bad_area; | ||
164 | else if (fault & VM_FAULT_SIGBUS) | 166 | else if (fault & VM_FAULT_SIGBUS) |
165 | goto do_sigbus; | 167 | goto do_sigbus; |
166 | 168 | ||
diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c index 0eca93327195..d223a8b57c1e 100644 --- a/arch/avr32/mm/fault.c +++ b/arch/avr32/mm/fault.c | |||
@@ -142,6 +142,8 @@ good_area: | |||
142 | if (unlikely(fault & VM_FAULT_ERROR)) { | 142 | if (unlikely(fault & VM_FAULT_ERROR)) { |
143 | if (fault & VM_FAULT_OOM) | 143 | if (fault & VM_FAULT_OOM) |
144 | goto out_of_memory; | 144 | goto out_of_memory; |
145 | else if (fault & VM_FAULT_SIGSEGV) | ||
146 | goto bad_area; | ||
145 | else if (fault & VM_FAULT_SIGBUS) | 147 | else if (fault & VM_FAULT_SIGBUS) |
146 | goto do_sigbus; | 148 | goto do_sigbus; |
147 | BUG(); | 149 | BUG(); |
diff --git a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c index 1790f22e71a2..2686a7aa8ec8 100644 --- a/arch/cris/mm/fault.c +++ b/arch/cris/mm/fault.c | |||
@@ -176,6 +176,8 @@ retry: | |||
176 | if (unlikely(fault & VM_FAULT_ERROR)) { | 176 | if (unlikely(fault & VM_FAULT_ERROR)) { |
177 | if (fault & VM_FAULT_OOM) | 177 | if (fault & VM_FAULT_OOM) |
178 | goto out_of_memory; | 178 | goto out_of_memory; |
179 | else if (fault & VM_FAULT_SIGSEGV) | ||
180 | goto bad_area; | ||
179 | else if (fault & VM_FAULT_SIGBUS) | 181 | else if (fault & VM_FAULT_SIGBUS) |
180 | goto do_sigbus; | 182 | goto do_sigbus; |
181 | BUG(); | 183 | BUG(); |
diff --git a/arch/frv/mm/fault.c b/arch/frv/mm/fault.c index 9a66372fc7c7..ec4917ddf678 100644 --- a/arch/frv/mm/fault.c +++ b/arch/frv/mm/fault.c | |||
@@ -168,6 +168,8 @@ asmlinkage void do_page_fault(int datammu, unsigned long esr0, unsigned long ear | |||
168 | if (unlikely(fault & VM_FAULT_ERROR)) { | 168 | if (unlikely(fault & VM_FAULT_ERROR)) { |
169 | if (fault & VM_FAULT_OOM) | 169 | if (fault & VM_FAULT_OOM) |
170 | goto out_of_memory; | 170 | goto out_of_memory; |
171 | else if (fault & VM_FAULT_SIGSEGV) | ||
172 | goto bad_area; | ||
171 | else if (fault & VM_FAULT_SIGBUS) | 173 | else if (fault & VM_FAULT_SIGBUS) |
172 | goto do_sigbus; | 174 | goto do_sigbus; |
173 | BUG(); | 175 | BUG(); |
diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c index 7225dad87094..ba5ba7accd0d 100644 --- a/arch/ia64/mm/fault.c +++ b/arch/ia64/mm/fault.c | |||
@@ -172,6 +172,8 @@ retry: | |||
172 | */ | 172 | */ |
173 | if (fault & VM_FAULT_OOM) { | 173 | if (fault & VM_FAULT_OOM) { |
174 | goto out_of_memory; | 174 | goto out_of_memory; |
175 | } else if (fault & VM_FAULT_SIGSEGV) { | ||
176 | goto bad_area; | ||
175 | } else if (fault & VM_FAULT_SIGBUS) { | 177 | } else if (fault & VM_FAULT_SIGBUS) { |
176 | signal = SIGBUS; | 178 | signal = SIGBUS; |
177 | goto bad_area; | 179 | goto bad_area; |
diff --git a/arch/m32r/mm/fault.c b/arch/m32r/mm/fault.c index e9c6a8014bd6..e3d4d4890104 100644 --- a/arch/m32r/mm/fault.c +++ b/arch/m32r/mm/fault.c | |||
@@ -200,6 +200,8 @@ good_area: | |||
200 | if (unlikely(fault & VM_FAULT_ERROR)) { | 200 | if (unlikely(fault & VM_FAULT_ERROR)) { |
201 | if (fault & VM_FAULT_OOM) | 201 | if (fault & VM_FAULT_OOM) |
202 | goto out_of_memory; | 202 | goto out_of_memory; |
203 | else if (fault & VM_FAULT_SIGSEGV) | ||
204 | goto bad_area; | ||
203 | else if (fault & VM_FAULT_SIGBUS) | 205 | else if (fault & VM_FAULT_SIGBUS) |
204 | goto do_sigbus; | 206 | goto do_sigbus; |
205 | BUG(); | 207 | BUG(); |
diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c index 2bd7487440c4..b2f04aee46ec 100644 --- a/arch/m68k/mm/fault.c +++ b/arch/m68k/mm/fault.c | |||
@@ -145,6 +145,8 @@ good_area: | |||
145 | if (unlikely(fault & VM_FAULT_ERROR)) { | 145 | if (unlikely(fault & VM_FAULT_ERROR)) { |
146 | if (fault & VM_FAULT_OOM) | 146 | if (fault & VM_FAULT_OOM) |
147 | goto out_of_memory; | 147 | goto out_of_memory; |
148 | else if (fault & VM_FAULT_SIGSEGV) | ||
149 | goto map_err; | ||
148 | else if (fault & VM_FAULT_SIGBUS) | 150 | else if (fault & VM_FAULT_SIGBUS) |
149 | goto bus_err; | 151 | goto bus_err; |
150 | BUG(); | 152 | BUG(); |
diff --git a/arch/metag/mm/fault.c b/arch/metag/mm/fault.c index 332680e5ebf2..2de5dc695a87 100644 --- a/arch/metag/mm/fault.c +++ b/arch/metag/mm/fault.c | |||
@@ -141,6 +141,8 @@ good_area: | |||
141 | if (unlikely(fault & VM_FAULT_ERROR)) { | 141 | if (unlikely(fault & VM_FAULT_ERROR)) { |
142 | if (fault & VM_FAULT_OOM) | 142 | if (fault & VM_FAULT_OOM) |
143 | goto out_of_memory; | 143 | goto out_of_memory; |
144 | else if (fault & VM_FAULT_SIGSEGV) | ||
145 | goto bad_area; | ||
144 | else if (fault & VM_FAULT_SIGBUS) | 146 | else if (fault & VM_FAULT_SIGBUS) |
145 | goto do_sigbus; | 147 | goto do_sigbus; |
146 | BUG(); | 148 | BUG(); |
diff --git a/arch/microblaze/mm/fault.c b/arch/microblaze/mm/fault.c index fa4cf52aa7a6..d46a5ebb7570 100644 --- a/arch/microblaze/mm/fault.c +++ b/arch/microblaze/mm/fault.c | |||
@@ -224,6 +224,8 @@ good_area: | |||
224 | if (unlikely(fault & VM_FAULT_ERROR)) { | 224 | if (unlikely(fault & VM_FAULT_ERROR)) { |
225 | if (fault & VM_FAULT_OOM) | 225 | if (fault & VM_FAULT_OOM) |
226 | goto out_of_memory; | 226 | goto out_of_memory; |
227 | else if (fault & VM_FAULT_SIGSEGV) | ||
228 | goto bad_area; | ||
227 | else if (fault & VM_FAULT_SIGBUS) | 229 | else if (fault & VM_FAULT_SIGBUS) |
228 | goto do_sigbus; | 230 | goto do_sigbus; |
229 | BUG(); | 231 | BUG(); |
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c index becc42bb1849..70ab5d664332 100644 --- a/arch/mips/mm/fault.c +++ b/arch/mips/mm/fault.c | |||
@@ -158,6 +158,8 @@ good_area: | |||
158 | if (unlikely(fault & VM_FAULT_ERROR)) { | 158 | if (unlikely(fault & VM_FAULT_ERROR)) { |
159 | if (fault & VM_FAULT_OOM) | 159 | if (fault & VM_FAULT_OOM) |
160 | goto out_of_memory; | 160 | goto out_of_memory; |
161 | else if (fault & VM_FAULT_SIGSEGV) | ||
162 | goto bad_area; | ||
161 | else if (fault & VM_FAULT_SIGBUS) | 163 | else if (fault & VM_FAULT_SIGBUS) |
162 | goto do_sigbus; | 164 | goto do_sigbus; |
163 | BUG(); | 165 | BUG(); |
diff --git a/arch/mn10300/mm/fault.c b/arch/mn10300/mm/fault.c index 3516cbdf1ee9..0c2cc5d39c8e 100644 --- a/arch/mn10300/mm/fault.c +++ b/arch/mn10300/mm/fault.c | |||
@@ -262,6 +262,8 @@ good_area: | |||
262 | if (unlikely(fault & VM_FAULT_ERROR)) { | 262 | if (unlikely(fault & VM_FAULT_ERROR)) { |
263 | if (fault & VM_FAULT_OOM) | 263 | if (fault & VM_FAULT_OOM) |
264 | goto out_of_memory; | 264 | goto out_of_memory; |
265 | else if (fault & VM_FAULT_SIGSEGV) | ||
266 | goto bad_area; | ||
265 | else if (fault & VM_FAULT_SIGBUS) | 267 | else if (fault & VM_FAULT_SIGBUS) |
266 | goto do_sigbus; | 268 | goto do_sigbus; |
267 | BUG(); | 269 | BUG(); |
diff --git a/arch/nios2/mm/fault.c b/arch/nios2/mm/fault.c index 15a0bb5fc06d..34429d5a0ccd 100644 --- a/arch/nios2/mm/fault.c +++ b/arch/nios2/mm/fault.c | |||
@@ -135,6 +135,8 @@ survive: | |||
135 | if (unlikely(fault & VM_FAULT_ERROR)) { | 135 | if (unlikely(fault & VM_FAULT_ERROR)) { |
136 | if (fault & VM_FAULT_OOM) | 136 | if (fault & VM_FAULT_OOM) |
137 | goto out_of_memory; | 137 | goto out_of_memory; |
138 | else if (fault & VM_FAULT_SIGSEGV) | ||
139 | goto bad_area; | ||
138 | else if (fault & VM_FAULT_SIGBUS) | 140 | else if (fault & VM_FAULT_SIGBUS) |
139 | goto do_sigbus; | 141 | goto do_sigbus; |
140 | BUG(); | 142 | BUG(); |
diff --git a/arch/openrisc/mm/fault.c b/arch/openrisc/mm/fault.c index 0703acf7d327..230ac20ae794 100644 --- a/arch/openrisc/mm/fault.c +++ b/arch/openrisc/mm/fault.c | |||
@@ -171,6 +171,8 @@ good_area: | |||
171 | if (unlikely(fault & VM_FAULT_ERROR)) { | 171 | if (unlikely(fault & VM_FAULT_ERROR)) { |
172 | if (fault & VM_FAULT_OOM) | 172 | if (fault & VM_FAULT_OOM) |
173 | goto out_of_memory; | 173 | goto out_of_memory; |
174 | else if (fault & VM_FAULT_SIGSEGV) | ||
175 | goto bad_area; | ||
174 | else if (fault & VM_FAULT_SIGBUS) | 176 | else if (fault & VM_FAULT_SIGBUS) |
175 | goto do_sigbus; | 177 | goto do_sigbus; |
176 | BUG(); | 178 | BUG(); |
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c index 3ca9c1131cfe..e5120e653240 100644 --- a/arch/parisc/mm/fault.c +++ b/arch/parisc/mm/fault.c | |||
@@ -256,6 +256,8 @@ good_area: | |||
256 | */ | 256 | */ |
257 | if (fault & VM_FAULT_OOM) | 257 | if (fault & VM_FAULT_OOM) |
258 | goto out_of_memory; | 258 | goto out_of_memory; |
259 | else if (fault & VM_FAULT_SIGSEGV) | ||
260 | goto bad_area; | ||
259 | else if (fault & VM_FAULT_SIGBUS) | 261 | else if (fault & VM_FAULT_SIGBUS) |
260 | goto bad_area; | 262 | goto bad_area; |
261 | BUG(); | 263 | BUG(); |
diff --git a/arch/powerpc/mm/copro_fault.c b/arch/powerpc/mm/copro_fault.c index 5a236f082c78..1b5305d4bdab 100644 --- a/arch/powerpc/mm/copro_fault.c +++ b/arch/powerpc/mm/copro_fault.c | |||
@@ -76,7 +76,7 @@ int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea, | |||
76 | if (*flt & VM_FAULT_OOM) { | 76 | if (*flt & VM_FAULT_OOM) { |
77 | ret = -ENOMEM; | 77 | ret = -ENOMEM; |
78 | goto out_unlock; | 78 | goto out_unlock; |
79 | } else if (*flt & VM_FAULT_SIGBUS) { | 79 | } else if (*flt & (VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV)) { |
80 | ret = -EFAULT; | 80 | ret = -EFAULT; |
81 | goto out_unlock; | 81 | goto out_unlock; |
82 | } | 82 | } |
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index eb79907f34fa..6154b0a2b063 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c | |||
@@ -437,6 +437,8 @@ good_area: | |||
437 | */ | 437 | */ |
438 | fault = handle_mm_fault(mm, vma, address, flags); | 438 | fault = handle_mm_fault(mm, vma, address, flags); |
439 | if (unlikely(fault & (VM_FAULT_RETRY|VM_FAULT_ERROR))) { | 439 | if (unlikely(fault & (VM_FAULT_RETRY|VM_FAULT_ERROR))) { |
440 | if (fault & VM_FAULT_SIGSEGV) | ||
441 | goto bad_area; | ||
440 | rc = mm_fault_error(regs, address, fault); | 442 | rc = mm_fault_error(regs, address, fault); |
441 | if (rc >= MM_FAULT_RETURN) | 443 | if (rc >= MM_FAULT_RETURN) |
442 | goto bail; | 444 | goto bail; |
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index 811937bb90be..9065d5aa3932 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c | |||
@@ -374,6 +374,12 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault) | |||
374 | do_no_context(regs); | 374 | do_no_context(regs); |
375 | else | 375 | else |
376 | pagefault_out_of_memory(); | 376 | pagefault_out_of_memory(); |
377 | } else if (fault & VM_FAULT_SIGSEGV) { | ||
378 | /* Kernel mode? Handle exceptions or die */ | ||
379 | if (!user_mode(regs)) | ||
380 | do_no_context(regs); | ||
381 | else | ||
382 | do_sigsegv(regs, SEGV_MAPERR); | ||
377 | } else if (fault & VM_FAULT_SIGBUS) { | 383 | } else if (fault & VM_FAULT_SIGBUS) { |
378 | /* Kernel mode? Handle exceptions or die */ | 384 | /* Kernel mode? Handle exceptions or die */ |
379 | if (!user_mode(regs)) | 385 | if (!user_mode(regs)) |
diff --git a/arch/score/mm/fault.c b/arch/score/mm/fault.c index 52238983527d..6860beb2a280 100644 --- a/arch/score/mm/fault.c +++ b/arch/score/mm/fault.c | |||
@@ -114,6 +114,8 @@ good_area: | |||
114 | if (unlikely(fault & VM_FAULT_ERROR)) { | 114 | if (unlikely(fault & VM_FAULT_ERROR)) { |
115 | if (fault & VM_FAULT_OOM) | 115 | if (fault & VM_FAULT_OOM) |
116 | goto out_of_memory; | 116 | goto out_of_memory; |
117 | else if (fault & VM_FAULT_SIGSEGV) | ||
118 | goto bad_area; | ||
117 | else if (fault & VM_FAULT_SIGBUS) | 119 | else if (fault & VM_FAULT_SIGBUS) |
118 | goto do_sigbus; | 120 | goto do_sigbus; |
119 | BUG(); | 121 | BUG(); |
diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c index 541dc6101508..a58fec9b55e0 100644 --- a/arch/sh/mm/fault.c +++ b/arch/sh/mm/fault.c | |||
@@ -353,6 +353,8 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code, | |||
353 | } else { | 353 | } else { |
354 | if (fault & VM_FAULT_SIGBUS) | 354 | if (fault & VM_FAULT_SIGBUS) |
355 | do_sigbus(regs, error_code, address); | 355 | do_sigbus(regs, error_code, address); |
356 | else if (fault & VM_FAULT_SIGSEGV) | ||
357 | bad_area(regs, error_code, address); | ||
356 | else | 358 | else |
357 | BUG(); | 359 | BUG(); |
358 | } | 360 | } |
diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c index 908e8c17c902..70d817154fe8 100644 --- a/arch/sparc/mm/fault_32.c +++ b/arch/sparc/mm/fault_32.c | |||
@@ -249,6 +249,8 @@ good_area: | |||
249 | if (unlikely(fault & VM_FAULT_ERROR)) { | 249 | if (unlikely(fault & VM_FAULT_ERROR)) { |
250 | if (fault & VM_FAULT_OOM) | 250 | if (fault & VM_FAULT_OOM) |
251 | goto out_of_memory; | 251 | goto out_of_memory; |
252 | else if (fault & VM_FAULT_SIGSEGV) | ||
253 | goto bad_area; | ||
252 | else if (fault & VM_FAULT_SIGBUS) | 254 | else if (fault & VM_FAULT_SIGBUS) |
253 | goto do_sigbus; | 255 | goto do_sigbus; |
254 | BUG(); | 256 | BUG(); |
diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c index 18fcd7167095..479823249429 100644 --- a/arch/sparc/mm/fault_64.c +++ b/arch/sparc/mm/fault_64.c | |||
@@ -446,6 +446,8 @@ good_area: | |||
446 | if (unlikely(fault & VM_FAULT_ERROR)) { | 446 | if (unlikely(fault & VM_FAULT_ERROR)) { |
447 | if (fault & VM_FAULT_OOM) | 447 | if (fault & VM_FAULT_OOM) |
448 | goto out_of_memory; | 448 | goto out_of_memory; |
449 | else if (fault & VM_FAULT_SIGSEGV) | ||
450 | goto bad_area; | ||
449 | else if (fault & VM_FAULT_SIGBUS) | 451 | else if (fault & VM_FAULT_SIGBUS) |
450 | goto do_sigbus; | 452 | goto do_sigbus; |
451 | BUG(); | 453 | BUG(); |
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c index 565e25a98334..0f61a73534e6 100644 --- a/arch/tile/mm/fault.c +++ b/arch/tile/mm/fault.c | |||
@@ -442,6 +442,8 @@ good_area: | |||
442 | if (unlikely(fault & VM_FAULT_ERROR)) { | 442 | if (unlikely(fault & VM_FAULT_ERROR)) { |
443 | if (fault & VM_FAULT_OOM) | 443 | if (fault & VM_FAULT_OOM) |
444 | goto out_of_memory; | 444 | goto out_of_memory; |
445 | else if (fault & VM_FAULT_SIGSEGV) | ||
446 | goto bad_area; | ||
445 | else if (fault & VM_FAULT_SIGBUS) | 447 | else if (fault & VM_FAULT_SIGBUS) |
446 | goto do_sigbus; | 448 | goto do_sigbus; |
447 | BUG(); | 449 | BUG(); |
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c index 5678c3571e7c..209617302df8 100644 --- a/arch/um/kernel/trap.c +++ b/arch/um/kernel/trap.c | |||
@@ -80,6 +80,8 @@ good_area: | |||
80 | if (unlikely(fault & VM_FAULT_ERROR)) { | 80 | if (unlikely(fault & VM_FAULT_ERROR)) { |
81 | if (fault & VM_FAULT_OOM) { | 81 | if (fault & VM_FAULT_OOM) { |
82 | goto out_of_memory; | 82 | goto out_of_memory; |
83 | } else if (fault & VM_FAULT_SIGSEGV) { | ||
84 | goto out; | ||
83 | } else if (fault & VM_FAULT_SIGBUS) { | 85 | } else if (fault & VM_FAULT_SIGBUS) { |
84 | err = -EACCES; | 86 | err = -EACCES; |
85 | goto out; | 87 | goto out; |
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 38dcec403b46..e3ff27a5b634 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
@@ -898,6 +898,8 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code, | |||
898 | if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON| | 898 | if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON| |
899 | VM_FAULT_HWPOISON_LARGE)) | 899 | VM_FAULT_HWPOISON_LARGE)) |
900 | do_sigbus(regs, error_code, address, fault); | 900 | do_sigbus(regs, error_code, address, fault); |
901 | else if (fault & VM_FAULT_SIGSEGV) | ||
902 | bad_area_nosemaphore(regs, error_code, address); | ||
901 | else | 903 | else |
902 | BUG(); | 904 | BUG(); |
903 | } | 905 | } |
diff --git a/arch/xtensa/mm/fault.c b/arch/xtensa/mm/fault.c index b57c4f91f487..9e3571a6535c 100644 --- a/arch/xtensa/mm/fault.c +++ b/arch/xtensa/mm/fault.c | |||
@@ -117,6 +117,8 @@ good_area: | |||
117 | if (unlikely(fault & VM_FAULT_ERROR)) { | 117 | if (unlikely(fault & VM_FAULT_ERROR)) { |
118 | if (fault & VM_FAULT_OOM) | 118 | if (fault & VM_FAULT_OOM) |
119 | goto out_of_memory; | 119 | goto out_of_memory; |
120 | else if (fault & VM_FAULT_SIGSEGV) | ||
121 | goto bad_area; | ||
120 | else if (fault & VM_FAULT_SIGBUS) | 122 | else if (fault & VM_FAULT_SIGBUS) |
121 | goto do_sigbus; | 123 | goto do_sigbus; |
122 | BUG(); | 124 | BUG(); |
diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 930f6010203e..65d610abe06e 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c | |||
@@ -632,7 +632,7 @@ static int vvp_io_kernel_fault(struct vvp_fault_io *cfio) | |||
632 | return 0; | 632 | return 0; |
633 | } | 633 | } |
634 | 634 | ||
635 | if (cfio->fault.ft_flags & VM_FAULT_SIGBUS) { | 635 | if (cfio->fault.ft_flags & (VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV)) { |
636 | CDEBUG(D_PAGE, "got addr %p - SIGBUS\n", vmf->virtual_address); | 636 | CDEBUG(D_PAGE, "got addr %p - SIGBUS\n", vmf->virtual_address); |
637 | return -EFAULT; | 637 | return -EFAULT; |
638 | } | 638 | } |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 80fc92a49649..dd5ea3016fc4 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -1070,6 +1070,7 @@ static inline int page_mapped(struct page *page) | |||
1070 | #define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */ | 1070 | #define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */ |
1071 | #define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned small page */ | 1071 | #define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned small page */ |
1072 | #define VM_FAULT_HWPOISON_LARGE 0x0020 /* Hit poisoned large page. Index encoded in upper bits */ | 1072 | #define VM_FAULT_HWPOISON_LARGE 0x0020 /* Hit poisoned large page. Index encoded in upper bits */ |
1073 | #define VM_FAULT_SIGSEGV 0x0040 | ||
1073 | 1074 | ||
1074 | #define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */ | 1075 | #define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */ |
1075 | #define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */ | 1076 | #define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */ |
@@ -1078,8 +1079,9 @@ static inline int page_mapped(struct page *page) | |||
1078 | 1079 | ||
1079 | #define VM_FAULT_HWPOISON_LARGE_MASK 0xf000 /* encodes hpage index for large hwpoison */ | 1080 | #define VM_FAULT_HWPOISON_LARGE_MASK 0xf000 /* encodes hpage index for large hwpoison */ |
1080 | 1081 | ||
1081 | #define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_HWPOISON | \ | 1082 | #define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \ |
1082 | VM_FAULT_FALLBACK | VM_FAULT_HWPOISON_LARGE) | 1083 | VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE | \ |
1084 | VM_FAULT_FALLBACK) | ||
1083 | 1085 | ||
1084 | /* Encode hstate index for a hwpoisoned large page */ | 1086 | /* Encode hstate index for a hwpoisoned large page */ |
1085 | #define VM_FAULT_SET_HINDEX(x) ((x) << 12) | 1087 | #define VM_FAULT_SET_HINDEX(x) ((x) << 12) |
@@ -296,7 +296,7 @@ static int faultin_page(struct task_struct *tsk, struct vm_area_struct *vma, | |||
296 | return -ENOMEM; | 296 | return -ENOMEM; |
297 | if (ret & (VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE)) | 297 | if (ret & (VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE)) |
298 | return *flags & FOLL_HWPOISON ? -EHWPOISON : -EFAULT; | 298 | return *flags & FOLL_HWPOISON ? -EHWPOISON : -EFAULT; |
299 | if (ret & VM_FAULT_SIGBUS) | 299 | if (ret & (VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV)) |
300 | return -EFAULT; | 300 | return -EFAULT; |
301 | BUG(); | 301 | BUG(); |
302 | } | 302 | } |
@@ -571,7 +571,7 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, | |||
571 | return -ENOMEM; | 571 | return -ENOMEM; |
572 | if (ret & (VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE)) | 572 | if (ret & (VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE)) |
573 | return -EHWPOISON; | 573 | return -EHWPOISON; |
574 | if (ret & VM_FAULT_SIGBUS) | 574 | if (ret & (VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV)) |
575 | return -EFAULT; | 575 | return -EFAULT; |
576 | BUG(); | 576 | BUG(); |
577 | } | 577 | } |
@@ -376,7 +376,7 @@ static int break_ksm(struct vm_area_struct *vma, unsigned long addr) | |||
376 | else | 376 | else |
377 | ret = VM_FAULT_WRITE; | 377 | ret = VM_FAULT_WRITE; |
378 | put_page(page); | 378 | put_page(page); |
379 | } while (!(ret & (VM_FAULT_WRITE | VM_FAULT_SIGBUS | VM_FAULT_OOM))); | 379 | } while (!(ret & (VM_FAULT_WRITE | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | VM_FAULT_OOM))); |
380 | /* | 380 | /* |
381 | * We must loop because handle_mm_fault() may back out if there's | 381 | * We must loop because handle_mm_fault() may back out if there's |
382 | * any difficulty e.g. if pte accessed bit gets updated concurrently. | 382 | * any difficulty e.g. if pte accessed bit gets updated concurrently. |