]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - kernel/sys.c
kernel/sys.c: fix potential Spectre v1 issue
[mirror_ubuntu-bionic-kernel.git] / kernel / sys.c
index d93b55b9e0bbc0e0c0ae0881f52133a7978b13d1..4e0a24b0c14d8b8dba626621662fd1f9ccc01b15 100644 (file)
@@ -1416,6 +1416,7 @@ SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
        if (resource >= RLIM_NLIMITS)
                return -EINVAL;
 
+       resource = array_index_nospec(resource, RLIM_NLIMITS);
        task_lock(current->group_leader);
        x = current->signal->rlim[resource];
        task_unlock(current->group_leader);
@@ -1435,6 +1436,7 @@ COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
        if (resource >= RLIM_NLIMITS)
                return -EINVAL;
 
+       resource = array_index_nospec(resource, RLIM_NLIMITS);
        task_lock(current->group_leader);
        r = current->signal->rlim[resource];
        task_unlock(current->group_leader);