maccess: Fix writing offset in case of fault in strncpy_from_kernel_nofault()
authorAlban Crequy <albancrequy@linux.microsoft.com>
Thu, 10 Nov 2022 08:56:13 +0000 (09:56 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2022 08:24:47 +0000 (09:24 +0100)
commit9648d760edf4320e23e2b819037501fb44cba291
tree1d2a50a158765eccf02e7b4312de8dbf75942352
parentfdd57c20d4408cac3c3c535c120d244e083406c9
maccess: Fix writing offset in case of fault in strncpy_from_kernel_nofault()

commit 8678ea06852cd1f819b870c773d43df888d15d46 upstream.

If a page fault occurs while copying the first byte, this function resets one
byte before dst.
As a consequence, an address could be modified and leaded to kernel crashes if
case the modified address was accessed later.

Fixes: b58294ead14c ("maccess: allow architectures to provide kernel probing directly")
Signed-off-by: Alban Crequy <albancrequy@linux.microsoft.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Francis Laniel <flaniel@linux.microsoft.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: <stable@vger.kernel.org> [5.8]
Link: https://lore.kernel.org/bpf/20221110085614.111213-2-albancrequy@linux.microsoft.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/maccess.c