Subject: CVE-2022-49004: riscv: Sync efi page table's kernel mappings before switching

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

riscv: Sync efi page table's kernel mappings before switching

The EFI page table is initially created as a copy of the kernel page table.
With VMAP_STACK enabled, kernel stacks are allocated in the vmalloc area:
if the stack is allocated in a new PGD (one that was not present at the
moment of the efi page table creation or not synced in a previous vmalloc
fault), the kernel will take a trap when switching to the efi page table
when the vmalloc kernel stack is accessed, resulting in a kernel panic.

Fix that by updating the efi kernel mappings before switching to the efi
page table.

The Linux kernel CVE team has assigned CVE-2022-49004 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 5.10 with commit b91540d52a08 and fixed in 5.15.82 with commit fa7a7d185ef3
	Issue introduced in 5.10 with commit b91540d52a08 and fixed in 6.0.12 with commit 96f479383d92
	Issue introduced in 5.10 with commit b91540d52a08 and fixed in 6.1 with commit 3f105a742725

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2022-49004
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	arch/riscv/include/asm/efi.h
	arch/riscv/include/asm/pgalloc.h

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/fa7a7d185ef380546b4b1fed6f84f31dbae8cec7
	https://git.kernel.org/stable/c/96f479383d92944406d4b3f2bc03c2f640def9f1
	https://git.kernel.org/stable/c/3f105a742725a1b78766a55169f1d827732e62b8