linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <jejb@linux.vnet.ibm.com>
To: Tony Battersby <tonyb@cybernetics.com>,
	dgilbert@interlog.com, linux-scsi@vger.kernel.org
Cc: martin.petersen@oracle.com, hare@suse.de, bvanassche@acm.org,
	kbuild test robot <lkp@intel.com>, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v3 17/20] sg: add sg_iosubmit_v3 and sg_ioreceive_v3 ioctls
Date: Mon, 12 Aug 2019 11:46:03 -0700	[thread overview]
Message-ID: <1565635563.3287.1.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <500183f3-fb16-77b7-90e0-5c8bb2a021c3@cybernetics.com>

On Mon, 2019-08-12 at 12:14 -0400, Tony Battersby wrote:
> On 8/12/19 11:37 AM, Douglas Gilbert wrote:
> > On 2019-08-09 7:15 p.m., James Bottomley wrote:
> > > On Wed, 2019-08-07 at 13:42 +0200, Douglas Gilbert wrote:
> > > > Add ioctl(SG_IOSUBMIT_V3) and ioctl(SG_IORECEIVE_V3). These
> > > > ioctls
> > > > are meant to be (almost) drop-in replacements for the
> > > > write()/read()
> > > > async version 3 interface. They only accept the version 3
> > > > interface.
> > > 
> > > I don't think we should do this at all.  Anyone who wants to use
> > > the
> > > new async interfaces should use the v4 headers.  As Tony
> > > Battersby
> > > already said, the legacy v3 users aren't going to update, so
> > > there's no
> > > point at all introducing new interfaces for v3.  We simply keep
> > > the v3
> > > only read/write interface until there are no users left and it
> > > can be
> > > eliminated.
> > 
> > Tony Battersby wrote [20190809]:
> >    "Actually I used the asynchronous write()/read()/poll() sg
> > interface to
> >    implement RAID-like functionality for tape drives and medium
> > changers,
> >    in a commercial product that has been around since 2002.  These
> > days our
> >    products use a lot more disk I/O than tape I/O, so I don't write
> > much
> >    new code using the sg interface anymore, although that code is
> > still
> >    there and has to be maintained as needed.  So I don't have any
> > immediate
> >    plans to use any of the new sgv4 features being introduced, and
> >    unfortunately I am way too busy to even give it a good
> > review..."
> > 
> > That is quoted in full his post. And here is the only other post
> > from
> > Tony I can find on this subject, again quoted in full [20190808]:
> > 
> >    "One of the reasons ioctls have a bad reputation is because they
> > can be
> >    used to implement poorly-thought-out interfaces.  So kernel
> > maintainers
> >    push back on adding new ioctls.  But the push back isn't about
> > the
> >    number of ioctls, it is about the poor interfaces.  My advice
> > was that
> >    in general, to implement a given API, it would be better to add
> > more
> >    ioctls with a simple interface for each one rather than to add
> > fewer
> >    extremely complex multiplexing ioctls."
> > 
> > Call me biased but I believe that taken together those posts
> > support
> > what I am proposing. And I can _not_ see how you deduce: "so
> > there's
> > no point at all introducing new interfaces for v3" in reference to
> > Tony's posts.
> > 
> > 
> > As I stated in a previous post, I do not consider the sg v3
> > interface
> > as legacy. Where simply implemented, I am prepared to implement new
> > features on both the sg v3 and v4 interfaces. One example of this
> > is
> > doing command timing in nanoseconds rather than the current
> > default,
> > which is timing in milliseconds. There is also the new option of
> > not
> > doing any command timing at all. In my current implementation it
> > would
> > actually be more code to implement that for the v4 interface but
> > not
> > for the v3 interface.
> > 
> > Replicating my argument from a previous post:
> > If the kernel had an API mapping layer that was sensitive to file
> > descriptors of a "special file" (e.g. "/dev/sg3") then it could
> > map:
> >      write(sg_fd, &sg_io_v3_obj, sizeof(sg_io_v3_obj))
> > to
> >      ioctl(sg_fd, SG_IOSUBMIT_V3, &sg_io_v3_obj)
> > 
> > Plus a similar mapping for read() to ioctl(SG_IORECEIVE_V3). If
> > such
> > a mapping did exist and was transparent to the user then write()
> > and read() could be retired from the sg driver.  And I assume that
> > would get a thumbs up from the kernel security folk.
> > 
> 
> FWIW, my employer will probably continue to use the async sg v3
> interface for a long time.  If the read/write syscalls are a security
> problem, and if we had ioctl()s that are mostly a drop-in replacement
> for them, then we could convert our products over to the new ioctl()s
> on our next kernel upgrade without too much work (our products are
> embedded devices, so we control the whole software stack).  So if you
> plan to deprecate the read/write syscall interface anytime soon, then
> having drop-in replacement ioctl()s would be beneficial, even if it
> can't be done transparently as Doug suggests.

So far we've mitigated the security threat by withdrawing the v4
r/w interface which you don't use and keeping the sg nodes root only
for v3 r/w.  Unless we get another security incident based on them, as
long as the use case doesn't expand, I think the prior issue is pretty
nasty but contained to root who should know what they're doing, so
there's no pressing need to remove it.

Given that shifting to ioctls or a different async interface would be
development anyway, is there a solid reason you couldn't also shift to
v4 if you do that?  I know all the field names changed but for a
standard SCSI command it should be very similar to v3.

James


  reply	other threads:[~2019-08-12 18:46 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07 11:42 [PATCH v3 00/20] sg: add v4 interface Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 01/20] sg: move functions around Douglas Gilbert
2019-08-12 14:22   ` Christoph Hellwig
2019-08-07 11:42 ` [PATCH v3 02/20] sg: remove typedefs, type+formatting cleanup Douglas Gilbert
2019-08-12 14:22   ` Christoph Hellwig
2019-08-07 11:42 ` [PATCH v3 03/20] sg: sg_log and is_enabled Douglas Gilbert
2019-08-12 14:23   ` Christoph Hellwig
2019-08-13 22:57     ` Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 04/20] sg: rework sg_poll(), minor changes Douglas Gilbert
2019-08-12 14:23   ` Christoph Hellwig
2019-08-13  0:35     ` Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 05/20] sg: bitops in sg_device Douglas Gilbert
2019-08-12 14:23   ` Christoph Hellwig
2019-08-14  1:35     ` Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 06/20] sg: make open count an atomic Douglas Gilbert
2019-08-12 14:23   ` Christoph Hellwig
2019-08-07 11:42 ` [PATCH v3 07/20] sg: move header to uapi section Douglas Gilbert
2019-08-12 14:24   ` Christoph Hellwig
2019-08-12 14:32     ` Greg KH
2019-08-12 14:35     ` James Bottomley
2019-08-13  0:21     ` Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 08/20] sg: speed sg_poll and sg_get_num_waiting Douglas Gilbert
2019-08-12 14:31   ` Christoph Hellwig
2019-08-12 16:31     ` Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 09/20] sg: sg_allow_if_err_recovery and renames Douglas Gilbert
2019-08-12 14:31   ` Christoph Hellwig
2019-08-14  1:26     ` Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 10/20] sg: remove most access_ok functions Douglas Gilbert
2019-08-12 14:32   ` Christoph Hellwig
2019-08-07 11:42 ` [PATCH v3 11/20] sg: replace rq array with lists Douglas Gilbert
2019-08-12 14:35   ` Christoph Hellwig
2019-08-13 23:46     ` Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 12/20] sg: sense buffer rework Douglas Gilbert
2019-08-12 14:37   ` Christoph Hellwig
2019-08-12 16:26     ` Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 13/20] sg: add sg v4 interface support Douglas Gilbert
2019-08-09 23:12   ` James Bottomley
2019-08-11 19:21     ` Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 14/20] sg: rework debug info Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 15/20] sg: add 8 byte SCSI LUN to sg_scsi_id Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 16/20] sg: expand sg_comm_wr_t Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 17/20] sg: add sg_iosubmit_v3 and sg_ioreceive_v3 ioctls Douglas Gilbert
2019-08-09 23:15   ` James Bottomley
2019-08-12 15:37     ` Douglas Gilbert
2019-08-12 16:14       ` Tony Battersby
2019-08-12 18:46         ` James Bottomley [this message]
2019-08-12 19:37           ` Tony Battersby
2019-08-07 11:42 ` [PATCH v3 18/20] sg: add some __must_hold macros Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 19/20] sg: first debugfs support Douglas Gilbert
2019-08-07 11:42 ` [PATCH v3 20/20] sg: bump version to 4.0.03 Douglas Gilbert
2019-08-08 19:10 ` [PATCH v3 00/20] sg: add v4 interface James Bottomley
2019-08-08 21:08   ` Douglas Gilbert
2019-08-08 21:37     ` Tony Battersby
2019-08-08 22:25       ` Bart Van Assche
2019-08-09 13:28         ` Tony Battersby
2019-08-08 23:00     ` James Bottomley
2019-08-14  4:19       ` Douglas Gilbert
2019-08-15 17:30         ` Bart Van Assche
2019-08-16 15:59           ` Douglas Gilbert
2019-08-16 17:19             ` Greg KH
2019-08-16 18:10             ` Bart Van Assche
2019-08-16 18:44               ` Douglas Gilbert
2019-08-12 15:23   ` Christoph Hellwig

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=1565635563.3287.1.camel@linux.vnet.ibm.com \
    --to=jejb@linux.vnet.ibm.com \
    --cc=arnd@arndb.de \
    --cc=bvanassche@acm.org \
    --cc=dgilbert@interlog.com \
    --cc=hare@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=martin.petersen@oracle.com \
    --cc=tonyb@cybernetics.com \
    /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).