Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6506303imm; Mon, 23 Jul 2018 20:28:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeWxkTX3ZVOfNBt1VgcveUUdUYcwK6QRqYe0OuiA8MapVTKQAlPWrXf/tqEfgGQClIZiQwA X-Received: by 2002:a17:902:708b:: with SMTP id z11-v6mr15040216plk.262.1532402939552; Mon, 23 Jul 2018 20:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532402939; cv=none; d=google.com; s=arc-20160816; b=FJTsouOwfrUg9lWwOowlEkzCHVZm+vLm/kgPOqcQV4WoQ7dbxWMBfqJVLrDlfzTZ4F 0qksumP5RzKbUcSSGXF/9ccKnXBDT+CQAH0aMoYkTnTEFAptVcHsNOlzMyo7WufyxPsZ tDWkBRy4uBCLqXxwG7t1qjRf2fFP6c2/7neAqIZUSRTFPHZexk991ojNd8yUdE16jMkt pVsg8HTL//ebudmgvRX3ghFNKK4gtBSg8W1AvFNl4GsMphgu0RWmTZsdkQeDDZetClbG nSjmtOiV1sWxqCNx3T+TI4ciAAzNLBLTJM4K777/ldyr0y1E5Ux2d/cug6a0YhjWeAA8 V1Ow== 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=D6UOz231hDoat1K0Nfml33i7LvR9Kq+CQKUl1xIJtGE=; b=Nq3K9Wku+og1CuAgghcPAD4plZ1twOskxDlN8rul6Uc3BURdcquD8c0MtDaJe0ocoi xnnE17lvSnTlWKpyF84M5jqaYxJ1zk44lFjvzq1CMI553IwXBWzig+O2w1kNDKNRr0Np ENzxVTHexg9I5qBrO/XSHi4d38oBY7TV8/UYlivSNS72NQ2KZ76SpKFpGrEW+bGctfQA ugjdOZUGN6ANL7TG904ToNOcNQTY0Z0wkDrPxVMC250/7t5/ScPHMWzgf2vjishdyjvB iXwF8HbYq3MCnCd82TCi4b6UVNwbZu4pFqefOSH0+/Dt5K9gqUj/kqUAIbawFkufSUi9 8u/g== 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 x4-v6si9214405pln.487.2018.07.23.20.28.45; Mon, 23 Jul 2018 20:28:59 -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 S2388522AbeGXEcA (ORCPT + 99 others); Tue, 24 Jul 2018 00:32:00 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:58874 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388391AbeGXEby (ORCPT ); Tue, 24 Jul 2018 00:31:54 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fhnz5-0005px-Ng; Mon, 23 Jul 2018 21:27:35 -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 1fhnxR-0008AK-Cl; Mon, 23 Jul 2018 21:25:54 -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:11 -0500 Message-Id: <20180724032419.20231-12-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=1fhnxR-0008AK-Cl;;;mid=<20180724032419.20231-12-ebiederm@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.119.167.31;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19HXzQ6CKVE4dsiA+nHfKC3ld4spwDbPvM= 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 sa05.xmission.com X-Spam-Level: * X-Spam-Status: No, score=1.8 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,XMGappySubj_01,XMNoVowels 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.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 * [sa05 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa05 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 349 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.2 (0.9%), b_tie_ro: 2.3 (0.6%), parse: 1.47 (0.4%), extract_message_metadata: 19 (5.3%), get_uri_detail_list: 4.5 (1.3%), tests_pri_-1000: 8 (2.4%), tests_pri_-950: 1.61 (0.5%), tests_pri_-900: 1.37 (0.4%), tests_pri_-400: 31 (9.0%), check_bayes: 30 (8.6%), b_tokenize: 15 (4.2%), b_tok_get_all: 8 (2.2%), b_comp_prob: 2.7 (0.8%), b_tok_touch_all: 3.2 (0.9%), b_finish: 0.70 (0.2%), tests_pri_0: 271 (77.6%), check_dkim_signature: 0.65 (0.2%), check_dkim_adsp: 3.7 (1.0%), tests_pri_500: 8 (2.2%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 12/20] signal: Pass pid type into do_send_sig_info 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 passes the information we already have at the call sight into do_send_sig_info. Ultimately allowing for better handling of signals sent to a group of processes during fork. Signed-off-by: "Eric W. Biederman" --- drivers/tty/sysrq.c | 2 +- fs/fcntl.c | 6 +++--- include/linux/signal.h | 2 +- kernel/signal.c | 10 +++++----- mm/oom_kill.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 6364890575ec..06ed20dd01ba 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -348,7 +348,7 @@ static void send_sig_all(int sig) if (is_global_init(p)) continue; - do_send_sig_info(sig, SEND_SIG_FORCED, p, true); + do_send_sig_info(sig, SEND_SIG_FORCED, p, PIDTYPE_MAX); } read_unlock(&tasklist_lock); } diff --git a/fs/fcntl.c b/fs/fcntl.c index 5d596a00f40b..a04accf6847f 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -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, type != PIDTYPE_PID)) + if (!do_send_sig_info(signum, &si, p, type)) break; /* fall-through: fall back on the old plain SIGIO signal */ case 0: - do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, type != PIDTYPE_PID); + do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, type); } } @@ -808,7 +808,7 @@ static void send_sigurg_to_task(struct task_struct *p, struct fown_struct *fown, enum pid_type type) { if (sigio_perm(p, fown, SIGURG)) - do_send_sig_info(SIGURG, SEND_SIG_PRIV, p, type != PIDTYPE_PID); + do_send_sig_info(SIGURG, SEND_SIG_PRIV, p, type); } int send_sigurg(struct fown_struct *fown) diff --git a/include/linux/signal.h b/include/linux/signal.h index d8f2bf3d41e6..fe125b0335f7 100644 --- a/include/linux/signal.h +++ b/include/linux/signal.h @@ -258,7 +258,7 @@ enum pid_type; extern int next_signal(struct sigpending *pending, sigset_t *mask); extern int do_send_sig_info(int sig, struct siginfo *info, - struct task_struct *p, bool group); + struct task_struct *p, enum pid_type type); extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p, enum pid_type type); extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *); diff --git a/kernel/signal.c b/kernel/signal.c index c7527338fe9d..2c09e6143dd8 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1161,13 +1161,13 @@ specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t) } int do_send_sig_info(int sig, struct siginfo *info, struct task_struct *p, - bool group) + enum pid_type type) { unsigned long flags; int ret = -ESRCH; if (lock_task_sighand(p, &flags)) { - ret = send_signal(sig, info, p, group); + ret = send_signal(sig, info, p, type != PIDTYPE_PID); unlock_task_sighand(p, &flags); } @@ -1284,7 +1284,7 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p, rcu_read_unlock(); if (!ret && sig) - ret = do_send_sig_info(sig, info, p, true); + ret = do_send_sig_info(sig, info, p, type); return ret; } @@ -1448,7 +1448,7 @@ int send_sig_info(int sig, struct siginfo *info, struct task_struct *p) if (!valid_signal(sig)) return -EINVAL; - return do_send_sig_info(sig, info, p, false); + return do_send_sig_info(sig, info, p, PIDTYPE_PID); } #define __si_special(priv) \ @@ -3199,7 +3199,7 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info) * probe. No signal is actually delivered. */ if (!error && sig) { - error = do_send_sig_info(sig, info, p, false); + error = do_send_sig_info(sig, info, p, PIDTYPE_PID); /* * If lock_task_sighand() failed we pretend the task * dies after receiving the signal. The window is tiny, diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 84081e77bc51..2cc9b238368f 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -920,7 +920,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message) * in order to prevent the OOM victim from depleting the memory * reserves from the user space under its control. */ - do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, true); + do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, PIDTYPE_TGID); mark_oom_victim(victim); pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n", task_pid_nr(victim), victim->comm, K(victim->mm->total_vm), @@ -958,7 +958,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message) */ if (unlikely(p->flags & PF_KTHREAD)) continue; - do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, true); + do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, PIDTYPE_TGID); } rcu_read_unlock(); -- 2.17.1