Received: by 10.192.165.148 with SMTP id m20csp345449imm; Fri, 20 Apr 2018 07:43:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Kkw6J9oTjTSZx2J6/NAGRq6U26e105Iy+rUTC7za18D02Du0iyzlM0zTBz8X9U2FNHu4k X-Received: by 10.98.61.84 with SMTP id k81mr10005401pfa.193.1524235388474; Fri, 20 Apr 2018 07:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524235388; cv=none; d=google.com; s=arc-20160816; b=mUwrb+u4PNxNAIvETJ0KJ4ZRplosTFmfW8UcnHNGs44T5RAr9fT0IgxJq31StbQJQv EtNqGRieWH1kbswZehahP31gf48DofZnoD6pquRmO0qseZk6dynFJuOfdhSCMnJDxXC+ LqgjOFkg02nsI/Ivscj2vh0endRSQXCl9zYQ9b0t8+vh16SzaPVH8zmOFK1izVSPEhc+ IoYXCosBXTVXbfBOJsoOjp8b/s1GLuXBqKbbJBqZrMOIDsXw9xTdGjX6hvX8OO68gby4 L2qN2TSRGf266g2CbfqbapuLAvm45eYBab1H9hrCfeO36/Atmg9F/OjB83l9G5paBVlp NNyw== 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=kZjPbdPNIp4/twmY2n4NV3lTSZe4w4iw4pfwYSFNnYM=; b=OeBTGc/TstfwMA+BPGbnCnIzwbqrqYsOj9ydw+Nq1mDa8f4tCfvubLIqYo8EdJjdAA vGAqGjceXI88jSjUCTuaeGX2jYf0+YBIYI940ht7CxegIdRptJ0/OSzEJhD1gvtE4pfD dkE4iHqT2mrjH7YeMhIsQ+YNQGEcDG+MOsX0MHs1SxZOHizC0wG8aWeBRk5X2d9jZoZK riuao/YlveGn+coKx7/8iTblTG4I245BdDRpadf59ppjnGJcUF1LjWnXZaIkXY5Q4cRI I+KcQMldjjTtIRTijaM+gigcpnTn+ADY6SjncglmIvht/voYIOudz+jH1wa9/ihZmEOI 0sXQ== 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 t2si4939862pgb.209.2018.04.20.07.42.53; Fri, 20 Apr 2018 07:43:08 -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 S1755472AbeDTOlc (ORCPT + 99 others); Fri, 20 Apr 2018 10:41:32 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:46256 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755295AbeDTOlF (ORCPT ); Fri, 20 Apr 2018 10:41:05 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1f9XDk-0007Xh-Ox; Fri, 20 Apr 2018 08:41:04 -0600 Received: from [97.119.174.25] (helo=x220.int.ebiederm.org) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1f9XDV-0006Ha-Aj; Fri, 20 Apr 2018 08:41:04 -0600 From: "Eric W. Biederman" To: linux-arch@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Eric W. Biederman" , Greentime Hu , Vincent Chen Date: Fri, 20 Apr 2018 09:37:58 -0500 Message-Id: <20180420143811.9994-9-ebiederm@xmission.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <87604mhrnb.fsf@xmission.com> References: <87604mhrnb.fsf@xmission.com> X-XM-SPF: eid=1f9XDV-0006Ha-Aj;;;mid=<20180420143811.9994-9-ebiederm@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.119.174.25;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18rLsQ50xUZyustg48GN5Qaya9kljWH/bQ= X-SA-Exim-Connect-IP: 97.119.174.25 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=3.6 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TR_Symld_Words,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01, XMNoVowels,XMSolicitRefs_0,XMSubLong autolearn=disabled version=3.4.1 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 * 1.5 TR_Symld_Words too many words that have symbols inside * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 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 * 0.1 XMSolicitRefs_0 Weightloss drug X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ***;linux-arch@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 15023 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 4.9 (0.0%), b_tie_ro: 4.0 (0.0%), parse: 0.79 (0.0%), extract_message_metadata: 10 (0.1%), get_uri_detail_list: 2.3 (0.0%), tests_pri_-1000: 2.7 (0.0%), tests_pri_-950: 1.20 (0.0%), tests_pri_-900: 0.96 (0.0%), tests_pri_-400: 24 (0.2%), check_bayes: 23 (0.2%), b_tokenize: 9 (0.1%), b_tok_get_all: 7 (0.0%), b_comp_prob: 2.00 (0.0%), b_tok_touch_all: 2.9 (0.0%), b_finish: 0.55 (0.0%), tests_pri_0: 230 (1.5%), check_dkim_signature: 0.71 (0.0%), check_dkim_adsp: 3.8 (0.0%), tests_pri_500: 14746 (98.2%), poll_dns_idle: 14738 (98.1%), rewrite_mail: 0.00 (0.0%) Subject: [REVIEW][PATCH 09/22] signal/nds32: Use force_sig_fault where appropriate 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Filling in struct siginfo before calling force_sig_info a tedious and error prone process, where once in a great while the wrong fields are filled out, and siginfo has been inconsistently cleared. Simplify this process by using the helper force_sig_fault. Which takes as a parameters all of the information it needs, ensures all of the fiddly bits of filling in struct siginfo are done properly and then calls force_sig_info. In short about a 5 line reduction in code for every time force_sig_info is called, which makes the calling function clearer. Cc: Greentime Hu Cc: Vincent Chen Signed-off-by: "Eric W. Biederman" --- arch/nds32/kernel/traps.c | 20 ++++---------------- arch/nds32/mm/fault.c | 19 +++++-------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/arch/nds32/kernel/traps.c b/arch/nds32/kernel/traps.c index 46911768f4b5..636d1c7aa895 100644 --- a/arch/nds32/kernel/traps.c +++ b/arch/nds32/kernel/traps.c @@ -222,20 +222,13 @@ void die_if_kernel(const char *str, struct pt_regs *regs, int err) int bad_syscall(int n, struct pt_regs *regs) { - siginfo_t info; - if (current->personality != PER_LINUX) { send_sig(SIGSEGV, current, 1); return regs->uregs[0]; } - clear_siginfo(&info); - info.si_signo = SIGILL; - info.si_errno = 0; - info.si_code = ILL_ILLTRP; - info.si_addr = (void __user *)instruction_pointer(regs) - 4; - - force_sig_info(SIGILL, &info, current); + force_sig_fault(SIGILL, ILL_ILLTRP, + (void __user *)instruction_pointer(regs) - 4, current); die_if_kernel("Oops - bad syscall", regs, n); return regs->uregs[0]; } @@ -288,16 +281,11 @@ void __init early_trap_init(void) void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code, int si_code) { - struct siginfo info; - tsk->thread.trap_no = ENTRY_DEBUG_RELATED; tsk->thread.error_code = error_code; - clear_siginfo(&info); - info.si_signo = SIGTRAP; - info.si_code = si_code; - info.si_addr = (void __user *)instruction_pointer(regs); - force_sig_info(SIGTRAP, &info, tsk); + force_sig_fault(SIGTRAP, si_code + (void __user *)instruction_pointer(regs), tsk); } void do_debug_trap(unsigned long entry, unsigned long addr, diff --git a/arch/nds32/mm/fault.c b/arch/nds32/mm/fault.c index 876ee01ff80a..9bdb7c3ecbb6 100644 --- a/arch/nds32/mm/fault.c +++ b/arch/nds32/mm/fault.c @@ -72,16 +72,15 @@ void do_page_fault(unsigned long entry, unsigned long addr, struct task_struct *tsk; struct mm_struct *mm; struct vm_area_struct *vma; - siginfo_t info; + int si_code; int fault; unsigned int mask = VM_READ | VM_WRITE | VM_EXEC; unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; - clear_siginfo(&info); error_code = error_code & (ITYPE_mskINST | ITYPE_mskETYPE); tsk = current; mm = tsk->mm; - info.si_code = SEGV_MAPERR; + si_code = SEGV_MAPERR; /* * We fault-in kernel-space virtual memory on-demand. The * 'reference' page table is init_mm.pgd. @@ -162,7 +161,7 @@ void do_page_fault(unsigned long entry, unsigned long addr, */ good_area: - info.si_code = SEGV_ACCERR; + si_code = SEGV_ACCERR; /* first do some preliminary protection checks */ if (entry == ENTRY_PTE_NOT_PRESENT) { @@ -267,11 +266,7 @@ void do_page_fault(unsigned long entry, unsigned long addr, tsk->thread.address = addr; tsk->thread.error_code = error_code; tsk->thread.trap_no = entry; - info.si_signo = SIGSEGV; - info.si_errno = 0; - /* info.si_code has been set above */ - info.si_addr = (void *)addr; - force_sig_info(SIGSEGV, &info, tsk); + force_sig_fault(SIGSEGV, si_code, (void __user *)addr, tsk); return; } @@ -340,11 +335,7 @@ void do_page_fault(unsigned long entry, unsigned long addr, tsk->thread.address = addr; tsk->thread.error_code = error_code; tsk->thread.trap_no = entry; - info.si_signo = SIGBUS; - info.si_errno = 0; - info.si_code = BUS_ADRERR; - info.si_addr = (void *)addr; - force_sig_info(SIGBUS, &info, tsk); + force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)addr, tsk); return; -- 2.14.1