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

matchBinaries Prefix operator fails to match path longer than 256 chars #2758

Closed
mtardy opened this issue Jul 31, 2024 · 2 comments · Fixed by #2764
Closed

matchBinaries Prefix operator fails to match path longer than 256 chars #2758

mtardy opened this issue Jul 31, 2024 · 2 comments · Fixed by #2764
Assignees
Labels
kind/bug Something isn't working

Comments

@mtardy
Copy link
Member

mtardy commented Jul 31, 2024

The matchBinaries Prefix operator fails to match a path longer than 256 chars because of the way we read the binary path. We use the exe of the process and walk the dentry from end to beginning. Thus if the path is too long, the buffer contains an incorrect start.

A good situation looks like this:

 <--        buflen         -->
 -----------------------------
 |                /etc/passwd|
 -----------------------------
                 ^
                 |
                buf

A bad situation looks like this:

 <- buflen ->
 -----------
 |tc/passwd|
 -----------
 error = 1

A permanent solution would be to increase the length prepend_name can work on. On a first attempt, it does not seem to be an issue. However, what is blocking is that memcpy and memset will fail on the larger struct (above 1K) even though we make sure those struct are not allocated on the stack (which is 512K).

@mtardy mtardy added the kind/bug Something isn't working label Jul 31, 2024
@mtardy
Copy link
Member Author

mtardy commented Jul 31, 2024

For context: cc @anfedotoff and related to #2718.

@mtardy mtardy self-assigned this Aug 1, 2024
@mtardy
Copy link
Member Author

mtardy commented Aug 1, 2024

yay, I have a PoC, I'll prepare a patch and send a PR for that. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant