From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f193.google.com ([209.85.210.193]:40406 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725812AbeLBIws (ORCPT ); Sun, 2 Dec 2018 03:52:48 -0500 Received: by mail-pf1-f193.google.com with SMTP id i12so4859997pfo.7 for ; Sun, 02 Dec 2018 00:52:44 -0800 (PST) Date: Sun, 2 Dec 2018 09:52:29 +0100 From: Christian Brauner To: "Eric W. Biederman" Cc: Arnd Bergmann , Andy Lutomirski , Andy Lutomirski , Florian Weimer , Linux Kernel Mailing List , "Serge E. Hallyn" , Jann Horn , Andrew Morton , Oleg Nesterov , cyphar@cyphar.com, Al Viro , Linux FS-devel Mailing List , Linux API , Daniel Colascione , Tim Murray , linux-man@vger.kernel.org, Kees Cook Subject: Re: [PATCH v2] signal: add procfd_signal() syscall Message-ID: <20181202085227.6krrxtxermxd7pcq@brauner.io> References: <993B98AC-51DF-4131-AF7F-7DA2A7F485F1@brauner.io> <20181129195551.woe2bl3z3yaysqb6@brauner.io> <6E21165F-2C76-4877-ABD9-0C86D55FD6AA@amacapital.net> <87y39b2lm2.fsf@xmission.com> <20181130065606.kmilbbq46oeycjp5@brauner.io> <87y399s3sc.fsf@xmission.com> <87tvjxp8pc.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87tvjxp8pc.fsf@xmission.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sat, Dec 01, 2018 at 09:28:47AM -0600, Eric W. Biederman wrote: > > It just occurs to me that the simple way to implement > procfd_sigqueueinfo info is like: > > int copy_siginfo_from_user_any(kernel_siginfo_t *info, siginfo_t *uinfo) > { > #ifdef CONFIG_COMPAT > if (in_compat_syscall) > return copy_siginfo_from_user32(info, uinfo); Right, though that would require a cast afaict. static int __copy_siginfo_from_user_generic(int signo, kernel_siginfo_t *kinfo, siginfo_t *info) { #ifdef CONFIG_COMPAT if (in_compat_syscall()) return __copy_siginfo_from_user32( signo, kinfo, (struct compat_siginfo __user *)info); #endif return __copy_siginfo_from_user(signo, kinfo, info); } It seems that a cast to (compat_siginfo __user *) should be safe in this context? I've at least seen similar things done for __sys_sendmsg(). > #endif > return copy_siginfo_from_user(info, uinfo); > } > > long procfd_sigqueueinfo(int fd, siginfo_t *uinfo) **bikeshedding** Not a fan of that name. I'm going to go with procfd_send_signal(). sigqueue gives non-native speakers a lot of room for spelling errors and it always seemed opaque to me what this function is doing without consulting the manpage. :) > { > kernel_siginfo info; > > if (copy_siginfo_from_user_any(&info, uinfo)) > return -EFAULT; > ...; > } > > It looks like there is already a place in ptrace.c that already > hand rolls copy_siginfo_from_user_any. > > So while I would love to figure out the subset of siginfo_t tha we can > just pass through, as I think that would make a better more forward > compatible copy_siginfo_from_user32. I think for this use case we just > add the in_compat_syscall test and then we just need to ensure this new > system call is placed in the proper places in the syscall table. > > Because we will need 3 call sights: x86_64, x32 and ia32. As the layout > changes between those three subarchitecuters. > > Eric >