]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/tdx: Fix "in-kernel MMIO" check
authorAlexey Gladkov (Intel) <legion@kernel.org>
Fri, 13 Sep 2024 17:05:56 +0000 (19:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:33:44 +0000 (16:33 +0200)
commit18ecd5b74682839e7cdafb7cd1ec106df7baa18c
treefee3fd87f63d8d27c0ae22988b9766e47802e1ec
parent37263b5d4c18fba46fcfb8e5e2c6ead96ae779a3
x86/tdx: Fix "in-kernel MMIO" check

[ Upstream commit d4fc4d01471528da8a9797a065982e05090e1d81 ]

TDX only supports kernel-initiated MMIO operations. The handle_mmio()
function checks if the #VE exception occurred in the kernel and rejects
the operation if it did not.

However, userspace can deceive the kernel into performing MMIO on its
behalf. For example, if userspace can point a syscall to an MMIO address,
syscall does get_user() or put_user() on it, triggering MMIO #VE. The
kernel will treat the #VE as in-kernel MMIO.

Ensure that the target MMIO address is within the kernel before decoding
instruction.

Fixes: 31d58c4e557d ("x86/tdx: Handle in-kernel MMIO")
Signed-off-by: Alexey Gladkov (Intel) <legion@kernel.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc:stable@vger.kernel.org
Link: https://lore.kernel.org/all/565a804b80387970460a4ebc67c88d1380f61ad1.1726237595.git.legion%40kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/coco/tdx/tdx.c