Re: [RFC 1/2] nvme: add whitelisting infrastructure

Christoph Hellwig
2022-09-10T05:35:44Z

On Fri, Sep 09, 2022 at 10:55:45AM -0600, Jens Axboe wrote:
> > +bool nvme_io_cmd_allowed(u8 opcode, fmode_t mode)
> > +{
> > + /* allow write/read based on what was allowed for open */
> > + /* TBD: try to use nvme_is_write() here */
> > + if (opcode & 1)
> > + return (mode & FMODE_WRITE);
> > + else
> > + return (mode & FMODE_READ);
> > +}
>
> The read/write distinction doesn't make a lot of sense to me. You've
> already been able to open the device at this point. It would only make
> sense to limit some things based on FMODE_WRITE imho, not FMODE_READ.

True. Note that the I/O queues can also send fabrics commands, which
we must exclude, and I'd also very much exclude vendor specific commands
as we can't trust them at all - they aren't even guaranteed to interpret
the nsid field like the standard ones.