John Sperbeck
ecb101aed8
powerpc/mm: Fix SEGV on mapped region to return SEGV_ACCERR
...
The recent refactoring of the powerpc page fault handler in commit
c3350602e8 ("powerpc/mm: Make bad_area* helper functions") caused
access to protected memory regions to indicate SEGV_MAPERR instead of
the traditional SEGV_ACCERR in the si_code field of a user-space
signal handler. This can confuse debug libraries that temporarily
change the protection of memory regions, and expect to use SEGV_ACCERR
as an indication to restore access to a region.
This commit restores the previous behavior. The following program
exhibits the issue:
$ ./repro read || echo "FAILED"
$ ./repro write || echo "FAILED"
$ ./repro exec || echo "FAILED"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <sys/mman.h>
#include <assert.h>
static void segv_handler(int n, siginfo_t *info, void *arg) {
_exit(info->si_code == SEGV_ACCERR ? 0 : 1);
}
int main(int argc, char **argv)
{
void *p = NULL;
struct sigaction act = {
.sa_sigaction = segv_handler,
.sa_flags = SA_SIGINFO,
};
assert(argc == 2);
p = mmap(NULL, getpagesize(),
(strcmp(argv[1], "write") == 0) ? PROT_READ : 0,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
assert(p != MAP_FAILED);
assert(sigaction(SIGSEGV, &act, NULL) == 0);
if (strcmp(argv[1], "read") == 0)
printf("%c", *(unsigned char *)p);
else if (strcmp(argv[1], "write") == 0)
*(unsigned char *)p = 0;
else if (strcmp(argv[1], "exec") == 0)
((void (*)(void))p)();
return 1; /* failed to generate SEGV */
}
Fixes: c3350602e8 ("powerpc/mm: Make bad_area* helper functions")
Cc: stable@vger.kernel.org # v4.14+
Signed-off-by: John Sperbeck <jsperbeck@google.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[mpe: Add commit references in change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-01-02 21:12:33 +11:00
arch
powerpc/mm: Fix SEGV on mapped region to return SEGV_ACCERR
2018-01-02 21:12:33 +11:00
block
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
2017-12-01 08:05:45 -05:00
certs
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
crypto
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
2017-11-28 16:22:10 -08:00
Documentation
hwmon fixes for v4.15-rc2
2017-12-03 10:46:16 -05:00
drivers
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
2017-12-03 10:48:24 -05:00
firmware
kbuild: remove all dummy assignments to obj-
2017-11-18 11:46:06 +09:00
fs
NFS client fixes for Linux 4.15-rc2
2017-12-01 20:04:20 -05:00
include
RISC-V Cleanups and ABI Fixes for 4.15-rc2
2017-12-01 19:39:12 -05:00
init
EXPERT Kconfig menu: fix broken EXPERT menu
2017-11-17 16:10:05 -08:00
ipc
Rename superblock flags (MS_xyz -> SB_xyz)
2017-11-27 13:05:09 -08:00
kernel
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
2017-12-01 08:05:45 -05:00
lib
RISC-V Cleanups and ABI Fixes for 4.15-rc2
2017-12-01 19:39:12 -05:00
mm
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
2017-12-01 08:05:45 -05:00
net
NFS client fixes for Linux 4.15-rc2
2017-12-01 20:04:20 -05:00
samples
kbuild: remove all dummy assignments to obj-
2017-11-18 11:46:06 +09:00
scripts
Merge branch 'akpm' (patches from Andrew)
2017-11-29 19:12:44 -08:00
security
bug fixes:
2017-11-30 18:56:41 -05:00
sound
Revert "ALSA: usb-audio: Fix potential zero-division at parsing FU"
2017-11-28 09:34:36 -08:00
tools
Power management fixes for v4.15-rc2
2017-11-30 18:45:55 -05:00
usr
initramfs: fix initramfs rebuilds w/ compression after disabling
2017-11-03 07:39:19 -07:00
virt
* x86 bugfixes: APIC, nested virtualization, IOAPIC
2017-11-30 08:15:19 -08:00
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitattributes: set git diff driver for C source code files
2016-10-07 18:46:30 -07:00
.gitignore
Kbuild misc updates for v4.15
2017-11-17 17:51:33 -08:00
.mailmap
Add Jason Gunthorpe as co-maintainer of the RDMA stack
2017-11-17 09:36:18 -08:00
COPYING
CREDITS
MAINTAINERS: update TPM driver infrastructure changes
2017-11-09 17:58:40 -08:00
Kbuild
Kbuild updates for v4.15
2017-11-17 17:45:29 -08:00
Kconfig
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
2017-11-02 11:10:55 +01:00
MAINTAINERS
hwmon fixes for v4.15-rc2
2017-12-03 10:46:16 -05:00
Makefile
Linux 4.15-rc2
2017-12-03 11:01:47 -05:00
README
README: add a new README file, pointing to the Documentation/
2016-10-24 08:12:35 -02:00