From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3551BC7618F for ; Thu, 18 Jul 2019 21:34:49 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B344A208C0 for ; Thu, 18 Jul 2019 21:34:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B344A208C0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45qS8Q2qxZzDqQ3 for ; Fri, 19 Jul 2019 07:34:46 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=209.85.222.194; helo=mail-qk1-f194.google.com; envelope-from=arndbergmann@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45qS370b1wzDqgf for ; Fri, 19 Jul 2019 07:30:10 +1000 (AEST) Received: by mail-qk1-f194.google.com with SMTP id m14so21632826qka.10 for ; Thu, 18 Jul 2019 14:30:10 -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=OjVoESVva1CWkevxYVwa6u/4/j30kNx/fTN/uDSc817uL3pGPMpO7FnaJnMS3vHHUw DvBCAaxbSMTFGXmII+R1zW2yiIkXHSQLqpaidhK2uqNvay3nj0/djnfpWlEp2LOnAZVh wiiBMYFIZ314yoWH/fWdBtO4f9+5vS62ekxGgVt5h4l0szMtWFFZPE3ixds1w4QQMe2u knzmrzRy3coJWUF9ccEeJG4NnIXx6f3N3Uf/ZnO4fEmjdpLopmPkwHD8kwKoPGG0/g7A 6BoQ2hPK9366ESL+rE4rCEq8DFfNl5OpL/stjsoaNkEaEWHKa2cJoNClXB6/IaQ+6Sfv 9BbA== X-Gm-Message-State: APjAAAVYuMZM7d4XfUtJM69jPnisD02azV8t700QeYqdulipHS/osOSs u18byhh4Q1DgC25wW8/qSSidzuoW8Dng1sDKDVU= X-Google-Smtp-Source: APXvYqwAnwmqNY3PBxWPuNJix5kLy4PEG765j1QyxyCKOemfTtTG+YSbK8sHn1TSB6/emkF2O/3aVUhdKFw2Cxuzrg4= 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 Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ia64@vger.kernel.org, Linux-sh list , Alexei Starovoitov , Linux Kernel Mailing List , David Howells , "open list:KERNEL SELFTEST FRAMEWORK" , sparclinux , Shuah Khan , linux-arch , linux-s390 , Tycho Andersen , Aleksa Sarai , Linux ARM , linux-mips@vger.kernel.org, linux-xtensa@linux-xtensa.org, Kees Cook , Jann Horn , linuxppc-dev , linux-m68k , Al Viro , Andy Lutomirski , Shuah Khan , David Drysdale , Christian Brauner , "J. Bruce Fields" , Parisc List , Linux API , Chanho Min , Jeff Layton , Oleg Nesterov , Eric Biederman , alpha , Linux FS-devel Mailing List , Andrew Morton , Linus Torvalds , containers@lists.linux-foundation.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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