-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[CWS] multiple fixes around runtime compiled constants #10908
Conversation
10dbb02
to
1802e22
Compare
08597bc
to
7882c6d
Compare
pkg/util/kernel/find_headers.go
Outdated
@@ -148,25 +141,50 @@ func validateHeaderDirs(hv Version, dirs []string) []string { | |||
log.Debugf("error validating %s: error validating headers version: %w", d, err) | |||
continue | |||
} | |||
if dirv != hv { | |||
|
|||
if !compareKernelVersionsRelaxed(dirv, hv) { |
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.
Do you have something I can read regarding this? We are using the actual LINUX_VERSION_CODE
constant from the version.h
file, which should contain the sublevel.
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.
Yes this is a bit strange but on OpenSUSE 15:
uname -a
= Linux opensuse15 5.3.18-59.37-default #1 SMP Mon Nov 22 12:29:04 UTC 2021 (d10168e) x86_64 x86_64 x86_64 GNU/Linux
>> cat /usr/src/linux-5.3.18-59.37-obj/x86_64/default/include/generated/uapi/linux/version.h
#define LINUX_VERSION_CODE 328466
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
>> cat /usr/include/linux/version.h
#ifdef __KERNEL__
#error "======================================================="
#error "You should not include /usr/include/{linux,asm}/ header"
#error "files directly for the compilation of kernel modules."
#error ""
#error "glibc now uses kernel header files from a well-defined"
#error "working kernel version (as recommended by Linus Torvalds)"
#error "These files are glibc internal and may not match the"
#error "currently running kernel. They should only be"
#error "included via other system header files - user space"
#error "programs should not directly include <linux/*.h> or"
#error "<asm/*.h> as well."
#error ""
#error "Since Linux 2.6, the kernel module build process has been"
#error "updated such that users building modules should not typically"
#error "need to specify additional include directories at all."
#error ""
#error "To build kernel modules, ensure you have the build environment "
#error "available either via the kernel-devel and kernel-<flavor>-devel "
#error "packages or a properly configured kernel source tree."
#error ""
#error "Then, modules can be built using:"
#error "make -C <path> M=$PWD"
#error ""
#error "For the currently running kernel there will be a symbolic "
#error "link pointing to the build environment located at "
#error "/lib/modules/$(uname -r)/build for use as <path>."
#error ""
#error "If you are seeing this message, your environment is "
#error "not configured properly. "
#error ""
#error "Please adjust the Makefile accordingly."
#error "======================================================="
#else
#define LINUX_VERSION_CODE 328448
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
Where 328466 = 5.3.18
and 328448 = 5.3.0
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.
OK. We originally didn't include /usr
as a kernel header directory, but it was added for Fedora. @ISauve perhaps we need to reexamine that decision, and see if there is an alternative directory.
I'm a little uncomfortable only being specific to major.minor matching, because there is no guarantee that kernel struct member offsets won't change in a sublevel version change.
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.
Let's keep /usr
and a full version check for now. If in the future we see some issues on OpenSUSE we'll find a better solution to this issue
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.
I say this because kconfig.h
is not in /usr
so it should be removed by the critical headers check
298b6a1
to
fb97d98
Compare
fb97d98
to
b2df5ef
Compare
What does this PR do?
This PR contains fixes for both the global kernel headers downloading mechanism and CWS specific usage around runtime compiled constants.
Regarding kernel headers downloading, this PR:
linux/types.h
, namelylinux/kconfig.h
and opens the door to add more critical file dependencies in the future/lib/modules
are not versioned with the full versionRegarding CWS specific code, this PR:
Motivation
Additional Notes
Possible Drawbacks / Trade-offs
Describe how to test/QA your changes
Reviewer's Checklist
Triage
milestone is set.team/..
label has been applied, if known.major_change
label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.changelog/no-changelog
label has been applied.qa/skip-qa
label is not applied.need-change/operator
andneed-change/helm
labels have been applied.