Skip to content

Commit

Permalink
fix(driver): use configure system to check for mnt_idmap for fs
Browse files Browse the repository at this point in the history
Kernel 6.3 changed fs functions to `struct mnt_idmap`.
Use the configure system in place of the version check to support driver
build on RHEL 9 (namely 5.14.0-547.el9.x86_64)

Signed-off-by: Angelo Puglisi <[email protected]>
  • Loading branch information
deepskyblue86 authored and poiana committed Jan 20, 2025
1 parent 02ac6f6 commit cb3e5cf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions driver/configure/FS_MNT_IDMAP/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright (C) 2025 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 fs function wants mnt_idmap
* See linux 6.3 changes:
* - https://github.com/torvalds/linux/commit/abf08576afe3
* - https://github.com/torvalds/linux/commit/01beba7957a2
*/

#include <linux/module.h>
#include <linux/fs.h>

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

static int fs_mnt_idmap_init(void) {
struct mnt_idmap *idmap = NULL;
const struct inode *inode = NULL;
inode_owner_or_capable(idmap, inode);
return 0;
}

static void fs_mnt_idmap_exit(void) {}

module_init(fs_mnt_idmap_init);
module_exit(fs_mnt_idmap_exit);
4 changes: 2 additions & 2 deletions driver/ppm_fillers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ int f_proc_startupdate(struct event_filler_arguments *args) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
if(file_inode(exe_file) != NULL) {
/* Support exe_writable */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
#ifdef HAS_FS_MNT_IDMAP
exe_writable |= (file_permission(exe_file, MAY_WRITE | MAY_NOT_BLOCK) == 0);
exe_writable |=
inode_owner_or_capable(file_mnt_idmap(exe_file), file_inode(exe_file));
Expand Down Expand Up @@ -7754,7 +7754,7 @@ int f_sched_prog_exec(struct event_filler_arguments *args) {
if(exe_file != NULL) {
if(file_inode(exe_file) != NULL) {
/* Support exe_writable */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
#ifdef HAS_FS_MNT_IDMAP
exe_writable |= (file_permission(exe_file, MAY_WRITE | MAY_NOT_BLOCK) == 0);
exe_writable |= inode_owner_or_capable(file_mnt_idmap(exe_file), file_inode(exe_file));
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0)
Expand Down

0 comments on commit cb3e5cf

Please sign in to comment.