nvme: consult the CSE log page for unprivileged passthrough
authorChristoph Hellwig <hch@lst.de>
Tue, 13 Dec 2022 15:13:38 +0000 (16:13 +0100)
committerChristoph Hellwig <hch@lst.de>
Wed, 28 Dec 2022 16:26:31 +0000 (06:26 -1000)
commit6f99ac04c469b5d0a180a4ccea99d25d5dc9d21c
treec1f058709af3082050c3219bfd1d06ba686d11ac
parent831ed60c2aca2d7c517b2da22897a90224a97d27
nvme: consult the CSE log page for unprivileged passthrough

Commands like Write Zeros can change the contents of a namespaces without
actually transferring data.  To protect against this, check the Commands
Supported and Effects log is supported by the controller for any
unprivileg command passthrough and refuse unprivileged passthrough if the
command has any effects that can change data or metadata.

Note: While the Commands Support and Effects log page has only been
mandatory since NVMe 2.0, it is widely supported because Windows requires
it for any command passthrough from userspace.

Fixes: e4fbcf32c860 ("nvme: identify-namespace without CAP_SYS_ADMIN")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
drivers/nvme/host/ioctl.c
include/linux/nvme.h