Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp169702imm; Thu, 12 Jul 2018 16:34:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe5KDHsbkyXi7hCnYoHDZ0KpJVodDydyX8KLN6/xqXfl0p/6xbqBPq7OkYFtaRhdHMkR/dD X-Received: by 2002:a65:6110:: with SMTP id z16-v6mr3919242pgu.412.1531438497234; Thu, 12 Jul 2018 16:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531438497; cv=none; d=google.com; s=arc-20160816; b=EM9hWfdxYRSmqMddg6DQwkpRT6UwpUjilIbkmqUGkSLXM0gNB639z3ihh9SxhAX63O e2TIVFMIC8bvBFozn51/msbBmnS5YkrPTSzG/+sPUJXOVMw0WF7OHxLddhpccO5yR8w7 9rzSYjQgjerre+6A5LEdw36vEvAVk4BLPZZmsM9I+n2LqlSF8KvnUpMmmy/FHilrSDg5 dXK/AWmUWQal0u6Y+C3ffw2kvn/Re1XvGQkAoqWxZ1RdacyIwhYidppsqL318B+VD/is aH8QdVpmSHiKW1Al0TiV2UE5ex1IQ39QygKlna9+0VcJMaWccXdffWIVVLBboTcYHQQ8 y5og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=FBQSpQTvdl+u4m4TKpfI4N/JrOAqhBXz0NfkmZ5Wu6M=; b=gtj2zjl89ccwqrR0aSeTqB4JYgp89SpOeG+NLd97DIxZ32/IKHIdSa1uZAXb8M8dy7 msx0m1nljiTMHtrRBdSW0FMj62MVuZeWfWGZ1WPfTHInT/X9S33hriIvy0vnCdcha67j Yfe7mP6EJIp10p7Tz9RHqTQtSoraYqsLKKRgs9Shm2nVNjox3Aovz46AtyG/U5QrSTWl RR791WwkZW8J4GkNGih1n8GGCAZkDwa2aYbOefgH/rTuiYNY5mffzlHVeb5wqUmqt8NF qepxVZRRADzSuFGSGg5mjkejyWK6BeqKBWIbTXzzpBgJXKxVwtoFpoz9bUKio2nsiVRi vutg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VIb54QcG; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22-v6si21328650pgs.396.2018.07.12.16.34.42; Thu, 12 Jul 2018 16:34:57 -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=@google.com header.s=20161025 header.b=VIb54QcG; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387688AbeGLXp4 (ORCPT + 99 others); Thu, 12 Jul 2018 19:45:56 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:42783 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387610AbeGLXp4 (ORCPT ); Thu, 12 Jul 2018 19:45:56 -0400 Received: by mail-oi0-f67.google.com with SMTP id n84-v6so58987990oib.9 for ; Thu, 12 Jul 2018 16:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FBQSpQTvdl+u4m4TKpfI4N/JrOAqhBXz0NfkmZ5Wu6M=; b=VIb54QcGqNJVFNFqZ9KYwFohL37Vh+/4OQF8ufQJwAli7M+5GFBT9uO7FsoYkuE5Ba cO6k+RvOg+4zRQkxan1IWHEBtMXJpLpMwNPwvGnEKQmM1NbgCyPxiSWpgOnf322V2fSE SDDAhZQALg0Ny4WQ1NQYhMDDrCT0lVtf6QedTMbi8fNWgRkeA0aiPPjWvDQ/EzMwW7Eh jCRDoE8MiG+X27NUjniPX4lEb61RNbBUI3L4wHia4CBUATffGlJGTiw+3GQcbOx9J0Ia fbcMgcMcG+8NuOIW7PR3D/hhECXkj4/J+y/lWjM+B90RY3c/le3q0wReff11qYwGNFIc tyYg== 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=FBQSpQTvdl+u4m4TKpfI4N/JrOAqhBXz0NfkmZ5Wu6M=; b=n5A0IHinDYauxtyH1gZ/RxCSMHjMmzoeB2TEtpD1yT+CT8aC6zetmOE/GGFhH3XX5h i56Kp3YYXRNZKbX4NFymSlXKVMEjkgFkmQ3fqyxK3nKUwjq8mvElE1333vA+4CPWc5XN 3DXzQugu6iANQYhueem8dADYNNQ2UB1c02jW4h1XOIuZ2P9TyRIssFfcy1jhLxXJu1YR bXWY+bqHevKn9fKKJciothE1OpW/BnAWeuzosFfyV6pqsXnhlKY5ecfwv3O5xJUMBaq/ j1JoR0ZwmHBrkg3jYxa8aLM2ZseRN08b9EBWymkHINubYb6oAAIlvb5ghjFFKFyC/sm8 m3Jw== X-Gm-Message-State: AOUpUlGLKYpZtMO5X9jEFRtCqM4NyAnuYj4N8ETfgyyMyZeTr3ZVRVCh Rj9rVgo+OQtT6a3NZsHNj3ZNVGDhynW0GTVdXIzICw== X-Received: by 2002:aca:5bd5:: with SMTP id p204-v6mr4823763oib.91.1531438445310; Thu, 12 Jul 2018 16:34:05 -0700 (PDT) MIME-Version: 1.0 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> <20180712223223.GA28610@thunk.org> <22105.1531436081@warthog.procyon.org.uk> In-Reply-To: From: Jann Horn Date: Thu, 12 Jul 2018 16:33:38 -0700 Message-ID: Subject: Re: [PATCH 24/32] vfs: syscall: Add fsopen() to prepare for superblock creation [ver #9] To: David Howells Cc: "Theodore Y. Ts'o" , Linus Torvalds , Andy Lutomirski , Al Viro , Linux API , linux-fsdevel@vger.kernel.org, kernel list Content-Type: text/plain; charset="UTF-8" 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 4:23 PM Jann Horn wrote: > > On Thu, Jul 12, 2018 at 3:54 PM David Howells wrote: > > > > Theodore Y. Ts'o wrote: > > > > > 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. > > > > Would that mean then that doing: > > > > mount /dev/sda3 /a > > mount /dev/sda3 /b > > > > would then fail on the second command because /dev/sda3 is already open > > exclusively? > > Not exactly. mount_bdev() uses FMODE_EXCL, which locks out parallel > usage *with a different filesystem type*. This is the effect: > > # strace -e trace=mount mount -t vfat /dev/loop0 mount > mount("/dev/loop0", "/home/jannh/tmp/x/mount", "vfat", MS_MGC_VAL, NULL) = 0 > +++ exited with 0 +++ > # strace -e trace=mount mount -t ext4 /dev/loop0 mount > mount("/dev/loop0", "/home/jannh/tmp/x/mount", "ext4", MS_MGC_VAL, > NULL) = -1 EBUSY (Device or resource busy) > mount: /home/jannh/tmp/x/mount: /dev/loop0 already mounted on > /home/jannh/tmp/x/mount. > +++ exited with 32 +++ > > I don't really understand why it's not more strict though... Er, sorry, of course that's the current behavior, not the behavior of the suggested API.