Skip to content

Conversation

@chr15p
Copy link

@chr15p chr15p commented May 24, 2022

kernel commit d56c0d45f0e27f814e87a1676b6bdccccbc252e9 changed the signature of the proc_create() function (used by simple-procfs-kmod.c) from taking an argument of type struct file_operations to taking a new struct, struct proc_ops. This change seems to have happened in the 5.6 kernel release so was not in RHEL8 but is now part of the RHEL9 kernel.

This causes simple-procfs-kmod.ko to fail to compile under RHEL9 with a message:

./include/linux/proc_fs.h:110:122: note: expected 'const struct proc_ops *' but argument is of type 'struct file_operations *'
110 | struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops);

This PR updates the code to allocate and populate a (very) basic proc_ops structure using the exisiting myread and mywrite functions, and use that as the argument to proc_create. It also adds a proc_lseek function stub which proc_ops mandates. Without this running the spkut utility causes a kernel panic (due to a null pointer dereference).

It wraps the new code in an #ifdef preprocessor directive that checks for the 5.6 kernel and uses the appropriate version of the code so the kmod will continue to compile on RHEL8 as before, only using the new struct for later kernels.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant