<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/testing/selftests/bpf/prog_tests, branch linux-5.7.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.7.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.7.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-06-24T15:49:11Z</updated>
<entry>
<title>libbpf: Support pre-initializing .bss global variables</title>
<updated>2020-06-24T15:49:11Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-06-12T19:45:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=845357b602f6f2e0e3b47425e8764947460c7aa2'/>
<id>urn:sha1:845357b602f6f2e0e3b47425e8764947460c7aa2</id>
<content type='text'>
[ Upstream commit caf62492f479585296e9d636c798d5ac256b7b04 ]

Remove invalid assumption in libbpf that .bss map doesn't have to be updated
in kernel. With addition of skeleton and memory-mapped initialization image,
.bss doesn't have to be all zeroes when BPF map is created, because user-code
might have initialized those variables from user-space.

Fixes: eba9c5f498a1 ("libbpf: Refactor global data map initialization")
Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200612194504.557844-1-andriin@fb.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf, flow_dissector: Close TAP device FD after the test</title>
<updated>2020-06-22T07:32:53Z</updated>
<author>
<name>Jakub Sitnicki</name>
</author>
<published>2020-05-31T08:28:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6aec0d0d14813fbf029b55c856f91fa3b979b598'/>
<id>urn:sha1:6aec0d0d14813fbf029b55c856f91fa3b979b598</id>
<content type='text'>
[ Upstream commit b8215dce7dfd817ca38807f55165bf502146cd68 ]

test_flow_dissector leaves a TAP device after it's finished, potentially
interfering with other tests that will run after it. Fix it by closing the
TAP descriptor on cleanup.

Fixes: 0905beec9f52 ("selftests/bpf: run flow dissector tests in skb-less mode")
Signed-off-by: Jakub Sitnicki &lt;jakub@cloudflare.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200531082846.2117903-11-jakub@cloudflare.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Fix bpf_link leak in ns_current_pid_tgid selftest</title>
<updated>2020-06-22T07:32:34Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-04-29T01:21:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b98caf9ca0f216d793eb0ee6764edfedc76ed4d2'/>
<id>urn:sha1:b98caf9ca0f216d793eb0ee6764edfedc76ed4d2</id>
<content type='text'>
[ Upstream commit 8d30e80a049ad699264e4a12911e349f93c7279a ]

If condition is inverted, but it's also just not necessary.

Fixes: 1c1052e0140a ("tools/testing/selftests/bpf: Add self-tests for new helper bpf_get_ns_current_pid_tgid.")
Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Cc: Carlos Neira &lt;cneirabustos@gmail.com&gt;
Link: https://lore.kernel.org/bpf/20200429012111.277390-11-andriin@fb.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>selftests/bpf: Fix invalid memory reads in core_relo selftest</title>
<updated>2020-06-22T07:32:34Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-04-29T01:21:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=02e4ad2ec00d1c341172283c00229de11b26ac1d'/>
<id>urn:sha1:02e4ad2ec00d1c341172283c00229de11b26ac1d</id>
<content type='text'>
[ Upstream commit 13c908495e5d51718a6da84ae925fa2aac056380 ]

Another one found by AddressSanitizer. input_len is bigger than actually
initialized data size.

Fixes: c7566a69695c ("selftests/bpf: Add field existence CO-RE relocs tests")
Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200429012111.277390-8-andriin@fb.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>bpf: Prevent mmap()'ing read-only maps as writable</title>
<updated>2020-05-21T03:21:53Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-05-19T05:38:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dfeb376dd4cb2c5004aeb625e2475f58a5ff2ea7'/>
<id>urn:sha1:dfeb376dd4cb2c5004aeb625e2475f58a5ff2ea7</id>
<content type='text'>
As discussed in [0], it's dangerous to allow mapping BPF map, that's meant to
be frozen and is read-only on BPF program side, because that allows user-space
to actually store a writable view to the page even after it is frozen. This is
exacerbated by BPF verifier making a strong assumption that contents of such
frozen map will remain unchanged. To prevent this, disallow mapping
BPF_F_RDONLY_PROG mmap()'able BPF maps as writable, ever.

  [0] https://lore.kernel.org/bpf/CAEf4BzYGWYhXdp6BJ7_=9OQPJxQpgug080MMjdSB72i9R+5c6g@mail.gmail.com/

Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
Suggested-by: Jann Horn &lt;jannh@google.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Reviewed-by: Jann Horn &lt;jannh@google.com&gt;
Link: https://lore.kernel.org/bpf/20200519053824.1089415-1-andriin@fb.com
</content>
</entry>
<entry>
<title>bpf: Fix bug in mmap() implementation for BPF array map</title>
<updated>2020-05-14T19:40:04Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-05-12T23:59:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=333291ce5055f2039afc907badaf5b66bc1adfdc'/>
<id>urn:sha1:333291ce5055f2039afc907badaf5b66bc1adfdc</id>
<content type='text'>
mmap() subsystem allows user-space application to memory-map region with
initial page offset. This wasn't taken into account in initial implementation
of BPF array memory-mapping. This would result in wrong pages, not taking into
account requested page shift, being memory-mmaped into user-space. This patch
fixes this gap and adds a test for such scenario.

Fixes: fc9702273e2e ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Yonghong Song &lt;yhs@fb.com&gt;
Link: https://lore.kernel.org/bpf/20200512235925.3817805-1-andriin@fb.com
</content>
</entry>
<entry>
<title>selftests/bpf: Add test for freplace program with expected_attach_type</title>
<updated>2020-04-25T00:34:30Z</updated>
<author>
<name>Toke Høiland-Jørgensen</name>
</author>
<published>2020-04-24T13:34:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1d8a0af5ee1ad219a9ebd9b43559b165bcb3ff40'/>
<id>urn:sha1:1d8a0af5ee1ad219a9ebd9b43559b165bcb3ff40</id>
<content type='text'>
This adds a new selftest that tests the ability to attach an freplace
program to a program type that relies on the expected_attach_type of the
target program to pass verification.

Signed-off-by: Toke Høiland-Jørgensen &lt;toke@redhat.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/158773526831.293902.16011743438619684815.stgit@toke.dk
</content>
</entry>
<entry>
<title>selftests/bpf: Check for correct program attach/detach in xdp_attach test</title>
<updated>2020-04-15T11:26:08Z</updated>
<author>
<name>Toke Høiland-Jørgensen</name>
</author>
<published>2020-04-14T14:50:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c6c111523d9e697bfb463870759825be5d6caff6'/>
<id>urn:sha1:c6c111523d9e697bfb463870759825be5d6caff6</id>
<content type='text'>
David Ahern noticed that there was a bug in the EXPECTED_FD code so
programs did not get detached properly when that parameter was supplied.
This case was not included in the xdp_attach tests; so let's add it to be
sure that such a bug does not sneak back in down.

Fixes: 87854a0b57b3 ("selftests/bpf: Add tests for attaching XDP programs")
Reported-by: David Ahern &lt;dsahern@gmail.com&gt;
Signed-off-by: Toke Høiland-Jørgensen &lt;toke@redhat.com&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/20200414145025.182163-2-toke@redhat.com
</content>
</entry>
<entry>
<title>libbpf: Always specify expected_attach_type on program load if supported</title>
<updated>2020-04-15T11:22:43Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-04-14T18:26:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=25498a1969bf3687c29c29bbac92821d7a0f8b4a'/>
<id>urn:sha1:25498a1969bf3687c29c29bbac92821d7a0f8b4a</id>
<content type='text'>
For some types of BPF programs that utilize expected_attach_type, libbpf won't
set load_attr.expected_attach_type, even if expected_attach_type is known from
section definition. This was done to preserve backwards compatibility with old
kernels that didn't recognize expected_attach_type attribute yet (which was
added in 5e43f899b03a ("bpf: Check attach type at prog load time"). But this
is problematic for some BPF programs that utilize newer features that require
kernel to know specific expected_attach_type (e.g., extended set of return
codes for cgroup_skb/egress programs).

This patch makes libbpf specify expected_attach_type by default, but also
detect support for this field in kernel and not set it during program load.
This allows to have a good metadata for bpf_program
(e.g., bpf_program__get_extected_attach_type()), but still work with old
kernels (for cases where it can work at all).

Additionally, due to expected_attach_type being always set for recognized
program types, bpf_program__attach_cgroup doesn't have to do extra checks to
determine correct attach type, so remove that additional logic.

Also adjust section_names selftest to account for this change.

More detailed discussion can be found in [0].

  [0] https://lore.kernel.org/bpf/20200412003604.GA15986@rdna-mbp.dhcp.thefacebook.com/

Fixes: 5cf1e9145630 ("bpf: cgroup inet skb programs can return 0 to 3")
Fixes: 5e43f899b03a ("bpf: Check attach type at prog load time")
Reported-by: Andrey Ignatov &lt;rdna@fb.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Acked-by: Song Liu &lt;songliubraving@fb.com&gt;
Acked-by: Andrey Ignatov &lt;rdna@fb.com&gt;
Link: https://lore.kernel.org/bpf/20200414182645.1368174-1-andriin@fb.com
</content>
</entry>
<entry>
<title>selftests/bpf: Validate frozen map contents stays frozen</title>
<updated>2020-04-14T19:28:57Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-04-10T20:26:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=642c1654702731ab42a3be771bebbd6ef938f0dc'/>
<id>urn:sha1:642c1654702731ab42a3be771bebbd6ef938f0dc</id>
<content type='text'>
Test that frozen and mmap()'ed BPF map can't be mprotect()'ed as writable or
executable memory. Also validate that "downgrading" from writable to read-only
doesn't screw up internal writable count accounting for the purposes of map
freezing.

Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20200410202613.3679837-2-andriin@fb.com
</content>
</entry>
</feed>
