Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-22 Thread Christoph Hellwig
On Tue, Dec 22, 2020 at 09:17:41PM +0100, Florent Revest wrote: > On Tue, Dec 22, 2020 at 3:18 PM Christoph Hellwig wrote: > > > > FYI, there is a reason why kallsyms_lookup is not exported any more. > > I don't think adding that back through a backdoor is a good idea. > > Did you maybe mean

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-22 Thread Florent Revest
On Fri, Dec 18, 2020 at 4:20 AM Alexei Starovoitov wrote: > As far as 6 arg issue: > long bpf_snprintf(const char *out, u32 out_size, > const char *fmt, u32 fmt_size, > const void *data, u32 data_len); > Yeah. It won't work as-is, but fmt_size is unnecessary

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-22 Thread Florent Revest
On Fri, Dec 18, 2020 at 9:47 PM Andrii Nakryiko wrote: > > On Fri, Dec 18, 2020 at 12:36 PM Alexei Starovoitov > wrote: > > > > On Fri, Dec 18, 2020 at 10:53:57AM -0800, Andrii Nakryiko wrote: > > > On Thu, Dec 17, 2020 at 7:20 PM Alexei Starovoitov > > > wrote: > > > > > > > > On Thu, Dec 17,

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-22 Thread Florent Revest
On Tue, Dec 22, 2020 at 3:18 PM Christoph Hellwig wrote: > > FYI, there is a reason why kallsyms_lookup is not exported any more. > I don't think adding that back through a backdoor is a good idea. Did you maybe mean kallsyms_lookup_name (the one that looks an address up based on a symbol name)

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-22 Thread Christoph Hellwig
FYI, there is a reason why kallsyms_lookup is not exported any more. I don't think adding that back through a backdoor is a good idea.

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-18 Thread Andrii Nakryiko
On Fri, Dec 18, 2020 at 12:36 PM Alexei Starovoitov wrote: > > On Fri, Dec 18, 2020 at 10:53:57AM -0800, Andrii Nakryiko wrote: > > On Thu, Dec 17, 2020 at 7:20 PM Alexei Starovoitov > > wrote: > > > > > > On Thu, Dec 17, 2020 at 09:26:09AM -0800, Yonghong Song wrote: > > > > > > > > > > > > On

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-18 Thread Alexei Starovoitov
On Fri, Dec 18, 2020 at 10:53:57AM -0800, Andrii Nakryiko wrote: > On Thu, Dec 17, 2020 at 7:20 PM Alexei Starovoitov > wrote: > > > > On Thu, Dec 17, 2020 at 09:26:09AM -0800, Yonghong Song wrote: > > > > > > > > > On 12/17/20 7:31 AM, Florent Revest wrote: > > > > On Mon, Dec 14, 2020 at 7:47

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-18 Thread Andrii Nakryiko
On Thu, Dec 17, 2020 at 7:20 PM Alexei Starovoitov wrote: > > On Thu, Dec 17, 2020 at 09:26:09AM -0800, Yonghong Song wrote: > > > > > > On 12/17/20 7:31 AM, Florent Revest wrote: > > > On Mon, Dec 14, 2020 at 7:47 AM Yonghong Song wrote: > > > > On 12/11/20 6:40 AM, Florent Revest wrote: > > >

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-17 Thread Yonghong Song
On 12/17/20 7:20 PM, Alexei Starovoitov wrote: On Thu, Dec 17, 2020 at 09:26:09AM -0800, Yonghong Song wrote: On 12/17/20 7:31 AM, Florent Revest wrote: On Mon, Dec 14, 2020 at 7:47 AM Yonghong Song wrote: On 12/11/20 6:40 AM, Florent Revest wrote: On Wed, Dec 2, 2020 at 10:18 PM

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-17 Thread Alexei Starovoitov
On Thu, Dec 17, 2020 at 09:26:09AM -0800, Yonghong Song wrote: > > > On 12/17/20 7:31 AM, Florent Revest wrote: > > On Mon, Dec 14, 2020 at 7:47 AM Yonghong Song wrote: > > > On 12/11/20 6:40 AM, Florent Revest wrote: > > > > On Wed, Dec 2, 2020 at 10:18 PM Alexei Starovoitov > > > > wrote: >

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-17 Thread Yonghong Song
On 12/17/20 7:31 AM, Florent Revest wrote: On Mon, Dec 14, 2020 at 7:47 AM Yonghong Song wrote: On 12/11/20 6:40 AM, Florent Revest wrote: On Wed, Dec 2, 2020 at 10:18 PM Alexei Starovoitov wrote: I still think that adopting printk/vsnprintf for this instead of reinventing the wheel is

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-17 Thread Florent Revest
On Mon, Dec 14, 2020 at 7:47 AM Yonghong Song wrote: > On 12/11/20 6:40 AM, Florent Revest wrote: > > On Wed, Dec 2, 2020 at 10:18 PM Alexei Starovoitov > > wrote: > >> I still think that adopting printk/vsnprintf for this instead of > >> reinventing the wheel > >> is more flexible and easier to

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-13 Thread Yonghong Song
On 12/11/20 6:40 AM, Florent Revest wrote: On Wed, Dec 2, 2020 at 10:18 PM Alexei Starovoitov wrote: I still think that adopting printk/vsnprintf for this instead of reinventing the wheel is more flexible and easier to maintain long term. Almost the same layout can be done with vsnprintf

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-11 Thread Florent Revest
On Wed, Dec 2, 2020 at 10:18 PM Alexei Starovoitov wrote: > I still think that adopting printk/vsnprintf for this instead of > reinventing the wheel > is more flexible and easier to maintain long term. > Almost the same layout can be done with vsnprintf > with exception of \0 char. > More

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-02 Thread Alexei Starovoitov
On Wed, Dec 2, 2020 at 12:32 PM Florent Revest wrote: > > On Tue, 2020-12-01 at 16:55 -0800, Andrii Nakryiko wrote: > > On Fri, Nov 27, 2020 at 8:09 AM Yonghong Song wrote: > > > > > > > > > On 11/27/20 3:20 AM, KP Singh wrote: > > > > On Fri, Nov 27, 2020 at 8:35 AM Yonghong Song wrote: > > >

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-02 Thread Florent Revest
On Tue, 2020-12-01 at 16:55 -0800, Andrii Nakryiko wrote: > On Fri, Nov 27, 2020 at 8:09 AM Yonghong Song wrote: > > > > > > On 11/27/20 3:20 AM, KP Singh wrote: > > > On Fri, Nov 27, 2020 at 8:35 AM Yonghong Song wrote: > > > > > > > > In this case, module name may be truncated and user did

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-01 Thread Andrii Nakryiko
On Fri, Nov 27, 2020 at 8:09 AM Yonghong Song wrote: > > > > On 11/27/20 3:20 AM, KP Singh wrote: > > On Fri, Nov 27, 2020 at 8:35 AM Yonghong Song wrote: > >> > >> > >> > >> On 11/26/20 8:57 AM, Florent Revest wrote: > >>> This helper exposes the kallsyms_lookup function to eBPF tracing > >>>

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-01 Thread Andrii Nakryiko
On Fri, Nov 27, 2020 at 3:20 AM KP Singh wrote: > > On Fri, Nov 27, 2020 at 8:35 AM Yonghong Song wrote: > > > > > > > > On 11/26/20 8:57 AM, Florent Revest wrote: > > > This helper exposes the kallsyms_lookup function to eBPF tracing > > > programs. This can be used to retrieve the name of the

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-12-01 Thread Florent Revest
On Mon, 2020-11-30 at 18:41 -0800, Alexei Starovoitov wrote: > On Mon, Nov 30, 2020 at 05:23:22PM +0100, Florent Revest wrote: > > On Sat, 2020-11-28 at 17:07 -0800, Alexei Starovoitov wrote: > > > Looks like debug-only helper. > > > I cannot think of a way to use in production code. > > > What

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-30 Thread Alexei Starovoitov
On Mon, Nov 30, 2020 at 05:23:22PM +0100, Florent Revest wrote: > On Sat, 2020-11-28 at 17:07 -0800, Alexei Starovoitov wrote: > > On Thu, Nov 26, 2020 at 05:57:47PM +0100, Florent Revest wrote: > > > This helper exposes the kallsyms_lookup function to eBPF tracing > > > programs. This can be used

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-30 Thread Florent Revest
On Sat, 2020-11-28 at 17:07 -0800, Alexei Starovoitov wrote: > On Thu, Nov 26, 2020 at 05:57:47PM +0100, Florent Revest wrote: > > This helper exposes the kallsyms_lookup function to eBPF tracing > > programs. This can be used to retrieve the name of the symbol at an > > address. For example, when

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-28 Thread Alexei Starovoitov
On Thu, Nov 26, 2020 at 05:57:47PM +0100, Florent Revest wrote: > This helper exposes the kallsyms_lookup function to eBPF tracing > programs. This can be used to retrieve the name of the symbol at an > address. For example, when hooking into nf_register_net_hook, one can > audit the name of the

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-27 Thread kernel test robot
Hi Florent, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on bpf-next/master] url: https://github.com/0day-ci/linux/commits/Florent-Revest/bpf-Add-a-bpf_kallsyms_lookup-helper/20201127-010044 base:

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-27 Thread Yonghong Song
On 11/27/20 3:20 AM, KP Singh wrote: On Fri, Nov 27, 2020 at 8:35 AM Yonghong Song wrote: On 11/26/20 8:57 AM, Florent Revest wrote: This helper exposes the kallsyms_lookup function to eBPF tracing programs. This can be used to retrieve the name of the symbol at an address. For example,

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-27 Thread KP Singh
On Fri, Nov 27, 2020 at 8:35 AM Yonghong Song wrote: > > > > On 11/26/20 8:57 AM, Florent Revest wrote: > > This helper exposes the kallsyms_lookup function to eBPF tracing > > programs. This can be used to retrieve the name of the symbol at an > > address. For example, when hooking into

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-27 Thread Florent Revest
On Fri, 2020-11-27 at 10:25 +0100, Florent Revest wrote: > I prefer Yongonhong's suggestion of having two helpers. Argh! I hit enter too fast! Yonghong*, sorry :|

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-27 Thread Florent Revest
On Fri, 2020-11-27 at 03:32 +0100, KP Singh wrote: > > + ret = strlen(name) + 1; > > + if (symbol_size) { > > + strncpy(symbol, name, symbol_size); > > + symbol[symbol_size - 1] = '\0'; > > + } > > + > > + if (modname && module_size) { > > +

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-27 Thread Florent Revest
On Thu, 2020-11-26 at 23:35 -0800, Yonghong Song wrote: > On 11/26/20 8:57 AM, Florent Revest wrote: > > +BPF_CALL_5(bpf_kallsyms_lookup, u64, address, char *, symbol, u32, > > symbol_size, > > + char *, module, u32, module_size) > > +{ > > + char buffer[KSYM_SYMBOL_LEN]; > > + unsigned

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-26 Thread Yonghong Song
On 11/26/20 8:57 AM, Florent Revest wrote: This helper exposes the kallsyms_lookup function to eBPF tracing programs. This can be used to retrieve the name of the symbol at an address. For example, when hooking into nf_register_net_hook, one can audit the name of the registered netfilter hook

Re: [PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-26 Thread KP Singh
[...] > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > index c3458ec1f30a..670998635eac 100644 > --- a/include/uapi/linux/bpf.h > +++ b/include/uapi/linux/bpf.h > @@ -3817,6 +3817,21 @@ union bpf_attr { > * The **hash_algo** is returned on success, > *

[PATCH bpf-next 1/2] bpf: Add a bpf_kallsyms_lookup helper

2020-11-26 Thread Florent Revest
This helper exposes the kallsyms_lookup function to eBPF tracing programs. This can be used to retrieve the name of the symbol at an address. For example, when hooking into nf_register_net_hook, one can audit the name of the registered netfilter hook and potentially also the name of the module in