nvme: prevent potential spectre v1 gadget
authorNitesh Shetty <nj.shetty@samsung.com>
Tue, 28 Nov 2023 12:29:57 +0000 (17:59 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Jan 2024 10:51:41 +0000 (11:51 +0100)
commit946fd64ba361e500582787cb9b6342d9f11b0b29
tree8a526a68199772f06ca7258c018d4adaf65b34c1
parent8b2a6a3692e2c0b06125741181fda9aa8a7f3a49
nvme: prevent potential spectre v1 gadget

[ Upstream commit 20dc66f2d76b4a410df14e4675e373b718babc34 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/target/configfs.c