Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6506763imm; Mon, 23 Jul 2018 20:29:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpduo242+toReL5/E8srYAHyb2O5boQeLmd/dd/6GyXMwqt2FsUo0Q6beWoMB2YiWSoznmMT X-Received: by 2002:a63:24c:: with SMTP id 73-v6mr15024470pgc.252.1532402986988; Mon, 23 Jul 2018 20:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532402986; cv=none; d=google.com; s=arc-20160816; b=uOxL9iWqS+i/EFt+kG0Zg9tCtv3Q6jt3/FNmuA8FbHYc528RsB0khD/zOQI49mlwUF deEshnOmKK9HGScQrdl7yMzCZtmZJ9rJL/G+49qgSaZ2htiSINx/Rn4k9j5DfBO4Fr+X huSfcLgxjHXHzoyhLQE7heU2pbbmxp1q2CpzEkQ5V77KBgMcn0ITSb6DKxZu/IeVE1up NWjfLtctQPhjyAHRQhIwTt67dGrkGC6M+VxVpdgnkq4GbOOUwiBE/W6wB0rfrmZyoIL8 q2gdoH0WaB3bHNWF+GMB97Kx+wTv0sOx1vqPuLm6+gg+hot2H3zPdFHSRRscnl3ztYXq ZuYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=S9Sr5O3YkYjf9aiR50i6CSfh2D7/SgBzUbSa5lslpFY=; b=AxE6y+XK9Z1n/oxXc5XL19SPINbOB2/YlZRzqFhVj3wmqXis+Gd3wfZNCdpKFcd17x mOLooT1Jqn72ufuQmCFZ8ymcfMI8uLrnr3NDFOG0SsTS3z4gdOjFPcswQnOBMaNENuXD 5wHCIGHPhye3n/c1gfe4MNtdhl3bR5X//Nw7F2TT7HVA87Fkgb0upix7wWWJn6UVZlB9 XxQQyKdl0g0YAjVQ/xB30yMnb0oECzbCeTYs7bZqT12IDmHImVaQSGG773WZLVvlrmzw vYQXJEhkSropV4w8ATtYI/sOfEHRzNgKJjDO3qGpGZ7BkHKQ4LvulRtBz8089aMdwvpE iFYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d30-v6si9516474pla.110.2018.07.23.20.29.32; Mon, 23 Jul 2018 20:29:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388373AbeGXEbx (ORCPT + 99 others); Tue, 24 Jul 2018 00:31:53 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:41954 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388085AbeGXEbw (ORCPT ); Tue, 24 Jul 2018 00:31:52 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fhnz2-00032V-Qv; Mon, 23 Jul 2018 21:27:32 -0600 Received: from [97.119.167.31] (helo=x220.int.ebiederm.org) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fhnxP-0008AK-61; Mon, 23 Jul 2018 21:25:51 -0600 From: "Eric W. Biederman" To: Linus Torvalds Cc: Oleg Nesterov , Andrew Morton , linux-kernel@vger.kernel.org, Wen Yang , majiang , "Eric W. Biederman" Date: Mon, 23 Jul 2018 22:24:10 -0500 Message-Id: <20180724032419.20231-11-ebiederm@xmission.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <87efft5ncd.fsf_-_@xmission.com> References: <87efft5ncd.fsf_-_@xmission.com> X-XM-SPF: eid=1fhnxP-0008AK-61;;;mid=<20180724032419.20231-11-ebiederm@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.119.167.31;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18BXOQMa+i1cW0T8v+ZhKxJgZ510kwuq/c= X-SA-Exim-Connect-IP: 97.119.167.31 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa08.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,XMGappySubj_01,XMNoVowels,XMSubLong autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.5 XMGappySubj_01 Very gappy subject * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa08 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa08 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 206 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 3.6 (1.8%), b_tie_ro: 2.8 (1.4%), parse: 0.67 (0.3%), extract_message_metadata: 8 (4.1%), get_uri_detail_list: 1.27 (0.6%), tests_pri_-1000: 4.6 (2.2%), tests_pri_-950: 1.14 (0.6%), tests_pri_-900: 0.92 (0.4%), tests_pri_-400: 18 (8.6%), check_bayes: 17 (8.1%), b_tokenize: 6 (2.7%), b_tok_get_all: 5 (2.7%), b_comp_prob: 1.13 (0.6%), b_tok_touch_all: 2.6 (1.3%), b_finish: 0.64 (0.3%), tests_pri_0: 162 (78.9%), check_dkim_signature: 0.42 (0.2%), check_dkim_adsp: 3.3 (1.6%), tests_pri_500: 3.9 (1.9%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 11/20] signal: Pass pid type into send_sigio_to_task & send_sigurg_to_task 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 in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This information is already present and using it directly simplifies the logic of the code. Signed-off-by: "Eric W. Biederman" --- fs/fcntl.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/fs/fcntl.c b/fs/fcntl.c index 1523588fd759..5d596a00f40b 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -723,7 +723,7 @@ static inline int sigio_perm(struct task_struct *p, static void send_sigio_to_task(struct task_struct *p, struct fown_struct *fown, - int fd, int reason, int group) + int fd, int reason, enum pid_type type) { /* * F_SETSIG can change ->signum lockless in parallel, make @@ -767,11 +767,11 @@ static void send_sigio_to_task(struct task_struct *p, else si.si_band = mangle_poll(band_table[reason - POLL_IN]); si.si_fd = fd; - if (!do_send_sig_info(signum, &si, p, group)) + if (!do_send_sig_info(signum, &si, p, type != PIDTYPE_PID)) break; /* fall-through: fall back on the old plain SIGIO signal */ case 0: - do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, group); + do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, type != PIDTYPE_PID); } } @@ -780,14 +780,10 @@ void send_sigio(struct fown_struct *fown, int fd, int band) struct task_struct *p; enum pid_type type; struct pid *pid; - int group = 1; read_lock(&fown->lock); type = fown->pid_type; - if (type == PIDTYPE_PID) - group = 0; - pid = fown->pid; if (!pid) goto out_unlock_fown; @@ -795,12 +791,12 @@ void send_sigio(struct fown_struct *fown, int fd, int band) if (type <= PIDTYPE_TGID) { rcu_read_lock(); p = pid_task(pid, PIDTYPE_PID); - send_sigio_to_task(p, fown, fd, band, group); + send_sigio_to_task(p, fown, fd, band, type); rcu_read_unlock(); } else { read_lock(&tasklist_lock); do_each_pid_task(pid, type, p) { - send_sigio_to_task(p, fown, fd, band, group); + send_sigio_to_task(p, fown, fd, band, type); } while_each_pid_task(pid, type, p); read_unlock(&tasklist_lock); } @@ -809,10 +805,10 @@ void send_sigio(struct fown_struct *fown, int fd, int band) } static void send_sigurg_to_task(struct task_struct *p, - struct fown_struct *fown, int group) + struct fown_struct *fown, enum pid_type type) { if (sigio_perm(p, fown, SIGURG)) - do_send_sig_info(SIGURG, SEND_SIG_PRIV, p, group); + do_send_sig_info(SIGURG, SEND_SIG_PRIV, p, type != PIDTYPE_PID); } int send_sigurg(struct fown_struct *fown) @@ -820,15 +816,11 @@ int send_sigurg(struct fown_struct *fown) struct task_struct *p; enum pid_type type; struct pid *pid; - int group = 1; int ret = 0; read_lock(&fown->lock); type = fown->pid_type; - if (type == PIDTYPE_PID) - group = 0; - pid = fown->pid; if (!pid) goto out_unlock_fown; @@ -838,12 +830,12 @@ int send_sigurg(struct fown_struct *fown) if (type <= PIDTYPE_TGID) { rcu_read_lock(); p = pid_task(pid, PIDTYPE_PID); - send_sigurg_to_task(p, fown, group); + send_sigurg_to_task(p, fown, type); rcu_read_unlock(); } else { read_lock(&tasklist_lock); do_each_pid_task(pid, type, p) { - send_sigurg_to_task(p, fown, group); + send_sigurg_to_task(p, fown, type); } while_each_pid_task(pid, type, p); read_unlock(&tasklist_lock); } -- 2.17.1