Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752260AbaKCWSh (ORCPT ); Mon, 3 Nov 2014 17:18:37 -0500 Received: from fn.samba.org ([216.83.154.106]:37648 "EHLO mail.samba.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751113AbaKCWSf (ORCPT ); Mon, 3 Nov 2014 17:18:35 -0500 X-Greylist: delayed 699 seconds by postgrey-1.27 at vger.kernel.org; Mon, 03 Nov 2014 17:18:35 EST Date: Mon, 3 Nov 2014 14:07:07 -0800 From: Jeremy Allison To: Eric Rannaud Cc: Andy Lutomirski , Christoph Hellwig , "linux-kernel@vger.kernel.org" , Andrew Morton , Al Viro , Linus Torvalds , linux-fsdevel Subject: Re: [RFC PATCH] fs: allow open(dir, O_TMPFILE|..., 0) with mode 0 Message-ID: <20141103220707.GJ5389@samba2> Reply-To: Jeremy Allison References: <5452B241.5010603@amacapital.net> <20141031084220.GA29085@infradead.org> <20141103083447.GA8617@infradead.org> 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 Mon, Nov 03, 2014 at 10:49:24AM -0800, Eric Rannaud wrote: > On Mon, Nov 3, 2014 at 9:06 AM, Andy Lutomirski wrote: > >> That doesn't help because we explicitly reject O_RDONLY when combined > >> with O_TMPFILE. > > > > I think I'm missing something. How is an O_RDONLY temporary file > > useful? Wouldn't you want an O_RDWR tempfile with mode 0400 or > > something like that? > > Isn't it because they are essentially emulating an atomic open() > capable of creating a file with inherited ACLs, according to > relatively complex rules? open *can* be used with O_CREAT|O_RDONLY > (touch(1) might do that), which would naively translate into: > > fd = open(dir, O_TMPFILE|O_RDONLY, 0600) > fsetxattr(fd, "...") > fsetxattr(fd, "...") > linkat(AT_FDCWD, "/proc/self/fd/...", ..., AT_SYMLINK_FOLLOW) > return fd; > > Now this would be happening on the server, and the only reason why it > would be important to ensure that fd is O_RDONLY, is that smbd does > not do its own bookkeeping of how each file handle was opened, and > would rather have the kernel enforce O_RDONLY? > > With O_TMPFILE as implemented now, smbd would have to do open(dir, > O_TMPFILE|O_RDWR, 0600), but internally keep track that O_RDONLY was > requested by the client on that fd, and block any writes to fd itself. Which we already do, actually.. Although the atomic open emulation is a very interesting idea for us. That's something we currently don't do correctly across different protocols (although we do it between smbd's themselves). Jeremy. -- 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/