Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert fix(kernel): array-index-out-of-bounds error on bpf #1023

Closed
nberlee opened this issue Sep 9, 2024 · 3 comments · Fixed by #1024
Closed

revert fix(kernel): array-index-out-of-bounds error on bpf #1023

nberlee opened this issue Sep 9, 2024 · 3 comments · Fixed by #1024

Comments

@nberlee
Copy link
Contributor

nberlee commented Sep 9, 2024

7f9c802 can be reverted as the patch is included in 6.6.47

In Kernel 6.6.47 changelog:

commit ef33f0296893356314a5c79e787bca977bb3c9ec
Author: Kees Cook <kees@kernel.org>
Date:   Thu Feb 22 07:56:15 2024 -0800

    bpf: Replace bpf_lpm_trie_key 0-length array with flexible array
    
[..]

PS: the 6.6.49 kernel build should have failed, as it does on my build, I do not understand the patch was successful.

1.683 patching file Documentation/bpf/map_lpm_trie.rst
1.684 Reversed (or previously applied) patch detected!  Assume -R? [n]
1.685 Apply anyway? [n]
1.685 Skipping patch.
1.686 1 out of 1 hunk ignored -- saving rejects to file Documentation/bpf/map_lpm_trie.rst.rej
1.689 patching file include/uapi/linux/bpf.h
1.689 Reversed (or previously applied) patch detected!  Assume -R? [n]
1.689 Apply anyway? [n]
1.689 Skipping patch.
1.689 1 out of 1 hunk ignored -- saving rejects to file include/uapi/linux/bpf.h.rej
1.690 patching file kernel/bpf/lpm_trie.c
1.690 Reversed (or previously applied) patch detected!  Assume -R? [n]
1.690 Apply anyway? [n]
1.690 Skipping patch.
1.691 9 out of 9 hunks ignored -- saving rejects to file kernel/bpf/lpm_trie.c.rej
1.692 patching file samples/bpf/map_perf_test_user.c
1.692 Reversed (or previously applied) patch detected!  Assume -R? [n]
1.692 Apply anyway? [n]
1.692 Skipping patch.
1.692 1 out of 1 hunk ignored -- saving rejects to file samples/bpf/map_perf_test_user.c.rej
1.693 patching file samples/bpf/xdp_router_ipv4_user.c
1.693 Reversed (or previously applied) patch detected!  Assume -R? [n]
1.693 Apply anyway? [n]
1.693 Skipping patch.
1.693 1 out of 1 hunk ignored -- saving rejects to file samples/bpf/xdp_router_ipv4_user.c.rej
1.695 patching file tools/include/uapi/linux/bpf.h
1.696 Reversed (or previously applied) patch detected!  Assume -R? [n]
1.696 Apply anyway? [n]
1.696 Skipping patch.
1.696 1 out of 1 hunk ignored -- saving rejects to file tools/include/uapi/linux/bpf.h.rej
1.697 patching file tools/testing/selftests/bpf/progs/map_ptr_kern.c
1.697 Reversed (or previously applied) patch detected!  Assume -R? [n]
1.697 Apply anyway? [n]
1.697 Skipping patch.
1.697 1 out of 1 hunk ignored -- saving rejects to file tools/testing/selftests/bpf/progs/map_ptr_kern.c.rej
1.698 patching file tools/testing/selftests/bpf/test_lpm_map.c
1.698 Reversed (or previously applied) patch detected!  Assume -R? [n]
1.698 Apply anyway? [n]
1.698 Skipping patch.
1.698 7 out of 7 hunks ignored -- saving rejects to file tools/testing/selftests/bpf/test_lpm_map.c.rej
1.712 Failed to apply patch /pkg/patches/0090-bpf-Replace-bpf_lpm_trie_key-0-length-array-with-flexible-array.patch
------
ERROR: failed to solve: process "/dev/.buildkit_qemu_emulator /toolchain/bin/bash -c set -eou pipefail\ncd /src\nfor patch in $(find /pkg/patches -type f -name \"*.patch\" | sort); do\n  patch -p1 < $patch || (echo \"Failed to apply patch $patch\" && exit 1)\ndone\n" did not complete successfully: exit code: 1
make[2]: *** [Makefile:116: target-kernel-build] Error 1
make[2]: Leaving directory '/home/nicob/repository/kernel'
make[1]: *** [Makefile:119: local-kernel-build] Error 2
make[1]: Leaving directory '/home/nicob/repository/kernel'
make: *** [Makefile:161: kernel-olddefconfig] Error 2
@smira
Copy link
Member

smira commented Sep 9, 2024

Thank you, we'll drop the patch

@frezbo
Copy link
Member

frezbo commented Sep 10, 2024

hmm i wonder why the patch failed to apply if it's already there 🤔

@smira
Copy link
Member

smira commented Sep 10, 2024

Ok, I don't know how exactly that happened, but the patch filename contained 0x20 (space) at the end, so it never matched find -name *.patch, and never got applied.

ls -l kernel/build/patches/ | hexdump -C  
00000000  74 6f 74 61 6c 20 32 38  0a 2d 72 77 2d 72 77 2d  |total 28.-rw-rw-|
00000010  72 2d 2d 20 31 20 73 6d  69 72 61 20 73 6d 69 72  |r-- 1 smira smir|
00000020  61 20 32 32 36 37 39 20  53 65 70 20 31 30 20 31  |a 22679 Sep 10 1|
00000030  34 3a 32 33 20 30 30 30  31 2d 62 70 66 2d 52 65  |4:23 0001-bpf-Re|
00000040  70 6c 61 63 65 2d 62 70  66 5f 6c 70 6d 5f 74 72  |place-bpf_lpm_tr|
00000050  69 65 5f 6b 65 79 2d 30  2d 6c 65 6e 67 74 68 2d  |ie_key-0-length-|
00000060  61 72 72 61 79 2d 77 69  74 68 2d 66 6c 65 78 69  |array-with-flexi|
00000070  62 6c 65 2d 61 72 72 61  79 2e 70 61 74 63 68 20  |ble-array.patch |
00000080  0a 2d 72 77 2d 72 77 2d  72 2d 2d 20 31 20 73 6d  |.-rw-rw-r-- 1 sm|
00000090  69 72 61 20 73 6d 69 72  61 20 20 31 30 36 33 20  |ira smira  1063 |
000000a0  53 65 70 20 20 34 20 31  34 3a 32 31 20 52 45 41  |Sep  4 14:21 REA|
000000b0  44 4d 45 2e 6d 64 0a                              |DME.md.|

smira added a commit to smira/pkgs that referenced this issue Sep 13, 2024
tl;dr it got never applied, and now it is in upstream

Fixes siderolabs#1023

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
(cherry picked from commit a09bf93)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants