drm/vc4: hdmi: Fix hotplug extcon uevent to works
[platform/kernel/linux-rpi.git] / kernel / sys.c
index 72c7639..3e4e893 100644 (file)
@@ -472,6 +472,16 @@ static int set_user(struct cred *new)
        if (!new_user)
                return -EAGAIN;
 
+       free_uid(new->user);
+       new->user = new_user;
+       return 0;
+}
+
+static void flag_nproc_exceeded(struct cred *new)
+{
+       if (new->ucounts == current_ucounts())
+               return;
+
        /*
         * We don't fail in case of NPROC limit excess here because too many
         * poorly written programs don't check set*uid() return code, assuming
@@ -480,15 +490,10 @@ static int set_user(struct cred *new)
         * failure to the execve() stage.
         */
        if (is_ucounts_overlimit(new->ucounts, UCOUNT_RLIMIT_NPROC, rlimit(RLIMIT_NPROC)) &&
-                       new_user != INIT_USER &&
-                       !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
+                       new->user != INIT_USER)
                current->flags |= PF_NPROC_EXCEEDED;
        else
                current->flags &= ~PF_NPROC_EXCEEDED;
-
-       free_uid(new->user);
-       new->user = new_user;
-       return 0;
 }
 
 /*
@@ -563,6 +568,7 @@ long __sys_setreuid(uid_t ruid, uid_t euid)
        if (retval < 0)
                goto error;
 
+       flag_nproc_exceeded(new);
        return commit_creds(new);
 
 error:
@@ -625,6 +631,7 @@ long __sys_setuid(uid_t uid)
        if (retval < 0)
                goto error;
 
+       flag_nproc_exceeded(new);
        return commit_creds(new);
 
 error:
@@ -704,6 +711,7 @@ long __sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)
        if (retval < 0)
                goto error;
 
+       flag_nproc_exceeded(new);
        return commit_creds(new);
 
 error:
@@ -1847,7 +1855,6 @@ SYSCALL_DEFINE1(umask, int, mask)
 static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
 {
        struct fd exe;
-       struct file *old_exe, *exe_file;
        struct inode *inode;
        int err;
 
@@ -1870,40 +1877,10 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
        if (err)
                goto exit;
 
-       /*
-        * Forbid mm->exe_file change if old file still mapped.
-        */
-       exe_file = get_mm_exe_file(mm);
-       err = -EBUSY;
-       if (exe_file) {
-               struct vm_area_struct *vma;
-
-               mmap_read_lock(mm);
-               for (vma = mm->mmap; vma; vma = vma->vm_next) {
-                       if (!vma->vm_file)
-                               continue;
-                       if (path_equal(&vma->vm_file->f_path,
-                                      &exe_file->f_path))
-                               goto exit_err;
-               }
-
-               mmap_read_unlock(mm);
-               fput(exe_file);
-       }
-
-       err = 0;
-       /* set the new file, lockless */
-       get_file(exe.file);
-       old_exe = xchg(&mm->exe_file, exe.file);
-       if (old_exe)
-               fput(old_exe);
+       err = replace_mm_exe_file(mm, exe.file);
 exit:
        fdput(exe);
        return err;
-exit_err:
-       mmap_read_unlock(mm);
-       fput(exe_file);
-       goto exit;
 }
 
 /*
@@ -1961,13 +1938,6 @@ static int validate_prctl_map_addr(struct prctl_mm_map *prctl_map)
        error = -EINVAL;
 
        /*
-        * @brk should be after @end_data in traditional maps.
-        */
-       if (prctl_map->start_brk <= prctl_map->end_data ||
-           prctl_map->brk <= prctl_map->end_data)
-               goto out;
-
-       /*
         * Neither we should allow to override limits if they set.
         */
        if (check_data_rlimit(rlimit(RLIMIT_DATA), prctl_map->brk,