]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/exec.c
Merge tag 'gvt-fixes-2017-12-06' of https://github.com/intel/gvt-linux into drm-intel...
[mirror_ubuntu-bionic-kernel.git] / fs / exec.c
index 3e14ba25f678bf8869e005a34dc9742e117e90df..6be2aa0ab26fe26cb37032b99bba656f8d7c6b51 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1340,10 +1340,15 @@ void setup_new_exec(struct linux_binprm * bprm)
                 * avoid bad behavior from the prior rlimits. This has to
                 * happen before arch_pick_mmap_layout(), which examines
                 * RLIMIT_STACK, but after the point of no return to avoid
-                * needing to clean up the change on failure.
+                * races from other threads changing the limits. This also
+                * must be protected from races with prlimit() calls.
                 */
+               task_lock(current->group_leader);
                if (current->signal->rlim[RLIMIT_STACK].rlim_cur > _STK_LIM)
                        current->signal->rlim[RLIMIT_STACK].rlim_cur = _STK_LIM;
+               if (current->signal->rlim[RLIMIT_STACK].rlim_max > _STK_LIM)
+                       current->signal->rlim[RLIMIT_STACK].rlim_max = _STK_LIM;
+               task_unlock(current->group_leader);
        }
 
        arch_pick_mmap_layout(current->mm);
@@ -1911,7 +1916,7 @@ void set_dumpable(struct mm_struct *mm, int value)
                return;
 
        do {
-               old = ACCESS_ONCE(mm->flags);
+               old = READ_ONCE(mm->flags);
                new = (old & ~MMF_DUMPABLE_MASK) | value;
        } while (cmpxchg(&mm->flags, old, new) != old);
 }