Received: by 10.192.165.148 with SMTP id m20csp145759imm; Thu, 19 Apr 2018 18:10:22 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+9nxYhWiVYhKExHZynB5CbUMx5Ljo3SSWQiLSI+95nafB6kw3xYp3ueO1v0ndS7Pxvw9BG X-Received: by 10.101.65.4 with SMTP id w4mr6642833pgp.181.1524186622196; Thu, 19 Apr 2018 18:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524186622; cv=none; d=google.com; s=arc-20160816; b=WtaUBkxjtBFlS+N3bk5+/fMKytCVRUFe9AUZkQ7tyMgsP8TxG3clTmOcDH6aHVcNwr /sqSQyXhhwMg5MzcFyni2B76Q0IvZjsIgsbnLVCC0rMJ4/q1gOHKHTfPeTgeUC6ef+Bs I0ANOuz9866nzDXArMaTqQ5yFoZ9TqBIgH45YyPJlnUCydxGA0bGGHj+Ql01lBP7/Cjr cDaExXa3CZL/7jQcj9AJ9bXDSNaTapeyTZlyoTpi5y+kTNA+2Lcd3uFb+CBJAURfAxGc AYUacwU9sBXIP68QaCyQqiZGiWsruOPLJ9bUdwoRisISS1GkAtPCMyiEBMSC8lqv2Sx3 KjEw== 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=+dYAoIw7tG2bF1fNKJoSAQ+HDtttK5nxJPgHyyGoJAY=; b=NtP1B0skDPrzlbOphQW4EF9Aw8tjrUMvVqueXgsTwLpW5ALwlpHUjaFPVYjSQxmAY/ UXB7TVMUUtL23drdL4V7ZGSEQ3MR1mbvv5PqaYXfkznQFxcY06CFWtazSO+Uoq4/gzAe tGAPla6n+Tel3tqsEb7bYn11yXuMP9+QGLFnrCS7A5PmtyGU0ilAi4sEcLZ5GifV2eqS YZwH/V7IKJmORDTv4emxlvK1KkTi92nqSV7ba0Iq7l5XASvPwZ8BAa8DC1XB5ri4LWVr pXnEdCkcK5XD0XKnRLND8XD6a/rwSLle0LKqwRbPKWLiP3L+X8BvPaYaleXqY73BhaTo FRxA== 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 b8si1078470pgs.456.2018.04.19.18.10.08; Thu, 19 Apr 2018 18:10:22 -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 S1754129AbeDTBHO (ORCPT + 99 others); Thu, 19 Apr 2018 21:07:14 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:50103 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754111AbeDTBHK (ORCPT ); Thu, 19 Apr 2018 21:07:10 -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 1f9KW5-0006n5-H2; Thu, 19 Apr 2018 19:07:09 -0600 Received: from [97.119.174.25] (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 1f9KW4-00014u-8A; Thu, 19 Apr 2018 19:07:09 -0600 From: "Eric W. Biederman" To: linux-arch@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, "Eric W. Biederman" Date: Thu, 19 Apr 2018 20:03:58 -0500 Message-Id: <20180420010408.24438-7-ebiederm@xmission.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <878t9ilmhv.fsf@xmission.com> References: <878t9ilmhv.fsf@xmission.com> X-XM-SPF: eid=1f9KW4-00014u-8A;;;mid=<20180420010408.24438-7-ebiederm@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.119.174.25;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/WQLWGLuc0FfpoA5VsF5c2b2XKVp4Zb/8= X-SA-Exim-Connect-IP: 97.119.174.25 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sa03.xmission.com X-Spam-Level: ****** X-Spam-Status: No, score=6.2 required=8.0 tests=ALL_TRUSTED,BAYES_40,DCC_CHECK, TR_Symld_Words,T_TooManySym_01,XMGappySubj_01,XMNoVowels,XMSubLong autolearn=disabled version=3.4.0 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 TR_Symld_Words too many words that have symbols inside * 0.5 XMGappySubj_01 Very gappy subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * -0.0 BAYES_40 BODY: Bayes spam probability is 20 to 40% * [score: 0.2837] * 3.0 DCC_CHECK Listed in DCC (http://rhyolite.com/anti-spam/dcc/) * [sa03 1397; Body=1 Fuz1=1 Fuz2=many] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=many X-Spam-Combo: ******;linux-arch@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 832 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 4.1 (0.5%), b_tie_ro: 3.0 (0.4%), parse: 1.41 (0.2%), extract_message_metadata: 28 (3.4%), get_uri_detail_list: 4.9 (0.6%), tests_pri_-1000: 11 (1.3%), tests_pri_-950: 2.5 (0.3%), tests_pri_-900: 1.85 (0.2%), tests_pri_-400: 37 (4.4%), check_bayes: 34 (4.1%), b_tokenize: 15 (1.8%), b_tok_get_all: 8 (1.0%), b_comp_prob: 4.4 (0.5%), b_tok_touch_all: 2.8 (0.3%), b_finish: 0.86 (0.1%), tests_pri_0: 733 (88.1%), check_dkim_signature: 0.95 (0.1%), check_dkim_adsp: 5.0 (0.6%), tests_pri_500: 8 (1.0%), rewrite_mail: 0.00 (0.0%) Subject: [REVIEW][PATCH 07/17] signal: Reduce copy_siginfo_to_user to just copy_to_user 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 Now that every instance of struct siginfo is now initialized it is no longer necessary to copy struct siginfo piece by piece to userspace but instead the entire structure can be copied. As well as making the code simpler and more efficient this means that copy_sinfo_to_user no longer cares which union member of struct siginfo is in use. In practice this means that all 32bit architectures that define FPE_FIXME will handle properly send SI_USER when kill(SIGFPE) is sent. While still performing their historic architectural brokenness when 0 is used a floating pointer signal. This matches the current behavior of 64bit architectures that define FPE_FIXME who get lucky and an overloaded SI_USER has continuted to work through copy_siginfo_to_user because the 8 byte si_addr occupies the same bytes in struct siginfo as the 4 byte si_pid and the 4 byte si_uid. Problematic architectures still need to fix their ABI so that signalfd and 32bit compat code will work properly. Signed-off-by: "Eric W. Biederman" --- kernel/signal.c | 84 ++------------------------------------------------------- 1 file changed, 2 insertions(+), 82 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index d4ccea599692..d56f4d496c89 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2850,89 +2850,9 @@ enum siginfo_layout siginfo_layout(int sig, int si_code) int copy_siginfo_to_user(siginfo_t __user *to, const siginfo_t *from) { - int err; - - if (!access_ok (VERIFY_WRITE, to, sizeof(siginfo_t))) + if (copy_to_user(to, from , sizeof(struct siginfo))) return -EFAULT; - if (from->si_code < 0) - return __copy_to_user(to, from, sizeof(siginfo_t)) - ? -EFAULT : 0; - /* - * If you change siginfo_t structure, please be sure - * this code is fixed accordingly. - * Please remember to update the signalfd_copyinfo() function - * inside fs/signalfd.c too, in case siginfo_t changes. - * It should never copy any pad contained in the structure - * to avoid security leaks, but must copy the generic - * 3 ints plus the relevant union member. - */ - err = __put_user(from->si_signo, &to->si_signo); - err |= __put_user(from->si_errno, &to->si_errno); - err |= __put_user(from->si_code, &to->si_code); - switch (siginfo_layout(from->si_signo, from->si_code)) { - case SIL_KILL: - err |= __put_user(from->si_pid, &to->si_pid); - err |= __put_user(from->si_uid, &to->si_uid); - break; - case SIL_TIMER: - /* Unreached SI_TIMER is negative */ - break; - case SIL_POLL: - err |= __put_user(from->si_band, &to->si_band); - err |= __put_user(from->si_fd, &to->si_fd); - break; - case SIL_FAULT: - err |= __put_user(from->si_addr, &to->si_addr); -#ifdef __ARCH_SI_TRAPNO - err |= __put_user(from->si_trapno, &to->si_trapno); -#endif -#ifdef __ia64__ - err |= __put_user(from->si_imm, &to->si_imm); - err |= __put_user(from->si_flags, &to->si_flags); - err |= __put_user(from->si_isr, &to->si_isr); -#endif - /* - * Other callers might not initialize the si_lsb field, - * so check explicitly for the right codes here. - */ -#ifdef BUS_MCEERR_AR - if (from->si_signo == SIGBUS && from->si_code == BUS_MCEERR_AR) - err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb); -#endif -#ifdef BUS_MCEERR_AO - if (from->si_signo == SIGBUS && from->si_code == BUS_MCEERR_AO) - err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb); -#endif -#ifdef SEGV_BNDERR - if (from->si_signo == SIGSEGV && from->si_code == SEGV_BNDERR) { - err |= __put_user(from->si_lower, &to->si_lower); - err |= __put_user(from->si_upper, &to->si_upper); - } -#endif -#ifdef SEGV_PKUERR - if (from->si_signo == SIGSEGV && from->si_code == SEGV_PKUERR) - err |= __put_user(from->si_pkey, &to->si_pkey); -#endif - break; - case SIL_CHLD: - err |= __put_user(from->si_pid, &to->si_pid); - err |= __put_user(from->si_uid, &to->si_uid); - err |= __put_user(from->si_status, &to->si_status); - err |= __put_user(from->si_utime, &to->si_utime); - err |= __put_user(from->si_stime, &to->si_stime); - break; - case SIL_RT: - err |= __put_user(from->si_pid, &to->si_pid); - err |= __put_user(from->si_uid, &to->si_uid); - err |= __put_user(from->si_ptr, &to->si_ptr); - break; - case SIL_SYS: - err |= __put_user(from->si_call_addr, &to->si_call_addr); - err |= __put_user(from->si_syscall, &to->si_syscall); - err |= __put_user(from->si_arch, &to->si_arch); - break; - } - return err; + return 0; } #ifdef CONFIG_COMPAT -- 2.14.1