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): add sanity check for kmod and ebpf configure systems #2283

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions driver/bpf/configure/0__SANITY/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: GPL-2.0-only OR MIT
/*

Copyright (C) 2024 The Falco Authors.

This file is dual licensed under either the MIT or GPL 2. See MIT.txt
or GPL2.txt for full copies of the license.

*/

/*
* Check that the build system is sane.
*/

#include "../../quirks.h"
#include "../../ppm_events_public.h"
#include "../../types.h"

BPF_PROBE("sanity/", sanity, sanity_args) {
return 0;
}

char __license[] __bpf_section("license") = "Dual MIT/GPL";
12 changes: 11 additions & 1 deletion driver/bpf/configure/Makefile.inc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ ifeq ($(HAS_@CONFIGURE_MODULE@),0)
$(info [configure-bpf] Setting HAS_@CONFIGURE_MODULE@ flag)
KBUILD_CPPFLAGS += -DHAS_@CONFIGURE_MODULE@
else
HAS_@CONFIGURE_MODULE@_OUT := $(shell cat $(MODULE_MAKEFILE_DIR)/build.log)
HAS_@CONFIGURE_MODULE@_OUT1 := $(shell cat $(MODULE_MAKEFILE_DIR)/build.log | sed -n ':a;N;$$$!ba;s/\n/@@NEWLINE@@/g;P')
HAS_@CONFIGURE_MODULE@_OUT := $(subst @@NEWLINE@@,$(newline),$(HAS_@CONFIGURE_MODULE@_OUT1))
$(info [configure-bpf] Build output for HAS_@CONFIGURE_MODULE@:)
$(info [configure-bpf] $(HAS_@CONFIGURE_MODULE@_OUT))
endif

ifeq ('@CONFIGURE_MODULE@','0__SANITY')
ifeq ($(HAS_@CONFIGURE_MODULE@),0)
$(info [configure-bpf] Build system is sane)
else
$(info [configure-bpf] Build system is broken, please see above errors)
$(error The build system is broken, please see above errors)
endif
endif
26 changes: 26 additions & 0 deletions driver/configure/0__SANITY/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*

Copyright (C) 2023 The Falco Authors.

This file is dual licensed under either the MIT or GPL 2. See MIT.txt
or GPL2.txt for full copies of the license.

*/

/*
* Check that the build environment is sane
*/

#include <linux/module.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("the Falco authors");

static int empty_init(void) {
return 0;
}

static void empty_exit(void) {}

module_init(empty_init);
module_exit(empty_exit);
12 changes: 11 additions & 1 deletion driver/configure/Makefile.inc.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ ifeq ($(HAS_@CONFIGURE_MODULE@),0)
$(info [configure-kmod] Setting HAS_@CONFIGURE_MODULE@ flag)
ccflags-y += -DHAS_@CONFIGURE_MODULE@
else
HAS_@CONFIGURE_MODULE@_OUT := $(shell cat $(MODULE_MAKEFILE_DIR)/build.log)
HAS_@CONFIGURE_MODULE@_OUT1 := $(shell cat $(MODULE_MAKEFILE_DIR)/build.log | sed -n ':a;N;$$$!ba;s/\n/@@NEWLINE@@/g;P')
HAS_@CONFIGURE_MODULE@_OUT := $(subst @@NEWLINE@@,$(newline),$(HAS_@CONFIGURE_MODULE@_OUT1))
$(info [configure-kmod] Build output for HAS_@CONFIGURE_MODULE@:)
$(info [configure-kmod] $(HAS_@CONFIGURE_MODULE@_OUT))
endif

ifeq ('@CONFIGURE_MODULE@','0__SANITY')
ifeq ($(HAS_@CONFIGURE_MODULE@),0)
$(info [configure-kmod] Build system is sane)
else
$(info [configure-kmod] Build system is broken, please see above errors)
$(error The build system is broken, please see above errors)
endif
endif
Loading