0

I am trying to test getname in a kernel module. My code for the hijacked system call looks like:

asmlinkage long (*real_open)(const char __user *, int, int);

struct filename *getname_filename;

asmlinkage long hijacked_open(const char __user *filename, int flags, int mode) {
    getname_filename = getname(filename);
    printk("Opened: %s", getname_filename->name);
    return real_open(filename, flags, mode);
}

The code compiles without any problems, but when I insert the module using insmod, I get the error Unknown symbol in module with AND without the printk line. But in /proc/kallsyms, I can find getname, so it IS exported. Why can't I use it and how can I use it?

I am using Ubuntu 16.04.

Melab
  • 2,594
  • 7
  • 30
  • 51
  • `But in /proc/kallsyms, I can find getname, so it IS exported.` - No, existing of the symbol in `/proc/kallsyms` doesn't mean that this symbol is available for *kernel module*. See that question: http://stackoverflow.com/questions/32965535/kernel-symbol-marked-with-t-in-proc-kallsyms-is-not-exported – Tsyvarev Nov 04 '16 at 18:14
  • @Tsyvarev And how does one determine if a symbol is exported or not? – Melab Nov 04 '16 at 19:26
  • See my answer to the referenced question. – Tsyvarev Nov 04 '16 at 19:32

0 Answers0