util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
Cc: Chris Hofstaedtler <chris@hofstaedtler.name>,
	"util-linux@vger.kernel.org" <util-linux@vger.kernel.org>,
	Coly Li <colyli@suse.de>, Damien Le Moal <Damien.LeMoal@wdc.com>
Subject: Re: [PATCH] blkzone: deny destructive ioctls on busy blockdev
Date: Fri, 15 May 2020 12:37:36 +0200	[thread overview]
Message-ID: <20200515103736.5jsezljksq64kofg@ws.net.home> (raw)
In-Reply-To: <SN4PR0401MB35982647432681A63CBABCA99BBD0@SN4PR0401MB3598.namprd04.prod.outlook.com>

On Fri, May 15, 2020 at 09:53:46AM +0000, Johannes Thumshirn wrote:
> On 15/05/2020 10:50, Chris Hofstaedtler wrote:
> > * Johannes Thumshirn <johannes.thumshirn@wdc.com> [200515 10:41]:
> >> If a user submits a zone management ioctl from user-space, like a zone
> >> reset and a file-system (like zonefs or f2fs) is mounted on the zoned
> >> block device, the zone will get reset and the file-system's cached value
> >> of the zone's write-pointer becomes invalid.
> >>
> >> Subsequent writes to this zone from the file-system will result in
> >> unaligned writes and the drive will error out.
> > 
> > "error out" meaning what exactly?
> 
> The drive will report an Unaligned Write error.
> 
> > 
> >> Open the block device file in exclusive mode for submitting these ioctls.
> >> If a file-system is mounted the kernel will return -EBUSY and we can't
> >> continue issuing the ioctl.
> > 
> > Isn't this something the kernel should enforce, then?
> 
> I did a patch for the kernel yesterday [1] enforcing this limitation, but as
> Damien said it's SYS_CAP_ADMIN and with great power comes great responsibility.
> We're also allowing other raw block device accesses on block devices.
> 
> [1] https://lore.kernel.org/linux-block/BY5PR04MB69006DE86D1050620B5EDAA4E7BD0@BY5PR04MB6900.namprd04.prod.outlook.com/
> 
> > What's to stop anybody from calling the ioctl from another tool,
> > without using O_EXCL?
> 
> Nothing, but still we don't need to make one's life hard by letting blkzone go 
> havoc with FS internal caching. If another tool does zone resets, it's up to them
> to check for mounted block devices.

O_EXCL good idea, it nothing unusual that you can do crazy things with
devices with mounted filesystem (see for example fdisk(s), wipefs, ...). 

And sometimes it is valid use-case to do "bad" things and in this case
we have --force option in our tools (for example to avoid O_EXCL).

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


  reply	other threads:[~2020-05-15 10:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15  8:41 [PATCH] blkzone: deny destructive ioctls on busy blockdev Johannes Thumshirn
2020-05-15  8:50 ` Chris Hofstaedtler
2020-05-15  9:53   ` Johannes Thumshirn
2020-05-15 10:37     ` Karel Zak [this message]
2020-05-15 12:58 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200515103736.5jsezljksq64kofg@ws.net.home \
    --to=kzak@redhat.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=chris@hofstaedtler.name \
    --cc=colyli@suse.de \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).