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/
>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
--
> >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()).
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
>> 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.
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
--
Jan Engelhardt wrote:
>>>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.
>
>
> 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
>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
--
| Alphagate Systems, http://alphagate.hopto.org/
| jengelh's site, http://jengelh.hopto.org/