Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751681AbdFFTMD (ORCPT ); Tue, 6 Jun 2017 15:12:03 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:57533 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbdFFTMB (ORCPT ); Tue, 6 Jun 2017 15:12:01 -0400 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, Linus Torvalds , Oleg Nesterov , Ingo Molnar , Thomas Gleixner , Kees Cook , Roland McGrath , Al Viro , David Howells , "Michael Kerrisk (man-pages)" , "Eric W. Biederman" Date: Tue, 6 Jun 2017 14:03:18 -0500 Message-Id: <20170606190338.28347-6-ebiederm@xmission.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170606190338.28347-1-ebiederm@xmission.com> References: <877f0pym71.fsf@xmission.com> <20170606190338.28347-1-ebiederm@xmission.com> X-XM-SPF: eid=1dIJtR-0006wd-T8;;;mid=<20170606190338.28347-6-ebiederm@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.121.81.159;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19L7U7rRUygLrODc7FDrC/Z+/nQqjuI9ak= X-SA-Exim-Connect-IP: 97.121.81.159 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa04 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 5546 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.5 (0.1%), b_tie_ro: 2.4 (0.0%), parse: 1.44 (0.0%), extract_message_metadata: 16 (0.3%), get_uri_detail_list: 1.44 (0.0%), tests_pri_-1000: 9 (0.2%), tests_pri_-950: 1.71 (0.0%), tests_pri_-900: 1.42 (0.0%), tests_pri_-400: 22 (0.4%), check_bayes: 21 (0.4%), b_tokenize: 8 (0.1%), b_tok_get_all: 6 (0.1%), b_comp_prob: 2.2 (0.0%), b_tok_touch_all: 3.0 (0.1%), b_finish: 0.73 (0.0%), tests_pri_0: 147 (2.7%), check_dkim_signature: 0.55 (0.0%), check_dkim_adsp: 3.2 (0.1%), tests_pri_500: 5338 (96.3%), poll_dns_idle: 5332 (96.2%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 06/26] rlimit: Remove unnecessary grab of tasklist_lock X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1187 Lines: 41 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" --- 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