0

For my university project I'm doing a module which will allow or disallow a process to perform a system calls (e. g. A little loadable selinux). For now I nave code that controls syscalls. For each process I store a link to the structure which contains permissions config. However, now I've just hardcoded two configs: one is default (allow all) and another one is to allow everything except opening '/testfile'.

My question is how to load configs dynamically?

I have a parser for config files but I've read that accessing files from the kernel is bad idea.

How should I store configs and how should I load them?

JAL
  • 41,701
  • 23
  • 172
  • 300
Zelta
  • 754
  • 5
  • 14
  • Create a character device and read config lines and directives (i.e. "remove config") from it. A user-space program with sufficient privileges will read a config file from some place in the filesystem and pipe it down to your character device. – n. m. could be an AI Dec 18 '15 at 11:28

1 Answers1

1

I've read that reading files from the kernel is bad idea

Description of filp_open function in the kernel sources says:

This is the helper to open a file from kernelspace if you really have to. But in generally you should not do this, so please move along, nothing to see here..

So, if you need to load/store content of the file into/from the kernel module, then do that. But use appropriate functions, as described in that question.

Community
  • 1
  • 1
Tsyvarev
  • 60,011
  • 17
  • 110
  • 153