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

new(driver): kmod configure system #1452

Merged
merged 5 commits into from
Mar 5, 2024

Conversation

deepskyblue86
Copy link
Contributor

What type of PR is this?
/kind feature

Any specific area of the project related to this PR?
/area driver-kmod

Does this PR require a change in the driver versions?

What this PR does / why we need it:
Introduce a new mechanism for conditional build in the kernel module, documented in driver/README.configure.md

Apply such mechanism to ppm_access_ok, easily detecting if access_ok is the old version with 3 parameters or the new one with just two.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

gnosek
gnosek previously approved these changes Oct 27, 2023
Copy link
Contributor

@gnosek gnosek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP IT!

@poiana
Copy link
Contributor

poiana commented Oct 27, 2023

LGTM label has been added.

Git tree hash: 18648c12b53dcbaa17bcea074e904de7011b4ab1

@FedeDP
Copy link
Contributor

FedeDP commented Oct 27, 2023

/hold
We must first figure how to support something like this in driverkit.

@Andreagit97 Andreagit97 added this to the TBD milestone Nov 6, 2023
@FedeDP
Copy link
Contributor

FedeDP commented Nov 15, 2023

I opened a wip falcosecurity/driverkit#302 to allow Driverkit to use cmake to configure and build kmod and bpf drivers.
It would allow us to support the changes in this PR.

@FedeDP
Copy link
Contributor

FedeDP commented Jan 15, 2024

It would be great if you could add a configuration for the only driver testing issues we are seeing: https://falcosecurity.github.io/libs/matrix_X64/#centos-418-kmod_build
This way, once this gets merged, we will finally have a fully green kernel testing matrix!

EDIT: uh i missed it, there was already the config to fix it! (indeed, as we can see below, centos 4.18 is already fixed!)
What's weird, is why fedora is still not fixed considering it spots the same issue

@FedeDP
Copy link
Contributor

FedeDP commented Jan 15, 2024

Also, i am running kernel-tests against this branch: https://github.com/falcosecurity/libs/actions/runs/7526616526, just to make sure everything is ok ;)

@FedeDP
Copy link
Contributor

FedeDP commented Jan 15, 2024

x86_64 matrix:

KERNEL CMAKE-CONFIGURE KMOD BUILD KMOD SCAP-OPEN BPF-PROBE BUILD BPF-PROBE SCAP-OPEN MODERN-BPF SCAP-OPEN
amazonlinux2-4.19 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2-5.10 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2-5.15 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2-5.4 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2022-5.15 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2023-6.1 🟢 🟢 🟢 🟢 🟢 🟢
archlinux-6.0 🟢 🟢 🟢 🟢 🟢 🟢
centos-3.10 🟢 🟢 🟢 🟡 🟡 🟡
centos-4.18 🟢 🟢 🟢 🟢 🟢 🟢
centos-5.14 🟢 🟢 🟢 🟢 🟢 🟢
fedora-5.17 🟢 🟢 🟢 🟢
fedora-5.8 🟢 🟢 🟢 🟢 🟢 🟢
fedora-6.2 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-3.10 🟢 🟢 🟢 🟡 🟡 🟡
oraclelinux-4.14 🟢 🟢 🟢 🟢 🟢 🟡
oraclelinux-5.15 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-5.4 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-4.15 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-6.3 🟢 🟢 🟢 🟢 🟢 🟢

@FedeDP
Copy link
Contributor

FedeDP commented Jan 15, 2024

Shouldn't this be already fixed given it is the same error as centos-4.18 (on master), and the latter is solved by this PR?

fedora-5.17 kmod_build

Msg:

non-zero return code

Err:

warning: the compiler differs from the one used to build the kernel
  The kernel was built by: gcc (GCC) 12.0.1 20220413 (Red Hat 12.0.1-0)
  You are using:           gcc (GCC) 12.2.1 20221121 (Red Hat 12.2.1-4)
/root/repos/falcosecurity-libs/build/driver/src/main.c: In function ‘scap_init’:
/root/repos/falcosecurity-libs/build/driver/src/main.c:2892:30: error: assignment to ‘char * (*)(struct device *, umode_t *)’ {aka ‘char * (*)(struct device *, short unsigned int *)’} from incompatible pointer type ‘char * (*)(const struct device *, umode_t *)’ {aka ‘char * (*)(const struct device *, short unsigned int *)’} [-Werror=incompatible-pointer-types]
 2892 |         g_ppm_class->devnode = ppm_devnode;
      |                              ^
cc1: some warnings being treated as errors
make[6]: *** [scripts/Makefile.build:288: /root/repos/falcosecurity-libs/build/driver/src/main.o] Error 1
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [Makefile:1841: /root/repos/falcosecurity-libs/build/driver/src] Error 2
make[4]: *** [Makefile:22: all] Error 2
make[3]: *** [driver/CMakeFiles/driver.dir/build.make:70: driver/CMakeFiles/driver] Error 2
make[2]: *** [CMakeFiles/Makefile2:669: driver/CMakeFiles/driver.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:676: driver/CMakeFiles/driver.dir/rule] Error 2
make: *** [Makefile:299: driver] Error 2

@deepskyblue86
Copy link
Contributor Author

deepskyblue86 commented Jan 16, 2024

@FedeDP now it should work. Thanks for pointing me to https://falcosecurity.github.io/kernel-crawler/?arch=x86_64&target=fedora&search=5.17.5-300.fc36.x86_64 🙂

@FedeDP
Copy link
Contributor

FedeDP commented Feb 29, 2024

Update! Driverkit PR was just merged; we are running some tests and then a new driverkit release will be tagged. At that time, we will be free to proceed with this one and i'll ask you @deepskyblue86 for a rebase ;)

@FedeDP
Copy link
Contributor

FedeDP commented Feb 29, 2024

@deepskyblue86 care to rebase? https://github.com/falcosecurity/driverkit/releases/tag/v0.17.0 😃

deepskyblue86 and others added 5 commits March 2, 2024 10:44
Introduce a new mechanism for conditional build in the kernel module,
documented in driver/README.configure.md

Apply such mechanism to `ppm_access_ok`, easily detecting if `access_ok`
is the old version with 3 parameters or the new one with just two.

Signed-off-by: Angelo Puglisi <[email protected]>
- embellish the output with a '[configure]' prefix
- show the make output of the configuration step
  (notice it will be squashed into a single line)

Signed-off-by: Gerlando Falauto <[email protected]>
Co-authored-by: Angelo Puglisi <[email protected]>
RHEL8.9 kernels (4.18.0) have an inconsistent behavior in that
the first releases (up to ~500) do NOT include the backported
change, which was however included from a certain point on.
The previous implementation empirically (but wrongly) assumed
that all RHEL8.9 kernels would have the patch, so the first
ones would not compile.
Now that we have a dynamic discovery mechanism, we can drop
this assumption and leverage HAS_DEVNODE_ARG1_CONST.

Notice how this includes a revert of:

commit 977f946
Author: Gerlando Falauto <[email protected]>
Date:   Wed Aug 2 14:22:37 2023 +0200

    fix(driver): fix build on RHEL 8.9 kernels

Signed-off-by: Gerlando Falauto <[email protected]>
Co-authored-by: Angelo Puglisi <[email protected]>
When installing a new kernel, dkms would build the module for it, but
with KERNELDIR defined with `uname -r` the compilation will likely fail.
Define it with the current kernel headers only when the makefile is used
directly, and rely on the make current directory otherwise (coming from
make -C ...).

Signed-off-by: Angelo Puglisi <[email protected]>
Trust the kmod configure system for `ppm_devnode`, and drop
PPM_RHEL_RELEASE_CODE checks.
Fixes fedora-5.17 build, failing because of RHEL release version 9.99

Signed-off-by: Angelo Puglisi <[email protected]>
@deepskyblue86 deepskyblue86 force-pushed the kmod-configure-system branch from 5ac59b8 to 3032f57 Compare March 2, 2024 09:50
@FedeDP
Copy link
Contributor

FedeDP commented Mar 2, 2024

/milestone 0.15.0

@poiana poiana modified the milestones: TBD, 0.15.0 Mar 2, 2024
Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@poiana
Copy link
Contributor

poiana commented Mar 2, 2024

LGTM label has been added.

Git tree hash: def53456f4e4ae4e82212318b5fb75b13fead664

@FedeDP
Copy link
Contributor

FedeDP commented Mar 2, 2024

/unhold

@deepskyblue86
Copy link
Contributor Author

@gnosek /approve 😁?

Copy link
Contributor

@gnosek gnosek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤩

@poiana
Copy link
Contributor

poiana commented Mar 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepskyblue86, FedeDP, gnosek

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants