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

bpf: fix path truncation in copying path arguments #3427

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mtardy
Copy link
Member

@mtardy mtardy commented Feb 20, 2025

@mtardy mtardy added the release-note/bug This PR fixes an issue in a previous release of Tetragon. label Feb 20, 2025
Copy link

netlify bot commented Feb 20, 2025

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit f655438
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/67b8943cca1d23000824b63a
😎 Deploy Preview https://deploy-preview-3427--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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 <mahe.tardy@gmail.com>
@mtardy mtardy force-pushed the pr/mtardy/fix-path-truncation branch 2 times, most recently from c61ad84 to f655438 Compare February 21, 2025 14:56
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 <mahe.tardy@gmail.com>
The asm was maybe no longer necessary and was restricting the maximum
size to be 1188.

Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
@mtardy mtardy force-pushed the pr/mtardy/fix-path-truncation branch from f655438 to 8a8506f Compare February 21, 2025 15:01
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 <mahe.tardy@gmail.com>
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 <mahe.tardy@gmail.com>
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 <mahe.tardy@gmail.com>
@mtardy mtardy force-pushed the pr/mtardy/fix-path-truncation branch from 8a8506f to ab9fdf5 Compare February 21, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

1 participant