<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/bpf/preload, branch v5.17</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.17</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.17'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2021-10-20T17:39:04Z</updated>
<entry>
<title>bpf/preload: Clean up .gitignore and "clean-files" target</title>
<updated>2021-10-20T17:39:04Z</updated>
<author>
<name>Quentin Monnet</name>
<email>quentin@isovalent.com</email>
</author>
<published>2021-10-20T09:46:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5f52d47c5f75a955ae29c59bed2ca886faba0ff4'/>
<id>urn:sha1:5f52d47c5f75a955ae29c59bed2ca886faba0ff4</id>
<content type='text'>
kernel/bpf/preload/Makefile was recently updated to have it install
libbpf's headers locally instead of pulling them from tools/lib/bpf. But
two items still need to be addressed.

First, the local .gitignore file was not adjusted to ignore the files
generated in the new kernel/bpf/preload/libbpf output directory.

Second, the "clean-files" target is now incorrect. The old artefacts
names were not removed from the target, while the new ones were added
incorrectly. This is because "clean-files" expects names relative to
$(obj), but we passed the absolute path instead. This results in the
output and header-destination directories for libbpf (and their
contents) not being removed from kernel/bpf/preload on "make clean" from
the root of the repository.

This commit fixes both issues. Note that $(userprogs) needs not be added
to "clean-files", because the cleaning infrastructure already accounts
for it.

Cleaning the files properly also prevents make from printing the
following message, for builds coming after a "make clean":
"make[4]: Nothing to be done for 'install_headers'."

v2: Simplify the "clean-files" target.

Fixes: bf60791741d4 ("bpf: preload: Install libbpf headers when building")
Signed-off-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Link: https://lore.kernel.org/bpf/20211020094647.15564-1-quentin@isovalent.com
</content>
</entry>
<entry>
<title>bpftool: Add install-bin target to install binary only</title>
<updated>2021-10-08T19:02:40Z</updated>
<author>
<name>Quentin Monnet</name>
<email>quentin@isovalent.com</email>
</author>
<published>2021-10-07T19:44:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d7db0a4e8d95101ebb545444578ba7085c270e5f'/>
<id>urn:sha1:d7db0a4e8d95101ebb545444578ba7085c270e5f</id>
<content type='text'>
With "make install", bpftool installs its binary and its bash completion
file. Usually, this is what we want. But a few components in the kernel
repository (namely, BPF iterators and selftests) also install bpftool
locally before using it. In such a case, bash completion is not
necessary and is just a useless build artifact.

Let's add an "install-bin" target to bpftool, to offer a way to install
the binary only.

Signed-off-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20211007194438.34443-13-quentin@isovalent.com
</content>
</entry>
<entry>
<title>bpf: iterators: Install libbpf headers when building</title>
<updated>2021-10-08T18:58:54Z</updated>
<author>
<name>Quentin Monnet</name>
<email>quentin@isovalent.com</email>
</author>
<published>2021-10-07T19:44:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7bf731dcc641f7d7c71d1932678e0de8ea472612'/>
<id>urn:sha1:7bf731dcc641f7d7c71d1932678e0de8ea472612</id>
<content type='text'>
API headers from libbpf should not be accessed directly from the
library's source directory. Instead, they should be exported with "make
install_headers". Let's make sure that bpf/preload/iterators/Makefile
installs the headers properly when building.

Signed-off-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20211007194438.34443-8-quentin@isovalent.com
</content>
</entry>
<entry>
<title>bpf: preload: Install libbpf headers when building</title>
<updated>2021-10-08T18:56:42Z</updated>
<author>
<name>Quentin Monnet</name>
<email>quentin@isovalent.com</email>
</author>
<published>2021-10-07T19:44:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bf60791741d430e8a3e2f8b4a3941d392bf838c2'/>
<id>urn:sha1:bf60791741d430e8a3e2f8b4a3941d392bf838c2</id>
<content type='text'>
API headers from libbpf should not be accessed directly from the
library's source directory. Instead, they should be exported with "make
install_headers". Let's make sure that bpf/preload/Makefile installs the
headers properly when building.

Note that we declare an additional dependency for iterators/iterators.o:
having $(LIBBPF_A) as a dependency to "$(obj)/bpf_preload_umd" is not
sufficient, as it makes it required only at the linking step. But we
need libbpf to be compiled, and in particular its headers to be
exported, before we attempt to compile iterators.o. The issue would not
occur before this commit, because libbpf's headers were not exported and
were always available under tools/lib/bpf.

Signed-off-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20211007194438.34443-7-quentin@isovalent.com
</content>
</entry>
<entry>
<title>libbpf: Move BPF_SEQ_PRINTF and BPF_SNPRINTF to bpf_helpers.h</title>
<updated>2021-05-26T17:45:41Z</updated>
<author>
<name>Florent Revest</name>
<email>revest@chromium.org</email>
</author>
<published>2021-05-26T16:46:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d6a6a55518c16040a369360255b355b7a2a261de'/>
<id>urn:sha1:d6a6a55518c16040a369360255b355b7a2a261de</id>
<content type='text'>
These macros are convenient wrappers around the bpf_seq_printf and
bpf_snprintf helpers. They are currently provided by bpf_tracing.h which
targets low level tracing primitives. bpf_helpers.h is a better fit.

The __bpf_narg and __bpf_apply are needed in both files and provided
twice. __bpf_empty isn't used anywhere and is removed from bpf_tracing.h

Reported-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Florent Revest &lt;revest@chromium.org&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20210526164643.2881368-1-revest@chromium.org
</content>
</entry>
<entry>
<title>bpf: Fix umd memory leak in copy_process()</title>
<updated>2021-03-19T21:23:19Z</updated>
<author>
<name>Zqiang</name>
<email>qiang.zhang@windriver.com</email>
</author>
<published>2021-03-17T03:09:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f60a85cad677c4f9bb4cadd764f1d106c38c7cf8'/>
<id>urn:sha1:f60a85cad677c4f9bb4cadd764f1d106c38c7cf8</id>
<content type='text'>
The syzbot reported a memleak as follows:

BUG: memory leak
unreferenced object 0xffff888101b41d00 (size 120):
  comm "kworker/u4:0", pid 8, jiffies 4294944270 (age 12.780s)
  backtrace:
    [&lt;ffffffff8125dc56&gt;] alloc_pid+0x66/0x560
    [&lt;ffffffff81226405&gt;] copy_process+0x1465/0x25e0
    [&lt;ffffffff81227943&gt;] kernel_clone+0xf3/0x670
    [&lt;ffffffff812281a1&gt;] kernel_thread+0x61/0x80
    [&lt;ffffffff81253464&gt;] call_usermodehelper_exec_work
    [&lt;ffffffff81253464&gt;] call_usermodehelper_exec_work+0xc4/0x120
    [&lt;ffffffff812591c9&gt;] process_one_work+0x2c9/0x600
    [&lt;ffffffff81259ab9&gt;] worker_thread+0x59/0x5d0
    [&lt;ffffffff812611c8&gt;] kthread+0x178/0x1b0
    [&lt;ffffffff8100227f&gt;] ret_from_fork+0x1f/0x30

unreferenced object 0xffff888110ef5c00 (size 232):
  comm "kworker/u4:0", pid 8414, jiffies 4294944270 (age 12.780s)
  backtrace:
    [&lt;ffffffff8154a0cf&gt;] kmem_cache_zalloc
    [&lt;ffffffff8154a0cf&gt;] __alloc_file+0x1f/0xf0
    [&lt;ffffffff8154a809&gt;] alloc_empty_file+0x69/0x120
    [&lt;ffffffff8154a8f3&gt;] alloc_file+0x33/0x1b0
    [&lt;ffffffff8154ab22&gt;] alloc_file_pseudo+0xb2/0x140
    [&lt;ffffffff81559218&gt;] create_pipe_files+0x138/0x2e0
    [&lt;ffffffff8126c793&gt;] umd_setup+0x33/0x220
    [&lt;ffffffff81253574&gt;] call_usermodehelper_exec_async+0xb4/0x1b0
    [&lt;ffffffff8100227f&gt;] ret_from_fork+0x1f/0x30

After the UMD process exits, the pipe_to_umh/pipe_from_umh and
tgid need to be released.

Fixes: d71fa5c9763c ("bpf: Add kernel module with user mode driver that populates bpffs.")
Reported-by: syzbot+44908bb56d2bfe56b28e@syzkaller.appspotmail.com
Signed-off-by: Zqiang &lt;qiang.zhang@windriver.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20210317030915.2865-1-qiang.zhang@windriver.com
</content>
</entry>
<entry>
<title>Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net</title>
<updated>2021-02-02T22:21:31Z</updated>
<author>
<name>Jakub Kicinski</name>
<email>kuba@kernel.org</email>
</author>
<published>2021-02-02T22:21:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d1e1355aefcc0cbda750a8931e93e1e04a5b0b6a'/>
<id>urn:sha1:d1e1355aefcc0cbda750a8931e93e1e04a5b0b6a</id>
<content type='text'>
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpf, preload: Fix build when $(O) points to a relative path</title>
<updated>2021-01-26T22:13:25Z</updated>
<author>
<name>Quentin Monnet</name>
<email>quentin@isovalent.com</email>
</author>
<published>2021-01-26T16:13:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=150a27328b681425c8cab239894a48f2aeb870e9'/>
<id>urn:sha1:150a27328b681425c8cab239894a48f2aeb870e9</id>
<content type='text'>
Building the kernel with CONFIG_BPF_PRELOAD, and by providing a relative
path for the output directory, may fail with the following error:

  $ make O=build bindeb-pkg
  ...
  /.../linux/tools/scripts/Makefile.include:5: *** O=build does not exist.  Stop.
  make[7]: *** [/.../linux/kernel/bpf/preload/Makefile:9: kernel/bpf/preload/libbpf.a] Error 2
  make[6]: *** [/.../linux/scripts/Makefile.build:500: kernel/bpf/preload] Error 2
  make[5]: *** [/.../linux/scripts/Makefile.build:500: kernel/bpf] Error 2
  make[4]: *** [/.../linux/Makefile:1799: kernel] Error 2
  make[4]: *** Waiting for unfinished jobs....

In the case above, for the "bindeb-pkg" target, the error is produced by
the "dummy" check in Makefile.include, called from libbpf's Makefile.
This check changes directory to $(PWD) before checking for the existence
of $(O). But at this step we have $(PWD) pointing to "/.../linux/build",
and $(O) pointing to "build". So the Makefile.include tries in fact to
assert the existence of a directory named "/.../linux/build/build",
which does not exist.

Note that the error does not occur for all make targets and
architectures combinations. This was observed on x86 for "bindeb-pkg",
or for a regular build for UML [0].

Here are some details. The root Makefile recursively calls itself once,
after changing directory to $(O). The content for the variable $(PWD) is
preserved across recursive calls to make, so it is unchanged at this
step. For "bindeb-pkg", $(PWD) is eventually updated because the target
writes a new Makefile (as debian/rules) and calls it indirectly through
dpkg-buildpackage. This script does not preserve $(PWD), which is reset
to the current working directory when the target in debian/rules is
called.

Although not investigated, it seems likely that something similar causes
UML to change its value for $(PWD).

Non-trivial fixes could be to remove the use of $(PWD) from the "dummy"
check, or to make sure that $(PWD) and $(O) are preserved or updated to
always play well and form a valid $(PWD)/$(O) path across the different
targets and architectures. Instead, we take a simpler approach and just
update $(O) when calling libbpf's Makefile, so it points to an absolute
path which should always resolve for the "dummy" check run (through
includes) by that Makefile.

David Gow previously posted a slightly different version of this patch
as a RFC [0], two months ago or so.

  [0] https://lore.kernel.org/bpf/20201119085022.3606135-1-davidgow@google.com/t/#u

Fixes: d71fa5c9763c ("bpf: Add kernel module with user mode driver that populates bpffs.")
Reported-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Quentin Monnet &lt;quentin@isovalent.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Cc: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Cc: Masahiro Yamada &lt;masahiroy@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20210126161320.24561-1-quentin@isovalent.com
</content>
</entry>
<entry>
<title>bpf: Remove unnecessary &lt;argp.h&gt; include from preload/iterators</title>
<updated>2021-01-08T21:39:24Z</updated>
<author>
<name>Leah Neukirchen</name>
<email>leah@vuxu.org</email>
</author>
<published>2020-12-16T10:03:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=619775c3cfd2bc8559abc4395bf7d85b72bd723f'/>
<id>urn:sha1:619775c3cfd2bc8559abc4395bf7d85b72bd723f</id>
<content type='text'>
This program does not use argp (which is a glibcism). Instead include &lt;errno.h&gt;
directly, which was pulled in by &lt;argp.h&gt;.

Signed-off-by: Leah Neukirchen &lt;leah@vuxu.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Song Liu &lt;songliubraving@fb.com&gt;
Link: https://lore.kernel.org/bpf/20201216100306.30942-1-leah@vuxu.org
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpf: BPF_PRELOAD depends on BPF_SYSCALL</title>
<updated>2020-11-06T02:49:29Z</updated>
<author>
<name>Randy Dunlap</name>
<email>rdunlap@infradead.org</email>
</author>
<published>2020-11-05T19:51:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7c0afcad7507636529e6a5a2a5eef5482619a449'/>
<id>urn:sha1:7c0afcad7507636529e6a5a2a5eef5482619a449</id>
<content type='text'>
Fix build error when BPF_SYSCALL is not set/enabled but BPF_PRELOAD is
by making BPF_PRELOAD depend on BPF_SYSCALL.

ERROR: modpost: "bpf_preload_ops" [kernel/bpf/preload/bpf_preload.ko] undefined!

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Reported-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Signed-off-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20201105195109.26232-1-rdunlap@infradead.org
</content>
</entry>
</feed>
