Received: by 10.223.176.46 with SMTP id f43csp4698659wra; Tue, 23 Jan 2018 13:11:01 -0800 (PST) X-Google-Smtp-Source: AH8x226kxZ0nkFW2OAVzJP67+EI9MaCJqHXVng3518nT9raim783csRqsMQADVvIR/lmyB8yEGVz X-Received: by 10.107.47.92 with SMTP id j89mr5427072ioo.222.1516741861219; Tue, 23 Jan 2018 13:11:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516741861; cv=none; d=google.com; s=arc-20160816; b=GlZP4S7Fc/veBUVQrdap3bLzrrFiQMvSlqd7S92PB5c5RtF3GoeB5/J0S1mfIU36BY 2kTAC/uvkQ+AG6M6Dj1DSWj1kJ1ZMhtwT/2dCB22BadKyMZmt7y+aPIPwV4fL5gMc7sQ lzD05+W7rmXqjUqAjl0Xp/9RpJeBA9t9HiChOXSNrVxQYh8MmAToc916Vn39inWTfnt0 kgCvb+qAoxgYQ+DrEbbv4FpsEZ0AlT2+KfkRwGEsLveOtLVdEZQKswdS53kslUYhd93M JQFwgFsex8x9RpcNT8CiRt+5SVgFz2EdfLqINwn47Lq3EnrUz/fpKqp+/mDuLCszd42b 0Kzw== 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=Z2KAQ+Qgfv3k6urEQR3qocM1WeGvKISxtE+mWbsZ/8M=; b=HrLSxVwZ9/oRy1nFPRiaW7L10wUKcZy8Fne/uH4gnUf4foWoUy3BKVZdr4OklgHHS0 yWsdhfJDbXsaiNd5GQPU1fhW8S/pPKoRzPucXVCCLVRPsIte6xDIjR4CT4DtzSfHBAQo Eily5ldhdYmavHg4kLHB2sMkJ8i3EYjhNB1hol5s8+HIyn/j06AjjshBJX6iCLCRFYBi oQE9C9Gd8sgA5bnj109gIF+6MvoqInupMzpj5IwhnT2BnIeUaQbb+a6VPfUCioE0vJkk 7/udn6hF9ysA6mNNnk7RRclwytF61X8wgXXHJBcE5lpmsLulni7X8SH3ozRl8Yk2oWDG yf3Q== 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 i202si9116717iti.130.2018.01.23.13.10.47; Tue, 23 Jan 2018 13:11:01 -0800 (PST) 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 S932282AbeAWVJL (ORCPT + 99 others); Tue, 23 Jan 2018 16:09:11 -0500 Received: from out03.mta.xmission.com ([166.70.13.233]:51899 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932195AbeAWVJI (ORCPT ); Tue, 23 Jan 2018 16:09:08 -0500 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 1ee5oZ-0001Pn-In; Tue, 23 Jan 2018 14:09:07 -0700 Received: from 97-121-88-104.omah.qwest.net ([97.121.88.104] 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 1ee5oX-0003u7-Qg; Tue, 23 Jan 2018 14:09:07 -0700 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: Al Viro , Oleg Nesterov , linux-arch@vger.kernel.org, Ram Pai , "Eric W. Biederman" Date: Tue, 23 Jan 2018 15:07:14 -0600 Message-Id: <20180123210719.10456-5-ebiederm@xmission.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <87607s5lra.fsf_-_@xmission.com> References: <87607s5lra.fsf_-_@xmission.com> X-XM-SPF: eid=1ee5oX-0003u7-Qg;;;mid=<20180123210719.10456-5-ebiederm@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.121.88.104;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19dL7nssedaF7XNhPXgdJCXeBVWsW4qVao= X-SA-Exim-Connect-IP: 97.121.88.104 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa07.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TVD_RCVD_IP,T_TooManySym_01,XMNoVowels,XMSubLong autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 1273 ms - load_scoreonly_sql: 0.03 (0.0%), signal_user_changed: 2.5 (0.2%), b_tie_ro: 1.70 (0.1%), parse: 0.80 (0.1%), extract_message_metadata: 11 (0.8%), get_uri_detail_list: 1.84 (0.1%), tests_pri_-1000: 6 (0.5%), tests_pri_-950: 1.24 (0.1%), tests_pri_-900: 1.02 (0.1%), tests_pri_-400: 22 (1.7%), check_bayes: 21 (1.7%), b_tokenize: 8 (0.6%), b_tok_get_all: 6 (0.5%), b_comp_prob: 1.95 (0.2%), b_tok_touch_all: 3.0 (0.2%), b_finish: 0.58 (0.0%), tests_pri_0: 1221 (95.8%), check_dkim_signature: 0.55 (0.0%), check_dkim_adsp: 2.5 (0.2%), tests_pri_500: 6 (0.4%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 05/10] signal: Add send_sig_fault and force_sig_fault 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 The vast majority of signals sent from architecture specific code are simple faults. Encapsulate this reality with two helper functions so that the nit-picky implementation of preparing a siginfo does not need to be repeated many times on each architecture. As only some architectures support the trapno field, make the trapno arguement only present on those architectures. Similary as ia64 has three fields: imm, flags, and isr that are specific to it. Have those arguments always present on ia64 and no where else. This ensures the architecture specific code always remembers which fields it needs to pass into the siginfo structure. Signed-off-by: "Eric W. Biederman" --- include/linux/sched/signal.h | 20 +++++++++++++++++++ kernel/signal.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index 0aa4548fb492..375f31eb3b6b 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -285,6 +285,26 @@ static inline void kernel_signal_stop(void) schedule(); } +#ifdef __ARCH_SI_TRAPNO +# define ___ARCH_SI_TRAPNO(_a1) , _a1 +#else +# define ___ARCH_SI_TRAPNO(_a1) +#endif +#ifdef __ia64__ +# define ___ARCH_SI_IA64(_a1, _a2, _a3) , _a1, _a2, _a3 +#else +# define ___ARCH_SI_IA64(_a1, _a2, _a3) +#endif + +int force_sig_fault(int sig, int code, void __user *addr + ___ARCH_SI_TRAPNO(int trapno) + ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) + , struct task_struct *t); +int send_sig_fault(int sig, int code, void __user *addr + ___ARCH_SI_TRAPNO(int trapno) + ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) + , struct task_struct *t); + extern int send_sig_info(int, struct siginfo *, struct task_struct *); extern int force_sigsegv(int, struct task_struct *); extern int force_sig_info(int, struct siginfo *, struct task_struct *); diff --git a/kernel/signal.c b/kernel/signal.c index f14492ff976f..15ec7b3cbe69 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1491,6 +1491,53 @@ force_sigsegv(int sig, struct task_struct *p) return 0; } +int force_sig_fault(int sig, int code, void __user *addr + ___ARCH_SI_TRAPNO(int trapno) + ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) + , struct task_struct *t) +{ + struct siginfo info; + + clear_siginfo(&info); + info.si_signo = sig; + info.si_errno = 0; + info.si_code = code; + info.si_addr = addr; +#ifdef __ARCH_SI_TRAPNO + info.si_trapno = trapno; +#endif +#ifdef __ia64__ + info.si_imm = imm; + info.si_flags = flags; + info.si_isr = isr; +#endif + return force_sig_info(info.si_signo, &info, t); +} + +int send_sig_fault(int sig, int code, void __user *addr + ___ARCH_SI_TRAPNO(int trapno) + ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) + , struct task_struct *t) +{ + struct siginfo info; + + clear_siginfo(&info); + info.si_signo = sig; + info.si_errno = 0; + info.si_code = code; + info.si_addr = addr; +#ifdef __ARCH_SI_TRAPNO + info.si_trapno = trapno; +#endif +#ifdef __ia64__ + info.si_imm = imm; + info.si_flags = flags; + info.si_isr = isr; +#endif + return send_sig_info(info.si_signo, &info, t); +} + + int kill_pgrp(struct pid *pid, int sig, int priv) { int ret; -- 2.14.1