From: "Serge Kuznetsov" <sk@deeptown.org>
To: <linux-kernel@vger.kernel.org>
Cc: <linux-net@vger.kernel.org>
Subject: [NET] Possible bug in netif_receive_skb
Date: Thu, 14 Nov 2002 12:12:07 -0500 [thread overview]
Message-ID: <015301c28c00$f6287390$34c096cd@toybox> (raw)
LeavesHi guys,
I think code for netif_receive_skb have a bug:
int netif_receive_skb(struct sk_buff *skb)
{
struct packet_type *ptype, *pt_prev;
int ret = NET_RX_DROP;
unsigned short type = skb->protocol;
/* some code skipped */
pt_prev = NULL;
for (ptype = ptype_all; ptype; ptype = ptype->next) {
if (!ptype->dev || ptype->dev == skb->dev) {
if (pt_prev) {
if (!pt_prev->data) {
ret = deliver_to_old_ones(pt_prev,
skb, 0);
} else {
atomic_inc(&skb->users);
ret = pt_prev->func(skb, skb->dev,
pt_prev);
}
/* Would be great to add this check here */
if ( ( ret == NET_RX_DROP ) || ( ret == NET_RX_BAD ) )
{
/* Check here if skb was freed in pt_prev_>func(), if not - free it */
...
return ret;
}
}
pt_prev = ptype;
}
}
First of all, just imagine if we have only on TAP attached to ptype_all.
In this case this TAP won't be called, because of pt_prev. ( BTW, why pt_prev, why we shouldn't call the function of first chain-link? )
In second case, imagine if we have three TAPs attached to ptype_all, and second TAP desided to be an universal firewall ( third one is just ordinar TAP ). If that second TAP will call kfree_skb ( skb ), and will return the code NET_RX_DROP or NET_RX_BAD, that return code will be overwritten by third TAP, which will get freed skb, and possible panic.
The same issue for the bottom half of the function ( for ptype_base ).
what if we will add the check for it? Like I added above.
PS: BTW, how to check if skb has been freed ? I didn't found any function for it. Is it possible to add the flag, like skb->freed ?
All the Best!
Serge.
next reply other threads:[~2002-11-14 17:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-14 17:12 Serge Kuznetsov [this message]
2002-11-14 17:26 ` David S. Miller
2002-11-14 20:15 ` Serge Kuznetsov
2002-11-14 18:00 ` Arnaldo Carvalho de Melo
2002-11-15 14:10 ` Serge Kuznetsov
2002-11-14 21:05 Serge Kuznetsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='015301c28c00$f6287390$34c096cd@toybox' \
--to=sk@deeptown.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®