Received: by 10.192.165.148 with SMTP id m20csp439189imm; Fri, 20 Apr 2018 09:08:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+wFtaYpIpqkgPS9grwZ+4YIruooAEnobQ8KODoYf+n3EshBNZFH/FkcQlJmtdOCoag3M3g X-Received: by 10.101.101.196 with SMTP id y4mr9035835pgv.129.1524240514808; Fri, 20 Apr 2018 09:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524240514; cv=none; d=google.com; s=arc-20160816; b=dTm6MT/ZSvFotYp6DO6YdCrJIQV2ZAH3wQ67iycdEdExS85d42dhyqxExYnSLtxERP C6wx9oTIxFaPqbJKoMb2YwZnPCdteoX8Q6AlvAxEivwGUAxbsj0MDZSZd3sZh0bogMPo 4YFt84+ou2/CEHKpm5LKbb7JAeOZrWQ8P3qJWz/On14d+N0jZxEYJsSbE9g58A2EPqs6 yQ0i1Uw/gqxJ5PK3YlnKPzd213fRq2NkbQbPxUqxKgiErk6YqlZJqkG4U7wO8v6BKYsx Pfwl31MYE4XQ1DFoi6X1ZtKlaoNmzIMOU9hcY1hiXge3Te7e0BCwFuouKQavGKmK7tc6 JX4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=VyfmZY4qmBxVFFrLOzX2NH9txrMTC0qJbkkF0U5yS+M=; b=Trn0RCoqH4Uu/S1u5ephYx8R10MKlUlJY+6aFiw7eLBPPc7LpTBzo7W6gfHn8MwRI4 mXb1j8Mq5JzrphP8WbOkcdGPqfjfEHOoLseo7k8NNnTV2T1crmqMlqHcI+dzv+vnwhms ErqGXkxb6jdfIaJppSV6U6Fbj99wWKrFDLnJKvKqe2exu/GIEcsHj+nJWuMmB5elMEXd iyGRUkJElgTuINytfb6zGnTvBcmG16jHdhwqDyG7RTQmm9ybDbGEpjxu3Afn9DtG5Iyk X1qmNaroO7V+rSuZKEQqA8RxoMkOBg3GlGvlqyoMNsNfQQ1YWSL9VXKYEgVGQ7kKQSjE ATZQ== 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 l22si2748262pgn.74.2018.04.20.09.08.19; Fri, 20 Apr 2018 09:08:34 -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 S1755938AbeDTQGg (ORCPT + 99 others); Fri, 20 Apr 2018 12:06:36 -0400 Received: from ivanoab5.miniserver.com ([78.31.111.25]:47144 "EHLO www.kot-begemot.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755709AbeDTQGf (ORCPT ); Fri, 20 Apr 2018 12:06:35 -0400 Received: from tun5.smaug.kot-begemot.co.uk ([192.168.18.6] helo=smaug.kot-begemot.co.uk) by www.kot-begemot.co.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1f9YY8-0000BY-8Q; Fri, 20 Apr 2018 16:06:12 +0000 Received: from amistad.kot-begemot.co.uk ([192.168.3.89]) by smaug.kot-begemot.co.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1f9YY8-0001wh-01; Fri, 20 Apr 2018 17:06:12 +0100 Subject: Re: [uml-devel] [REVIEW][PATCH 19/22] signal/um: Use force_sig_fault in relay_signal. To: "Eric W. Biederman" , linux-arch@vger.kernel.org Cc: Richard Weinberger , Jeff Dike , linux-kernel@vger.kernel.org, linux-um@lists.infradead.org, "user-mode-linux-devel@lists.sourceforge.net" References: <87604mhrnb.fsf@xmission.com> <20180420143811.9994-19-ebiederm@xmission.com> From: Anton Ivanov Message-ID: <7074fe36-27c5-ee82-9659-da703cfc91fe@kot-begemot.co.uk> Date: Fri, 20 Apr 2018 17:06:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180420143811.9994-19-ebiederm@xmission.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Clacks-Overhead: GNU Terry Pratchett Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/20/18 15:38, Eric W. Biederman wrote: > Today user mode linux only works on x86 and x86_64 and this allows > simplifications of relay_signal. I believe someone recently fixed the ARM port. I have not had the time to try the fixes though. I have added the new list we are migrating to the cc list. A. > > - x86 always set si_errno to 0 in fault handlers. > - x86 does not implement si_trapno. > - Only si_codes between SI_USER and SI_KERNEL have a fault address. > > Therefore warn if si_errno is set (it should never be). > Use force_sig_info in the case where we know we have a good fault. > > For signals whose content it is not clear how to relay use plain > force_sig and let the signal sending code come up with an > appropriate generic siginfo. > > Cc: Jeff Dike > Cc: Richard Weinberger > Cc: user-mode-linux-devel@lists.sourceforge.net > Signed-off-by: "Eric W. Biederman" > --- > arch/um/kernel/trap.c | 28 +++++++++++++--------------- > 1 file changed, 13 insertions(+), 15 deletions(-) > > diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c > index d4d38520c4c6..5f0ff17cd790 100644 > --- a/arch/um/kernel/trap.c > +++ b/arch/um/kernel/trap.c > @@ -296,9 +296,6 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, > > void relay_signal(int sig, struct siginfo *si, struct uml_pt_regs *regs) > { > - struct faultinfo *fi; > - struct siginfo clean_si; > - > if (!UPT_IS_USER(regs)) { > if (sig == SIGBUS) > printk(KERN_ERR "Bus error - the host /dev/shm or /tmp " > @@ -308,29 +305,30 @@ void relay_signal(int sig, struct siginfo *si, struct uml_pt_regs *regs) > > arch_examine_signal(sig, regs); > > - clear_siginfo(&clean_si); > - clean_si.si_signo = si->si_signo; > - clean_si.si_errno = si->si_errno; > - clean_si.si_code = si->si_code; > + if (unlikely(si->si_errno)) { > + printk(KERN_ERR "Attempted to relay signal %d (si_code = %d) with errno %d\n", > + sig, si->si_code, si->si_errno); > + } > switch (sig) { > case SIGILL: > case SIGFPE: > case SIGSEGV: > case SIGBUS: > case SIGTRAP: > - fi = UPT_FAULTINFO(regs); > - clean_si.si_addr = (void __user *) FAULT_ADDRESS(*fi); > - current->thread.arch.faultinfo = *fi; > -#ifdef __ARCH_SI_TRAPNO > - clean_si.si_trapno = si->si_trapno; > -#endif > - break; > + if ((si->si_code > SI_USER) && (si->si_code < SI_KERNEL)) { > + struct faultinfo *fi = UPT_FAULTINFO(regs); > + current->thread.arch.faultinfo = *fi; > + force_sig_fault(sig, si->si_code, > + (void __user *)FAULT_ADDRESS(*fi), > + current); > + break; > + } > default: > printk(KERN_ERR "Attempted to relay unknown signal %d (si_code = %d)\n", > sig, si->si_code); > } > > - force_sig_info(sig, &clean_si, current); > + force_sig(sig, current); > } > > void bus_handler(int sig, struct siginfo *si, struct uml_pt_regs *regs)