Thread (33 messages) 33 messages, 5 authors, 2017-06-07
STALE3338d

[PATCH 06/26] rlimit: Remove unnecessary grab of tasklist_lock

From: Eric W. Biederman <hidden>
Date: 2017-06-06 19:12:03
Also in: lkml
Subsystem: the rest · Maintainer: Linus Torvalds

There is no reason to take the tasklist lock here.  The sighand
structure is never referenced and and tsk->signal is guaranteed
to stick around until tsk is freed. Further update_rlimit_cpu
does not need the tasklist_lock.  And the rlim_lock is used
to guarantee mutual exclusion.

Signed-off-by: "Eric W. Biederman" <redacted>
---
 kernel/sys.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/kernel/sys.c b/kernel/sys.c
index 8a94b4eabcaa..705f14b28134 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1380,13 +1380,6 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
 			return -EPERM;
 	}
 
-	/* protect tsk->signal and tsk->sighand from disappearing */
-	read_lock(&tasklist_lock);
-	if (!tsk->sighand) {
-		retval = -ESRCH;
-		goto out;
-	}
-
 	rlim = tsk->signal->rlim + resource;
 	task_lock(tsk->group_leader);
 	if (new_rlim) {
@@ -1425,8 +1418,7 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
 	     new_rlim->rlim_cur != RLIM_INFINITY &&
 	     IS_ENABLED(CONFIG_POSIX_TIMERS))
 		update_rlimit_cpu(tsk, new_rlim->rlim_cur);
-out:
-	read_unlock(&tasklist_lock);
+
 	return retval;
 }
 
-- 
2.10.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help