[linux] 03/03: [x86] mmap: Add an exception to the stack gap for Hotspot JVM compatibility
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Thu Nov 30 19:31:09 UTC 2017
This is an automated email from the git hooks/post-receive script.
benh pushed a commit to branch stretch
in repository linux.
commit 7b7490fbcac4303a7c7583c21fe12f4e299f7dd5
Author: Ben Hutchings <ben at decadent.org.uk>
Date: Thu Nov 30 01:06:55 2017 +0000
[x86] mmap: Add an exception to the stack gap for Hotspot JVM compatibility
Closes: #865303
---
debian/changelog | 3 ++
...xception-to-the-stack-gap-for-hotspot-jvm.patch | 45 ++++++++++++++++++++++
...p-remember-the-map_fixed-flag-as-vm_fixed.patch | 32 +++++++++++++++
debian/patches/series | 2 +
4 files changed, 82 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 24b5e68..2e90ce1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -729,6 +729,9 @@ linux (4.9.65-1) UNRELEASED; urgency=medium
* mm/mmap.c: do not blow on PROT_NONE MAP_FIXED holes in the stack
(Closes: #865416)
* mm/mmap.c: expand_downwards: don't require the gap if !vm_prev
+ * mmap: Remember the MAP_FIXED flag as VM_FIXED
+ * [x86] mmap: Add an exception to the stack gap for Hotspot JVM compatibility
+ (Closes: #865303)
-- Ben Hutchings <ben at decadent.org.uk> Sun, 01 Oct 2017 16:14:43 +0100
diff --git a/debian/patches/bugfix/x86/mmap-add-an-exception-to-the-stack-gap-for-hotspot-jvm.patch b/debian/patches/bugfix/x86/mmap-add-an-exception-to-the-stack-gap-for-hotspot-jvm.patch
new file mode 100644
index 0000000..4e496dd
--- /dev/null
+++ b/debian/patches/bugfix/x86/mmap-add-an-exception-to-the-stack-gap-for-hotspot-jvm.patch
@@ -0,0 +1,45 @@
+From: Ben Hutchings <ben at decadent.org.uk>
+Date: Thu, 30 Nov 2017 00:29:18 +0000
+Subject: mmap: Add an exception to the stack gap for Hotspot JVM compatibility
+Bug-Debian: https://bugs.debian.org/865303
+
+The Hotspot JVM can easily exhaust the default stack, and has a
+SIGSEGV handler to cope with this by switching to a new stack segment.
+
+However, on i386 it creates a single writable and executable page just
+under the stack limit as a workaround for a bug in Exec Shield. That
+together with the enlarged stack gap causes the SIGSEGV handler to be
+triggered when the stack pointer is further away from the stack limit,
+and it doesn't recognise this as being a stack overflow.
+
+This specifically affects programs that use JNI. Hotspot doesn't
+normally run Java code on the initial thread.
+
+Reduce the effective stack guard gap on x86 if the previous vma is
+a single page allocated as MAP_FIXED.
+
+References: https://bugs.debian.org/865303
+Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
+---
+ mm/mmap.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/mm/mmap.c
++++ b/mm/mmap.c
+@@ -2324,6 +2324,16 @@ int expand_downwards(struct vm_area_stru
+ /* Check that both stack segments have the same anon_vma? */
+ if (prev && !(prev->vm_flags & VM_GROWSDOWN) &&
+ (prev->vm_flags & (VM_WRITE|VM_READ|VM_EXEC))) {
++ /*
++ * bwh: Reduce the stack guard gap if this looks like
++ * Hotspot JVM craziness - see Debian bug #865303
++ */
++ if (IS_ENABLED(CONFIG_X86) && (prev->vm_flags & VM_FIXED) &&
++ prev->vm_end - prev->vm_start == PAGE_SIZE) {
++ if (address - prev->vm_end <
++ min(stack_guard_gap, 4UL << PAGE_SHIFT))
++ return -ENOMEM;
++ } else
+ if (address - prev->vm_end < stack_guard_gap)
+ return -ENOMEM;
+ }
diff --git a/debian/patches/bugfix/x86/mmap-remember-the-map_fixed-flag-as-vm_fixed.patch b/debian/patches/bugfix/x86/mmap-remember-the-map_fixed-flag-as-vm_fixed.patch
new file mode 100644
index 0000000..456c89d
--- /dev/null
+++ b/debian/patches/bugfix/x86/mmap-remember-the-map_fixed-flag-as-vm_fixed.patch
@@ -0,0 +1,32 @@
+From: Ben Hutchings <ben at decadent.org.uk>
+Date: Wed, 5 Jul 2017 13:32:43 +0100
+Subject: mmap: Remember the MAP_FIXED flag as VM_FIXED
+
+Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
+---
+ include/linux/mm.h | 1 +
+ include/linux/mman.h | 3 ++-
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+--- a/include/linux/mm.h
++++ b/include/linux/mm.h
+@@ -182,6 +182,7 @@ extern unsigned int kobjsize(const void
+ #define VM_ACCOUNT 0x00100000 /* Is a VM accounted object */
+ #define VM_NORESERVE 0x00200000 /* should the VM suppress accounting */
+ #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
++#define VM_FIXED 0x00800000 /* Allocated at fixed address */
+ #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
+ #define VM_ARCH_2 0x02000000
+ #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
+--- a/include/linux/mman.h
++++ b/include/linux/mman.h
+@@ -86,7 +86,8 @@ calc_vm_flag_bits(unsigned long flags)
+ {
+ return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) |
+ _calc_vm_trans(flags, MAP_DENYWRITE, VM_DENYWRITE ) |
+- _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED );
++ _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) |
++ _calc_vm_trans(flags, MAP_FIXED, VM_FIXED );
+ }
+
+ unsigned long vm_commit_limit(void);
diff --git a/debian/patches/series b/debian/patches/series
index f82487a..6309980 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -100,6 +100,8 @@ bugfix/all/partially-revert-usb-kconfig-using-select-for-usb_co.patch
bugfix/all/kbuild-include-addtree-remove-quotes-before-matching-path.patch
bugfix/all/mm-mmap.c-do-not-blow-on-prot_none-map_fixed-holes-i.patch
bugfix/all/mm-mmap.c-expand_downwards-don-t-require-the-gap-if-.patch
+bugfix/x86/mmap-remember-the-map_fixed-flag-as-vm_fixed.patch
+bugfix/x86/mmap-add-an-exception-to-the-stack-gap-for-hotspot-jvm.patch
# Miscellaneous features
features/all/netfilter-nft_ct-add-notrack-support.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git
More information about the Kernel-svn-changes
mailing list