Bug 49851 - Missing NULL check of return value of dev_alloc_skb() in function ipw_packet_received_skb()
Summary: Missing NULL check of return value of dev_alloc_skb() in function ipw_packet_...
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: PCMCIA (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Alan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-01 09:16 UTC by RUC_Soft_Sec
Modified: 2012-12-22 09:26 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.39
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description RUC_Soft_Sec 2012-11-01 09:16:22 UTC
Function dev_alloc_skb() may return a NULL pointer, thus its return value shall be checked against NULL before used. But in function ipw_packet_received_skb(), the return value of dev_alloc_skb()(called at drivers/tty/ipwireless/network.c:349) is not checked. So an invalid memory access fault may be triggered when the return value (held by variable skb) of dev_alloc_skb() is used as a parameter of function skb_reserve() at line 350.
The related code snippets are as following.
ipw_packet_received_skb @@drivers/tty/ipwireless/network.c:349
349        skb = dev_alloc_skb(length + 4);
350        skb_reserve(skb, 2);
351        memcpy(skb_put(skb, length), data, length);

Generally, the return value of dev_alloc_skb() is checked against NULL before it is used. Take fwnet_pd_new(), a function in file drivers/firewire/net.c, for example.
fwnet_pd_new @@ drivers/firewire/net.c:400
400        new->skb = dev_alloc_skb(dg_size + net->hard_header_len + 15);
401        if (new->skb == NULL)
402                goto fail_w_fi;
403
404        skb_reserve(new->skb, (net->hard_header_len + 15) & ~15);
405        new->pbuf = skb_put(new->skb, dg_size);
406        memcpy(new->pbuf + frag_off, frag_buf, frag_len);

Thanks

RUC_Soft_Sec
Comment 1 Alan 2012-11-01 14:20:45 UTC
In general please copy any network driver bugs to netdev@vger.kernel.org to get them actioned.

In this case its ipwireless which happens to be half handled by me so I'll go deal with this one.
Comment 2 Florian Mickler 2012-12-22 09:26:43 UTC
A patch referencing this bug report has been merged in Linux v3.8-rc1:

commit d1519e23c2b3a518fb41daf3eceae43382433ceb
Author: Alan Cox <alan@linux.intel.com>
Date:   Thu Nov 1 16:45:49 2012 +0000

    ipwireless: don't oops if we run out of space

Note You need to log in before you can comment on or make changes to this bug.