nvme: prevent potential spectre v1 gadget
authorNitesh Shetty <nj.shetty@samsung.com>
Tue, 28 Nov 2023 12:29:57 +0000 (17:59 +0530)
committerKeith Busch <kbusch@kernel.org>
Mon, 4 Dec 2023 16:39:04 +0000 (08:39 -0800)
commit20dc66f2d76b4a410df14e4675e373b718babc34
treefb202350852461c940b808826d70c53d6f8e3903
parent29ac4b2f9263f52ba12fa35832cc6506ce3b4793
nvme: prevent potential spectre v1 gadget

This patch fixes the smatch warning, "nvmet_ns_ana_grpid_store() warn:
potential spectre issue 'nvmet_ana_group_enabled' [w] (local cap)"
Prevent the contents of kernel memory from being leaked to  user space
via speculative execution by using array_index_nospec.

Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/configfs.c