-
Notifications
You must be signed in to change notification settings - Fork 170
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
fix(userspace/libsinsp): revert to old concatenate_paths
helper funtion for perf reasons
#1645
Conversation
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.
Added and adapted tests.
#endif // _WIN32 | ||
(*tc)--; | ||
|
||
while((*tc) >= targetbase + 1 && *((*tc) - 1) != '/') |
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.
Inverted check to avoid possible underflow.
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.
We discussed that this is a better inverted check than https://github.com/falcosecurity/libs/pull/1530/files#diff-3a461a173cc85eaeb297c9d4c40fa1c58c0c3ab4556b3757ebdfe262de19d45cR611
... alongside other improvements. It was all tested w/ a fuzzer to the best of our abilities ❤️
// Example: "/foo/../a" -> "/a" BUT "foo/../a" -> "a" | ||
// -> Otherwise: "foo/../a" -> "/a" | ||
// | ||
if((tc > targetbase && *(tc - 1) == separator) || (tc == targetbase && !empty_base)) |
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.
When cutting away ../
in the target string, we return to its start, avoid putting a /
; this fixes edge cases like:
"foo/../a"
that previously returned /a
instead of just a
.
This case is now covered by tests.
Even if the diff is big, it should be seen as a (relatively small) patch against old code, ie: https://raw.githubusercontent.com/falcosecurity/libs/aa191bab837e9a7ab58bf0547addaad26aa7f05e/userspace/libsinsp/utils.cpp |
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.
/approve
Amazing work @FedeDP and @LucaGuerra !!!!
#endif // _WIN32 | ||
(*tc)--; | ||
|
||
while((*tc) >= targetbase + 1 && *((*tc) - 1) != '/') |
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.
We discussed that this is a better inverted check than https://github.com/falcosecurity/libs/pull/1530/files#diff-3a461a173cc85eaeb297c9d4c40fa1c58c0c3ab4556b3757ebdfe262de19d45cR611
... alongside other improvements. It was all tested w/ a fuzzer to the best of our abilities ❤️
@@ -17,13 +17,19 @@ limitations under the License. | |||
*/ | |||
|
|||
#include <gtest/gtest.h> | |||
#include <libsinsp/utils.h> | |||
#include "utils.h" |
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.
#include "utils.h" | |
#include <libsinsp/utils.h> |
This shouldn't be reverted. See 6f8cb47#diff-362102dc7b939ad80b6a97c6e36cb1c610f314172ebb33b9b1483b062e53c81d
cc @therealbobo
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.
We should really add a CI to avoid them slipping in :/
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.
Done.
/milestone 0.14.2 |
…ction for perf reasons. Also, added some small fixes and lots of new tests. Signed-off-by: Federico Di Pierro <[email protected]>
18f3bc8
to
8af72bd
Compare
Adding context to this:
Honestly it's sad to see the cleaner implementation go, but maybe not everything is lost. Surely, this solution works well for this upcoming release. In the process we fuzzed both the old and new implementation and no memory errors were detected in this patch. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, incertum, leogr, LucaGuerra The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Just now got to test this a bit more and I noticed a regression for example for a UEK 4.14 kernel e.g. https://yum.oracle.com/repo/OracleLinux/OL7/UEKR5/x86_64/getPackage/ -> any should do e.g. Logs now don't contain the file names anymore. Note this issue seems a corner case as I have seen it work on many kernels. Carefully verified that this commit is the root cause (did a cherry-pit on it).
|
I just added a test case:
and it is passing fine. Am i missing anything? |
Also, i don't see how an userspace (small) patch could be affected by the running kernel. |
I was missing the actual bug 😆 |
@FedeDP de-escalating. I destroyed everything and kicked off new CI builds for both versions as well and now the gremlins disappeared. Sorry about that, but figured we are so close to the release I should at least share this observation as it was very unexpected and weird to me. |
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
What this PR does / why we need it:
This PR embeds a better fix for the issue found in #1530, reverting the new
std::filesystem
implementation (that was great btw, and much better edge cases coverage; see #1533 ) to the old one with some small fixes on top, for perf reasons. We found that the new impl had like a 7.5x slowdown; since it is used in hot paths, we had to revert.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: