From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 3/3] selftests/bpf: Test PROBE_MEM loads from invalid addresses
Date: Tue, 01 Dec 2026 01:16:40 +0000 [thread overview]
Message-ID: <sashiko-outbox-242313@kernel.org> (raw)
In-Reply-To: <bc5804a5e45cb8e30e31a0305a56255e23204867.1796086624.git.memxor@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] selftests/bpf: probe_mem_fault uses LoongArch64 DMW0 base as
non-canonical
--
commit 86780e4477a0aeef39bfb4a6c844fecd37572420
Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>
selftests/bpf: Test PROBE_MEM loads from invalid addresses
This commit adds a BPF selftest that checks PROBE_MEM loads of three sizes
from various invalid addresses and verifies that each load produces zero
without oopsing the kernel.
> diff --git a/tools/testing/selftests/bpf/prog_tests/probe_mem_fault.c b/tools/testing/selftests/bpf/prog_tests/probe_mem_fault.c
> new file mode 100644
> index 0000000000000..9b89864b9ac24
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/probe_mem_fault.c
> @@ -0,0 +1,77 @@
[ ... ]
> +static const struct {
> + const char *name;
> + __u64 addr;
> +} bad_addrs[] = {
> +#if !defined(__s390x__)
> + /* s390x has its lowcore at these addresses, so the loads read it. */
> + { "null", 0 },
> + { "low_user", 4096 },
> +#endif
> + { "last_user_page_4l", (1ULL << 47) - 2 * 4096 },
> + { "guard_page_4l", (1ULL << 47) - 4096 },
> + { "last_user_page_5l", (1ULL << 56) - 2 * 4096 },
> + { "guard_page_5l", (1ULL << 56) - 4096 },
> + { "non_canonical", 1ULL << 63 },
[Severity: Medium]
Is 1ULL << 63 guaranteed to fault or be rejected in bad_addrs[] on 64-bit
LoongArch?
On LoongArch64, do_misc_fixups() only zeroes addresses whose upper 32 bits
are at or below TASK_SIZE >> 32, and 0x8000000000000000 is CSR_DMW0_BASE
(UNCACHE_BASE), the base of Direct Mapping Window 0 enabled in kernel mode:
arch/loongarch/include/asm/loongarch.h:
#define CSR_DMW0_PLV0 _CONST64_(1 << 0)
#define CSR_DMW0_VSEG _CONST64_(0x8000)
#define CSR_DMW0_BASE (CSR_DMW0_VSEG << DMW_PABITS)
#define CSR_DMW0_INIT (CSR_DMW0_BASE | CSR_DMW0_PLV0)
Instead of raising an exception, the PROBE_MEM loads access physical address
0x0 directly with uncached attributes, which fails the zero assertions in
test_probe_mem_fault() if low physical memory contains non-zero data or
triggers an uncached MMIO read if physical address 0x0 is not backed by RAM.
Using an address outside the direct mapping windows such as 1ULL << 60 (as in
bpf_testmod_return_ptr()) faults on LoongArch64 while remaining non-canonical
on x86-64.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796086624.git.memxor@gmail.com?part=3
prev parent reply other threads:[~2026-12-01 1:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 0:57 [PATCH bpf-next v3 0/3] bpf, x86: Drop the PROBE_MEM address range check under SMAP Kumar Kartikeya Dwivedi
2026-12-01 0:58 ` [PATCH bpf-next v3 1/3] x86/mm: Resolve BPF exception fixups for user address faults " Kumar Kartikeya Dwivedi
2026-12-01 0:58 ` [PATCH bpf-next v3 2/3] bpf, x86: Skip the PROBE_MEM address range check " Kumar Kartikeya Dwivedi
2026-12-01 0:58 ` [PATCH bpf-next v3 3/3] selftests/bpf: Test PROBE_MEM loads from invalid addresses Kumar Kartikeya Dwivedi
2026-12-01 1:16 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-242313@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox