Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1723759ybt; Mon, 15 Jun 2020 07:51:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDSawuiLg5pv9aHD0TJQ4U7U8KKnpBixcSQmRcWzyErZdKUb3YlHKUGjjirva0VwTZ3zWl X-Received: by 2002:a05:6402:1486:: with SMTP id e6mr23124206edv.99.1592232692845; Mon, 15 Jun 2020 07:51:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592232692; cv=none; d=google.com; s=arc-20160816; b=B31+yyMSlDVozc4Hv+/T/Ikf09Azc3y6UzX8DmcH+fQb3l1pFA/SvlOKREEvE0S4E8 lQ4qmXF0i7ssgFMArirFi+idxiV6vZCOWy6hf/3KJcSrzbgIw4eNku4tGtMkXWKfris7 mcp9zIGtAqav7KxdUAn5hhF2CUeYTR25LCCCb51ZOzbAAK45OwyujPgN0AxWbngvQWcM 503G5cA7I7q/reALOs+pu65c8dozhOL9o0xaoQsi6d054WwcnyXQJnJwMfrhludyzQNL VFHb2BTXRMUf9cgGB2gqx23GPdJfHlDvVXFIStcZ5ErHUj+7eh/FV7YaUeTecmWLgRdU rPcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=CFYHq9QU1VF3rchooKVX3EvDkFFGgQYVgoX+nSdXTuc=; b=BG5eKvZrAz3OIfwIyaDqCu0Kq/U7HAeiWSNfL/5xSyqg2kkiX3Col0pRbo0YkNyX/j hpTY5VDECC82GffKJiZx30CfUti7SpqLUp1mWWR70wolCHtJWmfRYSiJqyPizM9/XMbg 9XrOaKVKn3biKOd/9pjQuGENd++qRrmVafHON1SZdosKZ/c/jyUsU14Lxk3CsnivxrKo JBm1kXgq7f9hrsRgPk28jepS69L4YAb+ES/ws0NebpBJgEkW18AxgZMsH///NbMfKVDn 3hj2muLF5vpYQbfBEgls+zuOWDVPX9lUsl1Z+CCOuEIC1AyZDmVT1jkvTfvvGVr6pIEQ DOMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PRxkgdzs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s14si9368580ejx.620.2020.06.15.07.51.10; Mon, 15 Jun 2020 07:51:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PRxkgdzs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730788AbgFOOsm (ORCPT + 99 others); Mon, 15 Jun 2020 10:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730476AbgFOOsk (ORCPT ); Mon, 15 Jun 2020 10:48:40 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69523C061A0E; Mon, 15 Jun 2020 07:48:39 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id c8so18137913iob.6; Mon, 15 Jun 2020 07:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CFYHq9QU1VF3rchooKVX3EvDkFFGgQYVgoX+nSdXTuc=; b=PRxkgdzs6hj4NpKjLdU4+mZo+kiLgpl3v8qO3FUtkLItVntqN/v1UtTbvyh1fAkJDQ /r/QUNFX0i3kNhar6p3HMQRIc0/hnPpxSyfCSOk/7QGhSriP8dugDYCbD3NVmr3r39T+ L0RU8h1FEoVzRUIqiHPXWetm4KkkvOZ8sZuPa8pJIZPJbfJz9/qmImf4Haoxykq/U+Wm z0McY86vBdXb73lWVCJytm+tusWr8I6JfrKJ++433fcbFQ7IdZZfKn+gl9mRtO93JHfb KS+ugwQDy31DiZDXPTjkRurzgAFvHZ4Gbe2s6FFN7LQGjbdA1Klosmt+SwHoidzFhQqC XkJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CFYHq9QU1VF3rchooKVX3EvDkFFGgQYVgoX+nSdXTuc=; b=gu9PBb2xVGRKsDeAvPl9dTwQsZgQo83ED5+xLkeqKLebPGrluehaGJyzD5Rog37869 LNj/HGqUyMaGNCUgXT9+XI9PEnVluj/BcfKm0wxHhbU/ioq3FO+/ZNrlkPKvcb/ya5yY JsM93Nk4l4fGc5QIJft26rXR6n8qQamrRMInu3+WjuwcIKpfBeFbga9nuAHF2Qe0I90i Ec0UT8XIXr5COHFwYhXQF74UzQm/MUxiNlFJIphd5FbuvrIbfU5pXTi3x4uu9LfQC4Zr hQGVdXPJPsPJdcMxMR8tjNSFkOnVbTQvGpljZ1CIZ6pUew1wb1E7Ot8Erpy96GGBxyam q5Gg== X-Gm-Message-State: AOAM5300G7d+CpmXZt7VC/rgKW4r+5pLQX89/wkvCN3fmcBqLrzWnYbP TUFgxN7kWSNPd5Vw3QkzK3q0J/YecSriAkDCuE// X-Received: by 2002:a02:3501:: with SMTP id k1mr6072971jaa.133.1592232518583; Mon, 15 Jun 2020 07:48:38 -0700 (PDT) MIME-Version: 1.0 References: <20200615130032.931285-1-hch@lst.de> <20200615130032.931285-3-hch@lst.de> <20200615141239.GA12951@lst.de> In-Reply-To: <20200615141239.GA12951@lst.de> From: Brian Gerst Date: Mon, 15 Jun 2020 10:48:26 -0400 Message-ID: Subject: Re: [PATCH 2/6] exec: simplify the compat syscall handling To: Christoph Hellwig Cc: Arnd Bergmann , Al Viro , Luis Chamberlain , Linux ARM , "the arch/x86 maintainers" , "open list:BROADCOM NVRAM DRIVER" , Parisc List , linuxppc-dev , linux-s390 , sparclinux , Linux FS-devel Mailing List , linux-arch , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 15, 2020 at 10:13 AM Christoph Hellwig wrote: > > On Mon, Jun 15, 2020 at 03:31:35PM +0200, Arnd Bergmann wrote: > > > #ifdef CONFIG_COMPAT > > > - if (unlikely(argv.is_compat)) { > > > + if (in_compat_syscall()) { > > > + const compat_uptr_t __user *compat_argv = > > > + compat_ptr((unsigned long)argv); > > > compat_uptr_t compat; > > > > > > - if (get_user(compat, argv.ptr.compat + nr)) > > > + if (get_user(compat, compat_argv + nr)) > > > return ERR_PTR(-EFAULT); > > > > > > return compat_ptr(compat); > > > } > > > #endif > > > > I would expect that the "#ifdef CONFIG_COMPAT" can be removed > > now, since compat_ptr() and in_compat_syscall() are now defined > > unconditionally. I have not tried that though. > > True, I'll give it a spin. > > > > +/* > > > + * x32 syscalls are listed in the same table as x86_64 ones, so we need to > > > + * define compat syscalls that are exactly the same as the native version for > > > + * the syscall table machinery to work. Sigh.. > > > + */ > > > +#ifdef CONFIG_X86_X32 > > > COMPAT_SYSCALL_DEFINE3(execve, const char __user *, filename, > > > - const compat_uptr_t __user *, argv, > > > - const compat_uptr_t __user *, envp) > > > + const char __user *const __user *, argv, > > > + const char __user *const __user *, envp) > > > { > > > - return do_compat_execve(AT_FDCWD, getname(filename), argv, envp, 0); > > > + return do_execveat(AT_FDCWD, getname(filename), argv, envp, 0, NULL); > > > } > > > > Maybe move it to arch/x86/kernel/process_64.c or arch/x86/entry/syscall_x32.c > > to keep it out of the common code if this is needed. > > I'd rather keep it in common code as that allows all the low-level > exec stuff to be marked static, and avoid us growing new pointless > compat variants through copy and paste. > smart compiler to d > > > I don't really understand > > the comment, why can't this just use this? > > That errors out with: > > ld: arch/x86/entry/syscall_x32.o:(.rodata+0x1040): undefined reference to > `__x32_sys_execve' > ld: arch/x86/entry/syscall_x32.o:(.rodata+0x1108): undefined reference to > `__x32_sys_execveat' > make: *** [Makefile:1139: vmlinux] Error 1 I think I have a fix for this, by modifying the syscall wrappers to add an alias for the __x32 variant to the native __x64_sys_foo(). I'll get back to you with a patch. -- Brian Gerst