Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp238153imm; Thu, 10 May 2018 19:33:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrOSIg9PwTQieOtkgGUAJ+XZhMHXusUaosvj6zXy55RBprnzb1iq9b864JnmIMxzHWq1CCi X-Received: by 2002:a17:902:7e4a:: with SMTP id a10-v6mr3718413pln.276.1526005988449; Thu, 10 May 2018 19:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526005988; cv=none; d=google.com; s=arc-20160816; b=sKom/3Y09Zl2VH5WX6bEHsj8e1nRaVyQ+6ymEpLoULZTouzgY0WtjrM5/d8Ok64Z9u L7sfgaN4AMZlTCqzanldIwrK8vIInVlsy8IgOiqym2WH9smPvQjSzGiTDQYVCWI4RdGB gKywrEWXe/PR8PlBkVkTZopPDHR7bis9Rj+xezmurcd/GUNrqzDE1qhykrZ1aPIXYnM+ nHtUMS9rLQhREEuzCqn29/dbwDseGfuh+1UehY6fh+KmD22P1s28nJdicJujV9yIdXDP cYBWU/iALebgQaQAJ8oi0QxEqYSZR3LpDserMgUKKiyGgj1xjmTHujBipxjT/V9sVeOt Gdng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=vG3nvoAZGSxJatQd8VSztA/P9N1l+a9dIOa1IdpXTgI=; b=aEEMGEajRKmUUeHnT4xzLHbBA6kFlh/y0XvmY44JiodM3gB0pNZ4F89+BJhDZB9EqR 9t5TWUVMjtavoByxrp66n4pji+0n0RHi/eRVU4VqwDsZJ3AqpCvjeUE67FAkoTuFuOGp d8qBVRsrI/zEOIBRP72wZVLrISexEvTj/4wF06wa9NxF937q8xbCz5XBmz8mb3aZ6eE/ r24EmUIK2VPGsE7C5ZCrcmvRs3tJx0Z4X5pvy0+rqZculzdyVuFj8wi4TEDxfje3oeM2 yZdTJ8dA0NrDL6NMvUhgHbWrcHT1s/18C9GEF5g3d5RURQBgAjcz+ml71N7VpVC0Qs+G tLoQ== 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 y15-v6si1895060pgr.98.2018.05.10.19.32.53; Thu, 10 May 2018 19:33: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 S1752170AbeEKCbS (ORCPT + 99 others); Thu, 10 May 2018 22:31:18 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:36442 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751904AbeEKCbO (ORCPT ); Thu, 10 May 2018 22:31:14 -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 1fGxpx-0004gr-Bi; Thu, 10 May 2018 20:31:13 -0600 Received: from [97.90.247.198] (helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fGxpv-00043G-LM; Thu, 10 May 2018 20:31:13 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Matt Redfearn Cc: , , Ralf Baechle , James Hogan , References: <87604mhrnb.fsf@xmission.com> <20180420143811.9994-8-ebiederm@xmission.com> <8736z0s087.fsf@xmission.com> <6811e06d-ac0d-35a6-7d86-57838d5d7f8e@mips.com> Date: Thu, 10 May 2018 21:31:06 -0500 In-Reply-To: <6811e06d-ac0d-35a6-7d86-57838d5d7f8e@mips.com> (Matt Redfearn's message of "Thu, 10 May 2018 08:59:26 +0100") Message-ID: <87603uordh.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1fGxpv-00043G-LM;;;mid=<87603uordh.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.90.247.198;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/G3kHU/VtO4wj28jvOhsdLgSc3TS+8TqY= X-SA-Exim-Connect-IP: 97.90.247.198 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa04.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 TR_Symld_Words too many words that have symbols inside * 1.5 XMNoVowels Alpha-numberic number with no vowels * 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 * [sa04 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; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ***;Matt Redfearn X-Spam-Relay-Country: X-Spam-Timing: total 1179 ms - load_scoreonly_sql: 0.06 (0.0%), signal_user_changed: 2.5 (0.2%), b_tie_ro: 1.69 (0.1%), parse: 1.01 (0.1%), extract_message_metadata: 19 (1.7%), get_uri_detail_list: 2.9 (0.2%), tests_pri_-1000: 9 (0.7%), tests_pri_-950: 1.24 (0.1%), tests_pri_-900: 0.97 (0.1%), tests_pri_-400: 26 (2.2%), check_bayes: 25 (2.1%), b_tokenize: 9 (0.8%), b_tok_get_all: 9 (0.7%), b_comp_prob: 2.6 (0.2%), b_tok_touch_all: 3.1 (0.3%), b_finish: 0.54 (0.0%), tests_pri_0: 252 (21.4%), check_dkim_signature: 0.66 (0.1%), check_dkim_adsp: 3.0 (0.3%), tests_pri_500: 864 (73.3%), poll_dns_idle: 851 (72.2%), rewrite_mail: 0.00 (0.0%) Subject: Re: [REVIEW][PATCH 08/22] signal/mips: 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 in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Matt Redfearn writes: > Hi Eric, > > On 10/05/18 03:39, Eric W. Biederman wrote: >> Matt Redfearn writes: >> >>> Hi Eric, >>> >>> On 20/04/18 15:37, Eric W. Biederman wrote: >>>> 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: Ralf Baechle >>>> Cc: James Hogan >>>> Cc: linux-mips@linux-mips.org >>>> Signed-off-by: "Eric W. Biederman" >>>> --- >>>> arch/mips/kernel/traps.c | 65 ++++++++++++++---------------------------------- >>>> arch/mips/mm/fault.c | 19 ++++---------- >>>> 2 files changed, 23 insertions(+), 61 deletions(-) >>>> >>>> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c >>>> index 967e9e4e795e..66ec4b0b484d 100644 >>>> --- a/arch/mips/kernel/traps.c >>>> +++ b/arch/mips/kernel/traps.c >>>> @@ -699,17 +699,11 @@ static int simulate_sync(struct pt_regs *regs, unsigned int opcode) >>>> asmlinkage void do_ov(struct pt_regs *regs) >>>> { >>>> enum ctx_state prev_state; >>>> - siginfo_t info; >>>> - >>>> - clear_siginfo(&info); >>>> - info.si_signo = SIGFPE; >>>> - info.si_code = FPE_INTOVF; >>>> - info.si_addr = (void __user *)regs->cp0_epc; >>>> prev_state = exception_enter(); >>>> die_if_kernel("Integer overflow", regs); >>>> - force_sig_info(SIGFPE, &info, current); >>>> + force_sig_fault(SIGFPE, FPE_INTOVF, (void __user *)regs->cp0_epc, current); >>>> exception_exit(prev_state); >>>> } >>>> @@ -722,32 +716,27 @@ asmlinkage void do_ov(struct pt_regs *regs) >>>> void force_fcr31_sig(unsigned long fcr31, void __user *fault_addr, >>>> struct task_struct *tsk) >>>> { >>>> - struct siginfo si; >>>> - >>>> - clear_siginfo(&si); >>>> - si.si_addr = fault_addr; >>>> - si.si_signo = SIGFPE; >>>> + int si_code; >>> >>> This is giving build errors in Linux next >>> (https://storage.kernelci.org/next/master/next-20180509/mips/defconfig+kselftest/build.log) >>> >>> si_code would have ended up as 0 before from the clear_siginfo(), but perhaps >> >> And si_code 0 is not a valid si_code to use with a floating point >> siginfo layout. >> >>> int si_code = FPE_FLTUNK; >>> >>> Would make a more sensible default? >> >> FPE_FLTUNK would make a more sensible default. >> >> I seem to remember someone telling me that case can never happen in >> practice so I have simply not worried about it. Perhaps I am >> misremembering this. > > It probably can't happen in practise - but the issue is that the > kernel doesn't even compile because -Werror=maybe-uninitialized > results in a build error since the compiler can't know that one of the > branches will definitely be taken to set si_code. My cross compile work. So I don't know where that -Werror=maybe-unitialized comes from. I agree it is an issue. I agree that FPE_FLTUNK is one of the good solutions. Another is to add a final else where you return without doing anything. Right now this looks like mips people issue that I have unearthed. I could appreciate some guidance on which way mips folks would like to handle this. If you can point me to where the fatal error is coming from I will definitely do something in my tree so that this is not a harmful issue. Eric