mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
CRED: Use RCU to access another task's creds and to release a task's own creds
Use RCU to access another task's creds and to release a task's own creds. This means that it will be possible for the credentials of a task to be replaced without another task (a) requiring a full lock to read them, and (b) seeing deallocated memory. Signed-off-by: David Howells <[email protected]> Acked-by: James Morris <[email protected]> Acked-by: Serge Hallyn <[email protected]> Signed-off-by: James Morris <[email protected]>
This commit is contained in:
parent
86a264abe5
commit
c69e8d9c01
28 changed files with 355 additions and 204 deletions
|
|
@ -1045,7 +1045,7 @@ asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
|
|||
const int __user *nodes,
|
||||
int __user *status, int flags)
|
||||
{
|
||||
struct cred *cred, *tcred;
|
||||
const struct cred *cred = current_cred(), *tcred;
|
||||
struct task_struct *task;
|
||||
struct mm_struct *mm;
|
||||
int err;
|
||||
|
|
@ -1076,14 +1076,16 @@ asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
|
|||
* capabilities, superuser privileges or the same
|
||||
* userid as the target process.
|
||||
*/
|
||||
cred = current->cred;
|
||||
tcred = task->cred;
|
||||
rcu_read_lock();
|
||||
tcred = __task_cred(task);
|
||||
if (cred->euid != tcred->suid && cred->euid != tcred->uid &&
|
||||
cred->uid != tcred->suid && cred->uid != tcred->uid &&
|
||||
!capable(CAP_SYS_NICE)) {
|
||||
rcu_read_unlock();
|
||||
err = -EPERM;
|
||||
goto out;
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
||||
err = security_task_movememory(task);
|
||||
if (err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue