> From: Andrea Arcangeli <aarcange(a)redhat.com>
>
> Upstream 04f5866e41fb70690e28397487d8bd8eea7d712a commit.
>
>
> Signed-off-by: Michal Hocko <mhocko(a)suse.com>
> ---
> Hi,
> this is based on the backport I have done for out 4.4 based distribution
> kernel. Please double check that I haven't missed anything before
> applying to the stable tree. I have also CCed Joel for the binder part
> which is not in the current upstream anymore but I believe it needs the
> check as well.
>
> Review feedback welcome.
>
> drivers/android/binder.c | 6 ++++++
> fs/proc/task_mmu.c | 18 ++++++++++++++++++
> fs/userfaultfd.c | 10 ++++++++--
> include/linux/mm.h | 21 +++++++++++++++++++++
> mm/huge_memory.c | 2 +-
> mm/mmap.c | 7 ++++++-
> 6 files changed, 60 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 260ce0e60187..1fb1cddbd19a 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -570,6 +570,12 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
>
> if (mm) {
> down_write(&mm->mmap_sem);
> + if (!mmget_still_valid(mm)) {
> + if (allocate == 0)
> + goto free_range;
Please cross check, free_range: should not end-up with modifications in vma.
> + goto err_no_vma;
> + }
> +
> vma = proc->vma;
> if (vma && mm != proc->vma_vm_mm) {
> pr_err("%d: vma mm and task mm mismatch\n",
Hi,
I think patch f96278810150 ("of: overlay: set node fields from properties when add new overlay node")
should be back-ported to 4.19, for the reasons outlined below (briefly: without it, overlay fragments
that define phandles will appear to merged successfully, but they do so without those phandles, causing
any references to them to break).
Frank Rowand agrees that a back-port is necessary. I can verify that it solves the issue of the missing
phandles, and as far as I know it doesn't cause any regressions. However, the code in question isn't
really used in mainline kernels, so I understand if you prefer to leave things as they stand now rather
than risk further breaking a stable kernel.
Thanks,
Phil Elwell, Raspberry Pi
-------- Forwarded Message --------
Subject: Re: Dynamic overlay failure in 4.19 & 4.20
Date: Tue, 4 Jun 2019 11:20:43 -0700
From: Frank Rowand <frowand.list(a)gmail.com>
To: Phil Elwell <phil(a)raspberrypi.org>, Rob Herring <robh+dt(a)kernel.org>, Pantelis Antoniou <pantelis.antoniou(a)konsulko.com>, devicetree(a)vger.kernel.org, linux-kernel(a)vger.kernel.org <linux-kernel(a)vger.kernel.org>
Hi Phil,
On 6/4/19 5:15 AM, Phil Elwell wrote:
> Hi,
>
> In the downstream Raspberry Pi kernel we are using configfs to apply overlays at
> runtime, using a patchset from Pantelis that hasn't been accepted upstream yet.
> Apart from the occasional need to adapt to upstream changes, this has been working
> well for us.
>
> A Raspberry Pi user recently noticed that this mechanism was failing for an overlay in
> 4.19. Although the overlay appeared to be applied successfully, pinctrl was reporting
> that one of the two fragments contained an invalid phandle, and an examination of the
> live DT agreed - the target of the reference, which was in the other fragment, was
> missing the phandle property.
>
> 5.0 added two patches - [1] to stop blindly copying properties from the overlay fragments
> into the live tree, and [2] to explicitly copy across the name and phandle properties.
> These two commits should be treated as a pair; the former requires the properties that
> are legitimately defined by an overlay to be added via a changeset, but this mechanism
> deliberately skips the name and phandle; the latter addresses this shortcoming. However,
> [1] was back-ported to 4.19 and 4.20 but [2] wasn't, hence the problem.
I have relied upon Greg's statement that he would handle the stable kernels, and that
the process of doing so would not impact (or would minimally impact) maintainers. If
I think something should go into stable, I will tag it as such, but otherwise I ignore
the stable branches. For overlay related code specifically, my base standard is that
overlay support is an under development, not yet ready for prime time feature and thus
I do not tag my overlay patches for stable.
Your research and analysis above sound like there are on target (thanks for providing
the clear and detailed explanation!), so if you want the stable branches to work for
overlays (out of tree, as you mentioned) I would suggest you email Greg, asking that
the second patch be added to the stable branches. Since the two patches you pointed
out are put of a larger series, you might also want to check which of the other
patches in that series were included in stable or left out from stable. My suggestion
that you request Greg add the second patch continues to rely on the concept that
stable does not add to my workload, so I have not carefully analyzed whether adding
the patch actually is the correct and full fix, but instead am relying on your good
judgment that it is.
To give you some context on the patch series, I started with 144552c78692 ("of: overlay:
add tests to validate kfrees from overlay removal") due to my concerns with how
memory is allocated and freed for overlays. The added tests exposed issues, and
the rest of the patches in the series were dealing with the issues that were
exposed.
You can see the full series (with maybe an extra patch or so) with
git log --oneline 144552c78692^..eeb07c573ec3
> The effect can be seen in the "overlay" overlay in the unittest data. Although the
> overlay appears to apply correctly, the hvac-large-1 node is lacking the phandle it
> should have as a result of the hvac_2 label, and that leaves the hvac-provider property
> of ride@200 with an unresolved phandle.
>
> The obvious fix is to also back-port [2] to 4.19, but that leaves open the question of
> whether either the overlay application mechanism or the unit test framework should have
> detected the missing phandle.
Yes, unittest showed the missing phandle, as you described in the /proc view of
overlay.dts above. That portion of unittest depends on someone looking at the
result of what is in /proc/device-tree and is not automated and is not documented.
I intend to automate that check someday, but the task is still languishing on my
todo list.
>
> Phil
>
> [1] 8814dc46bd9e ("of: overlay: do not duplicate properties from overlay for new nodes")
> [2] f96278810150 ("of: overlay: set node fields from properties when add new overlay node")
>
Hello,
We ran automated tests on a patchset that was proposed for merging into this
kernel tree. The patches were applied to:
Kernel repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Commit: e109a984cf38 - Linux 4.19.48
The results of these automated tests are provided below.
Overall result: PASSED
Merge: OK
Compile: OK
Tests: OK
Please reply to this email if you have any questions about the tests that we
ran or if you have any suggestions on how to make future tests more effective.
,-. ,-.
( C ) ( K ) Continuous
`-',-.`-' Kernel
( I ) Integration
`-'
______________________________________________________________________________
Merge testing
-------------
We cloned this repository and checked out the following commit:
Repo: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Commit: e109a984cf38 - Linux 4.19.48
We then merged the patchset with `git am`:
sparc64-fix-regression-in-non-hypervisor-tlb-flush-xcall.patch
include-linux-bitops.h-sanitize-rotate-primitives.patch
xhci-update-bounce-buffer-with-correct-sg-num.patch
xhci-use-zu-for-printing-size_t-type.patch
xhci-convert-xhci_handshake-to-use-readl_poll_timeout_atomic.patch
usb-xhci-avoid-null-pointer-deref-when-bos-field-is-null.patch
usbip-usbip_host-fix-bug-sleeping-function-called-from-invalid-context.patch
usbip-usbip_host-fix-stub_dev-lock-context-imbalance-regression.patch
usb-fix-slab-out-of-bounds-write-in-usb_get_bos_descriptor.patch
usb-sisusbvga-fix-oops-in-error-path-of-sisusb_probe.patch
usb-add-lpm-quirk-for-surface-dock-gige-adapter.patch
usb-rio500-refuse-more-than-one-device-at-a-time.patch
usb-rio500-fix-memory-leak-in-close-after-disconnect.patch
media-usb-siano-fix-general-protection-fault-in-smsusb.patch
media-usb-siano-fix-false-positive-uninitialized-variable-warning.patch
media-smsusb-better-handle-optional-alignment.patch
brcmfmac-fix-null-pointer-derefence-during-usb-disconnect.patch
scsi-zfcp-fix-missing-zfcp_port-reference-put-on-ebusy-from-port_remove.patch
scsi-zfcp-fix-to-prevent-port_remove-with-pure-auto-scan-luns-only-sdevs.patch
tracing-avoid-memory-leak-in-predicate_parse.patch
btrfs-fix-wrong-ctime-and-mtime-of-a-directory-after-log-replay.patch
btrfs-fix-race-updating-log-root-item-during-fsync.patch
btrfs-fix-fsync-not-persisting-changed-attributes-of-a-directory.patch
btrfs-incremental-send-fix-file-corruption-when-no-holes-feature-is-enabled.patch
iio-dac-ds4422-ds4424-fix-chip-verification.patch
iio-adc-ti-ads8688-fix-timestamp-is-not-updated-in-buffer.patch
s390-crypto-fix-gcm-aes-s390-selftest-failures.patch
s390-crypto-fix-possible-sleep-during-spinlock-aquired.patch
kvm-ppc-book3s-hv-xive-do-not-clear-irq-data-of-passthrough-interrupts.patch
powerpc-perf-fix-mmcra-corruption-by-bhrb_filter.patch
alsa-line6-assure-canceling-delayed-work-at-disconnection.patch
alsa-hda-realtek-set-default-power-save-node-to-0.patch
alsa-hda-realtek-improve-the-headset-mic-for-acer-aspire-laptops.patch
kvm-s390-do-not-report-unusabled-ids-via-kvm_cap_max_vcpu_id.patch
drm-nouveau-i2c-disable-i2c-bus-access-after-fini.patch
i2c-mlxcpld-fix-wrong-initialization-order-in-probe.patch
i2c-synquacer-fix-synquacer_i2c_doxfer-return-value.patch
tty-serial-msm_serial-fix-xon-xoff.patch
tty-max310x-fix-external-crystal-register-setup.patch
memcg-make-it-work-on-sparse-non-0-node-systems.patch
kernel-signal.c-trace_signal_deliver-when-signal_group_exit.patch
arm64-fix-the-arm64_personality-syscall-wrapper-redirection.patch
docs-fix-conf.py-for-sphinx-2.0.patch
doc-cope-with-the-deprecation-of-autoreporter.patch
doc-cope-with-sphinx-logging-deprecations.patch
ima-show-rules-with-ima_inmask-correctly.patch
evm-check-hash-algorithm-passed-to-init_desc.patch
vt-fbcon-deinitialize-resources-in-visual_init-after-failed-memory-allocation.patch
serial-sh-sci-disable-dma-for-uart_console.patch
staging-vc04_services-prevent-integer-overflow-in-create_pagelist.patch
staging-wlan-ng-fix-adapter-initialization-failure.patch
cifs-fix-memory-leak-of-pneg_inbuf-on-eopnotsupp-ioctl-case.patch
cifs-cifs_read_allocate_pages-don-t-iterate-through-whole-page-array-on-enomem.patch
revert-lockd-show-pid-of-lockd-for-remote-locks.patch
gcc-plugins-fix-build-failures-under-darwin-host.patch
drm-tegra-gem-fix-cpu-cache-maintenance-for-bo-s-allocated-using-get_pages.patch
drm-vmwgfx-don-t-send-drm-sysfs-hotplug-events-on-initial-master-set.patch
drm-sun4i-fix-sun8i-hdmi-phy-clock-initialization.patch
drm-sun4i-fix-sun8i-hdmi-phy-configuration-for-148.5-mhz.patch
drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch
drm-lease-make-sure-implicit-planes-are-leased.patch
compiler-attributes-add-support-for-__copy-gcc-9.patch
include-linux-module.h-copy-__init-__exit-attrs-to-init-cleanup_module.patch
revert-x86-build-move-_etext-to-actual-end-of-.text.patch
revert-binder-fix-handling-of-misaligned-binder-object.patch
binder-fix-race-between-munmap-and-direct-reclaim.patch
x86-ftrace-do-not-call-function-graph-from-dynamic-t.patch
x86-ftrace-set-trampoline-pages-as-executable.patch
x86-kprobes-set-instruction-page-as-executable.patch
Compile testing
---------------
We compiled the kernel for 4 architectures:
aarch64:
build options: -j20 INSTALL_MOD_STRIP=1 targz-pkg
configuration: https://artifacts.cki-project.org/builds/aarch64/kernel-stable_queue_4.19-a…
kernel build: https://artifacts.cki-project.org/builds/aarch64/kernel-stable_queue_4.19-a…
ppc64le:
build options: -j20 INSTALL_MOD_STRIP=1 targz-pkg
configuration: https://artifacts.cki-project.org/builds/ppc64le/kernel-stable_queue_4.19-p…
kernel build: https://artifacts.cki-project.org/builds/ppc64le/kernel-stable_queue_4.19-p…
s390x:
build options: -j20 INSTALL_MOD_STRIP=1 targz-pkg
configuration: https://artifacts.cki-project.org/builds/s390x/kernel-stable_queue_4.19-s39…
kernel build: https://artifacts.cki-project.org/builds/s390x/kernel-stable_queue_4.19-s39…
x86_64:
build options: -j20 INSTALL_MOD_STRIP=1 targz-pkg
configuration: https://artifacts.cki-project.org/builds/x86_64/kernel-stable_queue_4.19-x8…
kernel build: https://artifacts.cki-project.org/builds/x86_64/kernel-stable_queue_4.19-x8…
Hardware testing
----------------
We booted each kernel and ran the following tests:
aarch64:
Host 1:
✅ Boot test [0]
✅ LTP lite [1]
✅ Loopdev Sanity [2]
✅ AMTU (Abstract Machine Test Utility) [3]
✅ audit: audit testsuite test [4]
✅ httpd: mod_ssl smoke sanity [5]
✅ iotop: sanity [6]
✅ tuned: tune-processes-through-perf [7]
✅ Usex - version 1.9-29 [8]
🚧 ✅ stress: stress-ng [9]
Host 2:
✅ Boot test [0]
✅ selinux-policy: serge-testsuite [10]
ppc64le:
Host 1:
✅ Boot test [0]
✅ LTP lite [1]
✅ Loopdev Sanity [2]
✅ AMTU (Abstract Machine Test Utility) [3]
✅ audit: audit testsuite test [4]
✅ httpd: mod_ssl smoke sanity [5]
✅ iotop: sanity [6]
✅ tuned: tune-processes-through-perf [7]
✅ Usex - version 1.9-29 [8]
Host 2:
✅ Boot test [0]
✅ selinux-policy: serge-testsuite [10]
s390x:
Host 1:
✅ Boot test [0]
✅ LTP lite [1]
✅ Loopdev Sanity [2]
✅ audit: audit testsuite test [4]
✅ httpd: mod_ssl smoke sanity [5]
✅ iotop: sanity [6]
✅ tuned: tune-processes-through-perf [7]
🚧 ✅ stress: stress-ng [9]
Host 2:
✅ Boot test [0]
✅ selinux-policy: serge-testsuite [10]
x86_64:
Host 1:
✅ Boot test [0]
✅ selinux-policy: serge-testsuite [10]
Host 2:
✅ Boot test [0]
✅ LTP lite [1]
✅ Loopdev Sanity [2]
✅ AMTU (Abstract Machine Test Utility) [3]
✅ audit: audit testsuite test [4]
✅ httpd: mod_ssl smoke sanity [5]
✅ iotop: sanity [6]
✅ tuned: tune-processes-through-perf [7]
✅ Usex - version 1.9-29 [8]
🚧 ✅ stress: stress-ng [9]
Test source:
💚 Pull requests are welcome for new tests or improvements to existing tests!
[0]: https://github.com/CKI-project/tests-beaker/archive/master.zip#distribution…
[1]: https://github.com/CKI-project/tests-beaker/archive/master.zip#distribution…
[2]: https://github.com/CKI-project/tests-beaker/archive/master.zip#filesystems/…
[3]: https://github.com/CKI-project/tests-beaker/archive/master.zip#misc/amtu
[4]: https://github.com/CKI-project/tests-beaker/archive/master.zip#packages/aud…
[5]: https://github.com/CKI-project/tests-beaker/archive/master.zip#packages/htt…
[6]: https://github.com/CKI-project/tests-beaker/archive/master.zip#packages/iot…
[7]: https://github.com/CKI-project/tests-beaker/archive/master.zip#packages/tun…
[8]: https://github.com/CKI-project/tests-beaker/archive/master.zip#standards/us…
[9]: https://github.com/CKI-project/tests-beaker/archive/master.zip#stress/stres…
[10]: https://github.com/CKI-project/tests-beaker/archive/master.zip#/packages/se…
Waived tests (marked with 🚧)
-----------------------------
This test run included waived tests. Such tests are executed but their results
are not taken into account. Tests are waived when their results are not
reliable enough, e.g. when they're just introduced or are being fixed.
From: Andrea Arcangeli <aarcange(a)redhat.com>
commit 04f5866e41fb70690e28397487d8bd8eea7d712a upstream.
The core dumping code has always run without holding the mmap_sem for
writing, despite that is the only way to ensure that the entire vma
layout will not change from under it. Only using some signal
serialization on the processes belonging to the mm is not nearly enough.
This was pointed out earlier. For example in Hugh's post from Jul 2017:
https://lkml.kernel.org/r/alpine.LSU.2.11.1707191716030.2055@eggly.anvils
"Not strictly relevant here, but a related note: I was very surprised
to discover, only quite recently, how handle_mm_fault() may be called
without down_read(mmap_sem) - when core dumping. That seems a
misguided optimization to me, which would also be nice to correct"
In particular because the growsdown and growsup can move the
vm_start/vm_end the various loops the core dump does around the vma will
not be consistent if page faults can happen concurrently.
Pretty much all users calling mmget_not_zero()/get_task_mm() and then
taking the mmap_sem had the potential to introduce unexpected side
effects in the core dumping code.
Adding mmap_sem for writing around the ->core_dump invocation is a
viable long term fix, but it requires removing all copy user and page
faults and to replace them with get_dump_page() for all binary formats
which is not suitable as a short term fix.
For the time being this solution manually covers the places that can
confuse the core dump either by altering the vma layout or the vma flags
while it runs. Once ->core_dump runs under mmap_sem for writing the
function mmget_still_valid() can be dropped.
Allowing mmap_sem protected sections to run in parallel with the
coredump provides some minor parallelism advantage to the swapoff code
(which seems to be safe enough by never mangling any vma field and can
keep doing swapins in parallel to the core dumping) and to some other
corner case.
In order to facilitate the backporting I added "Fixes: 86039bd3b4e6"
however the side effect of this same race condition in /proc/pid/mem
should be reproducible since before 2.6.12-rc2 so I couldn't add any
other "Fixes:" because there's no hash beyond the git genesis commit.
Because find_extend_vma() is the only location outside of the process
context that could modify the "mm" structures under mmap_sem for
reading, by adding the mmget_still_valid() check to it, all other cases
that take the mmap_sem for reading don't need the new check after
mmget_not_zero()/get_task_mm(). The expand_stack() in page fault
context also doesn't need the new check, because all tasks under core
dumping are frozen.
Link: http://lkml.kernel.org/r/20190325224949.11068-1-aarcange@redhat.com
Fixes: 86039bd3b4e6 ("userfaultfd: add new syscall to provide memory externalization")
Signed-off-by: Andrea Arcangeli <aarcange(a)redhat.com>
Reported-by: Jann Horn <jannh(a)google.com>
Suggested-by: Oleg Nesterov <oleg(a)redhat.com>
Acked-by: Peter Xu <peterx(a)redhat.com>
Reviewed-by: Mike Rapoport <rppt(a)linux.ibm.com>
Reviewed-by: Oleg Nesterov <oleg(a)redhat.com>
Reviewed-by: Jann Horn <jannh(a)google.com>
Acked-by: Jason Gunthorpe <jgg(a)mellanox.com>
Acked-by: Michal Hocko <mhocko(a)suse.com>
Cc: <stable(a)vger.kernel.org>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds(a)linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
[Ajay: Dropped infiniband changes to get patch to apply on 4.9.y]
Signed-off-by: Ajay Kaher <akaher(a)vmware.com>
---
fs/proc/task_mmu.c | 18 ++++++++++++++++++
fs/userfaultfd.c | 9 +++++++++
include/linux/sched.h | 21 +++++++++++++++++++++
mm/mmap.c | 7 ++++++-
4 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 5138e78..4b207b1 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1057,6 +1057,24 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
count = -EINTR;
goto out_mm;
}
+ /*
+ * Avoid to modify vma->vm_flags
+ * without locked ops while the
+ * coredump reads the vm_flags.
+ */
+ if (!mmget_still_valid(mm)) {
+ /*
+ * Silently return "count"
+ * like if get_task_mm()
+ * failed. FIXME: should this
+ * function have returned
+ * -ESRCH if get_task_mm()
+ * failed like if
+ * get_proc_task() fails?
+ */
+ up_write(&mm->mmap_sem);
+ goto out_mm;
+ }
for (vma = mm->mmap; vma; vma = vma->vm_next) {
vma->vm_flags &= ~VM_SOFTDIRTY;
vma_set_page_prot(vma);
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 784d667..8bf425a 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -479,6 +479,8 @@ static int userfaultfd_release(struct inode *inode, struct file *file)
* taking the mmap_sem for writing.
*/
down_write(&mm->mmap_sem);
+ if (!mmget_still_valid(mm))
+ goto skip_mm;
prev = NULL;
for (vma = mm->mmap; vma; vma = vma->vm_next) {
cond_resched();
@@ -501,6 +503,7 @@ static int userfaultfd_release(struct inode *inode, struct file *file)
vma->vm_flags = new_flags;
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
}
+skip_mm:
up_write(&mm->mmap_sem);
mmput(mm);
wakeup:
@@ -802,6 +805,9 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
goto out;
down_write(&mm->mmap_sem);
+ if (!mmget_still_valid(mm))
+ goto out_unlock;
+
vma = find_vma_prev(mm, start, &prev);
if (!vma)
goto out_unlock;
@@ -947,6 +953,9 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
goto out;
down_write(&mm->mmap_sem);
+ if (!mmget_still_valid(mm))
+ goto out_unlock;
+
vma = find_vma_prev(mm, start, &prev);
if (!vma)
goto out_unlock;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 1c487a3..c3d9ca0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2933,6 +2933,27 @@ static inline void mmdrop_async(struct mm_struct *mm)
}
}
+/*
+ * This has to be called after a get_task_mm()/mmget_not_zero()
+ * followed by taking the mmap_sem for writing before modifying the
+ * vmas or anything the coredump pretends not to change from under it.
+ *
+ * NOTE: find_extend_vma() called from GUP context is the only place
+ * that can modify the "mm" (notably the vm_start/end) under mmap_sem
+ * for reading and outside the context of the process, so it is also
+ * the only case that holds the mmap_sem for reading that must call
+ * this function. Generally if the mmap_sem is hold for reading
+ * there's no need of this check after get_task_mm()/mmget_not_zero().
+ *
+ * This function can be obsoleted and the check can be removed, after
+ * the coredump code will hold the mmap_sem for writing before
+ * invoking the ->core_dump methods.
+ */
+static inline bool mmget_still_valid(struct mm_struct *mm)
+{
+ return likely(!mm->core_state);
+}
+
static inline bool mmget_not_zero(struct mm_struct *mm)
{
return atomic_inc_not_zero(&mm->mm_users);
diff --git a/mm/mmap.c b/mm/mmap.c
index 3f2314a..acd93d1 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -45,6 +45,7 @@
#include <linux/moduleparam.h>
#include <linux/pkeys.h>
+#include <linux/sched.h>
#include <asm/uaccess.h>
#include <asm/cacheflush.h>
#include <asm/tlb.h>
@@ -2448,7 +2449,8 @@ find_extend_vma(struct mm_struct *mm, unsigned long addr)
vma = find_vma_prev(mm, addr, &prev);
if (vma && (vma->vm_start <= addr))
return vma;
- if (!prev || expand_stack(prev, addr))
+ /* don't alter vm_end if the coredump is running */
+ if (!prev || !mmget_still_valid(mm) || expand_stack(prev, addr))
return NULL;
if (prev->vm_flags & VM_LOCKED)
populate_vma_page_range(prev, addr, prev->vm_end, NULL);
@@ -2474,6 +2476,9 @@ find_extend_vma(struct mm_struct *mm, unsigned long addr)
return vma;
if (!(vma->vm_flags & VM_GROWSDOWN))
return NULL;
+ /* don't alter vm_start if the coredump is running */
+ if (!mmget_still_valid(mm))
+ return NULL;
start = vma->vm_start;
if (expand_stack(vma, addr))
return NULL;
--
2.7.4
On Tue, Jun 04, 2019 at 04:52:31PM +0200, Michal Hocko wrote:
> Please note that I have posted my backport today
> http://lkml.kernel.org/r/20190604094953.26688-1-mhocko@kernel.org and it
> differs from this one. Please have a look!
Ah, good point, I just noticed that. Ben, any thoughts as to the
difference?
thanks,
greg k-h