All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1 0/2] Fix offset when fault occurs in strncpy_from_kernel_nofault()
@ 2022-11-08 19:52 Francis Laniel
  2022-11-08 19:52 ` [RFC PATCH v1 1/2] maccess: fix writing offset in case of fault " Francis Laniel
  2022-11-08 19:52 ` [RFC PATCH v1 2/2] selftests: bpf: add a test when bpf_probe_read_kernel_str() returns EFAULT Francis Laniel
  0 siblings, 2 replies; 10+ messages in thread
From: Francis Laniel @ 2022-11-08 19:52 UTC (permalink / raw)
  To: linux-kernel
  Cc: Alban Crequy, Francis Laniel, Andrew Morton, Andrii Nakryiko,
	Mykola Lysenko, Alexei Starovoitov, Daniel Borkmann,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Shuah Khan,
	Alban Crequy, linux-mm, bpf, linux-kselftest

Hi.


First of all, I hope you are fine and the same for your relatives.

This contribution fixes a bug where the byte before the destination address can
be reset when a page fault occurs in strncpy_from_kernel_nofault() while copying
the first byte from the source address.

This bug leaded to kernel panic if a pointer containing the modified address is
dereferenced as the pointer does not contain a correct addresss.

To fix this bug, we simply reset the current destination byte in a case of a
page fault.
The proposed fix was tested and validated inside a VM:
root@vm-amd64:~# ./share/linux/tools/testing/selftests/bpf/test_progs --name varlen
...
#222     varlen:OK
Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
Without the patch, the test will fail:
root@vm-amd64:~# ./share/linux/tools/testing/selftests/bpf/test_progs --name varlen
...
#222     varlen:FAIL
Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED

If you see any way to improve this contribution, feel free to share.

Alban Crequy (2):
  maccess: fix writing offset in case of fault in
    strncpy_from_kernel_nofault()
  selftests: bpf: add a test when bpf_probe_read_kernel_str() returns
    EFAULT

 mm/maccess.c                                    | 2 +-
 tools/testing/selftests/bpf/prog_tests/varlen.c | 7 +++++++
 tools/testing/selftests/bpf/progs/test_varlen.c | 5 +++++
 3 files changed, 13 insertions(+), 1 deletion(-)


Best regards and thank you in advance.
--
2.25.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-09 16:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 19:52 [RFC PATCH v1 0/2] Fix offset when fault occurs in strncpy_from_kernel_nofault() Francis Laniel
2022-11-08 19:52 ` [RFC PATCH v1 1/2] maccess: fix writing offset in case of fault " Francis Laniel
2022-11-08 20:35   ` Yonghong Song
2022-11-08 20:38     ` Yonghong Song
2022-11-09 11:23       ` Alban Crequy
2022-11-09 16:09         ` Yonghong Song
2022-11-08 21:05   ` Andrew Morton
2022-11-09 11:04     ` Francis Laniel
2022-11-08 19:52 ` [RFC PATCH v1 2/2] selftests: bpf: add a test when bpf_probe_read_kernel_str() returns EFAULT Francis Laniel
2022-11-08 22:06   ` Yonghong Song

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.