I am trying to program a kernel module that copy the elf of the process that called the module using ioctl to a buffer in the module.
So far i managed to get the location of the elf in the memory by using /proc/pid/exe but i need the size of the file in order to copy it to kernel space.
I also have access to the elf header of the mentioned file but i could figure a way to calculate the size using the information from the header.
Since i can't use functions like stat is there a way to calculate the mentioned file size when programming in kernel space?
The unique part of my question that i need to calculate it under the constraints that kernel programming impose such is the inability to use system calls such as stat