Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp124238imm; Thu, 12 Jul 2018 15:33:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdQM+2wOgOl/3T3KeAIhOlnyxNeQypoY71UJvVUVcas16yzCpY/4g+GhGcFqm+O0sKYpQav X-Received: by 2002:a63:416:: with SMTP id 22-v6mr3729489pge.229.1531434799274; Thu, 12 Jul 2018 15:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531434799; cv=none; d=google.com; s=arc-20160816; b=WJqwr/C15Gs21uW57tI/Z4mBvV+MkooNFN04nVc9e8ouS8DtEAChkIDaNcp16mhvFt LBeH2Zud3Z4o+XZczUvRyLjT4wienCaAzcRBFv5vx4QVIzvuBK3vIHCeQUjmENx0pGgP 8VR02nc9lyxZUvfydKNvqngX6JTgLZ+mhGe3IqbPm6hcRJxatq4Y+T/FTXw/vnYvI8HX WaL/pAwVfoXO38R2ISOr8pFn0oq9vQBZjQRivTQMPn9IFTfT0yEpiZ4gFeDbXy+Jfkfr z9f8pfL3DSYGKRdJij88zT5NXQui3DT4Qx1EkUA6W4DI+CGHINGgGWFGHc2pvxWRBBjb qbCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=vfPnEpp+H+H84JqdRBOieBEdfnjzEGVQB1H7VxLkfEQ=; b=qpBPYwHbINs27rd4vaIp1qhr3sMDo/zDidBRT/FnNtIaDloRXfIazNmiznUlGs5UOm 9jzofaAHoiS1c2DznuqjehIy13FNLUSMOd0N8wIBHDFROpacPeXnUclNwp3jZKaEWqdT sEpESyVuseXd1Orq/r/Eu3JMGVG5kuJjAHS/DEhuaK7HSYRNEB3eWrP5JTXO8RGPXf5N 3k8MmM4R+aE8ey8v5GfZ3/gOrwWlAjjIAtX1NjOZF3F3yF/Vh+RXSXBu8VK29hNJp20t ZBNTN0czH3JkGV6ObYSiBd83hQjZ1eXGh8y7ncY8n/yifwijxJ317pivF2mdjLBY7OoJ kOLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@thunk.org header.s=ef5046eb header.b="NH0MoP2/"; 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 144-v6si22227227pge.406.2018.07.12.15.33.03; Thu, 12 Jul 2018 15:33:19 -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=fail header.i=@thunk.org header.s=ef5046eb header.b="NH0MoP2/"; 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 S1733232AbeGLWoH (ORCPT + 99 others); Thu, 12 Jul 2018 18:44:07 -0400 Received: from imap.thunk.org ([74.207.234.97]:36656 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732240AbeGLWoG (ORCPT ); Thu, 12 Jul 2018 18:44:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=vfPnEpp+H+H84JqdRBOieBEdfnjzEGVQB1H7VxLkfEQ=; b=NH0MoP2/E3qeaESfP5AVpBJGqC 45vVIWpINRxLc72PEH4fzWdAOc2p5kBtc5BoycSe8xTk7GNQLdf23MPnaCaAh4jHr3Cfg5Vkg8+Ru uZWO5YQSj81n1PKhlYhsW+d48hWKcaSpqG2LoKjqS7ya55QOZVcNoQyspNqdWzRDFlkM=; Received: from root (helo=callcc.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.89) (envelope-from ) id 1fdk8O-0005tl-P7; Thu, 12 Jul 2018 22:32:24 +0000 Received: by callcc.thunk.org (Postfix, from userid 15806) id 7EF0F7A55D2; Thu, 12 Jul 2018 18:32:23 -0400 (EDT) Date: Thu, 12 Jul 2018 18:32:23 -0400 From: "Theodore Y. Ts'o" To: David Howells Cc: Linus Torvalds , Andrew Lutomirski , Al Viro , Linux API , linux-fsdevel , Linux Kernel Mailing List , Jann Horn Subject: Re: [PATCH 24/32] vfs: syscall: Add fsopen() to prepare for superblock creation [ver #9] Message-ID: <20180712223223.GA28610@thunk.org> Mail-Followup-To: "Theodore Y. Ts'o" , David Howells , Linus Torvalds , Andrew Lutomirski , Al Viro , Linux API , linux-fsdevel , Linux Kernel Mailing List , Jann Horn References: <153126248868.14533.9751473662727327569.stgit@warthog.procyon.org.uk> <153126264966.14533.3388004240803696769.stgit@warthog.procyon.org.uk> <686E805C-81F3-43D0-A096-50C644C57EE3@amacapital.net> <22370.1531293761@warthog.procyon.org.uk> <7002.1531407244@warthog.procyon.org.uk> <16699.1531426991@warthog.procyon.org.uk> <18233.1531430797@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18233.1531430797@warthog.procyon.org.uk> User-Agent: Mutt/1.10.0 (2018-05-17) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 12, 2018 at 10:26:37PM +0100, David Howells wrote: > The problem is that there's more than one actual "open" involved. > > fd = fsopen("ext4"); <--- #1 > whatever_interface(fd, "s /dev/sda1"); > whatever_interface(fd, "o journal_path=/dev/sda2"); > do_the_create_thing(fd); <--- #2 and #3 > > The initial check to see whether you can mount or not is done at #1. > > But later there are two nested file opens. Internally, deep down inside the > block layer, /dev/sda1 and /dev/sda2 are opened and further permissions checks > are done, whether you like it or not. But these have no access to the creds > attached to fd as things currently stand. So maybe the answer is that you open /dev/sda1 and /dev/sda2 and then pass the file descriptors to the fsopen object? We can require that the fd's be opened with O_RDWR and O_EXCL, which has the benefit where if you have multiple block devices, you know *which* block device had a problem with being grabbed for an exclusive open. Just a thought. - Ted