bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf 0/3] Fix the read of vsyscall page through bpf
@ 2024-01-19  7:30 Hou Tao
  2024-01-19  7:30 ` [PATCH bpf 1/3] x86/mm: Move is_vsyscall_vaddr() into mm_internal.h Hou Tao
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Hou Tao @ 2024-01-19  7:30 UTC (permalink / raw)
  To: x86, bpf
  Cc: Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, H . Peter Anvin, linux-kernel,
	xingwei lee, Jann Horn, houtao1

From: Hou Tao <houtao1@huawei.com>

Hi,

As reported by syzboot [1] and [2], when trying to read vsyscall page
by using bpf_probe_read_kernel() or bpf_probe_read(), oops will happen.

Thomas Gleixner had proposed a test patch [3], but it seems that no
formal patch is posted after about one month [4], so I post it instead
and add an Originally-from tag in patch #2.

Patch #1 makes is_vsyscall_vaddr() being a common helper. Patch #2 fixes
the problem by disallowing vsyscall page read for
copy_from_kernel_nofault(). Patch #3 adds one test case to ensure the
read of vsyscall page through bpf is rejected. Although vsyscall page
can be disabled by vsyscall=none, but it doesn't affect the reproduce of
the problem and the added test.

Comments are always welcome.

[1]: https://lore.kernel.org/bpf/CAG48ez06TZft=ATH1qh2c5mpS5BT8UakwNkzi6nvK5_djC-4Nw@mail.gmail.com/
[2]: https://lore.kernel.org/bpf/CABOYnLynjBoFZOf3Z4BhaZkc5hx_kHfsjiW+UWLoB=w33LvScw@mail.gmail.com/
[3]: https://lore.kernel.org/bpf/87r0jwquhv.ffs@tglx/
[4]: https://lore.kernel.org/bpf/e24b125c-8ff4-9031-6c53-67ff2e01f316@huaweicloud.com/

Hou Tao (3):
  x86/mm: Move is_vsyscall_vaddr() into mm_internal.h
  x86/mm: Disallow vsyscall page read for copy_from_kernel_nofault()
  selftest/bpf: Test the read of vsyscall page under x86-64

 arch/x86/mm/fault.c                           | 11 +---
 arch/x86/mm/maccess.c                         |  6 ++
 arch/x86/mm/mm_internal.h                     | 13 ++++
 .../selftests/bpf/prog_tests/read_vsyscall.c  | 61 +++++++++++++++++++
 .../selftests/bpf/progs/read_vsyscall.c       | 45 ++++++++++++++
 5 files changed, 127 insertions(+), 9 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/read_vsyscall.c
 create mode 100644 tools/testing/selftests/bpf/progs/read_vsyscall.c

-- 
2.29.2


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

end of thread, other threads:[~2024-01-25  7:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-19  7:30 [PATCH bpf 0/3] Fix the read of vsyscall page through bpf Hou Tao
2024-01-19  7:30 ` [PATCH bpf 1/3] x86/mm: Move is_vsyscall_vaddr() into mm_internal.h Hou Tao
2024-01-20  0:35   ` Sohil Mehta
2024-01-20  1:29     ` Hou Tao
2024-01-19  7:30 ` [PATCH bpf 2/3] x86/mm: Disallow vsyscall page read for copy_from_kernel_nofault() Hou Tao
2024-01-23  0:18   ` Sohil Mehta
2024-01-25  7:18     ` Hou Tao
2024-01-19  7:30 ` [PATCH bpf 3/3] selftest/bpf: Test the read of vsyscall page under x86-64 Hou Tao
2024-01-22  6:30   ` Yonghong Song
2024-01-25  6:37     ` Hou Tao
2024-01-23  0:25   ` Sohil Mehta
2024-01-25  7:54     ` Hou Tao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).