From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932825AbeAXUzJ (ORCPT ); Wed, 24 Jan 2018 15:55:09 -0500 Received: from out02.mta.xmission.com ([166.70.13.232]:43979 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932507AbeAXUzG (ORCPT ); Wed, 24 Jan 2018 15:55:06 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: Ram Pai Cc: linux-kernel@vger.kernel.org, Al Viro , Oleg Nesterov , linux-arch@vger.kernel.org References: <87607s5lra.fsf_-_@xmission.com> <20180123210719.10456-6-ebiederm@xmission.com> <20180124192632.GA6671@ram.oc3035372033.ibm.com> Date: Wed, 24 Jan 2018 14:54:06 -0600 In-Reply-To: <20180124192632.GA6671@ram.oc3035372033.ibm.com> (Ram Pai's message of "Wed, 24 Jan 2018 11:26:32 -0800") Message-ID: <87zi53x9jl.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=1eeS4W-0008D7-MQ;;;mid=<87zi53x9jl.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.121.88.104;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+Eamai+Kdmu4IOseemXaB7ByJ9zraPhOc= X-SA-Exim-Connect-IP: 97.121.88.104 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 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.4522] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Ram Pai X-Spam-Relay-Country: X-Spam-Timing: total 230 ms - load_scoreonly_sql: 0.11 (0.0%), signal_user_changed: 3.4 (1.5%), b_tie_ro: 2.3 (1.0%), parse: 1.33 (0.6%), extract_message_metadata: 13 (5.6%), get_uri_detail_list: 2.3 (1.0%), tests_pri_-1000: 6 (2.6%), tests_pri_-950: 1.30 (0.6%), tests_pri_-900: 1.06 (0.5%), tests_pri_-400: 22 (9.7%), check_bayes: 21 (9.3%), b_tokenize: 7 (2.9%), b_tok_get_all: 7 (3.2%), b_comp_prob: 2.4 (1.1%), b_tok_touch_all: 3.0 (1.3%), b_finish: 0.59 (0.3%), tests_pri_0: 173 (75.2%), check_dkim_signature: 0.60 (0.3%), check_dkim_adsp: 2.6 (1.1%), tests_pri_500: 5.0 (2.2%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 06/10] signal: Helpers for faults with specialized siginfo layouts 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ram Pai writes: > On Tue, Jan 23, 2018 at 03:07:15PM -0600, Eric W. Biederman wrote: >> The helpers added are: >> send_sig_mceerr >> force_sig_mceerr >> force_sig_bnderr >> force_sig_pkuerr >> >> Filling out siginfo properly can ge tricky. Especially for these >> specialized cases where the temptation is to share code with other >> cases which use a different subset of siginfo fields. Unfortunately >> that code sharing frequently results in bugs with the wrong siginfo >> fields filled in, and makes it harder to verify that the siginfo >> structure was properly initialized. >> >> Provide these helpers instead that get all of the details right, and >> guarantee that siginfo is properly initialized. >> >> send_sig_mceerr and force_sig_mceer are a little special as two si >> codes BUS_MCEERR_AO and BUS_MCEER_AR both use the same extended >> signinfo layout. > > nice. i can make use of these helpers in the memory-key implementation. > > One small nit-pick below though... > >> >> Signed-off-by: "Eric W. Biederman" >> --- >> include/linux/sched/signal.h | 6 +++++ >> kernel/signal.c | 61 ++++++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 67 insertions(+) >> >> diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h > > ...snip.. > >> + >> +#ifdef SEGV_PKUERR > > Should this really be under SEGV_PKUERR ? that macro is defined > unconditionally anyway. Unless you are running my unified siginfo.h (from an earlier patchset which I build upon). It turns out that ia64 has a conflict for that number. So ia64 really can't use the define and this infrastructure. We might decide to sort that out and always have SEGV_PKUERR always defined. Sadly for the moment the #ifdef is necessary. >> +int force_sig_pkuerr(void __user *addr, u32 pkey) >> +{ >> + struct siginfo info; >> + >> + clear_siginfo(&info); >> + info.si_signo = SIGSEGV; >> + info.si_errno = 0; >> + info.si_code = SEGV_PKUERR; >> + info.si_addr = addr; >> + info.si_pkey = pkey; >> + return force_sig_info(info.si_signo, &info, current); >> +} >> +#endif Eric