Bug in using inet_lookup ()
Subsystems (2)
I suspected it could be that. However, can't see in ip_rcv the right portion that can help. Any further tip please?
Regards,
----- Message d'origine ----
Quoted 24 lines
De : Evgeniy Polyakov <[email protected]> À : Nj A <[email protected]>
Cc : [email protected]
Envoyé le : Mercredi, 14 Novembre 2007, 12h13mn 05s Objet : Re: Bug in usinginet_lookup()Quoted 5 lines · Nj A
/* The kernel TCP hashtable */
structinet_hashinfo__cacheline_alignedtcp_hashinfo= { .lhash_lock =__RW_LOCK_UNLOCKED(tcp_hashinfo.lhash_lock), .lhash_users =ATOMIC_INIT(0),
.lhash_wait =__WAIT_QUEUE_HEAD_INITIALIZER(tcp_hashinfo.lhash_wait),Quoted 8 lines
};
...
struct sock *sk;
structsk_buff*skb;
skb =alloc_skb(MAX_TCP_HEADER+ 15,GFP_KERNEL);
if (skb == NULL)
printk ("%s: Unable to allocate memory \n",__FUNCTION__);
sk =inet_lookup(&tcp_hashinfo,ip_src,src_port,ip_dst,dst_port,inet_iif(skb));
Quoted 3 lines
if (!sk)
...
This portion of code seems to cause the kernel to panic due to dereferencing a
Quoted 12 lines
NULL pointer.
Quoted 2 lines
Can anyone please tell me what is the error above? Best Regards,
Where exactly? Likely in
inet_iif(), since it dereferences dst (routing info), which is not presented after simplealloc_skb().
You have to setup skb correctly, check howip_rcv()does it.Signature · 2 lines
Evgeniy Polyakov
_____________________________________________________________________________
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
Quoted 2 lines · Nj A
I suspected it could be that. However, can't see in
ip_rcvthe right portion that can help. Any further tip please?
It is ip_rcv_finish() called from ip_rcv():
if (skb->dst == NULL) {
int err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos,
skb->dev);
if (unlikely(err)) {
if (err == -EHOSTUNREACH)
IP_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS);
else if (err == -ENETUNREACH)
IP_INC_STATS_BH(IPSTATS_MIB_INNOROUTES);
goto drop;
}
}So you will have to specify device, you got your skb via. Actually it is not exactly needed in some cases, you will need interface index (dev->ifindex). You can find socket by using that number instead of dereferencing dst.
Signature · 1 line
Evgeniy Polyakov