-
Notifications
You must be signed in to change notification settings - Fork 393
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
bpf: fix path truncation in cwd and copying path arguments #3427
Conversation
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
The functions called by copy_path were updated to support up to 4096 long paths, from d_path_local to prepend_name. However, before that update, copy_path was updated to reuse the work done via d_path_local. Eventually, it didn't take into account that the returned buffer can be well beyond 256 chars now. The patch fixes this by truncating to 4095 chars instead of 255. Signed-off-by: Mahe Tardy <[email protected]>
c61ad84
to
f655438
Compare
Commit 834b5fe ("String: Support longer exact match strings") added limitations on the size of strings parsed in userspace from the kernel which ended up creating a bug: longer strings can technically be passed in the event args and truncating ended up parsing incorrect flag and i_mode values. Since the size is a security measure, I don't see the point of limiting the value based on kernel value. Signed-off-by: Mahe Tardy <[email protected]>
The asm was maybe no longer necessary and was restricting the maximum size to be 1188. Signed-off-by: Mahe Tardy <[email protected]>
f655438
to
8a8506f
Compare
This test make sure that we don't have a regression on the bug fixed in the previous commit about truncating long args. Signed-off-by: Mahe Tardy <[email protected]>
The current working directory was truncated to 256 while the underlying buffer read into a buffer of 4096. This patch is raising the truncation to 4096, making it complete as it's the max on linux. Signed-off-by: Mahe Tardy <[email protected]>
Add a checker for a long cwd. Maybe this should be split into two different tests but in a way it tests the same thing, reuse the same directory structure, and we end up not having to restart tetragon twice. Signed-off-by: Mahe Tardy <[email protected]>
8a8506f
to
ab9fdf5
Compare
Hey @kevsecurity, could you check that 3e39741 is okay for you? Not sure why those specific lines were added in the first place, it seems wrong. |
Thanks @mtardy. Should we add backport tags for this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
They were there to mirror the existing code I was replacing with the hash maps. I probably got carried away unnecessarily and, as you say, created a bug as a result. |
We bumped the size of the underlying prepend_name buffer to 4096 #2764 but many users were still truncating the returned size to 255.