How to obtain process ID that created a packet
Hi,
Is there any way to catch REAL pid that generated a packet from 'struct sk_buff', 'struct sock', 'struct socket',
'struct file' or etc... ? direct/indirect ways are accepted.
Thank you!
__________________________________
Yahoo! for Good - Make a difference this year.
http://brand.yahoo.com/cybergivingweek2005/
Quoted 5 lines
Hi,
Is there any way to catch REAL pid that generated a packet from 'struct
sk_buff', 'struct sock', 'struct socket',
'struct file' or etc... ? direct/indirect ways are accepted.
The question is: when do you test for the PID? You would have to do it within send(), because anywhere else, you do not know. A socket may be shared among multiple processes (most simple way: fork()).
Jan Engelhardt
Quoted 3 lines
Quoted 3 lines
Hi,
Is there any way to catch REAL pid that generated a packet from 'struct
sk_buff', 'struct
sock', 'struct socket', 'struct file' or etc... ? direct/indirect ways are accepted.
Quoted 4 lines
The question is: when do you test for the PID? You would have to do it within
send(), because anywhere else, you do not know. A socket may be shared among multiple processes (most simple way:fork()).
I'm hooking in NF_IP_LOCAL_OUT of netfilter code using nf_register_hook() function.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Quoted 6 lines
Quoted 4 lines
The question is: when do you test for the PID? You would have to do it within
send(), because anywhere else, you do not know. A socket may be shared among multiple processes (most simple way:fork()).I'm hooking in
NF_IP_LOCAL_OUTof netfilter code usingnf_register_hook()function.
In sys_send(), I would have said you could use "current", but in netfilter I can't tell exactly whether it is going to work on SMP.
Check net/ipv4/netfilter/ipt_owner.c, it provides a way to match packets vs pids, but it's not easy to find out.
Jan Engelhardt
Quoted 4 lines · Jan Engelhardt
Quoted 4 lines
Quoted 3 lines
The question is: when do you test for the PID? You would have to do it within
send(), because anywhere else, you do not know. A socket may be shared among multiple processes (most simple way:fork()).
Quoted 8 lines
Quoted 1 line
I'm hooking in
NF_IP_LOCAL_OUTof netfilter code usingnf_register_hook()function.In
sys_send(), I would have said you could use "current", but in netfilter I can't tell exactly whether it is going to work on SMP.Check
net/ipv4/netfilter/ipt_owner.c, it provides a way to match packets vs pids, but it's not easy to find out.
In current 2.6 kernel, net/ipv4/netfilter/ipt_owner.c:checkentry() :
if (info->match & (IPT_OWNER_PID|IPT_OWNER_SID|IPT_OWNER_COMM)) {
printk("ipt_owner: pid, sid and command matching "
"not supported anymore\n");
return 0;
}So... even netfilter, breaking backward compatibility, does not support pid match anymore...
/mjt
Quoted 11 lines
In current 2.6 kernel, net/ipv4/netfilter/ipt_owner.c:checkentry() :
if (info->match & (IPT_OWNER_PID|IPT_OWNER_SID|IPT_OWNER_COMM)) { printk("ipt_owner: pid, sid and command matching " "not supported anymore\n"); return 0; }So... even netfilter, breaking backward compatibility, does not support pid match anymore...
Because they do not work on SMP. That's the reason they are disabled.
Jan Engelhardt
Signature · 2 lines
| Alphagate Systems, http://alphagate.hopto.org/ | jengelh's site, http://jengelh.hopto.org/