Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751851AbaJSWnF (ORCPT ); Sun, 19 Oct 2014 18:43:05 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:53217 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116AbaJSWnD (ORCPT ); Sun, 19 Oct 2014 18:43:03 -0400 Date: Sun, 19 Oct 2014 23:42:51 +0100 From: Al Viro To: Andy Lutomirski Cc: David Drysdale , "Eric W. Biederman" , Meredydd Luff , "linux-kernel@vger.kernel.org" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andrew Morton , Kees Cook , Arnd Bergmann , X86 ML , linux-arch , Linux API Subject: Re: [PATCHv4 RESEND 0/3] syscalls,x86: Add execveat() system call Message-ID: <20141019224251.GJ7996@ZenIV.linux.org.uk> References: <1401975635-6162-1-git-send-email-drysdale@google.com> <20141019202034.GH7996@ZenIV.linux.org.uk> <20141019212921.GI7996@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 19, 2014 at 03:16:03PM -0700, Andy Lutomirski wrote: > Oh, you mean that #!/usr/bin/make -f would turn into /usr/bin/make > /dev/fd/3? That could be interesting, although I can imagine it > breaking things, especially if /dev/fd/3 isn't set up like that, e.g. > early in boot. Sigh... What I mean is that fexecve(fd, ...) would have to put _something_ into argv when it execs the interpreter of #! file. Simply because the interpreter (which can be anything whatsoever) has no fscking idea what to do with some descriptor it has before execve(). Hell, it doesn't have any idea *which* descriptor had it been. You need to put some pathname that would yield your script upon open(2). If you bothered to read those patches, you'd see that they do supply one, generating it with d_path(). Which isn't particulary reliable. I'm not sure there's any point putting any of that in the kernel - if you *do* have that pathname, you can just pass it. > Aside from the general scariness of allowing one process to actually > dup another process's fds, I feel like this is asking for trouble wrt > the various types of file locks. Who said anything about another process's fds? That, indeed, would be a recipe for serious trouble. It's a filesystem with one directory, not with one directory for each process... FWIW, they (Plan 9) do have procfs and there they have /proc//fd. Which is a regular file, with contents consisting of \n-terminated lines (one per descriptor in 's descriptor table>) in the same format as in *ctl (they put descriptor number as the first field in those). Unlike our solution, they do not allow to get to any process' files via procfs. They do allow /dev/stdin-style access to your own files via dupfs. And yes, for /dev/stdin and friends dup-style semantics is better - you get consistent behaviours for pipes and redirects from file that way. See the example I've posted upthread. Besides, for things like sockets our semantics simply fails - they really depend on having only one struct file for given socket; it's dup or nothing there. The same goes for a lot of things like eventfd, etc. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/