-
Notifications
You must be signed in to change notification settings - Fork 166
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
[BUG] scap bpf engine requires API VERSION major bumps when it shouldn't #1283
Comments
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. Mark the issue as fresh with Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with Provide feedback via https://github.com/falcosecurity/community. /lifecycle stale |
/remove-lifecycle stale |
This could be related to this #2068 |
It is possible that we will need to add new filler bpf side so we need to bump the right version |
The solution would be this: diff --git a/userspace/libscap/engine/bpf/scap_bpf.c b/userspace/libscap/engine/bpf/scap_bpf.c
index 3f7ea6e58..a88aa9515 100644
--- a/userspace/libscap/engine/bpf/scap_bpf.c
+++ b/userspace/libscap/engine/bpf/scap_bpf.c
@@ -569,8 +569,6 @@ static int32_t load_single_prog(struct bpf_engine *handle,
BPF_PROGS_TAIL_CALLED_MAX);
}
- handle->m_tail_called_fds[handle->m_tail_called_cnt++] = fd;
-
event += sizeof("filler/") - 1;
if(*event == 0) {
return scap_errprintf(handle->m_lasterr, 0, "filler name cannot be empty");
@@ -578,7 +576,11 @@ static int32_t load_single_prog(struct bpf_engine *handle,
int prog_id = lookup_filler_id(event);
if(prog_id == -1) {
- return scap_errprintf(handle->m_lasterr, 0, "invalid filler name: %s", event);
+ // This is possible when we load a new ebpf probe `.o` with an old scap version.
+ // The ebpf probe defines a filler that is not present in the scap version. This should
+ // be safe until we keep the old fillers in the probe like we are doing today
+ close(fd);
+ return SCAP_SUCCESS;
} else if(prog_id >= BPF_PROGS_TAIL_CALLED_MAX) {
return scap_errprintf(handle->m_lasterr,
0,
@@ -587,6 +589,8 @@ static int32_t load_single_prog(struct bpf_engine *handle,
BPF_PROGS_TAIL_CALLED_MAX);
}
+ handle->m_tail_called_fds[handle->m_tail_called_cnt++] = fd;
+
/* Fill the tail table. The key is our filler internal code extracted
* from `g_filler_names` in `lookup_filler_id` function. The value
* is the program fd. In this way what we need to do is to bump a MINOR for the Let's consider this example: https://github.com/falcosecurity/libs/pull/1256/files -> We added a new filler Let's say the driver version is With the above fix, the old scap should be able to address the case of a new filler In the opposite case, the new scap version is no longer compatible with the old drivers:
So the 2 alternatives are:
Since we don't add new fillers every day I would go for the |
This means that for each new implemented syscall we will have to bump the major :/ while i agree that we won't add new syscalls every day, this somewhat is still a limitation. The bug only happens for the old bpf probe, right? The modern one is always shipped with libscap therefore no problem on that one, while the kmod is not affected. Since the old bpf probe is going to get killed sooner or later (no ETA of course but this is something we all have in mind), i agree that 2 is the best solution for now. |
yep, every time we add a new syscall or change a filler we should bump a major.
Unfortunately yes. We can always decide to fallback to solution 1 if we need to do too many major bumps |
I might miss some critical points, but I'm afraid I have to disagree with the solution of bumping a major when something is being added. Doing that would immediately make the versioning numbering useless. So, I'm for option 1, and I want to keep the correct pattern of bumping the minor for additions. |
Describe the bug
When the scap bpf engine loads the
.o
file it scans all elf sections. Right now when the engine finds a new filler section it expects to have the corresponding enum in userspace tableslibs/userspace/libscap/engine/bpf/scap_bpf.c
Line 596 in dc4ab16
but this is not always true. Consider this example:
Let's imagine
SCAP_MINIMUM_DRIVER_SCHEMA_VERSION
is like today:and we have a driver with SCHEMA VERSION
2.0.0
. Now we add a new filler like in this PR #1256sys_listen_e
and we bump the driver SCHEMA VERSION to2.1.0
. When libscap tries to load the new.o
with SCHEMA_VERSION2.1.0
it will fail because it will find asys_listen_e
section not known and will printinvalid filler name
. For this reason, when we add a new filler we need to bump also a major for theSCHEMA_VERSION
until we fix this issuethis issue happens when we use an old libscap version and a driver with at least one new filler, not a very common case but BTW it is a bug.
How to reproduce it
Build libscap with the commit before this PR (#1256) and build the bpf probe over this PR, you will see the
invalid filler name
error when you load the bpf probeThe text was updated successfully, but these errors were encountered: