Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1049490ybl; Wed, 28 Aug 2019 08:57:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNEsq/Gxe+Dyd0x1qt8ptOERUiP4D1BOF5+3pYICqOarBpQD4uNVz9eSipBNy5WknCq9RB X-Received: by 2002:a17:90a:2841:: with SMTP id p1mr5021963pjf.101.1567007824775; Wed, 28 Aug 2019 08:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567007824; cv=none; d=google.com; s=arc-20160816; b=Og+zRG0D8hRH867Z8YykzgMbyhn56LO5aH6ZcJodU8WjTD7R7bJMSlxAHAmE3h96H4 huGT2nQSYdh/wUNTdb7gtgwwK6XU2kI0zo76vvMeK4wYDa2pY6Pv9nzD6+BWFzjZPBKJ 0zvM7T77/kHaZ/WnXABQQ5u9q59pomVfcFFq7Sf12dH2E3eSN/6bSlk5ALdGxZ74e7LH D+vk4J1NUQc6dvwsdmscnVS316DXkcNti+pl3qzAsmZA9wfUbzhmxKMALSIvv0Evoltp MGoOkt38DiDOuY31kquqq/7e6w+cDGXNWOWMjsOzoAmhB8KMOqo3ytWYSm6DmgimLIjT ZUXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=mTiQkvuHqboEPyaQdrTmN7i26yCG/zNaUHlkc+wcoIU=; b=RPqT2+MFZn527hBinSvU+nlUpi14CmpahL9lGaEHXnZVMFc87SFyky5BhodqUnU3xe FxJN9AA/e999DPhlm0WWflO1Txp24g0KZESq/I01R1e3WNFemwrArK9PGYHQubjAwj6R u+kAYwGDjA0Da6UN7vw4UAVkc8f6H43aRaI/Jn+rYqZBg/5ikfYk8xj5OMK2SFNgkd0X 7we+wQKcwrosJ7ctnxorLzE5Lu/PhtI1QeVaq9UTtl4LguujOkDwmMIWdsXrF/uNs867 hiRfIK9eoxQ1jDw/wcCk4NZtOD9zUA6SP39QbNDIxGYRPIMMSbflzKAdcr2kAyrtiY1X tw7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pqTccn5J; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q15si2203124pls.184.2019.08.28.08.56.47; Wed, 28 Aug 2019 08:57:04 -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; dkim=pass header.i=@kernel.org header.s=default header.b=pqTccn5J; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbfH1Pzv (ORCPT + 99 others); Wed, 28 Aug 2019 11:55:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:38158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbfH1Pzu (ORCPT ); Wed, 28 Aug 2019 11:55:50 -0400 Received: from tleilax.poochiereds.net (68-20-15-154.lightspeed.rlghnc.sbcglobal.net [68.20.15.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 765322064A; Wed, 28 Aug 2019 15:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567007749; bh=tm23iPOHz5qNiVmbKBRthv6o0H14qpr8dY7bd4MTQKs=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=pqTccn5JcnucNCAhPvukewbhK7LnqfZiA1JhrrT1FDFY4mCrVB8AZyQ8GN7mLjP8y 7s9EDdOPkKuIVFWDEaVrPbihjrm8teyPYUCsz+WciUJXkEpW4kr0ySk55f/ASUGrn8 zpEFoJeA5Hy5XDMtaE0vrkdWUVKHa2wWQhJO2xxg= Message-ID: <4da231cd52880991d8a038adb8fbb2ef3d724db9.camel@kernel.org> Subject: Re: [PATCH RESEND v11 7/8] open: openat2(2) syscall From: Jeff Layton To: sbaugh@catern.com, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@ozlabs.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org Date: Wed, 28 Aug 2019 11:55:47 -0400 In-Reply-To: <854l2366zp.fsf@catern.com> References: <20190820033406.29796-1-cyphar@cyphar.com> <20190820033406.29796-8-cyphar@cyphar.com> <854l2366zp.fsf@catern.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.4 (3.32.4-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-08-26 at 19:50 +0000, sbaugh@catern.com wrote: > Aleksa Sarai writes: > > To this end, we introduce the openat2(2) syscall. It provides all of the > > features of openat(2) through the @how->flags argument, but also > > also provides a new @how->resolve argument which exposes RESOLVE_* flags > > that map to our new LOOKUP_* flags. It also eliminates the long-standing > > ugliness of variadic-open(2) by embedding it in a struct. > > I don't like this usage of a structure in memory to pass arguments that > would fit in registers. This would be quite inconvenient for me as a > userspace developer. > > Others have brought up issues with this: the issue of seccomp, and the > issue of mismatch between the userspace interface and the kernel > interface, are the most important for me. I want to add another, > admittedly somewhat niche, concern. > > This interfaces requires a program to allocate memory (even on the > stack) just to pass arguments to the kernel which could be passed > without allocating that memory. That makes it more difficult and less > efficient to use this syscall in any case where memory is not so easily > allocatable: such as early program startup or assembly, where the stack > may be limited in size or not even available yet, or when injecting a > syscall while ptracing. > > A struct-passing interface was needed for clone, since we ran out of > registers; but we have not run out of registers yet for openat, so it > would be nice to avoid this if we can. We can always expand later... > We can't really expand later like you suggest. Suppose in a couple of years that we need to add some new argument to openat2 that isn't just a new flag. If all these values are passed by individual arguments, you can't add one later without adding yet another syscall. Using a struct for this allows this to be extended later, OTOH. You can extend it, and add a flag that tells the kernel that it can access the new field. No new syscall required. -- Jeff Layton