RE: [PATCH v5 1/5] x86/mce: Add wrapper for struct mce to export vendor specific info

2024-10-14 Thread Zhuo, Qiuxu
> From: Avadhut Naik > [...] > diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index > 3b9970117a0f..3c86b838b541 100644 > --- a/arch/x86/include/asm/mce.h > +++ b/arch/x86/include/asm/mce.h > @@ -187,6 +187,14 @@ enum mce_notifier_prios { > MCE_PRIO_HIGHEST = MCE_PRIO_C

[PATCH v2] uprobe: avoid out-of-bounds memory access of fetching args

2024-10-14 Thread Ma Qiao
From: Qiao Ma Uprobe needs to fetch args into a percpu buffer, and then copy to ring buffer to avoid non-atomic context problem. Sometimes user-space strings, arrays can be very large, but the size of percpu buffer is only page size. And store_trace_args() won't check whether these data exceeds

Re: [PATCH v5 7/8] execmem: add support for cache of large ROX pages

2024-10-14 Thread Mike Rapoport
On Mon, Oct 14, 2024 at 09:09:49PM -0700, Luis Chamberlain wrote: > Mike, please run this with kmemleak enabled and running, and also try to get > tools/testing/selftests/kmod/kmod.sh to pass. There was an issue with kmemleak, I fixed it here: https://lore.kernel.org/linux-mm/20241009180816.83591

Re: [PATCH] uprobe: avoid out-of-bounds memory access of fetching args

2024-10-14 Thread maqiao.mq
> 2024年10月14日 下午10:40,Masami Hiramatsu (Google) 写道: > > On Mon, 14 Oct 2024 14:14:05 +0800 > Ma Qiao wrote: > >> From: Qiao Ma >> >> Uprobe needs to fetch args into a percpu buffer, and then copy to ring >> buffer to avoid non-atomic context problem. >> >> Sometimes user-space strings, ar

Re: [PATCH v5 7/8] execmem: add support for cache of large ROX pages

2024-10-14 Thread Luis Chamberlain
Mike, please run this with kmemleak enabled and running, and also try to get tools/testing/selftests/kmod/kmod.sh to pass. I run into silly boot issues with just a guest. Luis

Re: [PATCH] uprobe: avoid out-of-bounds memory access of fetching args

2024-10-14 Thread maqiao . mq
> 2024年10月14日 下午10:58,Oleg Nesterov 写道: > > Sorry, currently I don't have time to even try to read this patch, just > one note below... > > On 10/14, Ma Qiao wrote: >> >> @@ -979,6 +980,11 @@ static struct uprobe_cpu_buffer >> *prepare_uprobe_buffer(struct trace_uprobe *tu, >> ucb = up

[PATCH v16 06/18] fprobe: Use ftrace_regs in fprobe entry handler

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) This allows fprobes to be available with CONFIG_DYNAMIC_FTRACE_WITH_ARGS instead of CONFIG_DYNAMIC_FTRACE_WITH_REGS, then we can enable fprobe on arm64. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Florent Revest --- Changes in v6: - Keep using SAVE_REG

[PATCH v16 18/18] bpf: Add get_entry_ip() for arm64

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add get_entry_ip() implementation for arm64. This is based on the information in ftrace_call_adjust() on arm64. Basically function entry address = ftrace call entry_ip - 4, but when there is a BTI at the first instruction, we need one more instruction back (entry_i

[PATCH v16 17/18] Documentation: probes: Update fprobe on function-graph tracer

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Update fprobe documentation for the new fprobe on function-graph tracer. This includes some bahvior changes and pt_regs to ftrace_regs interface change. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Update @fregs parameter explanation. --- Doc

[PATCH v16 16/18] selftests/ftrace: Add a test case for repeating register/unregister fprobe

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) This test case repeats define and undefine the fprobe dynamic event to ensure that the fprobe does not cause any issue with such operations. Signed-off-by: Masami Hiramatsu (Google) --- .../test.d/dynevent/add_remove_fprobe_repeat.tc| 19 ++

[PATCH v16 15/18] selftests: ftrace: Remove obsolate maxactive syntax check

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Since the fprobe event does not support maxactive anymore, stop testing the maxactive syntax error checking. Signed-off-by: Masami Hiramatsu (Google) --- .../ftrace/test.d/dynevent/fprobe_syntax_errors.tc |4 +--- 1 file changed, 1 insertion(+), 3 deletions(

[PATCH v16 14/18] tracing/fprobe: Remove nr_maxactive from fprobe

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Remove depercated fprobe::nr_maxactive. This involves fprobe events to rejects the maxactive number. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v2: - Newly added. --- include/linux/fprobe.h |2 -- kernel/trace/trace_fprobe.c | 43 +

[PATCH v16 13/18] fprobe: Rewrite fprobe on function-graph tracer

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Rewrite fprobe implementation on function-graph tracer. Major API changes are: - 'nr_maxactive' field is deprecated. - This depends on CONFIG_DYNAMIC_FTRACE_WITH_ARGS or !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS, and CONFIG_HAVE_FUNCTION_GRAPH_FREGS. So cur

[PATCH v16 12/18] ftrace: Add CONFIG_HAVE_FTRACE_GRAPH_FUNC

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add CONFIG_HAVE_FTRACE_GRAPH_FUNC kconfig in addition to ftrace_graph_func macro check. This is for the other feature (e.g. FPROBE) which requires to access ftrace_regs from fgraph_ops::entryfunc() can avoid compiling if the fgraph can not pass the valid ftrace_reg

[PATCH v16 11/18] bpf: Enable kprobe_multi feature if CONFIG_FPROBE is enabled

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Enable kprobe_multi feature if CONFIG_FPROBE is enabled. The pt_regs is converted from ftrace_regs by ftrace_partial_regs(), thus some registers may always returns 0. But it should be enough for function entry (access arguments) and exit (access return value). Sig

[PATCH v16 10/18] tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Allow fprobe events to be enabled with CONFIG_DYNAMIC_FTRACE_WITH_ARGS. With this change, fprobe events mostly use ftrace_regs instead of pt_regs. Note that if the arch doesn't enable HAVE_FTRACE_REGS_HAVING_PT_REGS, fprobe events will not be able to be used from p

[PATCH v16 09/18] tracing: Add ftrace_fill_perf_regs() for perf event

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_fill_perf_regs() which should be compatible with the perf_fetch_caller_regs(). In other words, the pt_regs returned from the ftrace_fill_perf_regs() must satisfy 'user_mode(regs) == false' and can be used for stack tracing. Signed-off-by: Masami Hiramat

[PATCH v16 08/18] tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Add ftrace_partial_regs() which converts the ftrace_regs to pt_regs. This is for the eBPF which needs this to keep the same pt_regs interface to access registers. Thus when replacing the pt_regs with ftrace_regs in fprobes (which is used by kprobe_multi eBPF event)

[PATCH v16 07/18] fprobe: Use ftrace_regs in fprobe exit handler

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Change the fprobe exit handler to use ftrace_regs structure instead of pt_regs. This also introduce HAVE_FTRACE_REGS_HAVING_PT_REGS which means the ftrace_regs is including the pt_regs so that ftrace_regs can provide pt_regs without memory allocation. Fprobe introd

[PATCH v16 05/18] function_graph: Pass ftrace_regs to retfunc

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Pass ftrace_regs to the fgraph_ops::retfunc(). If ftrace_regs is not available, it passes a NULL instead. User callback function can access some registers (including return address) via this ftrace_regs. Signed-off-by: Masami Hiramatsu (Google) --- Changes in v8

[PATCH v16 04/18] function_graph: Replace fgraph_ret_regs with ftrace_regs

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Use ftrace_regs instead of fgraph_ret_regs for tracing return value on function_graph tracer because of simplifying the callback interface. The CONFIG_HAVE_FUNCTION_GRAPH_RETVAL is also replaced by CONFIG_HAVE_FUNCTION_GRAPH_FREGS. Signed-off-by: Masami Hiramatsu

[PATCH v16 03/18] function_graph: Pass ftrace_regs to entryfunc

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Pass ftrace_regs to the fgraph_ops::entryfunc(). If ftrace_regs is not available, it passes a NULL instead. User callback function can access some registers (including return address) via this ftrace_regs. Note that the ftrace_regs can be NULL when the arch does N

[PATCH v16 02/18] tracing: Rename ftrace_regs_return_value to ftrace_regs_get_return_value

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Rename ftrace_regs_return_value to ftrace_regs_get_return_value as same as other ftrace_regs_get/set_* APIs. arm64 and riscv are already using this new name. Signed-off-by: Masami Hiramatsu (Google) Acked-by: Mark Rutland --- Changes in v16: - Simplified acco

[PATCH v16 01/18] tracing: Use arch_ftrace_regs() for ftrace_regs_*() macros

2024-10-14 Thread Masami Hiramatsu (Google)
From: Masami Hiramatsu (Google) Since the arch_ftrace_get_regs(fregs) is only valid when the FL_SAVE_REGS is set, we need to use `&arch_ftrace_regs()->regs` for ftrace_regs_*() APIs because those APIs are for ftrace_regs, not complete pt_regs. Signed-off-by: Masami Hiramatsu (Google) --- inclu

[PATCH v16 00/18] tracing: fprobe: function_graph: Multi-function graph and fprobe on fgraph

2024-10-14 Thread Masami Hiramatsu (Google)
Hi, Here is the 16th version of the series to re-implement the fprobe on function-graph tracer. The previous version is; https://lore.kernel.org/all/172639136989.366111.11359590127009702129.stgit@devnote2/T/#u This version rebased on for-next branch on linux-trace tree (thus it is rebased on ftr

Have compiler remove __fentry locations from overwritten weak functions

2024-10-14 Thread Steven Rostedt
There's a long standing issue with having fentry in weak functions that were overwritten. This was first caught when a "notrace" function was showing up in the /sys/kernel/tracing/available_filter_functions list. https://lore.kernel.org/all/20220412094923.0abe90955e5db486b7bca...@kernel.org/

Re: [PATCH] ring-buffer: Fix reader locking when changing the sub buffer order

2024-10-14 Thread Steven Rostedt
On Mon, 14 Oct 2024 16:14:16 +0200 Petr Pavlu wrote: > The function ring_buffer_subbuf_order_set() updates each > ring_buffer_per_cpu and installs new sub buffers that match the requested > page order. This operation may be invoked concurrently with readers that > rely on some of the modified dat

Re: [PATCH v2] tracing: replace multiple deprecated strncpy with memcpy

2024-10-14 Thread Steven Rostedt
On Mon, 14 Oct 2024 14:31:29 -0700 Kees Cook wrote: > > We know the destination must have a NUL-terminated string. Is the src > NUL terminated? Looking at parse_pred(), it seems like no? And we can't > use memtostr_pad() here because the source buffer size isn't known at > compile time. Okay then

Re: [PATCH v2] tracing: replace multiple deprecated strncpy with memcpy

2024-10-14 Thread Kees Cook
On Mon, Oct 14, 2024 at 02:13:14PM -0700, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings [1] and > as such we should prefer more robust and less ambiguous string interfaces. > > String copy operations involving manual pointer offset and length > calcula

[PATCH v2] tracing: replace multiple deprecated strncpy with memcpy

2024-10-14 Thread Justin Stitt
strncpy() is deprecated for use on NUL-terminated destination strings [1] and as such we should prefer more robust and less ambiguous string interfaces. String copy operations involving manual pointer offset and length calculations followed by explicit NUL-byte assignments are best changed to eith

Re: [PATCH v3 tip/perf/core 1/4] mm: introduce mmap_lock_speculation_{start|end}

2024-10-14 Thread Suren Baghdasaryan
On Mon, Oct 14, 2024 at 1:27 PM Andrii Nakryiko wrote: > > On Sun, Oct 13, 2024 at 12:56 AM Shakeel Butt wrote: > > > > On Thu, Oct 10, 2024 at 01:56:41PM GMT, Andrii Nakryiko wrote: > > > From: Suren Baghdasaryan > > > > > > Add helper functions to speculatively perform operations without > > >

Re: [PATCH v3 tip/perf/core 1/4] mm: introduce mmap_lock_speculation_{start|end}

2024-10-14 Thread Andrii Nakryiko
On Sun, Oct 13, 2024 at 12:56 AM Shakeel Butt wrote: > > On Thu, Oct 10, 2024 at 01:56:41PM GMT, Andrii Nakryiko wrote: > > From: Suren Baghdasaryan > > > > Add helper functions to speculatively perform operations without > > read-locking mmap_lock, expecting that mmap_lock will not be > > write-

Re: [PATCH v5 7/8] execmem: add support for cache of large ROX pages

2024-10-14 Thread Luis Chamberlain
On Sun, Oct 13, 2024 at 08:26:26PM -0700, Andrew Morton wrote: > On Sun, 13 Oct 2024 11:43:41 +0300 Mike Rapoport wrote: > > > > > The idea is to keep everything together and have execmem_info describe > > > > all > > > > that architecture needs. > > > > > > But why? That's pretty different f

[PATCH v5 1/5] x86/mce: Add wrapper for struct mce to export vendor specific info

2024-10-14 Thread Naik, Avadhut
On 10/14/2024 01:04, Zhuo, Qiuxu wrote: >> From: Avadhut Naik >> [...] >> Subject: [PATCH v5 1/5] x86/mce: Add wrapper for struct mce to export vendor >> [...] >> --- a/arch/x86/include/asm/mce.h >> +++ b/arch/x86/include/asm/mce.h >> @@ -187,6 +187,14 @@ enum mce_notifier_prios { >> MCE_P

Re: [RFC PATCH v1 18/57] trace: Remove PAGE_SIZE compile-time constant assumption

2024-10-14 Thread Steven Rostedt
On Mon, 14 Oct 2024 11:58:25 +0100 Ryan Roberts wrote: > To prepare for supporting boot-time page size selection, refactor code > to remove assumptions about PAGE_SIZE being compile-time constant. Code > intended to be equivalent when compile-time page size is active. > > Convert BUILD_BUG_ON()

Re: tools/rtla: Fix installation from out-of-tree build

2024-10-14 Thread Steven Rostedt
On Sun, 13 Oct 2024 22:34:49 +0200 Ben Hutchings wrote: > > Is Debian using out of tree builds Ben? > [...] > > In the linux package specifically, yes, we try to do all builds out-of- > tree. Right. Out-of-tree builds is pretty much a must for anything in the Linux kernel tree. -- Steve

Re: [PATCH] uprobe: avoid out-of-bounds memory access of fetching args

2024-10-14 Thread Oleg Nesterov
Sorry, currently I don't have time to even try to read this patch, just one note below... On 10/14, Ma Qiao wrote: > > @@ -979,6 +980,11 @@ static struct uprobe_cpu_buffer > *prepare_uprobe_buffer(struct trace_uprobe *tu, > ucb = uprobe_buffer_get(); > ucb->dsize = tu->tp.size + dsize

Re: [PATCH] uprobe: avoid out-of-bounds memory access of fetching args

2024-10-14 Thread Google
On Mon, 14 Oct 2024 14:14:05 +0800 Ma Qiao wrote: > From: Qiao Ma > > Uprobe needs to fetch args into a percpu buffer, and then copy to ring > buffer to avoid non-atomic context problem. > > Sometimes user-space strings, arrays can be very large, but the size of > percpu buffer is only page si

[PATCH] ring-buffer: Fix reader locking when changing the sub buffer order

2024-10-14 Thread Petr Pavlu
The function ring_buffer_subbuf_order_set() updates each ring_buffer_per_cpu and installs new sub buffers that match the requested page order. This operation may be invoked concurrently with readers that rely on some of the modified data, such as the head bit (RB_PAGE_HEAD), or the ring_buffer_per_

Re: [PATCH v5 7/8] execmem: add support for cache of large ROX pages

2024-10-14 Thread Mike Rapoport
On Sun, Oct 13, 2024 at 10:55:25PM -0700, Christoph Hellwig wrote: > On Sun, Oct 13, 2024 at 11:43:41AM +0300, Mike Rapoport wrote: > > > But why? That's pretty different from our normal style of arch hooks, > > > and introduces an indirect call in a security sensitive area. > > > > Will change t

[RFC PATCH v1 18/57] trace: Remove PAGE_SIZE compile-time constant assumption

2024-10-14 Thread Ryan Roberts
To prepare for supporting boot-time page size selection, refactor code to remove assumptions about PAGE_SIZE being compile-time constant. Code intended to be equivalent when compile-time page size is active. Convert BUILD_BUG_ON() BUG_ON() since the argument depends on PAGE_SIZE and its not trivia

Re: [PATCH 1/2] rtla/timerlat: Make timerlat_top_cpu->*_count unsigned long long

2024-10-14 Thread Tomas Glozar
pá 11. 10. 2024 v 19:23 odesílatel Steven Rostedt napsal: > > Thanks, I'm applying these, but could you or someone else create a test > directory in rtla and even rv that tests this code. I just examine it and > run some basic operations, but I have no idea if it is really working or not. > > Havi

Re: [PATCH] tools/rtla: Enhance Error Handling and Readability for timerlat

2024-10-14 Thread Tomas Glozar
so 5. 10. 2024 v 19:21 odesílatel furkanonder napsal: > > The enhancements made to timerlat_load.py focus on improving error > handling, readability, and overall user experience. These changes aim to > make the script more robust and easier to maintain while providing clearer > feedback to users.

Re: [syzbot] [fs?] [mm?] stack segment fault in folio_wait_writeback

2024-10-14 Thread Dmitry Vyukov
On Sun, 13 Oct 2024 at 13:01, syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit:7234e2ea0edd Merge tag 'scsi-fixes' of git://git.kernel.or.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=157a085f98 > kernel config: h