From: "Björn Töpel" <bjorn@kernel.org>
To: Ruan Jinjie <ruanjinjie@huawei.com>,
paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, palmer@rivosinc.com
Subject: Re: [PATCH v3] riscv: fix kprobe __user string arg print fault issue
Date: Fri, 02 Jun 2023 11:41:13 +0200 [thread overview]
Message-ID: <87cz2ei4li.fsf@all.your.base.are.belong.to.us> (raw)
In-Reply-To: <c9b6939c-f072-c4aa-b721-3cd0b2fd5635@huawei.com>
Ruan Jinjie <ruanjinjie@huawei.com> writes:
> Ping.
Maybe it's not clear *why* we need
ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE on RISC-V?
ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE is used in the kernel to
determine what "memory access" function to use, e.g.
| #ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
| if ((unsigned long)str_val < TASK_SIZE)
| ret = strncpy_from_user_nofault(str_field, str_val, STR_VAR_LEN_MAX);
| else
| #endif
| ret = strncpy_from_kernel_nofault(str_field, str_val, STR_VAR_LEN_MAX);
RISC-V makes use of the SUM bit [1], which requires the kernel flips a
bit explicitly to touch user memory, so it's important to use the
correct access function.
What this means, is that if
CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE is *not* defined for RV
kernels, the copy_from_kernel will fault (as Jinjie points out in the
commit message).
The fixes tag should be when Daniel Borkmann introduced the config -- or
that makes sense from a backport perspective.
Maybe Palmer can add a lore link to this post, and the following
fixes-tag
Fixes: 0ebeea8ca8a4 ("bpf: Restrict bpf_probe_read{, str}() only to archs where they work")
when applying?
Björn
[1] https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc?plain=1#L118
next prev parent reply other threads:[~2023-06-02 9:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-04 7:29 [PATCH v3] riscv: fix kprobe __user string arg print fault issue Ruan Jinjie
2023-05-15 11:55 ` Ruan Jinjie
2023-06-02 9:41 ` Björn Töpel [this message]
2023-06-08 18:53 ` Palmer Dabbelt
2023-06-08 19:00 ` patchwork-bot+linux-riscv
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=87cz2ei4li.fsf@all.your.base.are.belong.to.us \
--to=bjorn@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.com \
--cc=ruanjinjie@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).