Finding name of executable sending packet in a netfilter hook
I'm writing a kernel module that uses a netfilter hook to filter TCP packets and need to find out the path to the executable that is sending the packets. So far I have used the following approach but it prints names that are seemingly unrelated to the executables used ( /usr/lib/firefox/firefox , usr/bin/telnet.netkit and /usr/bin/wget ). pid_t pid = current->pid; struct path path; char buff[BUFF_LEN]; snprintf (buff, BUFF_LEN, "/proc/%d/exe", pid); if(!kern_path(buff, LOOKUP_FOLLOW, &path)) { struct dentry* procEntry = path.dentry; printk("Process: %s\n", procEntry->d_name.name); printk(