I know that as a general note files should not be read from kernelspace.
However I am interested in looking for keywords in certain files using a BPF program.
Ideally I would like the BPF program to be able to be attached to a Kprobe and when the event triggers I would like it to say read a file and count the instances that a keyword appears within the file.
Can anyone tell me if it is possible to read in a file like this, and perhaps offer some guidance as to how I might go about this.
Thanks, Sam
No, this is not possible.
But you can maybe achieve something close if you reconsider your design:
read
or write
system calls). You will not be able to access the file, but you may have access to the data read or written by your process, and count the instances of your keywords in there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.