Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2789963ybi; Thu, 18 Jul 2019 14:30:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5UeqU8h5OcSItr6Guy27o/sMOW4ETnDSnYpXcO7K3nnskfEWbf6/ojBeya9N8BM0Aemkz X-Received: by 2002:a17:902:d715:: with SMTP id w21mr12756367ply.261.1563485445500; Thu, 18 Jul 2019 14:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563485445; cv=none; d=google.com; s=arc-20160816; b=MSua4mNrBBG/nf59a49nVNEi4X8ECKGHX0ZHXS2jE9UjYmsMtz1/vib97Ro0sVRUf8 fn+uAlx/01yrU6FjC2aKGyWfbZvw/vRtOcAwHxSP9rNOItubc5ol+JsBXTWDFvYJVfXj JLkjTe6J8SgrScyQ5a2xfYd3hTGaT6CGPK+sg9ChBE9/3ty/RWN2CyvfyL7T55/SZIeU nazAi/XL7jpxwyVxwlVaURuj7qYR08VZjZcm/ziOU9B1NpFh/3NUDGDa8EGrqjV2KB7/ jik00ws3SSOXY6RI1LPIyZAy2mwkjrchz9K0UecZXmjFV8cerLkvIvTt8wjcpoBMr+t7 dG8Q== 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; bh=gXA3fCzwUc7S8+pRMyyFoXYQ6Lxj2094nm3NP6Me1pg=; b=ieKrO3WHaQloo3v0A75W07WNB8CZWnBXs5Y+qv1JY9uuQbIdGh1G2n7hiN91yurS1p nLX3228zrEXxuujwVzMP0vnGOZKWFjJq4L14W1uxB0IAv1MX+JO2us9+mzkcLm60ap1x xfJywy8donnuxrusJmot2MolezGrTsk/oU3Fy6Ksvv4CPkOL04Vzgu5B1VlgNPIeBbzT 0cIOjJ8uHHMV4Fz+rZWxe4ZN0wM44G22nxC+1YgDqDet5pGiBDzbpaJqpuDtzMfCmzrB Zf7anZLXOgbU+Gqiia3JctPsIGTOwGtyr3onNw99PU1+iXrUTplrDX0JUTPscJqRlarJ ZhKg== 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 c11si3583028pga.118.2019.07.18.14.30.30; Thu, 18 Jul 2019 14:30:45 -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 S2391532AbfGRVaJ (ORCPT + 99 others); Thu, 18 Jul 2019 17:30:09 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:35212 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728014AbfGRVaJ (ORCPT ); Thu, 18 Jul 2019 17:30:09 -0400 Received: by mail-qk1-f196.google.com with SMTP id r21so21732487qke.2; Thu, 18 Jul 2019 14:30:07 -0700 (PDT) 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=gXA3fCzwUc7S8+pRMyyFoXYQ6Lxj2094nm3NP6Me1pg=; b=uCH2vUxrfcr6142uAaV9WcXORBKH/D7E4P4NiRuyJaE8kui154F7hapgGZCVK4V5oV h1KnYS8zB5WGcRW0yhYqz6ThOCVt0oV80LAGfoSFKRtZfNXUcqq4Vkc98WyzSf5MEfhC ChJWDCasnRmyjbS9ZdJ1VIkfY5G1MVa9zaR2pgCczj6oOHsD73sgibeBSKVPZopGXvDM xY7mk5kdPJ2hzmYK77+wvt1X8GlX5DuOJeI7mCZMAvHFwnVsvpfPZ56B86qqTVg8XPES 7Uk5MUGfBIJqa4SUJOhaEv7m8ueBN492aEPpsSidYIuqRP6htYAWtO8+oyTfmZ0jeCe8 JWVw== X-Gm-Message-State: APjAAAVWFgTKNxdz5VJMuDG74/oEsWc7zg83gF05rrI4hZNlp1YwqMUs 1xmowdKoxZ9t80vjXWPDDaUz1du0yDU5c5Rfqb8= X-Received: by 2002:a37:5f45:: with SMTP id t66mr32747316qkb.286.1563485406992; Thu, 18 Jul 2019 14:30:06 -0700 (PDT) MIME-Version: 1.0 References: <20190706145737.5299-1-cyphar@cyphar.com> <20190706145737.5299-9-cyphar@cyphar.com> <20190718161231.xcno272nvqpln3wj@yavin> In-Reply-To: <20190718161231.xcno272nvqpln3wj@yavin> From: Arnd Bergmann Date: Thu, 18 Jul 2019 23:29:50 +0200 Message-ID: Subject: Re: [PATCH v9 08/10] open: openat2(2) syscall To: Aleksa Sarai Cc: Al Viro , Jeff Layton , "J. Bruce Fields" , David Howells , Shuah Khan , Shuah Khan , Christian Brauner , Eric Biederman , Andy Lutomirski , Andrew Morton , Alexei Starovoitov , Kees Cook , Jann Horn , Tycho Andersen , David Drysdale , Chanho Min , Oleg Nesterov , Aleksa Sarai , Linus Torvalds , containers@lists.linux-foundation.org, alpha , Linux API , linux-arch , Linux ARM , Linux FS-devel Mailing List , linux-ia64@vger.kernel.org, Linux Kernel Mailing List , "open list:KERNEL SELFTEST FRAMEWORK" , linux-m68k , linux-mips@vger.kernel.org, Parisc List , linuxppc-dev , linux-s390 , Linux-sh list , linux-xtensa@linux-xtensa.org, sparclinux 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 Thu, Jul 18, 2019 at 6:12 PM Aleksa Sarai wrote: > On 2019-07-18, Arnd Bergmann wrote: > > On Sat, Jul 6, 2019 at 5:00 PM Aleksa Sarai wrote: > > > > In fact, that seems similar enough to the existing openat() that I think > > you could also just add the fifth argument to the existing call when > > a newly defined flag is set, similarly to how we only use the 'mode' > > argument when O_CREAT or O_TMPFILE are set. > > I considered doing this (and even had a preliminary version of it), but > I discovered that I was not in favour of this idea -- once I started to > write tests using it -- for a few reasons: > > 1. It doesn't really allow for clean extension for a future 6th > argument (because you are using up O_* flags to signify "use the > next argument", and O_* flags don't give -EINVAL if they're > unknown). Now, yes you can do the on-start runtime check that > everyone does -- but I've never really liked having to do it. > > Having reserved padding for later extensions (that is actually > checked and gives -EINVAL) matches more modern syscall designs. > > 2. I really was hoping that the variadic openat(2) could be done away > using this union setup (Linus said he didn't like it, and suggested > using something like 'struct stat' as an argument for openat(2) -- > though personally I am not sure I would personally like to use an > interface like that). > > 3. In order to avoid wasting a syscall argument for mode/mask you need > to either have something like your suggested mode_mask (which makes > the syscall arguments less consistent) or have some sort of > mode-like argument that is treated specially (which is really awful > on multiple levels -- this one I also tried and even wrote my > original tests using). And in both cases, the shims for > open{,at}(2) are somewhat less clean. These are all good reasons, thanks for providing the background. > All of that being said, I'd be happy to switch to whatever you think > makes the most sense. As long as it's possible to get an O_PATH with > RESOLVE_IN_ROOT set, I'm happy. I don't feel I should be in charge of making the decision. I'd still prefer avoiding the indirect argument structure because 4. it's inconsistent with most other syscalls 5. you get the same problem with seccomp and strace that clone3() has -- these and others only track the register arguments by default. 6. copying the structure adds a small overhead compared to passing registers 7. the calling conventions may be inconvenient for a user space library, so you end up with different prototypes for the low-level syscall and the libc abstraction. I don't see any of the above seven points as a showstopper either way, so I hope someone else has a strong opinion and can make the decision easier for you. In the meantime just keep what you have, so you don't have to change it multiple times. Arnd