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

v1.0 backport: bpf: fix bugs in the prepend_name function #1956

Merged
merged 4 commits into from
Jan 15, 2024

Conversation

mtardy
Copy link
Member

@mtardy mtardy commented Jan 10, 2024

Backport of the bugfix and tests of #1902.

@mtardy mtardy added area/bpf This is related to BPF code release-note/bug This PR fixes an issue in a previous release of Tetragon. labels Jan 10, 2024
@mtardy mtardy requested a review from a team as a code owner January 10, 2024 11:52
@mtardy mtardy requested review from tpapagian and removed request for a team January 10, 2024 11:52
@mtardy mtardy changed the title bpf: fix bugs in the prepend_name function v1.0 backport: bpf: fix bugs in the prepend_name function Jan 10, 2024
@mtardy mtardy added the kind/backport This PR provides functionality previously merged into master. label Jan 10, 2024
@mtardy mtardy requested a review from kkourt January 10, 2024 16:28
[ upstream commit ea914b6 ]

In order to make BPF_PROG_RUN work with BPF_PROG_TYPE_RAW_TRACEPOINT in
cilium/ebpf.

Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
[ upstream commit 0e242c4 ]

It looked like this particular function presented some bugs:
- It would not return -ENAMETOOLONG when the buffer was filled
  "best-effort" because the name was not fitting.
- It would never fill the first byte of the buffer, thus reducing the
  maximum size written by one.
- It would not fill "best-effort" correctly. E.g, previously in a buffer
  of 4, "pizza" would have been "/piz" (when ignoring previous bug)
  instead of "izza". Now it tries to write the "end" of the name without
  a wrong "/" char.
- It would behave unexpectedly when filled with more data than size of
  buffer.

BPF unit tests were put under bpf/tests, as more can be added there in
the future. The Makefile was updated so that we can share variable
definition between the bpf/Makefile and the bpf/tests/Makefile file.
This separation allows us not compile the test program along the rest of
the BPF progs, and not ship them in the released images/archives.

Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
[ upstream commit c8bcf64 ]

BPF units tests are not backported to v1.0 but this still ports the bug
fix in the prepend_name function as this can affect users via events.

Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
[ upstream commit f08c16f ]

Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
@mtardy mtardy force-pushed the pr/mtardy/backport/prepend-name-fix branch from 64c6a35 to e8ee5c9 Compare January 12, 2024 12:30
@mtardy
Copy link
Member Author

mtardy commented Jan 12, 2024

Complete backport ready with tests as well @kkourt

Copy link
Contributor

@kkourt kkourt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mtardy mtardy merged commit e11c31a into v1.0 Jan 15, 2024
27 checks passed
@mtardy mtardy deleted the pr/mtardy/backport/prepend-name-fix branch January 15, 2024 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bpf This is related to BPF code kind/backport This PR provides functionality previously merged into master. release-note/bug This PR fixes an issue in a previous release of Tetragon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants